@shadowclone/cli 0.0.15 → 0.0.17
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 +1 -1
- package/README.md +34 -31
- package/dist/_.._/web/client/index.html +28 -38
- package/dist/shadowclone.js +1327 -524
- package/dist/web/{index-dzztba9n.css → index-ntyv9x8a.css} +1 -1
- package/dist/web/index-twq4tm3n.js +135 -0
- package/evals.md +117 -267
- package/package.json +9 -3
- package/plugins/shadowclone/.claude-plugin/plugin.json +1 -1
- package/plugins/shadowclone/.codex-plugin/plugin.json +1 -1
- package/plugins/shadowclone/plugin.json +1 -1
- package/skills/design-deep-modules/SKILL.md +2 -0
- package/skills/diagnose-before-editing/SKILL.md +2 -0
- package/skills/prove-regression-tests/SKILL.md +2 -0
- package/skills/research-primary-sources/SKILL.md +2 -0
- package/skills/resolve-conflicts-by-intent/SKILL.md +2 -0
- package/skills/scope-confirmed-changes/SKILL.md +2 -0
- package/skills/shadowclone-work/SKILL.md +26 -20
- package/skills/testing-first/SKILL.md +2 -0
- package/skills/testing-risk-based/SKILL.md +2 -0
- package/skills/typescript-type-safety/SKILL.md +2 -0
- package/skills/verify-and-review/SKILL.md +2 -0
- package/dist/web/index-p75d8wn2.js +0 -134
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
function Ct(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 Ln(e,t="|"){return e.map((r)=>jn(r)).join(t)}function Tt(e,t){if(typeof t==="bigint")return t.toString();return t}class Cs{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 wr(e){return new Cs(e)}function Ts(e){return e===null||e===void 0}function kr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ns(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 he(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function zr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ce(e){return zr(e._zod.def)??e._zod.def.shape}function Rs(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return he(this,t,n),n},enumerable:!0,configurable:!0})}function Ms(e,t,r){if(t in e)he(e,t,r);else e[t]=r}function et(e,t,r,n){let o=Ce(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)Rs(e,i,()=>{let a=t._zod.def.shape[i];return n?n(a,i):a});else Ms(e,i,n?n(s.value,i):s.value)}}function Id(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)Rs(e,r,()=>t[r]);else Ms(e,r,n.value)}}function ae(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Ls(e){return JSON.stringify(e)}function Ds(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Dn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function At(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Bs=wr(()=>{if(ne.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function tt(e){if(At(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(At(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Bn(e){if(tt(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 js=new Set(["string","number","symbol"]);function ft(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ve(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function z(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 jn(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Fs(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var $r=(()=>({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]}))(),Fn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Pd(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 et(i,e,Sr(e,t)),ve(e,ae(r,{shape:i,checks:[]}))}function Sr(e,t){let r=Ce(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 Zd(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(Sr(e,t)),s={};return et(s,e,Reflect.ownKeys(Ce(e)).filter((a)=>!i.has(a))),ve(e,ae(r,{shape:s,checks:[]}))}function Ed(e,t){if(!tt(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Ce(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 ve(e,ae(e._zod.def,{shape:Us(e,t)}))}function Us(e,t){let r={};return et(r,e,Reflect.ownKeys(Ce(e))),Id(r,t),r}function Od(e,t){if(!tt(t))throw Error("Invalid input to safeExtend: expected a plain object");return ve(e,ae(e._zod.def,{shape:Us(e,t)}))}function Ad(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={};et(r,e,Reflect.ownKeys(Ce(e))),et(r,t,Reflect.ownKeys(Ce(t)));let n=ae(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ve(e,n)}function qs(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(Sr(t,r)):void 0,c={};return et(c,t,Reflect.ownKeys(Ce(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),ve(t,ae(t._zod.def,{shape:c,checks:[]}))}function Cd(e,t,r){let n=r?new Set(Sr(t,r)):void 0,o={};return et(o,t,Reflect.ownKeys(Ce(t)),(i,s)=>n&&!n.has(s)?i:new e({type:"nonoptional",innerType:i})),ve(t,ae(t._zod.def,{shape:o}))}function _e(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 Vs(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 qe(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Ot(e){return typeof e==="string"?e:e?.message}function Un(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function we(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:Ot(e.inst?._zod.def?.error?.(e))??Ot(i?.(e))??Ot(t?.error?.(e))??Ot(r.customError?.(e))??Ot(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 Td=/[\uD800-\uDBFF]/;function Ir(e){let t=e.length;if(!Td.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 Pr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Js(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 rt(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function Hs(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else Nd(e,r,n.value)}}function Te(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Zr(e,t,r){return Te(e,t,r,!1)}function Gs(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Te(this,r,n(this))},set(o){Te(this,r,o)}})}return t}function Nd(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Te(this,t,r.bind(this))},set(n){Te(this,t,n)}})}function Rd(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Mn,Ue=!1,Md={configurable:!0,get(){Ue=!0;return}};function N(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&Mn!==e._zod){Mn=void 0;return}Mn=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Md);let o=Ue;Ue=!1;try{let i=r(this);if(Ue)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return Ue=Ue||o,i}catch(i){throw delete this[t],Ue=Ue||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Ld(e,t,r,n){let o=Rd(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 Dd="~constantCatch";function Ks(e){let t=()=>e;return t[Dd]=!0,t}var Ys;var qn={value:void 0,enumerable:!1},Xs="captureStackTrace"in Error?Error:null;function Bd(e){let t=Xs;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return Xs=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function g(e,t,r,n){let o={};function i(d){this.def=d,this.constr=p,this.traits=new Set}i.prototype=o;let s=r,a=s&&new WeakSet;function c(d,f){if(!d._zod){qn.value=new i(f);try{Object.defineProperty(d,"_zod",qn)}finally{qn.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,f),a){let x=Object.getPrototypeOf(d),_=d._zod.constr.prototype,v=x;while(v&&v!==_)v=Object.getPrototypeOf(v);let P=v??x;if(!a.has(P))a.add(P),Hs(P,s)}let m=p.prototype;for(let x in m){if(!Object.prototype.hasOwnProperty.call(m,x))continue;if(!(x in d))d[x]=m[x].bind(d)}}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function p(d){let f=n?.Parent?Bd(l):this;c(f,d);let m=f._zod.deferred;if(m){for(let _ of m)_();f._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(f);return f}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(d)=>{if(n?.Parent&&d instanceof n.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class ke extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Nt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Ys=globalThis).__zod_globalConfig??(Ys.__zod_globalConfig={});var ne=globalThis.__zod_globalConfig;function ce(e){if(e)Object.assign(ne,e);return ne}function jd(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Tt,2)),e.message}function Fd(e){this._zod.message=e}var Ud={get:jd,set:Fd,enumerable:!0,configurable:!0},Jn={value:void 0,enumerable:!1},Ws=new WeakSet([Object.prototype,Error.prototype]),Qs=(e,t)=>{e.name="$ZodError",Jn.value=t,Object.defineProperty(e,"issues",Jn),Jn.value=void 0,Object.defineProperty(e,"message",Ud);let r=Object.getPrototypeOf(e);if(!Ws.has(r))Ws.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})}})},ea=g("$ZodError",Qs),Gx=g("$ZodError",Qs,void 0,{Parent:Error});function qd(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 ta(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)qd(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function ra(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],p=u===a.length-1;if(l==="_errors"){if(p)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 d=c[l];if(p)d._errors.push(t(s));c=d,u++}}}};return n(e),r}function Er(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Or=(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 ke;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>we(u,s,ce())));throw Dn(c,i?.callee??t),c}return a.value};return t};var Ar=(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)=>we(u,s,ce())));throw Dn(c,i?.callee??t),c}return a.value};return t};var Cr=(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 ke;return i.issues.length?na(e,i.issues,o):{success:!0,data:i.value}};function na(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>we(o,r,ce()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var Tr=(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?na(e,i.issues,o):{success:!0,data:i.value}};var Vd=Symbol.for("zod.compile.invalid"),Jd=Symbol.for("zod.compile.fallback"),Hn=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Vd)return!0;if(n.definite===!0&&r===void 0)return!1}return Hd(e,t,r)};function Hd(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)n[Jd]=!0,i=o({value:t,issues:[]},n);else i=e._zod.run({value:t,issues:[]},n);if(i instanceof Promise)throw new ke;return i.issues.length===0}var Gn=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},oa=(e)=>{let t=Or(e),r=(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(n,o,a,Er(r,s))};return r};var ia=(e)=>{let t=Or(e),r=(n,o,i,s)=>t(n,o,i,Er(r,s));return r};var sa=(e)=>{let t=Ar(e),r=async(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Er(r,s))};return r};var aa=(e)=>{let t=Ar(e),r=async(n,o,i,s)=>await t(n,o,i,Er(r,s));return r};var ca=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Cr(e)(t,r,o)};var ua=(e)=>(t,r,n)=>Cr(e)(t,r,n);var la=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Tr(e)(t,r,o)};var pa=(e)=>async(t,r,n)=>Tr(e)(t,r,n);var da=/^[cC][0-9a-z]{6,}$/,fa=/^[0-9a-z]+$/,ma=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ha=/^[0-9a-vA-V]{20}$/,ga=/^[A-Za-z0-9]{27}$/,xa=/^[a-zA-Z0-9_-]{21}$/;function ya(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ba=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var va=/^([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})$/,Yn=(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 _a=/^(?:[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 Gd="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function wa(){return new RegExp(Gd,"u")}var ka=/^(?:(?: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])$/,za=/^(([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 $a=/^((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])$/,Sa=/^(([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])$/,Ia=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pa=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Za=/^https?$/,Ea=/^\+[1-9]\d{6,14}$/;var Oa="(?:(?:\\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 Kd(e){return new RegExp(`^${e}$`)}var Aa=Kd(Oa);function Kn(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 Ca(e){return new RegExp(`^${Kn(e)}$`)}function Ta(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Kn({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Kn({precision:e.precision})}`:r;return new RegExp(`^${Oa}T(?:${n})$`)}var Na=/^[\s\S]{0,}$/;var Xn=/^-?\d+$/,Rt=/^-?\d+(?:\.\d+)?$/,Ra=/^(?:true|false)$/i;var Ma=/^[^A-Z]*$/,La=/^[^a-z]*$/;var X=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Wn=(e)=>{let t=e.value;return!Ts(t)&&t.length!==void 0},Nr={number:"number",bigint:"bigint",object:"date"},Qn=g("$ZodCheckLessThan",(e,t)=>{X.init(e,t);let r=Nr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:Nr[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})}}),eo=g("$ZodCheckGreaterThan",(e,t)=>{X.init(e,t);let r=Nr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:Nr[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})}}),Da=g("$ZodCheckMultipleOf",(e,t)=>{X.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):Ns(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})}}),Ba=g("$ZodCheckNumberFormat",(e,t)=>{X.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=$r[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 ja=g("$ZodCheckMaxLength",(e,t)=>{var r;X.init(e,t),(r=e._zod.def).when??(r.when=Wn),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>t.maximum?Ir(o):i)<=t.maximum)return;let a=Pr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Fa=g("$ZodCheckMinLength",(e,t)=>{var r;X.init(e,t),(r=e._zod.def).when??(r.when=Wn),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>=t.minimum&&i<t.minimum*2?Ir(o):i)>=t.minimum)return;let a=Pr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ua=g("$ZodCheckLengthEquals",(e,t)=>{var r;X.init(e,t),(r=e._zod.def).when??(r.when=Wn),e._zod.check=(n)=>{let o=n.value,i=o.length,s=typeof o==="string"&&i>=t.length&&i<=t.length*2?Ir(o):i;if(s===t.length)return;let a=Pr(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})}}),Lt=g("$ZodCheckStringFormat",(e,t)=>{var r,n;if(X.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=()=>{})}),qa=g("$ZodCheckRegex",(e,t)=>{Lt.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})}}),Va=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ma),Lt.init(e,t)}),Ja=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=La),Lt.init(e,t)}),Ha=g("$ZodCheckIncludes",(e,t)=>{X.init(e,t);let r=ft(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})}}),Ga=g("$ZodCheckStartsWith",(e,t)=>{X.init(e,t);let r=new RegExp(`^${ft(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})}}),Ka=g("$ZodCheckEndsWith",(e,t)=>{X.init(e,t);let r=new RegExp(`.*${ft(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 Ya=g("$ZodCheckOverwrite",(e,t)=>{X.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class to{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 Wa={major:4,minor:6,patch:5};var D=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Wa;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=_e(a),p;for(let d of c){if(d._zod.def.when){if(Vs(a))continue;if(!d._zod.def.when(a))continue}else if(l)continue;let f=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new ke;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await m,a.issues.length===f)return;if(Un(a.issues,f,e),!l)l=_e(a,f)});else{if(a.issues.length===f)continue;if(Un(a.issues,f,e),!l)l=_e(a,f)}}if(p)return p.then(()=>a);return a},s=(a,c,u)=>{if(_e(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ke;return l.then((p)=>e._zod.parse(p,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((p)=>s(p,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ke;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return Zr(this,"~standard",no(this))},set "~standard"(e){Te(this,"~standard",e)}}),uc=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>we(r,t,ce()))}:{value:e.value};async function Yd(e,t){let r={async:!0};return uc(await e._zod.run({value:t,issues:[]},r),r)}function no(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return uc(n,r)}catch(n){}return Yd(e,t)},vendor:"zod",version:1}}var Dr=g("$ZodString",(e,t)=>{D.init(e,t),e._zod.pattern=t.pattern??Na,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}}),M=g("$ZodStringFormat",(e,t)=>{Lt.init(e,t),Dr.init(e,t)}),lc=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=va),M.init(e,t)}),pc=g("$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=Yn(n))}else t.pattern??(t.pattern=Yn());M.init(e,t)}),dc=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=_a),M.init(e,t)}),fc=1,Mr=2;function mc(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Xd(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return mc(e)||Mr;return Wd(e,t)}function Wd(e,t){if(!t.normalize&&t.protocol?.source===Za.source&&!/^https?:\/\//i.test(e))return fc;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??Mr}return new URL(e)}catch{return Mr}}var Qd=/[\t\n\r]/g;function Qa(e){return e.replace(Qd,"")}function ef(e,t){return t.lastIndex=0,t.test(e.hostname)}function tf(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var hc=g("$ZodURL",(e,t)=>{M.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=Xd(n,t);if(o===fc){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Mr){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Qa(n);return}if(t.hostname&&!ef(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&&!tf(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:Qa(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),gc=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=wa()),M.init(e,t)}),xc=g("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?xa:ya(t.length)),M.init(e,t)}),yc=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=da),M.init(e,t)}),bc=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=fa),M.init(e,t)}),vc=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ma),M.init(e,t)}),_c=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ha),M.init(e,t)}),wc=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ga),M.init(e,t)}),kc=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ta(t)),M.init(e,t)}),zc=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Aa),M.init(e,t)}),$c=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ca(t)),M.init(e,t)}),Sc=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ba),M.init(e,t)}),Ic=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ka),M.init(e,t)}),rf=/^[0-9a-fA-F:.]+$/;function Pc(e){if(!rf.test(e))return!1;return mc(`http://[${e}]`)}var Zc=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=za),M.init(e,t),e._zod.check=(r)=>{if(!Pc(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var Ec=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=$a),M.init(e,t)});function nf(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 Pc(r)}var Oc=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Sa),M.init(e,t),e._zod.check=(r)=>{if(!nf(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Ac(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 oo=/^[0-9a-zA-Z+/]*={0,2}$/,Cc=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=oo),M.init(e,t),e._zod.check=(r)=>{if(Ac(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Br=/^[A-Za-z0-9_-]*$/;function of(e){if(!Br.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ac(r)}var Tc=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Br),M.init(e,t),e._zod.check=(r)=>{if(of(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Nc=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ea),M.init(e,t)});function sf(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 Rc=g("$ZodJWT",(e,t)=>{M.init(e,t),e._zod.check=(r)=>{if(sf(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var io=g("$ZodNumber",(e,t)=>{D.init(e,t),e._zod.pattern=Rt,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}}),Mc=g("$ZodNumberFormat",(e,t)=>{Ba.init(e,t),io.init(e,t)}),Lc=g("$ZodBoolean",(e,t)=>{D.init(e,t),e._zod.pattern=Ra,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 Dc=g("$ZodUnknown",(e,t)=>{D.init(e,t),e._zod.parse=(r)=>r}),Bc=g("$ZodNever",(e,t)=>{D.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function ec(e,t,r){if(e.issues.length)t.issues.push(...qe(r,e.issues));t.value[r]=e.value}var jc=g("$ZodArray",(e,t)=>{D.init(e,t);let r=ne.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((p)=>ec(p,n,c)));else if(ec(l,n,c),a&&l.issues.length!==0&&_e(l))break}if(s.length)return Promise.all(s).then(()=>n);return n}});function Lr(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(...qe(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 af=[];function Fc(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:af,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=Fs(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Uc(e,t,r,n,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:p,optout:d}=u,f=0;for(let m in t){if(s&&r.issues.length!==f){if(_e(r,f))break;f=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){if(l==="never")a.push(m);continue}if(l==="never"){a.push(m);continue}let x=u.run({value:t[m],issues:[]},n);if(x instanceof Promise)e.push(x.then((_)=>Lr(_,r,m,t,p,d)));else Lr(x,r,m,t,p,d)}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 cf=g("$ZodObject",(e,t)=>{D.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=wr(()=>Fc(t));N(e,"propValues",(u)=>{let l=u.def.shape,p={};for(let d in l){let f=l[d]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(p,d))he(p,d,new Set);for(let m of f.values)p[d].add(m);if(f.optin!==void 0)p[d].add(void 0)}}return p});let i=At,s=t.catchall,a,c=ne.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let p=u.value;if(!i(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let d=[],f=a.shape,m=l?.abortEarly,x=u.issues.length;for(let _ of a.allKeys){if(m&&u.issues.length!==x){if(_e(u,x))break;x=u.issues.length}if(_==="__proto__")continue;let v=f[_],P=v._zod.optin,L=v._zod.optout,j=v._zod.run({value:p[_],issues:[]},l);if(j instanceof Promise)d.push(j.then((T)=>Lr(T,u,_,p,P,L)));else Lr(j,u,_,p,P,L)}if(!s)return d.length?Promise.all(d).then(()=>u):u;return Uc(d,p,u,l,o.value,e,m===!0)}}),qc=g("$ZodObjectJIT",(e,t)=>{cf.init(e,t);let r=e._zod.parse,n=wr(()=>Fc(t)),o=ne.memoizer,i=(f)=>{let m=n.value,x=m.symbolKeys,_=new to(["payload","ctx"],{shape:f,inst:e,memo:o,syms:x}),v=(T)=>`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`,P=(T,O)=>`
|
|
6
|
+
let ${T}_ab = false;
|
|
7
|
+
for (let i = 0; i < ${T}.issues.length; i++) {
|
|
8
|
+
const iss = ${T}.issues[i];
|
|
9
|
+
iss.path = iss.path ? [${O}, ...iss.path] : [${O}];
|
|
10
|
+
payload.issues.push(iss);
|
|
11
|
+
if (iss.continue !== true) ${T}_ab = true;
|
|
12
|
+
}
|
|
13
|
+
if (${T}_ab && ctx && ctx.abortEarly) {
|
|
14
|
+
payload.value = newResult;
|
|
15
|
+
return payload;
|
|
16
|
+
}`;_.write("const input = payload.value;");let L=Object.create(null),j=0;for(let T of m.allKeys)L[T]=`key_${j++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let T of m.allKeys){if(T==="__proto__")continue;let O=L[T],G=typeof T==="symbol"?`syms[${x.indexOf(T)}]`:Ls(T),je=`${G} in input`,Qe=f[T],Fe=Qe?._zod?.optin,_r=Fe!==void 0,Tn=Qe?._zod?.optout==="optional";if(_.write(`const ${O} = ${v(G)};`),_r&&Tn){let Nn=Fe==="optional"?`${O}_present`:`${O}.value !== undefined || ${O}_present`;_.write(`
|
|
17
|
+
const ${O}_present = ${je};
|
|
18
|
+
if (!${O}.issues.length || ${O}_present) {
|
|
19
|
+
if (${O}.issues.length) {${P(O,G)}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (${Nn}) {
|
|
23
|
+
newResult[${G}] = ${O}.value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
`)}else if(!_r)_.write(`
|
|
28
|
+
const ${O}_present = ${je};
|
|
29
|
+
if (${O}.issues.length) {${P(O,G)}
|
|
30
|
+
}
|
|
31
|
+
if (!${O}_present && !${O}.issues.length) {
|
|
32
|
+
payload.issues.push({
|
|
33
|
+
code: "invalid_type",
|
|
34
|
+
expected: "nonoptional",
|
|
35
|
+
input: undefined,
|
|
36
|
+
path: [${G}]
|
|
37
|
+
});
|
|
38
|
+
if (ctx && ctx.abortEarly) {
|
|
39
|
+
payload.value = newResult;
|
|
40
|
+
return payload;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (${O}_present) {
|
|
45
|
+
newResult[${G}] = ${O}.value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
`);else if(_.write(`
|
|
49
|
+
if (${O}.issues.length) {${P(O,G)}
|
|
50
|
+
}
|
|
51
|
+
`),Fe==="defaulted")_.write(`newResult[${G}] = ${O}.value;`);else _.write(`
|
|
52
|
+
if (${O}.value !== undefined || ${je}) {
|
|
53
|
+
newResult[${G}] = ${O}.value;
|
|
54
|
+
}
|
|
55
|
+
`)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()},s,a=At,c=!ne.jitless,l=c&&Bs.value,p=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=n.value);let x=f.value;if(!a(x))return f.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),f;if(c&&l&&m?.async===!1&&m.jitless!==!0){if(!s)s=i(t.shape);if(f=s(f,m),!p)return f;return Uc([],x,f,m,d,e,m?.abortEarly===!0)}return r(f,m)}});function tc(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)=>!_e(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)=>we(s,n,ce())))}),t}var Vc=g("$ZodUnion",(e,t)=>{D.init(e,t),N(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),N(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),N(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}),N(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)=>kr(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 tc(s,n,e,o);return Promise.all(s).then((a)=>tc(a,n,e,o))}});var Jc=g("$ZodIntersection",(e,t)=>{D.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])=>rc(r,c,u));return rc(r,i,s)}});function ro(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(tt(e)&&tt(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=ro(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=ro(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 rc(e,t,r){let n=new Map,o,i=new Map,s=(u,l)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let d=String(u.path[0]);if(!i.has(d))i.set(d,u);p=[d]}else return!1;for(let d of p){if(!n.has(d))n.set(d,{});n.get(d)[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=ro(t.value,r.value);if(!c.valid){if(_e(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Hc=g("$ZodRecord",(e,t)=>{D.init(e,t);let r=ne.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!tt(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 p=t.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((m)=>we(m,o,ce())),input:l,path:[l],inst:e});continue}let d=p.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:i[l],issues:[]},o);if(f instanceof Promise)s.push(f.then((m)=>{if(m.issues.length)n.issues.push(...qe(l,m.issues));n.value[d]=m.value}));else{if(f.issues.length)n.issues.push(...qe(l,f.issues));n.value[d]=f.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"&&Rt.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)l=m}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((m)=>we(m,o,ce())),input:u,path:[u],inst:e});continue}let d=l.value;if(d==="__proto__")continue;let f=t.valueType._zod.run({value:i[u],issues:[]},o);if(f instanceof Promise)s.push(f.then((m)=>{if(m.issues.length)n.issues.push(...qe(u,m.issues));n.value[d]=m.value}));else{if(f.issues.length)n.issues.push(...qe(u,f.issues));n.value[d]=f.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 Gc=g("$ZodEnum",(e,t)=>{D.init(e,t);let r=Ct(t.entries),n=new Set(r);e._zod.values=n,N(e,"pattern",(o)=>{let i=Ct(o.def.entries).filter((s)=>js.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>ft(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 Kc=g("$ZodTransform",(e,t)=>{D.init(e,t),e._zod.optin="optional",ne.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Nt(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 ke;return r.value=o,r}});function nc(e,t){return e.value=t.issues.length?void 0:t.value,e}var so=g("$ZodOptional",(e,t)=>{D.init(e,t),N(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",N(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),N(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${kr(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)=>nc(r,i));return nc(r,o)}return t.innerType._zod.run(r,n)}}),Yc=g("$ZodExactOptional",(e,t)=>{so.init(e,t),N(e,"values",(r)=>r.def.innerType._zod.values),N(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Xc=g("$ZodNullable",(e,t)=>{D.init(e,t),N(e,"optin",(r)=>r.def.innerType._zod.optin),N(e,"optout",(r)=>r.def.innerType._zod.optout),N(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${kr(n.source)}|null)$`):void 0}),N(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)}}),Wc=g("$ZodDefault",(e,t)=>{D.init(e,t),e._zod.optin="defaulted",N(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)=>oc(i,t));return oc(o,t)}});function oc(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Qc=g("$ZodPrefault",(e,t)=>{D.init(e,t),e._zod.optin="defaulted",N(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)}}),eu=g("$ZodNonOptional",(e,t)=>{D.init(e,t),N(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)=>ic(i,e));return ic(o,e)}});function ic(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 sc(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)=>we(o,n,ce()))},input:e.value}),e}var tu=g("$ZodCatch",(e,t)=>{D.init(e,t),N(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),N(e,"optout",(r)=>r.def.innerType._zod.optout),N(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)=>sc(r,i,t,n));return sc(r,o,t,n)}});var ru=g("$ZodPipe",(e,t)=>{D.init(e,t),N(e,"values",(r)=>r.def.in._zod.values),N(e,"optin",(r)=>r.def.in._zod.optin),N(e,"optout",(r)=>r.def.out._zod.optout),N(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)=>Rr(s,t.in,n));return Rr(i,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>Rr(i,t.out,n));return Rr(o,t.out,n)}});function Rr(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 nu=g("$ZodReadonly",(e,t)=>{D.init(e,t),N(e,"propValues",(r)=>r.def.innerType._zod.propValues),N(e,"values",(r)=>r.def.innerType._zod.values),N(e,"optin",(r)=>r.def.innerType?._zod?.optin),N(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(ac);return ac(o)}});function ac(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var ou=g("$ZodCustom",(e,t)=>{X.init(e,t),D.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)=>cc(i,r,n,e));cc(o,r,n,e);return}});function cc(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(rt(o))}}class su extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var co="~memo",iu=[];function au(e){return e!==null&&typeof e==="object"}function ao(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var cu=new WeakMap,Dt=0,Ur=1,Bt=2;function qr(e,t,r){let n=cu.get(e);if(n!==void 0)return n?Bt:Dt;if(t.has(e))return Bt;t.add(e);let o=Dt,i=(l)=>{if(o!==Bt&&l?._zod){let p=qr(l,t,r);if(p>o)o=p}},s=(l,p)=>{let d=Dt;for(let f of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,f);if(p&&!m.enumerable)continue;let x=m.get?Ur:m.value?._zod?qr(m.value,t,r):Dt;if(x>d)d=x}return d},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=zr(c);a(l?s(l,!0):Ur),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?qr(l,t,!1):Ur);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 p=Object.getOwnPropertyDescriptor(c,l);if(!p||p.get)continue;let d=p.value;if(!d||typeof d!=="object")continue;if(d._zod)i(d);else if(Array.isArray(d))for(let f of d)i(f)}}return t.delete(e),uf(e,o)}function uf(e,t){if(t!==Ur)cu.set(e,t===Bt);return t}function lf(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var jr,Fr=[],pf={alloc(e,t,r){let n=jr;if(!n)return r;jr=void 0;let o={value:r,issues:null};return n.set(t.value,o),Fr.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"&&df(i,o.value))throw new su;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 v=qr(e,new Set,!1);if(v===Dt){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(v===Bt||n)r=!0;else n=!0}let l=c.value;if(!au(l))return s(c,u);let p=u[co];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[co]=p;let d;if(o===u)d=i;else d=lf(p,e),o=u,i=d;let f=d.get(l);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...ao(f.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(f.value);return c}jr=d;let m=Fr.length,x=s(c,u);jr=void 0;let _=Fr.length>m?Fr.pop():void 0;if(x instanceof Promise)return x.then((v)=>{if(_)_.issues=v.issues.length?ao(v.issues):iu;return v});if(_)_.issues=x.issues.length?ao(x.issues):iu;return x};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function uu(){return pf}function df(e,t){let r=e[co]?.backEdges;return r!==void 0&&au(t)&&r.has(t)}var ff=()=>{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=Js(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 ${jn(i.values[0])}`;return`Invalid option: expected one of ${Ln(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":""}: ${Ln(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 uo(){return{localeError:ff()}}var lu;class pu{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 mf(){return new pu}(lu=globalThis).__zod_globalRegistry??(lu.__zod_globalRegistry=mf());var nt=globalThis.__zod_globalRegistry;function du(e){if(e.checks)e.checks=[...e.checks];return e}function fu(e,t){return new e(du({type:"string",...z(t)}))}function mu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function hu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function lo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function gu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function xu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function yu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function po(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function bu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function vu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function _u(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function wu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function ku(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function zu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function $u(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function Su(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function Iu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function Pu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function Zu(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function Eu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function Ou(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function Au(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function Cu(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}function Tu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function Nu(e,t){return new e({type:"string",format:"date",check:"string_format",...z(t)})}function Ru(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function Mu(e,t){return new e({type:"string",format:"duration",check:"string_format",...z(t)})}function Lu(e,t){return new e(du({type:"number",checks:[],...z(t)}))}function Du(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function Bu(e,t){return new e({type:"boolean",...z(t)})}function ju(e){return new e({type:"unknown"})}function Fu(e,t){return new e({type:"never",...z(t)})}function Vr(e,t){return new Qn({check:"less_than",...z(t),value:e,inclusive:!1})}function jt(e,t){return new Qn({check:"less_than",...z(t),value:e,inclusive:!0})}function Jr(e,t){return new eo({check:"greater_than",...z(t),value:e,inclusive:!1})}function Ft(e,t){return new eo({check:"greater_than",...z(t),value:e,inclusive:!0})}function Hr(e,t){return new Da({check:"multiple_of",...z(t),value:e})}function Gr(e,t){return new ja({check:"max_length",...z(t),maximum:e})}function mt(e,t){return new Fa({check:"min_length",...z(t),minimum:e})}function Kr(e,t){return new Ua({check:"length_equals",...z(t),length:e})}function fo(e,t){return new qa({check:"string_format",format:"regex",...z(t),pattern:e})}function mo(e){return new Va({check:"string_format",format:"lowercase",...z(e)})}function ho(e){return new Ja({check:"string_format",format:"uppercase",...z(e)})}function go(e,t){return new Ha({check:"string_format",format:"includes",...z(t),includes:e})}function xo(e,t){return new Ga({check:"string_format",format:"starts_with",...z(t),prefix:e})}function yo(e,t){return new Ka({check:"string_format",format:"ends_with",...z(t),suffix:e})}function Ve(e){return new Ya({check:"overwrite",tx:e})}function bo(e){return Ve((t)=>t.normalize(e))}function vo(){return Ve((e)=>e.trim())}function _o(){return Ve((e)=>e.toLowerCase())}function wo(){return Ve((e)=>e.toUpperCase())}function ko(){return Ve((e)=>Ds(e))}function Uu(e,t,r){return new e({type:"array",element:t,...z(r)})}function qu(e,t,r){return new e({type:"custom",check:"custom",fn:t,...z(r)})}function Vu(e,t){let r=hf((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(rt(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(rt(i))}},e(n.value,n)),t);return r}function hf(e,t){let r=new X({check:"custom",...z(t)});return r._zod.check=e,r}function Ut(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))he(e,n,r[n]);return e}function $o(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??nt,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 ot(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 V(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 d=s.schema,f=t.processors[o.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,d,l)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;V(p,t,l),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Ut(s.schema,c);if(t.io==="input"&&te(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 Ju(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function So(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 p=e.external.registry.get(s[0])?.id,d=e.external.uri??((m)=>m);if(p)return{ref:d(p)};let f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${Ju(f)}`}}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+Ju(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 p in l)delete l[p];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 Ku(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;Ku(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 Yu=new Set(["type","properties","required","additionalProperties"]),Hu=["oneOf","anyOf"];function Gu(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 zo(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Yu.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]??Gu(u);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:zo(a)??{allOf:a};he(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=Gu(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 gf(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Yu)if(o in e)return;let r=t.filter((o)=>Hu.some((i)=>Array.isArray(o[i]))),n=null;if(!r.length)n=zo(t);else{let o=r[0],i=Hu.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)=>zo([...s,c]));if(a.some((c)=>!c))return;n={[i]:a}}if(!n)return;delete e.allOf,Ut(e,n)}function Io(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},p=c.ref;if(c.ref=null,p){n(p);let f=e.seen.get(p),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(m);else Ut(u,m);if(Ut(u,l),a._zod.parent===p)for(let _ in u){if(_==="$ref"||_==="allOf")continue;if(!(_ in l))delete u[_]}if(m.$ref&&f.def)for(let _ in u){if(_==="$ref"||_==="allOf")continue;if(_ in f.def&&JSON.stringify(u[_])===JSON.stringify(f.def[_]))delete u[_]}}let d=a._zod.parent;if(d&&d!==p){n(d);let f=e.seen.get(d);if(f?.schema.$ref){if(u.$ref=f.schema.$ref,f.def)for(let m in u){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m]))delete u[m]}}}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())Ku(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 p=a.get(l);if(p)p.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])gf(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)}Ut(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;he(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:qt(t,"input",e.processors),output:qt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function te(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 te(n.element,r);if(n.type==="set")return te(n.valueType,r);if(n.type==="lazy")return te(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 te(n.innerType,r);if(n.type==="intersection")return te(n.left,r)||te(n.right,r);if(n.type==="record"||n.type==="map")return te(n.keyType,r)||te(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return te(n.in,r)||te(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(te(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(te(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(te(o,r))return!0;if(n.rest&&te(n.rest,r))return!0;return!1}return!1}var Xu=(e,t={})=>(r)=>{let n=$o({...r,processors:t});return V(e,n),So(n,e),Io(n,e)},qt=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:i}=n??{},s=$o({...o??{},target:i,io:t,processors:r});return V(e,s),So(s,e),Io(s,e)};var ht=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},gt=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Wu=(e,t)=>{ht(e,"minimum",t),gt(e,"maximum",t)},rl=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},nl=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},ol=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},il=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Qu=(e,t)=>ht(e,"minimum",t.minimum),el=(e,t)=>gt(e,"maximum",t.maximum),tl=(e)=>(t,r)=>{il(t,r.format);let[n,o]=e[r.format];ht(t,"minimum",n),gt(t,"maximum",o)},xf={greater_than:(e,t)=>ht(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>gt(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>rl(e,t.value),number_format:tl($r),bigint_format:tl(Fn),min_length:Qu,max_length:el,length_equals:(e,t)=>Wu(e,t.length),min_size:Qu,max_size:el,size_equals:(e,t)=>Wu(e,t.size),string_format:(e,t)=>{if(il(e,t.format),t.pattern)nl(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)=>ol(e,t.mime)};function pe(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of n)xf[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)ht(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)ht(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)gt(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)gt(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)rl(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)ol(t,o.mime);for(let i of o.patterns??[])nl(t,i);return t}var yf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},bf=new Map([[oo,Ia],[Br,Pa]]),sl=(e)=>bf.get(e)??e,al=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=pe(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=yf[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 p=[...c].map(sl);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},cl=(e,t,r,n)=>{let o=r,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=pe(e);o.type=l?"integer":"number";let p=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(f)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(d)if(f)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let m=new Set;for(let v of a)if(Number.isFinite(v)&&v!==0)m.add(Math.abs(v));else ot(e,t,o,n,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[x,..._]=m;if(x!==void 0)o.multipleOf=x;if(_.length)o.allOf=[...o.allOf??[],..._.map((v)=>({multipleOf:v}))]}},ul=(e,t,r,n)=>{r.type="boolean"};var ll=(e,t,r,n)=>{r.not={}};var pl=(e,t,r,n)=>{};var dl=(e,t,r,n)=>{let o=e._zod.def,i=Ct(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 fl=(e,t,r,n)=>{ot(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var ml=(e,t,r,n)=>{ot(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var hl=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:a}=pe(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=V(i.element,t,{...n,path:[...n.path,"items"]})};function Yr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Yr(t.out);if(t.type==="catch")return Yr(t.innerType);return e._zod.optin}var gl=(e,t,r,n)=>{let o=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ot(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)he(o.properties,u,V(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"?Yr(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=V(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},xl=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>V(a,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));if(i)r.oneOf=s;else r.anyOf=s},yl=(e,t,r,n)=>{let o=e._zod.def,i=V(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=V(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 Po(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let x=Po(e,m,r);return x===m?t:x}for(let m of["anyOf","oneOf"]){let x=t[m];if(!Array.isArray(x))continue;let _=x.map((v)=>Po(e,v,r));if(_.some((v,P)=>v!==x[P]))t={...t,[m]:_}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((m)=>m==="number"||m==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((m)=>typeof m==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:d,...f}=t;if(f.enum)f.enum=f.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof f.const==="number")f.const=String(f.const);if(!o)return f;if(f.type="string",!i)f.pattern=(n.includes("number")?Rt:Xn).source;return f}var Zo=new WeakMap;function vf(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 Zo.get(e)??[]){let o=e.seen.get(n),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=Po(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 bl=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,a=pe(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=V(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)he(o.patternProperties,sl(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=V(i.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Zo.get(t);if(!l)l=[],Zo.set(t,l),t.deferred.push(()=>vf(t));l.push(e)}o.additionalProperties=V(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=s._zod.values,u=t.io==="input"&&Yr(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},vl=(e,t,r,n)=>{let o=e._zod.def,i=V(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"}]},_l=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Eo=Symbol();function wl(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 ot(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Eo}var kl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s=wl(o.defaultValue,e,t,r,n);if(s!==Eo)r.default=s},zl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=wl(o.defaultValue,e,t,r,n);if(s!==Eo)r._prefault=s},$l=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{ot(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},Sl=(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;V(s,t,n);let a=t.seen.get(e);a.ref=s},Il=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0};var Oo=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType};var Pl=new WeakSet([Object.prototype,Error.prototype]);function Xr(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 Pf=(e,t)=>{ea.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Pl.has(r))return;Pl.add(r),Xr(r,"format",(n)=>(o)=>ra(n,o)),Xr(r,"flatten",(n)=>(o)=>ta(n,o)),Xr(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Tt,2)}),Xr(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Tt,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ue=g("ZodError",Pf,void 0,{Parent:Error});var Zl=Or(ue),El=Ar(ue),Ol=Cr(ue),Al=Tr(ue),Cl=oa(ue),Tl=ia(ue),Nl=sa(ue),Rl=aa(ue),Ml=ca(ue),Ll=ua(ue),Dl=la(ue),Bl=pa(ue);function Ef(){if(!ne.localeError)ce(uo())}function Wr(){if(!ne.memoizer)ce({memoizer:uu()})}var F=g("ZodType",(e,t)=>(Ef(),D.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ae(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 ve(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(km(e,t))},superRefine(e,t){return this.check(zm(e,t))},overwrite(e){return this.check(Ve(e))},optional(){return ql(this)},exactOptional(){return lm(this)},nullable(){return Vl(this)},nullish(){return ql(Vl(this))},nonoptional(e){return gm(this,e)},array(){return W(this)},or(e){return im([this,e])},and(e){return am(this,e)},transform(e){return Jl(this,um(e))},default(e){return fm(this,e)},prefault(e){return hm(this,e)},catch(e){return ym(this,e)},pipe(e){return Jl(this,e)},readonly(){return _m(this)},describe(e){let t=this.clone();return nt.add(t,{description:e}),t},meta(...e){if(e.length===0)return nt.get(this);let t=this.clone();return nt.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 Zr(this,"~standard",{...no(this),jsonSchema:{input:qt(this,"input"),output:qt(this,"output")}})},set "~standard"(e){Te(this,"~standard",e)},parse:function e(t,r){return Zl(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await El(this,t,r,{callee:e})},safeParse(e,t){return Ol(this,e,t)},async safeParseAsync(e,t){return Al(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Te(this,"spa",e)},validate(e,t){return Hn(this,e,t)},validateAsync(e,t){return Gn(this,e,t)},encode:function e(t,r){return Cl(this,t,r,{callee:e})},decode:function e(t,r){return Tl(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Nl(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Rl(this,t,r,{callee:e})},safeEncode(e,t){return Ml(this,e,t)},safeDecode(e,t){return Ll(this,e,t)},async safeEncodeAsync(e,t){return Dl(this,e,t)},async safeDecodeAsync(e,t){return Bl(this,e,t)},toJSONSchema(e){return Xu(this,{})(e)},get description(){return nt.get(this)?.description},get _def(){return this._zod.def}}),Hl=g("_ZodString",(e,t)=>{Dr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>al(e,r,n,o)},Gs({format:(e)=>pe(e).format??null,minLength:(e)=>pe(e).minimum??null,maxLength:(e)=>pe(e).maximum??null},{regex(...e){return this.check(fo(...e))},includes(...e){return this.check(go(...e))},startsWith(...e){return this.check(xo(...e))},endsWith(...e){return this.check(yo(...e))},min(...e){return this.check(mt(...e))},max(...e){return this.check(Gr(...e))},length(...e){return this.check(Kr(...e))},nonempty(...e){return this.check(mt(1,...e))},lowercase(e){return this.check(mo(e))},uppercase(e){return this.check(ho(e))},trim(){return this.check(vo())},normalize(...e){return this.check(bo(...e))},toLowerCase(){return this.check(_o())},toUpperCase(){return this.check(wo())},slugify(){return this.check(ko())}})),Of=g("ZodString",(e,t)=>{Dr.init(e,t),Hl.init(e,t)},{email(e){return this.check(mu(Rf,e))},url(e){return this.check(po(Gl,e))},jwt(e){return this.check(Cu(Wf,e))},emoji(e){return this.check(bu(Lf,e))},guid(e){return this.check(hu(Mf,e))},uuid(e){return this.check(lo(Vt,e))},uuidv4(e){return this.check(gu(Vt,e))},uuidv6(e){return this.check(xu(Vt,e))},uuidv7(e){return this.check(yu(Vt,e))},nanoid(e){return this.check(vu(Df,e))},cuid(e){return this.check(_u(Bf,e))},cuid2(e){return this.check(wu(jf,e))},ulid(e){return this.check(ku(Ff,e))},base64(e){return this.check(Eu(Kf,e))},base64url(e){return this.check(Ou(Yf,e))},xid(e){return this.check(zu(Uf,e))},ksuid(e){return this.check($u(qf,e))},ipv4(e){return this.check(Su(Vf,e))},ipv6(e){return this.check(Iu(Jf,e))},cidrv4(e){return this.check(Pu(Hf,e))},cidrv6(e){return this.check(Zu(Gf,e))},e164(e){return this.check(Au(Xf,e))},datetime(e){return this.check(Tu(Af,e))},date(e){return this.check(Nu(Cf,e))},time(e){return this.check(Ru(Tf,e))},duration(e){return this.check(Mu(Nf,e))}});function k(e){return fu(Of,e)}var B=g("ZodStringFormat",(e,t)=>{M.init(e,t),Hl.init(e,t)}),Af=g("ZodISODateTime",(e,t)=>{kc.init(e,t),B.init(e,t)}),Cf=g("ZodISODate",(e,t)=>{zc.init(e,t),B.init(e,t)}),Tf=g("ZodISOTime",(e,t)=>{$c.init(e,t),B.init(e,t)}),Nf=g("ZodISODuration",(e,t)=>{Sc.init(e,t),B.init(e,t)}),Rf=g("ZodEmail",(e,t)=>{dc.init(e,t),B.init(e,t)});var Mf=g("ZodGUID",(e,t)=>{lc.init(e,t),B.init(e,t)});var Vt=g("ZodUUID",(e,t)=>{pc.init(e,t),B.init(e,t)});function Jt(e){return lo(Vt,e)}var Gl=g("ZodURL",(e,t)=>{hc.init(e,t),B.init(e,t)});function To(e){return po(Gl,e)}var Lf=g("ZodEmoji",(e,t)=>{gc.init(e,t),B.init(e,t)});var Df=g("ZodNanoID",(e,t)=>{xc.init(e,t),B.init(e,t)});var Bf=g("ZodCUID",(e,t)=>{yc.init(e,t),B.init(e,t)});var jf=g("ZodCUID2",(e,t)=>{bc.init(e,t),B.init(e,t)});var Ff=g("ZodULID",(e,t)=>{vc.init(e,t),B.init(e,t)});var Uf=g("ZodXID",(e,t)=>{_c.init(e,t),B.init(e,t)});var qf=g("ZodKSUID",(e,t)=>{wc.init(e,t),B.init(e,t)});var Vf=g("ZodIPv4",(e,t)=>{Ic.init(e,t),B.init(e,t)});var Jf=g("ZodIPv6",(e,t)=>{Zc.init(e,t),B.init(e,t)});var Hf=g("ZodCIDRv4",(e,t)=>{Ec.init(e,t),B.init(e,t)});var Gf=g("ZodCIDRv6",(e,t)=>{Oc.init(e,t),B.init(e,t)});var Kf=g("ZodBase64",(e,t)=>{Cc.init(e,t),B.init(e,t)});var Yf=g("ZodBase64URL",(e,t)=>{Tc.init(e,t),B.init(e,t)});var Xf=g("ZodE164",(e,t)=>{Nc.init(e,t),B.init(e,t)});var Wf=g("ZodJWT",(e,t)=>{Rc.init(e,t),B.init(e,t)});var Kl=g("ZodNumber",(e,t)=>{io.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cl(e,r,n,o),e.isFinite=!0},Gs({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=pe(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=pe(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=pe(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>pe(e).format??null},{gt(e,t){return this.check(Jr(e,t))},gte(e,t){return this.check(Ft(e,t))},min(e,t){return this.check(Ft(e,t))},lt(e,t){return this.check(Vr(e,t))},lte(e,t){return this.check(jt(e,t))},max(e,t){return this.check(jt(e,t))},int(e){return this.check(jl(e))},safe(e){return this.check(jl(e))},positive(e){return this.check(Jr(0,e))},nonnegative(e){return this.check(Ft(0,e))},negative(e){return this.check(Vr(0,e))},nonpositive(e){return this.check(jt(0,e))},multipleOf(e,t){return this.check(Hr(e,t))},step(e,t){return this.check(Hr(e,t))},finite(){return this}}));function Yl(e){return Lu(Kl,e)}var Qf=g("ZodNumberFormat",(e,t)=>{Mc.init(e,t),Kl.init(e,t)});function jl(e){return Du(Qf,e)}var em=g("ZodBoolean",(e,t)=>{Lc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ul(e,r,n,o)});function it(e){return Bu(em,e)}var tm=g("ZodUnknown",(e,t)=>{Dc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pl(e,r,n,o)});function Fl(){return ju(tm)}var rm=g("ZodNever",(e,t)=>{Bc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ll(e,r,n,o)});function Xl(e){return Fu(rm,e)}var nm=g("ZodArray",(e,t)=>{Wr(),jc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hl(e,r,n,o),e.element=t.element},{min(e,t){return this.check(mt(e,t))},nonempty(e){return this.check(mt(1,e))},max(e,t){return this.check(Gr(e,t))},length(e,t){return this.check(Kr(e,t))},unwrap(){return this.element}});function W(e,t){return Uu(nm,e,t)}var Wl=g("ZodObject",(e,t)=>{Wr(),qc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gl(e,r,n,o),Ld(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return Ht(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ae(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ae(this._zod.def,{catchall:Fl()}))},loose(){return this.clone(ae(this._zod.def,{catchall:Fl()}))},strict(){return this.clone(ae(this._zod.def,{catchall:Xl()}))},strip(){return this.clone(ae(this._zod.def,{catchall:void 0}))},extend(e){return Ed(this,e)},safeExtend(e){return Od(this,e)},merge(e){return Ad(this,e)},pick(e){return Pd(this,e)},omit(e){return Zd(this,e)},partial(...e){return qs(Ql,this,e[0])},exactPartial(...e){return qs(ep,this,e[0],"exactPartial")},required(...e){return Cd(tp,this,e[0])}});function Je(e,t){let r={type:"object",shape:e??{},...z(t)};return new Wl(r)}function J(e,t){return new Wl({type:"object",shape:e,catchall:Xl(),...z(t)})}var om=g("ZodUnion",(e,t)=>{Vc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xl(e,r,n,o),e.options=t.options});function im(e,t){return new om({type:"union",options:e,...z(t)})}var sm=g("ZodIntersection",(e,t)=>{Jc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yl(e,r,n,o)});function am(e,t){return new sm({type:"intersection",left:e,right:t})}var Ul=g("ZodRecord",(e,t)=>{Wr(),Hc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bl(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Qr(e,t,r){if(!t||!t._zod)return new Ul({type:"record",keyType:k(),valueType:e,...z(t)});return new Ul({type:"record",keyType:e,valueType:t,...z(r)})}var Co=g("ZodEnum",(e,t)=>{Gc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,o,i)=>dl(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 Co({...t,checks:[],...z(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 Co({...t,checks:[],...z(o),entries:i})}});function Ht(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Co({type:"enum",entries:r,...z(t)})}var cm=g("ZodTransform",(e,t)=>{Wr(),Kc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ml(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Nt(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(rt(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(rt(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 um(e){return new cm({type:"transform",transform:e})}var Ql=g("ZodOptional",(e,t)=>{so.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Oo(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ql(e){return new Ql({type:"optional",innerType:e})}var ep=g("ZodExactOptional",(e,t)=>{Yc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Oo(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function lm(e){return new ep({type:"optional",innerType:e})}var pm=g("ZodNullable",(e,t)=>{Xc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Vl(e){return new pm({type:"nullable",innerType:e})}var dm=g("ZodDefault",(e,t)=>{Wc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fm(e,t){return new dm({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Bn(t)}})}var mm=g("ZodPrefault",(e,t)=>{Qc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function hm(e,t){return new mm({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Bn(t)}})}var tp=g("ZodNonOptional",(e,t)=>{eu.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_l(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function gm(e,t){return new tp({type:"nonoptional",innerType:e,...z(t)})}var xm=g("ZodCatch",(e,t)=>{tu.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$l(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ym(e,t){return new xm({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Ks(t)})}var bm=g("ZodPipe",(e,t)=>{ru.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sl(e,r,n,o),e.in=t.in,e.out=t.out});function Jl(e,t){return new bm({type:"pipe",in:e,out:t})}var vm=g("ZodReadonly",(e,t)=>{nu.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Il(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function _m(e){return new vm({type:"readonly",innerType:e})}var wm=g("ZodCustom",(e,t)=>{ou.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fl(e,r,n,o)});function km(e,t={}){return qu(wm,e,t)}function zm(e,t){return Vu(e,t)}var xt=Ht(["global","private","shared"]),$m=k().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(48),yt=J({name:$m,description:k().trim().min(1).max(300),body:k().trim().min(1).max(24000)}),No=J({scope:xt,choices:Qr(k().max(128),it()),edits:Qr(k().max(128),k().min(1).max(48000)).default({}),custom:W(yt).max(40).default([])}),_v=No.extend({directory:k(),id:k()});var Sm=J({id:k(),title:k(),parentId:k().nullable()}),Im=J({id:k(),itemIds:W(k()).min(1),parentId:k(),relatedHubIds:W(k()).max(2)}),en=J({hubs:W(Sm),leaves:W(Im)});var Pm=J({id:k(),name:k(),title:k(),description:k(),text:k(),kind:Ht(["preference","skill"]),category:k().nullable(),section:k().nullable(),axis:k().nullable(),owner:Ht(["packaged","managed","user","provider"])}),rp=J({scope:xt,input:No,inherited:Qr(k(),it()),locked:Qr(k(),it()),items:W(Pm),constellation:en,requirements:W(k()),libraryEnabled:it(),migrationRequired:it(),revisionId:k().nullable()}),np=J({id:Jt(),changes:W(J({path:k(),before:k().nullable(),after:k().nullable(),internal:it()})),warnings:W(k())}),Ro=J({revisionId:k().nullable()});var Mo=window.location.hash.slice(1),Zm=Mo||sessionStorage.getItem("shadowclone-session")||"";if(Mo)sessionStorage.setItem("shadowclone-session",Mo),history.replaceState(null,"",`${location.pathname}${location.search}`);async function H(e){let t=await fetch(e.path,{method:e.body===void 0?"GET":"POST",headers:{Authorization:`Bearer ${Zm}`,"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=Je({error:k()}).safeParse(r);throw Error(n.success?n.data.error:"The local editor could not complete this action.")}return e.schema.parse(r)}function Lo(e){if(e.leaves.length<=10)return{hubs:[],leaves:e.leaves.map((o)=>({...o,parentId:e.parentId}))};let t=10;while(e.leaves.length/t>10)t*=10;let r=[],n=[];for(let o=0;o<e.leaves.length;o+=t){let i=o/t,s=`${e.parentId}:${i}`,a=`${e.title} ${i+1}`;r.push({id:s,title:a,parentId:e.parentId});let c=Lo({parentId:s,title:a,leaves:e.leaves.slice(o,o+t)});r.push(...c.hubs),n.push(...c.leaves)}return{hubs:r,leaves:n}}var Em=new Set(["agent","before","change","changing","code","existing","from","into","skill","that","the","this","when","with","work"]);function Do(e){return e.toLowerCase().replaceAll(/[^a-z0-9-]+/g," ").split(/[\s-]+/).filter((t)=>t.length>2&&!Em.has(t))}function Om(e){return[e.category,e.section,e.axis,...Do(e.name),...Do(e.title),...Do(e.description)].filter((t,r,n)=>Boolean(t&&n.indexOf(t)===r))}function op(e){return e.split("-").map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}function Am(e){let t=new Map;for(let r of[...e].sort((n,o)=>n.id.localeCompare(o.id))){let n=`${r.kind}\x00${r.text.trim()}`,o=t.get(n);if(o)o.ids.push(r.id);else t.set(n,{item:r,ids:[r.id]})}return[...t.values()].map(({item:r,ids:n})=>({item:r,itemIds:n,topics:Om(r)}))}function Cm(e){if(e<4)return Math.max(1,e);return Math.min(12,Math.max(4,Math.round(Math.sqrt(e))))}function Tm(e){let r=[...Map.groupBy(e,(i)=>i.topics[0]??"guidance")].map(([i,s])=>({key:i,entries:s})),n=Cm(e.length);r.sort((i,s)=>s.entries.length-i.entries.length||i.key.localeCompare(s.key));let o=r.slice(0,n);for(let i of r.slice(n))for(let s of i.entries)o.map((c)=>({candidate:c,score:(s.item.section===c.entries[0]?.item.section?4:0)+(s.topics.includes(c.key)?1:0)})).sort((c,u)=>u.score-c.score||c.candidate.entries.length-u.candidate.entries.length||c.candidate.key.localeCompare(u.candidate.key))[0]?.candidate.entries.push(s);return o.sort((i,s)=>i.key.localeCompare(s.key))}function Nm(e){let t=new Set(e.entries.flatMap((n)=>n.item.category?[n.item.category]:[]));if(t.size===1)return[...t][0]??e.key;let r=new Set(e.entries.flatMap((n)=>n.item.section?[n.item.section]:[]));return r.size===1?[...r][0]??e.key:e.key}function Rm(e,t){let r=new Map;for(let n of e)for(let o of n.topics.filter((i)=>i!==t))r.set(o,(r.get(o)??0)+1);return[...r].sort(([n,o],[i,s])=>s-o||n.localeCompare(i))[0]?.[0]??t}function ip(e){let t=Am(e),r=Tm(t),n=r.map(Nm),o=[],i=[];for(let[s,a]of r.entries()){let c=`hub:${s}:${a.key}`,u=n[s]??a.key,l=n.slice(0,s).filter((x)=>x===u).length,p=n.filter((x)=>x===u).length;o.push({id:c,title:`${op(u)}${p>1?` ${l+1}`:""}`,parentId:null});let d=[...a.entries].sort((x,_)=>x.item.id.localeCompare(_.item.id)),f=d.map((x)=>{let _=r.map((v,P)=>({candidate:v,index:P})).filter(({candidate:v})=>v.key!==a.key&&x.topics.includes(v.key)).slice(0,2).map(({candidate:v,index:P})=>`hub:${P}:${v.key}`);return{id:`skill:${x.item.id}`,itemIds:[...x.itemIds],relatedHubIds:_}}),m=Lo({parentId:c,title:op(Rm(d,a.key)),leaves:f});o.push(...m.hubs),i.push(...m.leaves)}return en.parse({hubs:o,leaves:i})}function Z(e){let t=document.getElementById(e);if(t===null)throw Error("The editor is missing a required control");return t}function Bo(e){let t=document.querySelector(`#${e}`);if(!(t instanceof SVGSVGElement))throw Error("Expected an SVG canvas");return t}function oe(e){let t=Z(e);if(!(t instanceof HTMLInputElement))throw Error("Expected an input control");return t}function ze(e){let t=Z(e);if(!(t instanceof HTMLSelectElement))throw Error("Expected a selection control");return t}function Re(e){let t=Z(e);if(!(t instanceof HTMLTextAreaElement))throw Error("Expected a text editor");return t}function bt(e){let t=Z(e);if(!(t instanceof HTMLDialogElement))throw Error("Expected an editor dialog");return t}function b(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 de(e){let t=Z("notice");t.textContent=e.message,t.classList.toggle("success",e.success===!0),t.hidden=e.message.length===0}function st(e){de({message:e instanceof Error?e.message:"The action failed."})}var w={view:null,input:{scope:"global",choices:{},edits:{},custom:[]},activeId:"",search:"",dirty:!1};function ie(e){let t=w.view?.locked[e.id];if(t!==void 0)return t;let r=w.input.choices[e.id];if(r!==void 0)return r;if(e.id.startsWith("custom:")&&w.input.custom.some((n)=>e.id===`custom:${n.name}`))return!0;return w.view?.inherited[e.id]===!0}function jo(e){if(w.view?.locked[e.id]!==void 0)return;let t=!ie(e);if(w.input.choices[e.id]=t,t&&e.axis){for(let r of w.view?.items??[])if(r.axis===e.axis&&r.id!==e.id)w.input.choices[r.id]=!1,delete w.input.edits[r.id]}if(!t)delete w.input.edits[e.id];w.dirty=!0}function Fo(e){Z("custom-status").textContent="",oe("custom-name").value=e?`my-${e.name}`.slice(0,48):"",oe("custom-description").value=e?`Use alongside ${e.name} for my working preferences.`:"",Re("custom-body").value=e?`# Personal guidance for ${e.title}
|
|
58
|
+
|
|
59
|
+
`:"",bt("custom-dialog").showModal()}function sp(){let e=yt.parse({name:oe("custom-name").value,description:oe("custom-description").value,body:Re("custom-body").value}),t=`custom:${e.name}`;if(w.view?.items.some((r)=>r.name===e.name))throw Error("Choose a name that does not replace an existing skill.");if(w.input.custom.push(e),w.input.choices[t]=!0,w.dirty=!0,w.activeId=t,w.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"}),w.view)w.view.constellation=ip(w.view.items);bt("custom-dialog").close(),oe("custom-name").value="",Re("custom-body").value=""}var ap={"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."},"scope-confirmed-changes":{title:"Scoped changes",summary:"Confirm the problem before editing. Keep the change focused, preserve surrounding behavior, and verify the result."},"diagnose-before-editing":{title:"Prove the bug",summary:"Trace the failure and establish its cause before changing code. Use evidence to choose the smallest useful fix."},"prove-regression-tests":{title:"Test the failure",summary:"Prove a regression test detects the original bug. Restore the fix and check that the same test passes."},"verify-and-review":{title:"Verify the finish",summary:"Run the relevant checks, inspect the complete diff, and report what was verified before calling the task done."},"testing-first":{title:"Test first",summary:"Capture the expected behavior at a public boundary before implementing the change. Let the failing test guide the work."},"testing-risk-based":{title:"Test the risk",summary:"Spend testing effort where behavior can break. Choose checks that catch meaningful failures without mirroring the implementation."},"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 ap[e.id]?.title??e.title}function cp(e){let t=ap[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 Mm(e){let t=b({tag:"details",className:"editor"});t.append(b({tag:"summary",text:"Edit instructions"}));let r=b({tag:"textarea"});r.value=w.input.edits[e.item.id]??e.item.text,r.maxLength=48000,r.setAttribute("aria-label",`Instructions for ${e.item.title}`);let n=b({tag:"button",className:"quiet-button",text:"Save to draft"});return n.addEventListener("click",()=>{if(!ie(e.item))jo(e.item);w.input.edits[e.item.id]=r.value,w.input.choices[e.item.id]=!0,w.dirty=!0,de({message:"Instructions added to your draft. Review the changes before applying.",success:!0}),e.rerender()}),t.append(r,n),t}function up(e){let t=Z("detail"),r=w.view?.items.find((a)=>a.id===w.activeId);if(t.replaceChildren(),!r){t.append(b({tag:"h2",text:"Choose a skill."})),t.append(b({tag:"p",className:"detail-description",text:"Inspect a star to see what it teaches your agent."}));return}t.append(b({tag:"p",className:"eyebrow",text:`${(r.category??"CUSTOM").replaceAll("-"," ").toUpperCase()} / ${r.kind.toUpperCase()}`}),b({tag:"h2",text:$e(r)}),b({tag:"p",className:"detail-description",text:r.description}));let n=b({tag:"div",className:"behavior"});n.append(b({tag:"p",className:"eyebrow",text:"YOUR AGENT WILL"}),b({tag:"p",text:cp({item:r,editedText:w.input.edits[r.id]})})),t.append(n);let o=r.owner==="provider",i=w.view?.locked[r.id]!==void 0;if(t.append(b({tag:"p",className:"skill-status",text:i?"◇ Shared requirement":o?"◇ Managed by its provider":"◇ Workflow guidance"})),i){t.append(b({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=b({tag:"button",className:"primary-button",text:o?"Create a local companion":ie(r)?"Unequip skill":"Equip skill"});if(s.addEventListener("click",()=>{if(o){e.companion(r);return}jo(r),e.rerender()}),t.append(s),o)t.append(b({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(Mm({item:r,rerender:e.rerender}))}var lp=J({title:k().min(1).max(80),summary:k().min(1).max(600),strengths:W(k().min(1).max(180)).max(3),tradeoffs:W(k().min(1).max(180)).max(3),hubLabels:W(J({id:k().min(1).max(120),title:k().min(1).max(40)})).max(12).default([])}),pp=J({id:Jt(),destination:k(),payload:k(),limits:k(),cached:lp.nullable()}),dp=J({description:lp});function tn(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 rn(e){let t=b({tag:"dialog"}),r=b({tag:"div",className:"dialog-heading"}),n=b({tag:"button",className:"quiet-button",text:"✕"}),o=b({tag:"details",className:"file-change"}),i=b({tag:"div",className:"dialog-actions"}),s=b({tag:"p",className:"review-message"}),a=b({tag:"button",className:"quiet-button",text:"Keep editing"}),c=b({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()),tn(t),r.append(b({tag:"h2",text:e.title}),n),o.append(b({tag:"summary",text:"Exact payload sent to the model"}),b({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 p=await H({path:e.path,schema:e.schema,body:{previewId:e.review.id},signal:u.signal});if(!u.signal.aborted)e.accept(p),t.close()}catch(p){if(u.signal.aborted)return;s.className="review-warning",s.textContent=p instanceof Error?p.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,b({tag:"p",className:"review-message",text:`Destination: ${e.review.destination}`}),b({tag:"p",className:"review-message",text:e.review.limits}),b({tag:"p",className:"review-message",text:e.explanation}),o,s,i),document.body.append(t),t.showModal()}function vt(e){return function(){return this.matches(e)}}function nn(e){return function(t){return t.matches(e)}}var on="http://www.w3.org/1999/xhtml",Uo={svg:"http://www.w3.org/2000/svg",xhtml:on,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Se(e){var t=e+="",r=t.indexOf(":");if(r>=0&&(t=e.slice(0,r))!=="xmlns")e=e.slice(r+1);return Uo.hasOwnProperty(t)?{space:Uo[t],local:e}:e}function qo(e){let t;while(t=e.sourceEvent)e=t;return e}function Ie(e,t){if(e=qo(e),t===void 0)t=e.currentTarget;if(t){var r=t.ownerSVGElement||t;if(r.createSVGPoint){var n=r.createSVGPoint();return n.x=e.clientX,n.y=e.clientY,n=n.matrixTransform(t.getScreenCTM().inverse()),[n.x,n.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}function Lm(){}function He(e){return e==null?Lm:function(){return this.querySelector(e)}}function Vo(e){if(typeof e!=="function")e=He(e);for(var t=this._groups,r=t.length,n=Array(r),o=0;o<r;++o)for(var i=t[o],s=i.length,a=n[o]=Array(s),c,u,l=0;l<s;++l)if((c=i[l])&&(u=e.call(c,c.__data__,l,i))){if("__data__"in c)u.__data__=c.__data__;a[l]=u}return new U(n,this._parents)}function Jo(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Dm(){return[]}function _t(e){return e==null?Dm:function(){return this.querySelectorAll(e)}}function Bm(e){return function(){return Jo(e.apply(this,arguments))}}function Ho(e){if(typeof e==="function")e=Bm(e);else e=_t(e);for(var t=this._groups,r=t.length,n=[],o=[],i=0;i<r;++i)for(var s=t[i],a=s.length,c,u=0;u<a;++u)if(c=s[u])n.push(e.call(c,c.__data__,u,s)),o.push(c);return new U(n,o)}var jm=Array.prototype.find;function Fm(e){return function(){return jm.call(this.children,e)}}function Um(){return this.firstElementChild}function Go(e){return this.select(e==null?Um:Fm(typeof e==="function"?e:nn(e)))}var qm=Array.prototype.filter;function Vm(){return Array.from(this.children)}function Jm(e){return function(){return qm.call(this.children,e)}}function Ko(e){return this.selectAll(e==null?Vm:Jm(typeof e==="function"?e:nn(e)))}function Yo(e){if(typeof e!=="function")e=vt(e);for(var t=this._groups,r=t.length,n=Array(r),o=0;o<r;++o)for(var i=t[o],s=i.length,a=n[o]=[],c,u=0;u<s;++u)if((c=i[u])&&e.call(c,c.__data__,u,i))a.push(c);return new U(n,this._parents)}function Gt(e){return Array(e.length)}function Xo(){return new U(this._enter||this._groups.map(Gt),this._parents)}function Kt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kt.prototype={constructor:Kt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Wo(e){return function(){return e}}function Hm(e,t,r,n,o,i){var s=0,a,c=t.length,u=i.length;for(;s<u;++s)if(a=t[s])a.__data__=i[s],n[s]=a;else r[s]=new Kt(e,i[s]);for(;s<c;++s)if(a=t[s])o[s]=a}function Gm(e,t,r,n,o,i,s){var a,c,u=new Map,l=t.length,p=i.length,d=Array(l),f;for(a=0;a<l;++a)if(c=t[a])if(d[a]=f=s.call(c,c.__data__,a,t)+"",u.has(f))o[a]=c;else u.set(f,c);for(a=0;a<p;++a)if(f=s.call(e,i[a],a,i)+"",c=u.get(f))n[a]=c,c.__data__=i[a],u.delete(f);else r[a]=new Kt(e,i[a]);for(a=0;a<l;++a)if((c=t[a])&&u.get(d[a])===c)o[a]=c}function Km(e){return e.__data__}function Qo(e,t){if(!arguments.length)return Array.from(this,Km);var r=t?Gm:Hm,n=this._parents,o=this._groups;if(typeof e!=="function")e=Wo(e);for(var i=o.length,s=Array(i),a=Array(i),c=Array(i),u=0;u<i;++u){var l=n[u],p=o[u],d=p.length,f=Ym(e.call(l,l&&l.__data__,u,n)),m=f.length,x=a[u]=Array(m),_=s[u]=Array(m),v=c[u]=Array(d);r(l,p,x,_,v,f,t);for(var P=0,L=0,j,T;P<m;++P)if(j=x[P]){if(P>=L)L=P+1;while(!(T=_[L])&&++L<m);j._next=T||null}}return s=new U(s,n),s._enter=a,s._exit=c,s}function Ym(e){return typeof e==="object"&&"length"in e?e:Array.from(e)}function ei(){return new U(this._exit||this._groups.map(Gt),this._parents)}function ti(e,t,r){var n=this.enter(),o=this,i=this.exit();if(typeof e==="function"){if(n=e(n),n)n=n.selection()}else n=n.append(e+"");if(t!=null){if(o=t(o),o)o=o.selection()}if(r==null)i.remove();else r(i);return n&&o?n.merge(o).order():o}function ri(e){var t=e.selection?e.selection():e;for(var r=this._groups,n=t._groups,o=r.length,i=n.length,s=Math.min(o,i),a=Array(o),c=0;c<s;++c)for(var u=r[c],l=n[c],p=u.length,d=a[c]=Array(p),f,m=0;m<p;++m)if(f=u[m]||l[m])d[m]=f;for(;c<o;++c)a[c]=r[c];return new U(a,this._parents)}function ni(){for(var e=this._groups,t=-1,r=e.length;++t<r;)for(var n=e[t],o=n.length-1,i=n[o],s;--o>=0;)if(s=n[o]){if(i&&s.compareDocumentPosition(i)^4)i.parentNode.insertBefore(s,i);i=s}return this}function oi(e){if(!e)e=Xm;function t(p,d){return p&&d?e(p.__data__,d.__data__):!p-!d}for(var r=this._groups,n=r.length,o=Array(n),i=0;i<n;++i){for(var s=r[i],a=s.length,c=o[i]=Array(a),u,l=0;l<a;++l)if(u=s[l])c[l]=u;c.sort(t)}return new U(o,this._parents).order()}function Xm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ii(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function si(){return Array.from(this)}function ai(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var n=e[t],o=0,i=n.length;o<i;++o){var s=n[o];if(s)return s}return null}function ci(){let e=0;for(let t of this)++e;return e}function ui(){return!this.node()}function li(e){for(var t=this._groups,r=0,n=t.length;r<n;++r)for(var o=t[r],i=0,s=o.length,a;i<s;++i)if(a=o[i])e.call(a,a.__data__,i,o);return this}function Wm(e){return function(){this.removeAttribute(e)}}function Qm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function eh(e,t){return function(){this.setAttribute(e,t)}}function th(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function rh(e,t){return function(){var r=t.apply(this,arguments);if(r==null)this.removeAttribute(e);else this.setAttribute(e,r)}}function nh(e,t){return function(){var r=t.apply(this,arguments);if(r==null)this.removeAttributeNS(e.space,e.local);else this.setAttributeNS(e.space,e.local,r)}}function pi(e,t){var r=Se(e);if(arguments.length<2){var n=this.node();return r.local?n.getAttributeNS(r.space,r.local):n.getAttribute(r)}return this.each((t==null?r.local?Qm:Wm:typeof t==="function"?r.local?nh:rh:r.local?th:eh)(r,t))}function Yt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function oh(e){return function(){this.style.removeProperty(e)}}function ih(e,t,r){return function(){this.style.setProperty(e,t,r)}}function sh(e,t,r){return function(){var n=t.apply(this,arguments);if(n==null)this.style.removeProperty(e);else this.style.setProperty(e,n,r)}}function di(e,t,r){return arguments.length>1?this.each((t==null?oh:typeof t==="function"?sh:ih)(e,t,r==null?"":r)):Ge(this.node(),e)}function Ge(e,t){return e.style.getPropertyValue(t)||Yt(e).getComputedStyle(e,null).getPropertyValue(t)}function ah(e){return function(){delete this[e]}}function ch(e,t){return function(){this[e]=t}}function uh(e,t){return function(){var r=t.apply(this,arguments);if(r==null)delete this[e];else this[e]=r}}function fi(e,t){return arguments.length>1?this.each((t==null?ah:typeof t==="function"?uh:ch)(e,t)):this.node()[e]}function fp(e){return e.trim().split(/^|\s+/)}function mi(e){return e.classList||new mp(e)}function mp(e){this._node=e,this._names=fp(e.getAttribute("class")||"")}mp.prototype={add:function(e){var t=this._names.indexOf(e);if(t<0)this._names.push(e),this._node.setAttribute("class",this._names.join(" "))},remove:function(e){var t=this._names.indexOf(e);if(t>=0)this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" "))},contains:function(e){return this._names.indexOf(e)>=0}};function hp(e,t){var r=mi(e),n=-1,o=t.length;while(++n<o)r.add(t[n])}function gp(e,t){var r=mi(e),n=-1,o=t.length;while(++n<o)r.remove(t[n])}function lh(e){return function(){hp(this,e)}}function ph(e){return function(){gp(this,e)}}function dh(e,t){return function(){(t.apply(this,arguments)?hp:gp)(this,e)}}function hi(e,t){var r=fp(e+"");if(arguments.length<2){var n=mi(this.node()),o=-1,i=r.length;while(++o<i)if(!n.contains(r[o]))return!1;return!0}return this.each((typeof t==="function"?dh:t?lh:ph)(r,t))}function fh(){this.textContent=""}function mh(e){return function(){this.textContent=e}}function hh(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function gi(e){return arguments.length?this.each(e==null?fh:(typeof e==="function"?hh:mh)(e)):this.node().textContent}function gh(){this.innerHTML=""}function xh(e){return function(){this.innerHTML=e}}function yh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function xi(e){return arguments.length?this.each(e==null?gh:(typeof e==="function"?yh:xh)(e)):this.node().innerHTML}function bh(){if(this.nextSibling)this.parentNode.appendChild(this)}function yi(){return this.each(bh)}function vh(){if(this.previousSibling)this.parentNode.insertBefore(this,this.parentNode.firstChild)}function bi(){return this.each(vh)}function _h(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===on&&t.documentElement.namespaceURI===on?t.createElement(e):t.createElementNS(r,e)}}function wh(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Xt(e){var t=Se(e);return(t.local?wh:_h)(t)}function vi(e){var t=typeof e==="function"?e:Xt(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function kh(){return null}function _i(e,t){var r=typeof e==="function"?e:Xt(e),n=t==null?kh:typeof t==="function"?t:He(t);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}function zh(){var e=this.parentNode;if(e)e.removeChild(this)}function wi(){return this.each(zh)}function $h(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Sh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ki(e){return this.select(e?Sh:$h)}function zi(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Ih(e){return function(t){e.call(this,t,this.__data__)}}function Ph(e){return e.trim().split(/^|\s+/).map(function(t){var r="",n=t.indexOf(".");if(n>=0)r=t.slice(n+1),t=t.slice(0,n);return{type:t,name:r}})}function Zh(e){return function(){var t=this.__on;if(!t)return;for(var r=0,n=-1,o=t.length,i;r<o;++r)if(i=t[r],(!e.type||i.type===e.type)&&i.name===e.name)this.removeEventListener(i.type,i.listener,i.options);else t[++n]=i;if(++n)t.length=n;else delete this.__on}}function Eh(e,t,r){return function(){var n=this.__on,o,i=Ih(t);if(n){for(var s=0,a=n.length;s<a;++s)if((o=n[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=r),o.value=t;return}}if(this.addEventListener(e.type,i,r),o={type:e.type,name:e.name,value:t,listener:i,options:r},!n)this.__on=[o];else n.push(o)}}function $i(e,t,r){var n=Ph(e+""),o,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,u=a.length,l;c<u;++c)for(o=0,l=a[c];o<i;++o)if((s=n[o]).type===l.type&&s.name===l.name)return l.value}return}a=t?Eh:Zh;for(o=0;o<i;++o)this.each(a(n[o],t,r));return this}function xp(e,t,r){var n=Yt(e),o=n.CustomEvent;if(typeof o==="function")o=new o(t,r);else if(o=n.document.createEvent("Event"),r)o.initEvent(t,r.bubbles,r.cancelable),o.detail=r.detail;else o.initEvent(t,!1,!1);e.dispatchEvent(o)}function Oh(e,t){return function(){return xp(this,e,t)}}function Ah(e,t){return function(){return xp(this,e,t.apply(this,arguments))}}function Si(e,t){return this.each((typeof t==="function"?Ah:Oh)(e,t))}function*Ii(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var n=e[t],o=0,i=n.length,s;o<i;++o)if(s=n[o])yield s}var Pi=[null];function U(e,t){this._groups=e,this._parents=t}function yp(){return new U([[document.documentElement]],Pi)}function Ch(){return this}U.prototype=yp.prototype={constructor:U,select:Vo,selectAll:Ho,selectChild:Go,selectChildren:Ko,filter:Yo,data:Qo,enter:Xo,exit:ei,join:ti,merge:ri,selection:Ch,order:ni,sort:oi,call:ii,nodes:si,node:ai,size:ci,empty:ui,each:li,attr:pi,style:di,property:fi,classed:hi,text:gi,html:xi,raise:yi,lower:bi,append:vi,insert:_i,remove:wi,clone:ki,datum:zi,on:$i,dispatch:Si,[Symbol.iterator]:Ii};var Me=yp;function Q(e){return typeof e==="string"?new U([[document.querySelector(e)]],[document.documentElement]):new U([[e]],Pi)}var Th={value:()=>{}};function vp(){for(var e=0,t=arguments.length,r={},n;e<t;++e){if(!(n=arguments[e]+"")||n in r||/[\s.]/.test(n))throw Error("illegal type: "+n);r[n]=[]}return new sn(r)}function sn(e){this._=e}function Nh(e,t){return e.trim().split(/^|\s+/).map(function(r){var n="",o=r.indexOf(".");if(o>=0)n=r.slice(o+1),r=r.slice(0,o);if(r&&!t.hasOwnProperty(r))throw Error("unknown type: "+r);return{type:r,name:n}})}sn.prototype=vp.prototype={constructor:sn,on:function(e,t){var r=this._,n=Nh(e+"",r),o,i=-1,s=n.length;if(arguments.length<2){while(++i<s)if((o=(e=n[i]).type)&&(o=Rh(r[o],e.name)))return o;return}if(t!=null&&typeof t!=="function")throw Error("invalid callback: "+t);while(++i<s)if(o=(e=n[i]).type)r[o]=bp(r[o],e.name,t);else if(t==null)for(o in r)r[o]=bp(r[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var r in t)e[r]=t[r].slice();return new sn(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var r=Array(o),n=0,o,i;n<o;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(i=this._[e],n=0,o=i.length;n<o;++n)i[n].value.apply(t,r)},apply:function(e,t,r){if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(var n=this._[e],o=0,i=n.length;o<i;++o)n[o].value.apply(t,r)}};function Rh(e,t){for(var r=0,n=e.length,o;r<n;++r)if((o=e[r]).name===t)return o.value}function bp(e,t,r){for(var n=0,o=e.length;n<o;++n)if(e[n].name===t){e[n]=Th,e=e.slice(0,n).concat(e.slice(n+1));break}if(r!=null)e.push({name:t,value:r});return e}var Wt=vp;var an={capture:!0,passive:!1};function Qt(e){e.preventDefault(),e.stopImmediatePropagation()}function cn(e){var t=e.document.documentElement,r=Q(e).on("dragstart.drag",Qt,an);if("onselectstart"in t)r.on("selectstart.drag",Qt,an);else t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none"}function Zi(e,t){var r=e.document.documentElement,n=Q(e).on("dragstart.drag",null);if(t)n.on("click.drag",Qt,an),setTimeout(function(){n.on("click.drag",null)},0);if("onselectstart"in r)n.on("selectstart.drag",null);else r.style.MozUserSelect=r.__noselect,delete r.__noselect}function le(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}var Oi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ei=new RegExp(Oi.source,"g");function Mh(e){return function(){return e}}function Lh(e){return function(t){return e(t)+""}}function un(e,t){var r=Oi.lastIndex=Ei.lastIndex=0,n,o,i,s=-1,a=[],c=[];e=e+"",t=t+"";while((n=Oi.exec(e))&&(o=Ei.exec(t))){if((i=o.index)>r)if(i=t.slice(r,i),a[s])a[s]+=i;else a[++s]=i;if((n=n[0])===(o=o[0]))if(a[s])a[s]+=o;else a[++s]=o;else a[++s]=null,c.push({i:s,x:le(n,o)});r=Ei.lastIndex}if(r<t.length)if(i=t.slice(r),a[s])a[s]+=i;else a[++s]=i;return a.length<2?c[0]?Lh(c[0].x):Mh(t):(t=c.length,function(u){for(var l=0,p;l<t;++l)a[(p=c[l]).i]=p.x(u);return a.join("")})}var _p=180/Math.PI,ln={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function pn(e,t,r,n,o,i){var s,a,c;if(s=Math.sqrt(e*e+t*t))e/=s,t/=s;if(c=e*r+t*n)r-=e*c,n-=t*c;if(a=Math.sqrt(r*r+n*n))r/=a,n/=a,c/=a;if(e*n<t*r)e=-e,t=-t,c=-c,s=-s;return{translateX:o,translateY:i,rotate:Math.atan2(t,e)*_p,skewX:Math.atan(c)*_p,scaleX:s,scaleY:a}}var dn;function wp(e){let t=new(typeof DOMMatrix==="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ln:pn(t.a,t.b,t.c,t.d,t.e,t.f)}function kp(e){if(e==null)return ln;if(!dn)dn=document.createElementNS("http://www.w3.org/2000/svg","g");if(dn.setAttribute("transform",e),!(e=dn.transform.baseVal.consolidate()))return ln;return e=e.matrix,pn(e.a,e.b,e.c,e.d,e.e,e.f)}function zp(e,t,r,n){function o(u){return u.length?u.pop()+" ":""}function i(u,l,p,d,f,m){if(u!==p||l!==d){var x=f.push("translate(",null,t,null,r);m.push({i:x-4,x:le(u,p)},{i:x-2,x:le(l,d)})}else if(p||d)f.push("translate("+p+t+d+r)}function s(u,l,p,d){if(u!==l){if(u-l>180)l+=360;else if(l-u>180)u+=360;d.push({i:p.push(o(p)+"rotate(",null,n)-2,x:le(u,l)})}else if(l)p.push(o(p)+"rotate("+l+n)}function a(u,l,p,d){if(u!==l)d.push({i:p.push(o(p)+"skewX(",null,n)-2,x:le(u,l)});else if(l)p.push(o(p)+"skewX("+l+n)}function c(u,l,p,d,f,m){if(u!==p||l!==d){var x=f.push(o(f)+"scale(",null,",",null,")");m.push({i:x-4,x:le(u,p)},{i:x-2,x:le(l,d)})}else if(p!==1||d!==1)f.push(o(f)+"scale("+p+","+d+")")}return function(u,l){var p=[],d=[];return u=e(u),l=e(l),i(u.translateX,u.translateY,l.translateX,l.translateY,p,d),s(u.rotate,l.rotate,p,d),a(u.skewX,l.skewX,p,d),c(u.scaleX,u.scaleY,l.scaleX,l.scaleY,p,d),u=l=null,function(f){var m=-1,x=d.length,_;while(++m<x)p[(_=d[m]).i]=_.x(f);return p.join("")}}}var Ai=zp(wp,"px, ","px)","deg)"),Ci=zp(kp,", ",")",")");var Dh=0.000000000001;function $p(e){return((e=Math.exp(e))+1/e)/2}function Bh(e){return((e=Math.exp(e))-1/e)/2}function jh(e){return((e=Math.exp(2*e))-1)/(e+1)}var Ti=function e(t,r,n){function o(i,s){var a=i[0],c=i[1],u=i[2],l=s[0],p=s[1],d=s[2],f=l-a,m=p-c,x=f*f+m*m,_,v;if(x<Dh)v=Math.log(d/u)/t,_=function(G){return[a+G*f,c+G*m,u*Math.exp(t*G*v)]};else{var P=Math.sqrt(x),L=(d*d-u*u+n*x)/(2*u*r*P),j=(d*d-u*u-n*x)/(2*d*r*P),T=Math.log(Math.sqrt(L*L+1)-L),O=Math.log(Math.sqrt(j*j+1)-j);v=(O-T)/t,_=function(G){var je=G*v,Qe=$p(T),Fe=u/(r*P)*(Qe*jh(t*je+T)-Bh(T));return[a+Fe*f,c+Fe*m,u*Qe/$p(t*je+T)]}}return _.duration=v*1000*t/Math.SQRT2,_}return o.rho=function(i){var s=Math.max(0.001,+i),a=s*s,c=a*a;return e(s,a,c)},o}(Math.SQRT2,2,4);function er(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function Ni(e,t){var r=Object.create(e.prototype);for(var n in t)r[n]=t[n];return r}function nr(){}var tr=0.7,hn=1/tr,wt="\\s*([+-]?\\d+)\\s*",rr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Pe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Fh=/^#([0-9a-f]{3,8})$/,Uh=new RegExp(`^rgb\\(${wt},${wt},${wt}\\)$`),qh=new RegExp(`^rgb\\(${Pe},${Pe},${Pe}\\)$`),Vh=new RegExp(`^rgba\\(${wt},${wt},${wt},${rr}\\)$`),Jh=new RegExp(`^rgba\\(${Pe},${Pe},${Pe},${rr}\\)$`),Hh=new RegExp(`^hsl\\(${rr},${Pe},${Pe}\\)$`),Gh=new RegExp(`^hsla\\(${rr},${Pe},${Pe},${rr}\\)$`),Sp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};er(nr,Ke,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ip,formatHex:Ip,formatHex8:Kh,formatHsl:Yh,formatRgb:Pp,toString:Pp});function Ip(){return this.rgb().formatHex()}function Kh(){return this.rgb().formatHex8()}function Yh(){return Tp(this).formatHsl()}function Pp(){return this.rgb().formatRgb()}function Ke(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=Fh.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?Zp(t):r===3?new se(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?fn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?fn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Uh.exec(e))?new se(t[1],t[2],t[3],1):(t=qh.exec(e))?new se(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Vh.exec(e))?fn(t[1],t[2],t[3],t[4]):(t=Jh.exec(e))?fn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Hh.exec(e))?Ap(t[1],t[2]/100,t[3]/100,1):(t=Gh.exec(e))?Ap(t[1],t[2]/100,t[3]/100,t[4]):Sp.hasOwnProperty(e)?Zp(Sp[e]):e==="transparent"?new se(NaN,NaN,NaN,0):null}function Zp(e){return new se(e>>16&255,e>>8&255,e&255,1)}function fn(e,t,r,n){if(n<=0)e=t=r=NaN;return new se(e,t,r,n)}function Xh(e){if(!(e instanceof nr))e=Ke(e);if(!e)return new se;return e=e.rgb(),new se(e.r,e.g,e.b,e.opacity)}function kt(e,t,r,n){return arguments.length===1?Xh(e):new se(e,t,r,n==null?1:n)}function se(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}er(se,kt,Ni(nr,{brighter(e){return e=e==null?hn:Math.pow(hn,e),new se(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?tr:Math.pow(tr,e),new se(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new se(ct(this.r),ct(this.g),ct(this.b),gn(this.opacity))},displayable(){return-0.5<=this.r&&this.r<255.5&&(-0.5<=this.g&&this.g<255.5)&&(-0.5<=this.b&&this.b<255.5)&&(0<=this.opacity&&this.opacity<=1)},hex:Ep,formatHex:Ep,formatHex8:Wh,formatRgb:Op,toString:Op}));function Ep(){return`#${at(this.r)}${at(this.g)}${at(this.b)}`}function Wh(){return`#${at(this.r)}${at(this.g)}${at(this.b)}${at((isNaN(this.opacity)?1:this.opacity)*255)}`}function Op(){let e=gn(this.opacity);return`${e===1?"rgb(":"rgba("}${ct(this.r)}, ${ct(this.g)}, ${ct(this.b)}${e===1?")":`, ${e})`}`}function gn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ct(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function at(e){return e=ct(e),(e<16?"0":"")+e.toString(16)}function Ap(e,t,r,n){if(n<=0)e=t=r=NaN;else if(r<=0||r>=1)e=t=NaN;else if(t<=0)e=NaN;return new xe(e,t,r,n)}function Tp(e){if(e instanceof xe)return new xe(e.h,e.s,e.l,e.opacity);if(!(e instanceof nr))e=Ke(e);if(!e)return new xe;if(e instanceof xe)return e;e=e.rgb();var t=e.r/255,r=e.g/255,n=e.b/255,o=Math.min(t,r,n),i=Math.max(t,r,n),s=NaN,a=i-o,c=(i+o)/2;if(a){if(t===i)s=(r-n)/a+(r<n)*6;else if(r===i)s=(n-t)/a+2;else s=(t-r)/a+4;a/=c<0.5?i+o:2-i-o,s*=60}else a=c>0&&c<1?0:s;return new xe(s,a,c,e.opacity)}function Np(e,t,r,n){return arguments.length===1?Tp(e):new xe(e,t,r,n==null?1:n)}function xe(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}er(xe,Np,Ni(nr,{brighter(e){return e=e==null?hn:Math.pow(hn,e),new xe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?tr:Math.pow(tr,e),new xe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<0.5?r:1-r)*t,o=2*r-n;return new se(Ri(e>=240?e-240:e+120,o,n),Ri(e,o,n),Ri(e<120?e+240:e-120,o,n),this.opacity)},clamp(){return new xe(Cp(this.h),mn(this.s),mn(this.l),gn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&(0<=this.l&&this.l<=1)&&(0<=this.opacity&&this.opacity<=1)},formatHsl(){let e=gn(this.opacity);return`${e===1?"hsl(":"hsla("}${Cp(this.h)}, ${mn(this.s)*100}%, ${mn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Cp(e){return e=(e||0)%360,e<0?e+360:e}function mn(e){return Math.max(0,Math.min(1,e||0))}function Ri(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}function Mi(e,t,r,n,o){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*r+(1+3*e+3*i-3*s)*n+s*o)/6}function Li(e){var t=e.length-1;return function(r){var n=r<=0?r=0:r>=1?(r=1,t-1):Math.floor(r*t),o=e[n],i=e[n+1],s=n>0?e[n-1]:2*o-i,a=n<t-1?e[n+2]:2*i-o;return Mi((r-n/t)*t,s,o,i,a)}}function Di(e){var t=e.length;return function(r){var n=Math.floor(((r%=1)<0?++r:r)*t),o=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return Mi((r-n/t)*t,o,i,s,a)}}var Bi=(e)=>()=>e;function Qh(e,t){return function(r){return e+r*t}}function eg(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(n){return Math.pow(e+n*t,r)}}function Rp(e){return(e=+e)===1?xn:function(t,r){return r-t?eg(t,r,e):Bi(isNaN(t)?r:t)}}function xn(e,t){var r=t-e;return r?Qh(e,r):Bi(isNaN(e)?t:e)}var yn=function e(t){var r=Rp(t);function n(o,i){var s=r((o=kt(o)).r,(i=kt(i)).r),a=r(o.g,i.g),c=r(o.b,i.b),u=xn(o.opacity,i.opacity);return function(l){return o.r=s(l),o.g=a(l),o.b=c(l),o.opacity=u(l),o+""}}return n.gamma=e,n}(1);function Mp(e){return function(t){var r=t.length,n=Array(r),o=Array(r),i=Array(r),s,a;for(s=0;s<r;++s)a=kt(t[s]),n[s]=a.r||0,o[s]=a.g||0,i[s]=a.b||0;return n=e(n),o=e(o),i=e(i),a.opacity=1,function(c){return a.r=n(c),a.g=o(c),a.b=i(c),a+""}}}var tg=Mp(Li),rg=Mp(Di);var zt=0,ir=0,or=0,Dp=1000,bn,sr,vn=0,ut=0,_n=0,ar=typeof performance==="object"&&performance.now?performance:Date,Bp=typeof window==="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ur(){return ut||(Bp(ng),ut=ar.now()+_n)}function ng(){ut=0}function cr(){this._call=this._time=this._next=null}cr.prototype=wn.prototype={constructor:cr,restart:function(e,t,r){if(typeof e!=="function")throw TypeError("callback is not a function");if(r=(r==null?ur():+r)+(t==null?0:+t),!this._next&&sr!==this){if(sr)sr._next=this;else bn=this;sr=this}this._call=e,this._time=r,ji()},stop:function(){if(this._call)this._call=null,this._time=1/0,ji()}};function wn(e,t,r){var n=new cr;return n.restart(e,t,r),n}function jp(){ur(),++zt;var e=bn,t;while(e){if((t=ut-e._time)>=0)e._call.call(void 0,t);e=e._next}--zt}function Lp(){ut=(vn=ar.now())+_n,zt=ir=0;try{jp()}finally{zt=0,ig(),ut=0}}function og(){var e=ar.now(),t=e-vn;if(t>Dp)_n-=t,vn=e}function ig(){var e,t=bn,r,n=1/0;while(t)if(t._call){if(n>t._time)n=t._time;e=t,t=t._next}else r=t._next,t._next=null,t=e?e._next=r:bn=r;sr=e,ji(n)}function ji(e){if(zt)return;if(ir)ir=clearTimeout(ir);var t=e-ut;if(t>24){if(e<1/0)ir=setTimeout(Lp,e-ar.now()-_n);if(or)or=clearInterval(or)}else{if(!or)vn=ar.now(),or=setInterval(og,Dp);zt=1,Bp(Lp)}}function lr(e,t,r){var n=new cr;return t=t==null?0:+t,n.restart((o)=>{n.stop(),e(o+t)},t,r),n}var sg=Wt("start","end","cancel","interrupt"),ag=[],qp=0,Fp=1,zn=2,kn=3,Up=4,$n=5,pr=6;function Le(e,t,r,n,o,i){var s=e.__transition;if(!s)e.__transition={};else if(r in s)return;cg(e,r,{name:t,index:n,group:o,on:sg,tween:ag,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:qp})}function dr(e,t){var r=K(e,t);if(r.state>qp)throw Error("too late; already scheduled");return r}function ee(e,t){var r=K(e,t);if(r.state>kn)throw Error("too late; already running");return r}function K(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw Error("transition not found");return r}function cg(e,t,r){var n=e.__transition,o;n[t]=r,r.timer=wn(i,0,r.time);function i(u){if(r.state=Fp,r.timer.restart(s,r.delay,r.time),r.delay<=u)s(u-r.delay)}function s(u){var l,p,d,f;if(r.state!==Fp)return c();for(l in n){if(f=n[l],f.name!==r.name)continue;if(f.state===kn)return lr(s);if(f.state===Up)f.state=pr,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[l];else if(+l<t)f.state=pr,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[l]}if(lr(function(){if(r.state===kn)r.state=Up,r.timer.restart(a,r.delay,r.time),a(u)}),r.state=zn,r.on.call("start",e,e.__data__,r.index,r.group),r.state!==zn)return;r.state=kn,o=Array(d=r.tween.length);for(l=0,p=-1;l<d;++l)if(f=r.tween[l].value.call(e,e.__data__,r.index,r.group))o[++p]=f;o.length=p+1}function a(u){var l=u<r.duration?r.ease.call(null,u/r.duration):(r.timer.restart(c),r.state=$n,1),p=-1,d=o.length;while(++p<d)o[p].call(e,l);if(r.state===$n)r.on.call("end",e,e.__data__,r.index,r.group),c()}function c(){r.state=pr,r.timer.stop(),delete n[t];for(var u in n)return;delete e.__transition}}function Ye(e,t){var r=e.__transition,n,o,i=!0,s;if(!r)return;t=t==null?null:t+"";for(s in r){if((n=r[s]).name!==t){i=!1;continue}o=n.state>zn&&n.state<$n,n.state=pr,n.timer.stop(),n.on.call(o?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete r[s]}if(i)delete e.__transition}function Fi(e){return this.each(function(){Ye(this,e)})}function ug(e,t){var r,n;return function(){var o=ee(this,e),i=o.tween;if(i!==r){n=r=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}o.tween=n}}function lg(e,t,r){var n,o;if(typeof r!=="function")throw Error();return function(){var i=ee(this,e),s=i.tween;if(s!==n){o=(n=s).slice();for(var a={name:t,value:r},c=0,u=o.length;c<u;++c)if(o[c].name===t){o[c]=a;break}if(c===u)o.push(a)}i.tween=o}}function Ui(e,t){var r=this._id;if(e+="",arguments.length<2){var n=K(this.node(),r).tween;for(var o=0,i=n.length,s;o<i;++o)if((s=n[o]).name===e)return s.value;return null}return this.each((t==null?ug:lg)(r,e,t))}function $t(e,t,r){var n=e._id;return e.each(function(){var o=ee(this,n);(o.value||(o.value={}))[t]=r.apply(this,arguments)}),function(o){return K(o,n).value[t]}}function fr(e,t){var r;return(typeof t==="number"?le:t instanceof Ke?yn:(r=Ke(t))?(t=r,yn):un)(e,t)}function pg(e){return function(){this.removeAttribute(e)}}function dg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fg(e,t,r){var n,o=r+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===n?i:i=t(n=s,r)}}function mg(e,t,r){var n,o=r+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===n?i:i=t(n=s,r)}}function hg(e,t,r){var n,o,i;return function(){var s,a=r(this),c;if(a==null)return void this.removeAttribute(e);return s=this.getAttribute(e),c=a+"",s===c?null:s===n&&c===o?i:(o=c,i=t(n=s,a))}}function gg(e,t,r){var n,o,i;return function(){var s,a=r(this),c;if(a==null)return void this.removeAttributeNS(e.space,e.local);return s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===n&&c===o?i:(o=c,i=t(n=s,a))}}function qi(e,t){var r=Se(e),n=r==="transform"?Ci:fr;return this.attrTween(e,typeof t==="function"?(r.local?gg:hg)(r,n,$t(this,"attr."+e,t)):t==null?(r.local?dg:pg)(r):(r.local?mg:fg)(r,n,t))}function xg(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function yg(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function bg(e,t){var r,n;function o(){var i=t.apply(this,arguments);if(i!==n)r=(n=i)&&yg(e,i);return r}return o._value=t,o}function vg(e,t){var r,n;function o(){var i=t.apply(this,arguments);if(i!==n)r=(n=i)&&xg(e,i);return r}return o._value=t,o}function Vi(e,t){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=="function")throw Error();var n=Se(e);return this.tween(r,(n.local?bg:vg)(n,t))}function _g(e,t){return function(){dr(this,e).delay=+t.apply(this,arguments)}}function wg(e,t){return t=+t,function(){dr(this,e).delay=t}}function Ji(e){var t=this._id;return arguments.length?this.each((typeof e==="function"?_g:wg)(t,e)):K(this.node(),t).delay}function kg(e,t){return function(){ee(this,e).duration=+t.apply(this,arguments)}}function zg(e,t){return t=+t,function(){ee(this,e).duration=t}}function Hi(e){var t=this._id;return arguments.length?this.each((typeof e==="function"?kg:zg)(t,e)):K(this.node(),t).duration}function $g(e,t){if(typeof t!=="function")throw Error();return function(){ee(this,e).ease=t}}function Gi(e){var t=this._id;return arguments.length?this.each($g(t,e)):K(this.node(),t).ease}function Sg(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!=="function")throw Error();ee(this,e).ease=r}}function Ki(e){if(typeof e!=="function")throw Error();return this.each(Sg(this._id,e))}function Yi(e){if(typeof e!=="function")e=vt(e);for(var t=this._groups,r=t.length,n=Array(r),o=0;o<r;++o)for(var i=t[o],s=i.length,a=n[o]=[],c,u=0;u<s;++u)if((c=i[u])&&e.call(c,c.__data__,u,i))a.push(c);return new re(n,this._parents,this._name,this._id)}function Xi(e){if(e._id!==this._id)throw Error();for(var t=this._groups,r=e._groups,n=t.length,o=r.length,i=Math.min(n,o),s=Array(n),a=0;a<i;++a)for(var c=t[a],u=r[a],l=c.length,p=s[a]=Array(l),d,f=0;f<l;++f)if(d=c[f]||u[f])p[f]=d;for(;a<n;++a)s[a]=t[a];return new re(s,this._parents,this._name,this._id)}function Ig(e){return(e+"").trim().split(/^|\s+/).every(function(t){var r=t.indexOf(".");if(r>=0)t=t.slice(0,r);return!t||t==="start"})}function Pg(e,t,r){var n,o,i=Ig(t)?dr:ee;return function(){var s=i(this,e),a=s.on;if(a!==n)(o=(n=a).copy()).on(t,r);s.on=o}}function Wi(e,t){var r=this._id;return arguments.length<2?K(this.node(),r).on.on(e):this.each(Pg(r,e,t))}function Zg(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;if(t)t.removeChild(this)}}function Qi(){return this.on("end.remove",Zg(this._id))}function es(e){var t=this._name,r=this._id;if(typeof e!=="function")e=He(e);for(var n=this._groups,o=n.length,i=Array(o),s=0;s<o;++s)for(var a=n[s],c=a.length,u=i[s]=Array(c),l,p,d=0;d<c;++d)if((l=a[d])&&(p=e.call(l,l.__data__,d,a))){if("__data__"in l)p.__data__=l.__data__;u[d]=p,Le(u[d],t,r,d,u,K(l,r))}return new re(i,this._parents,t,r)}function ts(e){var t=this._name,r=this._id;if(typeof e!=="function")e=_t(e);for(var n=this._groups,o=n.length,i=[],s=[],a=0;a<o;++a)for(var c=n[a],u=c.length,l,p=0;p<u;++p)if(l=c[p]){for(var d=e.call(l,l.__data__,p,c),f,m=K(l,r),x=0,_=d.length;x<_;++x)if(f=d[x])Le(f,t,r,x,d,m);i.push(d),s.push(l)}return new re(i,s,t,r)}var Eg=Me.prototype.constructor;function rs(){return new Eg(this._groups,this._parents)}function Og(e,t){var r,n,o;return function(){var i=Ge(this,e),s=(this.style.removeProperty(e),Ge(this,e));return i===s?null:i===r&&s===n?o:o=t(r=i,n=s)}}function Vp(e){return function(){this.style.removeProperty(e)}}function Ag(e,t,r){var n,o=r+"",i;return function(){var s=Ge(this,e);return s===o?null:s===n?i:i=t(n=s,r)}}function Cg(e,t,r){var n,o,i;return function(){var s=Ge(this,e),a=r(this),c=a+"";if(a==null)c=a=(this.style.removeProperty(e),Ge(this,e));return s===c?null:s===n&&c===o?i:(o=c,i=t(n=s,a))}}function Tg(e,t){var r,n,o,i="style."+t,s="end."+i,a;return function(){var c=ee(this,e),u=c.on,l=c.value[i]==null?a||(a=Vp(t)):void 0;if(u!==r||o!==l)(n=(r=u).copy()).on(s,o=l);c.on=n}}function ns(e,t,r){var n=(e+="")==="transform"?Ai:fr;return t==null?this.styleTween(e,Og(e,n)).on("end.style."+e,Vp(e)):typeof t==="function"?this.styleTween(e,Cg(e,n,$t(this,"style."+e,t))).each(Tg(this._id,e)):this.styleTween(e,Ag(e,n,t),r).on("end.style."+e,null)}function Ng(e,t,r){return function(n){this.style.setProperty(e,t.call(this,n),r)}}function Rg(e,t,r){var n,o;function i(){var s=t.apply(this,arguments);if(s!==o)n=(o=s)&&Ng(e,s,r);return n}return i._value=t,i}function os(e,t,r){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=="function")throw Error();return this.tween(n,Rg(e,t,r==null?"":r))}function Mg(e){return function(){this.textContent=e}}function Lg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function is(e){return this.tween("text",typeof e==="function"?Lg($t(this,"text",e)):Mg(e==null?"":e+""))}function Dg(e){return function(t){this.textContent=e.call(this,t)}}function Bg(e){var t,r;function n(){var o=e.apply(this,arguments);if(o!==r)t=(r=o)&&Dg(o);return t}return n._value=e,n}function ss(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=="function")throw Error();return this.tween(t,Bg(e))}function as(){var e=this._name,t=this._id,r=Sn();for(var n=this._groups,o=n.length,i=0;i<o;++i)for(var s=n[i],a=s.length,c,u=0;u<a;++u)if(c=s[u]){var l=K(c,t);Le(c,e,r,u,s,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new re(n,this._parents,e,r)}function cs(){var e,t,r=this,n=r._id,o=r.size();return new Promise(function(i,s){var a={value:s},c={value:function(){if(--o===0)i()}};if(r.each(function(){var u=ee(this,n),l=u.on;if(l!==e)t=(e=l).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c);u.on=t}),o===0)i()})}var jg=0;function re(e,t,r,n){this._groups=e,this._parents=t,this._name=r,this._id=n}function Jp(e){return Me().transition(e)}function Sn(){return++jg}var De=Me.prototype;re.prototype=Jp.prototype={constructor:re,select:es,selectAll:ts,selectChild:De.selectChild,selectChildren:De.selectChildren,filter:Yi,merge:Xi,selection:rs,transition:as,call:De.call,nodes:De.nodes,node:De.node,size:De.size,empty:De.empty,each:De.each,on:Wi,attr:qi,attrTween:Vi,style:ns,styleTween:os,text:is,textTween:ss,remove:Qi,tween:Ui,delay:Ji,duration:Hi,ease:Gi,easeVarying:Ki,end:cs,[Symbol.iterator]:De[Symbol.iterator]};function In(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Fg={time:null,delay:0,duration:250,ease:In};function Ug(e,t){var r;while(!(r=e.__transition)||!(r=r[t]))if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return r}function us(e){var t,r;if(e instanceof re)t=e._id,e=e._name;else t=Sn(),(r=Fg).time=ur(),e=e==null?null:e+"";for(var n=this._groups,o=n.length,i=0;i<o;++i)for(var s=n[i],a=s.length,c,u=0;u<a;++u)if(c=s[u])Le(c,e,t,u,s,r||Ug(c,t));return new re(n,this._parents,e,t)}Me.prototype.interrupt=Fi;Me.prototype.transition=us;var mr=(e)=>()=>e;function ls(e,{sourceEvent:t,target:r,transform:n,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:o}})}function ye(e,t,r){this.k=e,this.x=t,this.y=r}ye.prototype={constructor:ye,scale:function(e){return e===1?this:new ye(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ye(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ze=new ye(1,0,0);hr.prototype=ye.prototype;function hr(e){while(!e.__zoom)if(!(e=e.parentNode))return Ze;return e.__zoom}function Pn(e){e.stopImmediatePropagation()}function lt(e){e.preventDefault(),e.stopImmediatePropagation()}function qg(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Vg(){var e=this;if(e instanceof SVGElement){if(e=e.ownerSVGElement||e,e.hasAttribute("viewBox"))return e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]];return[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]}return[[0,0],[e.clientWidth,e.clientHeight]]}function Hp(){return this.__zoom||Ze}function Jg(e){return-e.deltaY*(e.deltaMode===1?0.05:e.deltaMode?1:0.002)*(e.ctrlKey?10:1)}function Hg(){return navigator.maxTouchPoints||"ontouchstart"in this}function Gg(e,t,r){var n=e.invertX(t[0][0])-r[0][0],o=e.invertX(t[1][0])-r[1][0],i=e.invertY(t[0][1])-r[0][1],s=e.invertY(t[1][1])-r[1][1];return e.translate(o>n?(n+o)/2:Math.min(0,n)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Zn(){var e=qg,t=Vg,r=Gg,n=Jg,o=Hg,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Ti,u=Wt("start","zoom","end"),l,p,d,f=500,m=150,x=0,_=10;function v(h){h.property("__zoom",Hp).on("wheel.zoom",je,{passive:!1}).on("mousedown.zoom",Qe).on("dblclick.zoom",Fe).filter(o).on("touchstart.zoom",_r).on("touchmove.zoom",Tn).on("touchend.zoom touchcancel.zoom",Nn).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(h,S,y,I){var E=h.selection?h.selection():h;if(E.property("__zoom",Hp),h!==E)T(h,S,y,I);else E.interrupt().each(function(){O(this,arguments).event(I).start().zoom(null,typeof S==="function"?S.apply(this,arguments):S).end()})},v.scaleBy=function(h,S,y,I){v.scaleTo(h,function(){var E=this.__zoom.k,A=typeof S==="function"?S.apply(this,arguments):S;return E*A},y,I)},v.scaleTo=function(h,S,y,I){v.transform(h,function(){var E=t.apply(this,arguments),A=this.__zoom,C=y==null?j(E):typeof y==="function"?y.apply(this,arguments):y,R=A.invert(C),q=typeof S==="function"?S.apply(this,arguments):S;return r(L(P(A,q),C,R),E,s)},y,I)},v.translateBy=function(h,S,y,I){v.transform(h,function(){return r(this.__zoom.translate(typeof S==="function"?S.apply(this,arguments):S,typeof y==="function"?y.apply(this,arguments):y),t.apply(this,arguments),s)},null,I)},v.translateTo=function(h,S,y,I,E){v.transform(h,function(){var A=t.apply(this,arguments),C=this.__zoom,R=I==null?j(A):typeof I==="function"?I.apply(this,arguments):I;return r(Ze.translate(R[0],R[1]).scale(C.k).translate(typeof S==="function"?-S.apply(this,arguments):-S,typeof y==="function"?-y.apply(this,arguments):-y),A,s)},I,E)};function P(h,S){return S=Math.max(i[0],Math.min(i[1],S)),S===h.k?h:new ye(S,h.x,h.y)}function L(h,S,y){var I=S[0]-y[0]*h.k,E=S[1]-y[1]*h.k;return I===h.x&&E===h.y?h:new ye(h.k,I,E)}function j(h){return[(+h[0][0]+ +h[1][0])/2,(+h[0][1]+ +h[1][1])/2]}function T(h,S,y,I){h.on("start.zoom",function(){O(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(I).end()}).tween("zoom",function(){var E=this,A=arguments,C=O(E,A).event(I),R=t.apply(E,A),q=y==null?j(R):typeof y==="function"?y.apply(E,A):y,be=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),Y=E.__zoom,fe=typeof S==="function"?S.apply(E,A):S,Oe=c(Y.invert(q).concat(be/Y.k),fe.invert(q).concat(be/fe.k));return function(me){if(me===1)me=fe;else{var Ae=Oe(me),Rn=be/Ae[2];me=new ye(Rn,q[0]-Ae[0]*Rn,q[1]-Ae[1]*Rn)}C.zoom(null,me)}})}function O(h,S,y){return!y&&h.__zooming||new G(h,S)}function G(h,S){this.that=h,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(h,S),this.taps=0}G.prototype={event:function(h){if(h)this.sourceEvent=h;return this},start:function(){if(++this.active===1)this.that.__zooming=this,this.emit("start");return this},zoom:function(h,S){if(this.mouse&&h!=="mouse")this.mouse[1]=S.invert(this.mouse[0]);if(this.touch0&&h!=="touch")this.touch0[1]=S.invert(this.touch0[0]);if(this.touch1&&h!=="touch")this.touch1[1]=S.invert(this.touch1[0]);return this.that.__zoom=S,this.emit("zoom"),this},end:function(){if(--this.active===0)delete this.that.__zooming,this.emit("end");return this},emit:function(h){var S=Q(this.that).datum();u.call(h,this.that,new ls(h,{sourceEvent:this.sourceEvent,target:v,type:h,transform:this.that.__zoom,dispatch:u}),S)}};function je(h,...S){if(!e.apply(this,arguments))return;var y=O(this,S).event(h),I=this.__zoom,E=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),A=Ie(h);if(y.wheel){if(y.mouse[0][0]!==A[0]||y.mouse[0][1]!==A[1])y.mouse[1]=I.invert(y.mouse[0]=A);clearTimeout(y.wheel)}else if(I.k===E)return;else y.mouse=[A,I.invert(A)],Ye(this),y.start();lt(h),y.wheel=setTimeout(C,m),y.zoom("mouse",r(L(P(I,E),y.mouse[0],y.mouse[1]),y.extent,s));function C(){y.wheel=null,y.end()}}function Qe(h,...S){if(d||!e.apply(this,arguments))return;var y=h.currentTarget,I=O(this,S,!0).event(h),E=Q(h.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",be,!0),A=Ie(h,y),{clientX:C,clientY:R}=h;cn(h.view),Pn(h),I.mouse=[A,this.__zoom.invert(A)],Ye(this),I.start();function q(Y){if(lt(Y),!I.moved){var fe=Y.clientX-C,Oe=Y.clientY-R;I.moved=fe*fe+Oe*Oe>x}I.event(Y).zoom("mouse",r(L(I.that.__zoom,I.mouse[0]=Ie(Y,y),I.mouse[1]),I.extent,s))}function be(Y){E.on("mousemove.zoom mouseup.zoom",null),Zi(Y.view,I.moved),lt(Y),I.event(Y).end()}}function Fe(h,...S){if(!e.apply(this,arguments))return;var y=this.__zoom,I=Ie(h.changedTouches?h.changedTouches[0]:h,this),E=y.invert(I),A=y.k*(h.shiftKey?0.5:2),C=r(L(P(y,A),I,E),t.apply(this,S),s);if(lt(h),a>0)Q(this).transition().duration(a).call(T,C,I,h);else Q(this).call(v.transform,C,I,h)}function _r(h,...S){if(!e.apply(this,arguments))return;var y=h.touches,I=y.length,E=O(this,S,h.changedTouches.length===I).event(h),A,C,R,q;Pn(h);for(C=0;C<I;++C)if(R=y[C],q=Ie(R,this),q=[q,this.__zoom.invert(q),R.identifier],!E.touch0)E.touch0=q,A=!0,E.taps=1+!!l;else if(!E.touch1&&E.touch0[2]!==q[2])E.touch1=q,E.taps=0;if(l)l=clearTimeout(l);if(A){if(E.taps<2)p=q[0],l=setTimeout(function(){l=null},f);Ye(this),E.start()}}function Tn(h,...S){if(!this.__zooming)return;var y=O(this,S).event(h),I=h.changedTouches,E=I.length,A,C,R,q;lt(h);for(A=0;A<E;++A)if(C=I[A],R=Ie(C,this),y.touch0&&y.touch0[2]===C.identifier)y.touch0[0]=R;else if(y.touch1&&y.touch1[2]===C.identifier)y.touch1[0]=R;if(C=y.that.__zoom,y.touch1){var be=y.touch0[0],Y=y.touch0[1],fe=y.touch1[0],Oe=y.touch1[1],me=(me=fe[0]-be[0])*me+(me=fe[1]-be[1])*me,Ae=(Ae=Oe[0]-Y[0])*Ae+(Ae=Oe[1]-Y[1])*Ae;C=P(C,Math.sqrt(me/Ae)),R=[(be[0]+fe[0])/2,(be[1]+fe[1])/2],q=[(Y[0]+Oe[0])/2,(Y[1]+Oe[1])/2]}else if(y.touch0)R=y.touch0[0],q=y.touch0[1];else return;y.zoom("touch",r(L(C,R,q),y.extent,s))}function Nn(h,...S){if(!this.__zooming)return;var y=O(this,S).event(h),I=h.changedTouches,E=I.length,A,C;if(Pn(h),d)clearTimeout(d);d=setTimeout(function(){d=null},f);for(A=0;A<E;++A)if(C=I[A],y.touch0&&y.touch0[2]===C.identifier)delete y.touch0;else if(y.touch1&&y.touch1[2]===C.identifier)delete y.touch1;if(y.touch1&&!y.touch0)y.touch0=y.touch1,delete y.touch1;if(y.touch0)y.touch0[1]=this.__zoom.invert(y.touch0[0]);else if(y.end(),y.taps===2){if(C=Ie(C,this),Math.hypot(p[0]-C[0],p[1]-C[1])<_){var R=Q(this).on("dblclick.zoom");if(R)R.apply(this,arguments)}}}return v.wheelDelta=function(h){return arguments.length?(n=typeof h==="function"?h:mr(+h),v):n},v.filter=function(h){return arguments.length?(e=typeof h==="function"?h:mr(!!h),v):e},v.touchable=function(h){return arguments.length?(o=typeof h==="function"?h:mr(!!h),v):o},v.extent=function(h){return arguments.length?(t=typeof h==="function"?h:mr([[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]]),v):t},v.scaleExtent=function(h){return arguments.length?(i[0]=+h[0],i[1]=+h[1],v):[i[0],i[1]]},v.translateExtent=function(h){return arguments.length?(s[0][0]=+h[0][0],s[1][0]=+h[1][0],s[0][1]=+h[0][1],s[1][1]=+h[1][1],v):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},v.constrain=function(h){return arguments.length?(r=h,v):r},v.duration=function(h){return arguments.length?(a=+h,v):a},v.interpolate=function(h){return arguments.length?(c=h,v):c},v.on=function(){var h=u.on.apply(u,arguments);return h===u?v:h},v.clickDistance=function(h){return arguments.length?(x=(h=+h)*h,v):Math.sqrt(x)},v.tapDistance=function(h){return arguments.length?(_=+h,v):_},v}function Kg(e){let t=e.map((r)=>w.view?.items.find((n)=>n.id===r)).filter((r)=>r!==void 0);return t.find(ie)??t[0]}function Yg(e){return`${$e(e)} ${e.description}`.toLowerCase().includes(w.search.toLowerCase())}function Gp(e){let t=Z("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=b({tag:"section",className:"skill-list-group"});o.append(b({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=Kg(i.itemIds);if(!s||!Yg(s))continue;let a=b({tag:"button",className:"skill-list-item",text:$e(s)});a.classList.toggle("equipped",ie(s)),a.addEventListener("click",()=>e.inspect(s.id)),o.append(a)}if(o.childElementCount>1)t.append(o)}}function Xg(e){var t=0,r=e.children,n=r&&r.length;if(!n)t=1;else while(--n>=0)t+=r[n].value;e.value=t}function ps(){return this.eachAfter(Xg)}function ds(e,t){let r=-1;for(let n of this)e.call(t,n,++r,this);return this}function fs(e,t){var r=this,n=[r],o,i,s=-1;while(r=n.pop())if(e.call(t,r,++s,this),o=r.children)for(i=o.length-1;i>=0;--i)n.push(o[i]);return this}function ms(e,t){var r=this,n=[r],o=[],i,s,a,c=-1;while(r=n.pop())if(o.push(r),i=r.children)for(s=0,a=i.length;s<a;++s)n.push(i[s]);while(r=o.pop())e.call(t,r,++c,this);return this}function hs(e,t){let r=-1;for(let n of this)if(e.call(t,n,++r,this))return n}function gs(e){return this.eachAfter(function(t){var r=+e(t.data)||0,n=t.children,o=n&&n.length;while(--o>=0)r+=n[o].value;t.value=r})}function xs(e){return this.eachBefore(function(t){if(t.children)t.children.sort(e)})}function ys(e){var t=this,r=Wg(t,e),n=[t];while(t!==r)t=t.parent,n.push(t);var o=n.length;while(e!==r)n.splice(o,0,e),e=e.parent;return n}function Wg(e,t){if(e===t)return e;var r=e.ancestors(),n=t.ancestors(),o=null;e=r.pop(),t=n.pop();while(e===t)o=e,e=r.pop(),t=n.pop();return o}function bs(){var e=this,t=[e];while(e=e.parent)t.push(e);return t}function vs(){return Array.from(this)}function _s(){var e=[];return this.eachBefore(function(t){if(!t.children)e.push(t)}),e}function ws(){var e=this,t=[];return e.each(function(r){if(r!==e)t.push({source:r.parent,target:r})}),t}function*ks(){var e=this,t,r=[e],n,o,i;do{t=r.reverse(),r=[];while(e=t.pop())if(yield e,n=e.children)for(o=0,i=n.length;o<i;++o)r.push(n[o])}while(r.length)}function St(e,t){if(e instanceof Map){if(e=[void 0,e],t===void 0)t=tx}else if(t===void 0)t=ex;var r=new pt(e),n,o=[r],i,s,a,c;while(n=o.pop())if((s=t(n.data))&&(c=(s=Array.from(s)).length)){n.children=s;for(a=c-1;a>=0;--a)o.push(i=s[a]=new pt(s[a])),i.parent=n,i.depth=n.depth+1}return r.eachBefore(nx)}function Qg(){return St(this).eachBefore(rx)}function ex(e){return e.children}function tx(e){return Array.isArray(e)?e[1]:null}function rx(e){if(e.data.value!==void 0)e.value=e.data.value;e.data=e.data.data}function nx(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function pt(e){this.data=e,this.depth=this.height=0,this.parent=null}pt.prototype=St.prototype={constructor:pt,count:ps,each:ds,eachAfter:ms,eachBefore:fs,find:hs,sum:gs,sort:xs,path:ys,ancestors:bs,descendants:vs,leaves:_s,links:ws,copy:Qg,[Symbol.iterator]:ks};function ox(e,t){return e.parent===t.parent?1:2}function zs(e){var t=e.children;return t?t[0]:e.t}function $s(e){var t=e.children;return t?t[t.length-1]:e.t}function ix(e,t,r){var n=r/(t.i-e.i);t.c-=n,t.s+=r,e.c+=n,t.z+=r,t.m+=r}function sx(e){var t=0,r=0,n=e.children,o=n.length,i;while(--o>=0)i=n[o],i.z+=t,i.m+=t,t+=i.s+(r+=i.c)}function ax(e,t,r){return e.a.parent===t.parent?e.a:r}function En(e,t){this._=e,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=t}En.prototype=Object.create(pt.prototype);function cx(e){var t=new En(e,0),r,n=[t],o,i,s,a;while(r=n.pop())if(i=r._.children){r.children=Array(a=i.length);for(s=a-1;s>=0;--s)n.push(o=r.children[s]=new En(i[s],s)),o.parent=r}return(t.parent=new En(null,0)).children=[t],t}function On(){var e=ox,t=1,r=1,n=null;function o(u){var l=cx(u);if(l.eachAfter(i),l.parent.m=-l.z,l.eachBefore(s),n)u.eachBefore(c);else{var p=u,d=u,f=u;u.eachBefore(function(P){if(P.x<p.x)p=P;if(P.x>d.x)d=P;if(P.depth>f.depth)f=P});var m=p===d?1:e(p,d)/2,x=m-p.x,_=t/(d.x+m+x),v=r/(f.depth||1);u.eachBefore(function(P){P.x=(P.x+x)*_,P.y=P.depth*v})}return u}function i(u){var l=u.children,p=u.parent.children,d=u.i?p[u.i-1]:null;if(l){sx(u);var f=(l[0].z+l[l.length-1].z)/2;if(d)u.z=d.z+e(u._,d._),u.m=u.z-f;else u.z=f}else if(d)u.z=d.z+e(u._,d._);u.parent.A=a(u,d,u.parent.A||p[0])}function s(u){u._.x=u.z+u.parent.m,u.m+=u.parent.m}function a(u,l,p){if(l){var d=u,f=u,m=l,x=d.parent.children[0],_=d.m,v=f.m,P=m.m,L=x.m,j;while(m=$s(m),d=zs(d),m&&d){if(x=zs(x),f=$s(f),f.a=u,j=m.z+P-d.z-_+e(m._,d._),j>0)ix(ax(m,u,p),u,j),_+=j,v+=j;P+=m.m,_+=d.m,L+=x.m,v+=f.m}if(m&&!$s(f))f.t=m,f.m+=P-v;if(d&&!zs(x))x.t=d,x.m+=_-L,p=u}return p}function c(u){u.x*=t,u.y=u.depth*r}return o.separation=function(u){return arguments.length?(e=u,o):e},o.size=function(u){return arguments.length?(n=!1,t=+u[0],r=+u[1],o):n?null:[t,r]},o.nodeSize=function(u){return arguments.length?(n=!0,t=+u[0],r=+u[1],o):n?[t,r]:null},o}function Ss(e){if(e===void 0)throw Error("Constellation layout is incomplete");return e}function ux(e){let t=new Map;for(let o of e.hubs)t.set(o.id,{id:o.id,title:o.title,itemIds:[],relatedHubIds:[],children:[],kind:"hub"});let r={id:"constellation-root",title:"Shadowclone",itemIds:[],relatedHubIds:[],children:[],kind:"root"};for(let o of e.hubs){let i=t.get(o.id),s=o.parentId?t.get(o.parentId):r;if(i&&s)s.children.push(i)}for(let o of e.leaves)t.get(o.parentId)?.children.push({id:o.id,title:"",itemIds:o.itemIds,relatedHubIds:o.relatedHubIds,children:[],kind:"skill"});let n=(o)=>{o.children.sort((i,s)=>i.id.localeCompare(s.id));for(let i of o.children)n(i)};return n(r),r}function Kp(e){let t=ux(e.constellation),r=St(t,(a)=>a.children.filter((c)=>c.kind!=="skill"));On().nodeSize([210,160])(r);let n=r.descendants().map((a)=>({id:a.data.id,title:a.data.title,itemIds:a.data.itemIds,relatedHubIds:a.data.relatedHubIds,kind:a.data.kind,parentId:a.parent?.data.id??null,x:Ss(a.x)+e.width/2,y:e.height-92-Ss(a.y)}));if(e.constellation.leaves.length===0&&r.height===1){let a=n.filter((p)=>p.kind==="hub"),c=Math.min(4,a.length),u=Math.ceil(a.length/c),l=new Map(a.map((p,d)=>[p.id,d]));n=n.map((p)=>{let d=l.get(p.id);return d===void 0?p:{...p,x:e.width/2+(d%c-(c-1)/2)*210,y:e.height-92-(u-Math.floor(d/c))*160}})}let o=[...n];for(let a of r.descendants()){let c=a.data.children.filter((u)=>u.kind==="skill");for(let[u,l]of c.entries())o.push({...l,parentId:a.data.id,x:Ss(a.x)+e.width/2,y:e.height-92-r.height*160-88*(u+1)})}let i=new Map(o.map((a)=>[a.id,a])),s=o.flatMap((a)=>{let c=a.parentId?i.get(a.parentId):void 0;return c?[{id:`${c.id}:${a.id}`,sourceX:c.x,sourceY:c.y,targetX:a.x,targetY:a.y,related:!1}]:[]});for(let a of o.filter((c)=>c.kind==="skill"))for(let c of a.relatedHubIds){let u=i.get(c);if(u)s.push({id:`${a.id}:${u.id}:related`,sourceX:a.x,sourceY:a.y,targetX:u.x,targetY:u.y,related:!0})}return{nodes:o,links:s}}var lx={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"},px={"design-deep-modules":"modules","typescript-type-safety":"code","scope-confirmed-changes":"focus","refactor-boundaries":"layers","refactor-preserve":"shield","dependencies-existing":"link","dependencies-mature":"layers","diagnose-before-editing":"bug","prove-regression-tests":"flask","testing-first":"flask","testing-risk-based":"shield","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 Yp(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",lx[e]),t.append(r),t}function Xp(e){return Yp(px[e.id]??"spark")}function Wp(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 Yp(n)}function Qp(e){let t=new Map(e.constellation.hubs.map((r)=>[r.id,r.parentId]));for(let r of e.constellation.leaves){if(!r.itemIds.some((o)=>e.matchingItemIds.has(o)))continue;let n=r.parentId;while(n)e.expandedHubIds.add(n),n=t.get(n)??null}}function ed(e){let t=new Set,r=new Map(e.constellation.hubs.map((o)=>[o.id,o.parentId]));return{hubs:e.constellation.hubs.filter((o)=>{let i=o.parentId;while(i){if(!e.expandedHubIds.has(i))return!1;i=r.get(i)??null}return t.add(o.id),!0}),leaves:e.constellation.leaves.filter((o)=>t.has(o.parentId)&&e.expandedHubIds.has(o.parentId))}}function td(e){let t=new Map,r=new Map(e.hubs.map((n)=>[n.id,n.parentId]));for(let n of e.leaves){let o=n.parentId;while(o)t.set(o,(t.get(o)??0)+1),o=r.get(o)??null}return t}function Is(e){let t=Math.min(...e.nodes.map((s)=>s.x))-100,r=Math.max(...e.nodes.map((s)=>s.x))+100,n=Math.min(...e.nodes.map((s)=>s.y))-56,o=Math.max(...e.nodes.map((s)=>s.y))+76,i=Math.min(1,(e.width-40)/(r-t),(e.height-80)/(o-n));return{scale:i,x:e.width/2-i*(t+r)/2,y:e.height/2-i*(n+o)/2}}var dx="http://www.w3.org/2000/svg",It=()=>{return},Xe="",gr=null,Be=new Set,rd="",nd=new Map,Ps=null,od=new Map;function Ee(e){return document.createElementNS(dx,e)}function Zs(e){let t=e.itemIds.map((r)=>od.get(r)).filter((r)=>r!==void 0);return t.find(ie)??t[0]}function An(e){let t=Zs(e);return t?$e(t):e.title}function id(e){if(!w.search)return!0;let t=Zs(e);return`${An(e)} ${t?.description??""}`.toLowerCase().includes(w.search.toLowerCase())}function fx(e){let t=[""];for(let r of e.split(/\s+/)){let n=t.at(-1)??"";if(n&&n.length+r.length>22)t.push(r);else t[t.length-1]=`${n} ${r}`.trim()}return t.slice(0,2).map((r,n)=>`${r.slice(0,24)}${n===1&&t.length>2||r.length>24?"…":""}`)}function mx(e){let{group:t,node:r}=e,n=Zs(r),o=Ee("g"),i=Ee(r.kind==="root"?"circle":"rect"),s=Ee("text"),a=n?ie(n):!1;if(o.setAttribute("class",`map-node map-node-${r.kind}`),o.setAttribute("transform",`translate(${r.x} ${r.y})`),o.classList.toggle("equipped",a),o.classList.toggle("search-miss",!id(r)),o.classList.toggle("focused",r.id===Xe),o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`${An(r)}${a?", equipped":""}`),r.kind==="root")i.setAttribute("r","26");else{let l=r.kind==="hub"?32:24;i.setAttribute("x",String(-l/2)),i.setAttribute("y",String(-l/2)),i.setAttribute("width",String(l)),i.setAttribute("height",String(l)),i.setAttribute("rx","6"),i.setAttribute("transform","rotate(45)")}s.setAttribute("text-anchor","middle");for(let[l,p]of fx(An(r)).entries()){let d=Ee("tspan");d.setAttribute("x","0"),d.setAttribute("y",String((r.kind==="root"?44:38)+l*14)),d.textContent=p,s.append(d)}let c=Ee("title");if(c.textContent=An(r),o.append(c),o.append(i,s),r.kind==="root"){let l=document.querySelector(".brand-mark");if(l instanceof HTMLImageElement){let p=Ee("image");p.setAttribute("href",l.src);for(let[d,f]of Object.entries({x:"-16",y:"-16",width:"32",height:"32"}))p.setAttribute(d,f);o.append(p)}}else{let l=Ee("foreignObject"),p=b({tag:"span",className:"map-node-icon"});l.setAttribute("x","-9"),l.setAttribute("y","-9"),l.setAttribute("width","18"),l.setAttribute("height","18"),p.append(n?Xp(n):Wp(r.title)),l.append(p),o.append(l)}if(r.kind==="hub"){o.setAttribute("aria-expanded",String(Be.has(r.id)));let l=Ee("text");l.setAttribute("class","map-node-count"),l.setAttribute("text-anchor","middle"),l.setAttribute("y","70");let p=nd.get(r.id)??0;l.textContent=`${Be.has(r.id)?"−":"+"} ${p} ${p===1?"skill":"skills"}`,o.append(l)}let u=()=>{if(n)It(n.id);else if(r.kind==="hub"){if(Be.has(r.id))Be.delete(r.id);else Be.add(r.id);Xe=r.id}xr({inspect:It})};o.addEventListener("click",u),o.addEventListener("keydown",(l)=>{if(l.key==="Enter"||l.key===" ")l.preventDefault(),u()}),t.append(o)}function xr(e){It=e.inspect;let t=Bo("constellation-map"),r=w.view;if(!r)return;Gp({constellation:r.constellation,inspect:It});let n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return;od=new Map(r.items.map((l)=>[l.id,l]));let o=[...r.constellation.hubs.map((l)=>`${l.id}:${l.parentId}`),...r.constellation.leaves.map((l)=>l.id)].join(`
|
|
67
|
+
`),i=o!==rd;if(i){if(Be.clear(),r.constellation.leaves.length<=40)for(let l of r.constellation.hubs)Be.add(l.id);rd=o,Xe=""}if(w.search)Qp({constellation:r.constellation,expandedHubIds:Be,matchingItemIds:new Set(r.items.filter((l)=>`${$e(l)} ${l.description}`.toLowerCase().includes(w.search.toLowerCase())).map((l)=>l.id))});nd=td(r.constellation);let s=Kp({constellation:ed({constellation:r.constellation,expandedHubIds:Be}),width:n.width,height:n.height});Ps=s,t.setAttribute("viewBox",`0 0 ${n.width} ${n.height}`),t.replaceChildren();let a=Ee("g");a.setAttribute("class","constellation-viewport"),t.append(a);for(let l of s.links){let p=Ee("path");p.setAttribute("class",l.related?"map-link related":"map-link"),p.setAttribute("d",`M${l.sourceX} ${l.sourceY}L${l.targetX} ${l.targetY}`),a.append(p)}for(let l of s.nodes)mx({group:a,node:l});let c=Zn().scaleExtent([0.1,2.5]).on("zoom",(l)=>{a.setAttribute("transform",l.transform.toString())});if(Q(t).call(c),a.setAttribute("transform",hr(t).toString()),gr=c,i){let l=Is({nodes:s.nodes,width:n.width,height:n.height});Q(t).call(c.transform,Ze.translate(l.x,l.y).scale(Math.max(0.65,l.scale)))}let u=w.search?s.nodes.find((l)=>l.kind==="skill"&&id(l)):Xe?s.nodes.find((l)=>l.id===Xe):void 0;if(u&&(Xe||w.search)){let l=Ze.translate(n.width/2,n.height/2).scale(1.25).translate(-u.x,-u.y);Q(t).call(c.transform,l)}}function sd(){let e=Bo("constellation-map");new ResizeObserver(()=>xr({inspect:It})).observe(e);let r=()=>{if(Xe="",gr)Q(e).call(gr.transform,Ze)};Z("fit-constellation").addEventListener("click",()=>{if(!gr||!Ps)return;Xe="";let o=e.getBoundingClientRect(),i=Is({nodes:Ps.nodes,width:o.width,height:o.height});Q(e).call(gr.transform,Ze.translate(i.x,i.y).scale(i.scale))}),Z("reset-constellation").addEventListener("click",r);let n=Z("toggle-constellation-view");n.addEventListener("click",()=>{let o=Z("constellation").classList.toggle("list-view");n.setAttribute("aria-pressed",String(o))})}function ad(){xr({inspect:It})}var cd=null,Pt=null;function Es(){let e=Z("model-description");if(e.replaceChildren(),!Pt||cd!==JSON.stringify(w.input))return;e.append(b({tag:"h3",text:Pt.title}),b({tag:"p",text:Pt.summary}));for(let t of Pt.strengths)e.append(b({tag:"p",text:`Strength: ${t}`}));for(let t of Pt.tradeoffs)e.append(b({tag:"p",text:`Tradeoff: ${t}`}))}async function ud(){let e=JSON.stringify(w.input),t=await H({path:"/api/description/preview",schema:pp,body:w.input});rn({review:t,title:"Describe your agent.",explanation:"An interpretation of your selected guidance. It does not change your skills or add personality instructions.",confirm:"Send and describe",path:"/api/description/generate",schema:dp,accept:(r)=>{Pt=r.description,cd=e;for(let n of r.description.hubLabels){let o=w.view?.constellation.hubs.find((i)=>i.id===n.id);if(o)o.title=n.title}ad(),Es()}})}function ld(e){let t=new Map(e.constellation.hubs.map((i)=>[i.id,i])),r=new Map;for(let i of e.constellation.leaves){if(!i.itemIds.some((a)=>e.selectedItemIds.has(a)))continue;let s=t.get(i.parentId);while(s?.parentId)s=t.get(s.parentId);if(s)r.set(s.id,(r.get(s.id)??0)+1)}let n=[...r].map(([i,s])=>({title:t.get(i)?.title??"Guidance",count:s})).sort((i,s)=>s.count-i.count||i.title.localeCompare(s.title)),o=n[0];return o?{title:`The ${o.title} Pathfinder`,traits:n.slice(0,4)}:null}function pd(){let e=w.view?.items.filter((o)=>o.owner!=="provider"&&ie(o))??[],t=w.view?ld({constellation:w.view.constellation,selectedItemIds:new Set(e.map((o)=>o.id))}):null;Z("equipped-count").textContent=`${e.length} ${e.length===1?"skill":"skills"} equipped${w.dirty?" · unsaved changes":""}`,Z("identity-title").textContent=t?.title??"An open canvas",Z("identity-description").textContent=t?`Your working style is shaped by ${e.slice(0,3).map((o)=>$e(o).toLowerCase()).join(", ")}${e.length>3?`, and ${e.length-3} more equipped skills`:""}.`:"Choose the instincts you want your agent to bring to work.";let r=Z("traits");r.replaceChildren();for(let o of t?.traits??[])r.append(b({tag:"span",className:"trait",text:`${o.title} · ${o.count}`}));let n=Z("requirements");if(n.replaceChildren(),n.hidden=!w.view?.requirements.length,w.view?.requirements.length){n.append(b({tag:"h3",text:"◇ Repository requirements"}));for(let o of w.view.requirements)n.append(b({tag:"p",text:o}))}}var Cn=null;async function dd(){if(w.view===null)throw Error("Wait for your skills to load before reviewing the build.");let e=await H({path:"/api/preview",schema:np,body:w.input});Cn=e;let t=Z("review-content");t.replaceChildren(),t.append(b({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(b({tag:"p",className:"review-warning",text:r}));for(let r of e.changes){let n=b({tag:"details",className:"file-change"});if(n.append(b({tag:"summary",text:r.path})),r.internal)n.append(b({tag:"p",text:"Local configuration or supporting resource. Its previous version is retained for undo."}));else n.append(b({tag:"h4",text:"Before"}),b({tag:"pre",text:r.before??"New file"}),b({tag:"h4",text:"After"}),b({tag:"pre",text:r.after??"Remove managed file"}));t.append(n)}bt("review-dialog").showModal()}async function fd(){if(Cn===null)throw Error("Review your build before applying it.");await H({path:"/api/apply",schema:Ro,body:{previewId:Cn.id}}),Cn=null,bt("review-dialog").close(),de({message:"Build equipped. Start a fresh agent session to use your updated skills.",success:!0})}async function md(){let e=w.view?.revisionId;if(!e||!window.confirm("Restore the files from before the last apply? Later edits will be preserved if they conflict."))return;await H({path:"/api/undo",schema:Ro,body:{revisionId:e}}),de({message:"Restored the previous build.",success:!0})}function hd(){let e=Z("starfield"),t=()=>{let n=e.getBoundingClientRect(),o=Math.max(1,Math.round(n.width)),i=Math.max(1,Math.round(n.height));e.setAttribute("viewBox",`0 0 ${o} ${i}`),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.replaceChildren();for(let s=0;s<54;s+=1){let a=document.createElementNS("http://www.w3.org/2000/svg","g"),c=document.createElementNS("http://www.w3.org/2000/svg","circle"),u=12+(s*137+29)%Math.max(24,o-24),l=8+(s*173+61)%Math.max(16,i-16);if(a.setAttribute("class",`star star-phase-${s%7}`),c.setAttribute("cx",String(u)),c.setAttribute("cy",String(l)),c.setAttribute("r",s%9===0?"1.7":"1"),a.append(c),s%9===0){let p=document.createElementNS("http://www.w3.org/2000/svg","path");p.setAttribute("d",`M${u-4} ${l}h8M${u} ${l-4}v8`),p.setAttribute("class","star-rays"),a.append(p)}e.append(a)}},r=()=>{e.classList.toggle("paused",document.hidden)};document.addEventListener("visibilitychange",r),new ResizeObserver(t).observe(e),t(),r()}var YI=J({name:k().trim().max(48),description:k().trim().max(300),body:k().trim().min(1).max(24000)}),gd=J({id:Jt(),destination:k(),payload:k(),limits:k(),cached:yt.nullable()}),xd=J({skill:yt});function dt(e){Z("custom-status").textContent=e}async function hx(){let e=Re("custom-body").value;if(!e.trim()){dt("Describe what your agent should do, then use AI to shape it into a skill."),Re("custom-body").focus();return}let t=await H({path:"/api/skill/preview",schema:gd,body:{name:oe("custom-name").value,description:oe("custom-description").value,body:e}});rn({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:xd,accept:({skill:r})=>{oe("custom-name").value=r.name,oe("custom-description").value=r.description,Re("custom-body").value=r.body,dt("AI draft ready. Edit the instructions before adding the skill to your build."),Re("custom-body").focus()}})}function yd(){let e=Z("custom-ai");if(!(e instanceof HTMLButtonElement))return;e.addEventListener("click",()=>{if(e.disabled)return;e.disabled=!0,dt("Preparing your model request…"),hx().catch((t)=>{dt(t instanceof Error?t.message:"Could not prepare an AI draft. Your text is unchanged.")}).finally(()=>{if(e.disabled=!1,Z("custom-status").textContent==="Preparing your model request…")dt("")})})}var Os=!1;async function Zt(e){if(Os)return;Os=!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;Os=!1}}function We(e){Z(e.id).addEventListener("click",()=>Zt(e.action).catch(st))}function bd(){let e=document.createElement("template");e.innerHTML=`
|
|
68
|
+
<dialog id="review-dialog" aria-labelledby="review-title">
|
|
69
|
+
<div class="dialog-heading">
|
|
70
|
+
<div>
|
|
71
|
+
<p class="eyebrow">READY TO EQUIP</p>
|
|
72
|
+
<h2 id="review-title">Review your changes.</h2>
|
|
73
|
+
</div>
|
|
74
|
+
<button class="close-dialog quiet-button" aria-label="Close review">
|
|
75
|
+
✕
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
<div id="review-content"></div>
|
|
79
|
+
<div class="dialog-actions">
|
|
80
|
+
<button class="close-dialog quiet-button">Keep editing</button>
|
|
81
|
+
<button id="apply" class="primary-button">Apply build</button>
|
|
82
|
+
</div>
|
|
83
|
+
</dialog>
|
|
84
|
+
|
|
85
|
+
<dialog id="custom-dialog" aria-labelledby="custom-title">
|
|
86
|
+
<div class="dialog-heading">
|
|
87
|
+
<h2 id="custom-title">Create a skill.</h2>
|
|
88
|
+
<button
|
|
89
|
+
class="close-dialog quiet-button"
|
|
90
|
+
aria-label="Close skill editor"
|
|
91
|
+
>
|
|
92
|
+
✕
|
|
93
|
+
</button>
|
|
94
|
+
</div>
|
|
95
|
+
<form id="custom-form">
|
|
96
|
+
<label>
|
|
97
|
+
Skill name
|
|
98
|
+
<input
|
|
99
|
+
id="custom-name"
|
|
100
|
+
pattern="[a-z0-9]+(-[a-z0-9]+)*"
|
|
101
|
+
maxlength="48"
|
|
102
|
+
placeholder="review-with-evidence"
|
|
103
|
+
required
|
|
104
|
+
>
|
|
105
|
+
</label>
|
|
106
|
+
<label>
|
|
107
|
+
When should your agent use it?
|
|
108
|
+
<input
|
|
109
|
+
id="custom-description"
|
|
110
|
+
maxlength="300"
|
|
111
|
+
placeholder="Use when reviewing an implementation."
|
|
112
|
+
required
|
|
113
|
+
>
|
|
114
|
+
</label>
|
|
115
|
+
<label>
|
|
116
|
+
What should your agent do?
|
|
117
|
+
<textarea
|
|
118
|
+
id="custom-body"
|
|
119
|
+
rows="9"
|
|
120
|
+
maxlength="24000"
|
|
121
|
+
placeholder="Describe the decisions, steps, and evidence you expect."
|
|
122
|
+
required
|
|
123
|
+
></textarea>
|
|
124
|
+
</label>
|
|
125
|
+
<p id="custom-status" class="review-message" role="status"></p>
|
|
126
|
+
<div class="dialog-actions">
|
|
127
|
+
<button id="custom-ai" type="button" class="quiet-button">✦ Use AI</button>
|
|
128
|
+
<button type="submit" class="primary-button">
|
|
129
|
+
Add to your build
|
|
130
|
+
</button>
|
|
131
|
+
</div>
|
|
132
|
+
</form>
|
|
133
|
+
</dialog>
|
|
134
|
+
`,document.body.append(e.content);for(let t of document.querySelectorAll("dialog"))tn(t)}var gx=J({engine:Ht(["claude-code","codex","cursor-agent","pi"]),model:k().min(1).optional(),name:k()}),vd=J({choices:W(gx),selected:Je({engine:k().optional(),model:k().optional()})});function _d(){let e=null;We({id:"load-models",action:async()=>{e=await H({path:"/api/learning-models",schema:vd});let t=ze("learning-model"),r=b({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=b({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)de({message:"Configure a model in your coding harness, then refresh models."})}}),ze("learning-model").addEventListener("change",()=>{let t=ze("learning-model").value;if(t==="")return;let r=e?.choices[Number(t)];if(!r)return;Zt(async()=>{await H({path:"/api/learning-model",schema:Je({saved:it()}),body:{engine:r.engine,model:r.model}}),de({message:"Saved your learning model. Session learning follows the session model unless overridden.",success:!0})}).catch(st)})}var gP=J({repository:k().regex(/^[\w.-]+\/[\w.-]+$/),name:k().trim().min(1).max(100),skills:W(k().regex(/^[a-z0-9-]+$/)).min(1).max(40)}),wd=Je({id:Jt(),repository:k(),repositoryId:Yl(),owner:k(),appOwner:k(),fingerprint:k(),bytes:Yl(),files:W(Je({path:k(),content:k()}))}),As=Je({repository:k().nullable(),skills:W(k()).default([]),app:Je({name:k(),installUrl:To()}).nullable(),pullUrl:To().nullable()}),kd=Je({action:To(),manifest:k()}),xx=J({previewId:Jt()}),xP=xx.extend({token:k().trim().regex(/^sk-ant-oat01-[A-Za-z0-9_-]{20,500}$/)});function yr(e){let t=b({tag:"label",className:"field"}),r=b({tag:"input"});return r.value=e.value??"",r.type=e.type??"text",r.required=!0,t.append(b({tag:"span",text:e.label}),r),{label:t,input:r}}function Et(e){let t=b({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 zd(e){let{container:t,status:r,preview:n}=e;t.replaceChildren(),t.append(b({tag:"p",text:`Repository: ${n.repository} (ID ${n.repositoryId}). App owner: ${n.appOwner}. Requester: ${n.owner}. Guidance: ${n.bytes} encoded bytes.`})),t.append(b({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=b({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:
|
|
135
|
+
${s.content}`}a.append(b({tag:"summary",text:s.path}),b({tag:"pre",text:u})),t.append(a)}let o=b({tag:"input"}),i=b({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(Et({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 H({path:"/api/bot/manifest",body:{previewId:n.id},schema:kd}),a=b({tag:"form"}),c=b({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 $d(){let e=b({tag:"dialog"});e.className="bot-dialog";let t=b({tag:"h2",text:"Your personal GitHub clone"}),r=b({tag:"div"}),n=b({tag:"p"}),o=b({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 H({path:"/api/bot/state",schema:As});if(r.replaceChildren(),a.pullUrl){let p=b({tag:"a",text:"Review the setup PR"});p.href=a.pullUrl,p.target="_blank",p.rel="noreferrer",r.append(p),n.textContent="The clone starts after you merge its setup PR. Create one small issue to verify the installation.";return}if(a.app){let p=b({tag:"a",text:`Install ${a.app.name} on GitHub`}),d=yr({label:"Claude subscription token",type:"password"}),f=b({tag:"input"}),m=b({tag:"label",className:"bot-consent"});p.href=a.app.installUrl,p.target="_blank",p.rel="noreferrer",d.input.autocomplete="off",f.type="checkbox",m.append(f,document.createTextNode("I authorize this repository to use my Claude subscription and the reviewed guidance.")),r.append(p,b({tag:"p",text:`Choose Only select repositories. Include ${a.repository}. Return to this tab after installation. All repositories is rejected.`}),b({tag:"p",text:"Run claude setup-token in your terminal. Use Safari for your personal Claude sign-in. Paste the resulting token below."}),d.label,m,Et({text:"Verify installation and create the setup PR",status:n,action:async()=>{let x=sessionStorage.getItem("shadowclone-bot-preview");if(!x||!f.checked)throw Error("Approve subscription use after reviewing the guidance.");let _=d.input.value.trim();d.input.value="",await H({path:"/api/bot/activate",body:{previewId:x,token:_},schema:As}),await i()}})),n.textContent="GitHub controls account and organization installation approval.";return}let c=yr({label:"Repository (owner/repository)",value:new URLSearchParams(location.search).get("repository")??a.repository??""}),u=yr({label:"Clone name",value:"my-shadowclone"}),l=yr({label:"Selected skill names, separated by commas",value:a.skills.length?a.skills.join(", "):"shadowclone-work"});r.append(b({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,Et({text:"Preview the exact guidance",status:n,action:async()=>{let p=await H({path:"/api/bot/preview",schema:wd,body:{repository:c.input.value.trim(),name:u.input.value.trim(),skills:l.input.value.split(",").map((d)=>d.trim()).filter(Boolean)}});zd({container:r,status:n,preview:p})}})),n.textContent="Start in this repository checkout with gh auth login and an active Shadowclone skills environment."}let s=Et({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()}bd();_d();$d();function br(){xr({inspect:(e)=>{w.activeId=e,br()}}),up({rerender:br,companion:Fo}),pd(),Es(),Z("undo").hidden=w.view?.revisionId===null}async function yx(e){let t=await H({path:`/api/build?scope=${e}`,schema:rp});if(w.view=t,w.input=structuredClone(t.input),w.dirty=!1,!t.items.some((n)=>n.id===w.activeId))w.activeId=t.items.find(ie)?.id??t.items[0]?.id??"";ze("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(Z("scope-note").textContent=r[e],Z("library-note").hidden=t.libraryEnabled,t.migrationRequired)de({message:"Your existing profile needs its reviewed skills migration before this build can be applied. You can explore the editor now."});br()}async function vr(e){let t=Z("constellation-status"),r=Z("retry-build");if(!r.hidden)de({message:""});t.hidden=!1,r.hidden=!0,Z("constellation-status-text").textContent="Loading your skills…",Z("constellation").setAttribute("aria-busy","true");try{await yx(e),t.hidden=!0}catch(n){throw Z("constellation-status-text").textContent="Your skills couldn't be loaded. Retry to reconnect to the local editor.",r.hidden=!1,ze("scope").value=w.input.scope,n}finally{Z("constellation").setAttribute("aria-busy","false")}}We({id:"retry-build",action:()=>vr(w.input.scope)});We({id:"review",action:dd});We({id:"describe",action:ud});We({id:"apply",action:async()=>{await fd(),await vr(w.input.scope)}});We({id:"undo",action:async()=>{await md(),await vr(w.input.scope)}});Z("new-skill").addEventListener("click",()=>Fo());Z("custom-form").addEventListener("submit",(e)=>{e.preventDefault();try{sp(),br()}catch(t){dt(t instanceof Error?t.message:"The skill could not be added.")}});oe("search").addEventListener("input",()=>{w.search=oe("search").value,br()});ze("scope").addEventListener("change",()=>{if(w.dirty&&!window.confirm("Discard the draft and switch build scope?")){ze("scope").value=w.input.scope;return}let e=xt.parse(ze("scope").value);Zt(()=>vr(e)).catch(st)});for(let e of document.querySelectorAll(".close-dialog"))e.addEventListener("click",()=>e.closest("dialog")?.close());window.addEventListener("beforeunload",(e)=>{if(w.dirty)e.preventDefault()});var Sd=xt.safeParse(new URLSearchParams(location.search).get("scope")??"global");hd();sd();yd();Zt(()=>vr(Sd.success?Sd.data:"global")).catch(st);
|