@vpxa/kb 0.1.34 → 0.1.35
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/package.json
CHANGED
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
--kb-radius: var(--border-radius-md, var(--radius));
|
|
43
43
|
--kb-shadow: var(--shadow-sm, var(--shadow));
|
|
44
44
|
--kb-hover-bg: color-mix(in srgb, var(--kb-accent) 10%, transparent);
|
|
45
|
+
/* Chart palette */
|
|
46
|
+
--chart-1:#818cf8; --chart-2:#38bdf8; --chart-3:#34d399; --chart-4:#fbbf24;
|
|
47
|
+
--chart-5:#f87171; --chart-6:#a78bfa; --chart-7:#f472b6; --chart-8:#2dd4bf;
|
|
48
|
+
--chart-9:#fb923c; --chart-10:#22d3ee; --chart-11:#c084fc; --chart-12:#a3e635;
|
|
49
|
+
--chart-others:#a8a29e;
|
|
45
50
|
color-scheme: light dark;
|
|
46
51
|
}
|
|
47
52
|
@media (prefers-color-scheme: dark) {
|
|
@@ -259,6 +264,16 @@
|
|
|
259
264
|
.metric-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
|
|
260
265
|
.metric-label { font-size: 0.8rem; opacity: 0.7; margin-top: 2px; }
|
|
261
266
|
|
|
267
|
+
/* Charts */
|
|
268
|
+
.chart-container { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin: 14px 0; overflow: hidden; }
|
|
269
|
+
.chart-title { font-size: .95em; font-weight: 600; margin-bottom: 14px; }
|
|
270
|
+
.chart-svg { width: 100%; display: block; }
|
|
271
|
+
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
|
|
272
|
+
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: .8em; opacity: 0.7; }
|
|
273
|
+
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
|
|
274
|
+
.chart-axis-label { font-size: .7em; fill: currentColor; opacity: 0.5; font-family: inherit; }
|
|
275
|
+
.chart-grid-line { stroke: var(--border); stroke-dasharray: 3,3; stroke-width: 0.5; }
|
|
276
|
+
|
|
262
277
|
/* Actions bar */
|
|
263
278
|
.actions {
|
|
264
279
|
display: flex;
|
|
@@ -350,9 +365,9 @@
|
|
|
350
365
|
.dm-btn:hover { background: var(--border); }
|
|
351
366
|
.dm-btn.dm-active { background: var(--accent); color: #fff; }
|
|
352
367
|
</style>
|
|
353
|
-
<script type="module" crossorigin>(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),Object.freeze({status:`aborted`});function e(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var t=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},n=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},r={};function i(e){return e&&Object.assign(r,e),r}function a(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function o(e,t){return typeof t==`bigint`?t.toString():t}function s(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function c(e){return e==null}function l(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function u(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var d=Symbol(`evaluating`);function f(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==d)return r===void 0&&(r=d,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function p(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function m(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function h(e){return JSON.stringify(e)}function ee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var te=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var re=s(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ie(e){if(ne(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ne(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ae(e){return ie(e)?{...e}:Array.isArray(e)?[...e]:e}var oe=new Set([`string`,`number`,`symbol`]);function se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function g(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function _(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}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ce(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var le={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ue(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return g(e,m(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return p(this,`shape`,e),e},checks:[]}))}function de(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return g(e,m(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return p(this,`shape`,r),r},checks:[]}))}function fe(e,t){if(!ie(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return g(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return p(this,`shape`,n),n}}))}function pe(e,t){if(!ie(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return g(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return p(this,`shape`,n),n}}))}function me(e,t){return g(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return p(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function he(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return g(t,m(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return p(this,`shape`,i),i},checks:[]}))}function ge(e,t,n){return g(t,m(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return p(this,`shape`,i),i}}))}function _e(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ve(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ye(e){return typeof e==`string`?e:e?.message}function v(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=ye(e.inst?._zod.def?.error?.(e))??ye(t?.error?.(e))??ye(n.customError?.(e))??ye(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function be(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function xe(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Se=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,o,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Ce=e(`$ZodError`,Se),we=e(`$ZodError`,Se,{Parent:Error});function Te(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ee(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var De=e=>(n,r,a,o)=>{let s=a?Object.assign(a,{async:!1}):{async:!1},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new t;if(c.issues.length){let t=new(o?.Err??e)(c.issues.map(e=>v(e,s,i())));throw te(t,o?.callee),t}return c.value},Oe=e=>async(t,n,r,a)=>{let o=r?Object.assign(r,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let t=new(a?.Err??e)(s.issues.map(e=>v(e,o,i())));throw te(t,a?.callee),t}return s.value},ke=e=>(n,r,a)=>{let o=a?{...a,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new t;return s.issues.length?{success:!1,error:new(e??Ce)(s.issues.map(e=>v(e,o,i())))}:{success:!0,data:s.value}},Ae=ke(we),je=e=>async(t,n,r)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>v(e,a,i())))}:{success:!0,data:o.value}},Me=je(we),Ne=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return De(e)(t,n,i)},Pe=e=>(t,n,r)=>De(e)(t,n,r),Fe=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Oe(e)(t,n,i)},Ie=e=>async(t,n,r)=>Oe(e)(t,n,r),Le=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ke(e)(t,n,i)},Re=e=>(t,n,r)=>ke(e)(t,n,r),ze=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return je(e)(t,n,i)},Be=e=>async(t,n,r)=>je(e)(t,n,r),Ve=/^[cC][^\s-]{8,}$/,He=/^[0-9a-z]+$/,Ue=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,We=/^[0-9a-vA-V]{20}$/,Ge=/^[A-Za-z0-9]{27}$/,Ke=/^[a-zA-Z0-9_-]{21}$/,qe=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Je=/^([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})$/,Ye=e=>e?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})$`):/^([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)$/,Xe=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ze=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Qe(){return new RegExp(Ze,`u`)}var $e=/^(?:(?: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])$/,et=/^(([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}|:))$/,tt=/^((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])$/,nt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,rt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,at=/^\+[1-9]\d{6,14}$/,ot=`(?:(?:\\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])))`,st=RegExp(`^${ot}$`);function ct(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function lt(e){return RegExp(`^${ct(e)}$`)}function ut(e){let t=ct({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${ot}T(?:${r})$`)}var dt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ft=/^-?\d+$/,pt=/^-?\d+(?:\.\d+)?$/,mt=/^(?:true|false)$/i,ht=/^null$/i,gt=/^undefined$/i,_t=/^[^A-Z]*$/,vt=/^[^a-z]*$/,y=e(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),yt={number:`number`,bigint:`bigint`,object:`date`},bt=e(`$ZodCheckLessThan`,(e,t)=>{y.init(e,t);let n=yt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xt=e(`$ZodCheckGreaterThan`,(e,t)=>{y.init(e,t);let n=yt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),St=e(`$ZodCheckMultipleOf`,(e,t)=>{y.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):u(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ct=e(`$ZodCheckNumberFormat`,(e,t)=>{y.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=le[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=ft)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),wt=e(`$ZodCheckMaxLength`,(e,t)=>{var n;y.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=be(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Tt=e(`$ZodCheckMinLength`,(e,t)=>{var n;y.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=be(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Et=e(`$ZodCheckLengthEquals`,(e,t)=>{var n;y.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=be(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Dt=e(`$ZodCheckStringFormat`,(e,t)=>{var n,r;y.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ot=e(`$ZodCheckRegex`,(e,t)=>{Dt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),kt=e(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=_t,Dt.init(e,t)}),At=e(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=vt,Dt.init(e,t)}),jt=e(`$ZodCheckIncludes`,(e,t)=>{y.init(e,t);let n=se(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Mt=e(`$ZodCheckStartsWith`,(e,t)=>{y.init(e,t);let n=RegExp(`^${se(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Nt=e(`$ZodCheckEndsWith`,(e,t)=>{y.init(e,t);let n=RegExp(`.*${se(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Pt=e(`$ZodCheckOverwrite`,(e,t)=>{y.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Ft=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
368
|
+
<script type="module" crossorigin>(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),Object.freeze({status:`aborted`});function e(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var t=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},n=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},r={};function i(e){return e&&Object.assign(r,e),r}function a(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function o(e,t){return typeof t==`bigint`?t.toString():t}function s(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function c(e){return e==null}function l(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function u(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var d=Symbol(`evaluating`);function f(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==d)return r===void 0&&(r=d,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function p(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function m(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function h(e){return JSON.stringify(e)}function ee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var te=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function g(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ne=s(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function re(e){if(g(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(g(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ie(e){return re(e)?{...e}:Array.isArray(e)?[...e]:e}var ae=new Set([`string`,`number`,`symbol`]);function oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function se(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function _(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}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function ce(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var le={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ue(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return se(e,m(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return p(this,`shape`,e),e},checks:[]}))}function de(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return se(e,m(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return p(this,`shape`,r),r},checks:[]}))}function fe(e,t){if(!re(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return se(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return p(this,`shape`,n),n}}))}function pe(e,t){if(!re(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return se(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return p(this,`shape`,n),n}}))}function me(e,t){return se(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return p(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function he(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return se(t,m(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return p(this,`shape`,i),i},checks:[]}))}function ge(e,t,n){return se(t,m(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return p(this,`shape`,i),i}}))}function _e(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ve(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ye(e){return typeof e==`string`?e:e?.message}function v(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=ye(e.inst?._zod.def?.error?.(e))??ye(t?.error?.(e))??ye(n.customError?.(e))??ye(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function be(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function xe(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Se=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,o,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Ce=e(`$ZodError`,Se),we=e(`$ZodError`,Se,{Parent:Error});function Te(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ee(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var De=e=>(n,r,a,o)=>{let s=a?Object.assign(a,{async:!1}):{async:!1},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new t;if(c.issues.length){let t=new(o?.Err??e)(c.issues.map(e=>v(e,s,i())));throw te(t,o?.callee),t}return c.value},Oe=e=>async(t,n,r,a)=>{let o=r?Object.assign(r,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let t=new(a?.Err??e)(s.issues.map(e=>v(e,o,i())));throw te(t,a?.callee),t}return s.value},ke=e=>(n,r,a)=>{let o=a?{...a,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new t;return s.issues.length?{success:!1,error:new(e??Ce)(s.issues.map(e=>v(e,o,i())))}:{success:!0,data:s.value}},Ae=ke(we),je=e=>async(t,n,r)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>v(e,a,i())))}:{success:!0,data:o.value}},Me=je(we),Ne=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return De(e)(t,n,i)},Pe=e=>(t,n,r)=>De(e)(t,n,r),Fe=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Oe(e)(t,n,i)},Ie=e=>async(t,n,r)=>Oe(e)(t,n,r),Le=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ke(e)(t,n,i)},Re=e=>(t,n,r)=>ke(e)(t,n,r),ze=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return je(e)(t,n,i)},Be=e=>async(t,n,r)=>je(e)(t,n,r),Ve=/^[cC][^\s-]{8,}$/,He=/^[0-9a-z]+$/,Ue=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,We=/^[0-9a-vA-V]{20}$/,Ge=/^[A-Za-z0-9]{27}$/,Ke=/^[a-zA-Z0-9_-]{21}$/,qe=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Je=/^([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})$/,Ye=e=>e?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})$`):/^([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)$/,Xe=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ze=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Qe(){return new RegExp(Ze,`u`)}var $e=/^(?:(?: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])$/,et=/^(([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}|:))$/,tt=/^((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])$/,nt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,rt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,at=/^\+[1-9]\d{6,14}$/,ot=`(?:(?:\\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])))`,st=RegExp(`^${ot}$`);function ct(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function lt(e){return RegExp(`^${ct(e)}$`)}function ut(e){let t=ct({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${ot}T(?:${r})$`)}var dt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ft=/^-?\d+$/,pt=/^-?\d+(?:\.\d+)?$/,mt=/^(?:true|false)$/i,ht=/^null$/i,gt=/^undefined$/i,_t=/^[^A-Z]*$/,vt=/^[^a-z]*$/,y=e(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),yt={number:`number`,bigint:`bigint`,object:`date`},bt=e(`$ZodCheckLessThan`,(e,t)=>{y.init(e,t);let n=yt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xt=e(`$ZodCheckGreaterThan`,(e,t)=>{y.init(e,t);let n=yt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),St=e(`$ZodCheckMultipleOf`,(e,t)=>{y.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):u(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ct=e(`$ZodCheckNumberFormat`,(e,t)=>{y.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=le[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=ft)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),wt=e(`$ZodCheckMaxLength`,(e,t)=>{var n;y.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=be(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Tt=e(`$ZodCheckMinLength`,(e,t)=>{var n;y.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=be(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Et=e(`$ZodCheckLengthEquals`,(e,t)=>{var n;y.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=be(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Dt=e(`$ZodCheckStringFormat`,(e,t)=>{var n,r;y.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ot=e(`$ZodCheckRegex`,(e,t)=>{Dt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),kt=e(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=_t,Dt.init(e,t)}),At=e(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=vt,Dt.init(e,t)}),jt=e(`$ZodCheckIncludes`,(e,t)=>{y.init(e,t);let n=oe(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Mt=e(`$ZodCheckStartsWith`,(e,t)=>{y.init(e,t);let n=RegExp(`^${oe(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Nt=e(`$ZodCheckEndsWith`,(e,t)=>{y.init(e,t);let n=RegExp(`.*${oe(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Pt=e(`$ZodCheckOverwrite`,(e,t)=>{y.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Ft=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
354
369
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
355
|
-
`))}},It={major:4,minor:3,patch:6},b=e(`$ZodType`,(e,n)=>{var r;e??={},e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=It;let i=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(e,n,r)=>{let i=_e(e),a;for(let o of n){if(o._zod.def.when){if(!o._zod.def.when(e))continue}else if(i)continue;let n=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&r?.async===!1)throw new t;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,e.issues.length!==n&&(i||=_e(e,n))});else{if(e.issues.length===n)continue;i||=_e(e,n)}}return a?a.then(()=>e):e},r=(r,a,o)=>{if(_e(r))return r.aborted=!0,r;let s=n(a,i,o);if(s instanceof Promise){if(o.async===!1)throw new t;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction===`backward`){let t=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,a,o)):r(t,a,o)}let s=e._zod.parse(a,o);if(s instanceof Promise){if(o.async===!1)throw new t;return s.then(e=>n(e,i,o))}return n(s,i,o)}}f(e,`~standard`,()=>({validate:t=>{try{let n=Ae(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Me(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Lt=e(`$ZodString`,(e,t)=>{b.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??dt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),x=e(`$ZodStringFormat`,(e,t)=>{Dt.init(e,t),Lt.init(e,t)}),Rt=e(`$ZodGUID`,(e,t)=>{t.pattern??=Je,x.init(e,t)}),zt=e(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ye(e)}else t.pattern??=Ye();x.init(e,t)}),Bt=e(`$ZodEmail`,(e,t)=>{t.pattern??=Xe,x.init(e,t)}),Vt=e(`$ZodURL`,(e,t)=>{x.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Ht=e(`$ZodEmoji`,(e,t)=>{t.pattern??=Qe(),x.init(e,t)}),Ut=e(`$ZodNanoID`,(e,t)=>{t.pattern??=Ke,x.init(e,t)}),Wt=e(`$ZodCUID`,(e,t)=>{t.pattern??=Ve,x.init(e,t)}),Gt=e(`$ZodCUID2`,(e,t)=>{t.pattern??=He,x.init(e,t)}),Kt=e(`$ZodULID`,(e,t)=>{t.pattern??=Ue,x.init(e,t)}),qt=e(`$ZodXID`,(e,t)=>{t.pattern??=We,x.init(e,t)}),Jt=e(`$ZodKSUID`,(e,t)=>{t.pattern??=Ge,x.init(e,t)}),Yt=e(`$ZodISODateTime`,(e,t)=>{t.pattern??=ut(t),x.init(e,t)}),Xt=e(`$ZodISODate`,(e,t)=>{t.pattern??=st,x.init(e,t)}),Zt=e(`$ZodISOTime`,(e,t)=>{t.pattern??=lt(t),x.init(e,t)}),Qt=e(`$ZodISODuration`,(e,t)=>{t.pattern??=qe,x.init(e,t)}),$t=e(`$ZodIPv4`,(e,t)=>{t.pattern??=$e,x.init(e,t),e._zod.bag.format=`ipv4`}),en=e(`$ZodIPv6`,(e,t)=>{t.pattern??=et,x.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),tn=e(`$ZodCIDRv4`,(e,t)=>{t.pattern??=tt,x.init(e,t)}),nn=e(`$ZodCIDRv6`,(e,t)=>{t.pattern??=nt,x.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function rn(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var an=e(`$ZodBase64`,(e,t)=>{t.pattern??=rt,x.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{rn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function on(e){if(!it.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return rn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var sn=e(`$ZodBase64URL`,(e,t)=>{t.pattern??=it,x.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{on(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),cn=e(`$ZodE164`,(e,t)=>{t.pattern??=at,x.init(e,t)});function ln(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var un=e(`$ZodJWT`,(e,t)=>{x.init(e,t),e._zod.check=n=>{ln(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),dn=e(`$ZodNumber`,(e,t)=>{b.init(e,t),e._zod.pattern=e._zod.bag.pattern??pt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),fn=e(`$ZodNumberFormat`,(e,t)=>{Ct.init(e,t),dn.init(e,t)}),pn=e(`$ZodBoolean`,(e,t)=>{b.init(e,t),e._zod.pattern=mt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),mn=e(`$ZodUndefined`,(e,t)=>{b.init(e,t),e._zod.pattern=gt,e._zod.values=new Set([void 0]),e._zod.optin=`optional`,e._zod.optout=`optional`,e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),hn=e(`$ZodNull`,(e,t)=>{b.init(e,t),e._zod.pattern=ht,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),gn=e(`$ZodUnknown`,(e,t)=>{b.init(e,t),e._zod.parse=e=>e}),_n=e(`$ZodNever`,(e,t)=>{b.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function vn(e,t,n){e.issues.length&&t.issues.push(...ve(n,e.issues)),t.value[n]=e.value}var yn=e(`$ZodArray`,(e,t)=>{b.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>vn(t,n,e))):vn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function bn(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...ve(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function xn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=ce(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Sn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>bn(e,n,i,t,u))):bn(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Cn=e(`$ZodObject`,(e,t)=>{if(b.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=s(()=>xn(t));f(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=
|
|
370
|
+
`))}},It={major:4,minor:3,patch:6},b=e(`$ZodType`,(e,n)=>{var r;e??={},e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=It;let i=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(e,n,r)=>{let i=_e(e),a;for(let o of n){if(o._zod.def.when){if(!o._zod.def.when(e))continue}else if(i)continue;let n=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&r?.async===!1)throw new t;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,e.issues.length!==n&&(i||=_e(e,n))});else{if(e.issues.length===n)continue;i||=_e(e,n)}}return a?a.then(()=>e):e},r=(r,a,o)=>{if(_e(r))return r.aborted=!0,r;let s=n(a,i,o);if(s instanceof Promise){if(o.async===!1)throw new t;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction===`backward`){let t=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,a,o)):r(t,a,o)}let s=e._zod.parse(a,o);if(s instanceof Promise){if(o.async===!1)throw new t;return s.then(e=>n(e,i,o))}return n(s,i,o)}}f(e,`~standard`,()=>({validate:t=>{try{let n=Ae(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Me(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Lt=e(`$ZodString`,(e,t)=>{b.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??dt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),x=e(`$ZodStringFormat`,(e,t)=>{Dt.init(e,t),Lt.init(e,t)}),Rt=e(`$ZodGUID`,(e,t)=>{t.pattern??=Je,x.init(e,t)}),zt=e(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ye(e)}else t.pattern??=Ye();x.init(e,t)}),Bt=e(`$ZodEmail`,(e,t)=>{t.pattern??=Xe,x.init(e,t)}),Vt=e(`$ZodURL`,(e,t)=>{x.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Ht=e(`$ZodEmoji`,(e,t)=>{t.pattern??=Qe(),x.init(e,t)}),Ut=e(`$ZodNanoID`,(e,t)=>{t.pattern??=Ke,x.init(e,t)}),Wt=e(`$ZodCUID`,(e,t)=>{t.pattern??=Ve,x.init(e,t)}),Gt=e(`$ZodCUID2`,(e,t)=>{t.pattern??=He,x.init(e,t)}),Kt=e(`$ZodULID`,(e,t)=>{t.pattern??=Ue,x.init(e,t)}),qt=e(`$ZodXID`,(e,t)=>{t.pattern??=We,x.init(e,t)}),Jt=e(`$ZodKSUID`,(e,t)=>{t.pattern??=Ge,x.init(e,t)}),Yt=e(`$ZodISODateTime`,(e,t)=>{t.pattern??=ut(t),x.init(e,t)}),Xt=e(`$ZodISODate`,(e,t)=>{t.pattern??=st,x.init(e,t)}),Zt=e(`$ZodISOTime`,(e,t)=>{t.pattern??=lt(t),x.init(e,t)}),Qt=e(`$ZodISODuration`,(e,t)=>{t.pattern??=qe,x.init(e,t)}),$t=e(`$ZodIPv4`,(e,t)=>{t.pattern??=$e,x.init(e,t),e._zod.bag.format=`ipv4`}),en=e(`$ZodIPv6`,(e,t)=>{t.pattern??=et,x.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),tn=e(`$ZodCIDRv4`,(e,t)=>{t.pattern??=tt,x.init(e,t)}),nn=e(`$ZodCIDRv6`,(e,t)=>{t.pattern??=nt,x.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function rn(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var an=e(`$ZodBase64`,(e,t)=>{t.pattern??=rt,x.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{rn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function on(e){if(!it.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return rn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var sn=e(`$ZodBase64URL`,(e,t)=>{t.pattern??=it,x.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{on(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),cn=e(`$ZodE164`,(e,t)=>{t.pattern??=at,x.init(e,t)});function ln(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var un=e(`$ZodJWT`,(e,t)=>{x.init(e,t),e._zod.check=n=>{ln(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),dn=e(`$ZodNumber`,(e,t)=>{b.init(e,t),e._zod.pattern=e._zod.bag.pattern??pt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),fn=e(`$ZodNumberFormat`,(e,t)=>{Ct.init(e,t),dn.init(e,t)}),pn=e(`$ZodBoolean`,(e,t)=>{b.init(e,t),e._zod.pattern=mt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),mn=e(`$ZodUndefined`,(e,t)=>{b.init(e,t),e._zod.pattern=gt,e._zod.values=new Set([void 0]),e._zod.optin=`optional`,e._zod.optout=`optional`,e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),hn=e(`$ZodNull`,(e,t)=>{b.init(e,t),e._zod.pattern=ht,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),gn=e(`$ZodUnknown`,(e,t)=>{b.init(e,t),e._zod.parse=e=>e}),_n=e(`$ZodNever`,(e,t)=>{b.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function vn(e,t,n){e.issues.length&&t.issues.push(...ve(n,e.issues)),t.value[n]=e.value}var yn=e(`$ZodArray`,(e,t)=>{b.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>vn(t,n,e))):vn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function bn(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...ve(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function xn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=ce(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Sn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>bn(e,n,i,t,u))):bn(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Cn=e(`$ZodObject`,(e,t)=>{if(b.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=s(()=>xn(t));f(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=g,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>bn(n,t,e,s,r))):bn(i,t,e,s,r)}return i?Sn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),wn=e(`$ZodObjectJIT`,(e,t)=>{Cn.init(e,t);let n=e._zod.parse,i=s(()=>xn(t)),a=e=>{let t=new Ft([`shape`,`payload`,`ctx`]),n=i.value,r=e=>{let t=h(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let i of n.keys){let n=a[i],o=h(i),s=e[i]?._zod?.optout===`optional`;t.write(`const ${n} = ${r(i)};`),s?t.write(`
|
|
356
371
|
if (${n}.issues.length) {
|
|
357
372
|
if (${o} in input) {
|
|
358
373
|
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
@@ -386,9 +401,9 @@
|
|
|
386
401
|
newResult[${o}] = ${n}.value;
|
|
387
402
|
}
|
|
388
403
|
|
|
389
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},o,c=ne,l=!r.jitless,u=l&&re.value,d=t.catchall,f;e._zod.parse=(r,s)=>{f??=i.value;let p=r.value;return c(p)?l&&u&&s?.async===!1&&s.jitless!==!0?(o||=a(t.shape),r=o(r,s),d?Sn([],p,r,s,f,e):r):n(r,s):(r.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),r)}});function Tn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let a=e.filter(e=>!_e(e));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>v(e,r,i())))}),t)}var En=e(`$ZodUnion`,(e,t)=>{b.init(e,t),f(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),f(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),f(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),f(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>l(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Tn(t,i,e,a)):Tn(s,i,e,a)}}),Dn=e(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,En.init(e,t);let n=e._zod.parse;f(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=s(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!ne(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),On=e(`$ZodIntersection`,(e,t)=>{b.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>An(e,t,n)):An(e,i,a)}});function kn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ie(e)&&ie(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=kn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=kn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function An(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),_e(e))return e;let o=kn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var jn=e(`$ZodRecord`,(e,t)=>{b.init(e,t),e._zod.parse=(n,r)=>{let a=n.value;if(!ie(a))return n.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),n;let o=[],s=t.keyType._zod.values;if(s){n.value={};let i=new Set;for(let e of s)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){i.add(typeof e==`number`?e.toString():e);let s=t.valueType._zod.run({value:a[e],issues:[]},r);s instanceof Promise?o.push(s.then(t=>{t.issues.length&&n.issues.push(...ve(e,t.issues)),n.value[e]=t.value})):(s.issues.length&&n.issues.push(...ve(e,s.issues)),n.value[e]=s.value)}let c;for(let e in a)i.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c})}else{n.value={};for(let s of Reflect.ownKeys(a)){if(s===`__proto__`)continue;let c=t.keyType._zod.run({value:s,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof s==`string`&&pt.test(s)&&c.issues.length){let e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[s]=a[s]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>v(e,r,i())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:a[s],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...ve(s,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...ve(s,l.issues)),n.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Mn=e(`$ZodEnum`,(e,t)=>{b.init(e,t);let n=a(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>oe.has(typeof e)).map(e=>typeof e==`string`?se(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Nn=e(`$ZodLiteral`,(e,t)=>{if(b.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?se(e):e?se(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Pn=e(`$ZodTransform`,(e,r)=>{b.init(e,r),e._zod.parse=(i,a)=>{if(a.direction===`backward`)throw new n(e.constructor.name);let o=r.transform(i.value,i);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(i.value=e,i));if(o instanceof Promise)throw new t;return i.value=o,i}});function Fn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var In=e(`$ZodOptional`,(e,t)=>{b.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),f(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${l(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Fn(t,e.value)):Fn(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Ln=e(`$ZodExactOptional`,(e,t)=>{In.init(e,t),f(e._zod,`values`,()=>t.innerType._zod.values),f(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Rn=e(`$ZodNullable`,(e,t)=>{b.init(e,t),f(e._zod,`optin`,()=>t.innerType._zod.optin),f(e._zod,`optout`,()=>t.innerType._zod.optout),f(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${l(e.source)}|null)$`):void 0}),f(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),zn=e(`$ZodDefault`,(e,t)=>{b.init(e,t),e._zod.optin=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Bn(e,t)):Bn(r,t)}});function Bn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Vn=e(`$ZodPrefault`,(e,t)=>{b.init(e,t),e._zod.optin=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Hn=e(`$ZodNonOptional`,(e,t)=>{b.init(e,t),f(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Un(t,e)):Un(i,e)}});function Un(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Wn=e(`$ZodCatch`,(e,t)=>{b.init(e,t),f(e._zod,`optin`,()=>t.innerType._zod.optin),f(e._zod,`optout`,()=>t.innerType._zod.optout),f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>v(e,n,i()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>v(e,n,i()))},input:e.value}),e.issues=[]),e)}}),Gn=e(`$ZodPipe`,(e,t)=>{b.init(e,t),f(e._zod,`values`,()=>t.in._zod.values),f(e._zod,`optin`,()=>t.in._zod.optin),f(e._zod,`optout`,()=>t.out._zod.optout),f(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Kn(e,t.in,n)):Kn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Kn(e,t.out,n)):Kn(r,t.out,n)}});function Kn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var qn=e(`$ZodReadonly`,(e,t)=>{b.init(e,t),f(e._zod,`propValues`,()=>t.innerType._zod.propValues),f(e._zod,`values`,()=>t.innerType._zod.values),f(e._zod,`optin`,()=>t.innerType?._zod?.optin),f(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Jn):Jn(r)}});function Jn(e){return e.value=Object.freeze(e.value),e}var Yn=e(`$ZodCustom`,(e,t)=>{y.init(e,t),b.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Xn(t,n,r,e));Xn(i,n,r,e)}});function Xn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(xe(e))}}var Zn,Qn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function $n(){return new Qn}(Zn=globalThis).__zod_globalRegistry??(Zn.__zod_globalRegistry=$n());var er=globalThis.__zod_globalRegistry;function tr(e,t){return new e({type:`string`,..._(t)})}function nr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,..._(t)})}function rr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,..._(t)})}function ir(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,..._(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,..._(t)})}function or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,..._(t)})}function sr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,..._(t)})}function cr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,..._(t)})}function lr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,..._(t)})}function ur(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,..._(t)})}function dr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,..._(t)})}function fr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,..._(t)})}function pr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,..._(t)})}function mr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,..._(t)})}function hr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,..._(t)})}function gr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,..._(t)})}function _r(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,..._(t)})}function vr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,..._(t)})}function yr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,..._(t)})}function br(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,..._(t)})}function xr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,..._(t)})}function Sr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,..._(t)})}function Cr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,..._(t)})}function wr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,..._(t)})}function Tr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,..._(t)})}function Er(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,..._(t)})}function Dr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,..._(t)})}function Or(e,t){return new e({type:`number`,checks:[],..._(t)})}function kr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,..._(t)})}function Ar(e,t){return new e({type:`boolean`,..._(t)})}function jr(e,t){return new e({type:`undefined`,..._(t)})}function Mr(e,t){return new e({type:`null`,..._(t)})}function Nr(e){return new e({type:`unknown`})}function Pr(e,t){return new e({type:`never`,..._(t)})}function Fr(e,t){return new bt({check:`less_than`,..._(t),value:e,inclusive:!1})}function Ir(e,t){return new bt({check:`less_than`,..._(t),value:e,inclusive:!0})}function Lr(e,t){return new xt({check:`greater_than`,..._(t),value:e,inclusive:!1})}function Rr(e,t){return new xt({check:`greater_than`,..._(t),value:e,inclusive:!0})}function zr(e,t){return new St({check:`multiple_of`,..._(t),value:e})}function Br(e,t){return new wt({check:`max_length`,..._(t),maximum:e})}function Vr(e,t){return new Tt({check:`min_length`,..._(t),minimum:e})}function Hr(e,t){return new Et({check:`length_equals`,..._(t),length:e})}function Ur(e,t){return new Ot({check:`string_format`,format:`regex`,..._(t),pattern:e})}function Wr(e){return new kt({check:`string_format`,format:`lowercase`,..._(e)})}function Gr(e){return new At({check:`string_format`,format:`uppercase`,..._(e)})}function Kr(e,t){return new jt({check:`string_format`,format:`includes`,..._(t),includes:e})}function qr(e,t){return new Mt({check:`string_format`,format:`starts_with`,..._(t),prefix:e})}function Jr(e,t){return new Nt({check:`string_format`,format:`ends_with`,..._(t),suffix:e})}function Yr(e){return new Pt({check:`overwrite`,tx:e})}function Xr(e){return Yr(t=>t.normalize(e))}function Zr(){return Yr(e=>e.trim())}function Qr(){return Yr(e=>e.toLowerCase())}function $r(){return Yr(e=>e.toUpperCase())}function ei(){return Yr(e=>ee(e))}function ti(e,t,n){return new e({type:`array`,element:t,..._(n)})}function ni(e,t,n){let r=_(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ri(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,..._(n)})}function ii(e){let t=ai(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(xe(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(xe(r))}},e(n.value,n)));return t}function ai(e,t){let n=new y({check:`custom`,..._(t)});return n._zod.check=e,n}function oi(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??er,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function S(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,S(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&C(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function si(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
404
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},o,c=g,l=!r.jitless,u=l&&ne.value,d=t.catchall,f;e._zod.parse=(r,s)=>{f??=i.value;let p=r.value;return c(p)?l&&u&&s?.async===!1&&s.jitless!==!0?(o||=a(t.shape),r=o(r,s),d?Sn([],p,r,s,f,e):r):n(r,s):(r.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),r)}});function Tn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let a=e.filter(e=>!_e(e));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>v(e,r,i())))}),t)}var En=e(`$ZodUnion`,(e,t)=>{b.init(e,t),f(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),f(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),f(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),f(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>l(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Tn(t,i,e,a)):Tn(s,i,e,a)}}),Dn=e(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,En.init(e,t);let n=e._zod.parse;f(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=s(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!g(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),On=e(`$ZodIntersection`,(e,t)=>{b.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>An(e,t,n)):An(e,i,a)}});function kn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(re(e)&&re(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=kn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=kn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function An(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),_e(e))return e;let o=kn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var jn=e(`$ZodRecord`,(e,t)=>{b.init(e,t),e._zod.parse=(n,r)=>{let a=n.value;if(!re(a))return n.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),n;let o=[],s=t.keyType._zod.values;if(s){n.value={};let i=new Set;for(let e of s)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){i.add(typeof e==`number`?e.toString():e);let s=t.valueType._zod.run({value:a[e],issues:[]},r);s instanceof Promise?o.push(s.then(t=>{t.issues.length&&n.issues.push(...ve(e,t.issues)),n.value[e]=t.value})):(s.issues.length&&n.issues.push(...ve(e,s.issues)),n.value[e]=s.value)}let c;for(let e in a)i.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c})}else{n.value={};for(let s of Reflect.ownKeys(a)){if(s===`__proto__`)continue;let c=t.keyType._zod.run({value:s,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof s==`string`&&pt.test(s)&&c.issues.length){let e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[s]=a[s]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>v(e,r,i())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:a[s],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...ve(s,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...ve(s,l.issues)),n.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Mn=e(`$ZodEnum`,(e,t)=>{b.init(e,t);let n=a(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ae.has(typeof e)).map(e=>typeof e==`string`?oe(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Nn=e(`$ZodLiteral`,(e,t)=>{if(b.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?oe(e):e?oe(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Pn=e(`$ZodTransform`,(e,r)=>{b.init(e,r),e._zod.parse=(i,a)=>{if(a.direction===`backward`)throw new n(e.constructor.name);let o=r.transform(i.value,i);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(i.value=e,i));if(o instanceof Promise)throw new t;return i.value=o,i}});function Fn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var In=e(`$ZodOptional`,(e,t)=>{b.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),f(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${l(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Fn(t,e.value)):Fn(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Ln=e(`$ZodExactOptional`,(e,t)=>{In.init(e,t),f(e._zod,`values`,()=>t.innerType._zod.values),f(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Rn=e(`$ZodNullable`,(e,t)=>{b.init(e,t),f(e._zod,`optin`,()=>t.innerType._zod.optin),f(e._zod,`optout`,()=>t.innerType._zod.optout),f(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${l(e.source)}|null)$`):void 0}),f(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),zn=e(`$ZodDefault`,(e,t)=>{b.init(e,t),e._zod.optin=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Bn(e,t)):Bn(r,t)}});function Bn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Vn=e(`$ZodPrefault`,(e,t)=>{b.init(e,t),e._zod.optin=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Hn=e(`$ZodNonOptional`,(e,t)=>{b.init(e,t),f(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Un(t,e)):Un(i,e)}});function Un(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Wn=e(`$ZodCatch`,(e,t)=>{b.init(e,t),f(e._zod,`optin`,()=>t.innerType._zod.optin),f(e._zod,`optout`,()=>t.innerType._zod.optout),f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>v(e,n,i()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>v(e,n,i()))},input:e.value}),e.issues=[]),e)}}),Gn=e(`$ZodPipe`,(e,t)=>{b.init(e,t),f(e._zod,`values`,()=>t.in._zod.values),f(e._zod,`optin`,()=>t.in._zod.optin),f(e._zod,`optout`,()=>t.out._zod.optout),f(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Kn(e,t.in,n)):Kn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Kn(e,t.out,n)):Kn(r,t.out,n)}});function Kn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var qn=e(`$ZodReadonly`,(e,t)=>{b.init(e,t),f(e._zod,`propValues`,()=>t.innerType._zod.propValues),f(e._zod,`values`,()=>t.innerType._zod.values),f(e._zod,`optin`,()=>t.innerType?._zod?.optin),f(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Jn):Jn(r)}});function Jn(e){return e.value=Object.freeze(e.value),e}var Yn=e(`$ZodCustom`,(e,t)=>{y.init(e,t),b.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Xn(t,n,r,e));Xn(i,n,r,e)}});function Xn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(xe(e))}}var Zn,Qn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function $n(){return new Qn}(Zn=globalThis).__zod_globalRegistry??(Zn.__zod_globalRegistry=$n());var er=globalThis.__zod_globalRegistry;function tr(e,t){return new e({type:`string`,..._(t)})}function nr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,..._(t)})}function rr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,..._(t)})}function ir(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,..._(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,..._(t)})}function or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,..._(t)})}function sr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,..._(t)})}function cr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,..._(t)})}function lr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,..._(t)})}function ur(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,..._(t)})}function dr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,..._(t)})}function fr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,..._(t)})}function pr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,..._(t)})}function mr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,..._(t)})}function hr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,..._(t)})}function gr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,..._(t)})}function _r(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,..._(t)})}function vr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,..._(t)})}function yr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,..._(t)})}function br(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,..._(t)})}function xr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,..._(t)})}function Sr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,..._(t)})}function Cr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,..._(t)})}function wr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,..._(t)})}function Tr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,..._(t)})}function Er(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,..._(t)})}function Dr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,..._(t)})}function Or(e,t){return new e({type:`number`,checks:[],..._(t)})}function kr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,..._(t)})}function Ar(e,t){return new e({type:`boolean`,..._(t)})}function jr(e,t){return new e({type:`undefined`,..._(t)})}function Mr(e,t){return new e({type:`null`,..._(t)})}function Nr(e){return new e({type:`unknown`})}function Pr(e,t){return new e({type:`never`,..._(t)})}function Fr(e,t){return new bt({check:`less_than`,..._(t),value:e,inclusive:!1})}function Ir(e,t){return new bt({check:`less_than`,..._(t),value:e,inclusive:!0})}function Lr(e,t){return new xt({check:`greater_than`,..._(t),value:e,inclusive:!1})}function Rr(e,t){return new xt({check:`greater_than`,..._(t),value:e,inclusive:!0})}function zr(e,t){return new St({check:`multiple_of`,..._(t),value:e})}function Br(e,t){return new wt({check:`max_length`,..._(t),maximum:e})}function Vr(e,t){return new Tt({check:`min_length`,..._(t),minimum:e})}function Hr(e,t){return new Et({check:`length_equals`,..._(t),length:e})}function Ur(e,t){return new Ot({check:`string_format`,format:`regex`,..._(t),pattern:e})}function Wr(e){return new kt({check:`string_format`,format:`lowercase`,..._(e)})}function Gr(e){return new At({check:`string_format`,format:`uppercase`,..._(e)})}function Kr(e,t){return new jt({check:`string_format`,format:`includes`,..._(t),includes:e})}function qr(e,t){return new Mt({check:`string_format`,format:`starts_with`,..._(t),prefix:e})}function Jr(e,t){return new Nt({check:`string_format`,format:`ends_with`,..._(t),suffix:e})}function Yr(e){return new Pt({check:`overwrite`,tx:e})}function Xr(e){return Yr(t=>t.normalize(e))}function Zr(){return Yr(e=>e.trim())}function Qr(){return Yr(e=>e.toLowerCase())}function $r(){return Yr(e=>e.toUpperCase())}function ei(){return Yr(e=>ee(e))}function ti(e,t,n){return new e({type:`array`,element:t,..._(n)})}function ni(e,t,n){let r=_(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ri(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,..._(n)})}function ii(e){let t=ai(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(xe(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(xe(r))}},e(n.value,n)));return t}function ai(e,t){let n=new y({check:`custom`,..._(t)});return n._zod.check=e,n}function oi(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??er,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function S(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,S(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&C(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function si(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
390
405
|
|
|
391
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ci(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:ui(t,`input`,e.processors),output:ui(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function C(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return C(r.element,n);if(r.type===`set`)return C(r.valueType,n);if(r.type===`lazy`)return C(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return C(r.innerType,n);if(r.type===`intersection`)return C(r.left,n)||C(r.right,n);if(r.type===`record`||r.type===`map`)return C(r.keyType,n)||C(r.valueType,n);if(r.type===`pipe`)return C(r.in,n)||C(r.out,n);if(r.type===`object`){for(let e in r.shape)if(C(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(C(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(C(e,n))return!0;return!!(r.rest&&C(r.rest,n))}return!1}var li=(e,t={})=>n=>{let r=oi({...n,processors:t});return S(e,r),si(r,e),ci(r,e)},ui=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=oi({...i??{},target:a,io:t,processors:n});return S(e,o),si(o,e),ci(o,e)},di={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},fi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=di[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},pi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},mi=(e,t,n,r)=>{n.type=`boolean`},hi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},gi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},_i=(e,t,n,r)=>{n.not={}},vi=(e,t,n,r)=>{let i=e._zod.def,o=a(i.entries);o.every(e=>typeof e==`number`)&&(n.type=`number`),o.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=o},yi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},bi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},xi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Si=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=S(a.element,t,{...r,path:[...r.path,`items`]})},Ci=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=S(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=S(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},wi=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>S(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ti=(e,t,n,r)=>{let i=e._zod.def,a=S(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=S(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Ei=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=S(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=S(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=S(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Di=(e,t,n,r)=>{let i=e._zod.def,a=S(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Oi=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ki=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ai=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ji=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Mi=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;S(a,t,r);let o=t.seen.get(e);o.ref=a},Ni=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Pi=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType};function Fi(e){return!!e._zod}function Ii(e,t){return Fi(e)?Ae(e,t):e.safeParse(t)}function Li(e){if(!e)return;let t;if(t=Fi(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function Ri(e){if(Fi(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}var zi=e(`ZodISODateTime`,(e,t)=>{Yt.init(e,t),D.init(e,t)});function Bi(e){return wr(zi,e)}var Vi=e(`ZodISODate`,(e,t)=>{Xt.init(e,t),D.init(e,t)});function Hi(e){return Tr(Vi,e)}var Ui=e(`ZodISOTime`,(e,t)=>{Zt.init(e,t),D.init(e,t)});function Wi(e){return Er(Ui,e)}var Gi=e(`ZodISODuration`,(e,t)=>{Qt.init(e,t),D.init(e,t)});function Ki(e){return Dr(Gi,e)}var qi=(e,t)=>{Ce.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ee(e,t)},flatten:{value:t=>Te(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,o,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,o,2)}},isEmpty:{get(){return e.issues.length===0}}})};e(`ZodError`,qi);var w=e(`ZodError`,qi,{Parent:Error}),Ji=De(w),Yi=Oe(w),Xi=ke(w),Zi=je(w),Qi=Ne(w),$i=Pe(w),ea=Fe(w),ta=Ie(w),na=Le(w),ra=Re(w),ia=ze(w),aa=Be(w),T=e(`ZodType`,(e,t)=>(b.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ui(e,`input`),output:ui(e,`output`)}}),e.toJSONSchema=li(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(m(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>g(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Ji(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Xi(e,t,n),e.parseAsync=async(t,n)=>Yi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Zi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Qi(e,t,n),e.decode=(t,n)=>$i(e,t,n),e.encodeAsync=async(t,n)=>ea(e,t,n),e.decodeAsync=async(t,n)=>ta(e,t,n),e.safeEncode=(t,n)=>na(e,t,n),e.safeDecode=(t,n)=>ra(e,t,n),e.safeEncodeAsync=async(t,n)=>ia(e,t,n),e.safeDecodeAsync=async(t,n)=>aa(e,t,n),e.refine=(t,n)=>e.check(go(t,n)),e.superRefine=t=>e.check(_o(t)),e.overwrite=t=>e.check(Yr(t)),e.optional=()=>R(e),e.exactOptional=()=>Qa(e),e.nullable=()=>eo(e),e.nullish=()=>R(eo(e)),e.nonoptional=t=>oo(e,t),e.array=()=>j(e),e.or=t=>P([e,t]),e.and=t=>Wa(e,t),e.transform=t=>uo(e,Ya(t)),e.default=t=>no(e,t),e.prefault=t=>io(e,t),e.catch=t=>co(e,t),e.pipe=t=>uo(e,t),e.readonly=()=>po(e),e.describe=t=>{let n=e.clone();return er.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return er.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return er.get(e);let n=e.clone();return er.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),oa=e(`_ZodString`,(e,t)=>{Lt.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Ur(...t)),e.includes=(...t)=>e.check(Kr(...t)),e.startsWith=(...t)=>e.check(qr(...t)),e.endsWith=(...t)=>e.check(Jr(...t)),e.min=(...t)=>e.check(Vr(...t)),e.max=(...t)=>e.check(Br(...t)),e.length=(...t)=>e.check(Hr(...t)),e.nonempty=(...t)=>e.check(Vr(1,...t)),e.lowercase=t=>e.check(Wr(t)),e.uppercase=t=>e.check(Gr(t)),e.trim=()=>e.check(Zr()),e.normalize=(...t)=>e.check(Xr(...t)),e.toLowerCase=()=>e.check(Qr()),e.toUpperCase=()=>e.check($r()),e.slugify=()=>e.check(ei())}),sa=e(`ZodString`,(e,t)=>{Lt.init(e,t),oa.init(e,t),e.email=t=>e.check(nr(ca,t)),e.url=t=>e.check(cr(da,t)),e.jwt=t=>e.check(Cr(Ea,t)),e.emoji=t=>e.check(lr(fa,t)),e.guid=t=>e.check(rr(la,t)),e.uuid=t=>e.check(ir(ua,t)),e.uuidv4=t=>e.check(ar(ua,t)),e.uuidv6=t=>e.check(or(ua,t)),e.uuidv7=t=>e.check(sr(ua,t)),e.nanoid=t=>e.check(ur(pa,t)),e.guid=t=>e.check(rr(la,t)),e.cuid=t=>e.check(dr(ma,t)),e.cuid2=t=>e.check(fr(ha,t)),e.ulid=t=>e.check(pr(ga,t)),e.base64=t=>e.check(br(Ca,t)),e.base64url=t=>e.check(xr(wa,t)),e.xid=t=>e.check(mr(_a,t)),e.ksuid=t=>e.check(hr(va,t)),e.ipv4=t=>e.check(gr(ya,t)),e.ipv6=t=>e.check(_r(ba,t)),e.cidrv4=t=>e.check(vr(xa,t)),e.cidrv6=t=>e.check(yr(Sa,t)),e.e164=t=>e.check(Sr(Ta,t)),e.datetime=t=>e.check(Bi(t)),e.date=t=>e.check(Hi(t)),e.time=t=>e.check(Wi(t)),e.duration=t=>e.check(Ki(t))});function E(e){return tr(sa,e)}var D=e(`ZodStringFormat`,(e,t)=>{x.init(e,t),oa.init(e,t)}),ca=e(`ZodEmail`,(e,t)=>{Bt.init(e,t),D.init(e,t)}),la=e(`ZodGUID`,(e,t)=>{Rt.init(e,t),D.init(e,t)}),ua=e(`ZodUUID`,(e,t)=>{zt.init(e,t),D.init(e,t)}),da=e(`ZodURL`,(e,t)=>{Vt.init(e,t),D.init(e,t)}),fa=e(`ZodEmoji`,(e,t)=>{Ht.init(e,t),D.init(e,t)}),pa=e(`ZodNanoID`,(e,t)=>{Ut.init(e,t),D.init(e,t)}),ma=e(`ZodCUID`,(e,t)=>{Wt.init(e,t),D.init(e,t)}),ha=e(`ZodCUID2`,(e,t)=>{Gt.init(e,t),D.init(e,t)}),ga=e(`ZodULID`,(e,t)=>{Kt.init(e,t),D.init(e,t)}),_a=e(`ZodXID`,(e,t)=>{qt.init(e,t),D.init(e,t)}),va=e(`ZodKSUID`,(e,t)=>{Jt.init(e,t),D.init(e,t)}),ya=e(`ZodIPv4`,(e,t)=>{$t.init(e,t),D.init(e,t)}),ba=e(`ZodIPv6`,(e,t)=>{en.init(e,t),D.init(e,t)}),xa=e(`ZodCIDRv4`,(e,t)=>{tn.init(e,t),D.init(e,t)}),Sa=e(`ZodCIDRv6`,(e,t)=>{nn.init(e,t),D.init(e,t)}),Ca=e(`ZodBase64`,(e,t)=>{an.init(e,t),D.init(e,t)}),wa=e(`ZodBase64URL`,(e,t)=>{sn.init(e,t),D.init(e,t)}),Ta=e(`ZodE164`,(e,t)=>{cn.init(e,t),D.init(e,t)}),Ea=e(`ZodJWT`,(e,t)=>{un.init(e,t),D.init(e,t)}),Da=e(`ZodNumber`,(e,t)=>{dn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r),e.gt=(t,n)=>e.check(Lr(t,n)),e.gte=(t,n)=>e.check(Rr(t,n)),e.min=(t,n)=>e.check(Rr(t,n)),e.lt=(t,n)=>e.check(Fr(t,n)),e.lte=(t,n)=>e.check(Ir(t,n)),e.max=(t,n)=>e.check(Ir(t,n)),e.int=t=>e.check(ka(t)),e.safe=t=>e.check(ka(t)),e.positive=t=>e.check(Lr(0,t)),e.nonnegative=t=>e.check(Rr(0,t)),e.negative=t=>e.check(Fr(0,t)),e.nonpositive=t=>e.check(Ir(0,t)),e.multipleOf=(t,n)=>e.check(zr(t,n)),e.step=(t,n)=>e.check(zr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function O(e){return Or(Da,e)}var Oa=e(`ZodNumberFormat`,(e,t)=>{fn.init(e,t),Da.init(e,t)});function ka(e){return kr(Oa,e)}var Aa=e(`ZodBoolean`,(e,t)=>{pn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r)});function k(e){return Ar(Aa,e)}var ja=e(`ZodUndefined`,(e,t)=>{mn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(e,t,n,r)});function Ma(e){return jr(ja,e)}var Na=e(`ZodNull`,(e,t)=>{hn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r)});function Pa(e){return Mr(Na,e)}var Fa=e(`ZodUnknown`,(e,t)=>{gn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function A(){return Nr(Fa)}var Ia=e(`ZodNever`,(e,t)=>{_n.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r)});function La(e){return Pr(Ia,e)}var Ra=e(`ZodArray`,(e,t)=>{yn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Vr(t,n)),e.nonempty=t=>e.check(Vr(1,t)),e.max=(t,n)=>e.check(Br(t,n)),e.length=(t,n)=>e.check(Hr(t,n)),e.unwrap=()=>e.element});function j(e,t){return ti(Ra,e,t)}var za=e(`ZodObject`,(e,t)=>{wn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r),f(e,`shape`,()=>t.shape),e.keyof=()=>I(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:A()}),e.loose=()=>e.clone({...e._zod.def,catchall:A()}),e.strict=()=>e.clone({...e._zod.def,catchall:La()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>fe(e,t),e.safeExtend=t=>pe(e,t),e.merge=t=>me(e,t),e.pick=t=>ue(e,t),e.omit=t=>de(e,t),e.partial=(...t)=>he(Xa,e,t[0]),e.required=(...t)=>ge(ao,e,t[0])});function M(e,t){return new za({type:`object`,shape:e??{},..._(t)})}function N(e,t){return new za({type:`object`,shape:e,catchall:A(),..._(t)})}var Ba=e(`ZodUnion`,(e,t)=>{En.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),e.options=t.options});function P(e,t){return new Ba({type:`union`,options:e,..._(t)})}var Va=e(`ZodDiscriminatedUnion`,(e,t)=>{Ba.init(e,t),Dn.init(e,t)});function Ha(e,t,n){return new Va({type:`union`,options:t,discriminator:e,..._(n)})}var Ua=e(`ZodIntersection`,(e,t)=>{On.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r)});function Wa(e,t){return new Ua({type:`intersection`,left:e,right:t})}var Ga=e(`ZodRecord`,(e,t)=>{jn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function F(e,t,n){return new Ga({type:`record`,keyType:e,valueType:t,..._(n)})}var Ka=e(`ZodEnum`,(e,t)=>{Mn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ka({...t,checks:[],..._(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ka({...t,checks:[],..._(r),entries:i})}});function I(e,t){return new Ka({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,..._(t)})}var qa=e(`ZodLiteral`,(e,t)=>{Nn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function L(e,t){return new qa({type:`literal`,values:Array.isArray(e)?e:[e],..._(t)})}var Ja=e(`ZodTransform`,(e,t)=>{Pn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e._zod.parse=(r,i)=>{if(i.direction===`backward`)throw new n(e.constructor.name);r.addIssue=n=>{if(typeof n==`string`)r.issues.push(xe(n,r.value,t));else{let t=n;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=r.value,t.inst??=e,r.issues.push(xe(t))}};let a=t.transform(r.value,r);return a instanceof Promise?a.then(e=>(r.value=e,r)):(r.value=a,r)}});function Ya(e){return new Ja({type:`transform`,transform:e})}var Xa=e(`ZodOptional`,(e,t)=>{In.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function R(e){return new Xa({type:`optional`,innerType:e})}var Za=e(`ZodExactOptional`,(e,t)=>{Ln.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qa(e){return new Za({type:`optional`,innerType:e})}var $a=e(`ZodNullable`,(e,t)=>{Rn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function eo(e){return new $a({type:`nullable`,innerType:e})}var to=e(`ZodDefault`,(e,t)=>{zn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function no(e,t){return new to({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ae(t)}})}var ro=e(`ZodPrefault`,(e,t)=>{Vn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function io(e,t){return new ro({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ae(t)}})}var ao=e(`ZodNonOptional`,(e,t)=>{Hn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oo(e,t){return new ao({type:`nonoptional`,innerType:e,..._(t)})}var so=e(`ZodCatch`,(e,t)=>{Wn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function co(e,t){return new so({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var lo=e(`ZodPipe`,(e,t)=>{Gn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),e.in=t.in,e.out=t.out});function uo(e,t){return new lo({type:`pipe`,in:e,out:t})}var fo=e(`ZodReadonly`,(e,t)=>{qn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function po(e){return new fo({type:`readonly`,innerType:e})}var mo=e(`ZodCustom`,(e,t)=>{Yn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r)});function ho(e,t){return ni(mo,e??(()=>!0),t)}function go(e,t={}){return ri(mo,e,t)}function _o(e){return ii(e)}function vo(e,t){return uo(Ya(e),t)}var z=`io.modelcontextprotocol/related-task`,B=ho(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),yo=P([E(),O().int()]),bo=E();N({ttl:O().optional(),pollInterval:O().optional()});var xo=M({ttl:O().optional()}),So=M({taskId:E()}),Co=N({progressToken:yo.optional(),[z]:So.optional()}),V=M({_meta:Co.optional()}),wo=V.extend({task:xo.optional()}),To=e=>wo.safeParse(e).success,H=M({method:E(),params:V.loose().optional()}),U=M({_meta:Co.optional()}),W=M({method:E(),params:U.loose().optional()}),G=N({_meta:Co.optional()}),Eo=P([E(),O().int()]),Do=M({jsonrpc:L(`2.0`),id:Eo,...H.shape}).strict(),Oo=e=>Do.safeParse(e).success,ko=M({jsonrpc:L(`2.0`),...W.shape}).strict(),Ao=e=>ko.safeParse(e).success,jo=M({jsonrpc:L(`2.0`),id:Eo,result:G}).strict(),Mo=e=>jo.safeParse(e).success,K;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(K||={});var No=M({jsonrpc:L(`2.0`),id:Eo.optional(),error:M({code:O().int(),message:E(),data:A().optional()})}).strict(),Po=e=>No.safeParse(e).success,Fo=P([Do,ko,jo,No]);P([jo,No]);var Io=G.strict(),Lo=U.extend({requestId:Eo.optional(),reason:E().optional()}),Ro=W.extend({method:L(`notifications/cancelled`),params:Lo}),zo=M({icons:j(M({src:E(),mimeType:E().optional(),sizes:j(E()).optional(),theme:I([`light`,`dark`]).optional()})).optional()}),Bo=M({name:E(),title:E().optional()}),Vo=Bo.extend({...Bo.shape,...zo.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),Ho=vo(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Wa(M({form:Wa(M({applyDefaults:k().optional()}),F(E(),A())).optional(),url:B.optional()}),F(E(),A()).optional())),Uo=N({list:B.optional(),cancel:B.optional(),requests:N({sampling:N({createMessage:B.optional()}).optional(),elicitation:N({create:B.optional()}).optional()}).optional()}),Wo=N({list:B.optional(),cancel:B.optional(),requests:N({tools:N({call:B.optional()}).optional()}).optional()}),Go=M({experimental:F(E(),B).optional(),sampling:M({context:B.optional(),tools:B.optional()}).optional(),elicitation:Ho.optional(),roots:M({listChanged:k().optional()}).optional(),tasks:Uo.optional(),extensions:F(E(),B).optional()}),Ko=V.extend({protocolVersion:E(),capabilities:Go,clientInfo:Vo}),qo=H.extend({method:L(`initialize`),params:Ko}),Jo=M({experimental:F(E(),B).optional(),logging:B.optional(),completions:B.optional(),prompts:M({listChanged:k().optional()}).optional(),resources:M({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:M({listChanged:k().optional()}).optional(),tasks:Wo.optional(),extensions:F(E(),B).optional()}),Yo=G.extend({protocolVersion:E(),capabilities:Jo,serverInfo:Vo,instructions:E().optional()}),Xo=W.extend({method:L(`notifications/initialized`),params:U.optional()}),Zo=H.extend({method:L(`ping`),params:V.optional()}),Qo=M({progress:O(),total:R(O()),message:R(E())}),$o=M({...U.shape,...Qo.shape,progressToken:yo}),es=W.extend({method:L(`notifications/progress`),params:$o}),ts=V.extend({cursor:bo.optional()}),ns=H.extend({params:ts.optional()}),rs=G.extend({nextCursor:bo.optional()}),is=I([`working`,`input_required`,`completed`,`failed`,`cancelled`]),as=M({taskId:E(),status:is,ttl:P([O(),Pa()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:R(O()),statusMessage:R(E())}),os=G.extend({task:as}),ss=U.merge(as),cs=W.extend({method:L(`notifications/tasks/status`),params:ss}),ls=H.extend({method:L(`tasks/get`),params:V.extend({taskId:E()})}),us=G.merge(as),ds=H.extend({method:L(`tasks/result`),params:V.extend({taskId:E()})});G.loose();var fs=ns.extend({method:L(`tasks/list`)}),ps=rs.extend({tasks:j(as)}),ms=H.extend({method:L(`tasks/cancel`),params:V.extend({taskId:E()})}),hs=G.merge(as),gs=M({uri:E(),mimeType:R(E()),_meta:F(E(),A()).optional()}),_s=gs.extend({text:E()}),vs=E().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),ys=gs.extend({blob:vs}),bs=I([`user`,`assistant`]),xs=M({audience:j(bs).optional(),priority:O().min(0).max(1).optional(),lastModified:Bi({offset:!0}).optional()}),Ss=M({...Bo.shape,...zo.shape,uri:E(),description:R(E()),mimeType:R(E()),size:R(O()),annotations:xs.optional(),_meta:R(N({}))}),Cs=M({...Bo.shape,...zo.shape,uriTemplate:E(),description:R(E()),mimeType:R(E()),annotations:xs.optional(),_meta:R(N({}))}),ws=ns.extend({method:L(`resources/list`)}),Ts=rs.extend({resources:j(Ss)}),Es=ns.extend({method:L(`resources/templates/list`)}),Ds=rs.extend({resourceTemplates:j(Cs)}),Os=V.extend({uri:E()}),ks=Os,As=H.extend({method:L(`resources/read`),params:ks}),js=G.extend({contents:j(P([_s,ys]))}),Ms=W.extend({method:L(`notifications/resources/list_changed`),params:U.optional()}),Ns=Os,Ps=H.extend({method:L(`resources/subscribe`),params:Ns}),Fs=Os,Is=H.extend({method:L(`resources/unsubscribe`),params:Fs}),Ls=U.extend({uri:E()}),Rs=W.extend({method:L(`notifications/resources/updated`),params:Ls}),zs=M({name:E(),description:R(E()),required:R(k())}),Bs=M({...Bo.shape,...zo.shape,description:R(E()),arguments:R(j(zs)),_meta:R(N({}))}),Vs=ns.extend({method:L(`prompts/list`)}),Hs=rs.extend({prompts:j(Bs)}),Us=V.extend({name:E(),arguments:F(E(),E()).optional()}),Ws=H.extend({method:L(`prompts/get`),params:Us}),Gs=M({type:L(`text`),text:E(),annotations:xs.optional(),_meta:F(E(),A()).optional()}),Ks=M({type:L(`image`),data:vs,mimeType:E(),annotations:xs.optional(),_meta:F(E(),A()).optional()}),qs=M({type:L(`audio`),data:vs,mimeType:E(),annotations:xs.optional(),_meta:F(E(),A()).optional()}),Js=M({type:L(`tool_use`),name:E(),id:E(),input:F(E(),A()),_meta:F(E(),A()).optional()}),Ys=M({type:L(`resource`),resource:P([_s,ys]),annotations:xs.optional(),_meta:F(E(),A()).optional()}),Xs=Ss.extend({type:L(`resource_link`)}),Zs=P([Gs,Ks,qs,Xs,Ys]),Qs=M({role:bs,content:Zs}),$s=G.extend({description:E().optional(),messages:j(Qs)}),ec=W.extend({method:L(`notifications/prompts/list_changed`),params:U.optional()}),tc=M({title:E().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),nc=M({taskSupport:I([`required`,`optional`,`forbidden`]).optional()}),rc=M({...Bo.shape,...zo.shape,description:E().optional(),inputSchema:M({type:L(`object`),properties:F(E(),B).optional(),required:j(E()).optional()}).catchall(A()),outputSchema:M({type:L(`object`),properties:F(E(),B).optional(),required:j(E()).optional()}).catchall(A()).optional(),annotations:tc.optional(),execution:nc.optional(),_meta:F(E(),A()).optional()}),ic=ns.extend({method:L(`tools/list`)}),ac=rs.extend({tools:j(rc)}),oc=G.extend({content:j(Zs).default([]),structuredContent:F(E(),A()).optional(),isError:k().optional()});oc.or(G.extend({toolResult:A()}));var sc=wo.extend({name:E(),arguments:F(E(),A()).optional()}),cc=H.extend({method:L(`tools/call`),params:sc}),lc=W.extend({method:L(`notifications/tools/list_changed`),params:U.optional()});M({autoRefresh:k().default(!0),debounceMs:O().int().nonnegative().default(300)});var uc=I([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),dc=V.extend({level:uc}),fc=H.extend({method:L(`logging/setLevel`),params:dc}),pc=U.extend({level:uc,logger:E().optional(),data:A()}),mc=W.extend({method:L(`notifications/message`),params:pc}),hc=M({hints:j(M({name:E().optional()})).optional(),costPriority:O().min(0).max(1).optional(),speedPriority:O().min(0).max(1).optional(),intelligencePriority:O().min(0).max(1).optional()}),gc=M({mode:I([`auto`,`required`,`none`]).optional()}),_c=M({type:L(`tool_result`),toolUseId:E().describe(`The unique identifier for the corresponding tool call.`),content:j(Zs).default([]),structuredContent:M({}).loose().optional(),isError:k().optional(),_meta:F(E(),A()).optional()}),vc=Ha(`type`,[Gs,Ks,qs]),yc=Ha(`type`,[Gs,Ks,qs,Js,_c]),bc=M({role:bs,content:P([yc,j(yc)]),_meta:F(E(),A()).optional()}),xc=wo.extend({messages:j(bc),modelPreferences:hc.optional(),systemPrompt:E().optional(),includeContext:I([`none`,`thisServer`,`allServers`]).optional(),temperature:O().optional(),maxTokens:O().int(),stopSequences:j(E()).optional(),metadata:B.optional(),tools:j(rc).optional(),toolChoice:gc.optional()}),Sc=H.extend({method:L(`sampling/createMessage`),params:xc}),Cc=G.extend({model:E(),stopReason:R(I([`endTurn`,`stopSequence`,`maxTokens`]).or(E())),role:bs,content:vc}),wc=G.extend({model:E(),stopReason:R(I([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(E())),role:bs,content:P([yc,j(yc)])}),Tc=M({type:L(`boolean`),title:E().optional(),description:E().optional(),default:k().optional()}),Ec=M({type:L(`string`),title:E().optional(),description:E().optional(),minLength:O().optional(),maxLength:O().optional(),format:I([`email`,`uri`,`date`,`date-time`]).optional(),default:E().optional()}),Dc=M({type:I([`number`,`integer`]),title:E().optional(),description:E().optional(),minimum:O().optional(),maximum:O().optional(),default:O().optional()}),Oc=M({type:L(`string`),title:E().optional(),description:E().optional(),enum:j(E()),default:E().optional()}),kc=M({type:L(`string`),title:E().optional(),description:E().optional(),oneOf:j(M({const:E(),title:E()})),default:E().optional()}),Ac=P([P([M({type:L(`string`),title:E().optional(),description:E().optional(),enum:j(E()),enumNames:j(E()).optional(),default:E().optional()}),P([Oc,kc]),P([M({type:L(`array`),title:E().optional(),description:E().optional(),minItems:O().optional(),maxItems:O().optional(),items:M({type:L(`string`),enum:j(E())}),default:j(E()).optional()}),M({type:L(`array`),title:E().optional(),description:E().optional(),minItems:O().optional(),maxItems:O().optional(),items:M({anyOf:j(M({const:E(),title:E()}))}),default:j(E()).optional()})])]),Tc,Ec,Dc]),jc=P([wo.extend({mode:L(`form`).optional(),message:E(),requestedSchema:M({type:L(`object`),properties:F(E(),Ac),required:j(E()).optional()})}),wo.extend({mode:L(`url`),message:E(),elicitationId:E(),url:E().url()})]),Mc=H.extend({method:L(`elicitation/create`),params:jc}),Nc=U.extend({elicitationId:E()}),Pc=W.extend({method:L(`notifications/elicitation/complete`),params:Nc}),Fc=G.extend({action:I([`accept`,`decline`,`cancel`]),content:vo(e=>e===null?void 0:e,F(E(),P([E(),O(),k(),j(E())])).optional())}),Ic=M({type:L(`ref/resource`),uri:E()}),Lc=M({type:L(`ref/prompt`),name:E()}),Rc=V.extend({ref:P([Lc,Ic]),argument:M({name:E(),value:E()}),context:M({arguments:F(E(),E()).optional()}).optional()}),zc=H.extend({method:L(`completion/complete`),params:Rc}),Bc=G.extend({completion:N({values:j(E()).max(100),total:R(O().int()),hasMore:R(k())})}),Vc=M({uri:E().startsWith(`file://`),name:E().optional(),_meta:F(E(),A()).optional()}),Hc=H.extend({method:L(`roots/list`),params:V.optional()}),Uc=G.extend({roots:j(Vc)}),Wc=W.extend({method:L(`notifications/roots/list_changed`),params:U.optional()});P([Zo,qo,zc,fc,Ws,Vs,ws,Es,As,Ps,Is,cc,ic,ls,ds,fs,ms]),P([Ro,es,Xo,Wc,cs]),P([Io,Cc,wc,Fc,Uc,us,ps,os]),P([Zo,Sc,Mc,Hc,ls,ds,fs,ms]),P([Ro,es,mc,Rs,Ms,lc,ec,cs,Pc]),P([Io,Yo,Bc,$s,Hs,Ts,Ds,js,oc,ac,us,ps,os]);var q=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===K.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Gc(e.elicitations,n)}return new e(t,n,r)}},Gc=class extends q{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(K.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Kc(e){return e===`completed`||e===`failed`||e===`cancelled`}function qc(e){let t=Li(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Ri(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Jc(e,t){let n=Ii(e,t);if(!n.success)throw n.error;return n.data}var Yc=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ro,e=>{this._oncancel(e)}),this.setNotificationHandler(es,e=>{this._onprogress(e)}),this.setRequestHandler(Zo,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ls,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new q(K.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(ds,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new q(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new q(K.InvalidParams,`Task not found: ${r}`);if(!Kc(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(Kc(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[z]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(fs,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new q(K.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(ms,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new q(K.InvalidParams,`Task not found: ${e.params.taskId}`);if(Kc(n.status))throw new q(K.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new q(K.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof q?e:new q(K.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),q.fromError(K.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Mo(e)||Po(e)?this._onresponse(e):Oo(e)?this._onrequest(e,t):Ao(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=q.fromError(K.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[z]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:K.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=To(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new q(K.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:K.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),Mo(e)?n(e):n(new q(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(Mo(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),Mo(e)?r(e):r(q.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof q?e:new q(K.InternalError,String(e))}}return}let i;try{let r=await this.request(e,os,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new q(K.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Kc(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new q(K.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new q(K.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof q?e:new q(K.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[z]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof q?e:new q(K.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Ii(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(q.fromError(K.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},us,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},ps,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},hs,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[z]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[z]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[z]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=qc(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Jc(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=qc(e);this._notificationHandlers.set(n,n=>{let r=Jc(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&Oo(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new q(K.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new q(K.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new q(K.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new q(K.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=cs.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Kc(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new q(K.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Kc(a.status))throw new q(K.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=cs.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Kc(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}},Xc=`2026-01-26`,Zc=class{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource){console.debug(`Ignoring message from unknown source`,e);return}let n=Fo.safeParse(e.data);n.success?(console.debug(`Parsed message`,n.data),this.onmessage?.(n.data)):e.data?.jsonrpc===`2.0`?(console.error(`Failed to parse message`,n.error.message,e),this.onerror?.(Error(`Invalid JSON-RPC message received: `+n.error.message))):console.debug(`Ignoring non-JSON-RPC message`,n.error.message,e)}}async start(){window.addEventListener(`message`,this.messageListener)}async send(e,t){e.method!==`ui/notifications/tool-input-partial`&&console.debug(`Sending message`,e),this.eventTarget.postMessage(e,`*`)}async close(){window.removeEventListener(`message`,this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},Qc=P([L(`light`),L(`dark`)]).describe(`Color theme preference for the host environment.`),$c=P([L(`inline`),L(`fullscreen`),L(`pip`)]).describe(`Display mode for UI presentation.`),el=F(P([L(`--color-background-primary`),L(`--color-background-secondary`),L(`--color-background-tertiary`),L(`--color-background-inverse`),L(`--color-background-ghost`),L(`--color-background-info`),L(`--color-background-danger`),L(`--color-background-success`),L(`--color-background-warning`),L(`--color-background-disabled`),L(`--color-text-primary`),L(`--color-text-secondary`),L(`--color-text-tertiary`),L(`--color-text-inverse`),L(`--color-text-ghost`),L(`--color-text-info`),L(`--color-text-danger`),L(`--color-text-success`),L(`--color-text-warning`),L(`--color-text-disabled`),L(`--color-border-primary`),L(`--color-border-secondary`),L(`--color-border-tertiary`),L(`--color-border-inverse`),L(`--color-border-ghost`),L(`--color-border-info`),L(`--color-border-danger`),L(`--color-border-success`),L(`--color-border-warning`),L(`--color-border-disabled`),L(`--color-ring-primary`),L(`--color-ring-secondary`),L(`--color-ring-inverse`),L(`--color-ring-info`),L(`--color-ring-danger`),L(`--color-ring-success`),L(`--color-ring-warning`),L(`--font-sans`),L(`--font-mono`),L(`--font-weight-normal`),L(`--font-weight-medium`),L(`--font-weight-semibold`),L(`--font-weight-bold`),L(`--font-text-xs-size`),L(`--font-text-sm-size`),L(`--font-text-md-size`),L(`--font-text-lg-size`),L(`--font-heading-xs-size`),L(`--font-heading-sm-size`),L(`--font-heading-md-size`),L(`--font-heading-lg-size`),L(`--font-heading-xl-size`),L(`--font-heading-2xl-size`),L(`--font-heading-3xl-size`),L(`--font-text-xs-line-height`),L(`--font-text-sm-line-height`),L(`--font-text-md-line-height`),L(`--font-text-lg-line-height`),L(`--font-heading-xs-line-height`),L(`--font-heading-sm-line-height`),L(`--font-heading-md-line-height`),L(`--font-heading-lg-line-height`),L(`--font-heading-xl-line-height`),L(`--font-heading-2xl-line-height`),L(`--font-heading-3xl-line-height`),L(`--border-radius-xs`),L(`--border-radius-sm`),L(`--border-radius-md`),L(`--border-radius-lg`),L(`--border-radius-xl`),L(`--border-radius-full`),L(`--border-width-regular`),L(`--shadow-hairline`),L(`--shadow-sm`),L(`--shadow-md`),L(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
|
|
406
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ci(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:ui(t,`input`,e.processors),output:ui(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function C(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return C(r.element,n);if(r.type===`set`)return C(r.valueType,n);if(r.type===`lazy`)return C(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return C(r.innerType,n);if(r.type===`intersection`)return C(r.left,n)||C(r.right,n);if(r.type===`record`||r.type===`map`)return C(r.keyType,n)||C(r.valueType,n);if(r.type===`pipe`)return C(r.in,n)||C(r.out,n);if(r.type===`object`){for(let e in r.shape)if(C(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(C(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(C(e,n))return!0;return!!(r.rest&&C(r.rest,n))}return!1}var li=(e,t={})=>n=>{let r=oi({...n,processors:t});return S(e,r),si(r,e),ci(r,e)},ui=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=oi({...i??{},target:a,io:t,processors:n});return S(e,o),si(o,e),ci(o,e)},di={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},fi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=di[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},pi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},mi=(e,t,n,r)=>{n.type=`boolean`},hi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},gi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},_i=(e,t,n,r)=>{n.not={}},vi=(e,t,n,r)=>{let i=e._zod.def,o=a(i.entries);o.every(e=>typeof e==`number`)&&(n.type=`number`),o.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=o},yi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},bi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},xi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Si=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=S(a.element,t,{...r,path:[...r.path,`items`]})},Ci=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=S(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=S(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},wi=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>S(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ti=(e,t,n,r)=>{let i=e._zod.def,a=S(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=S(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Ei=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=S(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=S(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=S(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Di=(e,t,n,r)=>{let i=e._zod.def,a=S(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Oi=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ki=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ai=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},ji=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Mi=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;S(a,t,r);let o=t.seen.get(e);o.ref=a},Ni=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Pi=(e,t,n,r)=>{let i=e._zod.def;S(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType};function Fi(e){return!!e._zod}function Ii(e,t){return Fi(e)?Ae(e,t):e.safeParse(t)}function Li(e){if(!e)return;let t;if(t=Fi(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function Ri(e){if(Fi(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}var zi=e(`ZodISODateTime`,(e,t)=>{Yt.init(e,t),D.init(e,t)});function Bi(e){return wr(zi,e)}var Vi=e(`ZodISODate`,(e,t)=>{Xt.init(e,t),D.init(e,t)});function Hi(e){return Tr(Vi,e)}var Ui=e(`ZodISOTime`,(e,t)=>{Zt.init(e,t),D.init(e,t)});function Wi(e){return Er(Ui,e)}var Gi=e(`ZodISODuration`,(e,t)=>{Qt.init(e,t),D.init(e,t)});function Ki(e){return Dr(Gi,e)}var qi=(e,t)=>{Ce.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ee(e,t)},flatten:{value:t=>Te(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,o,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,o,2)}},isEmpty:{get(){return e.issues.length===0}}})};e(`ZodError`,qi);var w=e(`ZodError`,qi,{Parent:Error}),Ji=De(w),Yi=Oe(w),Xi=ke(w),Zi=je(w),Qi=Ne(w),$i=Pe(w),ea=Fe(w),ta=Ie(w),na=Le(w),ra=Re(w),ia=ze(w),aa=Be(w),T=e(`ZodType`,(e,t)=>(b.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ui(e,`input`),output:ui(e,`output`)}}),e.toJSONSchema=li(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(m(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>se(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Ji(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Xi(e,t,n),e.parseAsync=async(t,n)=>Yi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Zi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Qi(e,t,n),e.decode=(t,n)=>$i(e,t,n),e.encodeAsync=async(t,n)=>ea(e,t,n),e.decodeAsync=async(t,n)=>ta(e,t,n),e.safeEncode=(t,n)=>na(e,t,n),e.safeDecode=(t,n)=>ra(e,t,n),e.safeEncodeAsync=async(t,n)=>ia(e,t,n),e.safeDecodeAsync=async(t,n)=>aa(e,t,n),e.refine=(t,n)=>e.check(go(t,n)),e.superRefine=t=>e.check(_o(t)),e.overwrite=t=>e.check(Yr(t)),e.optional=()=>R(e),e.exactOptional=()=>Qa(e),e.nullable=()=>eo(e),e.nullish=()=>R(eo(e)),e.nonoptional=t=>oo(e,t),e.array=()=>j(e),e.or=t=>P([e,t]),e.and=t=>Wa(e,t),e.transform=t=>uo(e,Ya(t)),e.default=t=>no(e,t),e.prefault=t=>io(e,t),e.catch=t=>co(e,t),e.pipe=t=>uo(e,t),e.readonly=()=>po(e),e.describe=t=>{let n=e.clone();return er.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return er.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return er.get(e);let n=e.clone();return er.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),oa=e(`_ZodString`,(e,t)=>{Lt.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Ur(...t)),e.includes=(...t)=>e.check(Kr(...t)),e.startsWith=(...t)=>e.check(qr(...t)),e.endsWith=(...t)=>e.check(Jr(...t)),e.min=(...t)=>e.check(Vr(...t)),e.max=(...t)=>e.check(Br(...t)),e.length=(...t)=>e.check(Hr(...t)),e.nonempty=(...t)=>e.check(Vr(1,...t)),e.lowercase=t=>e.check(Wr(t)),e.uppercase=t=>e.check(Gr(t)),e.trim=()=>e.check(Zr()),e.normalize=(...t)=>e.check(Xr(...t)),e.toLowerCase=()=>e.check(Qr()),e.toUpperCase=()=>e.check($r()),e.slugify=()=>e.check(ei())}),sa=e(`ZodString`,(e,t)=>{Lt.init(e,t),oa.init(e,t),e.email=t=>e.check(nr(ca,t)),e.url=t=>e.check(cr(da,t)),e.jwt=t=>e.check(Cr(Ea,t)),e.emoji=t=>e.check(lr(fa,t)),e.guid=t=>e.check(rr(la,t)),e.uuid=t=>e.check(ir(ua,t)),e.uuidv4=t=>e.check(ar(ua,t)),e.uuidv6=t=>e.check(or(ua,t)),e.uuidv7=t=>e.check(sr(ua,t)),e.nanoid=t=>e.check(ur(pa,t)),e.guid=t=>e.check(rr(la,t)),e.cuid=t=>e.check(dr(ma,t)),e.cuid2=t=>e.check(fr(ha,t)),e.ulid=t=>e.check(pr(ga,t)),e.base64=t=>e.check(br(Ca,t)),e.base64url=t=>e.check(xr(wa,t)),e.xid=t=>e.check(mr(_a,t)),e.ksuid=t=>e.check(hr(va,t)),e.ipv4=t=>e.check(gr(ya,t)),e.ipv6=t=>e.check(_r(ba,t)),e.cidrv4=t=>e.check(vr(xa,t)),e.cidrv6=t=>e.check(yr(Sa,t)),e.e164=t=>e.check(Sr(Ta,t)),e.datetime=t=>e.check(Bi(t)),e.date=t=>e.check(Hi(t)),e.time=t=>e.check(Wi(t)),e.duration=t=>e.check(Ki(t))});function E(e){return tr(sa,e)}var D=e(`ZodStringFormat`,(e,t)=>{x.init(e,t),oa.init(e,t)}),ca=e(`ZodEmail`,(e,t)=>{Bt.init(e,t),D.init(e,t)}),la=e(`ZodGUID`,(e,t)=>{Rt.init(e,t),D.init(e,t)}),ua=e(`ZodUUID`,(e,t)=>{zt.init(e,t),D.init(e,t)}),da=e(`ZodURL`,(e,t)=>{Vt.init(e,t),D.init(e,t)}),fa=e(`ZodEmoji`,(e,t)=>{Ht.init(e,t),D.init(e,t)}),pa=e(`ZodNanoID`,(e,t)=>{Ut.init(e,t),D.init(e,t)}),ma=e(`ZodCUID`,(e,t)=>{Wt.init(e,t),D.init(e,t)}),ha=e(`ZodCUID2`,(e,t)=>{Gt.init(e,t),D.init(e,t)}),ga=e(`ZodULID`,(e,t)=>{Kt.init(e,t),D.init(e,t)}),_a=e(`ZodXID`,(e,t)=>{qt.init(e,t),D.init(e,t)}),va=e(`ZodKSUID`,(e,t)=>{Jt.init(e,t),D.init(e,t)}),ya=e(`ZodIPv4`,(e,t)=>{$t.init(e,t),D.init(e,t)}),ba=e(`ZodIPv6`,(e,t)=>{en.init(e,t),D.init(e,t)}),xa=e(`ZodCIDRv4`,(e,t)=>{tn.init(e,t),D.init(e,t)}),Sa=e(`ZodCIDRv6`,(e,t)=>{nn.init(e,t),D.init(e,t)}),Ca=e(`ZodBase64`,(e,t)=>{an.init(e,t),D.init(e,t)}),wa=e(`ZodBase64URL`,(e,t)=>{sn.init(e,t),D.init(e,t)}),Ta=e(`ZodE164`,(e,t)=>{cn.init(e,t),D.init(e,t)}),Ea=e(`ZodJWT`,(e,t)=>{un.init(e,t),D.init(e,t)}),Da=e(`ZodNumber`,(e,t)=>{dn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r),e.gt=(t,n)=>e.check(Lr(t,n)),e.gte=(t,n)=>e.check(Rr(t,n)),e.min=(t,n)=>e.check(Rr(t,n)),e.lt=(t,n)=>e.check(Fr(t,n)),e.lte=(t,n)=>e.check(Ir(t,n)),e.max=(t,n)=>e.check(Ir(t,n)),e.int=t=>e.check(ka(t)),e.safe=t=>e.check(ka(t)),e.positive=t=>e.check(Lr(0,t)),e.nonnegative=t=>e.check(Rr(0,t)),e.negative=t=>e.check(Fr(0,t)),e.nonpositive=t=>e.check(Ir(0,t)),e.multipleOf=(t,n)=>e.check(zr(t,n)),e.step=(t,n)=>e.check(zr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function O(e){return Or(Da,e)}var Oa=e(`ZodNumberFormat`,(e,t)=>{fn.init(e,t),Da.init(e,t)});function ka(e){return kr(Oa,e)}var Aa=e(`ZodBoolean`,(e,t)=>{pn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r)});function k(e){return Ar(Aa,e)}var ja=e(`ZodUndefined`,(e,t)=>{mn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(e,t,n,r)});function Ma(e){return jr(ja,e)}var Na=e(`ZodNull`,(e,t)=>{hn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r)});function Pa(e){return Mr(Na,e)}var Fa=e(`ZodUnknown`,(e,t)=>{gn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function A(){return Nr(Fa)}var Ia=e(`ZodNever`,(e,t)=>{_n.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r)});function La(e){return Pr(Ia,e)}var Ra=e(`ZodArray`,(e,t)=>{yn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Vr(t,n)),e.nonempty=t=>e.check(Vr(1,t)),e.max=(t,n)=>e.check(Br(t,n)),e.length=(t,n)=>e.check(Hr(t,n)),e.unwrap=()=>e.element});function j(e,t){return ti(Ra,e,t)}var za=e(`ZodObject`,(e,t)=>{wn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r),f(e,`shape`,()=>t.shape),e.keyof=()=>I(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:A()}),e.loose=()=>e.clone({...e._zod.def,catchall:A()}),e.strict=()=>e.clone({...e._zod.def,catchall:La()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>fe(e,t),e.safeExtend=t=>pe(e,t),e.merge=t=>me(e,t),e.pick=t=>ue(e,t),e.omit=t=>de(e,t),e.partial=(...t)=>he(Xa,e,t[0]),e.required=(...t)=>ge(ao,e,t[0])});function M(e,t){return new za({type:`object`,shape:e??{},..._(t)})}function N(e,t){return new za({type:`object`,shape:e,catchall:A(),..._(t)})}var Ba=e(`ZodUnion`,(e,t)=>{En.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),e.options=t.options});function P(e,t){return new Ba({type:`union`,options:e,..._(t)})}var Va=e(`ZodDiscriminatedUnion`,(e,t)=>{Ba.init(e,t),Dn.init(e,t)});function Ha(e,t,n){return new Va({type:`union`,options:t,discriminator:e,..._(n)})}var Ua=e(`ZodIntersection`,(e,t)=>{On.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r)});function Wa(e,t){return new Ua({type:`intersection`,left:e,right:t})}var Ga=e(`ZodRecord`,(e,t)=>{jn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function F(e,t,n){return new Ga({type:`record`,keyType:e,valueType:t,..._(n)})}var Ka=e(`ZodEnum`,(e,t)=>{Mn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ka({...t,checks:[],..._(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ka({...t,checks:[],..._(r),entries:i})}});function I(e,t){return new Ka({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,..._(t)})}var qa=e(`ZodLiteral`,(e,t)=>{Nn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function L(e,t){return new qa({type:`literal`,values:Array.isArray(e)?e:[e],..._(t)})}var Ja=e(`ZodTransform`,(e,t)=>{Pn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e._zod.parse=(r,i)=>{if(i.direction===`backward`)throw new n(e.constructor.name);r.addIssue=n=>{if(typeof n==`string`)r.issues.push(xe(n,r.value,t));else{let t=n;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=r.value,t.inst??=e,r.issues.push(xe(t))}};let a=t.transform(r.value,r);return a instanceof Promise?a.then(e=>(r.value=e,r)):(r.value=a,r)}});function Ya(e){return new Ja({type:`transform`,transform:e})}var Xa=e(`ZodOptional`,(e,t)=>{In.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function R(e){return new Xa({type:`optional`,innerType:e})}var Za=e(`ZodExactOptional`,(e,t)=>{Ln.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qa(e){return new Za({type:`optional`,innerType:e})}var $a=e(`ZodNullable`,(e,t)=>{Rn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function eo(e){return new $a({type:`nullable`,innerType:e})}var to=e(`ZodDefault`,(e,t)=>{zn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function no(e,t){return new to({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var ro=e(`ZodPrefault`,(e,t)=>{Vn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function io(e,t){return new ro({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var ao=e(`ZodNonOptional`,(e,t)=>{Hn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oo(e,t){return new ao({type:`nonoptional`,innerType:e,..._(t)})}var so=e(`ZodCatch`,(e,t)=>{Wn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function co(e,t){return new so({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var lo=e(`ZodPipe`,(e,t)=>{Gn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),e.in=t.in,e.out=t.out});function uo(e,t){return new lo({type:`pipe`,in:e,out:t})}var fo=e(`ZodReadonly`,(e,t)=>{qn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function po(e){return new fo({type:`readonly`,innerType:e})}var mo=e(`ZodCustom`,(e,t)=>{Yn.init(e,t),T.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r)});function ho(e,t){return ni(mo,e??(()=>!0),t)}function go(e,t={}){return ri(mo,e,t)}function _o(e){return ii(e)}function vo(e,t){return uo(Ya(e),t)}var yo=`io.modelcontextprotocol/related-task`,z=ho(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),bo=P([E(),O().int()]),xo=E();N({ttl:O().optional(),pollInterval:O().optional()});var So=M({ttl:O().optional()}),Co=M({taskId:E()}),wo=N({progressToken:bo.optional(),[yo]:Co.optional()}),B=M({_meta:wo.optional()}),To=B.extend({task:So.optional()}),Eo=e=>To.safeParse(e).success,V=M({method:E(),params:B.loose().optional()}),H=M({_meta:wo.optional()}),U=M({method:E(),params:H.loose().optional()}),W=N({_meta:wo.optional()}),Do=P([E(),O().int()]),Oo=M({jsonrpc:L(`2.0`),id:Do,...V.shape}).strict(),ko=e=>Oo.safeParse(e).success,Ao=M({jsonrpc:L(`2.0`),...U.shape}).strict(),jo=e=>Ao.safeParse(e).success,Mo=M({jsonrpc:L(`2.0`),id:Do,result:W}).strict(),No=e=>Mo.safeParse(e).success,G;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(G||={});var Po=M({jsonrpc:L(`2.0`),id:Do.optional(),error:M({code:O().int(),message:E(),data:A().optional()})}).strict(),Fo=e=>Po.safeParse(e).success,Io=P([Oo,Ao,Mo,Po]);P([Mo,Po]);var Lo=W.strict(),Ro=H.extend({requestId:Do.optional(),reason:E().optional()}),zo=U.extend({method:L(`notifications/cancelled`),params:Ro}),Bo=M({icons:j(M({src:E(),mimeType:E().optional(),sizes:j(E()).optional(),theme:I([`light`,`dark`]).optional()})).optional()}),Vo=M({name:E(),title:E().optional()}),Ho=Vo.extend({...Vo.shape,...Bo.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),Uo=vo(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Wa(M({form:Wa(M({applyDefaults:k().optional()}),F(E(),A())).optional(),url:z.optional()}),F(E(),A()).optional())),Wo=N({list:z.optional(),cancel:z.optional(),requests:N({sampling:N({createMessage:z.optional()}).optional(),elicitation:N({create:z.optional()}).optional()}).optional()}),Go=N({list:z.optional(),cancel:z.optional(),requests:N({tools:N({call:z.optional()}).optional()}).optional()}),Ko=M({experimental:F(E(),z).optional(),sampling:M({context:z.optional(),tools:z.optional()}).optional(),elicitation:Uo.optional(),roots:M({listChanged:k().optional()}).optional(),tasks:Wo.optional(),extensions:F(E(),z).optional()}),qo=B.extend({protocolVersion:E(),capabilities:Ko,clientInfo:Ho}),Jo=V.extend({method:L(`initialize`),params:qo}),Yo=M({experimental:F(E(),z).optional(),logging:z.optional(),completions:z.optional(),prompts:M({listChanged:k().optional()}).optional(),resources:M({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:M({listChanged:k().optional()}).optional(),tasks:Go.optional(),extensions:F(E(),z).optional()}),Xo=W.extend({protocolVersion:E(),capabilities:Yo,serverInfo:Ho,instructions:E().optional()}),Zo=U.extend({method:L(`notifications/initialized`),params:H.optional()}),Qo=V.extend({method:L(`ping`),params:B.optional()}),$o=M({progress:O(),total:R(O()),message:R(E())}),es=M({...H.shape,...$o.shape,progressToken:bo}),ts=U.extend({method:L(`notifications/progress`),params:es}),ns=B.extend({cursor:xo.optional()}),rs=V.extend({params:ns.optional()}),is=W.extend({nextCursor:xo.optional()}),as=I([`working`,`input_required`,`completed`,`failed`,`cancelled`]),os=M({taskId:E(),status:as,ttl:P([O(),Pa()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:R(O()),statusMessage:R(E())}),ss=W.extend({task:os}),cs=H.merge(os),ls=U.extend({method:L(`notifications/tasks/status`),params:cs}),us=V.extend({method:L(`tasks/get`),params:B.extend({taskId:E()})}),ds=W.merge(os),fs=V.extend({method:L(`tasks/result`),params:B.extend({taskId:E()})});W.loose();var ps=rs.extend({method:L(`tasks/list`)}),ms=is.extend({tasks:j(os)}),hs=V.extend({method:L(`tasks/cancel`),params:B.extend({taskId:E()})}),gs=W.merge(os),_s=M({uri:E(),mimeType:R(E()),_meta:F(E(),A()).optional()}),vs=_s.extend({text:E()}),ys=E().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),bs=_s.extend({blob:ys}),xs=I([`user`,`assistant`]),Ss=M({audience:j(xs).optional(),priority:O().min(0).max(1).optional(),lastModified:Bi({offset:!0}).optional()}),Cs=M({...Vo.shape,...Bo.shape,uri:E(),description:R(E()),mimeType:R(E()),size:R(O()),annotations:Ss.optional(),_meta:R(N({}))}),ws=M({...Vo.shape,...Bo.shape,uriTemplate:E(),description:R(E()),mimeType:R(E()),annotations:Ss.optional(),_meta:R(N({}))}),Ts=rs.extend({method:L(`resources/list`)}),Es=is.extend({resources:j(Cs)}),Ds=rs.extend({method:L(`resources/templates/list`)}),Os=is.extend({resourceTemplates:j(ws)}),ks=B.extend({uri:E()}),As=ks,js=V.extend({method:L(`resources/read`),params:As}),Ms=W.extend({contents:j(P([vs,bs]))}),Ns=U.extend({method:L(`notifications/resources/list_changed`),params:H.optional()}),Ps=ks,Fs=V.extend({method:L(`resources/subscribe`),params:Ps}),Is=ks,Ls=V.extend({method:L(`resources/unsubscribe`),params:Is}),Rs=H.extend({uri:E()}),zs=U.extend({method:L(`notifications/resources/updated`),params:Rs}),Bs=M({name:E(),description:R(E()),required:R(k())}),Vs=M({...Vo.shape,...Bo.shape,description:R(E()),arguments:R(j(Bs)),_meta:R(N({}))}),Hs=rs.extend({method:L(`prompts/list`)}),Us=is.extend({prompts:j(Vs)}),Ws=B.extend({name:E(),arguments:F(E(),E()).optional()}),Gs=V.extend({method:L(`prompts/get`),params:Ws}),Ks=M({type:L(`text`),text:E(),annotations:Ss.optional(),_meta:F(E(),A()).optional()}),qs=M({type:L(`image`),data:ys,mimeType:E(),annotations:Ss.optional(),_meta:F(E(),A()).optional()}),Js=M({type:L(`audio`),data:ys,mimeType:E(),annotations:Ss.optional(),_meta:F(E(),A()).optional()}),Ys=M({type:L(`tool_use`),name:E(),id:E(),input:F(E(),A()),_meta:F(E(),A()).optional()}),Xs=M({type:L(`resource`),resource:P([vs,bs]),annotations:Ss.optional(),_meta:F(E(),A()).optional()}),Zs=Cs.extend({type:L(`resource_link`)}),Qs=P([Ks,qs,Js,Zs,Xs]),$s=M({role:xs,content:Qs}),ec=W.extend({description:E().optional(),messages:j($s)}),tc=U.extend({method:L(`notifications/prompts/list_changed`),params:H.optional()}),nc=M({title:E().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),rc=M({taskSupport:I([`required`,`optional`,`forbidden`]).optional()}),ic=M({...Vo.shape,...Bo.shape,description:E().optional(),inputSchema:M({type:L(`object`),properties:F(E(),z).optional(),required:j(E()).optional()}).catchall(A()),outputSchema:M({type:L(`object`),properties:F(E(),z).optional(),required:j(E()).optional()}).catchall(A()).optional(),annotations:nc.optional(),execution:rc.optional(),_meta:F(E(),A()).optional()}),ac=rs.extend({method:L(`tools/list`)}),oc=is.extend({tools:j(ic)}),sc=W.extend({content:j(Qs).default([]),structuredContent:F(E(),A()).optional(),isError:k().optional()});sc.or(W.extend({toolResult:A()}));var cc=To.extend({name:E(),arguments:F(E(),A()).optional()}),lc=V.extend({method:L(`tools/call`),params:cc}),uc=U.extend({method:L(`notifications/tools/list_changed`),params:H.optional()});M({autoRefresh:k().default(!0),debounceMs:O().int().nonnegative().default(300)});var dc=I([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),fc=B.extend({level:dc}),pc=V.extend({method:L(`logging/setLevel`),params:fc}),mc=H.extend({level:dc,logger:E().optional(),data:A()}),hc=U.extend({method:L(`notifications/message`),params:mc}),gc=M({hints:j(M({name:E().optional()})).optional(),costPriority:O().min(0).max(1).optional(),speedPriority:O().min(0).max(1).optional(),intelligencePriority:O().min(0).max(1).optional()}),_c=M({mode:I([`auto`,`required`,`none`]).optional()}),vc=M({type:L(`tool_result`),toolUseId:E().describe(`The unique identifier for the corresponding tool call.`),content:j(Qs).default([]),structuredContent:M({}).loose().optional(),isError:k().optional(),_meta:F(E(),A()).optional()}),yc=Ha(`type`,[Ks,qs,Js]),bc=Ha(`type`,[Ks,qs,Js,Ys,vc]),xc=M({role:xs,content:P([bc,j(bc)]),_meta:F(E(),A()).optional()}),Sc=To.extend({messages:j(xc),modelPreferences:gc.optional(),systemPrompt:E().optional(),includeContext:I([`none`,`thisServer`,`allServers`]).optional(),temperature:O().optional(),maxTokens:O().int(),stopSequences:j(E()).optional(),metadata:z.optional(),tools:j(ic).optional(),toolChoice:_c.optional()}),Cc=V.extend({method:L(`sampling/createMessage`),params:Sc}),wc=W.extend({model:E(),stopReason:R(I([`endTurn`,`stopSequence`,`maxTokens`]).or(E())),role:xs,content:yc}),Tc=W.extend({model:E(),stopReason:R(I([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(E())),role:xs,content:P([bc,j(bc)])}),Ec=M({type:L(`boolean`),title:E().optional(),description:E().optional(),default:k().optional()}),Dc=M({type:L(`string`),title:E().optional(),description:E().optional(),minLength:O().optional(),maxLength:O().optional(),format:I([`email`,`uri`,`date`,`date-time`]).optional(),default:E().optional()}),Oc=M({type:I([`number`,`integer`]),title:E().optional(),description:E().optional(),minimum:O().optional(),maximum:O().optional(),default:O().optional()}),kc=M({type:L(`string`),title:E().optional(),description:E().optional(),enum:j(E()),default:E().optional()}),Ac=M({type:L(`string`),title:E().optional(),description:E().optional(),oneOf:j(M({const:E(),title:E()})),default:E().optional()}),jc=P([P([M({type:L(`string`),title:E().optional(),description:E().optional(),enum:j(E()),enumNames:j(E()).optional(),default:E().optional()}),P([kc,Ac]),P([M({type:L(`array`),title:E().optional(),description:E().optional(),minItems:O().optional(),maxItems:O().optional(),items:M({type:L(`string`),enum:j(E())}),default:j(E()).optional()}),M({type:L(`array`),title:E().optional(),description:E().optional(),minItems:O().optional(),maxItems:O().optional(),items:M({anyOf:j(M({const:E(),title:E()}))}),default:j(E()).optional()})])]),Ec,Dc,Oc]),Mc=P([To.extend({mode:L(`form`).optional(),message:E(),requestedSchema:M({type:L(`object`),properties:F(E(),jc),required:j(E()).optional()})}),To.extend({mode:L(`url`),message:E(),elicitationId:E(),url:E().url()})]),Nc=V.extend({method:L(`elicitation/create`),params:Mc}),Pc=H.extend({elicitationId:E()}),Fc=U.extend({method:L(`notifications/elicitation/complete`),params:Pc}),Ic=W.extend({action:I([`accept`,`decline`,`cancel`]),content:vo(e=>e===null?void 0:e,F(E(),P([E(),O(),k(),j(E())])).optional())}),Lc=M({type:L(`ref/resource`),uri:E()}),Rc=M({type:L(`ref/prompt`),name:E()}),zc=B.extend({ref:P([Rc,Lc]),argument:M({name:E(),value:E()}),context:M({arguments:F(E(),E()).optional()}).optional()}),Bc=V.extend({method:L(`completion/complete`),params:zc}),Vc=W.extend({completion:N({values:j(E()).max(100),total:R(O().int()),hasMore:R(k())})}),Hc=M({uri:E().startsWith(`file://`),name:E().optional(),_meta:F(E(),A()).optional()}),Uc=V.extend({method:L(`roots/list`),params:B.optional()}),Wc=W.extend({roots:j(Hc)}),Gc=U.extend({method:L(`notifications/roots/list_changed`),params:H.optional()});P([Qo,Jo,Bc,pc,Gs,Hs,Ts,Ds,js,Fs,Ls,lc,ac,us,fs,ps,hs]),P([zo,ts,Zo,Gc,ls]),P([Lo,wc,Tc,Ic,Wc,ds,ms,ss]),P([Qo,Cc,Nc,Uc,us,fs,ps,hs]),P([zo,ts,hc,zs,Ns,uc,tc,ls,Fc]),P([Lo,Xo,Vc,ec,Us,Es,Os,Ms,sc,oc,ds,ms,ss]);var K=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===G.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Kc(e.elicitations,n)}return new e(t,n,r)}},Kc=class extends K{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(G.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function qc(e){return e===`completed`||e===`failed`||e===`cancelled`}function Jc(e){let t=Li(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Ri(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Yc(e,t){let n=Ii(e,t);if(!n.success)throw n.error;return n.data}var Xc=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(zo,e=>{this._oncancel(e)}),this.setNotificationHandler(ts,e=>{this._onprogress(e)}),this.setRequestHandler(Qo,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(us,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new K(G.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(fs,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new K(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new K(G.InvalidParams,`Task not found: ${r}`);if(!qc(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(qc(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[yo]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(ps,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new K(G.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(hs,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new K(G.InvalidParams,`Task not found: ${e.params.taskId}`);if(qc(n.status))throw new K(G.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new K(G.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof K?e:new K(G.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),K.fromError(G.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),No(e)||Fo(e)?this._onresponse(e):ko(e)?this._onrequest(e,t):jo(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=K.fromError(G.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[yo]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:G.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=Eo(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new K(G.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:G.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),No(e)?n(e):n(new K(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(No(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),No(e)?r(e):r(K.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof K?e:new K(G.InternalError,String(e))}}return}let i;try{let r=await this.request(e,ss,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new K(G.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},qc(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new K(G.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new K(G.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof K?e:new K(G.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[yo]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof K?e:new K(G.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Ii(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(K.fromError(G.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},ds,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},ms,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},gs,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[yo]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[yo]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[yo]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Jc(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Yc(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Jc(e);this._notificationHandlers.set(n,n=>{let r=Yc(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&ko(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new K(G.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new K(G.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new K(G.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new K(G.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=ls.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),qc(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new K(G.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(qc(a.status))throw new K(G.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=ls.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),qc(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}},Zc=`2026-01-26`,Qc=class{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource){console.debug(`Ignoring message from unknown source`,e);return}let n=Io.safeParse(e.data);n.success?(console.debug(`Parsed message`,n.data),this.onmessage?.(n.data)):e.data?.jsonrpc===`2.0`?(console.error(`Failed to parse message`,n.error.message,e),this.onerror?.(Error(`Invalid JSON-RPC message received: `+n.error.message))):console.debug(`Ignoring non-JSON-RPC message`,n.error.message,e)}}async start(){window.addEventListener(`message`,this.messageListener)}async send(e,t){e.method!==`ui/notifications/tool-input-partial`&&console.debug(`Sending message`,e),this.eventTarget.postMessage(e,`*`)}async close(){window.removeEventListener(`message`,this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},$c=P([L(`light`),L(`dark`)]).describe(`Color theme preference for the host environment.`),el=P([L(`inline`),L(`fullscreen`),L(`pip`)]).describe(`Display mode for UI presentation.`),tl=F(P([L(`--color-background-primary`),L(`--color-background-secondary`),L(`--color-background-tertiary`),L(`--color-background-inverse`),L(`--color-background-ghost`),L(`--color-background-info`),L(`--color-background-danger`),L(`--color-background-success`),L(`--color-background-warning`),L(`--color-background-disabled`),L(`--color-text-primary`),L(`--color-text-secondary`),L(`--color-text-tertiary`),L(`--color-text-inverse`),L(`--color-text-ghost`),L(`--color-text-info`),L(`--color-text-danger`),L(`--color-text-success`),L(`--color-text-warning`),L(`--color-text-disabled`),L(`--color-border-primary`),L(`--color-border-secondary`),L(`--color-border-tertiary`),L(`--color-border-inverse`),L(`--color-border-ghost`),L(`--color-border-info`),L(`--color-border-danger`),L(`--color-border-success`),L(`--color-border-warning`),L(`--color-border-disabled`),L(`--color-ring-primary`),L(`--color-ring-secondary`),L(`--color-ring-inverse`),L(`--color-ring-info`),L(`--color-ring-danger`),L(`--color-ring-success`),L(`--color-ring-warning`),L(`--font-sans`),L(`--font-mono`),L(`--font-weight-normal`),L(`--font-weight-medium`),L(`--font-weight-semibold`),L(`--font-weight-bold`),L(`--font-text-xs-size`),L(`--font-text-sm-size`),L(`--font-text-md-size`),L(`--font-text-lg-size`),L(`--font-heading-xs-size`),L(`--font-heading-sm-size`),L(`--font-heading-md-size`),L(`--font-heading-lg-size`),L(`--font-heading-xl-size`),L(`--font-heading-2xl-size`),L(`--font-heading-3xl-size`),L(`--font-text-xs-line-height`),L(`--font-text-sm-line-height`),L(`--font-text-md-line-height`),L(`--font-text-lg-line-height`),L(`--font-heading-xs-line-height`),L(`--font-heading-sm-line-height`),L(`--font-heading-md-line-height`),L(`--font-heading-lg-line-height`),L(`--font-heading-xl-line-height`),L(`--font-heading-2xl-line-height`),L(`--font-heading-3xl-line-height`),L(`--border-radius-xs`),L(`--border-radius-sm`),L(`--border-radius-md`),L(`--border-radius-lg`),L(`--border-radius-xl`),L(`--border-radius-full`),L(`--border-width-regular`),L(`--shadow-hairline`),L(`--shadow-sm`),L(`--shadow-md`),L(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
|
|
392
407
|
|
|
393
408
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
394
409
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -406,10 +421,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
406
421
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
407
422
|
|
|
408
423
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
409
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);M({method:L(`ui/open-link`),params:M({url:E().describe(`URL to open in the host's browser`)})});var
|
|
424
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);M({method:L(`ui/open-link`),params:M({url:E().describe(`URL to open in the host's browser`)})});var nl=M({isError:k().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),rl=M({isError:k().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),il=M({isError:k().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough();M({method:L(`ui/notifications/sandbox-proxy-ready`),params:M({})});var al=M({connectDomains:j(E()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
410
425
|
|
|
411
426
|
- Maps to CSP \`connect-src\` directive
|
|
412
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:j(E()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:j(E()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:j(E()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),
|
|
427
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:j(E()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:j(E()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:j(E()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),ol=M({camera:M({}).optional().describe(`Request camera access.
|
|
413
428
|
|
|
414
429
|
Maps to Permission Policy \`camera\` feature.`),microphone:M({}).optional().describe(`Request microphone access.
|
|
415
430
|
|
|
@@ -417,7 +432,7 @@ Maps to Permission Policy \`microphone\` feature.`),geolocation:M({}).optional()
|
|
|
417
432
|
|
|
418
433
|
Maps to Permission Policy \`geolocation\` feature.`),clipboardWrite:M({}).optional().describe(`Request clipboard write access.
|
|
419
434
|
|
|
420
|
-
Maps to Permission Policy \`clipboard-write\` feature.`)});M({method:L(`ui/notifications/size-changed`),params:M({width:O().optional().describe(`New width in pixels.`),height:O().optional().describe(`New height in pixels.`)})});var
|
|
435
|
+
Maps to Permission Policy \`clipboard-write\` feature.`)});M({method:L(`ui/notifications/size-changed`),params:M({width:O().optional().describe(`New width in pixels.`),height:O().optional().describe(`New height in pixels.`)})});var sl=M({method:L(`ui/notifications/tool-input`),params:M({arguments:F(E(),A().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),cl=M({method:L(`ui/notifications/tool-input-partial`),params:M({arguments:F(E(),A().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),ll=M({method:L(`ui/notifications/tool-cancelled`),params:M({reason:E().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})}),ul=M({fonts:E().optional()}),dl=M({variables:tl.optional().describe(`CSS variables for theming the app.`),css:ul.optional().describe(`CSS blocks that apps can inject.`)}),fl=M({method:L(`ui/resource-teardown`),params:M({})});F(E(),A());var pl=M({text:M({}).optional().describe(`Host supports text content blocks.`),image:M({}).optional().describe(`Host supports image content blocks.`),audio:M({}).optional().describe(`Host supports audio content blocks.`),resource:M({}).optional().describe(`Host supports resource content blocks.`),resourceLink:M({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:M({}).optional().describe(`Host supports structured content.`)});M({method:L(`ui/notifications/request-teardown`),params:M({}).optional()});var ml=M({experimental:M({}).optional().describe(`Experimental features (structure TBD).`),openLinks:M({}).optional().describe(`Host supports opening external URLs.`),downloadFile:M({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:M({listChanged:k().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:M({listChanged:k().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:M({}).optional().describe(`Host accepts log messages.`),sandbox:M({permissions:ol.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:al.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:pl.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:pl.optional().describe(`Host supports receiving content messages (ui/message) from the view.`)}),hl=M({experimental:M({}).optional().describe(`Experimental features (structure TBD).`),tools:M({listChanged:k().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:j(el).optional().describe(`Display modes the app supports.`)});M({method:L(`ui/notifications/initialized`),params:M({}).optional()}),M({csp:al.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:ol.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:E().optional().describe(`Dedicated origin for view sandbox.
|
|
421
436
|
|
|
422
437
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
423
438
|
|
|
@@ -431,12 +446,23 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
431
446
|
|
|
432
447
|
- \`true\`: request visible border + background
|
|
433
448
|
- \`false\`: request no visible border + background
|
|
434
|
-
- omitted: host decides border`)}),M({method:L(`ui/request-display-mode`),params:M({mode
|
|
449
|
+
- omitted: host decides border`)}),M({method:L(`ui/request-display-mode`),params:M({mode:el.describe(`The display mode being requested.`)})});var gl=M({mode:el.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),_l=P([L(`model`),L(`app`)]).describe(`Tool visibility scope - who can access the tool.`);M({resourceUri:E().optional(),visibility:j(_l).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
435
450
|
- "model": Tool visible to and callable by the agent
|
|
436
|
-
- "app": Tool callable by the app from this server only`)}),M({mimeTypes:j(E()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),M({method:L(`ui/download-file`),params:M({contents:j(P([
|
|
437
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:E().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:E().optional().describe(`User's timezone in IANA format.`),userAgent:E().optional().describe(`Host application identifier.`),platform:P([L(`web`),L(`desktop`),L(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:M({touch:k().optional().describe(`Whether the device supports touch input.`),hover:k().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:M({top:O().describe(`Top safe area inset in pixels.`),right:O().describe(`Right safe area inset in pixels.`),bottom:O().describe(`Bottom safe area inset in pixels.`),left:O().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),
|
|
438
|
-
|
|
439
|
-
|
|
451
|
+
- "app": Tool callable by the app from this server only`)}),M({mimeTypes:j(E()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),M({method:L(`ui/download-file`),params:M({contents:j(P([Xs,Zs])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),M({method:L(`ui/message`),params:M({role:L(`user`).describe(`Message role, currently only "user" is supported.`),content:j(Qs).describe(`Message content blocks (text, image, etc.).`)})}),M({method:L(`ui/notifications/sandbox-resource-ready`),params:M({html:E().describe(`HTML content to load into the inner iframe.`),sandbox:E().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:al.optional().describe(`CSP configuration from resource metadata.`),permissions:ol.optional().describe(`Sandbox permissions from resource metadata.`)})});var vl=M({method:L(`ui/notifications/tool-result`),params:sc.describe(`Standard MCP tool execution result.`)}),yl=M({toolInfo:M({id:Do.optional().describe(`JSON-RPC id of the tools/call request.`),tool:ic.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:$c.optional().describe(`Current color theme preference.`),styles:dl.optional().describe(`Style configuration for theming the app.`),displayMode:el.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:j(el).optional().describe(`Display modes the host supports.`),containerDimensions:P([M({height:O().describe(`Fixed container height in pixels.`)}),M({maxHeight:P([O(),Ma()]).optional().describe(`Maximum container height in pixels.`)})]).and(P([M({width:O().describe(`Fixed container width in pixels.`)}),M({maxWidth:P([O(),Ma()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
452
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:E().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:E().optional().describe(`User's timezone in IANA format.`),userAgent:E().optional().describe(`Host application identifier.`),platform:P([L(`web`),L(`desktop`),L(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:M({touch:k().optional().describe(`Whether the device supports touch input.`),hover:k().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:M({top:O().describe(`Top safe area inset in pixels.`),right:O().describe(`Right safe area inset in pixels.`),bottom:O().describe(`Bottom safe area inset in pixels.`),left:O().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),bl=M({method:L(`ui/notifications/host-context-changed`),params:yl.describe(`Partial context update containing only changed fields.`)});M({method:L(`ui/update-model-context`),params:M({content:j(Qs).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:F(E(),A().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),M({method:L(`ui/initialize`),params:M({appInfo:Ho.describe(`App identification (name and version).`),appCapabilities:hl.describe(`Features and capabilities this app provides.`),protocolVersion:E().describe(`Protocol version this app supports.`)})});var xl=M({protocolVersion:E().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Ho.describe(`Host application identification and version.`),hostCapabilities:ml.describe(`Features and capabilities provided by the host.`),hostContext:yl.describe(`Rich context about the host environment.`)}).passthrough();function Sl(){let e=document.documentElement.getAttribute(`data-theme`);return e===`dark`||e===`light`?e:document.documentElement.classList.contains(`dark`)?`dark`:`light`}function Cl(e){let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e}function wl(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}var Tl=class extends Xc{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,this.setRequestHandler(Qo,e=>(console.log(`Received ping:`,e.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(e){this.setNotificationHandler(sl,t=>e(t.params))}set ontoolinputpartial(e){this.setNotificationHandler(cl,t=>e(t.params))}set ontoolresult(e){this.setNotificationHandler(vl,t=>e(t.params))}set ontoolcancelled(e){this.setNotificationHandler(ll,t=>e(t.params))}set onhostcontextchanged(e){this.setNotificationHandler(bl,t=>{this._hostContext={...this._hostContext,...t.params},e(t.params)})}set onteardown(e){this.setRequestHandler(fl,(t,n)=>e(t.params,n))}set oncalltool(e){this.setRequestHandler(lc,(t,n)=>e(t.params,n))}set onlisttools(e){this.setRequestHandler(ac,(t,n)=>e(t.params,n))}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}async callServerTool(e,t){if(typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},sc,t)}async readServerResource(e,t){return await this.request({method:`resources/read`,params:e},Ms,t)}async listServerResources(e,t){return await this.request({method:`resources/list`,params:e},Es,t)}sendMessage(e,t){return this.request({method:`ui/message`,params:e},il,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this.request({method:`ui/update-model-context`,params:e},Lo,t)}openLink(e,t){return this.request({method:`ui/open-link`,params:e},nl,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this.request({method:`ui/download-file`,params:e},rl,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this.request({method:`ui/request-display-mode`,params:e},gl,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new Qc(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:Zc}},xl,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.hostContext,await this.notification({method:`ui/notifications/initialized`}),this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}},El=new Set;function q(e,t){if(El.has(e))return;El.add(e);let n=document.createElement(`style`);n.textContent=t,document.head.appendChild(n)}function Dl(e){let t=Y(e);return t=t.replace(/```(\w*)\n([\s\S]*?)```/g,(e,t,n)=>`<pre><code class="language-${t}">${n.trim()}</code></pre>`),t=t.replace(/`([^`]+)`/g,`<code>$1</code>`),t=t.replace(/^######\s+(.+)$/gm,`<h6>$1</h6>`),t=t.replace(/^#####\s+(.+)$/gm,`<h5>$1</h5>`),t=t.replace(/^####\s+(.+)$/gm,`<h4>$1</h4>`),t=t.replace(/^###\s+(.+)$/gm,`<h3>$1</h3>`),t=t.replace(/^##\s+(.+)$/gm,`<h2>$1</h2>`),t=t.replace(/^#\s+(.+)$/gm,`<h1>$1</h1>`),t=t.replace(/\*\*\*(.+?)\*\*\*/g,`<strong><em>$1</em></strong>`),t=t.replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`),t=t.replace(/\*(.+?)\*/g,`<em>$1</em>`),t=t.replace(/^>\s+(.+)$/gm,`<blockquote>$1</blockquote>`),t=t.replace(/^(\s*)[-*]\s+(.+)$/gm,`$1<li>$2</li>`),t=t.replace(/((?:<li>.*<\/li>\n?)+)/g,`<ul>$1</ul>`),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,n)=>{let r=Ol(n);return r?`<a href="${r}" target="_blank" rel="noopener">${t}</a>`:t}),t=t.replace(/\n\n+/g,`</p><p>`),t=`<p>${t}</p>`,t=t.replace(/<p>\s*<(h[1-6]|ul|ol|pre|blockquote)/g,`<$1`),t=t.replace(/<\/(h[1-6]|ul|ol|pre|blockquote)>\s*<\/p>/g,`</$1>`),t}function J(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n&&(r.textContent=n),r}function Ol(e){let t=e.trim();return/^https?:\/\//i.test(t)||/^mailto:/i.test(t)?t:/^[a-z][a-z0-9+.-]*:/i.test(t)?null:t}function Y(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}function kl(e){return e==null?`null`:Array.isArray(e)?`[${e.map(kl).join(`, `)}]`:String(e)}function Al(e){return e.replace(/[^a-zA-Z0-9_]/g,`_`)}function jl(e){return typeof e==`object`&&!!e&&`type`in e}function Ml(e){return Math.abs(e)>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:Number.isInteger(e)?String(e):e.toFixed(1)}function Nl(e){return`var(--chart-${e%12+1})`}var Pl=0,X={top:20,right:20,bottom:35,left:55},Fl=600;function Il(e,t){return e.map(e=>Number(e[t])||0)}function Ll(e,t){return e.map(e=>String(e[t]??``))}function Rl(e){let t=1/0,n=-1/0;for(let r of e)r<t&&(t=r),r>n&&(n=r);return t===n&&(t=t===0?0:t*.9,n=n===0?1:n*1.1),[t,n]}function zl(e){return e>=0?0:e}function Bl(e,t,n,r=5){let i=[];for(let a=0;a<=r;a++){let o=a/r,s=X.top+n-o*n,c=e+o*(t-e);i.push(`<line class="chart-grid-line" x1="${X.left}" x2="${Fl-X.right}" y1="${s}" y2="${s}"/>`),i.push(`<text class="chart-axis-label" x="${X.left-8}" y="${s+4}" text-anchor="end">${Ml(c)}</text>`)}return i.join(``)}function Vl(e,t,n,r){let i=Math.floor(t/50),a=Math.max(1,Math.ceil(e.length/i));return e.map((e,t)=>t%a===0?`<text class="chart-axis-label" x="${X.left+t*r+r/2}" y="${X.top+n+18}" text-anchor="middle">${Y(e.length>10?`${e.slice(0,9)}…`:e)}</text>`:``).join(``)}function Hl(e,t){let n=(e.height??300)-X.top-X.bottom,r=Fl-X.left-X.right,i=Ll(e.data,e.xKey),a=e.data.length;if(a===0)return``;let o=r/Math.max(a-1,1),s=1/0,c=-1/0;for(let t of e.yKeys){let[n,r]=Rl(Il(e.data,t));n<s&&(s=n),r>c&&(c=r)}s=zl(s);let l=c-s||1,u=e=>X.top+n-(e-s)/l*n,d=e=>X.left+e*o,f=``,p=[];for(let r=0;r<e.yKeys.length;r++){let i=Il(e.data,e.yKeys[r]),o=Nl(r),s=`M${i.map((e,t)=>`${d(t).toFixed(1)},${u(e).toFixed(1)}`).join(`L`)}`;if(t){let e=`ag${Pl}_${r}`;f+=`<linearGradient id="${e}" x1="0" y1="0" x2="0" y2="1">
|
|
453
|
+
<stop offset="0%" stop-color="${o}" stop-opacity="0.3"/>
|
|
454
|
+
<stop offset="100%" stop-color="${o}" stop-opacity="0"/>
|
|
455
|
+
</linearGradient>`;let t=`${s}L${d(a-1).toFixed(1)},${(X.top+n).toFixed(1)}L${d(0).toFixed(1)},${(X.top+n).toFixed(1)}Z`;p.push(`<path d="${t}" fill="url(#${e})" stroke="none"/>`)}p.push(`<path d="${s}" fill="none" stroke="${o}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`);for(let e=0;e<i.length;e++)p.push(`<circle cx="${d(e).toFixed(1)}" cy="${u(i[e]).toFixed(1)}" r="3" fill="${o}" stroke="var(--bg)" stroke-width="1.5"/>`)}let m=e.height??300,h=e.showGrid===!1?``:Bl(s,c,n),ee=Vl(i,r,n,a>1?o:r);return`<svg class="chart-svg" viewBox="0 0 ${Fl} ${m}" preserveAspectRatio="xMidYMid meet">
|
|
456
|
+
${f?`<defs>${f}</defs>`:``}
|
|
457
|
+
${h}${ee}${p.join(``)}
|
|
458
|
+
</svg>`}function Ul(e,t){let n=(e.height??300)-X.top-X.bottom,r=Fl-X.left-X.right,i=Ll(e.data,e.xKey),a=e.data.length;if(a===0)return``;let o=e.yKeys.length,s=0;for(let t of e.yKeys)for(let n of Il(e.data,t))n>s&&(s=n);s===0&&(s=1);let c=e.height??300,l=[];if(t){let t=Math.min(24,(n-(a-1)*4)/(a*o)),u=t*o+4,d=e.showGrid===!1?``:Bl(0,s,n),f=i.map((e,t)=>{let n=X.top+t*u+u/2,r=e.length>15?`${e.slice(0,14)}…`:e;return`<text class="chart-axis-label" x="${X.left-8}" y="${n+4}" text-anchor="end">${Y(r)}</text>`}).join(``);for(let n=0;n<a;n++)for(let i=0;i<o;i++){let a=Number(e.data[n][e.yKeys[i]])||0,o=a/s*r,c=X.top+n*u+i*t;l.push(`<rect x="${X.left}" y="${c}" width="${o.toFixed(1)}" height="${t-2}" rx="3" fill="${Nl(i)}" opacity="0.85"><title>${Y(e.yKeys[i])}: ${Ml(a)}</title></rect>`)}return`<svg class="chart-svg" viewBox="0 0 ${Fl} ${Math.max(c,a*u+X.top+X.bottom)}" preserveAspectRatio="xMidYMid meet">${d}${f}${l.join(``)}</svg>`}else{let t=r/a,u=Math.min(40,(t-8)/o),d=e.showGrid===!1?``:Bl(0,s,n),f=Vl(i,r,n,t);for(let r=0;r<a;r++)for(let i=0;i<o;i++){let a=Number(e.data[r][e.yKeys[i]])||0,c=a/s*n,d=X.left+r*t+(t-u*o)/2+i*u,f=X.top+n-c;l.push(`<rect x="${d.toFixed(1)}" y="${f.toFixed(1)}" width="${(u-2).toFixed(1)}" height="${c.toFixed(1)}" rx="3" fill="${Nl(i)}" opacity="0.85"><title>${Y(e.yKeys[i])}: ${Ml(a)}</title></rect>`)}return`<svg class="chart-svg" viewBox="0 0 ${Fl} ${c}" preserveAspectRatio="xMidYMid meet">${d}${f}${l.join(``)}</svg>`}}function Wl(e,t){let n=e.height??300,r=n/2,i=n/2,a=n/2-10,o=t?a*.55:0,s=e.yKeys[0]||`value`,c=e.data.map(e=>Math.max(0,Number(e[s])||0)),l=Ll(e.data,e.xKey),u=c.reduce((e,t)=>e+t,0);if(u===0)return`<div style="text-align:center;padding:20px;opacity:0.6">No data</div>`;let d=[],f=-Math.PI/2;for(let e=0;e<c.length;e++){let t=c[e]/u;if(t===0)continue;let n=t*Math.PI*2,s=f,p=f+n,m=r+a*Math.cos(s),h=i+a*Math.sin(s),ee=r+a*Math.cos(p),te=i+a*Math.sin(p),g=n>Math.PI?1:0,ne;if(o>0){let e=r+o*Math.cos(s),t=i+o*Math.sin(s),n=r+o*Math.cos(p),c=i+o*Math.sin(p);ne=`M${m.toFixed(2)},${h.toFixed(2)} A${a},${a} 0 ${g},1 ${ee.toFixed(2)},${te.toFixed(2)} L${n.toFixed(2)},${c.toFixed(2)} A${o},${o} 0 ${g},0 ${e.toFixed(2)},${t.toFixed(2)}Z`}else ne=`M${r},${i} L${m.toFixed(2)},${h.toFixed(2)} A${a},${a} 0 ${g},1 ${ee.toFixed(2)},${te.toFixed(2)}Z`;d.push(`<path d="${ne}" fill="${Nl(e)}" stroke="var(--bg)" stroke-width="2" opacity="0.9"><title>${Y(l[e]||`Item ${e+1}`)}: ${Ml(c[e])} (${(t*100).toFixed(1)}%)</title></path>`),f=p}let p=t?`<text x="${r}" y="${i-6}" text-anchor="middle" fill="var(--fg)" font-size="18" font-weight="700">${Ml(u)}</text><text x="${r}" y="${i+12}" text-anchor="middle" fill="var(--fg)" font-size="11" opacity="0.6">Total</text>`:``,m=ql(l.filter((e,t)=>c[t]>0));return`<svg class="chart-svg" viewBox="0 0 ${n} ${n}" preserveAspectRatio="xMidYMid meet">${d.join(``)}${p}</svg>${m}`}function Gl(e){let t=e.height??40,n=e.yKeys[0]||`value`,r=Il(e.data,n),i=r.length;if(i===0)return``;let[a,o]=Rl(r),s=o-a||1,c=200/Math.max(i-1,1),l=r.map((e,n)=>`${(n*c).toFixed(1)},${(t-4-(e-a)/s*(t-8)).toFixed(1)}`),u=`spk${Pl}`,d=Nl(0);return`<svg class="chart-svg" viewBox="0 0 200 ${t}" preserveAspectRatio="xMidYMid meet" style="max-width:200px;height:${t}px">
|
|
459
|
+
<defs><linearGradient id="${u}" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="${d}" stop-opacity="0.2"/><stop offset="100%" stop-color="${d}" stop-opacity="0"/></linearGradient></defs>
|
|
460
|
+
<path d="M${l.join(`L`)}L${((i-1)*c).toFixed(1)},${t}L0,${t}Z" fill="url(#${u})" stroke="none"/>
|
|
461
|
+
<polyline points="${l.join(` `)}" fill="none" stroke="${d}" stroke-width="1.5" stroke-linejoin="round"/>
|
|
462
|
+
<circle cx="${((i-1)*c).toFixed(1)}" cy="${l[i-1].split(`,`)[1]}" r="2.5" fill="${d}"/>
|
|
463
|
+
</svg>`}function Kl(e){let t=Ll(e.data,e.xKey),n=e.data.length,r=e.yKeys.length;if(n===0||r===0)return``;let i=1/0,a=-1/0;for(let t of e.yKeys)for(let n of Il(e.data,t))n<i&&(i=n),n>a&&(a=n);let o=a-i||1,s=Math.min(50,(Fl-X.left-X.right)/n),c=Math.min(30,200/r),l=X.left+n*s+X.right,u=X.top+r*c+X.bottom,d=[];for(let t=0;t<r;t++){let n=X.top+t*c+c/2+4,r=e.yKeys[t].length>8?`${e.yKeys[t].slice(0,7)}…`:e.yKeys[t];d.push(`<text class="chart-axis-label" x="${X.left-8}" y="${n}" text-anchor="end">${Y(r)}</text>`)}let f=Math.floor((l-X.left)/40),p=Math.max(1,Math.ceil(n/f));for(let e=0;e<n;e++){if(e%p!==0)continue;let n=X.left+e*s+s/2,r=t[e].length>6?`${t[e].slice(0,5)}…`:t[e];d.push(`<text class="chart-axis-label" x="${n}" y="${u-8}" text-anchor="middle">${Y(r)}</text>`)}for(let a=0;a<n;a++)for(let n=0;n<r;n++){let r=Number(e.data[a][e.yKeys[n]])||0,l=(r-i)/o,u=X.left+a*s,f=X.top+n*c;d.push(`<rect x="${u}" y="${f}" width="${s-1}" height="${c-1}" rx="2" fill="var(--accent)" opacity="${(.1+l*.8).toFixed(2)}"><title>${Y(t[a])} / ${Y(e.yKeys[n])}: ${Ml(r)}</title></rect>`)}return`<svg class="chart-svg" viewBox="0 0 ${l} ${u}" preserveAspectRatio="xMidYMid meet">${d.join(``)}</svg>`}function ql(e){return`<div class="chart-legend">${e.map((e,t)=>`<span class="chart-legend-item"><span class="chart-legend-swatch" style="background:${Nl(t)}"></span>${Y(e)}</span>`).join(``)}</div>`}function Jl(e){let t=J(`div`,`block block-chart`),n=e.value;if(!n?.data?.length||!n.chartType)return t.innerHTML=`<pre>${Y(JSON.stringify(e.value,null,2))}</pre>`,t;Pl++;let r=e.title||n.title?`<div class="chart-title">${Y(String(e.title||n.title))}</div>`:``,i;switch(n.chartType){case`line`:i=Hl(n,!1);break;case`area`:i=Hl(n,!0);break;case`bar`:i=Ul(n,!1);break;case`horizontal-bar`:i=Ul(n,!0);break;case`pie`:i=Wl(n,!1);break;case`donut`:i=Wl(n,!0);break;case`sparkline`:i=Gl(n);break;case`heatmap`:i=Kl(n);break;default:i=`<pre>${Y(JSON.stringify(n,null,2))}</pre>`}let a=n.showLegend!==!1&&n.yKeys.length>1&&n.chartType!==`sparkline`?ql(n.yKeys):``;return t.innerHTML=`<div class="chart-container">${r}${i}${a}</div>`,t}function Yl(e){if(typeof e==`string`)return Xl(e);if(Array.isArray(e))return e.length===0?Ql(`*Empty array*`):typeof e[0]==`object`&&e[0]!==null?eu(e):Ql(e.map(e=>`- ${String(e)}`).join(`
|
|
464
|
+
`));if(typeof e==`object`&&e){let t=e;return Array.isArray(t.nodes)&&Array.isArray(t.edges)?au(t):Array.isArray(t.metrics)?iu(t.metrics):nu(t)}return Ql(String(e))}function Xl(e){let t=e.trim();if(/^(graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph)\b/i.test(t))return $l(t);if(/^#{1,6}\s|^\s*[-*]\s|\*\*|__|\[.*\]\(|```/.test(t))return Ql(t);if((t.startsWith(`{`)||t.startsWith(`[`))&&(t.endsWith(`}`)||t.endsWith(`]`)))try{return Yl(JSON.parse(t))}catch{}return Ql(t)}function Zl(e){switch(e.type){case`markdown`:return Ql(String(e.value??``));case`mermaid`:return $l(String(e.value??``));case`table`:{let t=e.value;if(Array.isArray(t)){if(t.length>0&&Array.isArray(t[0])){let e=t,n=e[0].map(String);return eu(e.slice(1).map(e=>Object.fromEntries(n.map((t,n)=>[t,e[n]]))))}return eu(t)}if(t&&typeof t==`object`&&`headers`in t&&`rows`in t){let{headers:e,rows:n}=t;return eu(n.map(t=>Object.fromEntries(e.map((e,n)=>[e,t[n]]))))}return eu([])}case`code`:return tu(String(e.value??``),e.language);case`tree`:return nu(e.value);case`cards`:return ru(e.value);case`metrics`:return iu(e.value);case`graph`:return au(e.value);case`chart`:return Jl(e);default:return Ql(JSON.stringify(e.value,null,2))}}function Ql(e){let t=J(`div`,`block block-markdown`);return t.innerHTML=Dl(e),t}function $l(e){let t=J(`div`,`block block-mermaid`),n=J(`pre`,`mermaid`,e);t.appendChild(n);let r=window;if(r.mermaid)setTimeout(()=>r.mermaid.run(),10);else if(!r.__mermaidLoading){r.__mermaidLoading=!0;let e=document.createElement(`script`);e.src=`https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js`,e.onload=()=>{r.mermaid.run()},document.head.appendChild(e)}return t}function eu(e){let t=J(`div`,`block block-table`);if(e.length===0)return Ql(`*Empty table*`);let n=Object.keys(e[0]),r=-1,i=!0,a=[...e],o=``,s=document.createElement(`input`);s.className=`table-filter`,s.placeholder=`Filter...`,s.addEventListener(`input`,()=>{o=s.value.toLowerCase(),f()}),t.appendChild(s);let c=document.createElement(`table`),l=document.createElement(`thead`),u=document.createElement(`tr`);n.forEach((e,t)=>{let n=document.createElement(`th`);n.textContent=e;let a=J(`span`,`sort-icon`,`⇅`);n.appendChild(a),n.addEventListener(`click`,()=>{r===t?i=!i:(r=t,i=!0),f()}),u.appendChild(n)}),l.appendChild(u),c.appendChild(l);let d=document.createElement(`tbody`);c.appendChild(d),t.appendChild(c);function f(){if(a=[...e],o&&(a=a.filter(e=>n.some(t=>String(e[t]??``).toLowerCase().includes(o)))),r>=0){let e=n[r];a.sort((t,n)=>{let r=String(t[e]??``),a=String(n[e]??``),o=r.localeCompare(a,void 0,{numeric:!0});return i?o:-o})}d.innerHTML=``;for(let e of a){let t=document.createElement(`tr`);for(let r of n){let n=document.createElement(`td`);n.textContent=String(e[r]??``),t.appendChild(n)}d.appendChild(t)}}return f(),t}function tu(e,t){let n=J(`div`,`block block-code`),r=J(`div`,`code-header`);r.appendChild(J(`span`,``,t??`code`));let i=document.createElement(`button`);i.className=`copy-btn`,i.textContent=`Copy`,i.addEventListener(`click`,()=>{navigator.clipboard.writeText(e).then(()=>{i.textContent=`Copied!`,setTimeout(()=>{i.textContent=`Copy`},1500)})}),r.appendChild(i),n.appendChild(r);let a=document.createElement(`pre`),o=document.createElement(`code`);return o.textContent=e,a.appendChild(o),n.appendChild(a),n}function nu(e,t=0){let n=J(`div`,t===0?`block block-tree`:``);for(let[r,i]of Object.entries(e))if(typeof i==`object`&&i&&!Array.isArray(i)){let e=J(`div`,`tree-node`),a=J(`span`,`tree-toggle`,`▼`),o=nu(i,t+1);o.className=`tree-children`;let s=!0;a.addEventListener(`click`,()=>{s=!s,a.textContent=s?`▼`:`▶`,o.style.display=s?``:`none`}),e.appendChild(a),e.appendChild(document.createTextNode(` ${r}`)),n.appendChild(e),n.appendChild(o)}else{let e=J(`div`,`tree-leaf`);e.innerHTML=`<strong>${Y(r)}:</strong> ${Y(kl(i))}`,n.appendChild(e)}return n}function ru(e){let t=J(`div`,`block block-cards`);for(let n of e){let e=J(`div`,`card`);if(n.title&&e.appendChild(J(`div`,`card-title`,String(n.title))),(n.body||n.description)&&e.appendChild(J(`div`,`card-body`,String(n.body??n.description))),n.badge||n.status){let t=String(n.variant??n.status??`default`).toLowerCase(),r=[`success`,`warning`,`error`].includes(t)?t:``;e.appendChild(J(`span`,`card-badge ${r}`,String(n.badge??n.status)))}t.appendChild(e)}return t}function iu(e){let t=J(`div`,`block block-metrics`);for(let n of e){let e=J(`div`,`metric`);e.appendChild(J(`div`,`metric-value`,String(n.value))),e.appendChild(J(`div`,`metric-label`,n.label)),t.appendChild(e)}return t}function au(e){let t=[`graph LR`],n=new Map;for(let r of e.nodes){let e=String(r.id??r.name??``),i=String(r.label??r.name??e);n.set(e,i),t.push(` ${Al(e)}["${Y(i)}"]`)}for(let n of e.edges){let e=Al(String(n.source??n.from??``)),r=Al(String(n.target??n.to??``)),i=n.label?`|${Y(String(n.label))}|`:``;t.push(` ${e} -->${i} ${r}`)}return $l(t.join(`
|
|
465
|
+
`))}function ou(e,t){let n=J(`div`,`actions`);for(let r of e)if(r.type===`select`&&r.options){let e=document.createElement(`select`);e.className=`action-select`;let i=document.createElement(`option`);i.textContent=r.label,i.disabled=!0,i.selected=!0,e.appendChild(i);for(let t of r.options){let n=document.createElement(`option`);typeof t==`string`?(n.value=t,n.textContent=t):(n.value=t.value,n.textContent=t.label),e.appendChild(n)}e.addEventListener(`change`,()=>{t.emitAction(r,e.value)}),n.appendChild(e)}else{let e=document.createElement(`button`);e.className=`action-btn ${r.variant??`default`}`,e.textContent=r.label,e.addEventListener(`click`,()=>t.emitAction(r)),n.appendChild(e)}return n}function su(e){return function(t,n){e.updateModelContext({key:`action:${t.id}`,content:JSON.stringify({actionId:t.id,actionType:t.type,label:t.label,value:n??t.label,timestamp:new Date().toISOString()})}),e.sendMessage(`User selected: ${t.label}${n?` → ${n}`:``}`)}}function cu(e){return{callTool:(t,n)=>e.callServerTool({name:t,arguments:n}),sendMessage:async t=>{await e.sendMessage({message:{role:`user`,content:{type:`text`,text:t}}})},updateContext:async t=>{await e.updateModelContext({content:[{type:`text`,text:t}]})}}}var lu=class{app;currentMode=`inline`;availableModes=[];toolbar=null;constructor(e){this.app=e}apply(e){e.displayMode&&(this.currentMode=e.displayMode),e.availableDisplayModes&&(this.availableModes=e.availableDisplayModes),this.updateToolbar()}async requestMode(e){try{let t=await this.app.requestDisplayMode({mode:e});return this.currentMode=t.mode,document.documentElement.dataset.display=t.mode,this.updateToolbar(),t.mode}catch{return this.currentMode}}updateToolbar(){if(this.availableModes.length<=1){this.toolbar?.remove(),this.toolbar=null;return}this.toolbar||=this.createToolbar(),this.renderButtons()}createToolbar(){let e=document.createElement(`div`);return e.className=`display-mode-toolbar`,document.body.appendChild(e),e}renderButtons(){if(!this.toolbar)return;this.toolbar.innerHTML=``;let e={inline:`▣`,fullscreen:`⛶`,pip:`◱`};for(let t of this.availableModes){let n=document.createElement(`button`);n.className=`dm-btn${t===this.currentMode?` dm-active`:``}`,n.textContent=e[t]??t,n.title=t,n.addEventListener(`click`,()=>this.requestMode(t)),this.toolbar.appendChild(n)}}},uu=[[400,`compact`],[800,`comfortable`]],du=class{root;displayMode=`inline`;sizeClass=`comfortable`;constructor(e){this.root=e??document.documentElement}apply(e){this.applyDisplayMode(e),this.applyContainerDimensions(e),this.applySafeArea(e),this.applyPlatform(e),this.applyDeviceCapabilities(e)}getDisplayMode(){return this.displayMode}getSize(){return this.sizeClass}applyDisplayMode(e){e.displayMode&&(this.displayMode=e.displayMode,this.root.dataset.display=e.displayMode)}applyContainerDimensions(e){let t=e.containerDimensions;if(!t)return;let n=this.root.style,r=`width`in t?t.width:`maxWidth`in t?t.maxWidth:void 0,i=`height`in t?t.height:`maxHeight`in t?t.maxHeight:void 0;r!==void 0&&(n.setProperty(`--kb-container-w`,`${r}px`),this.sizeClass=this.deriveSizeClass(r),this.root.dataset.size=this.sizeClass,n.setProperty(`--kb-content-max-width`,this.deriveMaxWidth(r)),n.setProperty(`--kb-body-pad-x`,this.derivePadX()),n.setProperty(`--kb-grid-cols`,this.deriveGridCols()),n.setProperty(`--kb-card-min`,this.deriveCardMin()),n.setProperty(`--kb-metric-min`,this.deriveMetricMin())),i!==void 0&&(n.setProperty(`--kb-container-h`,`${i}px`),n.setProperty(`--kb-body-pad-y`,this.derivePadY()))}applySafeArea(e){let t=e.safeAreaInsets;if(!t)return;let n=this.root.style;n.setProperty(`--kb-safe-top`,`${t.top}px`),n.setProperty(`--kb-safe-right`,`${t.right}px`),n.setProperty(`--kb-safe-bottom`,`${t.bottom}px`),n.setProperty(`--kb-safe-left`,`${t.left}px`)}applyPlatform(e){e.platform&&(this.root.dataset.platform=e.platform)}applyDeviceCapabilities(e){let t=e.deviceCapabilities;t&&(t.touch!==void 0&&(this.root.dataset.touch=String(t.touch)),t.hover!==void 0&&(this.root.dataset.hover=String(t.hover)))}deriveSizeClass(e){for(let[t,n]of uu)if(e<t)return n;return`full`}deriveMaxWidth(e){return this.displayMode===`pip`?`100%`:this.displayMode===`fullscreen`?`none`:e<960?`100%`:`900px`}derivePadX(){return this.sizeClass===`compact`?`8px`:`16px`}derivePadY(){return this.sizeClass===`compact`?`8px`:`16px`}deriveGridCols(){switch(this.sizeClass){case`compact`:return`1`;case`comfortable`:return`2`;case`full`:return`3`}}deriveCardMin(){return this.sizeClass===`compact`?`100%`:`250px`}deriveMetricMin(){return this.sizeClass===`compact`?`100px`:`150px`}},fu=class{templates=new Map;register(e){this.templates.set(e.name,e)}get(e){return this.templates.get(e)}detect(e){let t,n=0;for(let r of this.templates.values()){let i=r.detect(e);i>n&&(n=i,t=r)}return n>0?t:void 0}getAll(){return[...this.templates.values()]}},pu={"--color-background-primary":`--kb-bg`,"--color-background-secondary":`--kb-surface`,"--color-background-tertiary":`--kb-surface2`,"--color-text-primary":`--kb-text`,"--color-text-secondary":`--kb-muted`,"--color-border-primary":`--kb-border`,"--color-ring-primary":`--kb-accent`,"--color-text-success":`--kb-success`,"--color-text-danger":`--kb-error`,"--color-text-warning":`--kb-warning`,"--color-text-info":`--kb-info`,"--color-background-inverse":`--kb-code-bg`,"--color-text-inverse":`--kb-code-fg`,"--font-sans":`--kb-font-sans`,"--font-mono":`--kb-font-mono`,"--border-radius-md":`--kb-radius`,"--shadow-sm":`--kb-shadow`},mu={"--kb-bg":`--bg`,"--kb-text":`--fg`,"--kb-surface":`--surface`,"--kb-border":`--border`,"--kb-accent":`--accent`,"--kb-success":`--success`,"--kb-warning":`--warning`,"--kb-error":`--error`,"--kb-code-bg":`--code-bg`,"--kb-code-fg":`--code-fg`,"--kb-font-sans":`--font-sans`,"--kb-font-mono":`--font-mono`,"--kb-radius":`--radius`,"--kb-shadow":`--shadow`},hu=class{root;constructor(e){this.root=e??document.documentElement}apply(e){e.theme&&Cl(e.theme),e.styles?.variables&&(wl(e.styles.variables),this.mapTokens(e.styles.variables)),e.styles?.css?.fonts&&this.injectFonts(e.styles.css.fonts)}getTheme(){return Sl()}mapTokens(e){let t=this.root.style;for(let[n,r]of Object.entries(pu)){let i=e[n];if(i){t.setProperty(r,i);let e=mu[r];e&&t.setProperty(e,i)}}let n=e[`--color-ring-primary`];n&&(t.setProperty(`--kb-accent-light`,n),t.setProperty(`--accent-light`,n),t.setProperty(`--kb-hover-bg`,`color-mix(in srgb, ${n} 10%, transparent)`))}injectFonts(e){let t=`kb-host-fonts`;if(document.getElementById(t))return;let n=document.createElement(`style`);n.id=t,n.textContent=e,document.head.appendChild(n)}},gu=`
|
|
440
466
|
.tpl-dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
|
|
441
467
|
.db-card { min-height: 136px; padding: 14px; border: 1px solid var(--kb-border, #3c3c3c);
|
|
442
468
|
border-left-width: 4px; border-radius: var(--kb-radius, 10px); background: var(--kb-surface, #252526);
|
|
@@ -462,7 +488,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
462
488
|
.db-list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--kb-text, #e5e7eb);
|
|
463
489
|
font: 500 13px var(--kb-font-sans, Inter, sans-serif); }
|
|
464
490
|
.db-list-item span:last-child { color: var(--kb-muted, #9ca3af); font-family: var(--kb-font-mono, Consolas, monospace); }
|
|
465
|
-
|
|
491
|
+
`,_u={name:`dashboard`,label:`Dashboard`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e,n=Array.isArray(t.metrics)?t.metrics[0]:void 0;return n&&typeof n.label==`string`&&`value`in n?.85:0},render(e,t,n){q(`tpl-dashboard`,gu);let r=t,i=J(`div`,`block tpl-dashboard`);for(let e of r.metrics){let t=J(`article`,`db-card status-${e.status??`info`}`),n=J(`div`,`db-header`);if(n.appendChild(J(`div`,`db-label`,e.label)),e.trend){let t=e.trend.direction===`up`?`▲`:e.trend.direction===`down`?`▼`:`—`;n.appendChild(J(`div`,`db-trend ${e.trend.direction}`,`${t} ${e.trend.value}`))}if(t.appendChild(n),t.appendChild(J(`div`,`db-value`,kl(e.value))),e.type===`progress`){let n=J(`div`,`db-progress-track`),r=J(`div`,`db-progress-fill`);r.style.width=`${Math.max(0,Math.min(100,e.progress??0))}%`,n.appendChild(r),t.appendChild(n),t.appendChild(J(`div`,`db-progress-meta`,`${Math.max(0,Math.min(100,e.progress??0))}% complete`))}if(e.type===`list`&&e.items?.length){let n=J(`ul`,`db-list`);for(let t of e.items){let e=J(`li`,`db-list-item`);e.appendChild(J(`span`,``,t.label)),e.appendChild(J(`span`,``,t.value)),n.appendChild(e)}t.appendChild(n)}i.appendChild(t)}e.appendChild(i)},styles(){return gu}},vu=`
|
|
466
492
|
.dt-stats { display: flex; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
|
|
467
493
|
.dt-stat { text-align: center; min-width: 80px; }
|
|
468
494
|
.dt-stat-value { font-size: 22px; font-weight: 700; color: var(--kb-accent, #0078d4); }
|
|
@@ -481,7 +507,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
481
507
|
.dt-table td { padding: 7px 12px; border-bottom: 1px solid var(--kb-border, #3c3c3c); color: var(--kb-text, #ccc); }
|
|
482
508
|
.dt-table tr:hover td { background: rgba(255,255,255,0.03); }
|
|
483
509
|
.sort-icon { margin-left: 4px; font-size: 10px; opacity: 0.4; }
|
|
484
|
-
`,
|
|
510
|
+
`,yu={name:`data-table`,label:`Data Table`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e;return t.columns&&t.rows&&Array.isArray(t.columns)&&Array.isArray(t.rows)?.9:0},render(e,t,n){let r=t,i=J(`div`,`block tpl-data-table`);if(r.stats?.length){let e=J(`div`,`dt-stats`);for(let t of r.stats){let n=J(`div`,`dt-stat`),r=J(`div`,`dt-stat-value`,String(t.value));t.color&&(r.style.color=t.color),n.appendChild(r),n.appendChild(J(`div`,`dt-stat-label`,t.label)),e.appendChild(n)}i.appendChild(e)}let a=J(`div`,`dt-filter-bar`),o=document.createElement(`input`);o.className=`dt-search`,o.placeholder=`Search...`,a.appendChild(o);let s=J(`span`,`dt-count`,`${r.rows.length} rows`);a.appendChild(s);let c=document.createElement(`button`);c.className=`action-btn default dt-export`,c.textContent=`Export`,c.addEventListener(`click`,()=>{n.emitAction({type:`button`,id:`export`,label:`Export`},JSON.stringify(h))}),a.appendChild(c),i.appendChild(a);let l=document.createElement(`table`);l.className=`dt-table`;let u=document.createElement(`thead`),d=document.createElement(`tr`),f=``,p=!0;for(let e of r.columns){let t=document.createElement(`th`);t.textContent=e.label;let n=J(`span`,`sort-icon`,`⇅`);t.appendChild(n),t.addEventListener(`click`,()=>{f===e.key?p=!p:(f=e.key,p=!0),ee()}),d.appendChild(t)}u.appendChild(d),l.appendChild(u);let m=document.createElement(`tbody`);l.appendChild(m),i.appendChild(l);let h=[...r.rows];o.addEventListener(`input`,()=>ee());function ee(){let e=o.value.toLowerCase();h=r.rows.filter(t=>e?r.columns.some(n=>String(t[n.key]??``).toLowerCase().includes(e)):!0),f&&h.sort((e,t)=>{let n=String(e[f]??``),r=String(t[f]??``),i=n.localeCompare(r,void 0,{numeric:!0});return p?i:-i}),m.innerHTML=``;for(let e of h){let t=document.createElement(`tr`);for(let n of r.columns){let r=document.createElement(`td`);r.textContent=String(e[n.key]??``),t.appendChild(r)}m.appendChild(t)}s.textContent=`${h.length} rows`}ee(),q(`tpl-data-table`,vu),e.appendChild(i)},styles(){return vu}},bu=`
|
|
485
511
|
.tpl-diff-view { display: grid; gap: 14px; }
|
|
486
512
|
.diff-stats { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 14px; border: 1px solid var(--kb-border, #3c3c3c);
|
|
487
513
|
border-radius: var(--kb-radius, 10px); background: var(--kb-surface, #252526); color: var(--kb-text, #e5e7eb);
|
|
@@ -517,7 +543,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
517
543
|
.diff-line.add .diff-prefix { color: var(--kb-success, #22c55e); }
|
|
518
544
|
.diff-line.delete .diff-prefix { color: var(--kb-error, #ef4444); }
|
|
519
545
|
.diff-code { color: var(--kb-text, #e5e7eb); white-space: pre-wrap; word-break: break-word; }
|
|
520
|
-
`;function
|
|
546
|
+
`;function xu(e){let t=/@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/.exec(e);return{oldLine:t?Number(t[1]):1,newLine:t?Number(t[2]):1}}var Su={name:`diff-view`,label:`Diff View`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e,n=Array.isArray(t.files)?t.files[0]:void 0,r=Array.isArray(n?.hunks)?n?.hunks[0]:void 0;return Array.isArray(t.files)&&Array.isArray(n?.hunks)&&Array.isArray(r?.changes)?.9:0},render(e,t,n){q(`tpl-diff-view`,bu);let r=t,i=J(`div`,`block tpl-diff-view`),a=r.stats??{additions:r.files.reduce((e,t)=>e+t.additions,0),deletions:r.files.reduce((e,t)=>e+t.deletions,0),filesChanged:r.files.length},o=new Set,s=0,c=J(`div`,`diff-stats`);c.appendChild(J(`span`,`diff-additions`,`+${a.additions}`)),c.appendChild(J(`span`,`diff-deletions`,`-${a.deletions}`)),c.appendChild(J(`span`,``,`${a.filesChanged} files`)),i.appendChild(c);let l=J(`div`,`diff-files`),u=J(`div`,`diff-panel`);i.appendChild(l),i.appendChild(u);let d=()=>{l.innerHTML=``,u.innerHTML=``;for(let e=0;e<r.files.length;e++){let t=r.files[e],n=document.createElement(`button`);n.className=`diff-tab${e===s?` active`:``}`,n.textContent=t.path,n.addEventListener(`click`,()=>{s=e,d()}),l.appendChild(n)}let e=r.files[s],t=J(`div`,`diff-file-header`);t.appendChild(J(`div`,`diff-file-path`,e.path));let n=J(`div`,`diff-file-meta`);e.oldPath&&n.appendChild(J(`span`,``,`from ${e.oldPath}`)),n.appendChild(J(`span`,`diff-status ${e.status}`,e.status)),u.appendChild(t),t.appendChild(n);for(let t=0;t<e.hunks.length;t++){let n=e.hunks[t],r=`${Al(e.path)}-${Al(n.header)}-${t}`,i=J(`section`,`diff-hunk`),a=document.createElement(`button`);a.className=`diff-hunk-header`,a.textContent=n.header;let s=J(`div`,`diff-hunk-body`);s.hidden=o.has(r),a.addEventListener(`click`,()=>{o.has(r)?o.delete(r):o.add(r),s.hidden=o.has(r)});let c=xu(n.header),l=c.oldLine,d=c.newLine;for(let e of n.changes){let t=J(`div`,`diff-line ${e.type}`),n=J(`span`,`diff-old-line`),r=J(`span`,`diff-new-line`),i=J(`span`,`diff-prefix`,e.type===`add`?`+`:e.type===`delete`?`-`:` `),a=J(`span`,`diff-code`);a.innerHTML=Y(e.content),e.type===`add`?(r.textContent=String(e.line??d),d=(e.line??d)+1):e.type===`delete`?(n.textContent=String(e.line??l),l=(e.line??l)+1):(n.textContent=String(e.line??l),r.textContent=String(e.line??d),l=(e.line??l)+1,d=(e.line??d)+1),t.appendChild(n),t.appendChild(r),t.appendChild(i),t.appendChild(a),s.appendChild(t)}i.appendChild(a),i.appendChild(s),u.appendChild(i)}};d(),e.appendChild(i)},styles(){return bu}},Cu=`
|
|
521
547
|
.fg-breadcrumb { display: flex; align-items: center; gap: 4px; padding: 8px 0; flex-wrap: wrap; }
|
|
522
548
|
.fg-crumb { background: var(--kb-surface, #252526); border: 1px solid var(--kb-border, #3c3c3c);
|
|
523
549
|
color: var(--kb-text, #ccc); padding: 3px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
|
|
@@ -532,7 +558,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
532
558
|
text-overflow: ellipsis; font-weight: 500; }
|
|
533
559
|
.fg-info { font-size: 12px; color: var(--kb-muted, #858585); padding: 8px 0;
|
|
534
560
|
border-top: 1px solid var(--kb-border, #3c3c3c); margin-top: 8px; }
|
|
535
|
-
`;function
|
|
561
|
+
`;function wu(e){return{name:String(e.name??``),total:typeof e.total==`number`?e.total:typeof e.value==`number`?e.value:0,self:typeof e.self==`number`?e.self:void 0,children:Array.isArray(e.children)?e.children.map(e=>wu(e)):void 0}}var Tu={name:`flame-graph`,label:`Flame Graph`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e.profile;return t&&typeof t==`object`&&t.children?.9:0},render(e,t,n){let r=t,i=J(`div`,`block tpl-flame-graph`),a=wu(r.profile),o=a,s=[a],c=J(`div`,`fg-breadcrumb`);i.appendChild(c);let l=J(`div`,`fg-canvas`);i.appendChild(l);let u=J(`div`,`fg-info`);i.appendChild(u);function d(){c.innerHTML=``;for(let e=0;e<s.length;e++){let t=s[e],n=document.createElement(`button`);n.className=`fg-crumb`,n.textContent=t.name,n.addEventListener(`click`,()=>{s.splice(e+1),o=t,d()}),c.appendChild(n),e<s.length-1&&c.appendChild(J(`span`,`fg-sep`,`›`))}l.innerHTML=``,f(l,o,0,o.total),u.textContent=`${o.name} — total: ${o.total}${o.self==null?``:`, self: ${o.self}`}`}function f(e,t,r,i){let a=J(`div`,`fg-row`);a.style.paddingLeft=`${r*2}px`;let c=J(`div`,`fg-bar`),l=Math.max(2,t.total/i*100);c.style.width=`${l}%`,c.style.background=p(r),c.title=`${t.name}: ${t.total}${t.self==null?``:` (self: ${t.self})`}`;let m=J(`span`,`fg-bar-label`,`${t.name} (${t.total})`);if(c.appendChild(m),t.children?.length&&(c.style.cursor=`pointer`,c.addEventListener(`click`,()=>{o=t,s.push(t),d(),n.emitAction({type:`button`,id:`zoom`,label:`Zoom`},JSON.stringify({name:t.name,total:t.total}))})),c.addEventListener(`mouseenter`,()=>{u.textContent=`${t.name} — total: ${t.total}${t.self==null?``:`, self: ${t.self}`}`}),a.appendChild(c),e.appendChild(a),t.children)for(let n of t.children)f(e,n,r+1,i)}function p(e){let t=[`#e24d28`,`#e8602a`,`#edad2a`,`#f5c842`,`#fce94f`,`#c4a000`,`#e07028`,`#d45500`];return t[e%t.length]}d(),q(`tpl-flame-graph`,Cu),e.appendChild(i)},styles(){return Cu}},Eu=`
|
|
536
562
|
.tpl-form { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
|
|
537
563
|
@media (max-width: 640px) { .tpl-form { grid-template-columns: 1fr; } }
|
|
538
564
|
.fm-fields { display: flex; flex-direction: column; gap: 14px; }
|
|
@@ -553,7 +579,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
553
579
|
letter-spacing: 0.5px; margin-bottom: 8px; }
|
|
554
580
|
.fm-preview-json { font-size: 12px; color: var(--kb-text, #ccc); margin: 0; white-space: pre-wrap;
|
|
555
581
|
word-break: break-all; font-family: 'SF Mono', Consolas, monospace; }
|
|
556
|
-
`,
|
|
582
|
+
`,Du={name:`form`,label:`Form`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e;return t.fields&&Array.isArray(t.fields)?.85:0},render(e,t,n){let r=t,i=J(`div`,`block tpl-form`),a=J(`div`,`fm-fields`),o=J(`div`,`fm-preview`),s={};for(let e of r.fields)s[e.name]=e.value??``;for(let e of r.fields){let t=J(`div`,`fm-group`);t.appendChild(J(`label`,`fm-label`,e.label));let n=e.type??`text`;if(n===`select`&&e.options){let n=document.createElement(`select`);n.className=`fm-input`;for(let t of e.options){let r=document.createElement(`option`);r.value=t,r.textContent=t,t===e.value&&(r.selected=!0),n.appendChild(r)}n.addEventListener(`change`,()=>{s[e.name]=n.value,l()}),t.appendChild(n)}else if(n===`textarea`){let n=document.createElement(`textarea`);n.className=`fm-input fm-textarea`,n.value=e.value??``,n.rows=4,n.addEventListener(`input`,()=>{s[e.name]=n.value,l()}),t.appendChild(n)}else if(n===`multi-select`&&e.options){let n=J(`div`,`fm-multi`);for(let t of e.options){let r=document.createElement(`label`);r.className=`fm-check-label`;let i=document.createElement(`input`);i.type=`checkbox`,e.value?.includes(t)&&(i.checked=!0),i.addEventListener(`change`,()=>{let t=n.querySelectorAll(`input:checked`);s[e.name]=Array.from(t).map(e=>e.nextSibling?.textContent??``).join(`, `),l()}),r.appendChild(i),r.appendChild(document.createTextNode(` ${t}`)),n.appendChild(r)}t.appendChild(n)}else{let r=document.createElement(`input`);r.className=`fm-input`,r.type=n,r.value=e.value??``,r.addEventListener(`input`,()=>{s[e.name]=r.value,l()}),t.appendChild(r)}a.appendChild(t)}let c=document.createElement(`button`);c.className=`action-btn primary fm-submit`,c.textContent=`Submit`,c.addEventListener(`click`,()=>{n.emitAction({type:`button`,id:`submit`,label:`Submit Form`},JSON.stringify(s)),c.textContent=`✓ Submitted`,c.disabled=!0,setTimeout(()=>{c.textContent=`Submit`,c.disabled=!1},2e3)}),a.appendChild(c);function l(){o.innerHTML=``,o.appendChild(J(`div`,`fm-preview-title`,`Preview`));let e=document.createElement(`pre`);e.className=`fm-preview-json`,e.textContent=JSON.stringify(s,null,2),o.appendChild(e)}i.appendChild(a),i.appendChild(o),l(),q(`tpl-form`,Eu),e.appendChild(i)},styles(){return Eu}},Ou=`
|
|
557
583
|
.tpl-kanban { overflow-x: auto; }
|
|
558
584
|
.kbn-board { display: flex; gap: 14px; align-items: flex-start; min-width: min-content; padding-bottom: 4px; }
|
|
559
585
|
.kbn-column { width: 280px; flex: 0 0 280px; border: 1px solid var(--kb-border, #3c3c3c); border-radius: var(--kb-radius, 10px);
|
|
@@ -579,7 +605,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
579
605
|
.kbn-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
|
|
580
606
|
.kbn-tag { padding: 2px 8px; border-radius: 999px; background: var(--kb-surface, #252526); color: var(--kb-muted, #9ca3af);
|
|
581
607
|
font: 500 11px var(--kb-font-sans, Inter, sans-serif); }
|
|
582
|
-
`,
|
|
608
|
+
`,ku={name:`kanban`,label:`Kanban`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e,n=Array.isArray(t.cards)?t.cards[0]:void 0;return Array.isArray(t.columns)&&Array.isArray(t.cards)&&typeof n?.column==`string`?.85:0},render(e,t,n){q(`tpl-kanban`,Ou);let r=t,i=r.cards.map(e=>({...e,tags:e.tags?[...e.tags]:void 0})),a=new Set,o=``,s=J(`div`,`block tpl-kanban`),c=J(`div`,`kbn-board`);s.appendChild(c);let l=()=>{c.innerHTML=``;for(let e of r.columns){let t=J(`section`,`kbn-column`),r=J(`div`,`kbn-column-header`),s=J(`div`,`kbn-column-title`),u=J(`span`,`kbn-column-swatch`);e.color&&(u.style.background=e.color),s.appendChild(u),s.appendChild(J(`span`,``,e.label)),r.appendChild(s);let d=i.filter(t=>t.column===e.id);r.appendChild(J(`span`,`kbn-column-count`,String(d.length))),t.appendChild(r);let f=J(`div`,`kbn-cards`);t.addEventListener(`dragover`,e=>{e.preventDefault(),t.classList.add(`drop-target`)}),t.addEventListener(`dragleave`,()=>{t.classList.remove(`drop-target`)}),t.addEventListener(`drop`,r=>{if(r.preventDefault(),t.classList.remove(`drop-target`),!o)return;let a=i.find(e=>e.id===o);!a||a.column===e.id||(a.column=e.id,l(),n.emitAction({type:`button`,id:`move-card`,label:`Move Card`},JSON.stringify({id:a.id,column:e.id})))});for(let e of d){let t=J(`article`,`kbn-card priority-${e.priority??`low`}`);if(t.draggable=!0,t.appendChild(J(`div`,`kbn-card-title`,e.title)),e.description){let n=J(`div`,`kbn-card-description`,e.description);n.hidden=!a.has(e.id),t.appendChild(n),t.addEventListener(`click`,()=>{a.has(e.id)?a.delete(e.id):a.add(e.id),n.hidden=!a.has(e.id)})}else t.addEventListener(`click`,()=>{a.has(e.id)?a.delete(e.id):a.add(e.id)});if(e.tags?.length){let n=J(`div`,`kbn-tags`);for(let t of e.tags)n.appendChild(J(`span`,`kbn-tag`,t));t.appendChild(n)}t.addEventListener(`dragstart`,()=>{o=e.id,t.classList.add(`dragging`)}),t.addEventListener(`dragend`,()=>{t.classList.remove(`dragging`),o=``}),f.appendChild(t)}t.appendChild(f),c.appendChild(t)}};l(),e.appendChild(s)},styles(){return Ou}},Au=`
|
|
583
609
|
.sort-list { list-style: none; padding: 0; margin: 0; }
|
|
584
610
|
.sort-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 4px 0;
|
|
585
611
|
background: var(--kb-surface, #252526); border: 1px solid var(--kb-border, #3c3c3c);
|
|
@@ -590,7 +616,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
590
616
|
.drag-handle { font-size: 18px; color: var(--kb-muted, #858585); cursor: grab; user-select: none; }
|
|
591
617
|
.sort-label { flex: 1; color: var(--kb-text, #ccc); }
|
|
592
618
|
.sort-pos { font-size: 12px; color: var(--kb-muted, #858585); font-variant-numeric: tabular-nums; }
|
|
593
|
-
`,
|
|
619
|
+
`,ju={name:`list-sort`,label:`Sortable List`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e;return t.items&&Array.isArray(t.items)&&!t.categories?.8:0},render(e,t,n){let r=t,i=J(`div`,`block tpl-list-sort`);q(`tpl-list-sort`,Au);function a(e){i.innerHTML=``;let t=J(`ul`,`sort-list`),r=-1;for(let i=0;i<e.length;i++){let o=e[i],s=document.createElement(`li`);s.className=`sort-item`,s.draggable=!0,s.dataset.idx=String(i);let c=J(`span`,`drag-handle`,`⠿`),l=J(`span`,`sort-label`,o.label),u=J(`span`,`sort-pos`,`#${i+1}`);s.appendChild(c),s.appendChild(l),s.appendChild(u),s.addEventListener(`dragstart`,()=>{r=Number(s.dataset.idx),s.classList.add(`dragging`)}),s.addEventListener(`dragend`,()=>{s.classList.remove(`dragging`)}),s.addEventListener(`dragover`,e=>{e.preventDefault(),s.classList.add(`drag-over`)}),s.addEventListener(`dragleave`,()=>{s.classList.remove(`drag-over`)}),s.addEventListener(`drop`,t=>{t.preventDefault(),s.classList.remove(`drag-over`);let i=Number(s.dataset.idx);if(r>=0&&r!==i){let t=[...e],[o]=t.splice(r,1);t.splice(i,0,o),a(t),n.emitAction({type:`button`,id:`reorder`,label:`Reorder`},JSON.stringify(t.map(e=>e.id)))}}),t.appendChild(s)}i.appendChild(t)}a([...r.items??[]]),e.appendChild(i)},styles(){return Au}},Mu=`
|
|
594
620
|
.pk-tabs { display: flex; gap: 4px; padding: 4px; background: var(--kb-surface, #252526);
|
|
595
621
|
border-radius: 8px; margin-bottom: 10px; overflow-x: auto; }
|
|
596
622
|
.pk-tab { padding: 6px 14px; border: none; background: transparent; color: var(--kb-muted, #858585);
|
|
@@ -614,7 +640,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
614
640
|
.pk-tag { font-size: 10px; padding: 1px 6px; border-radius: 4px;
|
|
615
641
|
background: var(--kb-surface2, #2d2d30); color: var(--kb-muted, #858585); }
|
|
616
642
|
.pk-apply { margin-top: 10px; width: 100%; }
|
|
617
|
-
`,
|
|
643
|
+
`,Nu={name:`picker`,label:`Picker`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e;return t.categories&&t.items&&Array.isArray(t.categories)&&Array.isArray(t.items)?.85:0},render(e,t,n){let r=t,i=J(`div`,`block tpl-picker`),a=new Set,o=`all`,s=``,c=J(`div`,`pk-tabs`),l=document.createElement(`button`);l.className=`pk-tab active`,l.textContent=`All (${r.items.length})`,l.addEventListener(`click`,()=>{o=`all`,m()}),c.appendChild(l);for(let e of r.categories){let t=document.createElement(`button`);t.className=`pk-tab`;let n=r.items.filter(t=>t.category===e.id).length;t.textContent=`${e.label} (${n})`,t.addEventListener(`click`,()=>{o=e.id,m()}),c.appendChild(t)}i.appendChild(c);let u=document.createElement(`input`);u.className=`pk-search`,u.placeholder=`Search items...`,u.addEventListener(`input`,()=>{s=u.value.toLowerCase(),m()}),i.appendChild(u);let d=J(`div`,`pk-summary`,`0 selected`);i.appendChild(d);let f=J(`div`,`pk-list`);i.appendChild(f);let p=document.createElement(`button`);p.className=`action-btn primary pk-apply`,p.textContent=`Apply Selection`,p.addEventListener(`click`,()=>{n.emitAction({type:`button`,id:`pick`,label:`Apply Selection`},JSON.stringify([...a])),p.textContent=`✓ Applied`,p.disabled=!0,setTimeout(()=>{p.textContent=`Apply Selection`,p.disabled=!1},2e3)}),i.appendChild(p);function m(){c.querySelectorAll(`.pk-tab`).forEach((e,t)=>{e.classList.toggle(`active`,t===0?o===`all`:r.categories[t-1]?.id===o)});let e=r.items.filter(e=>!(o!==`all`&&e.category!==o||s&&!e.label.toLowerCase().includes(s)));f.innerHTML=``;for(let t of e){let e=J(`div`,`pk-item`),n=document.createElement(`input`);if(n.type=`checkbox`,n.checked=a.has(t.id),n.addEventListener(`change`,()=>{n.checked?a.add(t.id):a.delete(t.id),d.textContent=`${a.size} selected`}),e.appendChild(n),e.appendChild(J(`span`,`pk-item-label`,t.label)),t.status){let n=t.status.toLowerCase(),r=[`active`,`enabled`,`on`].includes(n)?`success`:``;e.appendChild(J(`span`,`pk-item-status ${r}`,t.status))}if(t.tags?.length){let n=J(`div`,`pk-tags`);for(let e of t.tags)n.appendChild(J(`span`,`pk-tag`,e));e.appendChild(n)}f.appendChild(e)}d.textContent=`${a.size} selected`}m(),q(`tpl-picker`,Mu),e.appendChild(i)},styles(){return Mu}},Pu=`
|
|
618
644
|
.tpl-timeline { position: relative; }
|
|
619
645
|
.tl-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
|
|
620
646
|
.tl-filter-pill { padding: 6px 12px; border: 1px solid var(--kb-border, #3c3c3c);
|
|
@@ -655,7 +681,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
655
681
|
70% { box-shadow: 0 0 0 10px transparent; }
|
|
656
682
|
100% { box-shadow: 0 0 0 0 transparent; }
|
|
657
683
|
}
|
|
658
|
-
`,
|
|
684
|
+
`,Fu={name:`timeline`,label:`Timeline`,detect(e){if(typeof e!=`object`||!e||Array.isArray(e))return 0;let t=e,n=Array.isArray(t.events)?t.events[0]:void 0;return n&&typeof n.title==`string`&&(typeof n.status==`string`||typeof n.timestamp==`string`)?.85:0},render(e,t,n){q(`tpl-timeline`,Pu);let r=t,i=J(`div`,`block tpl-timeline`),a=[...new Set(r.events.map(e=>e.category).filter(Boolean))],o=new Set,s=`all`,c=[];if(a.length>1){let e=J(`div`,`tl-filters`),t=[`all`,...a];for(let n of t){let t=document.createElement(`button`);t.className=`tl-filter-pill${n===s?` active`:``}`,t.textContent=n===`all`?`All`:n,t.addEventListener(`click`,()=>{s=n,u()}),e.appendChild(t)}i.appendChild(e)}let l=J(`div`,`tl-list`);i.appendChild(l);let u=()=>{i.querySelectorAll(`.tl-filter-pill`).forEach(e=>{let t=e.textContent===`All`;e.classList.toggle(`active`,t&&s===`all`||e.textContent===s)});for(let e of c)e.item.hidden=!(s===`all`||e.category===s)};for(let e=0;e<r.events.length;e++){let t=r.events[e],n=t.id??`${e}:${t.title}`,i=J(`article`,`tl-event status-${t.status??`pending`}`);i.appendChild(J(`span`,`tl-dot`));let a=J(`div`,`tl-card`),s=document.createElement(`button`);s.className=`tl-event-summary`;let u=J(`div`,`tl-summary-text`),d=J(`div`,`tl-title-line`);t.icon&&d.appendChild(J(`span`,`tl-icon`,t.icon)),d.appendChild(J(`span`,`tl-title`,t.title)),u.appendChild(d);let f=J(`div`,`tl-meta`);t.timestamp&&f.appendChild(J(`span`,`tl-timestamp`,t.timestamp)),t.category&&f.appendChild(J(`span`,`tl-category`,t.category)),f.childElementCount>0&&u.appendChild(f);let p=J(`span`,`tl-chevron`,`▶`);s.appendChild(u),s.appendChild(p);let m=J(`div`,`tl-description`);m.hidden=!0,t.description&&(m.innerHTML=Y(t.description).replace(/\n/g,`<br>`)),s.addEventListener(`click`,()=>{o.has(n)?o.delete(n):o.add(n),m.hidden=!o.has(n),p.textContent=m.hidden?`▶`:`▼`}),a.appendChild(s),t.description&&a.appendChild(m),i.appendChild(a),l.appendChild(i),c.push({category:t.category,item:i})}u(),e.appendChild(i)},styles(){return Pu}},Iu=`
|
|
659
685
|
.tpl-tree { display: grid; gap: 4px; }
|
|
660
686
|
.tree-node { border-radius: var(--kb-radius, 10px); }
|
|
661
687
|
.tree-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: calc(var(--kb-radius, 10px) - 4px);
|
|
@@ -670,7 +696,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
670
696
|
.tree-metadata { color: var(--kb-muted, #9ca3af); font: 500 11px var(--kb-font-sans, Inter, sans-serif); }
|
|
671
697
|
.tree-children { margin-left: 18px; padding-left: 12px; border-left: 1px dashed var(--kb-border, #3c3c3c); }
|
|
672
698
|
.tree-children[hidden] { display: none; }
|
|
673
|
-
`;function
|
|
699
|
+
`;function Lu(e){return typeof e==`object`&&!!e&&typeof e.label==`string`}var Ru={name:`tree`,label:`Tree`,detect(e){if(Array.isArray(e)){let t=e[0];return Lu(t)&&Array.isArray(t.children)?.7:0}if(typeof e!=`object`||!e)return 0;let t=e;if(Array.isArray(t.root)){let e=t.root[0];return Lu(e)&&Array.isArray(e.children)?.85:0}return Lu(t.root)&&Array.isArray(t.root.children)?.85:0},render(e,t,n){q(`tpl-tree`,Iu);let r=t,i=Array.isArray(r)?r:Array.isArray(r.root)?r.root:[r.root],a=J(`div`,`block tpl-tree`),o=(e,t)=>{let n=J(`div`,`tree-node`),r=J(`div`,`tree-row`);if(r.id=Al(e.id??`${e.label}-${t}`),e.children?.length){let i=document.createElement(`button`),a=t<1;i.className=`tree-toggle`,i.textContent=a?`▼`:`▶`,r.appendChild(i);let s=J(`div`,`tree-children`);s.dataset.depth=String(t),s.hidden=!a;for(let n of e.children)s.appendChild(o(n,t+1));i.addEventListener(`click`,()=>{s.hidden=!s.hidden,i.textContent=s.hidden?`▶`:`▼`}),n.appendChild(r),n.appendChild(s)}else r.appendChild(J(`span`,`tree-spacer`)),n.appendChild(r);if(e.icon&&r.appendChild(J(`span`,`tree-icon`,e.icon)),r.appendChild(J(`span`,`tree-label`,e.label)),e.metadata&&Object.keys(e.metadata).length>0){let t=J(`span`,`tree-metadata`);t.textContent=Object.entries(e.metadata).map(([e,t])=>`${e}: ${kl(t)}`).join(` · `),r.appendChild(t)}return n};for(let e of i)a.appendChild(o(e,0));e.appendChild(a)},styles(){return Iu}},Z=new Tl({name:`KB Present`,version:`1.0.0`}),zu=document.getElementById(`app`);if(!zu)throw Error(`Missing #app element`);var Q=zu,$=new fu;$.register(ju),$.register(yu),$.register(Nu),$.register(Tu),$.register(Du),$.register(Fu),$.register(_u),$.register(ku),$.register(Ru),$.register(Su);var Bu=su(Z),Vu={app:Z,data:cu(Z),emitAction:Bu},Hu=new hu,Uu=new du,Wu=new lu(Z);Z.connect().then(()=>{let e=Z.getHostContext();e&&(Hu.apply(e),Uu.apply(e),Wu.apply(e))}),Z.onhostcontextchanged=e=>{Hu.apply(e),Uu.apply(e),Wu.apply(e),qu?.onThemeChange&&qu.onThemeChange(Hu.getTheme())};var Gu;Z.ontoolinputpartial=e=>{let t=e.arguments;t&&(Q.dataset.streaming=`true`,clearTimeout(Gu),Gu=setTimeout(()=>{try{let e=t.content;if(!e)return;Ku({title:t.title,template:t.template,content:e})}catch{}},80))},Z.ontoolinput=()=>{clearTimeout(Gu),delete Q.dataset.streaming};function Ku(e){if(Q.innerHTML=``,e.title){let t=J(`div`,`header`);t.appendChild(J(`h1`,``,e.title)),t.appendChild(J(`span`,`badge streaming`,`⟳`)),Q.appendChild(t)}let t=J(`div`,`content`);if(Array.isArray(e.content)&&e.content.length>0&&jl(e.content[0]))for(let n of e.content)jl(n)&&t.appendChild(Zl(n));else t.appendChild(Yl(e.content));Q.appendChild(t)}Z.ontoolresult=e=>{if(clearTimeout(Gu),delete Q.dataset.streaming,e.structuredContent)try{Yu(e.structuredContent);return}catch(e){Ju(`Render error`,e);return}let t=e.content?.find(e=>e.type===`text`)?.text;if(!t){Q.innerHTML=`<p>No data received.</p>`;return}try{Yu(JSON.parse(t))}catch{Yu({content:t})}};var qu=null;function Ju(e,t){Q.innerHTML=``;let n=J(`div`,`error-panel`);n.appendChild(J(`h3`,``,`⚠ ${e}`)),n.appendChild(J(`pre`,``,t instanceof Error?t.message:String(t))),Q.appendChild(n)}function Yu(e){if(qu?.destroy&&qu.destroy(),qu=null,Q.innerHTML=``,!e.content){Q.innerHTML=`<p class="no-data">No content data received.</p>`;return}if(e.title){let t=J(`div`,`header`);t.appendChild(J(`h1`,``,e.title)),t.appendChild(J(`span`,`badge`,`KB`)),Q.appendChild(t)}let t=e.template?$.get(e.template):$.detect(e.content),n=J(`div`,`content`);if(t)qu=t,t.render(n,e.content,Vu);else if(Array.isArray(e.content)&&e.content.length>0&&jl(e.content[0]))for(let t of e.content)jl(t)&&n.appendChild(Zl(t));else n.appendChild(Yl(e.content));Q.appendChild(n),e.actions?.length&&Q.appendChild(ou(e.actions,Vu))}</script>
|
|
674
700
|
</head>
|
|
675
701
|
<body>
|
|
676
702
|
<div id="app">
|
|
@@ -16,4 +16,4 @@ import{getToolMeta as e}from"../../tool-metadata.js";import{buildBrowserHtml as
|
|
|
16
16
|
- "browser": Serves a themed dashboard on a local URL. Use ONLY when you need user interaction back (confirmations, selections, form input). The tool blocks until user clicks an action button, then returns their selection.
|
|
17
17
|
FORMAT RULE: If no user interaction is needed → use "html". If you need user input back → use "browser".
|
|
18
18
|
BROWSER WORKFLOW: After calling present with format "browser", you MUST extract the URL from the response and call openBrowserPage({ url }) to open it in VS Code Simple Browser. A system browser fallback also opens automatically, but always call openBrowserPage yourself.`,annotations:r.annotations,inputSchema:_,_meta:{ui:{resourceUri:h}}},async({format:e,title:t,content:r,actions:i,template:a})=>(e??`html`)===`browser`?await w(t,r,i,n,a):T(t,r,i,a))}async function w(e,r,i,a,o){let s=n(e,r),d=t(e,r,i,o),f=u({uri:`ui://kb/present-browser.html`,content:{type:`rawHtml`,htmlString:d},encoding:`text`,adapters:{mcpApps:{enabled:!0}}}),p,m,h=Array.isArray(i)?i:[],g=``,_;try{b&&=(b.close(),null),h.length>0&&(p=new Promise(e=>{m=e}));let e=!1;g=await new Promise((t,n)=>{let r=l((t,n)=>{if(e||(e=!0,_&&clearTimeout(_)),t.method===`POST`&&t.url===`/callback`){let e=``;t.on(`data`,t=>{e+=t.toString()}),t.on(`end`,()=>{n.writeHead(200,{"Content-Type":`application/json`,"Access-Control-Allow-Origin":`*`}),n.end(`{"ok":true}`);try{let t=JSON.parse(e);m?.(t)}catch{}});return}if(t.method===`OPTIONS`){n.writeHead(204,{"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST`,"Access-Control-Allow-Headers":`Content-Type`}),n.end();return}n.writeHead(200,{"Content-Type":`text/html; charset=utf-8`}),n.end(d)});r.listen(0,`127.0.0.1`,()=>{let i=r.address();if(typeof i==`object`&&i){b=r;let n=`http://127.0.0.1:${i.port}`;_=setTimeout(()=>{if(!e)try{c(process.platform===`win32`?`start "" "${n}"`:process.platform===`darwin`?`open "${n}"`:`xdg-open "${n}"`)}catch{}},8e3),_.unref(),t(n)}else n(Error(`Failed to start present server`))}),setTimeout(()=>{r.close(),b===r&&(b=null)},300*1e3).unref()})}catch{}let v=g?`${s}\n\n---\n🌐 **Dashboard opened in browser:** ${g}\n\n**IMPORTANT:** You MUST now open this URL using the \`openBrowserPage\` tool (Simple Browser). If that tool is unavailable, open the URL in the system browser as a fallback. If neither works, ask the user to open the URL manually.`:s;if(h.length>0&&a?.available&&p)try{let e=await Promise.race([p,new Promise((e,t)=>setTimeout(()=>t(Error(`timeout`)),300*1e3))]);return{content:[{type:`text`,text:`${v}\n\n✅ **Selected:** ${e.actionId} = \`${e.value}\``},f]}}catch{return{content:[{type:`text`,text:`${v}\n\n⚠️ *No selection received (timed out).*`},f]}}return{content:[{type:`text`,text:v},f]}}function T(e,r,i,a){let o=Array.isArray(i)?i:[],s=n(e,r);if(o.length>0){let e=[``];for(let t=0;t<o.length;t++){let n=o[t],r=typeof n.label==`string`?n.label:`Action ${t+1}`;if(n.type===`select`&&Array.isArray(n.options)){let i=n.options.map(e=>typeof e==`string`?e:e.label).join(`, `);e.push(`${t+1}. **${r}** — choose: ${i}`)}else e.push(`${t+1}. **${r}**`)}s+=`\n${e.join(`
|
|
19
|
-
`)}`}let c=u({uri:`ui://kb/present-static.html`,content:{type:`rawHtml`,htmlString:t(e,r,i,a)},encoding:`text`,adapters:{mcpApps:{enabled:!0}}});return{content:[{type:`text`,text:s},c],structuredContent:{actions:o}}}export{w as formatAsBrowser,T as formatAsHtml,S as getPresentHtml,C as registerPresentTool,x as resolvePresentHtml};
|
|
19
|
+
`)}`}let c=u({uri:`ui://kb/present-static.html`,content:{type:`rawHtml`,htmlString:t(e,r,i,a)},encoding:`text`,adapters:{mcpApps:{enabled:!0}}});return{content:[{type:`text`,text:s},c],structuredContent:{title:e,content:r,actions:o}}}export{w as formatAsBrowser,T as formatAsHtml,S as getPresentHtml,C as registerPresentTool,x as resolvePresentHtml};
|