@shadowclone/cli 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/_.._/web/client/index.html +7 -1
- package/dist/shadowclone.js +624 -612
- package/dist/web/index-p75d8wn2.js +134 -0
- package/package.json +1 -1
- 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/shadowclone-work/SKILL.md +38 -0
- package/dist/web/index-pty3xg03.js +0 -134
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
function Zt(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 In(e,t="|"){return e.map((r)=>En(r)).join(t)}function Et(e,t){if(typeof t==="bigint")return t.toString();return t}class ys{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 dr(e){return new ys(e)}function bs(e){return e===null||e===void 0}function mr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function de(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function hr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Ee(e){return hr(e._zod.def)??e._zod.def.shape}function vs(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return de(this,t,n),n},enumerable:!0,configurable:!0})}function _s(e,t,r){if(t in e)de(e,t,r);else e[t]=r}function Ge(e,t,r,n){let o=Ee(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)vs(e,i,()=>{let a=t._zod.def.shape[i];return n?n(a,i):a});else _s(e,i,n?n(s.value,i):s.value)}}function Kp(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)vs(e,r,()=>t[r]);else _s(e,r,n.value)}}function oe(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ws(e){return JSON.stringify(e)}function ks(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Pn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Pt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var zs=dr(()=>{if(ee.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Xe(e){if(Pt(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Pt(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Zn(e){if(Xe(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 $s=new Set(["string","number","symbol"]);function st(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ye(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function S(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 En(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Ss(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var On=(()=>({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]}))(),An={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Gp(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 Ge(i,e,gr(e,t)),ye(e,oe(r,{shape:i,checks:[]}))}function gr(e,t){let r=Ee(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 Xp(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(gr(e,t)),s={};return Ge(s,e,Reflect.ownKeys(Ee(e)).filter((a)=>!i.has(a))),ye(e,oe(r,{shape:s,checks:[]}))}function Yp(e,t){if(!Xe(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Ee(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 ye(e,oe(e._zod.def,{shape:Is(e,t)}))}function Is(e,t){let r={};return Ge(r,e,Reflect.ownKeys(Ee(e))),Kp(r,t),r}function Wp(e,t){if(!Xe(t))throw Error("Invalid input to safeExtend: expected a plain object");return ye(e,oe(e._zod.def,{shape:Is(e,t)}))}function Qp(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={};Ge(r,e,Reflect.ownKeys(Ee(e))),Ge(r,t,Reflect.ownKeys(Ee(t)));let n=oe(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ye(e,n)}function Ps(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(gr(t,r)):void 0,u={};return Ge(u,t,Reflect.ownKeys(Ee(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),ye(t,oe(t._zod.def,{shape:u,checks:[]}))}function ef(e,t,r){let n=r?new Set(gr(t,r)):void 0,o={};return Ge(o,t,Reflect.ownKeys(Ee(t)),(i,s)=>n&&!n.has(s)?i:new e({type:"nonoptional",innerType:i})),ye(t,oe(t._zod.def,{shape:o}))}function be(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 Zs(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 je(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function It(e){return typeof e==="string"?e:e?.message}function Cn(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ve(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:It(e.inst?._zod.def?.error?.(e))??It(i?.(e))??It(t?.error?.(e))??It(r.customError?.(e))??It(r.localeError?.(e))??"Invalid input",a={};for(let u of Object.keys(e)){if(u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__")continue;a[u]=e[u]}if(a.path??(a.path=[]),a.message=s,t?.reportInput)a.input=e.input;return a}var tf=/[\uD800-\uDBFF]/;function xr(e){let t=e.length;if(!tf.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 yr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Es(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 Ye(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function Os(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else nf(e,r,n.value)}}function Oe(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function br(e,t,r){return Oe(e,t,r,!1)}function rf(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Oe(this,r,n(this))},set(o){Oe(this,r,o)}})}return t}function nf(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Oe(this,t,r.bind(this))},set(n){Oe(this,t,n)}})}function of(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Sn,Be=!1,sf={configurable:!0,get(){Be=!0;return}};function N(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&Sn!==e._zod){Sn=void 0;return}Sn=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,sf);let o=Be;Be=!1;try{let i=r(this);if(Be)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return Be=Be||o,i}catch(i){throw delete this[t],Be=Be||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function af(e,t,r,n){let o=of(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 cf="~constantCatch";function As(e){let t=()=>e;return t[cf]=!0,t}var Cs;var Tn={value:void 0,enumerable:!1},Ts="captureStackTrace"in Error?Error:null;function uf(e){let t=Ts;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return Ts=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function g(e,t,r,n){let o={};function i(f){this.def=f,this.constr=p,this.traits=new Set}i.prototype=o;let s=r,a=s&&new WeakSet;function u(f,d){if(!f._zod){Tn.value=new i(d);try{Object.defineProperty(f,"_zod",Tn)}finally{Tn.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,d),a){let x=Object.getPrototypeOf(f),_=f._zod.constr.prototype,b=x;while(b&&b!==_)b=Object.getPrototypeOf(b);let P=b??x;if(!a.has(P))a.add(P),Os(P,s)}let m=p.prototype;for(let x in m){if(!Object.prototype.hasOwnProperty.call(m,x))continue;if(!(x in f))f[x]=m[x].bind(f)}}let c=n?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:e});function p(f){let d=n?.Parent?uf(l):this;u(d,f);let m=d._zod.deferred;if(m){for(let _ of m)_();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(p,"init",{value:u}),Object.defineProperty(p,Symbol.hasInstance,{value:(f)=>{if(n?.Parent&&f instanceof n.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class _e extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ot extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Cs=globalThis).__zod_globalConfig??(Cs.__zod_globalConfig={});var ee=globalThis.__zod_globalConfig;function ie(e){if(e)Object.assign(ee,e);return ee}function lf(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Et,2)),e.message}function pf(e){this._zod.message=e}var ff={get:lf,set:pf,enumerable:!0,configurable:!0},Rn={value:void 0,enumerable:!1},Ns=new WeakSet([Object.prototype,Error.prototype]),Rs=(e,t)=>{e.name="$ZodError",Rn.value=t,Object.defineProperty(e,"issues",Rn),Rn.value=void 0,Object.defineProperty(e,"message",ff);let r=Object.getPrototypeOf(e);if(!Ns.has(r))Ns.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})}})},Ms=g("$ZodError",Rs),bx=g("$ZodError",Rs,void 0,{Parent:Error});function df(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 Ds(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)df(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ls(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 u=r,c=0;while(c<a.length){let l=a[c],p=c===a.length-1;if(l==="_errors"){if(p)u._errors.push(t(s));c++;continue}if(!Object.prototype.hasOwnProperty.call(u,l))Object.defineProperty(u,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=u[l];if(p)f._errors.push(t(s));u=f,c++}}}};return n(e),r}function vr(e,t){return{callee:t?.callee??e,Err:t?.Err}}var _r=(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 _e;if(a.issues.length){let u=new(i?.Err??e)(a.issues.map((c)=>ve(c,s,ie())));throw Pn(u,i?.callee??t),u}return a.value};return t};var wr=(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 u=new(i?.Err??e)(a.issues.map((c)=>ve(c,s,ie())));throw Pn(u,i?.callee??t),u}return a.value};return t};var kr=(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 _e;return i.issues.length?Bs(e,i.issues,o):{success:!0,data:i.value}};function Bs(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>ve(o,r,ie()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var zr=(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?Bs(e,i.issues,o):{success:!0,data:i.value}};var mf=Symbol.for("zod.compile.invalid"),hf=Symbol.for("zod.compile.fallback"),Mn=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==mf)return!0;if(n.definite===!0&&r===void 0)return!1}return gf(e,t,r)};function gf(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)n[hf]=!0,i=o({value:t,issues:[]},n);else i=e._zod.run({value:t,issues:[]},n);if(i instanceof Promise)throw new _e;return i.issues.length===0}var Dn=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},js=(e)=>{let t=_r(e),r=(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(n,o,a,vr(r,s))};return r};var Fs=(e)=>{let t=_r(e),r=(n,o,i,s)=>t(n,o,i,vr(r,s));return r};var Us=(e)=>{let t=wr(e),r=async(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(n,o,a,vr(r,s))};return r};var qs=(e)=>{let t=wr(e),r=async(n,o,i,s)=>await t(n,o,i,vr(r,s));return r};var Vs=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return kr(e)(t,r,o)};var Js=(e)=>(t,r,n)=>kr(e)(t,r,n);var Hs=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return zr(e)(t,r,o)};var Ks=(e)=>async(t,r,n)=>zr(e)(t,r,n);var Gs=/^[cC][0-9a-z]{6,}$/,Xs=/^[0-9a-z]+$/,Ys=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ws=/^[0-9a-vA-V]{20}$/,Qs=/^[A-Za-z0-9]{27}$/,ea=/^[a-zA-Z0-9_-]{21}$/;function ta(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ra=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var na=/^([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})$/,Bn=(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 oa=/^(?:[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 xf="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function ia(){return new RegExp(xf,"u")}var sa=/^(?:(?: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])$/,aa=/^(([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 ca=/^((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])$/,ua=/^(([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])$/,la=/^$|^(?:[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 fa=/^https?$/,da=/^\+[1-9]\d{6,14}$/;var ma="(?:(?:\\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 yf(e){return new RegExp(`^${e}$`)}var ha=yf(ma);function Ln(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 ga(e){return new RegExp(`^${Ln(e)}$`)}function xa(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Ln({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Ln({precision:e.precision})}`:r;return new RegExp(`^${ma}T(?:${n})$`)}var ya=/^[\s\S]{0,}$/;var jn=/^-?\d+$/,$r=/^-?\d+(?:\.\d+)?$/,ba=/^(?:true|false)$/i;var va=/^[^A-Z]*$/,_a=/^[^a-z]*$/;var se=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Fn=(e)=>{let t=e.value;return!bs(t)&&t.length!==void 0};var wa=g("$ZodCheckMaxLength",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=Fn),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>t.maximum?xr(o):i)<=t.maximum)return;let a=yr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ka=g("$ZodCheckMinLength",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=Fn),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>=t.minimum&&i<t.minimum*2?xr(o):i)>=t.minimum)return;let a=yr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),za=g("$ZodCheckLengthEquals",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=Fn),e._zod.check=(n)=>{let o=n.value,i=o.length,s=typeof o==="string"&&i>=t.length&&i<=t.length*2?xr(o):i;if(s===t.length)return;let a=yr(o),u=s>t.length;n.issues.push({origin:a,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ct=g("$ZodCheckStringFormat",(e,t)=>{var r,n;if(se.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=()=>{})}),$a=g("$ZodCheckRegex",(e,t)=>{Ct.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})}}),Sa=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=va),Ct.init(e,t)}),Ia=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=_a),Ct.init(e,t)}),Pa=g("$ZodCheckIncludes",(e,t)=>{se.init(e,t);let r=st(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})}}),Za=g("$ZodCheckStartsWith",(e,t)=>{se.init(e,t);let r=new RegExp(`^${st(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})}}),Ea=g("$ZodCheckEndsWith",(e,t)=>{se.init(e,t);let r=new RegExp(`.*${st(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 Oa=g("$ZodCheckOverwrite",(e,t)=>{se.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Un{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 Ca={major:4,minor:6,patch:5};var j=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ca;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,u,c)=>{if(a.memo)return a;let l=be(a),p;for(let f of u){if(f._zod.def.when){if(Zs(a))continue;if(!f._zod.def.when(a))continue}else if(l)continue;let d=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&c?.async===!1)throw new _e;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await m,a.issues.length===d)return;if(Cn(a.issues,d,e),!l)l=be(a,d)});else{if(a.issues.length===d)continue;if(Cn(a.issues,d,e),!l)l=be(a,d)}}if(p)return p.then(()=>a);return a},s=(a,u,c)=>{if(be(a))return a.aborted=!0,a;let l=i(u,o,c);if(l instanceof Promise){if(c.async===!1)throw new _e;return l.then((p)=>e._zod.parse(p,c))}return e._zod.parse(l,c)};e._zod.run=(a,u)=>{if(u.skipChecks)return e._zod.parse(a,u);if(u.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...u,skipChecks:!0});if(l instanceof Promise)return l.then((p)=>s(p,a,u));return s(l,a,u)}let c=e._zod.parse(a,u);if(c instanceof Promise){if(u.async===!1)throw new _e;return c.then((l)=>i(l,o,u))}return i(c,o,u)}}},{get "~standard"(){return br(this,"~standard",Vn(this))},set "~standard"(e){Oe(this,"~standard",e)}}),qa=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>ve(r,t,ie()))}:{value:e.value};async function bf(e,t){let r={async:!0};return qa(await e._zod.run({value:t,issues:[]},r),r)}function Vn(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return qa(n,r)}catch(n){}return bf(e,t)},vendor:"zod",version:1}}var Zr=g("$ZodString",(e,t)=>{j.init(e,t),e._zod.pattern=t.pattern??ya,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)=>{Ct.init(e,t),Zr.init(e,t)}),Va=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=na),M.init(e,t)}),Ja=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=Bn(n))}else t.pattern??(t.pattern=Bn());M.init(e,t)}),Ha=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=oa),M.init(e,t)}),Ka=1,Ir=2;function Ga(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function vf(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Ga(e)||Ir;return _f(e,t)}function _f(e,t){if(!t.normalize&&t.protocol?.source===fa.source&&!/^https?:\/\//i.test(e))return Ka;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??Ir}return new URL(e)}catch{return Ir}}var wf=/[\t\n\r]/g;function Ta(e){return e.replace(wf,"")}function kf(e,t){return t.lastIndex=0,t.test(e.hostname)}function zf(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Xa=g("$ZodURL",(e,t)=>{M.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=vf(n,t);if(o===Ka){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Ir){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Ta(n);return}if(t.hostname&&!kf(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&&!zf(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:Ta(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Ya=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ia()),M.init(e,t)}),Wa=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?ea:ta(t.length)),M.init(e,t)}),Qa=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Gs),M.init(e,t)}),ec=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Xs),M.init(e,t)}),tc=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ys),M.init(e,t)}),rc=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ws),M.init(e,t)}),nc=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Qs),M.init(e,t)}),oc=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=xa(t)),M.init(e,t)}),ic=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ha),M.init(e,t)}),sc=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ga(t)),M.init(e,t)}),ac=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ra),M.init(e,t)}),cc=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=sa),M.init(e,t)}),$f=/^[0-9a-fA-F:.]+$/;function uc(e){if(!$f.test(e))return!1;return Ga(`http://[${e}]`)}var lc=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=aa),M.init(e,t),e._zod.check=(r)=>{if(!uc(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var pc=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ca),M.init(e,t)});function Sf(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 uc(r)}var fc=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ua),M.init(e,t),e._zod.check=(r)=>{if(!Sf(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function dc(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 Jn=/^[0-9a-zA-Z+/]*={0,2}$/,mc=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Jn),M.init(e,t),e._zod.check=(r)=>{if(dc(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Er=/^[A-Za-z0-9_-]*$/;function If(e){if(!Er.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return dc(r)}var hc=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Er),M.init(e,t),e._zod.check=(r)=>{if(If(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),gc=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=da),M.init(e,t)});function Pf(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 xc=g("$ZodJWT",(e,t)=>{M.init(e,t),e._zod.check=(r)=>{if(Pf(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var yc=g("$ZodBoolean",(e,t)=>{j.init(e,t),e._zod.pattern=ba,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 bc=g("$ZodUnknown",(e,t)=>{j.init(e,t),e._zod.parse=(r)=>r}),vc=g("$ZodNever",(e,t)=>{j.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Na(e,t,r){if(e.issues.length)t.issues.push(...je(r,e.issues));t.value[r]=e.value}var _c=g("$ZodArray",(e,t)=>{j.init(e,t);let r=ee.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 u=0;u<i.length;u++){let c=i[u],l=t.element._zod.run({value:c,issues:[]},o);if(l instanceof Promise)s.push(l.then((p)=>Na(p,n,u)));else if(Na(l,n,u),a&&l.issues.length!==0&&be(l))break}if(s.length)return Promise.all(s).then(()=>n);return n}});function Pr(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(...je(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 Zf=[];function wc(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Zf,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=Ss(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function kc(e,t,r,n,o,i,s){let a=[],u=o.keySet,c=o.catchall._zod,l=c.def.type,{optin:p,optout:f}=c,d=0;for(let m in t){if(s&&r.issues.length!==d){if(be(r,d))break;d=r.issues.length}if(u.has(m))continue;if(m==="__proto__"){if(l==="never")a.push(m);continue}if(l==="never"){a.push(m);continue}let x=c.run({value:t[m],issues:[]},n);if(x instanceof Promise)e.push(x.then((_)=>Pr(_,r,m,t,p,f)));else Pr(x,r,m,t,p,f)}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 Ef=g("$ZodObject",(e,t)=>{j.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let c=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),c.raw=l,l};c.raw=n,Object.defineProperty(t,"shape",{get:c})}let o=dr(()=>wc(t));N(e,"propValues",(c)=>{let l=c.def.shape,p={};for(let f in l){let d=l[f]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(p,f))de(p,f,new Set);for(let m of d.values)p[f].add(m);if(d.optin!==void 0)p[f].add(void 0)}}return p});let i=Pt,s=t.catchall,a,u=ee.memoizer;u?.attach(e),e._zod.parse=(c,l)=>{a??(a=o.value);let p=c.value;if(!i(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value=u?u.alloc(e,c,{},l):{};let f=[],d=a.shape,m=l?.abortEarly,x=c.issues.length;for(let _ of a.allKeys){if(m&&c.issues.length!==x){if(be(c,x))break;x=c.issues.length}if(_==="__proto__")continue;let b=d[_],P=b._zod.optin,D=b._zod.optout,B=b._zod.run({value:p[_],issues:[]},l);if(B instanceof Promise)f.push(B.then((T)=>Pr(T,c,_,p,P,D)));else Pr(B,c,_,p,P,D)}if(!s)return f.length?Promise.all(f).then(()=>c):c;return kc(f,p,c,l,o.value,e,m===!0)}}),zc=g("$ZodObjectJIT",(e,t)=>{Ef.init(e,t);let r=e._zod.parse,n=dr(()=>wc(t)),o=ee.memoizer,i=(d)=>{let m=n.value,x=m.symbolKeys,_=new Un(["payload","ctx"],{shape:d,inst:e,memo:o,syms:x}),b=(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 D=Object.create(null),B=0;for(let T of m.allKeys)D[T]=`key_${B++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let T of m.allKeys){if(T==="__proto__")continue;let O=D[T],J=typeof T==="symbol"?`syms[${x.indexOf(T)}]`:ws(T),De=`${J} in input`,Ke=d[T],Le=Ke?._zod?.optin,fr=Le!==void 0,kn=Ke?._zod?.optout==="optional";if(_.write(`const ${O} = ${b(J)};`),fr&&kn){let zn=Le==="optional"?`${O}_present`:`${O}.value !== undefined || ${O}_present`;_.write(`
|
|
17
|
-
const ${O}_present = ${De};
|
|
18
|
-
if (!${O}.issues.length || ${O}_present) {
|
|
19
|
-
if (${O}.issues.length) {${P(O,J)}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (${zn}) {
|
|
23
|
-
newResult[${J}] = ${O}.value;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
`)}else if(!fr)_.write(`
|
|
28
|
-
const ${O}_present = ${De};
|
|
29
|
-
if (${O}.issues.length) {${P(O,J)}
|
|
30
|
-
}
|
|
31
|
-
if (!${O}_present && !${O}.issues.length) {
|
|
32
|
-
payload.issues.push({
|
|
33
|
-
code: "invalid_type",
|
|
34
|
-
expected: "nonoptional",
|
|
35
|
-
input: undefined,
|
|
36
|
-
path: [${J}]
|
|
37
|
-
});
|
|
38
|
-
if (ctx && ctx.abortEarly) {
|
|
39
|
-
payload.value = newResult;
|
|
40
|
-
return payload;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (${O}_present) {
|
|
45
|
-
newResult[${J}] = ${O}.value;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
`);else if(_.write(`
|
|
49
|
-
if (${O}.issues.length) {${P(O,J)}
|
|
50
|
-
}
|
|
51
|
-
`),Le==="defaulted")_.write(`newResult[${J}] = ${O}.value;`);else _.write(`
|
|
52
|
-
if (${O}.value !== undefined || ${De}) {
|
|
53
|
-
newResult[${J}] = ${O}.value;
|
|
54
|
-
}
|
|
55
|
-
`)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()},s,a=Pt,u=!ee.jitless,l=u&&zs.value,p=t.catchall,f;e._zod.parse=(d,m)=>{f??(f=n.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(u&&l&&m?.async===!1&&m.jitless!==!0){if(!s)s=i(t.shape);if(d=s(d,m),!p)return d;return kc([],x,d,m,f,e,m?.abortEarly===!0)}return r(d,m)}});function Ra(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)=>!be(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)=>ve(s,n,ie())))}),t}var $c=g("$ZodUnion",(e,t)=>{j.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)=>mr(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 u=a._zod.run({value:n.value,issues:[]},o);if(u instanceof Promise)s.push(u),i=!0;else{if(u.issues.length===0)return u;s.push(u)}}if(!i)return Ra(s,n,e,o);return Promise.all(s).then((a)=>Ra(a,n,e,o))}});var Sc=g("$ZodIntersection",(e,t)=>{j.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(([u,c])=>Ma(r,u,c));return Ma(r,i,s)}});function qn(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(Xe(e)&&Xe(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=qn(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=qn(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 Ma(e,t,r){let n=new Map,o,i=new Map,s=(c,l)=>{let p;if(c.code==="unrecognized_keys"&&!c.path?.length)o??(o=c),p=c.keys;else if(c.code==="invalid_key"&&c.origin==="record"&&c.path?.length===1){let f=String(c.path[0]);if(!i.has(f))i.set(f,c);p=[f]}else return!1;for(let f of p){if(!n.has(f))n.set(f,{});n.get(f)[l]=!0}return!0};for(let c of t.issues)if(!s(c,"l"))e.issues.push(c);for(let c of r.issues)if(!s(c,"r"))e.issues.push(c);let a=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length){let c=o?a.filter((l)=>o.keys.includes(l)):[];if(c.length)e.issues.push({...o,keys:c});for(let l of a)if(!c.includes(l)&&i.has(l))e.issues.push(i.get(l))}let u=qn(t.value,r.value);if(!u.valid){if(be(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}var Ic=g("$ZodRecord",(e,t)=>{j.init(e,t);let r=ee.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Xe(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 u=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(u.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)=>ve(m,o,ie())),input:l,path:[l],inst:e});continue}let f=p.value;if(f==="__proto__")continue;let d=t.valueType._zod.run({value:i[l],issues:[]},o);if(d instanceof Promise)s.push(d.then((m)=>{if(m.issues.length)n.issues.push(...je(l,m.issues));n.value[f]=m.value}));else{if(d.issues.length)n.issues.push(...je(l,d.issues));n.value[f]=d.value}}let c;for(let l in i)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=i[l]}else c=c??[],c.push(l);if(c&&c.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let u;for(let c of Reflect.ownKeys(i)){if(c==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof c==="string"&&$r.test(c)&&l.issues.length){let m=t.keyType._zod.run({value:Number(c),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[c]=i[c];else if(a)u=u??[],u.push(c);else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((m)=>ve(m,o,ie())),input:c,path:[c],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let d=t.valueType._zod.run({value:i[c],issues:[]},o);if(d instanceof Promise)s.push(d.then((m)=>{if(m.issues.length)n.issues.push(...je(c,m.issues));n.value[f]=m.value}));else{if(d.issues.length)n.issues.push(...je(c,d.issues));n.value[f]=d.value}}if(u&&u.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}if(s.length)return Promise.all(s).then(()=>n);return n}});var Pc=g("$ZodEnum",(e,t)=>{j.init(e,t);let r=Zt(t.entries),n=new Set(r);e._zod.values=n,N(e,"pattern",(o)=>{let i=Zt(o.def.entries).filter((s)=>$s.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>st(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 Zc=g("$ZodTransform",(e,t)=>{j.init(e,t),e._zod.optin="optional",ee.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ot(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 _e;return r.value=o,r}});function Da(e,t){return e.value=t.issues.length?void 0:t.value,e}var Hn=g("$ZodOptional",(e,t)=>{j.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(`^(${mr(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)=>Da(r,i));return Da(r,o)}return t.innerType._zod.run(r,n)}}),Ec=g("$ZodExactOptional",(e,t)=>{Hn.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)}),Oc=g("$ZodNullable",(e,t)=>{j.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(`^(${mr(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)}}),Ac=g("$ZodDefault",(e,t)=>{j.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)=>La(i,t));return La(o,t)}});function La(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Cc=g("$ZodPrefault",(e,t)=>{j.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)}}),Tc=g("$ZodNonOptional",(e,t)=>{j.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)=>Ba(i,e));return Ba(o,e)}});function Ba(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 ja(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)=>ve(o,n,ie()))},input:e.value}),e}var Nc=g("$ZodCatch",(e,t)=>{j.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)=>ja(r,i,t,n));return ja(r,o,t,n)}});var Rc=g("$ZodPipe",(e,t)=>{j.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)=>Sr(s,t.in,n));return Sr(i,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>Sr(i,t.out,n));return Sr(o,t.out,n)}});function Sr(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 Mc=g("$ZodReadonly",(e,t)=>{j.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(Fa);return Fa(o)}});function Fa(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Dc=g("$ZodCustom",(e,t)=>{se.init(e,t),j.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)=>Ua(i,r,n,e));Ua(o,r,n,e);return}});function Ua(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(Ye(o))}}class Bc extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Gn="~memo",Lc=[];function jc(e){return e!==null&&typeof e==="object"}function Kn(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Fc=new WeakMap,Tt=0,Cr=1,Nt=2;function Tr(e,t,r){let n=Fc.get(e);if(n!==void 0)return n?Nt:Tt;if(t.has(e))return Nt;t.add(e);let o=Tt,i=(l)=>{if(o!==Nt&&l?._zod){let p=Tr(l,t,r);if(p>o)o=p}},s=(l,p)=>{let f=Tt;for(let d of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,d);if(p&&!m.enumerable)continue;let x=m.get?Cr:m.value?._zod?Tr(m.value,t,r):Tt;if(x>f)f=x}return f},a=(l)=>{if(l>o)o=l},u=e._zod.def,c=u.type;switch(c){case"object":{let l=hr(u);a(l?s(l,!0):Cr),i(u.catchall);break}case"array":i(u.element);break;case"tuple":for(let l of u.items)i(l);i(u.rest);break;case"record":case"map":i(u.keyType),i(u.valueType);break;case"set":i(u.valueType);break;case"union":for(let l of u.options)i(l);break;case"intersection":i(u.left),i(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(u.innerType);break;case"pipe":i(u.in),i(u.out);break;case"function":i(u.input),i(u.output);break;case"lazy":{let l=u._cachedInner??(r?e._zod.innerType:void 0);a(l?Tr(l,t,!1):Cr);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 u){let p=Object.getOwnPropertyDescriptor(u,l);if(!p||p.get)continue;let f=p.value;if(!f||typeof f!=="object")continue;if(f._zod)i(f);else if(Array.isArray(f))for(let d of f)i(d)}}return t.delete(e),Of(e,o)}function Of(e,t){if(t!==Cr)Fc.set(e,t===Nt);return t}function Af(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Or,Ar=[],Cf={alloc(e,t,r){let n=Or;if(!n)return r;Or=void 0;let o={value:r,issues:null};return n.set(t.value,o),Ar.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"&&Tf(i,o.value))throw new Bc;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=(u,c)=>{if(r===void 0){let b=Tr(e,new Set,!1);if(b===Tt){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(u,c)}if(b===Nt||n)r=!0;else n=!0}let l=u.value;if(!jc(l))return s(u,c);let p=c[Gn];if(!p)p={buckets:new WeakMap,backEdges:void 0},c[Gn]=p;let f;if(o===c)f=i;else f=Af(p,e),o=c,i=f;let d=f.get(l);if(d){if(u.value=d.value,d.issues){if(d.issues.length)u.issues.push(...Kn(d.issues))}else u.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(d.value);return u}Or=f;let m=Ar.length,x=s(u,c);Or=void 0;let _=Ar.length>m?Ar.pop():void 0;if(x instanceof Promise)return x.then((b)=>{if(_)_.issues=b.issues.length?Kn(b.issues):Lc;return b});if(_)_.issues=x.issues.length?Kn(x.issues):Lc;return x};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function Uc(){return Cf}function Tf(e,t){let r=e[Gn]?.backEdges;return r!==void 0&&jc(t)&&r.has(t)}var Nf=()=>{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=Es(i.input),u=o(a,i.input);return`Invalid input: expected ${s}, received ${u}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${En(i.values[0])}`;return`Invalid option: expected one of ${In(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":""}: ${In(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 Xn(){return{localeError:Nf()}}var qc;class Vc{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 Rf(){return new Vc}(qc=globalThis).__zod_globalRegistry??(qc.__zod_globalRegistry=Rf());var We=globalThis.__zod_globalRegistry;function Mf(e){if(e.checks)e.checks=[...e.checks];return e}function Jc(e,t){return new e(Mf({type:"string",...S(t)}))}function Hc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}function Kc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function Yn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}function Gc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}function Xc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}function Yc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}function Wc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}function Qc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}function eu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}function tu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}function ru(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}function nu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}function ou(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}function iu(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}function su(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}function au(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}function cu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}function uu(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}function lu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}function pu(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}function fu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}function du(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}function mu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(t)})}function hu(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}function gu(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}function xu(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}function yu(e,t){return new e({type:"boolean",...S(t)})}function bu(e){return new e({type:"unknown"})}function vu(e,t){return new e({type:"never",...S(t)})}function Nr(e,t){return new wa({check:"max_length",...S(t),maximum:e})}function at(e,t){return new ka({check:"min_length",...S(t),minimum:e})}function Rr(e,t){return new za({check:"length_equals",...S(t),length:e})}function Wn(e,t){return new $a({check:"string_format",format:"regex",...S(t),pattern:e})}function Qn(e){return new Sa({check:"string_format",format:"lowercase",...S(e)})}function eo(e){return new Ia({check:"string_format",format:"uppercase",...S(e)})}function to(e,t){return new Pa({check:"string_format",format:"includes",...S(t),includes:e})}function ro(e,t){return new Za({check:"string_format",format:"starts_with",...S(t),prefix:e})}function no(e,t){return new Ea({check:"string_format",format:"ends_with",...S(t),suffix:e})}function Fe(e){return new Oa({check:"overwrite",tx:e})}function oo(e){return Fe((t)=>t.normalize(e))}function io(){return Fe((e)=>e.trim())}function so(){return Fe((e)=>e.toLowerCase())}function ao(){return Fe((e)=>e.toUpperCase())}function co(){return Fe((e)=>ks(e))}function _u(e,t,r){return new e({type:"array",element:t,...S(r)})}function wu(e,t,r){return new e({type:"custom",check:"custom",fn:t,...S(r)})}function ku(e,t){let r=Df((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(Ye(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(Ye(i))}},e(n.value,n)),t);return r}function Df(e,t){let r=new se({check:"custom",...S(t)});return r._zod.check=e,r}function Rt(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))de(e,n,r[n]);return e}function lo(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??We,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 ct(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 q(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 f=s.schema,d=t.processors[o.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);d(e,t,f,l)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;q(p,t,l),t.seen.get(p).isParent=!0}}let u=t.metadataRegistry.get(e);if(u)Rt(s.schema,u);if(t.io==="input"&&W(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 zu(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function po(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 u=n.get(a);if(u&&u!==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,f=e.external.uri??((m)=>m);if(p)return{ref:f(p)};let d=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=d,{defId:d,ref:`${f("__shared")}#/${a}/${zu(d)}`}}let u="#",c=`${u}/${a}/`;if(s[1]===r&&!s[1].schema.id)return{ref:u};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:c+zu(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:u,defId:c}=o(s);if(a.def={...a.schema},c)a.defId=c;let l=a.schema;for(let p in l)delete l[p];l.$ref=u};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 c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){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 Iu(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;Iu(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 Pu=new Set(["type","properties","required","additionalProperties"]),$u=["oneOf","anyOf"];function Su(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 uo(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Pu.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 c of t){let l=c.properties?.[s]??Su(c);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let u=a.length===1?a[0]:uo(a)??{allOf:a};de(r,s,u)}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=Su(s);if(a&&!i.some((u)=>JSON.stringify(u)===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 Lf(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Pu)if(o in e)return;let r=t.filter((o)=>$u.some((i)=>Array.isArray(o[i]))),n=null;if(!r.length)n=uo(t);else{let o=r[0],i=$u.find((u)=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;let s=t.filter((u)=>u!==o),a=o[i].map((u)=>uo([...s,u]));if(a.some((u)=>!u))return;n={[i]:a}}if(!n)return;delete e.allOf,Rt(e,n)}function fo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(a)=>{let u=e.seen.get(a);if(u.ref===null)return;let c=u.def??u.schema,l={...c},p=u.ref;if(u.ref=null,p){n(p);let d=e.seen.get(p),m=d.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))c.allOf=c.allOf??[],c.allOf.push(m);else Rt(c,m);if(Rt(c,l),a._zod.parent===p)for(let _ in c){if(_==="$ref"||_==="allOf")continue;if(!(_ in l))delete c[_]}if(m.$ref&&d.def)for(let _ in c){if(_==="$ref"||_==="allOf")continue;if(_ in d.def&&JSON.stringify(c[_])===JSON.stringify(d.def[_]))delete c[_]}}let f=a._zod.parent;if(f&&f!==p){n(f);let d=e.seen.get(f);if(d?.schema.$ref){if(c.$ref=d.schema.$ref,d.def)for(let m in c){if(m==="$ref"||m==="allOf")continue;if(m in d.def&&JSON.stringify(c[m])===JSON.stringify(d.def[m]))delete c[m]}}}e.override({zodSchema:a,jsonSchema:c,path:u.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())Iu(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let u of e.seen.values())for(let c of[u.schema,u.def]){let l=c?.allOf;if(!Array.isArray(l))continue;let p=a.get(l);if(p)p.push(c);else a.set(l,[c])}for(let u of e.intersections)for(let c of a.get(u)??[])Lf(c)}}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)}Rt(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 u=a[1];if(u.def&&u.defId){if(u.def.id===u.defId)delete u.def.id;de(s,u.defId,u.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:Mt(t,"input",e.processors),output:Mt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function W(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 W(n.element,r);if(n.type==="set")return W(n.valueType,r);if(n.type==="lazy")return W(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 W(n.innerType,r);if(n.type==="intersection")return W(n.left,r)||W(n.right,r);if(n.type==="record"||n.type==="map")return W(n.keyType,r)||W(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return W(n.in,r)||W(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(W(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(W(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(W(o,r))return!0;if(n.rest&&W(n.rest,r))return!0;return!1}return!1}var Zu=(e,t={})=>(r)=>{let n=lo({...r,processors:t});return q(e,n),po(n,e),fo(n,e)},Mt=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:i}=n??{},s=lo({...o??{},target:i,io:t,processors:r});return q(e,s),po(s,e),fo(s,e)};var ut=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},lt=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Eu=(e,t)=>{ut(e,"minimum",t),lt(e,"maximum",t)},Tu=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Nu=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Ru=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Mu=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Ou=(e,t)=>ut(e,"minimum",t.minimum),Au=(e,t)=>lt(e,"maximum",t.maximum),Cu=(e)=>(t,r)=>{Mu(t,r.format);let[n,o]=e[r.format];ut(t,"minimum",n),lt(t,"maximum",o)},Bf={greater_than:(e,t)=>ut(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>lt(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Tu(e,t.value),number_format:Cu(On),bigint_format:Cu(An),min_length:Ou,max_length:Au,length_equals:(e,t)=>Eu(e,t.length),min_size:Ou,max_size:Au,size_equals:(e,t)=>Eu(e,t.size),string_format:(e,t)=>{if(Mu(e,t.format),t.pattern)Nu(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)=>Ru(e,t.mime)};function Qe(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of n)Bf[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)ut(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)ut(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)lt(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)lt(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)Tu(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)Ru(t,o.mime);for(let i of o.patterns??[])Nu(t,i);return t}var jf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ff=new Map([[Jn,la],[Er,pa]]),Du=(e)=>Ff.get(e)??e,Lu=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=Qe(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=jf[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(c)o.contentEncoding=c;if(u&&u.size>0){let p=[...u].map(Du);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}};var Bu=(e,t,r,n)=>{r.type="boolean"};var ju=(e,t,r,n)=>{r.not={}};var Fu=(e,t,r,n)=>{};var Uu=(e,t,r,n)=>{let o=e._zod.def,i=Zt(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 qu=(e,t,r,n)=>{ct(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Vu=(e,t,r,n)=>{ct(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Ju=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:a}=Qe(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=q(i.element,t,{...n,path:[...n.path,"items"]})};function Mr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Mr(t.out);if(t.type==="catch")return Mr(t.innerType);return e._zod.optin}var Hu=(e,t,r,n)=>{let o=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ct(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let c in s)de(o.properties,c,q(s[c],t,{...n,path:[...n.path,"properties",c]}));let u=[];for(let c of Object.keys(s)){let l=i.shape[c];if(t.io==="input"?Mr(l)===void 0:l._zod.optout===void 0)u.push(c)}if(u.length>0)o.required=u;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=q(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},Ku=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,u)=>q(a,t,{...n,path:[...n.path,i?"oneOf":"anyOf",u]}));if(i)r.oneOf=s;else r.anyOf=s},Gu=(e,t,r,n)=>{let o=e._zod.def,i=q(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=q(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=(c)=>("allOf"in c)&&Object.keys(c).length===1,u=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=u,t.intersections.push(u)};function mo(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=mo(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((b)=>mo(e,b,r));if(_.some((b,P)=>b!==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:u,exclusiveMaximum:c,multipleOf:l,format:p,id:f,...d}=t;if(d.enum)d.enum=d.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof d.const==="number")d.const=String(d.const);if(!o)return d;if(d.type="string",!i)d.pattern=(n.includes("number")?$r:jn).source;return d}var ho=new WeakMap;function Uf(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 ho.get(e)??[]){let o=e.seen.get(n),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=mo(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 Xu=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,a=Qe(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=q(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)de(o.patternProperties,Du(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=q(i.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=ho.get(t);if(!l)l=[],ho.set(t,l),t.deferred.push(()=>Uf(t));l.push(e)}o.additionalProperties=q(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let u=s._zod.values,c=t.io==="input"&&Mr(i.valueType)!==void 0;if(u&&!i.partial&&!c){let l=[...u].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},Yu=(e,t,r,n)=>{let o=e._zod.def,i=q(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"}]},Wu=(e,t,r,n)=>{let o=e._zod.def;q(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},go=Symbol();function Qu(e,t,r,n,o){let i=!1,s=JSON.stringify(e,(a,u)=>{if(typeof u!=="bigint")return u;return i=!0,null});if(!i)return JSON.parse(s);return ct(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),go}var el=(e,t,r,n)=>{let o=e._zod.def;q(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s=Qu(o.defaultValue,e,t,r,n);if(s!==go)r.default=s},tl=(e,t,r,n)=>{let o=e._zod.def;q(o.innerType,t,n);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=Qu(o.defaultValue,e,t,r,n);if(s!==go)r._prefault=s},rl=(e,t,r,n)=>{let o=e._zod.def;q(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{ct(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},nl=(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;q(s,t,n);let a=t.seen.get(e);a.ref=s},ol=(e,t,r,n)=>{let o=e._zod.def;q(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0};var xo=(e,t,r,n)=>{let o=e._zod.def;q(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType};var il=new WeakSet([Object.prototype,Error.prototype]);function Dr(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 rd=(e,t)=>{Ms.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(il.has(r))return;il.add(r),Dr(r,"format",(n)=>(o)=>Ls(n,o)),Dr(r,"flatten",(n)=>(o)=>Ds(n,o)),Dr(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Et,2)}),Dr(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Et,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ae=g("ZodError",rd,void 0,{Parent:Error});var sl=_r(ae),al=wr(ae),cl=kr(ae),ul=zr(ae),ll=js(ae),pl=Fs(ae),fl=Us(ae),dl=qs(ae),ml=Vs(ae),hl=Js(ae),gl=Hs(ae),xl=Ks(ae);function od(){if(!ee.localeError)ie(Xn())}function Lr(){if(!ee.memoizer)ie({memoizer:Uc()})}var V=g("ZodType",(e,t)=>(od(),j.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(oe(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 ye(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Wd(e,t))},superRefine(e,t){return this.check(Qd(e,t))},overwrite(e){return this.check(Fe(e))},optional(){return vl(this)},exactOptional(){return Ld(this)},nullable(){return _l(this)},nullish(){return vl(_l(this))},nonoptional(e){return Vd(this,e)},array(){return ce(this)},or(e){return Td([this,e])},and(e){return Rd(this,e)},transform(e){return wl(this,Dd(e))},default(e){return Fd(this,e)},prefault(e){return qd(this,e)},catch(e){return Hd(this,e)},pipe(e){return wl(this,e)},readonly(){return Xd(this)},describe(e){let t=this.clone();return We.add(t,{description:e}),t},meta(...e){if(e.length===0)return We.get(this);let t=this.clone();return We.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 br(this,"~standard",{...Vn(this),jsonSchema:{input:Mt(this,"input"),output:Mt(this,"output")}})},set "~standard"(e){Oe(this,"~standard",e)},parse:function e(t,r){return sl(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await al(this,t,r,{callee:e})},safeParse(e,t){return cl(this,e,t)},async safeParseAsync(e,t){return ul(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Oe(this,"spa",e)},validate(e,t){return Mn(this,e,t)},validateAsync(e,t){return Dn(this,e,t)},encode:function e(t,r){return ll(this,t,r,{callee:e})},decode:function e(t,r){return pl(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await fl(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await dl(this,t,r,{callee:e})},safeEncode(e,t){return ml(this,e,t)},safeDecode(e,t){return hl(this,e,t)},async safeEncodeAsync(e,t){return gl(this,e,t)},async safeDecodeAsync(e,t){return xl(this,e,t)},toJSONSchema(e){return Zu(this,{})(e)},get description(){return We.get(this)?.description},get _def(){return this._zod.def}}),kl=g("_ZodString",(e,t)=>{Zr.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Lu(e,r,n,o)},rf({format:(e)=>Qe(e).format??null,minLength:(e)=>Qe(e).minimum??null,maxLength:(e)=>Qe(e).maximum??null},{regex(...e){return this.check(Wn(...e))},includes(...e){return this.check(to(...e))},startsWith(...e){return this.check(ro(...e))},endsWith(...e){return this.check(no(...e))},min(...e){return this.check(at(...e))},max(...e){return this.check(Nr(...e))},length(...e){return this.check(Rr(...e))},nonempty(...e){return this.check(at(1,...e))},lowercase(e){return this.check(Qn(e))},uppercase(e){return this.check(eo(e))},trim(){return this.check(io())},normalize(...e){return this.check(oo(...e))},toLowerCase(){return this.check(so())},toUpperCase(){return this.check(ao())},slugify(){return this.check(co())}})),id=g("ZodString",(e,t)=>{Zr.init(e,t),kl.init(e,t)},{email(e){return this.check(Hc(ld,e))},url(e){return this.check(Wc(fd,e))},jwt(e){return this.check(du(Id,e))},emoji(e){return this.check(Qc(dd,e))},guid(e){return this.check(Kc(pd,e))},uuid(e){return this.check(Yn(Dt,e))},uuidv4(e){return this.check(Gc(Dt,e))},uuidv6(e){return this.check(Xc(Dt,e))},uuidv7(e){return this.check(Yc(Dt,e))},nanoid(e){return this.check(eu(md,e))},cuid(e){return this.check(tu(hd,e))},cuid2(e){return this.check(ru(gd,e))},ulid(e){return this.check(nu(xd,e))},base64(e){return this.check(lu(zd,e))},base64url(e){return this.check(pu($d,e))},xid(e){return this.check(ou(yd,e))},ksuid(e){return this.check(iu(bd,e))},ipv4(e){return this.check(su(vd,e))},ipv6(e){return this.check(au(_d,e))},cidrv4(e){return this.check(cu(wd,e))},cidrv6(e){return this.check(uu(kd,e))},e164(e){return this.check(fu(Sd,e))},datetime(e){return this.check(mu(sd,e))},date(e){return this.check(hu(ad,e))},time(e){return this.check(gu(cd,e))},duration(e){return this.check(xu(ud,e))}});function I(e){return Jc(id,e)}var L=g("ZodStringFormat",(e,t)=>{M.init(e,t),kl.init(e,t)}),sd=g("ZodISODateTime",(e,t)=>{oc.init(e,t),L.init(e,t)}),ad=g("ZodISODate",(e,t)=>{ic.init(e,t),L.init(e,t)}),cd=g("ZodISOTime",(e,t)=>{sc.init(e,t),L.init(e,t)}),ud=g("ZodISODuration",(e,t)=>{ac.init(e,t),L.init(e,t)}),ld=g("ZodEmail",(e,t)=>{Ha.init(e,t),L.init(e,t)});var pd=g("ZodGUID",(e,t)=>{Va.init(e,t),L.init(e,t)});var Dt=g("ZodUUID",(e,t)=>{Ja.init(e,t),L.init(e,t)});function vo(e){return Yn(Dt,e)}var fd=g("ZodURL",(e,t)=>{Xa.init(e,t),L.init(e,t)});var dd=g("ZodEmoji",(e,t)=>{Ya.init(e,t),L.init(e,t)});var md=g("ZodNanoID",(e,t)=>{Wa.init(e,t),L.init(e,t)});var hd=g("ZodCUID",(e,t)=>{Qa.init(e,t),L.init(e,t)});var gd=g("ZodCUID2",(e,t)=>{ec.init(e,t),L.init(e,t)});var xd=g("ZodULID",(e,t)=>{tc.init(e,t),L.init(e,t)});var yd=g("ZodXID",(e,t)=>{rc.init(e,t),L.init(e,t)});var bd=g("ZodKSUID",(e,t)=>{nc.init(e,t),L.init(e,t)});var vd=g("ZodIPv4",(e,t)=>{cc.init(e,t),L.init(e,t)});var _d=g("ZodIPv6",(e,t)=>{lc.init(e,t),L.init(e,t)});var wd=g("ZodCIDRv4",(e,t)=>{pc.init(e,t),L.init(e,t)});var kd=g("ZodCIDRv6",(e,t)=>{fc.init(e,t),L.init(e,t)});var zd=g("ZodBase64",(e,t)=>{mc.init(e,t),L.init(e,t)});var $d=g("ZodBase64URL",(e,t)=>{hc.init(e,t),L.init(e,t)});var Sd=g("ZodE164",(e,t)=>{gc.init(e,t),L.init(e,t)});var Id=g("ZodJWT",(e,t)=>{xc.init(e,t),L.init(e,t)});var Pd=g("ZodBoolean",(e,t)=>{yc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bu(e,r,n,o)});function pt(e){return yu(Pd,e)}var Zd=g("ZodUnknown",(e,t)=>{bc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fu(e,r,n,o)});function yl(){return bu(Zd)}var Ed=g("ZodNever",(e,t)=>{vc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ju(e,r,n,o)});function zl(e){return vu(Ed,e)}var Od=g("ZodArray",(e,t)=>{Lr(),_c.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ju(e,r,n,o),e.element=t.element},{min(e,t){return this.check(at(e,t))},nonempty(e){return this.check(at(1,e))},max(e,t){return this.check(Nr(e,t))},length(e,t){return this.check(Rr(e,t))},unwrap(){return this.element}});function ce(e,t){return _u(Od,e,t)}var $l=g("ZodObject",(e,t)=>{Lr(),zc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hu(e,r,n,o),af(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return jr(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(oe(this._zod.def,{catchall:e}))},passthrough(){return this.clone(oe(this._zod.def,{catchall:yl()}))},loose(){return this.clone(oe(this._zod.def,{catchall:yl()}))},strict(){return this.clone(oe(this._zod.def,{catchall:zl()}))},strip(){return this.clone(oe(this._zod.def,{catchall:void 0}))},extend(e){return Yp(this,e)},safeExtend(e){return Wp(this,e)},merge(e){return Qp(this,e)},pick(e){return Gp(this,e)},omit(e){return Xp(this,e)},partial(...e){return Ps(Sl,this,e[0])},exactPartial(...e){return Ps(Il,this,e[0],"exactPartial")},required(...e){return ef(Pl,this,e[0])}});function Ad(e,t){let r={type:"object",shape:e??{},...S(t)};return new $l(r)}function G(e,t){return new $l({type:"object",shape:e,catchall:zl(),...S(t)})}var Cd=g("ZodUnion",(e,t)=>{$c.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ku(e,r,n,o),e.options=t.options});function Td(e,t){return new Cd({type:"union",options:e,...S(t)})}var Nd=g("ZodIntersection",(e,t)=>{Sc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gu(e,r,n,o)});function Rd(e,t){return new Nd({type:"intersection",left:e,right:t})}var bl=g("ZodRecord",(e,t)=>{Lr(),Ic.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xu(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Br(e,t,r){if(!t||!t._zod)return new bl({type:"record",keyType:I(),valueType:e,...S(t)});return new bl({type:"record",keyType:e,valueType:t,...S(r)})}var bo=g("ZodEnum",(e,t)=>{Pc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Uu(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 bo({...t,checks:[],...S(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 bo({...t,checks:[],...S(o),entries:i})}});function jr(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new bo({type:"enum",entries:r,...S(t)})}var Md=g("ZodTransform",(e,t)=>{Lr(),Zc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vu(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ot(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(Ye(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(Ye(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 Dd(e){return new Md({type:"transform",transform:e})}var Sl=g("ZodOptional",(e,t)=>{Hn.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xo(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function vl(e){return new Sl({type:"optional",innerType:e})}var Il=g("ZodExactOptional",(e,t)=>{Ec.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xo(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ld(e){return new Il({type:"optional",innerType:e})}var Bd=g("ZodNullable",(e,t)=>{Oc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function _l(e){return new Bd({type:"nullable",innerType:e})}var jd=g("ZodDefault",(e,t)=>{Ac.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>el(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Fd(e,t){return new jd({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Zn(t)}})}var Ud=g("ZodPrefault",(e,t)=>{Cc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function qd(e,t){return new Ud({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Zn(t)}})}var Pl=g("ZodNonOptional",(e,t)=>{Tc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wu(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Vd(e,t){return new Pl({type:"nonoptional",innerType:e,...S(t)})}var Jd=g("ZodCatch",(e,t)=>{Nc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hd(e,t){return new Jd({type:"catch",innerType:e,catchValue:typeof t==="function"?t:As(t)})}var Kd=g("ZodPipe",(e,t)=>{Rc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nl(e,r,n,o),e.in=t.in,e.out=t.out});function wl(e,t){return new Kd({type:"pipe",in:e,out:t})}var Gd=g("ZodReadonly",(e,t)=>{Mc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ol(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Xd(e){return new Gd({type:"readonly",innerType:e})}var Yd=g("ZodCustom",(e,t)=>{Dc.init(e,t),V.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qu(e,r,n,o)});function Wd(e,t={}){return wu(Yd,e,t)}function Qd(e,t){return ku(e,t)}var dt=jr(["global","private","shared"]),em=I().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(48),mt=G({name:em,description:I().trim().min(1).max(300),body:I().trim().min(1).max(24000)}),_o=G({scope:dt,choices:Br(I().max(128),pt()),edits:Br(I().max(128),I().min(1).max(48000)).default({}),custom:ce(mt).max(40).default([])}),r0=_o.extend({directory:I(),id:I()});var tm=G({id:I(),title:I(),parentId:I().nullable()}),rm=G({id:I(),itemIds:ce(I()).min(1),parentId:I(),relatedHubIds:ce(I()).max(2)}),Fr=G({hubs:ce(tm),leaves:ce(rm)});var nm=G({id:I(),name:I(),title:I(),description:I(),text:I(),kind:jr(["preference","skill"]),category:I().nullable(),section:I().nullable(),axis:I().nullable(),owner:jr(["packaged","managed","user","provider"])}),Zl=G({scope:dt,input:_o,inherited:Br(I(),pt()),locked:Br(I(),pt()),items:ce(nm),constellation:Fr,requirements:ce(I()),libraryEnabled:pt(),migrationRequired:pt(),revisionId:I().nullable()}),El=G({id:vo(),changes:ce(G({path:I(),before:I().nullable(),after:I().nullable(),internal:pt()})),warnings:ce(I())}),wo=G({revisionId:I().nullable()});var ko=window.location.hash.slice(1),om=ko||sessionStorage.getItem("shadowclone-session")||"";if(ko)sessionStorage.setItem("shadowclone-session",ko),history.replaceState(null,"",`${location.pathname}${location.search}`);async function le(e){let t=await fetch(e.path,{method:e.body===void 0?"GET":"POST",headers:{Authorization:`Bearer ${om}`,"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=Ad({error:I()}).safeParse(r);throw Error(n.success?n.data.error:"The local editor could not complete this action.")}return e.schema.parse(r)}function zo(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 u=zo({parentId:s,title:a,leaves:e.leaves.slice(o,o+t)});r.push(...u.hubs),n.push(...u.leaves)}return{hubs:r,leaves:n}}var im=new Set(["agent","before","change","changing","code","existing","from","into","skill","that","the","this","when","with","work"]);function $o(e){return e.toLowerCase().replaceAll(/[^a-z0-9-]+/g," ").split(/[\s-]+/).filter((t)=>t.length>2&&!im.has(t))}function sm(e){return[e.category,e.section,e.axis,...$o(e.name),...$o(e.title),...$o(e.description)].filter((t,r,n)=>Boolean(t&&n.indexOf(t)===r))}function Ol(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:sm(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 um(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((u)=>({candidate:u,score:(s.item.section===u.entries[0]?.item.section?4:0)+(s.topics.includes(u.key)?1:0)})).sort((u,c)=>c.score-u.score||u.candidate.entries.length-c.candidate.entries.length||u.candidate.key.localeCompare(c.candidate.key))[0]?.candidate.entries.push(s);return o.sort((i,s)=>i.key.localeCompare(s.key))}function lm(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 pm(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 Al(e){let t=am(e),r=um(t),n=r.map(lm),o=[],i=[];for(let[s,a]of r.entries()){let u=`hub:${s}:${a.key}`,c=n[s]??a.key,l=n.slice(0,s).filter((x)=>x===c).length,p=n.filter((x)=>x===c).length;o.push({id:u,title:`${Ol(c)}${p>1?` ${l+1}`:""}`,parentId:null});let f=[...a.entries].sort((x,_)=>x.item.id.localeCompare(_.item.id)),d=f.map((x)=>{let _=r.map((b,P)=>({candidate:b,index:P})).filter(({candidate:b})=>b.key!==a.key&&x.topics.includes(b.key)).slice(0,2).map(({candidate:b,index:P})=>`hub:${P}:${b.key}`);return{id:`skill:${x.item.id}`,itemIds:[...x.itemIds],relatedHubIds:_}}),m=zo({parentId:u,title:Ol(pm(f,a.key)),leaves:d});o.push(...m.hubs),i.push(...m.leaves)}return Fr.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 So(e){let t=document.querySelector(`#${e}`);if(!(t instanceof SVGSVGElement))throw Error("Expected an SVG canvas");return t}function te(e){let t=Z(e);if(!(t instanceof HTMLInputElement))throw Error("Expected an input control");return t}function ht(e){let t=Z(e);if(!(t instanceof HTMLSelectElement))throw Error("Expected a selection control");return t}function Ae(e){let t=Z(e);if(!(t instanceof HTMLTextAreaElement))throw Error("Expected a text editor");return t}function gt(e){let t=Z(e);if(!(t instanceof HTMLDialogElement))throw Error("Expected an editor dialog");return t}function w(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 Ce(e){let t=Z("notice");t.textContent=e.message,t.classList.toggle("success",e.success===!0),t.hidden=e.message.length===0}function Lt(e){Ce({message:e instanceof Error?e.message:"The action failed."})}var v={view:null,input:{scope:"global",choices:{},edits:{},custom:[]},activeId:"",search:"",dirty:!1};function re(e){let t=v.view?.locked[e.id];if(t!==void 0)return t;let r=v.input.choices[e.id];if(r!==void 0)return r;if(e.id.startsWith("custom:")&&v.input.custom.some((n)=>e.id===`custom:${n.name}`))return!0;return v.view?.inherited[e.id]===!0}function Io(e){if(v.view?.locked[e.id]!==void 0)return;let t=!re(e);if(v.input.choices[e.id]=t,t&&e.axis){for(let r of v.view?.items??[])if(r.axis===e.axis&&r.id!==e.id)v.input.choices[r.id]=!1,delete v.input.edits[r.id]}if(!t)delete v.input.edits[e.id];v.dirty=!0}function Po(e){Z("custom-status").textContent="",te("custom-name").value=e?`my-${e.name}`.slice(0,48):"",te("custom-description").value=e?`Use alongside ${e.name} for my working preferences.`:"",Ae("custom-body").value=e?`# Personal guidance for ${e.title}
|
|
58
|
-
|
|
59
|
-
`:"",gt("custom-dialog").showModal()}function Cl(){let e=mt.parse({name:te("custom-name").value,description:te("custom-description").value,body:Ae("custom-body").value}),t=`custom:${e.name}`;if(v.view?.items.some((r)=>r.name===e.name))throw Error("Choose a name that does not replace an existing skill.");if(v.input.custom.push(e),v.input.choices[t]=!0,v.dirty=!0,v.activeId=t,v.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"}),v.view)v.view.constellation=Al(v.view.items);gt("custom-dialog").close(),te("custom-name").value="",Ae("custom-body").value=""}var Tl={"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 we(e){return Tl[e.id]?.title??e.title}function Nl(e){let t=Tl[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 fm(e){let t=w({tag:"details",className:"editor"});t.append(w({tag:"summary",text:"Edit instructions"}));let r=w({tag:"textarea"});r.value=v.input.edits[e.item.id]??e.item.text,r.maxLength=48000,r.setAttribute("aria-label",`Instructions for ${e.item.title}`);let n=w({tag:"button",className:"quiet-button",text:"Save to draft"});return n.addEventListener("click",()=>{if(!re(e.item))Io(e.item);v.input.edits[e.item.id]=r.value,v.input.choices[e.item.id]=!0,v.dirty=!0,Ce({message:"Instructions added to your draft. Review the changes before applying.",success:!0}),e.rerender()}),t.append(r,n),t}function Rl(e){let t=Z("detail"),r=v.view?.items.find((a)=>a.id===v.activeId);if(t.replaceChildren(),!r){t.append(w({tag:"h2",text:"Choose a skill."})),t.append(w({tag:"p",className:"detail-description",text:"Inspect a star to see what it teaches your agent."}));return}t.append(w({tag:"p",className:"eyebrow",text:`${(r.category??"CUSTOM").replaceAll("-"," ").toUpperCase()} / ${r.kind.toUpperCase()}`}),w({tag:"h2",text:we(r)}),w({tag:"p",className:"detail-description",text:r.description}));let n=w({tag:"div",className:"behavior"});n.append(w({tag:"p",className:"eyebrow",text:"YOUR AGENT WILL"}),w({tag:"p",text:Nl({item:r,editedText:v.input.edits[r.id]})})),t.append(n);let o=r.owner==="provider",i=v.view?.locked[r.id]!==void 0;if(t.append(w({tag:"p",className:"skill-status",text:i?"◇ Shared requirement":o?"◇ Managed by its provider":"◇ Workflow guidance"})),i){t.append(w({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=w({tag:"button",className:"primary-button",text:o?"Create a local companion":re(r)?"Unequip skill":"Equip skill"});if(s.addEventListener("click",()=>{if(o){e.companion(r);return}Io(r),e.rerender()}),t.append(s),o)t.append(w({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(fm({item:r,rerender:e.rerender}))}var Ml=G({title:I().min(1).max(80),summary:I().min(1).max(600),strengths:ce(I().min(1).max(180)).max(3),tradeoffs:ce(I().min(1).max(180)).max(3),hubLabels:ce(G({id:I().min(1).max(120),title:I().min(1).max(40)})).max(12).default([])}),Dl=G({id:vo(),destination:I(),payload:I(),limits:I(),cached:Ml.nullable()}),Ll=G({description:Ml});function Ur(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 qr(e){let t=w({tag:"dialog"}),r=w({tag:"div",className:"dialog-heading"}),n=w({tag:"button",className:"quiet-button",text:"✕"}),o=w({tag:"details",className:"file-change"}),i=w({tag:"div",className:"dialog-actions"}),s=w({tag:"p",className:"review-message"}),a=w({tag:"button",className:"quiet-button",text:"Keep editing"}),u=w({tag:"button",className:"primary-button",text:e.confirm}),c=new AbortController;t.setAttribute("aria-label",e.title),n.setAttribute("aria-label","Close model request"),s.setAttribute("role","status"),n.addEventListener("click",()=>t.close()),Ur(t),r.append(w({tag:"h2",text:e.title}),n),o.append(w({tag:"summary",text:"Exact payload sent to the model"}),w({tag:"pre",text:e.review.payload})),a.addEventListener("click",()=>t.close()),t.addEventListener("close",()=>{c.abort(),t.remove()});async function l(){if(u.disabled)return;u.disabled=!0,u.textContent="Generating…",a.textContent="Cancel generation",s.textContent="Your model is working. You can cancel and keep your original draft.";try{let p=await le({path:e.path,schema:e.schema,body:{previewId:e.review.id},signal:c.signal});if(!c.signal.aborted)e.accept(p),t.close()}catch(p){if(c.signal.aborted)return;s.className="review-warning",s.textContent=p instanceof Error?p.message:"Generation failed. Your draft is unchanged.",u.textContent="Request ended",a.textContent="Back to editing"}}u.addEventListener("click",()=>{l().catch(()=>{s.textContent="Generation failed. Return to editing to try again."})}),i.append(a,u),t.append(r,w({tag:"p",className:"review-message",text:`Destination: ${e.review.destination}`}),w({tag:"p",className:"review-message",text:e.review.limits}),w({tag:"p",className:"review-message",text:e.explanation}),o,s,i),document.body.append(t),t.showModal()}function xt(e){return function(){return this.matches(e)}}function Vr(e){return function(t){return t.matches(e)}}var Jr="http://www.w3.org/1999/xhtml",Zo={svg:"http://www.w3.org/2000/svg",xhtml:Jr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ke(e){var t=e+="",r=t.indexOf(":");if(r>=0&&(t=e.slice(0,r))!=="xmlns")e=e.slice(r+1);return Zo.hasOwnProperty(t)?{space:Zo[t],local:e}:e}function Eo(e){let t;while(t=e.sourceEvent)e=t;return e}function ze(e,t){if(e=Eo(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 dm(){}function Ue(e){return e==null?dm:function(){return this.querySelector(e)}}function Oo(e){if(typeof e!=="function")e=Ue(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),u,c,l=0;l<s;++l)if((u=i[l])&&(c=e.call(u,u.__data__,l,i))){if("__data__"in u)c.__data__=u.__data__;a[l]=c}return new F(n,this._parents)}function Ao(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function mm(){return[]}function yt(e){return e==null?mm:function(){return this.querySelectorAll(e)}}function hm(e){return function(){return Ao(e.apply(this,arguments))}}function Co(e){if(typeof e==="function")e=hm(e);else e=yt(e);for(var t=this._groups,r=t.length,n=[],o=[],i=0;i<r;++i)for(var s=t[i],a=s.length,u,c=0;c<a;++c)if(u=s[c])n.push(e.call(u,u.__data__,c,s)),o.push(u);return new F(n,o)}var gm=Array.prototype.find;function xm(e){return function(){return gm.call(this.children,e)}}function ym(){return this.firstElementChild}function To(e){return this.select(e==null?ym:xm(typeof e==="function"?e:Vr(e)))}var bm=Array.prototype.filter;function vm(){return Array.from(this.children)}function _m(e){return function(){return bm.call(this.children,e)}}function No(e){return this.selectAll(e==null?vm:_m(typeof e==="function"?e:Vr(e)))}function Ro(e){if(typeof e!=="function")e=xt(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]=[],u,c=0;c<s;++c)if((u=i[c])&&e.call(u,u.__data__,c,i))a.push(u);return new F(n,this._parents)}function Bt(e){return Array(e.length)}function Mo(){return new F(this._enter||this._groups.map(Bt),this._parents)}function jt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}jt.prototype={constructor:jt,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 Do(e){return function(){return e}}function wm(e,t,r,n,o,i){var s=0,a,u=t.length,c=i.length;for(;s<c;++s)if(a=t[s])a.__data__=i[s],n[s]=a;else r[s]=new jt(e,i[s]);for(;s<u;++s)if(a=t[s])o[s]=a}function km(e,t,r,n,o,i,s){var a,u,c=new Map,l=t.length,p=i.length,f=Array(l),d;for(a=0;a<l;++a)if(u=t[a])if(f[a]=d=s.call(u,u.__data__,a,t)+"",c.has(d))o[a]=u;else c.set(d,u);for(a=0;a<p;++a)if(d=s.call(e,i[a],a,i)+"",u=c.get(d))n[a]=u,u.__data__=i[a],c.delete(d);else r[a]=new jt(e,i[a]);for(a=0;a<l;++a)if((u=t[a])&&c.get(f[a])===u)o[a]=u}function zm(e){return e.__data__}function Lo(e,t){if(!arguments.length)return Array.from(this,zm);var r=t?km:wm,n=this._parents,o=this._groups;if(typeof e!=="function")e=Do(e);for(var i=o.length,s=Array(i),a=Array(i),u=Array(i),c=0;c<i;++c){var l=n[c],p=o[c],f=p.length,d=$m(e.call(l,l&&l.__data__,c,n)),m=d.length,x=a[c]=Array(m),_=s[c]=Array(m),b=u[c]=Array(f);r(l,p,x,_,b,d,t);for(var P=0,D=0,B,T;P<m;++P)if(B=x[P]){if(P>=D)D=P+1;while(!(T=_[D])&&++D<m);B._next=T||null}}return s=new F(s,n),s._enter=a,s._exit=u,s}function $m(e){return typeof e==="object"&&"length"in e?e:Array.from(e)}function Bo(){return new F(this._exit||this._groups.map(Bt),this._parents)}function jo(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 Fo(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),u=0;u<s;++u)for(var c=r[u],l=n[u],p=c.length,f=a[u]=Array(p),d,m=0;m<p;++m)if(d=c[m]||l[m])f[m]=d;for(;u<o;++u)a[u]=r[u];return new F(a,this._parents)}function Uo(){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 qo(e){if(!e)e=Sm;function t(p,f){return p&&f?e(p.__data__,f.__data__):!p-!f}for(var r=this._groups,n=r.length,o=Array(n),i=0;i<n;++i){for(var s=r[i],a=s.length,u=o[i]=Array(a),c,l=0;l<a;++l)if(c=s[l])u[l]=c;u.sort(t)}return new F(o,this._parents).order()}function Sm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Vo(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Jo(){return Array.from(this)}function Ho(){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 Ko(){let e=0;for(let t of this)++e;return e}function Go(){return!this.node()}function Xo(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 Im(e){return function(){this.removeAttribute(e)}}function Pm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zm(e,t){return function(){this.setAttribute(e,t)}}function Em(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Om(e,t){return function(){var r=t.apply(this,arguments);if(r==null)this.removeAttribute(e);else this.setAttribute(e,r)}}function Am(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 Yo(e,t){var r=ke(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?Pm:Im:typeof t==="function"?r.local?Am:Om:r.local?Em:Zm)(r,t))}function Ft(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Cm(e){return function(){this.style.removeProperty(e)}}function Tm(e,t,r){return function(){this.style.setProperty(e,t,r)}}function Nm(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 Wo(e,t,r){return arguments.length>1?this.each((t==null?Cm:typeof t==="function"?Nm:Tm)(e,t,r==null?"":r)):qe(this.node(),e)}function qe(e,t){return e.style.getPropertyValue(t)||Ft(e).getComputedStyle(e,null).getPropertyValue(t)}function Rm(e){return function(){delete this[e]}}function Mm(e,t){return function(){this[e]=t}}function Dm(e,t){return function(){var r=t.apply(this,arguments);if(r==null)delete this[e];else this[e]=r}}function Qo(e,t){return arguments.length>1?this.each((t==null?Rm:typeof t==="function"?Dm:Mm)(e,t)):this.node()[e]}function Bl(e){return e.trim().split(/^|\s+/)}function ei(e){return e.classList||new jl(e)}function jl(e){this._node=e,this._names=Bl(e.getAttribute("class")||"")}jl.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 Fl(e,t){var r=ei(e),n=-1,o=t.length;while(++n<o)r.add(t[n])}function Ul(e,t){var r=ei(e),n=-1,o=t.length;while(++n<o)r.remove(t[n])}function Lm(e){return function(){Fl(this,e)}}function Bm(e){return function(){Ul(this,e)}}function jm(e,t){return function(){(t.apply(this,arguments)?Fl:Ul)(this,e)}}function ti(e,t){var r=Bl(e+"");if(arguments.length<2){var n=ei(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"?jm:t?Lm:Bm)(r,t))}function Fm(){this.textContent=""}function Um(e){return function(){this.textContent=e}}function qm(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function ri(e){return arguments.length?this.each(e==null?Fm:(typeof e==="function"?qm:Um)(e)):this.node().textContent}function Vm(){this.innerHTML=""}function Jm(e){return function(){this.innerHTML=e}}function Hm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function ni(e){return arguments.length?this.each(e==null?Vm:(typeof e==="function"?Hm:Jm)(e)):this.node().innerHTML}function Km(){if(this.nextSibling)this.parentNode.appendChild(this)}function oi(){return this.each(Km)}function Gm(){if(this.previousSibling)this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ii(){return this.each(Gm)}function Xm(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===Jr&&t.documentElement.namespaceURI===Jr?t.createElement(e):t.createElementNS(r,e)}}function Ym(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ut(e){var t=ke(e);return(t.local?Ym:Xm)(t)}function si(e){var t=typeof e==="function"?e:Ut(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Wm(){return null}function ai(e,t){var r=typeof e==="function"?e:Ut(e),n=t==null?Wm:typeof t==="function"?t:Ue(t);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}function Qm(){var e=this.parentNode;if(e)e.removeChild(this)}function ci(){return this.each(Qm)}function eh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function th(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ui(e){return this.select(e?th:eh)}function li(e){return arguments.length?this.property("__data__",e):this.node().__data__}function rh(e){return function(t){e.call(this,t,this.__data__)}}function nh(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 oh(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 ih(e,t,r){return function(){var n=this.__on,o,i=rh(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 pi(e,t,r){var n=nh(e+""),o,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var u=0,c=a.length,l;u<c;++u)for(o=0,l=a[u];o<i;++o)if((s=n[o]).type===l.type&&s.name===l.name)return l.value}return}a=t?ih:oh;for(o=0;o<i;++o)this.each(a(n[o],t,r));return this}function ql(e,t,r){var n=Ft(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 sh(e,t){return function(){return ql(this,e,t)}}function ah(e,t){return function(){return ql(this,e,t.apply(this,arguments))}}function fi(e,t){return this.each((typeof t==="function"?ah:sh)(e,t))}function*di(){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 mi=[null];function F(e,t){this._groups=e,this._parents=t}function Vl(){return new F([[document.documentElement]],mi)}function ch(){return this}F.prototype=Vl.prototype={constructor:F,select:Oo,selectAll:Co,selectChild:To,selectChildren:No,filter:Ro,data:Lo,enter:Mo,exit:Bo,join:jo,merge:Fo,selection:ch,order:Uo,sort:qo,call:Vo,nodes:Jo,node:Ho,size:Ko,empty:Go,each:Xo,attr:Yo,style:Wo,property:Qo,classed:ti,text:ri,html:ni,raise:oi,lower:ii,append:si,insert:ai,remove:ci,clone:ui,datum:li,on:pi,dispatch:fi,[Symbol.iterator]:di};var Te=Vl;function X(e){return typeof e==="string"?new F([[document.querySelector(e)]],[document.documentElement]):new F([[e]],mi)}var uh={value:()=>{}};function Hl(){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 Hr(r)}function Hr(e){this._=e}function lh(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}})}Hr.prototype=Hl.prototype={constructor:Hr,on:function(e,t){var r=this._,n=lh(e+"",r),o,i=-1,s=n.length;if(arguments.length<2){while(++i<s)if((o=(e=n[i]).type)&&(o=ph(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]=Jl(r[o],e.name,t);else if(t==null)for(o in r)r[o]=Jl(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 Hr(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 ph(e,t){for(var r=0,n=e.length,o;r<n;++r)if((o=e[r]).name===t)return o.value}function Jl(e,t,r){for(var n=0,o=e.length;n<o;++n)if(e[n].name===t){e[n]=uh,e=e.slice(0,n).concat(e.slice(n+1));break}if(r!=null)e.push({name:t,value:r});return e}var qt=Hl;var Kr={capture:!0,passive:!1};function Vt(e){e.preventDefault(),e.stopImmediatePropagation()}function Gr(e){var t=e.document.documentElement,r=X(e).on("dragstart.drag",Vt,Kr);if("onselectstart"in t)r.on("selectstart.drag",Vt,Kr);else t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none"}function hi(e,t){var r=e.document.documentElement,n=X(e).on("dragstart.drag",null);if(t)n.on("click.drag",Vt,Kr),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 ue(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}var xi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,gi=new RegExp(xi.source,"g");function fh(e){return function(){return e}}function dh(e){return function(t){return e(t)+""}}function Xr(e,t){var r=xi.lastIndex=gi.lastIndex=0,n,o,i,s=-1,a=[],u=[];e=e+"",t=t+"";while((n=xi.exec(e))&&(o=gi.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,u.push({i:s,x:ue(n,o)});r=gi.lastIndex}if(r<t.length)if(i=t.slice(r),a[s])a[s]+=i;else a[++s]=i;return a.length<2?u[0]?dh(u[0].x):fh(t):(t=u.length,function(c){for(var l=0,p;l<t;++l)a[(p=u[l]).i]=p.x(c);return a.join("")})}var Kl=180/Math.PI,Yr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Wr(e,t,r,n,o,i){var s,a,u;if(s=Math.sqrt(e*e+t*t))e/=s,t/=s;if(u=e*r+t*n)r-=e*u,n-=t*u;if(a=Math.sqrt(r*r+n*n))r/=a,n/=a,u/=a;if(e*n<t*r)e=-e,t=-t,u=-u,s=-s;return{translateX:o,translateY:i,rotate:Math.atan2(t,e)*Kl,skewX:Math.atan(u)*Kl,scaleX:s,scaleY:a}}var Qr;function Gl(e){let t=new(typeof DOMMatrix==="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Yr:Wr(t.a,t.b,t.c,t.d,t.e,t.f)}function Xl(e){if(e==null)return Yr;if(!Qr)Qr=document.createElementNS("http://www.w3.org/2000/svg","g");if(Qr.setAttribute("transform",e),!(e=Qr.transform.baseVal.consolidate()))return Yr;return e=e.matrix,Wr(e.a,e.b,e.c,e.d,e.e,e.f)}function Yl(e,t,r,n){function o(c){return c.length?c.pop()+" ":""}function i(c,l,p,f,d,m){if(c!==p||l!==f){var x=d.push("translate(",null,t,null,r);m.push({i:x-4,x:ue(c,p)},{i:x-2,x:ue(l,f)})}else if(p||f)d.push("translate("+p+t+f+r)}function s(c,l,p,f){if(c!==l){if(c-l>180)l+=360;else if(l-c>180)c+=360;f.push({i:p.push(o(p)+"rotate(",null,n)-2,x:ue(c,l)})}else if(l)p.push(o(p)+"rotate("+l+n)}function a(c,l,p,f){if(c!==l)f.push({i:p.push(o(p)+"skewX(",null,n)-2,x:ue(c,l)});else if(l)p.push(o(p)+"skewX("+l+n)}function u(c,l,p,f,d,m){if(c!==p||l!==f){var x=d.push(o(d)+"scale(",null,",",null,")");m.push({i:x-4,x:ue(c,p)},{i:x-2,x:ue(l,f)})}else if(p!==1||f!==1)d.push(o(d)+"scale("+p+","+f+")")}return function(c,l){var p=[],f=[];return c=e(c),l=e(l),i(c.translateX,c.translateY,l.translateX,l.translateY,p,f),s(c.rotate,l.rotate,p,f),a(c.skewX,l.skewX,p,f),u(c.scaleX,c.scaleY,l.scaleX,l.scaleY,p,f),c=l=null,function(d){var m=-1,x=f.length,_;while(++m<x)p[(_=f[m]).i]=_.x(d);return p.join("")}}}var yi=Yl(Gl,"px, ","px)","deg)"),bi=Yl(Xl,", ",")",")");var mh=0.000000000001;function Wl(e){return((e=Math.exp(e))+1/e)/2}function hh(e){return((e=Math.exp(e))-1/e)/2}function gh(e){return((e=Math.exp(2*e))-1)/(e+1)}var vi=function e(t,r,n){function o(i,s){var a=i[0],u=i[1],c=i[2],l=s[0],p=s[1],f=s[2],d=l-a,m=p-u,x=d*d+m*m,_,b;if(x<mh)b=Math.log(f/c)/t,_=function(J){return[a+J*d,u+J*m,c*Math.exp(t*J*b)]};else{var P=Math.sqrt(x),D=(f*f-c*c+n*x)/(2*c*r*P),B=(f*f-c*c-n*x)/(2*f*r*P),T=Math.log(Math.sqrt(D*D+1)-D),O=Math.log(Math.sqrt(B*B+1)-B);b=(O-T)/t,_=function(J){var De=J*b,Ke=Wl(T),Le=c/(r*P)*(Ke*gh(t*De+T)-hh(T));return[a+Le*d,u+Le*m,c*Ke/Wl(t*De+T)]}}return _.duration=b*1000*t/Math.SQRT2,_}return o.rho=function(i){var s=Math.max(0.001,+i),a=s*s,u=a*a;return e(s,a,u)},o}(Math.SQRT2,2,4);function Jt(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function _i(e,t){var r=Object.create(e.prototype);for(var n in t)r[n]=t[n];return r}function Gt(){}var Ht=0.7,rn=1/Ht,bt="\\s*([+-]?\\d+)\\s*",Kt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",$e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xh=/^#([0-9a-f]{3,8})$/,yh=new RegExp(`^rgb\\(${bt},${bt},${bt}\\)$`),bh=new RegExp(`^rgb\\(${$e},${$e},${$e}\\)$`),vh=new RegExp(`^rgba\\(${bt},${bt},${bt},${Kt}\\)$`),_h=new RegExp(`^rgba\\(${$e},${$e},${$e},${Kt}\\)$`),wh=new RegExp(`^hsl\\(${Kt},${$e},${$e}\\)$`),kh=new RegExp(`^hsla\\(${Kt},${$e},${$e},${Kt}\\)$`),Ql={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};Jt(Gt,Ve,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ep,formatHex:ep,formatHex8:zh,formatHsl:$h,formatRgb:tp,toString:tp});function ep(){return this.rgb().formatHex()}function zh(){return this.rgb().formatHex8()}function $h(){return ap(this).formatHsl()}function tp(){return this.rgb().formatRgb()}function Ve(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=xh.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?rp(t):r===3?new ne(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?en(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?en(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=yh.exec(e))?new ne(t[1],t[2],t[3],1):(t=bh.exec(e))?new ne(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=vh.exec(e))?en(t[1],t[2],t[3],t[4]):(t=_h.exec(e))?en(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=wh.exec(e))?ip(t[1],t[2]/100,t[3]/100,1):(t=kh.exec(e))?ip(t[1],t[2]/100,t[3]/100,t[4]):Ql.hasOwnProperty(e)?rp(Ql[e]):e==="transparent"?new ne(NaN,NaN,NaN,0):null}function rp(e){return new ne(e>>16&255,e>>8&255,e&255,1)}function en(e,t,r,n){if(n<=0)e=t=r=NaN;return new ne(e,t,r,n)}function Sh(e){if(!(e instanceof Gt))e=Ve(e);if(!e)return new ne;return e=e.rgb(),new ne(e.r,e.g,e.b,e.opacity)}function vt(e,t,r,n){return arguments.length===1?Sh(e):new ne(e,t,r,n==null?1:n)}function ne(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}Jt(ne,vt,_i(Gt,{brighter(e){return e=e==null?rn:Math.pow(rn,e),new ne(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new ne(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ne(tt(this.r),tt(this.g),tt(this.b),nn(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:np,formatHex:np,formatHex8:Ih,formatRgb:op,toString:op}));function np(){return`#${et(this.r)}${et(this.g)}${et(this.b)}`}function Ih(){return`#${et(this.r)}${et(this.g)}${et(this.b)}${et((isNaN(this.opacity)?1:this.opacity)*255)}`}function op(){let e=nn(this.opacity);return`${e===1?"rgb(":"rgba("}${tt(this.r)}, ${tt(this.g)}, ${tt(this.b)}${e===1?")":`, ${e})`}`}function nn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function tt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function et(e){return e=tt(e),(e<16?"0":"")+e.toString(16)}function ip(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 he(e,t,r,n)}function ap(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(!(e instanceof Gt))e=Ve(e);if(!e)return new he;if(e instanceof he)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,u=(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/=u<0.5?i+o:2-i-o,s*=60}else a=u>0&&u<1?0:s;return new he(s,a,u,e.opacity)}function cp(e,t,r,n){return arguments.length===1?ap(e):new he(e,t,r,n==null?1:n)}function he(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}Jt(he,cp,_i(Gt,{brighter(e){return e=e==null?rn:Math.pow(rn,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ht:Math.pow(Ht,e),new he(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 ne(wi(e>=240?e-240:e+120,o,n),wi(e,o,n),wi(e<120?e+240:e-120,o,n),this.opacity)},clamp(){return new he(sp(this.h),tn(this.s),tn(this.l),nn(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=nn(this.opacity);return`${e===1?"hsl(":"hsla("}${sp(this.h)}, ${tn(this.s)*100}%, ${tn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function sp(e){return e=(e||0)%360,e<0?e+360:e}function tn(e){return Math.max(0,Math.min(1,e||0))}function wi(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 ki(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 zi(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 ki((r-n/t)*t,s,o,i,a)}}function $i(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 ki((r-n/t)*t,o,i,s,a)}}var Si=(e)=>()=>e;function Ph(e,t){return function(r){return e+r*t}}function Zh(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 up(e){return(e=+e)===1?on:function(t,r){return r-t?Zh(t,r,e):Si(isNaN(t)?r:t)}}function on(e,t){var r=t-e;return r?Ph(e,r):Si(isNaN(e)?t:e)}var sn=function e(t){var r=up(t);function n(o,i){var s=r((o=vt(o)).r,(i=vt(i)).r),a=r(o.g,i.g),u=r(o.b,i.b),c=on(o.opacity,i.opacity);return function(l){return o.r=s(l),o.g=a(l),o.b=u(l),o.opacity=c(l),o+""}}return n.gamma=e,n}(1);function lp(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=vt(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(u){return a.r=n(u),a.g=o(u),a.b=i(u),a+""}}}var Eh=lp(zi),Oh=lp($i);var _t=0,Yt=0,Xt=0,fp=1000,an,Wt,cn=0,rt=0,un=0,Qt=typeof performance==="object"&&performance.now?performance:Date,dp=typeof window==="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function tr(){return rt||(dp(Ah),rt=Qt.now()+un)}function Ah(){rt=0}function er(){this._call=this._time=this._next=null}er.prototype=ln.prototype={constructor:er,restart:function(e,t,r){if(typeof e!=="function")throw TypeError("callback is not a function");if(r=(r==null?tr():+r)+(t==null?0:+t),!this._next&&Wt!==this){if(Wt)Wt._next=this;else an=this;Wt=this}this._call=e,this._time=r,Ii()},stop:function(){if(this._call)this._call=null,this._time=1/0,Ii()}};function ln(e,t,r){var n=new er;return n.restart(e,t,r),n}function mp(){tr(),++_t;var e=an,t;while(e){if((t=rt-e._time)>=0)e._call.call(void 0,t);e=e._next}--_t}function pp(){rt=(cn=Qt.now())+un,_t=Yt=0;try{mp()}finally{_t=0,Th(),rt=0}}function Ch(){var e=Qt.now(),t=e-cn;if(t>fp)un-=t,cn=e}function Th(){var e,t=an,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:an=r;Wt=e,Ii(n)}function Ii(e){if(_t)return;if(Yt)Yt=clearTimeout(Yt);var t=e-rt;if(t>24){if(e<1/0)Yt=setTimeout(pp,e-Qt.now()-un);if(Xt)Xt=clearInterval(Xt)}else{if(!Xt)cn=Qt.now(),Xt=setInterval(Ch,fp);_t=1,dp(pp)}}function rr(e,t,r){var n=new er;return t=t==null?0:+t,n.restart((o)=>{n.stop(),e(o+t)},t,r),n}var Nh=qt("start","end","cancel","interrupt"),Rh=[],xp=0,hp=1,fn=2,pn=3,gp=4,dn=5,nr=6;function Ne(e,t,r,n,o,i){var s=e.__transition;if(!s)e.__transition={};else if(r in s)return;Mh(e,r,{name:t,index:n,group:o,on:Nh,tween:Rh,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:xp})}function or(e,t){var r=H(e,t);if(r.state>xp)throw Error("too late; already scheduled");return r}function Y(e,t){var r=H(e,t);if(r.state>pn)throw Error("too late; already running");return r}function H(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw Error("transition not found");return r}function Mh(e,t,r){var n=e.__transition,o;n[t]=r,r.timer=ln(i,0,r.time);function i(c){if(r.state=hp,r.timer.restart(s,r.delay,r.time),r.delay<=c)s(c-r.delay)}function s(c){var l,p,f,d;if(r.state!==hp)return u();for(l in n){if(d=n[l],d.name!==r.name)continue;if(d.state===pn)return rr(s);if(d.state===gp)d.state=nr,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete n[l];else if(+l<t)d.state=nr,d.timer.stop(),d.on.call("cancel",e,e.__data__,d.index,d.group),delete n[l]}if(rr(function(){if(r.state===pn)r.state=gp,r.timer.restart(a,r.delay,r.time),a(c)}),r.state=fn,r.on.call("start",e,e.__data__,r.index,r.group),r.state!==fn)return;r.state=pn,o=Array(f=r.tween.length);for(l=0,p=-1;l<f;++l)if(d=r.tween[l].value.call(e,e.__data__,r.index,r.group))o[++p]=d;o.length=p+1}function a(c){var l=c<r.duration?r.ease.call(null,c/r.duration):(r.timer.restart(u),r.state=dn,1),p=-1,f=o.length;while(++p<f)o[p].call(e,l);if(r.state===dn)r.on.call("end",e,e.__data__,r.index,r.group),u()}function u(){r.state=nr,r.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Je(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>fn&&n.state<dn,n.state=nr,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 Pi(e){return this.each(function(){Je(this,e)})}function Dh(e,t){var r,n;return function(){var o=Y(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 Lh(e,t,r){var n,o;if(typeof r!=="function")throw Error();return function(){var i=Y(this,e),s=i.tween;if(s!==n){o=(n=s).slice();for(var a={name:t,value:r},u=0,c=o.length;u<c;++u)if(o[u].name===t){o[u]=a;break}if(u===c)o.push(a)}i.tween=o}}function Zi(e,t){var r=this._id;if(e+="",arguments.length<2){var n=H(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?Dh:Lh)(r,e,t))}function wt(e,t,r){var n=e._id;return e.each(function(){var o=Y(this,n);(o.value||(o.value={}))[t]=r.apply(this,arguments)}),function(o){return H(o,n).value[t]}}function ir(e,t){var r;return(typeof t==="number"?ue:t instanceof Ve?sn:(r=Ve(t))?(t=r,sn):Xr)(e,t)}function Bh(e){return function(){this.removeAttribute(e)}}function jh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Fh(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 Uh(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 qh(e,t,r){var n,o,i;return function(){var s,a=r(this),u;if(a==null)return void this.removeAttribute(e);return s=this.getAttribute(e),u=a+"",s===u?null:s===n&&u===o?i:(o=u,i=t(n=s,a))}}function Vh(e,t,r){var n,o,i;return function(){var s,a=r(this),u;if(a==null)return void this.removeAttributeNS(e.space,e.local);return s=this.getAttributeNS(e.space,e.local),u=a+"",s===u?null:s===n&&u===o?i:(o=u,i=t(n=s,a))}}function Ei(e,t){var r=ke(e),n=r==="transform"?bi:ir;return this.attrTween(e,typeof t==="function"?(r.local?Vh:qh)(r,n,wt(this,"attr."+e,t)):t==null?(r.local?jh:Bh)(r):(r.local?Uh:Fh)(r,n,t))}function Jh(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function Hh(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function Kh(e,t){var r,n;function o(){var i=t.apply(this,arguments);if(i!==n)r=(n=i)&&Hh(e,i);return r}return o._value=t,o}function Gh(e,t){var r,n;function o(){var i=t.apply(this,arguments);if(i!==n)r=(n=i)&&Jh(e,i);return r}return o._value=t,o}function Oi(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=ke(e);return this.tween(r,(n.local?Kh:Gh)(n,t))}function Xh(e,t){return function(){or(this,e).delay=+t.apply(this,arguments)}}function Yh(e,t){return t=+t,function(){or(this,e).delay=t}}function Ai(e){var t=this._id;return arguments.length?this.each((typeof e==="function"?Xh:Yh)(t,e)):H(this.node(),t).delay}function Wh(e,t){return function(){Y(this,e).duration=+t.apply(this,arguments)}}function Qh(e,t){return t=+t,function(){Y(this,e).duration=t}}function Ci(e){var t=this._id;return arguments.length?this.each((typeof e==="function"?Wh:Qh)(t,e)):H(this.node(),t).duration}function eg(e,t){if(typeof t!=="function")throw Error();return function(){Y(this,e).ease=t}}function Ti(e){var t=this._id;return arguments.length?this.each(eg(t,e)):H(this.node(),t).ease}function tg(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!=="function")throw Error();Y(this,e).ease=r}}function Ni(e){if(typeof e!=="function")throw Error();return this.each(tg(this._id,e))}function Ri(e){if(typeof e!=="function")e=xt(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]=[],u,c=0;c<s;++c)if((u=i[c])&&e.call(u,u.__data__,c,i))a.push(u);return new Q(n,this._parents,this._name,this._id)}function Mi(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 u=t[a],c=r[a],l=u.length,p=s[a]=Array(l),f,d=0;d<l;++d)if(f=u[d]||c[d])p[d]=f;for(;a<n;++a)s[a]=t[a];return new Q(s,this._parents,this._name,this._id)}function rg(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 ng(e,t,r){var n,o,i=rg(t)?or:Y;return function(){var s=i(this,e),a=s.on;if(a!==n)(o=(n=a).copy()).on(t,r);s.on=o}}function Di(e,t){var r=this._id;return arguments.length<2?H(this.node(),r).on.on(e):this.each(ng(r,e,t))}function og(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;if(t)t.removeChild(this)}}function Li(){return this.on("end.remove",og(this._id))}function Bi(e){var t=this._name,r=this._id;if(typeof e!=="function")e=Ue(e);for(var n=this._groups,o=n.length,i=Array(o),s=0;s<o;++s)for(var a=n[s],u=a.length,c=i[s]=Array(u),l,p,f=0;f<u;++f)if((l=a[f])&&(p=e.call(l,l.__data__,f,a))){if("__data__"in l)p.__data__=l.__data__;c[f]=p,Ne(c[f],t,r,f,c,H(l,r))}return new Q(i,this._parents,t,r)}function ji(e){var t=this._name,r=this._id;if(typeof e!=="function")e=yt(e);for(var n=this._groups,o=n.length,i=[],s=[],a=0;a<o;++a)for(var u=n[a],c=u.length,l,p=0;p<c;++p)if(l=u[p]){for(var f=e.call(l,l.__data__,p,u),d,m=H(l,r),x=0,_=f.length;x<_;++x)if(d=f[x])Ne(d,t,r,x,f,m);i.push(f),s.push(l)}return new Q(i,s,t,r)}var ig=Te.prototype.constructor;function Fi(){return new ig(this._groups,this._parents)}function sg(e,t){var r,n,o;return function(){var i=qe(this,e),s=(this.style.removeProperty(e),qe(this,e));return i===s?null:i===r&&s===n?o:o=t(r=i,n=s)}}function yp(e){return function(){this.style.removeProperty(e)}}function ag(e,t,r){var n,o=r+"",i;return function(){var s=qe(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=qe(this,e),a=r(this),u=a+"";if(a==null)u=a=(this.style.removeProperty(e),qe(this,e));return s===u?null:s===n&&u===o?i:(o=u,i=t(n=s,a))}}function ug(e,t){var r,n,o,i="style."+t,s="end."+i,a;return function(){var u=Y(this,e),c=u.on,l=u.value[i]==null?a||(a=yp(t)):void 0;if(c!==r||o!==l)(n=(r=c).copy()).on(s,o=l);u.on=n}}function Ui(e,t,r){var n=(e+="")==="transform"?yi:ir;return t==null?this.styleTween(e,sg(e,n)).on("end.style."+e,yp(e)):typeof t==="function"?this.styleTween(e,cg(e,n,wt(this,"style."+e,t))).each(ug(this._id,e)):this.styleTween(e,ag(e,n,t),r).on("end.style."+e,null)}function lg(e,t,r){return function(n){this.style.setProperty(e,t.call(this,n),r)}}function pg(e,t,r){var n,o;function i(){var s=t.apply(this,arguments);if(s!==o)n=(o=s)&&lg(e,s,r);return n}return i._value=t,i}function qi(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,pg(e,t,r==null?"":r))}function fg(e){return function(){this.textContent=e}}function dg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Vi(e){return this.tween("text",typeof e==="function"?dg(wt(this,"text",e)):fg(e==null?"":e+""))}function mg(e){return function(t){this.textContent=e.call(this,t)}}function hg(e){var t,r;function n(){var o=e.apply(this,arguments);if(o!==r)t=(r=o)&&mg(o);return t}return n._value=e,n}function Ji(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,hg(e))}function Hi(){var e=this._name,t=this._id,r=mn();for(var n=this._groups,o=n.length,i=0;i<o;++i)for(var s=n[i],a=s.length,u,c=0;c<a;++c)if(u=s[c]){var l=H(u,t);Ne(u,e,r,c,s,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new Q(n,this._parents,e,r)}function Ki(){var e,t,r=this,n=r._id,o=r.size();return new Promise(function(i,s){var a={value:s},u={value:function(){if(--o===0)i()}};if(r.each(function(){var c=Y(this,n),l=c.on;if(l!==e)t=(e=l).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(u);c.on=t}),o===0)i()})}var gg=0;function Q(e,t,r,n){this._groups=e,this._parents=t,this._name=r,this._id=n}function bp(e){return Te().transition(e)}function mn(){return++gg}var Re=Te.prototype;Q.prototype=bp.prototype={constructor:Q,select:Bi,selectAll:ji,selectChild:Re.selectChild,selectChildren:Re.selectChildren,filter:Ri,merge:Mi,selection:Fi,transition:Hi,call:Re.call,nodes:Re.nodes,node:Re.node,size:Re.size,empty:Re.empty,each:Re.each,on:Di,attr:Ei,attrTween:Oi,style:Ui,styleTween:qi,text:Vi,textTween:Ji,remove:Li,tween:Zi,delay:Ai,duration:Ci,ease:Ti,easeVarying:Ni,end:Ki,[Symbol.iterator]:Re[Symbol.iterator]};function hn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xg={time:null,delay:0,duration:250,ease:hn};function yg(e,t){var r;while(!(r=e.__transition)||!(r=r[t]))if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return r}function Gi(e){var t,r;if(e instanceof Q)t=e._id,e=e._name;else t=mn(),(r=xg).time=tr(),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,u,c=0;c<a;++c)if(u=s[c])Ne(u,e,t,c,s,r||yg(u,t));return new Q(n,this._parents,e,t)}Te.prototype.interrupt=Pi;Te.prototype.transition=Gi;var sr=(e)=>()=>e;function Xi(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 ge(e,t,r){this.k=e,this.x=t,this.y=r}ge.prototype={constructor:ge,scale:function(e){return e===1?this:new ge(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ge(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 Se=new ge(1,0,0);ar.prototype=ge.prototype;function ar(e){while(!e.__zoom)if(!(e=e.parentNode))return Se;return e.__zoom}function gn(e){e.stopImmediatePropagation()}function nt(e){e.preventDefault(),e.stopImmediatePropagation()}function bg(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 vp(){return this.__zoom||Se}function _g(e){return-e.deltaY*(e.deltaMode===1?0.05:e.deltaMode?1:0.002)*(e.ctrlKey?10:1)}function wg(){return navigator.maxTouchPoints||"ontouchstart"in this}function kg(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 xn(){var e=bg,t=vg,r=kg,n=_g,o=wg,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,u=vi,c=qt("start","zoom","end"),l,p,f,d=500,m=150,x=0,_=10;function b(h){h.property("__zoom",vp).on("wheel.zoom",De,{passive:!1}).on("mousedown.zoom",Ke).on("dblclick.zoom",Le).filter(o).on("touchstart.zoom",fr).on("touchmove.zoom",kn).on("touchend.zoom touchcancel.zoom",zn).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(h,k,y,z){var E=h.selection?h.selection():h;if(E.property("__zoom",vp),h!==E)T(h,k,y,z);else E.interrupt().each(function(){O(this,arguments).event(z).start().zoom(null,typeof k==="function"?k.apply(this,arguments):k).end()})},b.scaleBy=function(h,k,y,z){b.scaleTo(h,function(){var E=this.__zoom.k,A=typeof k==="function"?k.apply(this,arguments):k;return E*A},y,z)},b.scaleTo=function(h,k,y,z){b.transform(h,function(){var E=t.apply(this,arguments),A=this.__zoom,C=y==null?B(E):typeof y==="function"?y.apply(this,arguments):y,R=A.invert(C),U=typeof k==="function"?k.apply(this,arguments):k;return r(D(P(A,U),C,R),E,s)},y,z)},b.translateBy=function(h,k,y,z){b.transform(h,function(){return r(this.__zoom.translate(typeof k==="function"?k.apply(this,arguments):k,typeof y==="function"?y.apply(this,arguments):y),t.apply(this,arguments),s)},null,z)},b.translateTo=function(h,k,y,z,E){b.transform(h,function(){var A=t.apply(this,arguments),C=this.__zoom,R=z==null?B(A):typeof z==="function"?z.apply(this,arguments):z;return r(Se.translate(R[0],R[1]).scale(C.k).translate(typeof k==="function"?-k.apply(this,arguments):-k,typeof y==="function"?-y.apply(this,arguments):-y),A,s)},z,E)};function P(h,k){return k=Math.max(i[0],Math.min(i[1],k)),k===h.k?h:new ge(k,h.x,h.y)}function D(h,k,y){var z=k[0]-y[0]*h.k,E=k[1]-y[1]*h.k;return z===h.x&&E===h.y?h:new ge(h.k,z,E)}function B(h){return[(+h[0][0]+ +h[1][0])/2,(+h[0][1]+ +h[1][1])/2]}function T(h,k,y,z){h.on("start.zoom",function(){O(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(z).end()}).tween("zoom",function(){var E=this,A=arguments,C=O(E,A).event(z),R=t.apply(E,A),U=y==null?B(R):typeof y==="function"?y.apply(E,A):y,xe=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),K=E.__zoom,pe=typeof k==="function"?k.apply(E,A):k,Pe=u(K.invert(U).concat(xe/K.k),pe.invert(U).concat(xe/pe.k));return function(fe){if(fe===1)fe=pe;else{var Ze=Pe(fe),$n=xe/Ze[2];fe=new ge($n,U[0]-Ze[0]*$n,U[1]-Ze[1]*$n)}C.zoom(null,fe)}})}function O(h,k,y){return!y&&h.__zooming||new J(h,k)}function J(h,k){this.that=h,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(h,k),this.taps=0}J.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,k){if(this.mouse&&h!=="mouse")this.mouse[1]=k.invert(this.mouse[0]);if(this.touch0&&h!=="touch")this.touch0[1]=k.invert(this.touch0[0]);if(this.touch1&&h!=="touch")this.touch1[1]=k.invert(this.touch1[0]);return this.that.__zoom=k,this.emit("zoom"),this},end:function(){if(--this.active===0)delete this.that.__zooming,this.emit("end");return this},emit:function(h){var k=X(this.that).datum();c.call(h,this.that,new Xi(h,{sourceEvent:this.sourceEvent,target:b,type:h,transform:this.that.__zoom,dispatch:c}),k)}};function De(h,...k){if(!e.apply(this,arguments))return;var y=O(this,k).event(h),z=this.__zoom,E=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,n.apply(this,arguments)))),A=ze(h);if(y.wheel){if(y.mouse[0][0]!==A[0]||y.mouse[0][1]!==A[1])y.mouse[1]=z.invert(y.mouse[0]=A);clearTimeout(y.wheel)}else if(z.k===E)return;else y.mouse=[A,z.invert(A)],Je(this),y.start();nt(h),y.wheel=setTimeout(C,m),y.zoom("mouse",r(D(P(z,E),y.mouse[0],y.mouse[1]),y.extent,s));function C(){y.wheel=null,y.end()}}function Ke(h,...k){if(f||!e.apply(this,arguments))return;var y=h.currentTarget,z=O(this,k,!0).event(h),E=X(h.view).on("mousemove.zoom",U,!0).on("mouseup.zoom",xe,!0),A=ze(h,y),{clientX:C,clientY:R}=h;Gr(h.view),gn(h),z.mouse=[A,this.__zoom.invert(A)],Je(this),z.start();function U(K){if(nt(K),!z.moved){var pe=K.clientX-C,Pe=K.clientY-R;z.moved=pe*pe+Pe*Pe>x}z.event(K).zoom("mouse",r(D(z.that.__zoom,z.mouse[0]=ze(K,y),z.mouse[1]),z.extent,s))}function xe(K){E.on("mousemove.zoom mouseup.zoom",null),hi(K.view,z.moved),nt(K),z.event(K).end()}}function Le(h,...k){if(!e.apply(this,arguments))return;var y=this.__zoom,z=ze(h.changedTouches?h.changedTouches[0]:h,this),E=y.invert(z),A=y.k*(h.shiftKey?0.5:2),C=r(D(P(y,A),z,E),t.apply(this,k),s);if(nt(h),a>0)X(this).transition().duration(a).call(T,C,z,h);else X(this).call(b.transform,C,z,h)}function fr(h,...k){if(!e.apply(this,arguments))return;var y=h.touches,z=y.length,E=O(this,k,h.changedTouches.length===z).event(h),A,C,R,U;gn(h);for(C=0;C<z;++C)if(R=y[C],U=ze(R,this),U=[U,this.__zoom.invert(U),R.identifier],!E.touch0)E.touch0=U,A=!0,E.taps=1+!!l;else if(!E.touch1&&E.touch0[2]!==U[2])E.touch1=U,E.taps=0;if(l)l=clearTimeout(l);if(A){if(E.taps<2)p=U[0],l=setTimeout(function(){l=null},d);Je(this),E.start()}}function kn(h,...k){if(!this.__zooming)return;var y=O(this,k).event(h),z=h.changedTouches,E=z.length,A,C,R,U;nt(h);for(A=0;A<E;++A)if(C=z[A],R=ze(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 xe=y.touch0[0],K=y.touch0[1],pe=y.touch1[0],Pe=y.touch1[1],fe=(fe=pe[0]-xe[0])*fe+(fe=pe[1]-xe[1])*fe,Ze=(Ze=Pe[0]-K[0])*Ze+(Ze=Pe[1]-K[1])*Ze;C=P(C,Math.sqrt(fe/Ze)),R=[(xe[0]+pe[0])/2,(xe[1]+pe[1])/2],U=[(K[0]+Pe[0])/2,(K[1]+Pe[1])/2]}else if(y.touch0)R=y.touch0[0],U=y.touch0[1];else return;y.zoom("touch",r(D(C,R,U),y.extent,s))}function zn(h,...k){if(!this.__zooming)return;var y=O(this,k).event(h),z=h.changedTouches,E=z.length,A,C;if(gn(h),f)clearTimeout(f);f=setTimeout(function(){f=null},d);for(A=0;A<E;++A)if(C=z[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=ze(C,this),Math.hypot(p[0]-C[0],p[1]-C[1])<_){var R=X(this).on("dblclick.zoom");if(R)R.apply(this,arguments)}}}return b.wheelDelta=function(h){return arguments.length?(n=typeof h==="function"?h:sr(+h),b):n},b.filter=function(h){return arguments.length?(e=typeof h==="function"?h:sr(!!h),b):e},b.touchable=function(h){return arguments.length?(o=typeof h==="function"?h:sr(!!h),b):o},b.extent=function(h){return arguments.length?(t=typeof h==="function"?h:sr([[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]]),b):t},b.scaleExtent=function(h){return arguments.length?(i[0]=+h[0],i[1]=+h[1],b):[i[0],i[1]]},b.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],b):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},b.constrain=function(h){return arguments.length?(r=h,b):r},b.duration=function(h){return arguments.length?(a=+h,b):a},b.interpolate=function(h){return arguments.length?(u=h,b):u},b.on=function(){var h=c.on.apply(c,arguments);return h===c?b:h},b.clickDistance=function(h){return arguments.length?(x=(h=+h)*h,b):Math.sqrt(x)},b.tapDistance=function(h){return arguments.length?(_=+h,b):_},b}function zg(e){let t=e.map((r)=>v.view?.items.find((n)=>n.id===r)).filter((r)=>r!==void 0);return t.find(re)??t[0]}function $g(e){return`${we(e)} ${e.description}`.toLowerCase().includes(v.search.toLowerCase())}function _p(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=w({tag:"section",className:"skill-list-group"});o.append(w({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=zg(i.itemIds);if(!s||!$g(s))continue;let a=w({tag:"button",className:"skill-list-item",text:we(s)});a.classList.toggle("equipped",re(s)),a.addEventListener("click",()=>e.inspect(s.id)),o.append(a)}if(o.childElementCount>1)t.append(o)}}function Sg(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 Yi(){return this.eachAfter(Sg)}function Wi(e,t){let r=-1;for(let n of this)e.call(t,n,++r,this);return this}function Qi(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 es(e,t){var r=this,n=[r],o=[],i,s,a,u=-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,++u,this);return this}function ts(e,t){let r=-1;for(let n of this)if(e.call(t,n,++r,this))return n}function rs(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 ns(e){return this.eachBefore(function(t){if(t.children)t.children.sort(e)})}function os(e){var t=this,r=Ig(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 Ig(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 is(){var e=this,t=[e];while(e=e.parent)t.push(e);return t}function ss(){return Array.from(this)}function as(){var e=[];return this.eachBefore(function(t){if(!t.children)e.push(t)}),e}function cs(){var e=this,t=[];return e.each(function(r){if(r!==e)t.push({source:r.parent,target:r})}),t}function*us(){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 kt(e,t){if(e instanceof Map){if(e=[void 0,e],t===void 0)t=Eg}else if(t===void 0)t=Zg;var r=new ot(e),n,o=[r],i,s,a,u;while(n=o.pop())if((s=t(n.data))&&(u=(s=Array.from(s)).length)){n.children=s;for(a=u-1;a>=0;--a)o.push(i=s[a]=new ot(s[a])),i.parent=n,i.depth=n.depth+1}return r.eachBefore(Ag)}function Pg(){return kt(this).eachBefore(Og)}function Zg(e){return e.children}function Eg(e){return Array.isArray(e)?e[1]:null}function Og(e){if(e.data.value!==void 0)e.value=e.data.value;e.data=e.data.data}function Ag(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function ot(e){this.data=e,this.depth=this.height=0,this.parent=null}ot.prototype=kt.prototype={constructor:ot,count:Yi,each:Wi,eachAfter:es,eachBefore:Qi,find:ts,sum:rs,sort:ns,path:os,ancestors:is,descendants:ss,leaves:as,links:cs,copy:Pg,[Symbol.iterator]:us};function Cg(e,t){return e.parent===t.parent?1:2}function ls(e){var t=e.children;return t?t[0]:e.t}function ps(e){var t=e.children;return t?t[t.length-1]:e.t}function Tg(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 Ng(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 Rg(e,t,r){return e.a.parent===t.parent?e.a:r}function yn(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}yn.prototype=Object.create(ot.prototype);function Mg(e){var t=new yn(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 yn(i[s],s)),o.parent=r}return(t.parent=new yn(null,0)).children=[t],t}function bn(){var e=Cg,t=1,r=1,n=null;function o(c){var l=Mg(c);if(l.eachAfter(i),l.parent.m=-l.z,l.eachBefore(s),n)c.eachBefore(u);else{var p=c,f=c,d=c;c.eachBefore(function(P){if(P.x<p.x)p=P;if(P.x>f.x)f=P;if(P.depth>d.depth)d=P});var m=p===f?1:e(p,f)/2,x=m-p.x,_=t/(f.x+m+x),b=r/(d.depth||1);c.eachBefore(function(P){P.x=(P.x+x)*_,P.y=P.depth*b})}return c}function i(c){var l=c.children,p=c.parent.children,f=c.i?p[c.i-1]:null;if(l){Ng(c);var d=(l[0].z+l[l.length-1].z)/2;if(f)c.z=f.z+e(c._,f._),c.m=c.z-d;else c.z=d}else if(f)c.z=f.z+e(c._,f._);c.parent.A=a(c,f,c.parent.A||p[0])}function s(c){c._.x=c.z+c.parent.m,c.m+=c.parent.m}function a(c,l,p){if(l){var f=c,d=c,m=l,x=f.parent.children[0],_=f.m,b=d.m,P=m.m,D=x.m,B;while(m=ps(m),f=ls(f),m&&f){if(x=ls(x),d=ps(d),d.a=c,B=m.z+P-f.z-_+e(m._,f._),B>0)Tg(Rg(m,c,p),c,B),_+=B,b+=B;P+=m.m,_+=f.m,D+=x.m,b+=d.m}if(m&&!ps(d))d.t=m,d.m+=P-b;if(f&&!ls(x))x.t=f,x.m+=_-D,p=c}return p}function u(c){c.x*=t,c.y=c.depth*r}return o.separation=function(c){return arguments.length?(e=c,o):e},o.size=function(c){return arguments.length?(n=!1,t=+c[0],r=+c[1],o):n?null:[t,r]},o.nodeSize=function(c){return arguments.length?(n=!0,t=+c[0],r=+c[1],o):n?[t,r]:null},o}function fs(e){if(e===void 0)throw Error("Constellation layout is incomplete");return e}function Dg(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 wp(e){let t=Dg(e.constellation),r=kt(t,(a)=>a.children.filter((u)=>u.kind!=="skill"));bn().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:fs(a.x)+e.width/2,y:e.height-92-fs(a.y)}));if(e.constellation.leaves.length===0&&r.height===1){let a=n.filter((p)=>p.kind==="hub"),u=Math.min(4,a.length),c=Math.ceil(a.length/u),l=new Map(a.map((p,f)=>[p.id,f]));n=n.map((p)=>{let f=l.get(p.id);return f===void 0?p:{...p,x:e.width/2+(f%u-(u-1)/2)*210,y:e.height-92-(c-Math.floor(f/u))*160}})}let o=[...n];for(let a of r.descendants()){let u=a.data.children.filter((c)=>c.kind==="skill");for(let[c,l]of u.entries())o.push({...l,parentId:a.data.id,x:fs(a.x)+e.width/2,y:e.height-92-r.height*160-88*(c+1)})}let i=new Map(o.map((a)=>[a.id,a])),s=o.flatMap((a)=>{let u=a.parentId?i.get(a.parentId):void 0;return u?[{id:`${u.id}:${a.id}`,sourceX:u.x,sourceY:u.y,targetX:a.x,targetY:a.y,related:!1}]:[]});for(let a of o.filter((u)=>u.kind==="skill"))for(let u of a.relatedHubIds){let c=i.get(u);if(c)s.push({id:`${a.id}:${c.id}:related`,sourceX:a.x,sourceY:a.y,targetX:c.x,targetY:c.y,related:!0})}return{nodes:o,links:s}}var Lg={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"},Bg={"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 kp(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",Lg[e]),t.append(r),t}function zp(e){return kp(Bg[e.id]??"spark")}function $p(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 kp(n)}function Sp(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 Ip(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 Pp(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 ds(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 jg="http://www.w3.org/2000/svg",zt=()=>{return},He="",cr=null,Me=new Set,Zp="",Ep=new Map,ms=null,Op=new Map;function Ie(e){return document.createElementNS(jg,e)}function hs(e){let t=e.itemIds.map((r)=>Op.get(r)).filter((r)=>r!==void 0);return t.find(re)??t[0]}function vn(e){let t=hs(e);return t?we(t):e.title}function Ap(e){if(!v.search)return!0;let t=hs(e);return`${vn(e)} ${t?.description??""}`.toLowerCase().includes(v.search.toLowerCase())}function Fg(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 Ug(e){let{group:t,node:r}=e,n=hs(r),o=Ie("g"),i=Ie(r.kind==="root"?"circle":"rect"),s=Ie("text"),a=n?re(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",!Ap(r)),o.classList.toggle("focused",r.id===He),o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`${vn(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 Fg(vn(r)).entries()){let f=Ie("tspan");f.setAttribute("x","0"),f.setAttribute("y",String((r.kind==="root"?44:38)+l*14)),f.textContent=p,s.append(f)}let u=Ie("title");if(u.textContent=vn(r),o.append(u),o.append(i,s),r.kind==="root"){let l=document.querySelector(".brand-mark");if(l instanceof HTMLImageElement){let p=Ie("image");p.setAttribute("href",l.src);for(let[f,d]of Object.entries({x:"-16",y:"-16",width:"32",height:"32"}))p.setAttribute(f,d);o.append(p)}}else{let l=Ie("foreignObject"),p=w({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?zp(n):$p(r.title)),l.append(p),o.append(l)}if(r.kind==="hub"){o.setAttribute("aria-expanded",String(Me.has(r.id)));let l=Ie("text");l.setAttribute("class","map-node-count"),l.setAttribute("text-anchor","middle"),l.setAttribute("y","70");let p=Ep.get(r.id)??0;l.textContent=`${Me.has(r.id)?"−":"+"} ${p} ${p===1?"skill":"skills"}`,o.append(l)}let c=()=>{if(n)zt(n.id);else if(r.kind==="hub"){if(Me.has(r.id))Me.delete(r.id);else Me.add(r.id);He=r.id}ur({inspect:zt})};o.addEventListener("click",c),o.addEventListener("keydown",(l)=>{if(l.key==="Enter"||l.key===" ")l.preventDefault(),c()}),t.append(o)}function ur(e){zt=e.inspect;let t=So("constellation-map"),r=v.view;if(!r)return;_p({constellation:r.constellation,inspect:zt});let n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return;Op=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!==Zp;if(i){if(Me.clear(),r.constellation.leaves.length<=40)for(let l of r.constellation.hubs)Me.add(l.id);Zp=o,He=""}if(v.search)Sp({constellation:r.constellation,expandedHubIds:Me,matchingItemIds:new Set(r.items.filter((l)=>`${we(l)} ${l.description}`.toLowerCase().includes(v.search.toLowerCase())).map((l)=>l.id))});Ep=Pp(r.constellation);let s=wp({constellation:Ip({constellation:r.constellation,expandedHubIds:Me}),width:n.width,height:n.height});ms=s,t.setAttribute("viewBox",`0 0 ${n.width} ${n.height}`),t.replaceChildren();let a=Ie("g");a.setAttribute("class","constellation-viewport"),t.append(a);for(let l of s.links){let p=Ie("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)Ug({group:a,node:l});let u=xn().scaleExtent([0.1,2.5]).on("zoom",(l)=>{a.setAttribute("transform",l.transform.toString())});if(X(t).call(u),a.setAttribute("transform",ar(t).toString()),cr=u,i){let l=ds({nodes:s.nodes,width:n.width,height:n.height});X(t).call(u.transform,Se.translate(l.x,l.y).scale(Math.max(0.65,l.scale)))}let c=v.search?s.nodes.find((l)=>l.kind==="skill"&&Ap(l)):He?s.nodes.find((l)=>l.id===He):void 0;if(c&&(He||v.search)){let l=Se.translate(n.width/2,n.height/2).scale(1.25).translate(-c.x,-c.y);X(t).call(u.transform,l)}}function Cp(){let e=So("constellation-map");new ResizeObserver(()=>ur({inspect:zt})).observe(e);let r=()=>{if(He="",cr)X(e).call(cr.transform,Se)};Z("fit-constellation").addEventListener("click",()=>{if(!cr||!ms)return;He="";let o=e.getBoundingClientRect(),i=ds({nodes:ms.nodes,width:o.width,height:o.height});X(e).call(cr.transform,Se.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 Tp(){ur({inspect:zt})}var Np=null,$t=null;function gs(){let e=Z("model-description");if(e.replaceChildren(),!$t||Np!==JSON.stringify(v.input))return;e.append(w({tag:"h3",text:$t.title}),w({tag:"p",text:$t.summary}));for(let t of $t.strengths)e.append(w({tag:"p",text:`Strength: ${t}`}));for(let t of $t.tradeoffs)e.append(w({tag:"p",text:`Tradeoff: ${t}`}))}async function Rp(){let e=JSON.stringify(v.input),t=await le({path:"/api/description/preview",schema:Dl,body:v.input});qr({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:Ll,accept:(r)=>{$t=r.description,Np=e;for(let n of r.description.hubLabels){let o=v.view?.constellation.hubs.find((i)=>i.id===n.id);if(o)o.title=n.title}Tp(),gs()}})}function Mp(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 Dp(){let e=v.view?.items.filter((o)=>o.owner!=="provider"&&re(o))??[],t=v.view?Mp({constellation:v.view.constellation,selectedItemIds:new Set(e.map((o)=>o.id))}):null;Z("equipped-count").textContent=`${e.length} ${e.length===1?"skill":"skills"} equipped${v.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)=>we(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(w({tag:"span",className:"trait",text:`${o.title} · ${o.count}`}));let n=Z("requirements");if(n.replaceChildren(),n.hidden=!v.view?.requirements.length,v.view?.requirements.length){n.append(w({tag:"h3",text:"◇ Repository requirements"}));for(let o of v.view.requirements)n.append(w({tag:"p",text:o}))}}var _n=null;async function Lp(){if(v.view===null)throw Error("Wait for your skills to load before reviewing the build.");let e=await le({path:"/api/preview",schema:El,body:v.input});_n=e;let t=Z("review-content");t.replaceChildren(),t.append(w({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(w({tag:"p",className:"review-warning",text:r}));for(let r of e.changes){let n=w({tag:"details",className:"file-change"});if(n.append(w({tag:"summary",text:r.path})),r.internal)n.append(w({tag:"p",text:"Local configuration or supporting resource. Its previous version is retained for undo."}));else n.append(w({tag:"h4",text:"Before"}),w({tag:"pre",text:r.before??"New file"}),w({tag:"h4",text:"After"}),w({tag:"pre",text:r.after??"Remove managed file"}));t.append(n)}gt("review-dialog").showModal()}async function Bp(){if(_n===null)throw Error("Review your build before applying it.");await le({path:"/api/apply",schema:wo,body:{previewId:_n.id}}),_n=null,gt("review-dialog").close(),Ce({message:"Build equipped. Start a fresh agent session to use your updated skills.",success:!0})}async function jp(){let e=v.view?.revisionId;if(!e||!window.confirm("Restore the files from before the last apply? Later edits will be preserved if they conflict."))return;await le({path:"/api/undo",schema:wo,body:{revisionId:e}}),Ce({message:"Restored the previous build.",success:!0})}function Fp(){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"),u=document.createElementNS("http://www.w3.org/2000/svg","circle"),c=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}`),u.setAttribute("cx",String(c)),u.setAttribute("cy",String(l)),u.setAttribute("r",s%9===0?"1.7":"1"),a.append(u),s%9===0){let p=document.createElementNS("http://www.w3.org/2000/svg","path");p.setAttribute("d",`M${c-4} ${l}h8M${c} ${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 OI=G({name:I().trim().max(48),description:I().trim().max(300),body:I().trim().min(1).max(24000)}),Up=G({id:vo(),destination:I(),payload:I(),limits:I(),cached:mt.nullable()}),qp=G({skill:mt});function it(e){Z("custom-status").textContent=e}async function qg(){let e=Ae("custom-body").value;if(!e.trim()){it("Describe what your agent should do, then use AI to shape it into a skill."),Ae("custom-body").focus();return}let t=await le({path:"/api/skill/preview",schema:Up,body:{name:te("custom-name").value,description:te("custom-description").value,body:e}});qr({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:qp,accept:({skill:r})=>{te("custom-name").value=r.name,te("custom-description").value=r.description,Ae("custom-body").value=r.body,it("AI draft ready. Edit the instructions before adding the skill to your build."),Ae("custom-body").focus()}})}function Vp(){let e=Z("custom-ai");if(!(e instanceof HTMLButtonElement))return;e.addEventListener("click",()=>{if(e.disabled)return;e.disabled=!0,it("Preparing your model request…"),qg().catch((t)=>{it(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…")it("")})})}var xs=!1;async function wn(e){if(xs)return;xs=!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;xs=!1}}function St(e){Z(e.id).addEventListener("click",()=>wn(e.action).catch(Lt))}function Jp(){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"))Ur(t)}Jp();function lr(){ur({inspect:(e)=>{v.activeId=e,lr()}}),Rl({rerender:lr,companion:Po}),Dp(),gs(),Z("undo").hidden=v.view?.revisionId===null}async function Vg(e){let t=await le({path:`/api/build?scope=${e}`,schema:Zl});if(v.view=t,v.input=structuredClone(t.input),v.dirty=!1,!t.items.some((n)=>n.id===v.activeId))v.activeId=t.items.find(re)?.id??t.items[0]?.id??"";ht("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)Ce({message:"Your existing profile needs its reviewed skills migration before this build can be applied. You can explore the editor now."});lr()}async function pr(e){let t=Z("constellation-status"),r=Z("retry-build");if(!r.hidden)Ce({message:""});t.hidden=!1,r.hidden=!0,Z("constellation-status-text").textContent="Loading your skills…",Z("constellation").setAttribute("aria-busy","true");try{await Vg(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,ht("scope").value=v.input.scope,n}finally{Z("constellation").setAttribute("aria-busy","false")}}St({id:"retry-build",action:()=>pr(v.input.scope)});St({id:"review",action:Lp});St({id:"describe",action:Rp});St({id:"apply",action:async()=>{await Bp(),await pr(v.input.scope)}});St({id:"undo",action:async()=>{await jp(),await pr(v.input.scope)}});Z("new-skill").addEventListener("click",()=>Po());Z("custom-form").addEventListener("submit",(e)=>{e.preventDefault();try{Cl(),lr()}catch(t){it(t instanceof Error?t.message:"The skill could not be added.")}});te("search").addEventListener("input",()=>{v.search=te("search").value,lr()});ht("scope").addEventListener("change",()=>{if(v.dirty&&!window.confirm("Discard the draft and switch build scope?")){ht("scope").value=v.input.scope;return}let e=dt.parse(ht("scope").value);wn(()=>pr(e)).catch(Lt)});for(let e of document.querySelectorAll(".close-dialog"))e.addEventListener("click",()=>e.closest("dialog")?.close());window.addEventListener("beforeunload",(e)=>{if(v.dirty)e.preventDefault()});var Hp=dt.safeParse(new URLSearchParams(location.search).get("scope")??"global");Fp();Cp();Vp();wn(()=>pr(Hp.success?Hp.data:"global")).catch(Lt);
|