@aborruso/ckan-mcp-server 0.4.106 → 0.4.108
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/LOG.md +15 -0
- package/README.md +2 -0
- package/dist/index.js +135 -29
- package/dist/worker.js +98 -93
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var Yb=Object.create;var Ba=Object.defineProperty;var Xb=Object.getOwnPropertyDescriptor;var ew=Object.getOwnPropertyNames;var tw=Object.getPrototypeOf,rw=Object.prototype.hasOwnProperty;var E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Os=(t,e)=>{for(var r in e)Ba(t,r,{get:e[r],enumerable:!0})},nw=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ew(e))!rw.call(t,o)&&o!==r&&Ba(t,o,{get:()=>e[o],enumerable:!(n=Xb(e,o))||n.enumerable});return t};var gp=(t,e,r)=>(r=t!=null?Yb(tw(t)):{},nw(e||!t||!t.__esModule?Ba(r,"default",{value:t,enumerable:!0}):r,t));var Lo=E(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.regexpCode=re.getEsmExportName=re.getProperty=re.safeStringify=re.stringify=re.strConcat=re.addCodeArg=re.str=re._=re.nil=re._Code=re.Name=re.IDENTIFIER=re._CodeOrName=void 0;var Do=class{};re._CodeOrName=Do;re.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var on=class extends Do{constructor(e){if(super(),!re.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};re.Name=on;var ft=class extends Do{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof on&&(r[n.str]=(r[n.str]||0)+1),r),{})}};re._Code=ft;re.nil=new ft("");function ug(t,...e){let r=[t[0]],n=0;for(;n<e.length;)El(r,e[n]),r.push(t[++n]);return new ft(r)}re._=ug;var Rl=new ft("+");function lg(t,...e){let r=[Zo(t[0])],n=0;for(;n<e.length;)r.push(Rl),El(r,e[n]),r.push(Rl,Zo(t[++n]));return e$(r),new ft(r)}re.str=lg;function El(t,e){e instanceof ft?t.push(...e._items):e instanceof on?t.push(e):t.push(n$(e))}re.addCodeArg=El;function e$(t){let e=1;for(;e<t.length-1;){if(t[e]===Rl){let r=t$(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function t$(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof on||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof on))return`"${t}${e.slice(1)}`}function r$(t,e){return e.emptyStr()?t:t.emptyStr()?e:lg`${t}${e}`}re.strConcat=r$;function n$(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Zo(Array.isArray(t)?t.join(","):t)}function o$(t){return new ft(Zo(t))}re.stringify=o$;function Zo(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}re.safeStringify=Zo;function s$(t){return typeof t=="string"&&re.IDENTIFIER.test(t)?new ft(`.${t}`):ug`[${t}]`}re.getProperty=s$;function i$(t){if(typeof t=="string"&&re.IDENTIFIER.test(t))return new ft(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}re.getEsmExportName=i$;function a$(t){return new ft(t.toString())}re.regexpCode=a$});var Cl=E(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.ValueScope=Ye.ValueScopeName=Ye.Scope=Ye.varKinds=Ye.UsedValueState=void 0;var Qe=Lo(),Pl=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Ii;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Ii||(Ye.UsedValueState=Ii={}));Ye.varKinds={const:new Qe.Name("const"),let:new Qe.Name("let"),var:new Qe.Name("var")};var Mi=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Qe.Name?e:this.name(e)}name(e){return new Qe.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Ye.Scope=Mi;var ji=class extends Qe.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Qe._)`.${new Qe.Name(r)}[${n}]`}};Ye.ValueScopeName=ji;var c$=(0,Qe._)`\n`,Al=class extends Mi{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?c$:Qe.nil}}get(){return this._scope}name(e){return new ji(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Qe._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=Qe.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Ii.Started);let l=r(u);if(l){let d=this.opts.es5?Ye.varKinds.var:Ye.varKinds.const;s=(0,Qe._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Qe._)`${s}${l}${this.opts._n}`;else throw new Pl(u);c.set(u,Ii.Completed)})}return s}};Ye.ValueScope=Al});var B=E(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.or=K.and=K.not=K.CodeGen=K.operators=K.varKinds=K.ValueScopeName=K.ValueScope=K.Scope=K.Name=K.regexpCode=K.stringify=K.getProperty=K.nil=K.strConcat=K.str=K._=void 0;var ee=Lo(),kt=Cl(),wr=Lo();Object.defineProperty(K,"_",{enumerable:!0,get:function(){return wr._}});Object.defineProperty(K,"str",{enumerable:!0,get:function(){return wr.str}});Object.defineProperty(K,"strConcat",{enumerable:!0,get:function(){return wr.strConcat}});Object.defineProperty(K,"nil",{enumerable:!0,get:function(){return wr.nil}});Object.defineProperty(K,"getProperty",{enumerable:!0,get:function(){return wr.getProperty}});Object.defineProperty(K,"stringify",{enumerable:!0,get:function(){return wr.stringify}});Object.defineProperty(K,"regexpCode",{enumerable:!0,get:function(){return wr.regexpCode}});Object.defineProperty(K,"Name",{enumerable:!0,get:function(){return wr.Name}});var Li=Cl();Object.defineProperty(K,"Scope",{enumerable:!0,get:function(){return Li.Scope}});Object.defineProperty(K,"ValueScope",{enumerable:!0,get:function(){return Li.ValueScope}});Object.defineProperty(K,"ValueScopeName",{enumerable:!0,get:function(){return Li.ValueScopeName}});Object.defineProperty(K,"varKinds",{enumerable:!0,get:function(){return Li.varKinds}});K.operators={GT:new ee._Code(">"),GTE:new ee._Code(">="),LT:new ee._Code("<"),LTE:new ee._Code("<="),EQ:new ee._Code("==="),NEQ:new ee._Code("!=="),NOT:new ee._Code("!"),OR:new ee._Code("||"),AND:new ee._Code("&&"),ADD:new ee._Code("+")};var Xt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Ol=class extends Xt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?kt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Un(this.rhs,e,r)),this}get names(){return this.rhs instanceof ee._CodeOrName?this.rhs.names:{}}},qi=class extends Xt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ee.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Un(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ee.Name?{}:{...this.lhs.names};return Zi(e,this.rhs)}},Nl=class extends qi{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Il=class extends Xt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Ml=class extends Xt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},jl=class extends Xt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},ql=class extends Xt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Un(this.code,e,r),this}get names(){return this.code instanceof ee._CodeOrName?this.code.names:{}}},Uo=class extends Xt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(u$(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>cn(e,r.names),{})}},er=class extends Uo{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Dl=class extends Uo{},Ln=class extends er{};Ln.kind="else";var sn=class t extends er{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Ln(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(dg(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Un(this.condition,e,r),this}get names(){let e=super.names;return Zi(e,this.condition),this.else&&cn(e,this.else.names),e}};sn.kind="if";var an=class extends er{};an.kind="for";var Zl=class extends an{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Un(this.iteration,e,r),this}get names(){return cn(super.names,this.iteration.names)}},Ll=class extends an{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?kt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Zi(super.names,this.from);return Zi(e,this.to)}},Di=class extends an{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Un(this.iterable,e,r),this}get names(){return cn(super.names,this.iterable.names)}},Fo=class extends er{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Fo.kind="func";var Ho=class extends Uo{render(e){return"return "+super.render(e)}};Ho.kind="return";var Ul=class extends er{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&cn(e,this.catch.names),this.finally&&cn(e,this.finally.names),e}},Vo=class extends er{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Vo.kind="catch";var Bo=class extends er{render(e){return"finally"+super.render(e)}};Bo.kind="finally";var Fl=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
2
|
-
`:""},this._extScope=e,this._scope=new kt.Scope({parent:e}),this._nodes=[new Dl]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Ol(e,s,n)),s}const(e,r,n){return this._def(kt.varKinds.const,e,r,n)}let(e,r,n){return this._def(kt.varKinds.let,e,r,n)}var(e,r,n){return this._def(kt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new qi(e,r,n))}add(e,r){return this._leafNode(new Nl(e,K.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ee.nil&&this._leafNode(new ql(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,ee.addCodeArg)(r,o));return r.push("}"),new ee._Code(r)}if(e,r,n){if(this._blockNode(new sn(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new sn(e))}else(){return this._elseNode(new Ln)}endIf(){return this._endBlockNode(sn,Ln)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Zl(e),r)}forRange(e,r,n,o,s=this.opts.es5?kt.varKinds.var:kt.varKinds.let){let i=this._scope.toName(e);return this._for(new Ll(s,i,r,n),()=>o(i))}forOf(e,r,n,o=kt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof ee.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ee._)`${i}.length`,a=>{this.var(s,(0,ee._)`${i}[${a}]`),n(s)})}return this._for(new Di("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?kt.varKinds.var:kt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ee._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Di("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(an)}label(e){return this._leafNode(new Il(e))}break(e){return this._leafNode(new Ml(e))}return(e){let r=new Ho;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Ho)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Ul;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new Vo(s),r(s)}return n&&(this._currNode=o.finally=new Bo,this.code(n)),this._endBlockNode(Vo,Bo)}throw(e){return this._leafNode(new jl(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ee.nil,n,o){return this._blockNode(new Fo(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Fo)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof sn))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};K.CodeGen=Fl;function cn(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Zi(t,e){return e instanceof ee._CodeOrName?cn(t,e.names):t}function Un(t,e,r){if(t instanceof ee.Name)return n(t);if(!o(t))return t;return new ee._Code(t._items.reduce((s,i)=>(i instanceof ee.Name&&(i=n(i)),i instanceof ee._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof ee._Code&&s._items.some(i=>i instanceof ee.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function u$(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function dg(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ee._)`!${Hl(t)}`}K.not=dg;var l$=fg(K.operators.AND);function d$(...t){return t.reduce(l$)}K.and=d$;var f$=fg(K.operators.OR);function p$(...t){return t.reduce(f$)}K.or=p$;function fg(t){return(e,r)=>e===ee.nil?r:r===ee.nil?e:(0,ee._)`${Hl(e)} ${t} ${Hl(r)}`}function Hl(t){return t instanceof ee.Name?t:(0,ee._)`(${t})`}});var ne=E(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.checkStrictMode=J.getErrorPath=J.Type=J.useFunc=J.setEvaluated=J.evaluatedPropsToName=J.mergeEvaluated=J.eachItem=J.unescapeJsonPointer=J.escapeJsonPointer=J.escapeFragment=J.unescapeFragment=J.schemaRefOrVal=J.schemaHasRulesButRef=J.schemaHasRules=J.checkUnknownRules=J.alwaysValidSchema=J.toHash=void 0;var ue=B(),m$=Lo();function h$(t){let e={};for(let r of t)e[r]=!0;return e}J.toHash=h$;function g$(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(hg(t,e),!gg(e,t.self.RULES.all))}J.alwaysValidSchema=g$;function hg(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||vg(t,`unknown keyword: "${s}"`)}J.checkUnknownRules=hg;function gg(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}J.schemaHasRules=gg;function y$(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}J.schemaHasRulesButRef=y$;function _$({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ue._)`${r}`}return(0,ue._)`${t}${e}${(0,ue.getProperty)(n)}`}J.schemaRefOrVal=_$;function v$(t){return yg(decodeURIComponent(t))}J.unescapeFragment=v$;function b$(t){return encodeURIComponent(Bl(t))}J.escapeFragment=b$;function Bl(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}J.escapeJsonPointer=Bl;function yg(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}J.unescapeJsonPointer=yg;function w$(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}J.eachItem=w$;function pg({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ue.Name?(s instanceof ue.Name?t(o,s,i):e(o,s,i),i):s instanceof ue.Name?(e(o,i,s),s):r(s,i);return a===ue.Name&&!(c instanceof ue.Name)?n(o,c):c}}J.mergeEvaluated={props:pg({mergeNames:(t,e,r)=>t.if((0,ue._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ue._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ue._)`${r} || {}`).code((0,ue._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ue._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ue._)`${r} || {}`),Kl(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:_g}),items:pg({mergeNames:(t,e,r)=>t.if((0,ue._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ue._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ue._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ue._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function _g(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ue._)`{}`);return e!==void 0&&Kl(t,r,e),r}J.evaluatedPropsToName=_g;function Kl(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ue._)`${e}${(0,ue.getProperty)(n)}`,!0))}J.setEvaluated=Kl;var mg={};function x$(t,e){return t.scopeValue("func",{ref:e,code:mg[e.code]||(mg[e.code]=new m$._Code(e.code))})}J.useFunc=x$;var Vl;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Vl||(J.Type=Vl={}));function k$(t,e,r){if(t instanceof ue.Name){let n=e===Vl.Num;return r?n?(0,ue._)`"[" + ${t} + "]"`:(0,ue._)`"['" + ${t} + "']"`:n?(0,ue._)`"/" + ${t}`:(0,ue._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ue.getProperty)(t).toString():"/"+Bl(t)}J.getErrorPath=k$;function vg(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}J.checkStrictMode=vg});var tr=E(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});var qe=B(),S$={data:new qe.Name("data"),valCxt:new qe.Name("valCxt"),instancePath:new qe.Name("instancePath"),parentData:new qe.Name("parentData"),parentDataProperty:new qe.Name("parentDataProperty"),rootData:new qe.Name("rootData"),dynamicAnchors:new qe.Name("dynamicAnchors"),vErrors:new qe.Name("vErrors"),errors:new qe.Name("errors"),this:new qe.Name("this"),self:new qe.Name("self"),scope:new qe.Name("scope"),json:new qe.Name("json"),jsonPos:new qe.Name("jsonPos"),jsonLen:new qe.Name("jsonLen"),jsonPart:new qe.Name("jsonPart")};Jl.default=S$});var Ko=E(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.extendErrors=De.resetErrorsCount=De.reportExtraError=De.reportError=De.keyword$DataError=De.keywordError=void 0;var te=B(),Ui=ne(),Fe=tr();De.keywordError={message:({keyword:t})=>(0,te.str)`must pass "${t}" keyword validation`};De.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,te.str)`"${t}" keyword must be ${e} ($data)`:(0,te.str)`"${t}" keyword is invalid ($data)`};function $$(t,e=De.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=xg(t,e,r);n??(i||a)?bg(s,c):wg(o,(0,te._)`[${c}]`)}De.reportError=$$;function T$(t,e=De.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=xg(t,e,r);bg(o,a),s||i||wg(n,Fe.default.vErrors)}De.reportExtraError=T$;function z$(t,e){t.assign(Fe.default.errors,e),t.if((0,te._)`${Fe.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,te._)`${Fe.default.vErrors}.length`,e),()=>t.assign(Fe.default.vErrors,null)))}De.resetErrorsCount=z$;function R$({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,Fe.default.errors,a=>{t.const(i,(0,te._)`${Fe.default.vErrors}[${a}]`),t.if((0,te._)`${i}.instancePath === undefined`,()=>t.assign((0,te._)`${i}.instancePath`,(0,te.strConcat)(Fe.default.instancePath,s.errorPath))),t.assign((0,te._)`${i}.schemaPath`,(0,te.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,te._)`${i}.schema`,r),t.assign((0,te._)`${i}.data`,n))})}De.extendErrors=R$;function bg(t,e){let r=t.const("err",e);t.if((0,te._)`${Fe.default.vErrors} === null`,()=>t.assign(Fe.default.vErrors,(0,te._)`[${r}]`),(0,te._)`${Fe.default.vErrors}.push(${r})`),t.code((0,te._)`${Fe.default.errors}++`)}function wg(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,te._)`new ${t.ValidationError}(${e})`):(r.assign((0,te._)`${n}.errors`,e),r.return(!1))}var un={keyword:new te.Name("keyword"),schemaPath:new te.Name("schemaPath"),params:new te.Name("params"),propertyName:new te.Name("propertyName"),message:new te.Name("message"),schema:new te.Name("schema"),parentSchema:new te.Name("parentSchema")};function xg(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,te._)`{}`:E$(t,e,r)}function E$(t,e,r={}){let{gen:n,it:o}=t,s=[P$(o,r),A$(t,r)];return C$(t,e,s),n.object(...s)}function P$({errorPath:t},{instancePath:e}){let r=e?(0,te.str)`${t}${(0,Ui.getErrorPath)(e,Ui.Type.Str)}`:t;return[Fe.default.instancePath,(0,te.strConcat)(Fe.default.instancePath,r)]}function A$({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,te.str)`${e}/${t}`;return r&&(o=(0,te.str)`${o}${(0,Ui.getErrorPath)(r,Ui.Type.Str)}`),[un.schemaPath,o]}function C$(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([un.keyword,o],[un.params,typeof e=="function"?e(t):e||(0,te._)`{}`]),c.messages&&n.push([un.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([un.schema,i],[un.parentSchema,(0,te._)`${l}${d}`],[Fe.default.data,s]),u&&n.push([un.propertyName,u])}});var Sg=E(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.boolOrEmptySchema=Fn.topBoolOrEmptySchema=void 0;var O$=Ko(),N$=B(),I$=tr(),M$={message:"boolean schema is false"};function j$(t){let{gen:e,schema:r,validateName:n}=t;r===!1?kg(t,!1):typeof r=="object"&&r.$async===!0?e.return(I$.default.data):(e.assign((0,N$._)`${n}.errors`,null),e.return(!0))}Fn.topBoolOrEmptySchema=j$;function q$(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),kg(t)):r.var(e,!0)}Fn.boolOrEmptySchema=q$;function kg(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,O$.reportError)(o,M$,void 0,e)}});var Wl=E(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.getRules=Hn.isJSONType=void 0;var D$=["string","number","integer","boolean","null","object","array"],Z$=new Set(D$);function L$(t){return typeof t=="string"&&Z$.has(t)}Hn.isJSONType=L$;function U$(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Hn.getRules=U$});var Gl=E(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.shouldUseRule=xr.shouldUseGroup=xr.schemaHasRulesForType=void 0;function F$({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&$g(t,n)}xr.schemaHasRulesForType=F$;function $g(t,e){return e.rules.some(r=>Tg(t,r))}xr.shouldUseGroup=$g;function Tg(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}xr.shouldUseRule=Tg});var Jo=E(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.reportTypeError=Ze.checkDataTypes=Ze.checkDataType=Ze.coerceAndCheckDataType=Ze.getJSONTypes=Ze.getSchemaTypes=Ze.DataType=void 0;var H$=Wl(),V$=Gl(),B$=Ko(),H=B(),zg=ne(),Vn;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Vn||(Ze.DataType=Vn={}));function K$(t){let e=Rg(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ze.getSchemaTypes=K$;function Rg(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(H$.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ze.getJSONTypes=Rg;function J$(t,e){let{gen:r,data:n,opts:o}=t,s=W$(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,V$.schemaHasRulesForType)(t,e[0]));if(i){let a=Yl(e,n,o.strictNumbers,Vn.Wrong);r.if(a,()=>{s.length?G$(t,e,s):Xl(t)})}return i}Ze.coerceAndCheckDataType=J$;var Eg=new Set(["string","number","integer","boolean","null"]);function W$(t,e){return e?t.filter(r=>Eg.has(r)||e==="array"&&r==="array"):[]}function G$(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,H._)`typeof ${o}`),a=n.let("coerced",(0,H._)`undefined`);s.coerceTypes==="array"&&n.if((0,H._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,H._)`${o}[0]`).assign(i,(0,H._)`typeof ${o}`).if(Yl(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,H._)`${a} !== undefined`);for(let u of r)(Eg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Xl(t),n.endIf(),n.if((0,H._)`${a} !== undefined`,()=>{n.assign(o,a),Q$(t,a)});function c(u){switch(u){case"string":n.elseIf((0,H._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,H._)`"" + ${o}`).elseIf((0,H._)`${o} === null`).assign(a,(0,H._)`""`);return;case"number":n.elseIf((0,H._)`${i} == "boolean" || ${o} === null
|
|
1
|
+
var rw=Object.create;var Ja=Object.defineProperty;var nw=Object.getOwnPropertyDescriptor;var ow=Object.getOwnPropertyNames;var sw=Object.getPrototypeOf,iw=Object.prototype.hasOwnProperty;var E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Os=(t,e)=>{for(var r in e)Ja(t,r,{get:e[r],enumerable:!0})},aw=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ow(e))!iw.call(t,o)&&o!==r&&Ja(t,o,{get:()=>e[o],enumerable:!(n=nw(e,o))||n.enumerable});return t};var vp=(t,e,r)=>(r=t!=null?rw(sw(t)):{},aw(e||!t||!t.__esModule?Ja(r,"default",{value:t,enumerable:!0}):r,t));var Lo=E(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.regexpCode=re.getEsmExportName=re.getProperty=re.safeStringify=re.stringify=re.strConcat=re.addCodeArg=re.str=re._=re.nil=re._Code=re.Name=re.IDENTIFIER=re._CodeOrName=void 0;var Do=class{};re._CodeOrName=Do;re.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var on=class extends Do{constructor(e){if(super(),!re.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};re.Name=on;var ft=class extends Do{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof on&&(r[n.str]=(r[n.str]||0)+1),r),{})}};re._Code=ft;re.nil=new ft("");function fg(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Al(r,e[n]),r.push(t[++n]);return new ft(r)}re._=fg;var Pl=new ft("+");function pg(t,...e){let r=[Zo(t[0])],n=0;for(;n<e.length;)r.push(Pl),Al(r,e[n]),r.push(Pl,Zo(t[++n]));return o$(r),new ft(r)}re.str=pg;function Al(t,e){e instanceof ft?t.push(...e._items):e instanceof on?t.push(e):t.push(a$(e))}re.addCodeArg=Al;function o$(t){let e=1;for(;e<t.length-1;){if(t[e]===Pl){let r=s$(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function s$(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof on||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof on))return`"${t}${e.slice(1)}`}function i$(t,e){return e.emptyStr()?t:t.emptyStr()?e:pg`${t}${e}`}re.strConcat=i$;function a$(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:Zo(Array.isArray(t)?t.join(","):t)}function c$(t){return new ft(Zo(t))}re.stringify=c$;function Zo(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}re.safeStringify=Zo;function u$(t){return typeof t=="string"&&re.IDENTIFIER.test(t)?new ft(`.${t}`):fg`[${t}]`}re.getProperty=u$;function l$(t){if(typeof t=="string"&&re.IDENTIFIER.test(t))return new ft(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}re.getEsmExportName=l$;function d$(t){return new ft(t.toString())}re.regexpCode=d$});var Nl=E(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.ValueScope=Ye.ValueScopeName=Ye.Scope=Ye.varKinds=Ye.UsedValueState=void 0;var Qe=Lo(),Cl=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Ii;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Ii||(Ye.UsedValueState=Ii={}));Ye.varKinds={const:new Qe.Name("const"),let:new Qe.Name("let"),var:new Qe.Name("var")};var Mi=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Qe.Name?e:this.name(e)}name(e){return new Qe.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Ye.Scope=Mi;var ji=class extends Qe.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Qe._)`.${new Qe.Name(r)}[${n}]`}};Ye.ValueScopeName=ji;var f$=(0,Qe._)`\n`,Ol=class extends Mi{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?f$:Qe.nil}}get(){return this._scope}name(e){return new ji(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Qe._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=Qe.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Ii.Started);let l=r(u);if(l){let d=this.opts.es5?Ye.varKinds.var:Ye.varKinds.const;s=(0,Qe._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Qe._)`${s}${l}${this.opts._n}`;else throw new Cl(u);c.set(u,Ii.Completed)})}return s}};Ye.ValueScope=Ol});var B=E(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.or=K.and=K.not=K.CodeGen=K.operators=K.varKinds=K.ValueScopeName=K.ValueScope=K.Scope=K.Name=K.regexpCode=K.stringify=K.getProperty=K.nil=K.strConcat=K.str=K._=void 0;var ee=Lo(),kt=Nl(),wr=Lo();Object.defineProperty(K,"_",{enumerable:!0,get:function(){return wr._}});Object.defineProperty(K,"str",{enumerable:!0,get:function(){return wr.str}});Object.defineProperty(K,"strConcat",{enumerable:!0,get:function(){return wr.strConcat}});Object.defineProperty(K,"nil",{enumerable:!0,get:function(){return wr.nil}});Object.defineProperty(K,"getProperty",{enumerable:!0,get:function(){return wr.getProperty}});Object.defineProperty(K,"stringify",{enumerable:!0,get:function(){return wr.stringify}});Object.defineProperty(K,"regexpCode",{enumerable:!0,get:function(){return wr.regexpCode}});Object.defineProperty(K,"Name",{enumerable:!0,get:function(){return wr.Name}});var Li=Nl();Object.defineProperty(K,"Scope",{enumerable:!0,get:function(){return Li.Scope}});Object.defineProperty(K,"ValueScope",{enumerable:!0,get:function(){return Li.ValueScope}});Object.defineProperty(K,"ValueScopeName",{enumerable:!0,get:function(){return Li.ValueScopeName}});Object.defineProperty(K,"varKinds",{enumerable:!0,get:function(){return Li.varKinds}});K.operators={GT:new ee._Code(">"),GTE:new ee._Code(">="),LT:new ee._Code("<"),LTE:new ee._Code("<="),EQ:new ee._Code("==="),NEQ:new ee._Code("!=="),NOT:new ee._Code("!"),OR:new ee._Code("||"),AND:new ee._Code("&&"),ADD:new ee._Code("+")};var Xt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Il=class extends Xt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?kt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=Un(this.rhs,e,r)),this}get names(){return this.rhs instanceof ee._CodeOrName?this.rhs.names:{}}},qi=class extends Xt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ee.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=Un(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ee.Name?{}:{...this.lhs.names};return Zi(e,this.rhs)}},Ml=class extends qi{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},jl=class extends Xt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},ql=class extends Xt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Dl=class extends Xt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Zl=class extends Xt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=Un(this.code,e,r),this}get names(){return this.code instanceof ee._CodeOrName?this.code.names:{}}},Uo=class extends Xt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(p$(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>cn(e,r.names),{})}},er=class extends Uo{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Ll=class extends Uo{},Ln=class extends er{};Ln.kind="else";var sn=class t extends er{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Ln(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(mg(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=Un(this.condition,e,r),this}get names(){let e=super.names;return Zi(e,this.condition),this.else&&cn(e,this.else.names),e}};sn.kind="if";var an=class extends er{};an.kind="for";var Ul=class extends an{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=Un(this.iteration,e,r),this}get names(){return cn(super.names,this.iteration.names)}},Fl=class extends an{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?kt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Zi(super.names,this.from);return Zi(e,this.to)}},Di=class extends an{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=Un(this.iterable,e,r),this}get names(){return cn(super.names,this.iterable.names)}},Fo=class extends er{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Fo.kind="func";var Ho=class extends Uo{render(e){return"return "+super.render(e)}};Ho.kind="return";var Hl=class extends er{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&cn(e,this.catch.names),this.finally&&cn(e,this.finally.names),e}},Vo=class extends er{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Vo.kind="catch";var Bo=class extends er{render(e){return"finally"+super.render(e)}};Bo.kind="finally";var Vl=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
2
|
+
`:""},this._extScope=e,this._scope=new kt.Scope({parent:e}),this._nodes=[new Ll]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Il(e,s,n)),s}const(e,r,n){return this._def(kt.varKinds.const,e,r,n)}let(e,r,n){return this._def(kt.varKinds.let,e,r,n)}var(e,r,n){return this._def(kt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new qi(e,r,n))}add(e,r){return this._leafNode(new Ml(e,K.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ee.nil&&this._leafNode(new Zl(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,ee.addCodeArg)(r,o));return r.push("}"),new ee._Code(r)}if(e,r,n){if(this._blockNode(new sn(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new sn(e))}else(){return this._elseNode(new Ln)}endIf(){return this._endBlockNode(sn,Ln)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ul(e),r)}forRange(e,r,n,o,s=this.opts.es5?kt.varKinds.var:kt.varKinds.let){let i=this._scope.toName(e);return this._for(new Fl(s,i,r,n),()=>o(i))}forOf(e,r,n,o=kt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof ee.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ee._)`${i}.length`,a=>{this.var(s,(0,ee._)`${i}[${a}]`),n(s)})}return this._for(new Di("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?kt.varKinds.var:kt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ee._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Di("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(an)}label(e){return this._leafNode(new jl(e))}break(e){return this._leafNode(new ql(e))}return(e){let r=new Ho;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Ho)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Hl;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new Vo(s),r(s)}return n&&(this._currNode=o.finally=new Bo,this.code(n)),this._endBlockNode(Vo,Bo)}throw(e){return this._leafNode(new Dl(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ee.nil,n,o){return this._blockNode(new Fo(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Fo)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof sn))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};K.CodeGen=Vl;function cn(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Zi(t,e){return e instanceof ee._CodeOrName?cn(t,e.names):t}function Un(t,e,r){if(t instanceof ee.Name)return n(t);if(!o(t))return t;return new ee._Code(t._items.reduce((s,i)=>(i instanceof ee.Name&&(i=n(i)),i instanceof ee._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof ee._Code&&s._items.some(i=>i instanceof ee.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function p$(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function mg(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ee._)`!${Bl(t)}`}K.not=mg;var m$=hg(K.operators.AND);function h$(...t){return t.reduce(m$)}K.and=h$;var g$=hg(K.operators.OR);function y$(...t){return t.reduce(g$)}K.or=y$;function hg(t){return(e,r)=>e===ee.nil?r:r===ee.nil?e:(0,ee._)`${Bl(e)} ${t} ${Bl(r)}`}function Bl(t){return t instanceof ee.Name?t:(0,ee._)`(${t})`}});var ne=E(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.checkStrictMode=J.getErrorPath=J.Type=J.useFunc=J.setEvaluated=J.evaluatedPropsToName=J.mergeEvaluated=J.eachItem=J.unescapeJsonPointer=J.escapeJsonPointer=J.escapeFragment=J.unescapeFragment=J.schemaRefOrVal=J.schemaHasRulesButRef=J.schemaHasRules=J.checkUnknownRules=J.alwaysValidSchema=J.toHash=void 0;var ue=B(),_$=Lo();function v$(t){let e={};for(let r of t)e[r]=!0;return e}J.toHash=v$;function b$(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(_g(t,e),!vg(e,t.self.RULES.all))}J.alwaysValidSchema=b$;function _g(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||xg(t,`unknown keyword: "${s}"`)}J.checkUnknownRules=_g;function vg(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}J.schemaHasRules=vg;function w$(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}J.schemaHasRulesButRef=w$;function x$({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ue._)`${r}`}return(0,ue._)`${t}${e}${(0,ue.getProperty)(n)}`}J.schemaRefOrVal=x$;function k$(t){return bg(decodeURIComponent(t))}J.unescapeFragment=k$;function S$(t){return encodeURIComponent(Jl(t))}J.escapeFragment=S$;function Jl(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}J.escapeJsonPointer=Jl;function bg(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}J.unescapeJsonPointer=bg;function $$(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}J.eachItem=$$;function gg({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ue.Name?(s instanceof ue.Name?t(o,s,i):e(o,s,i),i):s instanceof ue.Name?(e(o,i,s),s):r(s,i);return a===ue.Name&&!(c instanceof ue.Name)?n(o,c):c}}J.mergeEvaluated={props:gg({mergeNames:(t,e,r)=>t.if((0,ue._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ue._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ue._)`${r} || {}`).code((0,ue._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ue._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ue._)`${r} || {}`),Wl(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:wg}),items:gg({mergeNames:(t,e,r)=>t.if((0,ue._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ue._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ue._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ue._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function wg(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ue._)`{}`);return e!==void 0&&Wl(t,r,e),r}J.evaluatedPropsToName=wg;function Wl(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ue._)`${e}${(0,ue.getProperty)(n)}`,!0))}J.setEvaluated=Wl;var yg={};function T$(t,e){return t.scopeValue("func",{ref:e,code:yg[e.code]||(yg[e.code]=new _$._Code(e.code))})}J.useFunc=T$;var Kl;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Kl||(J.Type=Kl={}));function z$(t,e,r){if(t instanceof ue.Name){let n=e===Kl.Num;return r?n?(0,ue._)`"[" + ${t} + "]"`:(0,ue._)`"['" + ${t} + "']"`:n?(0,ue._)`"/" + ${t}`:(0,ue._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ue.getProperty)(t).toString():"/"+Jl(t)}J.getErrorPath=z$;function xg(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}J.checkStrictMode=xg});var tr=E(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});var qe=B(),R$={data:new qe.Name("data"),valCxt:new qe.Name("valCxt"),instancePath:new qe.Name("instancePath"),parentData:new qe.Name("parentData"),parentDataProperty:new qe.Name("parentDataProperty"),rootData:new qe.Name("rootData"),dynamicAnchors:new qe.Name("dynamicAnchors"),vErrors:new qe.Name("vErrors"),errors:new qe.Name("errors"),this:new qe.Name("this"),self:new qe.Name("self"),scope:new qe.Name("scope"),json:new qe.Name("json"),jsonPos:new qe.Name("jsonPos"),jsonLen:new qe.Name("jsonLen"),jsonPart:new qe.Name("jsonPart")};Gl.default=R$});var Ko=E(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.extendErrors=De.resetErrorsCount=De.reportExtraError=De.reportError=De.keyword$DataError=De.keywordError=void 0;var te=B(),Ui=ne(),Fe=tr();De.keywordError={message:({keyword:t})=>(0,te.str)`must pass "${t}" keyword validation`};De.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,te.str)`"${t}" keyword must be ${e} ($data)`:(0,te.str)`"${t}" keyword is invalid ($data)`};function E$(t,e=De.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=$g(t,e,r);n??(i||a)?kg(s,c):Sg(o,(0,te._)`[${c}]`)}De.reportError=E$;function P$(t,e=De.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=$g(t,e,r);kg(o,a),s||i||Sg(n,Fe.default.vErrors)}De.reportExtraError=P$;function A$(t,e){t.assign(Fe.default.errors,e),t.if((0,te._)`${Fe.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,te._)`${Fe.default.vErrors}.length`,e),()=>t.assign(Fe.default.vErrors,null)))}De.resetErrorsCount=A$;function C$({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,Fe.default.errors,a=>{t.const(i,(0,te._)`${Fe.default.vErrors}[${a}]`),t.if((0,te._)`${i}.instancePath === undefined`,()=>t.assign((0,te._)`${i}.instancePath`,(0,te.strConcat)(Fe.default.instancePath,s.errorPath))),t.assign((0,te._)`${i}.schemaPath`,(0,te.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,te._)`${i}.schema`,r),t.assign((0,te._)`${i}.data`,n))})}De.extendErrors=C$;function kg(t,e){let r=t.const("err",e);t.if((0,te._)`${Fe.default.vErrors} === null`,()=>t.assign(Fe.default.vErrors,(0,te._)`[${r}]`),(0,te._)`${Fe.default.vErrors}.push(${r})`),t.code((0,te._)`${Fe.default.errors}++`)}function Sg(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,te._)`new ${t.ValidationError}(${e})`):(r.assign((0,te._)`${n}.errors`,e),r.return(!1))}var un={keyword:new te.Name("keyword"),schemaPath:new te.Name("schemaPath"),params:new te.Name("params"),propertyName:new te.Name("propertyName"),message:new te.Name("message"),schema:new te.Name("schema"),parentSchema:new te.Name("parentSchema")};function $g(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,te._)`{}`:O$(t,e,r)}function O$(t,e,r={}){let{gen:n,it:o}=t,s=[N$(o,r),I$(t,r)];return M$(t,e,s),n.object(...s)}function N$({errorPath:t},{instancePath:e}){let r=e?(0,te.str)`${t}${(0,Ui.getErrorPath)(e,Ui.Type.Str)}`:t;return[Fe.default.instancePath,(0,te.strConcat)(Fe.default.instancePath,r)]}function I$({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,te.str)`${e}/${t}`;return r&&(o=(0,te.str)`${o}${(0,Ui.getErrorPath)(r,Ui.Type.Str)}`),[un.schemaPath,o]}function M$(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([un.keyword,o],[un.params,typeof e=="function"?e(t):e||(0,te._)`{}`]),c.messages&&n.push([un.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([un.schema,i],[un.parentSchema,(0,te._)`${l}${d}`],[Fe.default.data,s]),u&&n.push([un.propertyName,u])}});var zg=E(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.boolOrEmptySchema=Fn.topBoolOrEmptySchema=void 0;var j$=Ko(),q$=B(),D$=tr(),Z$={message:"boolean schema is false"};function L$(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Tg(t,!1):typeof r=="object"&&r.$async===!0?e.return(D$.default.data):(e.assign((0,q$._)`${n}.errors`,null),e.return(!0))}Fn.topBoolOrEmptySchema=L$;function U$(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Tg(t)):r.var(e,!0)}Fn.boolOrEmptySchema=U$;function Tg(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,j$.reportError)(o,Z$,void 0,e)}});var Ql=E(Hn=>{"use strict";Object.defineProperty(Hn,"__esModule",{value:!0});Hn.getRules=Hn.isJSONType=void 0;var F$=["string","number","integer","boolean","null","object","array"],H$=new Set(F$);function V$(t){return typeof t=="string"&&H$.has(t)}Hn.isJSONType=V$;function B$(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Hn.getRules=B$});var Yl=E(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.shouldUseRule=xr.shouldUseGroup=xr.schemaHasRulesForType=void 0;function K$({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Rg(t,n)}xr.schemaHasRulesForType=K$;function Rg(t,e){return e.rules.some(r=>Eg(t,r))}xr.shouldUseGroup=Rg;function Eg(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}xr.shouldUseRule=Eg});var Jo=E(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.reportTypeError=Ze.checkDataTypes=Ze.checkDataType=Ze.coerceAndCheckDataType=Ze.getJSONTypes=Ze.getSchemaTypes=Ze.DataType=void 0;var J$=Ql(),W$=Yl(),G$=Ko(),H=B(),Pg=ne(),Vn;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Vn||(Ze.DataType=Vn={}));function Q$(t){let e=Ag(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ze.getSchemaTypes=Q$;function Ag(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(J$.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ze.getJSONTypes=Ag;function Y$(t,e){let{gen:r,data:n,opts:o}=t,s=X$(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,W$.schemaHasRulesForType)(t,e[0]));if(i){let a=ed(e,n,o.strictNumbers,Vn.Wrong);r.if(a,()=>{s.length?eT(t,e,s):td(t)})}return i}Ze.coerceAndCheckDataType=Y$;var Cg=new Set(["string","number","integer","boolean","null"]);function X$(t,e){return e?t.filter(r=>Cg.has(r)||e==="array"&&r==="array"):[]}function eT(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,H._)`typeof ${o}`),a=n.let("coerced",(0,H._)`undefined`);s.coerceTypes==="array"&&n.if((0,H._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,H._)`${o}[0]`).assign(i,(0,H._)`typeof ${o}`).if(ed(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,H._)`${a} !== undefined`);for(let u of r)(Cg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),td(t),n.endIf(),n.if((0,H._)`${a} !== undefined`,()=>{n.assign(o,a),tT(t,a)});function c(u){switch(u){case"string":n.elseIf((0,H._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,H._)`"" + ${o}`).elseIf((0,H._)`${o} === null`).assign(a,(0,H._)`""`);return;case"number":n.elseIf((0,H._)`${i} == "boolean" || ${o} === null
|
|
3
3
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,H._)`+${o}`);return;case"integer":n.elseIf((0,H._)`${i} === "boolean" || ${o} === null
|
|
4
4
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,H._)`+${o}`);return;case"boolean":n.elseIf((0,H._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,H._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,H._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,H._)`${i} === "string" || ${i} === "number"
|
|
5
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,H._)`[${o}]`)}}}function Q$({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,H._)`${e} !== undefined`,()=>t.assign((0,H._)`${e}[${r}]`,n))}function Ql(t,e,r,n=Vn.Correct){let o=n===Vn.Correct?H.operators.EQ:H.operators.NEQ,s;switch(t){case"null":return(0,H._)`${e} ${o} null`;case"array":s=(0,H._)`Array.isArray(${e})`;break;case"object":s=(0,H._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,H._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,H._)`typeof ${e} ${o} ${t}`}return n===Vn.Correct?s:(0,H.not)(s);function i(a=H.nil){return(0,H.and)((0,H._)`typeof ${e} == "number"`,a,r?(0,H._)`isFinite(${e})`:H.nil)}}Ze.checkDataType=Ql;function Yl(t,e,r,n){if(t.length===1)return Ql(t[0],e,r,n);let o,s=(0,zg.toHash)(t);if(s.array&&s.object){let i=(0,H._)`typeof ${e} != "object"`;o=s.null?i:(0,H._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=H.nil;s.number&&delete s.integer;for(let i in s)o=(0,H.and)(o,Ql(i,e,r,n));return o}Ze.checkDataTypes=Yl;var Y$={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,H._)`{type: ${t}}`:(0,H._)`{type: ${e}}`};function Xl(t){let e=X$(t);(0,B$.reportError)(e,Y$)}Ze.reportTypeError=Xl;function X$(t){let{gen:e,data:r,schema:n}=t,o=(0,zg.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Ag=E(Fi=>{"use strict";Object.defineProperty(Fi,"__esModule",{value:!0});Fi.assignDefaults=void 0;var Bn=B(),eT=ne();function tT(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Pg(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Pg(t,s,o.default))}Fi.assignDefaults=tT;function Pg(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,Bn._)`${s}${(0,Bn.getProperty)(e)}`;if(o){(0,eT.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Bn._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Bn._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Bn._)`${a} = ${(0,Bn.stringify)(r)}`)}});var pt=E(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.validateUnion=ce.validateArray=ce.usePattern=ce.callValidateCode=ce.schemaProperties=ce.allSchemaProperties=ce.noPropertyInData=ce.propertyInData=ce.isOwnProperty=ce.hasPropFunc=ce.reportMissingProp=ce.checkMissingProp=ce.checkReportMissingProp=void 0;var he=B(),ed=ne(),kr=tr(),rT=ne();function nT(t,e){let{gen:r,data:n,it:o}=t;r.if(rd(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,he._)`${e}`},!0),t.error()})}ce.checkReportMissingProp=nT;function oT({gen:t,data:e,it:{opts:r}},n,o){return(0,he.or)(...n.map(s=>(0,he.and)(rd(t,e,s,r.ownProperties),(0,he._)`${o} = ${s}`)))}ce.checkMissingProp=oT;function sT(t,e){t.setParams({missingProperty:e},!0),t.error()}ce.reportMissingProp=sT;function Cg(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,he._)`Object.prototype.hasOwnProperty`})}ce.hasPropFunc=Cg;function td(t,e,r){return(0,he._)`${Cg(t)}.call(${e}, ${r})`}ce.isOwnProperty=td;function iT(t,e,r,n){let o=(0,he._)`${e}${(0,he.getProperty)(r)} !== undefined`;return n?(0,he._)`${o} && ${td(t,e,r)}`:o}ce.propertyInData=iT;function rd(t,e,r,n){let o=(0,he._)`${e}${(0,he.getProperty)(r)} === undefined`;return n?(0,he.or)(o,(0,he.not)(td(t,e,r))):o}ce.noPropertyInData=rd;function Og(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}ce.allSchemaProperties=Og;function aT(t,e){return Og(e).filter(r=>!(0,ed.alwaysValidSchema)(t,e[r]))}ce.schemaProperties=aT;function cT({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,he._)`${t}, ${e}, ${n}${o}`:e,d=[[kr.default.instancePath,(0,he.strConcat)(kr.default.instancePath,s)],[kr.default.parentData,i.parentData],[kr.default.parentDataProperty,i.parentDataProperty],[kr.default.rootData,kr.default.rootData]];i.opts.dynamicRef&&d.push([kr.default.dynamicAnchors,kr.default.dynamicAnchors]);let p=(0,he._)`${l}, ${r.object(...d)}`;return c!==he.nil?(0,he._)`${a}.call(${c}, ${p})`:(0,he._)`${a}(${p})`}ce.callValidateCode=cT;var uT=(0,he._)`new RegExp`;function lT({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,he._)`${o.code==="new RegExp"?uT:(0,rT.useFunc)(t,o)}(${r}, ${n})`})}ce.usePattern=lT;function dT(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,he._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:ed.Type.Num},s),e.if((0,he.not)(s),a)})}}ce.validateArray=dT;function fT(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,ed.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,he._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,he.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}ce.validateUnion=fT});var Mg=E(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.validateKeywordUsage=It.validSchemaType=It.funcKeywordCode=It.macroKeywordCode=void 0;var He=B(),ln=tr(),pT=pt(),mT=Ko();function hT(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=Ig(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:He.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}It.macroKeywordCode=hT;function gT(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;_T(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=Ig(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)h(),e.modifying&&Ng(t),g(()=>t.error());else{let y=e.async?m():f();e.modifying&&Ng(t),g(()=>yT(t,y))}}function m(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,He._)`await `),b=>n.assign(d,!1).if((0,He._)`${b} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,He._)`${b}.errors`),()=>n.throw(b))),y}function f(){let y=(0,He._)`${l}.errors`;return n.assign(y,null),h(He.nil),y}function h(y=e.async?(0,He._)`await `:He.nil){let b=c.opts.passContext?ln.default.this:ln.default.self,k=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,He._)`${y}${(0,pT.callValidateCode)(t,l,b,k)}`,e.modifying)}function g(y){var b;n.if((0,He.not)((b=e.valid)!==null&&b!==void 0?b:d),y)}}It.funcKeywordCode=gT;function Ng(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,He._)`${n.parentData}[${n.parentDataProperty}]`))}function yT(t,e){let{gen:r}=t;r.if((0,He._)`Array.isArray(${e})`,()=>{r.assign(ln.default.vErrors,(0,He._)`${ln.default.vErrors} === null ? ${e} : ${ln.default.vErrors}.concat(${e})`).assign(ln.default.errors,(0,He._)`${ln.default.vErrors}.length`),(0,mT.extendErrors)(t)},()=>t.error())}function _T({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Ig(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,He.stringify)(r)})}function vT(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}It.validSchemaType=vT;function bT({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}It.validateKeywordUsage=bT});var qg=E(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.extendSubschemaMode=Sr.extendSubschemaData=Sr.getSubschema=void 0;var Mt=B(),jg=ne();function wT(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Mt._)`${t.schemaPath}${(0,Mt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Mt._)`${t.schemaPath}${(0,Mt.getProperty)(e)}${(0,Mt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,jg.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Sr.getSubschema=wT;function xT(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,Mt._)`${e.data}${(0,Mt.getProperty)(r)}`,!0);c(p),t.errorPath=(0,Mt.str)`${u}${(0,jg.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Mt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Mt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Sr.extendSubschemaData=xT;function kT(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Sr.extendSubschemaMode=kT});var nd=E((eq,Dg)=>{"use strict";Dg.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Lg=E((tq,Zg)=>{"use strict";var $r=Zg.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Hi(e,n,o,t,"",t)};$r.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};$r.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};$r.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};$r.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Hi(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in $r.arrayKeywords)for(var p=0;p<d.length;p++)Hi(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in $r.propsKeywords){if(d&&typeof d=="object")for(var m in d)Hi(t,e,r,d[m],o+"/"+l+"/"+ST(m),s,o,l,n,m)}else(l in $r.keywords||t.allKeys&&!(l in $r.skipKeywords))&&Hi(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function ST(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Wo=E(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.getSchemaRefs=Xe.resolveUrl=Xe.normalizeId=Xe._getFullPath=Xe.getFullPath=Xe.inlineRef=void 0;var $T=ne(),TT=nd(),zT=Lg(),RT=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function ET(t,e=!0){return typeof t=="boolean"?!0:e===!0?!od(t):e?Ug(t)<=e:!1}Xe.inlineRef=ET;var PT=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function od(t){for(let e in t){if(PT.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(od)||typeof r=="object"&&od(r))return!0}return!1}function Ug(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!RT.has(r)&&(typeof t[r]=="object"&&(0,$T.eachItem)(t[r],n=>e+=Ug(n)),e===1/0))return 1/0}return e}function Fg(t,e="",r){r!==!1&&(e=Kn(e));let n=t.parse(e);return Hg(t,n)}Xe.getFullPath=Fg;function Hg(t,e){return t.serialize(e).split("#")[0]+"#"}Xe._getFullPath=Hg;var AT=/#\/?$/;function Kn(t){return t?t.replace(AT,""):""}Xe.normalizeId=Kn;function CT(t,e,r){return r=Kn(r),t.resolve(e,r)}Xe.resolveUrl=CT;var OT=/^[a-z_][-a-z0-9._]*$/i;function NT(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Kn(t[r]||e),s={"":o},i=Fg(n,o,!1),a={},c=new Set;return zT(t,{allKeys:!0},(d,p,m,f)=>{if(f===void 0)return;let h=i+p,g=s[f];typeof d[r]=="string"&&(g=y.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),s[p]=g;function y(k){let T=this.opts.uriResolver.resolve;if(k=Kn(g?T(g,k):k),c.has(k))throw l(k);c.add(k);let R=this.refs[k];return typeof R=="string"&&(R=this.refs[R]),typeof R=="object"?u(d,R.schema,k):k!==Kn(h)&&(k[0]==="#"?(u(d,a[k],k),a[k]=d):this.refs[k]=h),k}function b(k){if(typeof k=="string"){if(!OT.test(k))throw new Error(`invalid anchor "${k}"`);y.call(this,`#${k}`)}}}),a;function u(d,p,m){if(p!==void 0&&!TT(d,p))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Xe.getSchemaRefs=NT});var Yo=E(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.getData=Tr.KeywordCxt=Tr.validateFunctionCode=void 0;var Wg=Sg(),Vg=Jo(),id=Gl(),Vi=Jo(),IT=Ag(),Qo=Mg(),sd=qg(),I=B(),L=tr(),MT=Wo(),rr=ne(),Go=Ko();function jT(t){if(Yg(t)&&(Xg(t),Qg(t))){ZT(t);return}Gg(t,()=>(0,Wg.topBoolOrEmptySchema)(t))}Tr.validateFunctionCode=jT;function Gg({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,I._)`${L.default.data}, ${L.default.valCxt}`,n.$async,()=>{t.code((0,I._)`"use strict"; ${Bg(r,o)}`),DT(t,o),t.code(s)}):t.func(e,(0,I._)`${L.default.data}, ${qT(o)}`,n.$async,()=>t.code(Bg(r,o)).code(s))}function qT(t){return(0,I._)`{${L.default.instancePath}="", ${L.default.parentData}, ${L.default.parentDataProperty}, ${L.default.rootData}=${L.default.data}${t.dynamicRef?(0,I._)`, ${L.default.dynamicAnchors}={}`:I.nil}}={}`}function DT(t,e){t.if(L.default.valCxt,()=>{t.var(L.default.instancePath,(0,I._)`${L.default.valCxt}.${L.default.instancePath}`),t.var(L.default.parentData,(0,I._)`${L.default.valCxt}.${L.default.parentData}`),t.var(L.default.parentDataProperty,(0,I._)`${L.default.valCxt}.${L.default.parentDataProperty}`),t.var(L.default.rootData,(0,I._)`${L.default.valCxt}.${L.default.rootData}`),e.dynamicRef&&t.var(L.default.dynamicAnchors,(0,I._)`${L.default.valCxt}.${L.default.dynamicAnchors}`)},()=>{t.var(L.default.instancePath,(0,I._)`""`),t.var(L.default.parentData,(0,I._)`undefined`),t.var(L.default.parentDataProperty,(0,I._)`undefined`),t.var(L.default.rootData,L.default.data),e.dynamicRef&&t.var(L.default.dynamicAnchors,(0,I._)`{}`)})}function ZT(t){let{schema:e,opts:r,gen:n}=t;Gg(t,()=>{r.$comment&&e.$comment&&ty(t),VT(t),n.let(L.default.vErrors,null),n.let(L.default.errors,0),r.unevaluated&<(t),ey(t),JT(t)})}function LT(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,I._)`${r}.evaluated`),e.if((0,I._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,I._)`${t.evaluated}.props`,(0,I._)`undefined`)),e.if((0,I._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,I._)`${t.evaluated}.items`,(0,I._)`undefined`))}function Bg(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,I._)`/*# sourceURL=${r} */`:I.nil}function UT(t,e){if(Yg(t)&&(Xg(t),Qg(t))){FT(t,e);return}(0,Wg.boolOrEmptySchema)(t,e)}function Qg({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Yg(t){return typeof t.schema!="boolean"}function FT(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&ty(t),BT(t),KT(t);let s=n.const("_errs",L.default.errors);ey(t,s),n.var(e,(0,I._)`${s} === ${L.default.errors}`)}function Xg(t){(0,rr.checkUnknownRules)(t),HT(t)}function ey(t,e){if(t.opts.jtd)return Kg(t,[],!1,e);let r=(0,Vg.getSchemaTypes)(t.schema),n=(0,Vg.coerceAndCheckDataType)(t,r);Kg(t,r,!n,e)}function HT(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,rr.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function VT(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,rr.checkStrictMode)(t,"default is ignored in the schema root")}function BT(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,MT.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function KT(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function ty({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,I._)`${L.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,I.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,I._)`${L.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function JT(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,I._)`${L.default.errors} === 0`,()=>e.return(L.default.data),()=>e.throw((0,I._)`new ${o}(${L.default.vErrors})`)):(e.assign((0,I._)`${n}.errors`,L.default.vErrors),s.unevaluated&&WT(t),e.return((0,I._)`${L.default.errors} === 0`))}function WT({gen:t,evaluated:e,props:r,items:n}){r instanceof I.Name&&t.assign((0,I._)`${e}.props`,r),n instanceof I.Name&&t.assign((0,I._)`${e}.items`,n)}function Kg(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,rr.schemaHasRulesButRef)(s,l))){o.block(()=>ny(t,"$ref",l.all.$ref.definition));return}c.jtd||GT(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,id.shouldUseGroup)(s,p)&&(p.type?(o.if((0,Vi.checkDataType)(p.type,i,c.strictNumbers)),Jg(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,Vi.reportTypeError)(t)),o.endIf()):Jg(t,p),a||o.if((0,I._)`${L.default.errors} === ${n||0}`))}}function Jg(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,IT.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,id.shouldUseRule)(n,s)&&ny(t,s.keyword,s.definition,e.type)})}function GT(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(QT(t,e),t.opts.allowUnionTypes||YT(t,e),XT(t,t.dataTypes))}function QT(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{ry(t.dataTypes,r)||ad(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),tz(t,e)}}function YT(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&ad(t,"use allowUnionTypes to allow union type keyword")}function XT(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,id.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>ez(e,i))&&ad(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function ez(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function ry(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function tz(t,e){let r=[];for(let n of t.dataTypes)ry(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function ad(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,rr.checkStrictMode)(t,e,t.opts.strictTypes)}var Bi=class{constructor(e,r,n){if((0,Qo.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,rr.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",oy(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Qo.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",L.default.errors))}result(e,r,n){this.failResult((0,I.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,I.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,I._)`${r} !== undefined && (${(0,I.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Go.reportExtraError:Go.reportError)(this,this.def.error,r)}$dataError(){(0,Go.reportError)(this,this.def.$dataError||Go.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Go.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=I.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=I.nil,r=I.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,I.or)((0,I._)`${o} === undefined`,r)),e!==I.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==I.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,I.or)(i(),a());function i(){if(n.length){if(!(r instanceof I.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,I._)`${(0,Vi.checkDataTypes)(c,r,s.opts.strictNumbers,Vi.DataType.Wrong)}`}return I.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,I._)`!${c}(${r})`}return I.nil}}subschema(e,r){let n=(0,sd.getSubschema)(this.it,e);(0,sd.extendSubschemaData)(n,this.it,e),(0,sd.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return UT(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=rr.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=rr.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,I.Name)),!0}};Tr.KeywordCxt=Bi;function ny(t,e,r,n){let o=new Bi(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Qo.funcKeywordCode)(o,r):"macro"in r?(0,Qo.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Qo.funcKeywordCode)(o,r)}var rz=/^\/(?:[^~]|~0|~1)*$/,nz=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function oy(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return L.default.rootData;if(t[0]==="/"){if(!rz.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=L.default.rootData}else{let u=nz.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,I._)`${s}${(0,I.getProperty)((0,rr.unescapeJsonPointer)(u))}`,i=(0,I._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Tr.getData=oy});var Ki=E(ud=>{"use strict";Object.defineProperty(ud,"__esModule",{value:!0});var cd=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};ud.default=cd});var Xo=E(fd=>{"use strict";Object.defineProperty(fd,"__esModule",{value:!0});var ld=Wo(),dd=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ld.resolveUrl)(e,r,n),this.missingSchema=(0,ld.normalizeId)((0,ld.getFullPath)(e,this.missingRef))}};fd.default=dd});var Wi=E(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.resolveSchema=mt.getCompilingSchema=mt.resolveRef=mt.compileSchema=mt.SchemaEnv=void 0;var St=B(),oz=Ki(),dn=tr(),$t=Wo(),sy=ne(),sz=Yo(),Jn=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,$t.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};mt.SchemaEnv=Jn;function md(t){let e=iy.call(this,t);if(e)return e;let r=(0,$t.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new St.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:oz.default,code:(0,St._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:dn.default.data,parentData:dn.default.parentData,parentDataProperty:dn.default.parentDataProperty,dataNames:[dn.default.data],dataPathArr:[St.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,St.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:St.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,St._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,sz.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(dn.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${dn.default.self}`,`${dn.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:f,items:h}=u;m.evaluated={props:f instanceof St.Name?void 0:f,items:h instanceof St.Name?void 0:h,dynamicProps:f instanceof St.Name,dynamicItems:h instanceof St.Name},m.source&&(m.source.evaluated=(0,St.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}mt.compileSchema=md;function iz(t,e,r){var n;r=(0,$t.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=uz.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Jn({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=az.call(this,s)}mt.resolveRef=iz;function az(t){return(0,$t.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:md.call(this,t)}function iy(t){for(let e of this._compilations)if(cz(e,t))return e}mt.getCompilingSchema=iy;function cz(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function uz(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Ji.call(this,t,e)}function Ji(t,e){let r=this.opts.uriResolver.parse(e),n=(0,$t._getFullPath)(this.opts.uriResolver,r),o=(0,$t.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return pd.call(this,r,t);let s=(0,$t.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Ji.call(this,t,i);return typeof a?.schema!="object"?void 0:pd.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||md.call(this,i),s===(0,$t.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,$t.resolveUrl)(this.opts.uriResolver,o,u)),new Jn({schema:a,schemaId:c,root:t,baseId:o})}return pd.call(this,r,i)}}mt.resolveSchema=Ji;var lz=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function pd(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,sy.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!lz.has(a)&&u&&(e=(0,$t.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,sy.schemaHasRulesButRef)(r,this.RULES)){let a=(0,$t.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Ji.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Jn({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var ay=E((aq,dz)=>{dz.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var gd=E((cq,dy)=>{"use strict";var fz=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),uy=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function hd(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var pz=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function cy(t){return t.length=0,!0}function mz(t,e,r){if(t.length){let n=hd(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function hz(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=mz;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=cy}else{o.push(u);continue}}return o.length&&(a===cy?r.zone=o.join(""):i?n.push(o.join("")):n.push(hd(o))),r.address=n.join(""),r}function ly(t){if(gz(t,":")<2)return{host:t,isIPV6:!1};let e=hz(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function gz(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function yz(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function _z(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function vz(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!uy(r)){let n=ly(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}dy.exports={nonSimpleDomain:pz,recomposeAuthority:vz,normalizeComponentEncoding:_z,removeDotSegments:yz,isIPv4:uy,isUUID:fz,normalizeIPv6:ly,stringArrayToHexStripped:hd}});var gy=E((uq,hy)=>{"use strict";var{isUUID:bz}=gd(),wz=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,xz=["http","https","ws","wss","urn","urn:uuid"];function kz(t){return xz.indexOf(t)!==-1}function yd(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function fy(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function py(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function Sz(t){return t.secure=yd(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function $z(t){if((t.port===(yd(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function Tz(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(wz);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=_d(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function zz(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=_d(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function Rz(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!bz(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Ez(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var my={scheme:"http",domainHost:!0,parse:fy,serialize:py},Pz={scheme:"https",domainHost:my.domainHost,parse:fy,serialize:py},Gi={scheme:"ws",domainHost:!0,parse:Sz,serialize:$z},Az={scheme:"wss",domainHost:Gi.domainHost,parse:Gi.parse,serialize:Gi.serialize},Cz={scheme:"urn",parse:Tz,serialize:zz,skipNormalize:!0},Oz={scheme:"urn:uuid",parse:Rz,serialize:Ez,skipNormalize:!0},Qi={http:my,https:Pz,ws:Gi,wss:Az,urn:Cz,"urn:uuid":Oz};Object.setPrototypeOf(Qi,null);function _d(t){return t&&(Qi[t]||Qi[t.toLowerCase()])||void 0}hy.exports={wsIsSecure:yd,SCHEMES:Qi,isValidSchemeName:kz,getSchemeHandler:_d}});var vy=E((lq,Xi)=>{"use strict";var{normalizeIPv6:Nz,removeDotSegments:es,recomposeAuthority:Iz,normalizeComponentEncoding:Yi,isIPv4:Mz,nonSimpleDomain:jz}=gd(),{SCHEMES:qz,getSchemeHandler:yy}=gy();function Dz(t,e){return typeof t=="string"?t=jt(nr(t,e),e):typeof t=="object"&&(t=nr(jt(t,e),e)),t}function Zz(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=_y(nr(t,n),nr(e,n),n,!0);return n.skipEscape=!0,jt(o,n)}function _y(t,e,r,n){let o={};return n||(t=nr(jt(t,r),r),e=nr(jt(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=es(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=es(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=es(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=es(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function Lz(t,e,r){return typeof t=="string"?(t=unescape(t),t=jt(Yi(nr(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=jt(Yi(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=jt(Yi(nr(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=jt(Yi(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function jt(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=yy(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=Iz(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=es(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var Uz=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function nr(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let s=t.match(Uz);if(s){if(n.scheme=s[1],n.userinfo=s[3],n.host=s[4],n.port=parseInt(s[5],10),n.path=s[6]||"",n.query=s[7],n.fragment=s[8],isNaN(n.port)&&(n.port=s[5]),n.host)if(Mz(n.host)===!1){let c=Nz(n.host);n.host=c.host.toLowerCase(),o=c.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let i=yy(r.scheme||n.scheme);if(!r.unicodeSupport&&(!i||!i.unicodeSupport)&&n.host&&(r.domainHost||i&&i.domainHost)&&o===!1&&jz(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!i||i&&!i.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),i&&i.parse&&i.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var vd={SCHEMES:qz,normalize:Dz,resolve:Zz,resolveComponent:_y,equal:Lz,serialize:jt,parse:nr};Xi.exports=vd;Xi.exports.default=vd;Xi.exports.fastUri=vd});var wy=E(bd=>{"use strict";Object.defineProperty(bd,"__esModule",{value:!0});var by=vy();by.code='require("ajv/dist/runtime/uri").default';bd.default=by});var Ey=E(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.CodeGen=Ie.Name=Ie.nil=Ie.stringify=Ie.str=Ie._=Ie.KeywordCxt=void 0;var Fz=Yo();Object.defineProperty(Ie,"KeywordCxt",{enumerable:!0,get:function(){return Fz.KeywordCxt}});var Wn=B();Object.defineProperty(Ie,"_",{enumerable:!0,get:function(){return Wn._}});Object.defineProperty(Ie,"str",{enumerable:!0,get:function(){return Wn.str}});Object.defineProperty(Ie,"stringify",{enumerable:!0,get:function(){return Wn.stringify}});Object.defineProperty(Ie,"nil",{enumerable:!0,get:function(){return Wn.nil}});Object.defineProperty(Ie,"Name",{enumerable:!0,get:function(){return Wn.Name}});Object.defineProperty(Ie,"CodeGen",{enumerable:!0,get:function(){return Wn.CodeGen}});var Hz=Ki(),Ty=Xo(),Vz=Wl(),ts=Wi(),Bz=B(),rs=Wo(),ea=Jo(),xd=ne(),xy=ay(),Kz=wy(),zy=(t,e)=>new RegExp(t,e);zy.code="new RegExp";var Jz=["removeAdditional","useDefaults","coerceTypes"],Wz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Gz={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},Qz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},ky=200;function Yz(t){var e,r,n,o,s,i,a,c,u,l,d,p,m,f,h,g,y,b,k,T,R,me,ie,Ve,Be;let ir=t.strict,bn=(e=t.code)===null||e===void 0?void 0:e.optimize,Nr=bn===!0||bn===void 0?1:bn||0,ar=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:zy,Bt=(o=t.uriResolver)!==null&&o!==void 0?o:Kz.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:ir)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:ir)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:ir)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:ir)!==null&&p!==void 0?p:"log",strictRequired:(f=(m=t.strictRequired)!==null&&m!==void 0?m:ir)!==null&&f!==void 0?f:!1,code:t.code?{...t.code,optimize:Nr,regExp:ar}:{optimize:Nr,regExp:ar},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:ky,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:ky,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(b=t.messages)!==null&&b!==void 0?b:!0,inlineRefs:(k=t.inlineRefs)!==null&&k!==void 0?k:!0,schemaId:(T=t.schemaId)!==null&&T!==void 0?T:"$id",addUsedSchema:(R=t.addUsedSchema)!==null&&R!==void 0?R:!0,validateSchema:(me=t.validateSchema)!==null&&me!==void 0?me:!0,validateFormats:(ie=t.validateFormats)!==null&&ie!==void 0?ie:!0,unicodeRegExp:(Ve=t.unicodeRegExp)!==null&&Ve!==void 0?Ve:!0,int32range:(Be=t.int32range)!==null&&Be!==void 0?Be:!0,uriResolver:Bt}}var ns=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Yz(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Bz.ValueScope({scope:{},prefixes:Wz,es5:r,lines:n}),this.logger=oR(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Vz.getRules)(),Sy.call(this,Gz,e,"NOT SUPPORTED"),Sy.call(this,Qz,e,"DEPRECATED","warn"),this._metaOpts=rR.call(this),e.formats&&eR.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&tR.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Xz.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=xy;n==="id"&&(o={...xy},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Ty.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,rs.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=$y.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ts.SchemaEnv({schema:{},schemaId:n});if(r=ts.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=$y.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,rs.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(iR.call(this,n,r),!r)return(0,xd.eachItem)(n,s=>wd.call(this,s)),this;cR.call(this,r);let o={...r,type:(0,ea.getJSONTypes)(r.type),schemaType:(0,ea.getJSONTypes)(r.schemaType)};return(0,xd.eachItem)(n,o.type.length===0?s=>wd.call(this,s,o):s=>o.type.forEach(i=>wd.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Ry(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,rs.normalizeId)(i||n);let u=rs.getSchemaRefs.call(this,e,n);return c=new ts.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ts.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ts.compileSchema.call(this,e)}finally{this.opts=r}}};ns.ValidationError=Hz.default;ns.MissingRefError=Ty.default;Ie.default=ns;function Sy(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function $y(t){return t=(0,rs.normalizeId)(t),this.schemas[t]||this.refs[t]}function Xz(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function eR(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function tR(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function rR(){let t={...this.opts};for(let e of Jz)delete t[e];return t}var nR={log(){},warn(){},error(){}};function oR(t){if(t===!1)return nR;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var sR=/^[a-z_$][a-z0-9_$:-]*$/i;function iR(t,e){let{RULES:r}=this;if((0,xd.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!sR.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function wd(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,ea.getJSONTypes)(e.type),schemaType:(0,ea.getJSONTypes)(e.schemaType)}};e.before?aR.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function aR(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function cR(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Ry(e)),t.validateSchema=this.compile(e,!0))}var uR={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ry(t){return{anyOf:[t,uR]}}});var Py=E(kd=>{"use strict";Object.defineProperty(kd,"__esModule",{value:!0});var lR={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};kd.default=lR});var Ny=E(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.callRef=fn.getValidate=void 0;var dR=Xo(),Ay=pt(),et=B(),Gn=tr(),Cy=Wi(),ta=ne(),fR={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=Cy.resolveRef.call(c,u,o,r);if(l===void 0)throw new dR.default(n.opts.uriResolver,o,r);if(l instanceof Cy.SchemaEnv)return p(l);return m(l);function d(){if(s===u)return ra(t,i,s,s.$async);let f=e.scopeValue("root",{ref:u});return ra(t,(0,et._)`${f}.validate`,u,u.$async)}function p(f){let h=Oy(t,f);ra(t,h,f,f.$async)}function m(f){let h=e.scopeValue("schema",a.code.source===!0?{ref:f,code:(0,et.stringify)(f)}:{ref:f}),g=e.name("valid"),y=t.subschema({schema:f,dataTypes:[],schemaPath:et.nil,topSchemaRef:h,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function Oy(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,et._)`${r.scopeValue("wrapper",{ref:e})}.validate`}fn.getValidate=Oy;function ra(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Gn.default.this:et.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let f=o.let("valid");o.try(()=>{o.code((0,et._)`await ${(0,Ay.callValidateCode)(t,e,u)}`),m(e),i||o.assign(f,!0)},h=>{o.if((0,et._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),p(h),i||o.assign(f,!1)}),t.ok(f)}function d(){t.result((0,Ay.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(f){let h=(0,et._)`${f}.errors`;o.assign(Gn.default.vErrors,(0,et._)`${Gn.default.vErrors} === null ? ${h} : ${Gn.default.vErrors}.concat(${h})`),o.assign(Gn.default.errors,(0,et._)`${Gn.default.vErrors}.length`)}function m(f){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=ta.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,et._)`${f}.evaluated.props`);s.props=ta.mergeEvaluated.props(o,y,s.props,et.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=ta.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,et._)`${f}.evaluated.items`);s.items=ta.mergeEvaluated.items(o,y,s.items,et.Name)}}}fn.callRef=ra;fn.default=fR});var Iy=E(Sd=>{"use strict";Object.defineProperty(Sd,"__esModule",{value:!0});var pR=Py(),mR=Ny(),hR=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",pR.default,mR.default];Sd.default=hR});var My=E($d=>{"use strict";Object.defineProperty($d,"__esModule",{value:!0});var na=B(),zr=na.operators,oa={maximum:{okStr:"<=",ok:zr.LTE,fail:zr.GT},minimum:{okStr:">=",ok:zr.GTE,fail:zr.LT},exclusiveMaximum:{okStr:"<",ok:zr.LT,fail:zr.GTE},exclusiveMinimum:{okStr:">",ok:zr.GT,fail:zr.LTE}},gR={message:({keyword:t,schemaCode:e})=>(0,na.str)`must be ${oa[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,na._)`{comparison: ${oa[t].okStr}, limit: ${e}}`},yR={keyword:Object.keys(oa),type:"number",schemaType:"number",$data:!0,error:gR,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,na._)`${r} ${oa[e].fail} ${n} || isNaN(${r})`)}};$d.default=yR});var jy=E(Td=>{"use strict";Object.defineProperty(Td,"__esModule",{value:!0});var os=B(),_R={message:({schemaCode:t})=>(0,os.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,os._)`{multipleOf: ${t}}`},vR={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:_R,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,os._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,os._)`${i} !== parseInt(${i})`;t.fail$data((0,os._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Td.default=vR});var Dy=E(zd=>{"use strict";Object.defineProperty(zd,"__esModule",{value:!0});function qy(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}zd.default=qy;qy.code='require("ajv/dist/runtime/ucs2length").default'});var Zy=E(Rd=>{"use strict";Object.defineProperty(Rd,"__esModule",{value:!0});var pn=B(),bR=ne(),wR=Dy(),xR={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,pn.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,pn._)`{limit: ${t}}`},kR={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:xR,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?pn.operators.GT:pn.operators.LT,i=o.opts.unicode===!1?(0,pn._)`${r}.length`:(0,pn._)`${(0,bR.useFunc)(t.gen,wR.default)}(${r})`;t.fail$data((0,pn._)`${i} ${s} ${n}`)}};Rd.default=kR});var Ly=E(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});var SR=pt(),sa=B(),$R={message:({schemaCode:t})=>(0,sa.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,sa._)`{pattern: ${t}}`},TR={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:$R,code(t){let{data:e,$data:r,schema:n,schemaCode:o,it:s}=t,i=s.opts.unicodeRegExp?"u":"",a=r?(0,sa._)`(new RegExp(${o}, ${i}))`:(0,SR.usePattern)(t,n);t.fail$data((0,sa._)`!${a}.test(${e})`)}};Ed.default=TR});var Uy=E(Pd=>{"use strict";Object.defineProperty(Pd,"__esModule",{value:!0});var ss=B(),zR={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,ss.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,ss._)`{limit: ${t}}`},RR={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:zR,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?ss.operators.GT:ss.operators.LT;t.fail$data((0,ss._)`Object.keys(${r}).length ${o} ${n}`)}};Pd.default=RR});var Fy=E(Ad=>{"use strict";Object.defineProperty(Ad,"__esModule",{value:!0});var is=pt(),as=B(),ER=ne(),PR={message:({params:{missingProperty:t}})=>(0,as.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,as._)`{missingProperty: ${t}}`},AR={keyword:"required",type:"object",schemaType:"array",$data:!0,error:PR,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:f}=t.it;for(let h of r)if(m?.[h]===void 0&&!f.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,ER.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(as.nil,d);else for(let m of r)(0,is.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||s){let f=e.let("valid",!0);t.block$data(f,()=>p(m,f)),t.ok(f)}else e.if((0,is.checkMissingProp)(t,r,m)),(0,is.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,is.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function p(m,f){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(f,(0,is.propertyInData)(e,o,m,a.ownProperties)),e.if((0,as.not)(f),()=>{t.error(),e.break()})},as.nil)}}};Ad.default=AR});var Hy=E(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:!0});var cs=B(),CR={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,cs.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,cs._)`{limit: ${t}}`},OR={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:CR,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?cs.operators.GT:cs.operators.LT;t.fail$data((0,cs._)`${r}.length ${o} ${n}`)}};Cd.default=OR});var ia=E(Od=>{"use strict";Object.defineProperty(Od,"__esModule",{value:!0});var Vy=nd();Vy.code='require("ajv/dist/runtime/equal").default';Od.default=Vy});var By=E(Id=>{"use strict";Object.defineProperty(Id,"__esModule",{value:!0});var Nd=Jo(),Me=B(),NR=ne(),IR=ia(),MR={message:({params:{i:t,j:e}})=>(0,Me.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Me._)`{i: ${t}, j: ${e}}`},jR={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:MR,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,Nd.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,Me._)`${i} === false`),t.ok(c);function l(){let f=e.let("i",(0,Me._)`${r}.length`),h=e.let("j");t.setParams({i:f,j:h}),e.assign(c,!0),e.if((0,Me._)`${f} > 1`,()=>(d()?p:m)(f,h))}function d(){return u.length>0&&!u.some(f=>f==="object"||f==="array")}function p(f,h){let g=e.name("item"),y=(0,Nd.checkDataTypes)(u,g,a.opts.strictNumbers,Nd.DataType.Wrong),b=e.const("indices",(0,Me._)`{}`);e.for((0,Me._)`;${f}--;`,()=>{e.let(g,(0,Me._)`${r}[${f}]`),e.if(y,(0,Me._)`continue`),u.length>1&&e.if((0,Me._)`typeof ${g} == "string"`,(0,Me._)`${g} += "_"`),e.if((0,Me._)`typeof ${b}[${g}] == "number"`,()=>{e.assign(h,(0,Me._)`${b}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,Me._)`${b}[${g}] = ${f}`)})}function m(f,h){let g=(0,NR.useFunc)(e,IR.default),y=e.name("outer");e.label(y).for((0,Me._)`;${f}--;`,()=>e.for((0,Me._)`${h} = ${f}; ${h}--;`,()=>e.if((0,Me._)`${g}(${r}[${f}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Id.default=jR});var Ky=E(jd=>{"use strict";Object.defineProperty(jd,"__esModule",{value:!0});var Md=B(),qR=ne(),DR=ia(),ZR={message:"must be equal to constant",params:({schemaCode:t})=>(0,Md._)`{allowedValue: ${t}}`},LR={keyword:"const",$data:!0,error:ZR,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,Md._)`!${(0,qR.useFunc)(e,DR.default)}(${r}, ${o})`):t.fail((0,Md._)`${s} !== ${r}`)}};jd.default=LR});var Jy=E(qd=>{"use strict";Object.defineProperty(qd,"__esModule",{value:!0});var us=B(),UR=ne(),FR=ia(),HR={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,us._)`{allowedValues: ${t}}`},VR={keyword:"enum",schemaType:"array",$data:!0,error:HR,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,UR.useFunc)(e,FR.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",s);l=(0,us.or)(...o.map((f,h)=>p(m,h)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,m=>e.if((0,us._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function p(m,f){let h=o[f];return typeof h=="object"&&h!==null?(0,us._)`${u()}(${r}, ${m}[${f}])`:(0,us._)`${r} === ${h}`}}};qd.default=VR});var Wy=E(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});var BR=My(),KR=jy(),JR=Zy(),WR=Ly(),GR=Uy(),QR=Fy(),YR=Hy(),XR=By(),eE=Ky(),tE=Jy(),rE=[BR.default,KR.default,JR.default,WR.default,GR.default,QR.default,YR.default,XR.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},eE.default,tE.default];Dd.default=rE});var Ld=E(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.validateAdditionalItems=void 0;var mn=B(),Zd=ne(),nE={message:({params:{len:t}})=>(0,mn.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,mn._)`{limit: ${t}}`},oE={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:nE,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Zd.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Gy(t,n)}};function Gy(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,mn._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,mn._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Zd.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,mn._)`${a} <= ${e.length}`);r.if((0,mn.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Zd.Type.Num},u),i.allErrors||r.if((0,mn.not)(u),()=>r.break())})}}ls.validateAdditionalItems=Gy;ls.default=oE});var Ud=E(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.validateTuple=void 0;var Qy=B(),aa=ne(),sE=pt(),iE={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Yy(t,"additionalItems",e);r.items=!0,!(0,aa.alwaysValidSchema)(r,e)&&t.ok((0,sE.validateArray)(t))}};function Yy(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=aa.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Qy._)`${s}.length`);r.forEach((d,p)=>{(0,aa.alwaysValidSchema)(a,d)||(n.if((0,Qy._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:m}=a,f=r.length,h=f===d.minItems&&(f===d.maxItems||d[e]===!1);if(p.strictTuples&&!h){let g=`"${i}" is ${f}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,aa.checkStrictMode)(a,g,p.strictTuples)}}}ds.validateTuple=Yy;ds.default=iE});var Xy=E(Fd=>{"use strict";Object.defineProperty(Fd,"__esModule",{value:!0});var aE=Ud(),cE={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,aE.validateTuple)(t,"items")};Fd.default=cE});var t_=E(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0});var e_=B(),uE=ne(),lE=pt(),dE=Ld(),fE={message:({params:{len:t}})=>(0,e_.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,e_._)`{limit: ${t}}`},pE={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:fE,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,uE.alwaysValidSchema)(n,e)&&(o?(0,dE.validateAdditionalItems)(t,o):t.ok((0,lE.validateArray)(t)))}};Hd.default=pE});var r_=E(Vd=>{"use strict";Object.defineProperty(Vd,"__esModule",{value:!0});var ht=B(),ca=ne(),mE={message:({params:{min:t,max:e}})=>e===void 0?(0,ht.str)`must contain at least ${t} valid item(s)`:(0,ht.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,ht._)`{minContains: ${t}}`:(0,ht._)`{minContains: ${t}, maxContains: ${e}}`},hE={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:mE,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,ht._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,ca.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ca.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,ca.alwaysValidSchema)(s,r)){let h=(0,ht._)`${l} >= ${i}`;a!==void 0&&(h=(0,ht._)`${h} && ${l} <= ${a}`),t.pass(h);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,ht._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let h=e.name("_valid"),g=e.let("count",0);m(h,()=>e.if(h,()=>f(g)))}function m(h,g){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:ca.Type.Num,compositeRule:!0},h),g()})}function f(h){e.code((0,ht._)`${h}++`),a===void 0?e.if((0,ht._)`${h} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,ht._)`${h} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,ht._)`${h} >= ${i}`,()=>e.assign(d,!0)))}}};Vd.default=hE});var s_=E(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.validateSchemaDeps=qt.validatePropertyDeps=qt.error=void 0;var Bd=B(),gE=ne(),fs=pt();qt.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Bd.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Bd._)`{property: ${t},
|
|
5
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,H._)`[${o}]`)}}}function tT({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,H._)`${e} !== undefined`,()=>t.assign((0,H._)`${e}[${r}]`,n))}function Xl(t,e,r,n=Vn.Correct){let o=n===Vn.Correct?H.operators.EQ:H.operators.NEQ,s;switch(t){case"null":return(0,H._)`${e} ${o} null`;case"array":s=(0,H._)`Array.isArray(${e})`;break;case"object":s=(0,H._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,H._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,H._)`typeof ${e} ${o} ${t}`}return n===Vn.Correct?s:(0,H.not)(s);function i(a=H.nil){return(0,H.and)((0,H._)`typeof ${e} == "number"`,a,r?(0,H._)`isFinite(${e})`:H.nil)}}Ze.checkDataType=Xl;function ed(t,e,r,n){if(t.length===1)return Xl(t[0],e,r,n);let o,s=(0,Pg.toHash)(t);if(s.array&&s.object){let i=(0,H._)`typeof ${e} != "object"`;o=s.null?i:(0,H._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=H.nil;s.number&&delete s.integer;for(let i in s)o=(0,H.and)(o,Xl(i,e,r,n));return o}Ze.checkDataTypes=ed;var rT={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,H._)`{type: ${t}}`:(0,H._)`{type: ${e}}`};function td(t){let e=nT(t);(0,G$.reportError)(e,rT)}Ze.reportTypeError=td;function nT(t){let{gen:e,data:r,schema:n}=t,o=(0,Pg.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Ng=E(Fi=>{"use strict";Object.defineProperty(Fi,"__esModule",{value:!0});Fi.assignDefaults=void 0;var Bn=B(),oT=ne();function sT(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Og(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Og(t,s,o.default))}Fi.assignDefaults=sT;function Og(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,Bn._)`${s}${(0,Bn.getProperty)(e)}`;if(o){(0,oT.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Bn._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Bn._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Bn._)`${a} = ${(0,Bn.stringify)(r)}`)}});var pt=E(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});ce.validateUnion=ce.validateArray=ce.usePattern=ce.callValidateCode=ce.schemaProperties=ce.allSchemaProperties=ce.noPropertyInData=ce.propertyInData=ce.isOwnProperty=ce.hasPropFunc=ce.reportMissingProp=ce.checkMissingProp=ce.checkReportMissingProp=void 0;var he=B(),rd=ne(),kr=tr(),iT=ne();function aT(t,e){let{gen:r,data:n,it:o}=t;r.if(od(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,he._)`${e}`},!0),t.error()})}ce.checkReportMissingProp=aT;function cT({gen:t,data:e,it:{opts:r}},n,o){return(0,he.or)(...n.map(s=>(0,he.and)(od(t,e,s,r.ownProperties),(0,he._)`${o} = ${s}`)))}ce.checkMissingProp=cT;function uT(t,e){t.setParams({missingProperty:e},!0),t.error()}ce.reportMissingProp=uT;function Ig(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,he._)`Object.prototype.hasOwnProperty`})}ce.hasPropFunc=Ig;function nd(t,e,r){return(0,he._)`${Ig(t)}.call(${e}, ${r})`}ce.isOwnProperty=nd;function lT(t,e,r,n){let o=(0,he._)`${e}${(0,he.getProperty)(r)} !== undefined`;return n?(0,he._)`${o} && ${nd(t,e,r)}`:o}ce.propertyInData=lT;function od(t,e,r,n){let o=(0,he._)`${e}${(0,he.getProperty)(r)} === undefined`;return n?(0,he.or)(o,(0,he.not)(nd(t,e,r))):o}ce.noPropertyInData=od;function Mg(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}ce.allSchemaProperties=Mg;function dT(t,e){return Mg(e).filter(r=>!(0,rd.alwaysValidSchema)(t,e[r]))}ce.schemaProperties=dT;function fT({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,he._)`${t}, ${e}, ${n}${o}`:e,d=[[kr.default.instancePath,(0,he.strConcat)(kr.default.instancePath,s)],[kr.default.parentData,i.parentData],[kr.default.parentDataProperty,i.parentDataProperty],[kr.default.rootData,kr.default.rootData]];i.opts.dynamicRef&&d.push([kr.default.dynamicAnchors,kr.default.dynamicAnchors]);let p=(0,he._)`${l}, ${r.object(...d)}`;return c!==he.nil?(0,he._)`${a}.call(${c}, ${p})`:(0,he._)`${a}(${p})`}ce.callValidateCode=fT;var pT=(0,he._)`new RegExp`;function mT({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,he._)`${o.code==="new RegExp"?pT:(0,iT.useFunc)(t,o)}(${r}, ${n})`})}ce.usePattern=mT;function hT(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,he._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:rd.Type.Num},s),e.if((0,he.not)(s),a)})}}ce.validateArray=hT;function gT(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,rd.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,he._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,he.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}ce.validateUnion=gT});var Dg=E(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.validateKeywordUsage=It.validSchemaType=It.funcKeywordCode=It.macroKeywordCode=void 0;var He=B(),ln=tr(),yT=pt(),_T=Ko();function vT(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=qg(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:He.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}It.macroKeywordCode=vT;function bT(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;xT(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=qg(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)h(),e.modifying&&jg(t),g(()=>t.error());else{let y=e.async?m():f();e.modifying&&jg(t),g(()=>wT(t,y))}}function m(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,He._)`await `),b=>n.assign(d,!1).if((0,He._)`${b} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,He._)`${b}.errors`),()=>n.throw(b))),y}function f(){let y=(0,He._)`${l}.errors`;return n.assign(y,null),h(He.nil),y}function h(y=e.async?(0,He._)`await `:He.nil){let b=c.opts.passContext?ln.default.this:ln.default.self,k=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,He._)`${y}${(0,yT.callValidateCode)(t,l,b,k)}`,e.modifying)}function g(y){var b;n.if((0,He.not)((b=e.valid)!==null&&b!==void 0?b:d),y)}}It.funcKeywordCode=bT;function jg(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,He._)`${n.parentData}[${n.parentDataProperty}]`))}function wT(t,e){let{gen:r}=t;r.if((0,He._)`Array.isArray(${e})`,()=>{r.assign(ln.default.vErrors,(0,He._)`${ln.default.vErrors} === null ? ${e} : ${ln.default.vErrors}.concat(${e})`).assign(ln.default.errors,(0,He._)`${ln.default.vErrors}.length`),(0,_T.extendErrors)(t)},()=>t.error())}function xT({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function qg(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,He.stringify)(r)})}function kT(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}It.validSchemaType=kT;function ST({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}It.validateKeywordUsage=ST});var Lg=E(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.extendSubschemaMode=Sr.extendSubschemaData=Sr.getSubschema=void 0;var Mt=B(),Zg=ne();function $T(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Mt._)`${t.schemaPath}${(0,Mt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Mt._)`${t.schemaPath}${(0,Mt.getProperty)(e)}${(0,Mt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Zg.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Sr.getSubschema=$T;function TT(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,Mt._)`${e.data}${(0,Mt.getProperty)(r)}`,!0);c(p),t.errorPath=(0,Mt.str)`${u}${(0,Zg.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Mt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Mt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Sr.extendSubschemaData=TT;function zT(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Sr.extendSubschemaMode=zT});var sd=E((iq,Ug)=>{"use strict";Ug.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Hg=E((aq,Fg)=>{"use strict";var $r=Fg.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Hi(e,n,o,t,"",t)};$r.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};$r.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};$r.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};$r.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Hi(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in $r.arrayKeywords)for(var p=0;p<d.length;p++)Hi(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in $r.propsKeywords){if(d&&typeof d=="object")for(var m in d)Hi(t,e,r,d[m],o+"/"+l+"/"+RT(m),s,o,l,n,m)}else(l in $r.keywords||t.allKeys&&!(l in $r.skipKeywords))&&Hi(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function RT(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Wo=E(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.getSchemaRefs=Xe.resolveUrl=Xe.normalizeId=Xe._getFullPath=Xe.getFullPath=Xe.inlineRef=void 0;var ET=ne(),PT=sd(),AT=Hg(),CT=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function OT(t,e=!0){return typeof t=="boolean"?!0:e===!0?!id(t):e?Vg(t)<=e:!1}Xe.inlineRef=OT;var NT=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function id(t){for(let e in t){if(NT.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(id)||typeof r=="object"&&id(r))return!0}return!1}function Vg(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!CT.has(r)&&(typeof t[r]=="object"&&(0,ET.eachItem)(t[r],n=>e+=Vg(n)),e===1/0))return 1/0}return e}function Bg(t,e="",r){r!==!1&&(e=Kn(e));let n=t.parse(e);return Kg(t,n)}Xe.getFullPath=Bg;function Kg(t,e){return t.serialize(e).split("#")[0]+"#"}Xe._getFullPath=Kg;var IT=/#\/?$/;function Kn(t){return t?t.replace(IT,""):""}Xe.normalizeId=Kn;function MT(t,e,r){return r=Kn(r),t.resolve(e,r)}Xe.resolveUrl=MT;var jT=/^[a-z_][-a-z0-9._]*$/i;function qT(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Kn(t[r]||e),s={"":o},i=Bg(n,o,!1),a={},c=new Set;return AT(t,{allKeys:!0},(d,p,m,f)=>{if(f===void 0)return;let h=i+p,g=s[f];typeof d[r]=="string"&&(g=y.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),s[p]=g;function y(k){let T=this.opts.uriResolver.resolve;if(k=Kn(g?T(g,k):k),c.has(k))throw l(k);c.add(k);let R=this.refs[k];return typeof R=="string"&&(R=this.refs[R]),typeof R=="object"?u(d,R.schema,k):k!==Kn(h)&&(k[0]==="#"?(u(d,a[k],k),a[k]=d):this.refs[k]=h),k}function b(k){if(typeof k=="string"){if(!jT.test(k))throw new Error(`invalid anchor "${k}"`);y.call(this,`#${k}`)}}}),a;function u(d,p,m){if(p!==void 0&&!PT(d,p))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Xe.getSchemaRefs=qT});var Yo=E(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.getData=Tr.KeywordCxt=Tr.validateFunctionCode=void 0;var Yg=zg(),Jg=Jo(),cd=Yl(),Vi=Jo(),DT=Ng(),Qo=Dg(),ad=Lg(),I=B(),L=tr(),ZT=Wo(),rr=ne(),Go=Ko();function LT(t){if(ty(t)&&(ry(t),ey(t))){HT(t);return}Xg(t,()=>(0,Yg.topBoolOrEmptySchema)(t))}Tr.validateFunctionCode=LT;function Xg({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,I._)`${L.default.data}, ${L.default.valCxt}`,n.$async,()=>{t.code((0,I._)`"use strict"; ${Wg(r,o)}`),FT(t,o),t.code(s)}):t.func(e,(0,I._)`${L.default.data}, ${UT(o)}`,n.$async,()=>t.code(Wg(r,o)).code(s))}function UT(t){return(0,I._)`{${L.default.instancePath}="", ${L.default.parentData}, ${L.default.parentDataProperty}, ${L.default.rootData}=${L.default.data}${t.dynamicRef?(0,I._)`, ${L.default.dynamicAnchors}={}`:I.nil}}={}`}function FT(t,e){t.if(L.default.valCxt,()=>{t.var(L.default.instancePath,(0,I._)`${L.default.valCxt}.${L.default.instancePath}`),t.var(L.default.parentData,(0,I._)`${L.default.valCxt}.${L.default.parentData}`),t.var(L.default.parentDataProperty,(0,I._)`${L.default.valCxt}.${L.default.parentDataProperty}`),t.var(L.default.rootData,(0,I._)`${L.default.valCxt}.${L.default.rootData}`),e.dynamicRef&&t.var(L.default.dynamicAnchors,(0,I._)`${L.default.valCxt}.${L.default.dynamicAnchors}`)},()=>{t.var(L.default.instancePath,(0,I._)`""`),t.var(L.default.parentData,(0,I._)`undefined`),t.var(L.default.parentDataProperty,(0,I._)`undefined`),t.var(L.default.rootData,L.default.data),e.dynamicRef&&t.var(L.default.dynamicAnchors,(0,I._)`{}`)})}function HT(t){let{schema:e,opts:r,gen:n}=t;Xg(t,()=>{r.$comment&&e.$comment&&oy(t),WT(t),n.let(L.default.vErrors,null),n.let(L.default.errors,0),r.unevaluated&&VT(t),ny(t),YT(t)})}function VT(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,I._)`${r}.evaluated`),e.if((0,I._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,I._)`${t.evaluated}.props`,(0,I._)`undefined`)),e.if((0,I._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,I._)`${t.evaluated}.items`,(0,I._)`undefined`))}function Wg(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,I._)`/*# sourceURL=${r} */`:I.nil}function BT(t,e){if(ty(t)&&(ry(t),ey(t))){KT(t,e);return}(0,Yg.boolOrEmptySchema)(t,e)}function ey({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function ty(t){return typeof t.schema!="boolean"}function KT(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&oy(t),GT(t),QT(t);let s=n.const("_errs",L.default.errors);ny(t,s),n.var(e,(0,I._)`${s} === ${L.default.errors}`)}function ry(t){(0,rr.checkUnknownRules)(t),JT(t)}function ny(t,e){if(t.opts.jtd)return Gg(t,[],!1,e);let r=(0,Jg.getSchemaTypes)(t.schema),n=(0,Jg.coerceAndCheckDataType)(t,r);Gg(t,r,!n,e)}function JT(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,rr.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function WT(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,rr.checkStrictMode)(t,"default is ignored in the schema root")}function GT(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,ZT.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function QT(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function oy({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,I._)`${L.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,I.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,I._)`${L.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function YT(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,I._)`${L.default.errors} === 0`,()=>e.return(L.default.data),()=>e.throw((0,I._)`new ${o}(${L.default.vErrors})`)):(e.assign((0,I._)`${n}.errors`,L.default.vErrors),s.unevaluated&&XT(t),e.return((0,I._)`${L.default.errors} === 0`))}function XT({gen:t,evaluated:e,props:r,items:n}){r instanceof I.Name&&t.assign((0,I._)`${e}.props`,r),n instanceof I.Name&&t.assign((0,I._)`${e}.items`,n)}function Gg(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,rr.schemaHasRulesButRef)(s,l))){o.block(()=>iy(t,"$ref",l.all.$ref.definition));return}c.jtd||ez(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,cd.shouldUseGroup)(s,p)&&(p.type?(o.if((0,Vi.checkDataType)(p.type,i,c.strictNumbers)),Qg(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,Vi.reportTypeError)(t)),o.endIf()):Qg(t,p),a||o.if((0,I._)`${L.default.errors} === ${n||0}`))}}function Qg(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,DT.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,cd.shouldUseRule)(n,s)&&iy(t,s.keyword,s.definition,e.type)})}function ez(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(tz(t,e),t.opts.allowUnionTypes||rz(t,e),nz(t,t.dataTypes))}function tz(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{sy(t.dataTypes,r)||ud(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),sz(t,e)}}function rz(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&ud(t,"use allowUnionTypes to allow union type keyword")}function nz(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,cd.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>oz(e,i))&&ud(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function oz(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function sy(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function sz(t,e){let r=[];for(let n of t.dataTypes)sy(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function ud(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,rr.checkStrictMode)(t,e,t.opts.strictTypes)}var Bi=class{constructor(e,r,n){if((0,Qo.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,rr.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",ay(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Qo.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",L.default.errors))}result(e,r,n){this.failResult((0,I.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,I.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,I._)`${r} !== undefined && (${(0,I.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Go.reportExtraError:Go.reportError)(this,this.def.error,r)}$dataError(){(0,Go.reportError)(this,this.def.$dataError||Go.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Go.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=I.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=I.nil,r=I.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,I.or)((0,I._)`${o} === undefined`,r)),e!==I.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==I.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,I.or)(i(),a());function i(){if(n.length){if(!(r instanceof I.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,I._)`${(0,Vi.checkDataTypes)(c,r,s.opts.strictNumbers,Vi.DataType.Wrong)}`}return I.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,I._)`!${c}(${r})`}return I.nil}}subschema(e,r){let n=(0,ad.getSubschema)(this.it,e);(0,ad.extendSubschemaData)(n,this.it,e),(0,ad.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return BT(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=rr.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=rr.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,I.Name)),!0}};Tr.KeywordCxt=Bi;function iy(t,e,r,n){let o=new Bi(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Qo.funcKeywordCode)(o,r):"macro"in r?(0,Qo.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Qo.funcKeywordCode)(o,r)}var iz=/^\/(?:[^~]|~0|~1)*$/,az=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function ay(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return L.default.rootData;if(t[0]==="/"){if(!iz.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=L.default.rootData}else{let u=az.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,I._)`${s}${(0,I.getProperty)((0,rr.unescapeJsonPointer)(u))}`,i=(0,I._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Tr.getData=ay});var Ki=E(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:!0});var ld=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};dd.default=ld});var Xo=E(md=>{"use strict";Object.defineProperty(md,"__esModule",{value:!0});var fd=Wo(),pd=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,fd.resolveUrl)(e,r,n),this.missingSchema=(0,fd.normalizeId)((0,fd.getFullPath)(e,this.missingRef))}};md.default=pd});var Wi=E(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.resolveSchema=mt.getCompilingSchema=mt.resolveRef=mt.compileSchema=mt.SchemaEnv=void 0;var St=B(),cz=Ki(),dn=tr(),$t=Wo(),cy=ne(),uz=Yo(),Jn=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,$t.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};mt.SchemaEnv=Jn;function gd(t){let e=uy.call(this,t);if(e)return e;let r=(0,$t.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new St.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:cz.default,code:(0,St._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:dn.default.data,parentData:dn.default.parentData,parentDataProperty:dn.default.parentDataProperty,dataNames:[dn.default.data],dataPathArr:[St.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,St.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:St.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,St._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,uz.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(dn.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${dn.default.self}`,`${dn.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:f,items:h}=u;m.evaluated={props:f instanceof St.Name?void 0:f,items:h instanceof St.Name?void 0:h,dynamicProps:f instanceof St.Name,dynamicItems:h instanceof St.Name},m.source&&(m.source.evaluated=(0,St.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}mt.compileSchema=gd;function lz(t,e,r){var n;r=(0,$t.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=pz.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Jn({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=dz.call(this,s)}mt.resolveRef=lz;function dz(t){return(0,$t.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:gd.call(this,t)}function uy(t){for(let e of this._compilations)if(fz(e,t))return e}mt.getCompilingSchema=uy;function fz(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function pz(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Ji.call(this,t,e)}function Ji(t,e){let r=this.opts.uriResolver.parse(e),n=(0,$t._getFullPath)(this.opts.uriResolver,r),o=(0,$t.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return hd.call(this,r,t);let s=(0,$t.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Ji.call(this,t,i);return typeof a?.schema!="object"?void 0:hd.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||gd.call(this,i),s===(0,$t.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,$t.resolveUrl)(this.opts.uriResolver,o,u)),new Jn({schema:a,schemaId:c,root:t,baseId:o})}return hd.call(this,r,i)}}mt.resolveSchema=Ji;var mz=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function hd(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,cy.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!mz.has(a)&&u&&(e=(0,$t.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,cy.schemaHasRulesButRef)(r,this.RULES)){let a=(0,$t.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Ji.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Jn({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var ly=E((pq,hz)=>{hz.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var _d=E((mq,my)=>{"use strict";var gz=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),fy=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function yd(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var yz=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function dy(t){return t.length=0,!0}function _z(t,e,r){if(t.length){let n=yd(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function vz(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=_z;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=dy}else{o.push(u);continue}}return o.length&&(a===dy?r.zone=o.join(""):i?n.push(o.join("")):n.push(yd(o))),r.address=n.join(""),r}function py(t){if(bz(t,":")<2)return{host:t,isIPV6:!1};let e=vz(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function bz(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function wz(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function xz(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function kz(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!fy(r)){let n=py(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}my.exports={nonSimpleDomain:yz,recomposeAuthority:kz,normalizeComponentEncoding:xz,removeDotSegments:wz,isIPv4:fy,isUUID:gz,normalizeIPv6:py,stringArrayToHexStripped:yd}});var vy=E((hq,_y)=>{"use strict";var{isUUID:Sz}=_d(),$z=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Tz=["http","https","ws","wss","urn","urn:uuid"];function zz(t){return Tz.indexOf(t)!==-1}function vd(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function hy(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function gy(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function Rz(t){return t.secure=vd(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Ez(t){if((t.port===(vd(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function Pz(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match($z);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=bd(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Az(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=bd(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function Cz(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Sz(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Oz(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var yy={scheme:"http",domainHost:!0,parse:hy,serialize:gy},Nz={scheme:"https",domainHost:yy.domainHost,parse:hy,serialize:gy},Gi={scheme:"ws",domainHost:!0,parse:Rz,serialize:Ez},Iz={scheme:"wss",domainHost:Gi.domainHost,parse:Gi.parse,serialize:Gi.serialize},Mz={scheme:"urn",parse:Pz,serialize:Az,skipNormalize:!0},jz={scheme:"urn:uuid",parse:Cz,serialize:Oz,skipNormalize:!0},Qi={http:yy,https:Nz,ws:Gi,wss:Iz,urn:Mz,"urn:uuid":jz};Object.setPrototypeOf(Qi,null);function bd(t){return t&&(Qi[t]||Qi[t.toLowerCase()])||void 0}_y.exports={wsIsSecure:vd,SCHEMES:Qi,isValidSchemeName:zz,getSchemeHandler:bd}});var xy=E((gq,Xi)=>{"use strict";var{normalizeIPv6:qz,removeDotSegments:es,recomposeAuthority:Dz,normalizeComponentEncoding:Yi,isIPv4:Zz,nonSimpleDomain:Lz}=_d(),{SCHEMES:Uz,getSchemeHandler:by}=vy();function Fz(t,e){return typeof t=="string"?t=jt(nr(t,e),e):typeof t=="object"&&(t=nr(jt(t,e),e)),t}function Hz(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=wy(nr(t,n),nr(e,n),n,!0);return n.skipEscape=!0,jt(o,n)}function wy(t,e,r,n){let o={};return n||(t=nr(jt(t,r),r),e=nr(jt(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=es(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=es(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=es(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=es(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function Vz(t,e,r){return typeof t=="string"?(t=unescape(t),t=jt(Yi(nr(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=jt(Yi(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=jt(Yi(nr(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=jt(Yi(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function jt(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=by(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=Dz(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=es(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var Bz=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function nr(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let s=t.match(Bz);if(s){if(n.scheme=s[1],n.userinfo=s[3],n.host=s[4],n.port=parseInt(s[5],10),n.path=s[6]||"",n.query=s[7],n.fragment=s[8],isNaN(n.port)&&(n.port=s[5]),n.host)if(Zz(n.host)===!1){let c=qz(n.host);n.host=c.host.toLowerCase(),o=c.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let i=by(r.scheme||n.scheme);if(!r.unicodeSupport&&(!i||!i.unicodeSupport)&&n.host&&(r.domainHost||i&&i.domainHost)&&o===!1&&Lz(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!i||i&&!i.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),i&&i.parse&&i.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var wd={SCHEMES:Uz,normalize:Fz,resolve:Hz,resolveComponent:wy,equal:Vz,serialize:jt,parse:nr};Xi.exports=wd;Xi.exports.default=wd;Xi.exports.fastUri=wd});var Sy=E(xd=>{"use strict";Object.defineProperty(xd,"__esModule",{value:!0});var ky=xy();ky.code='require("ajv/dist/runtime/uri").default';xd.default=ky});var Cy=E(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.CodeGen=Ie.Name=Ie.nil=Ie.stringify=Ie.str=Ie._=Ie.KeywordCxt=void 0;var Kz=Yo();Object.defineProperty(Ie,"KeywordCxt",{enumerable:!0,get:function(){return Kz.KeywordCxt}});var Wn=B();Object.defineProperty(Ie,"_",{enumerable:!0,get:function(){return Wn._}});Object.defineProperty(Ie,"str",{enumerable:!0,get:function(){return Wn.str}});Object.defineProperty(Ie,"stringify",{enumerable:!0,get:function(){return Wn.stringify}});Object.defineProperty(Ie,"nil",{enumerable:!0,get:function(){return Wn.nil}});Object.defineProperty(Ie,"Name",{enumerable:!0,get:function(){return Wn.Name}});Object.defineProperty(Ie,"CodeGen",{enumerable:!0,get:function(){return Wn.CodeGen}});var Jz=Ki(),Ey=Xo(),Wz=Ql(),ts=Wi(),Gz=B(),rs=Wo(),ea=Jo(),Sd=ne(),$y=ly(),Qz=Sy(),Py=(t,e)=>new RegExp(t,e);Py.code="new RegExp";var Yz=["removeAdditional","useDefaults","coerceTypes"],Xz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),eR={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},tR={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Ty=200;function rR(t){var e,r,n,o,s,i,a,c,u,l,d,p,m,f,h,g,y,b,k,T,R,me,ie,Ve,Be;let ir=t.strict,bn=(e=t.code)===null||e===void 0?void 0:e.optimize,Nr=bn===!0||bn===void 0?1:bn||0,ar=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Py,Bt=(o=t.uriResolver)!==null&&o!==void 0?o:Qz.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:ir)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:ir)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:ir)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:ir)!==null&&p!==void 0?p:"log",strictRequired:(f=(m=t.strictRequired)!==null&&m!==void 0?m:ir)!==null&&f!==void 0?f:!1,code:t.code?{...t.code,optimize:Nr,regExp:ar}:{optimize:Nr,regExp:ar},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:Ty,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:Ty,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(b=t.messages)!==null&&b!==void 0?b:!0,inlineRefs:(k=t.inlineRefs)!==null&&k!==void 0?k:!0,schemaId:(T=t.schemaId)!==null&&T!==void 0?T:"$id",addUsedSchema:(R=t.addUsedSchema)!==null&&R!==void 0?R:!0,validateSchema:(me=t.validateSchema)!==null&&me!==void 0?me:!0,validateFormats:(ie=t.validateFormats)!==null&&ie!==void 0?ie:!0,unicodeRegExp:(Ve=t.unicodeRegExp)!==null&&Ve!==void 0?Ve:!0,int32range:(Be=t.int32range)!==null&&Be!==void 0?Be:!0,uriResolver:Bt}}var ns=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...rR(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Gz.ValueScope({scope:{},prefixes:Xz,es5:r,lines:n}),this.logger=cR(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Wz.getRules)(),zy.call(this,eR,e,"NOT SUPPORTED"),zy.call(this,tR,e,"DEPRECATED","warn"),this._metaOpts=iR.call(this),e.formats&&oR.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&sR.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),nR.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=$y;n==="id"&&(o={...$y},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Ey.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,rs.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=Ry.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ts.SchemaEnv({schema:{},schemaId:n});if(r=ts.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Ry.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,rs.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(lR.call(this,n,r),!r)return(0,Sd.eachItem)(n,s=>kd.call(this,s)),this;fR.call(this,r);let o={...r,type:(0,ea.getJSONTypes)(r.type),schemaType:(0,ea.getJSONTypes)(r.schemaType)};return(0,Sd.eachItem)(n,o.type.length===0?s=>kd.call(this,s,o):s=>o.type.forEach(i=>kd.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Ay(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,rs.normalizeId)(i||n);let u=rs.getSchemaRefs.call(this,e,n);return c=new ts.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):ts.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{ts.compileSchema.call(this,e)}finally{this.opts=r}}};ns.ValidationError=Jz.default;ns.MissingRefError=Ey.default;Ie.default=ns;function zy(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function Ry(t){return t=(0,rs.normalizeId)(t),this.schemas[t]||this.refs[t]}function nR(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function oR(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function sR(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function iR(){let t={...this.opts};for(let e of Yz)delete t[e];return t}var aR={log(){},warn(){},error(){}};function cR(t){if(t===!1)return aR;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var uR=/^[a-z_$][a-z0-9_$:-]*$/i;function lR(t,e){let{RULES:r}=this;if((0,Sd.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!uR.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function kd(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,ea.getJSONTypes)(e.type),schemaType:(0,ea.getJSONTypes)(e.schemaType)}};e.before?dR.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function dR(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function fR(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Ay(e)),t.validateSchema=this.compile(e,!0))}var pR={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Ay(t){return{anyOf:[t,pR]}}});var Oy=E($d=>{"use strict";Object.defineProperty($d,"__esModule",{value:!0});var mR={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};$d.default=mR});var jy=E(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.callRef=fn.getValidate=void 0;var hR=Xo(),Ny=pt(),et=B(),Gn=tr(),Iy=Wi(),ta=ne(),gR={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=Iy.resolveRef.call(c,u,o,r);if(l===void 0)throw new hR.default(n.opts.uriResolver,o,r);if(l instanceof Iy.SchemaEnv)return p(l);return m(l);function d(){if(s===u)return ra(t,i,s,s.$async);let f=e.scopeValue("root",{ref:u});return ra(t,(0,et._)`${f}.validate`,u,u.$async)}function p(f){let h=My(t,f);ra(t,h,f,f.$async)}function m(f){let h=e.scopeValue("schema",a.code.source===!0?{ref:f,code:(0,et.stringify)(f)}:{ref:f}),g=e.name("valid"),y=t.subschema({schema:f,dataTypes:[],schemaPath:et.nil,topSchemaRef:h,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function My(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,et._)`${r.scopeValue("wrapper",{ref:e})}.validate`}fn.getValidate=My;function ra(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Gn.default.this:et.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let f=o.let("valid");o.try(()=>{o.code((0,et._)`await ${(0,Ny.callValidateCode)(t,e,u)}`),m(e),i||o.assign(f,!0)},h=>{o.if((0,et._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),p(h),i||o.assign(f,!1)}),t.ok(f)}function d(){t.result((0,Ny.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(f){let h=(0,et._)`${f}.errors`;o.assign(Gn.default.vErrors,(0,et._)`${Gn.default.vErrors} === null ? ${h} : ${Gn.default.vErrors}.concat(${h})`),o.assign(Gn.default.errors,(0,et._)`${Gn.default.vErrors}.length`)}function m(f){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=ta.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,et._)`${f}.evaluated.props`);s.props=ta.mergeEvaluated.props(o,y,s.props,et.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=ta.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,et._)`${f}.evaluated.items`);s.items=ta.mergeEvaluated.items(o,y,s.items,et.Name)}}}fn.callRef=ra;fn.default=gR});var qy=E(Td=>{"use strict";Object.defineProperty(Td,"__esModule",{value:!0});var yR=Oy(),_R=jy(),vR=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",yR.default,_R.default];Td.default=vR});var Dy=E(zd=>{"use strict";Object.defineProperty(zd,"__esModule",{value:!0});var na=B(),zr=na.operators,oa={maximum:{okStr:"<=",ok:zr.LTE,fail:zr.GT},minimum:{okStr:">=",ok:zr.GTE,fail:zr.LT},exclusiveMaximum:{okStr:"<",ok:zr.LT,fail:zr.GTE},exclusiveMinimum:{okStr:">",ok:zr.GT,fail:zr.LTE}},bR={message:({keyword:t,schemaCode:e})=>(0,na.str)`must be ${oa[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,na._)`{comparison: ${oa[t].okStr}, limit: ${e}}`},wR={keyword:Object.keys(oa),type:"number",schemaType:"number",$data:!0,error:bR,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,na._)`${r} ${oa[e].fail} ${n} || isNaN(${r})`)}};zd.default=wR});var Zy=E(Rd=>{"use strict";Object.defineProperty(Rd,"__esModule",{value:!0});var os=B(),xR={message:({schemaCode:t})=>(0,os.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,os._)`{multipleOf: ${t}}`},kR={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:xR,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,os._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,os._)`${i} !== parseInt(${i})`;t.fail$data((0,os._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Rd.default=kR});var Uy=E(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:!0});function Ly(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}Ed.default=Ly;Ly.code='require("ajv/dist/runtime/ucs2length").default'});var Fy=E(Pd=>{"use strict";Object.defineProperty(Pd,"__esModule",{value:!0});var pn=B(),SR=ne(),$R=Uy(),TR={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,pn.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,pn._)`{limit: ${t}}`},zR={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:TR,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?pn.operators.GT:pn.operators.LT,i=o.opts.unicode===!1?(0,pn._)`${r}.length`:(0,pn._)`${(0,SR.useFunc)(t.gen,$R.default)}(${r})`;t.fail$data((0,pn._)`${i} ${s} ${n}`)}};Pd.default=zR});var Hy=E(Ad=>{"use strict";Object.defineProperty(Ad,"__esModule",{value:!0});var RR=pt(),sa=B(),ER={message:({schemaCode:t})=>(0,sa.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,sa._)`{pattern: ${t}}`},PR={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:ER,code(t){let{data:e,$data:r,schema:n,schemaCode:o,it:s}=t,i=s.opts.unicodeRegExp?"u":"",a=r?(0,sa._)`(new RegExp(${o}, ${i}))`:(0,RR.usePattern)(t,n);t.fail$data((0,sa._)`!${a}.test(${e})`)}};Ad.default=PR});var Vy=E(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:!0});var ss=B(),AR={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,ss.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,ss._)`{limit: ${t}}`},CR={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:AR,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?ss.operators.GT:ss.operators.LT;t.fail$data((0,ss._)`Object.keys(${r}).length ${o} ${n}`)}};Cd.default=CR});var By=E(Od=>{"use strict";Object.defineProperty(Od,"__esModule",{value:!0});var is=pt(),as=B(),OR=ne(),NR={message:({params:{missingProperty:t}})=>(0,as.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,as._)`{missingProperty: ${t}}`},IR={keyword:"required",type:"object",schemaType:"array",$data:!0,error:NR,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:f}=t.it;for(let h of r)if(m?.[h]===void 0&&!f.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,OR.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(as.nil,d);else for(let m of r)(0,is.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||s){let f=e.let("valid",!0);t.block$data(f,()=>p(m,f)),t.ok(f)}else e.if((0,is.checkMissingProp)(t,r,m)),(0,is.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,is.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function p(m,f){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(f,(0,is.propertyInData)(e,o,m,a.ownProperties)),e.if((0,as.not)(f),()=>{t.error(),e.break()})},as.nil)}}};Od.default=IR});var Ky=E(Nd=>{"use strict";Object.defineProperty(Nd,"__esModule",{value:!0});var cs=B(),MR={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,cs.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,cs._)`{limit: ${t}}`},jR={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:MR,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?cs.operators.GT:cs.operators.LT;t.fail$data((0,cs._)`${r}.length ${o} ${n}`)}};Nd.default=jR});var ia=E(Id=>{"use strict";Object.defineProperty(Id,"__esModule",{value:!0});var Jy=sd();Jy.code='require("ajv/dist/runtime/equal").default';Id.default=Jy});var Wy=E(jd=>{"use strict";Object.defineProperty(jd,"__esModule",{value:!0});var Md=Jo(),Me=B(),qR=ne(),DR=ia(),ZR={message:({params:{i:t,j:e}})=>(0,Me.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Me._)`{i: ${t}, j: ${e}}`},LR={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:ZR,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,Md.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,Me._)`${i} === false`),t.ok(c);function l(){let f=e.let("i",(0,Me._)`${r}.length`),h=e.let("j");t.setParams({i:f,j:h}),e.assign(c,!0),e.if((0,Me._)`${f} > 1`,()=>(d()?p:m)(f,h))}function d(){return u.length>0&&!u.some(f=>f==="object"||f==="array")}function p(f,h){let g=e.name("item"),y=(0,Md.checkDataTypes)(u,g,a.opts.strictNumbers,Md.DataType.Wrong),b=e.const("indices",(0,Me._)`{}`);e.for((0,Me._)`;${f}--;`,()=>{e.let(g,(0,Me._)`${r}[${f}]`),e.if(y,(0,Me._)`continue`),u.length>1&&e.if((0,Me._)`typeof ${g} == "string"`,(0,Me._)`${g} += "_"`),e.if((0,Me._)`typeof ${b}[${g}] == "number"`,()=>{e.assign(h,(0,Me._)`${b}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,Me._)`${b}[${g}] = ${f}`)})}function m(f,h){let g=(0,qR.useFunc)(e,DR.default),y=e.name("outer");e.label(y).for((0,Me._)`;${f}--;`,()=>e.for((0,Me._)`${h} = ${f}; ${h}--;`,()=>e.if((0,Me._)`${g}(${r}[${f}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};jd.default=LR});var Gy=E(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});var qd=B(),UR=ne(),FR=ia(),HR={message:"must be equal to constant",params:({schemaCode:t})=>(0,qd._)`{allowedValue: ${t}}`},VR={keyword:"const",$data:!0,error:HR,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,qd._)`!${(0,UR.useFunc)(e,FR.default)}(${r}, ${o})`):t.fail((0,qd._)`${s} !== ${r}`)}};Dd.default=VR});var Qy=E(Zd=>{"use strict";Object.defineProperty(Zd,"__esModule",{value:!0});var us=B(),BR=ne(),KR=ia(),JR={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,us._)`{allowedValues: ${t}}`},WR={keyword:"enum",schemaType:"array",$data:!0,error:JR,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,BR.useFunc)(e,KR.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",s);l=(0,us.or)(...o.map((f,h)=>p(m,h)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,m=>e.if((0,us._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function p(m,f){let h=o[f];return typeof h=="object"&&h!==null?(0,us._)`${u()}(${r}, ${m}[${f}])`:(0,us._)`${r} === ${h}`}}};Zd.default=WR});var Yy=E(Ld=>{"use strict";Object.defineProperty(Ld,"__esModule",{value:!0});var GR=Dy(),QR=Zy(),YR=Fy(),XR=Hy(),eE=Vy(),tE=By(),rE=Ky(),nE=Wy(),oE=Gy(),sE=Qy(),iE=[GR.default,QR.default,YR.default,XR.default,eE.default,tE.default,rE.default,nE.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},oE.default,sE.default];Ld.default=iE});var Fd=E(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.validateAdditionalItems=void 0;var mn=B(),Ud=ne(),aE={message:({params:{len:t}})=>(0,mn.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,mn._)`{limit: ${t}}`},cE={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:aE,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Ud.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Xy(t,n)}};function Xy(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,mn._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,mn._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Ud.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,mn._)`${a} <= ${e.length}`);r.if((0,mn.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Ud.Type.Num},u),i.allErrors||r.if((0,mn.not)(u),()=>r.break())})}}ls.validateAdditionalItems=Xy;ls.default=cE});var Hd=E(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.validateTuple=void 0;var e_=B(),aa=ne(),uE=pt(),lE={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return t_(t,"additionalItems",e);r.items=!0,!(0,aa.alwaysValidSchema)(r,e)&&t.ok((0,uE.validateArray)(t))}};function t_(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=aa.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,e_._)`${s}.length`);r.forEach((d,p)=>{(0,aa.alwaysValidSchema)(a,d)||(n.if((0,e_._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:m}=a,f=r.length,h=f===d.minItems&&(f===d.maxItems||d[e]===!1);if(p.strictTuples&&!h){let g=`"${i}" is ${f}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,aa.checkStrictMode)(a,g,p.strictTuples)}}}ds.validateTuple=t_;ds.default=lE});var r_=E(Vd=>{"use strict";Object.defineProperty(Vd,"__esModule",{value:!0});var dE=Hd(),fE={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,dE.validateTuple)(t,"items")};Vd.default=fE});var o_=E(Bd=>{"use strict";Object.defineProperty(Bd,"__esModule",{value:!0});var n_=B(),pE=ne(),mE=pt(),hE=Fd(),gE={message:({params:{len:t}})=>(0,n_.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,n_._)`{limit: ${t}}`},yE={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:gE,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,pE.alwaysValidSchema)(n,e)&&(o?(0,hE.validateAdditionalItems)(t,o):t.ok((0,mE.validateArray)(t)))}};Bd.default=yE});var s_=E(Kd=>{"use strict";Object.defineProperty(Kd,"__esModule",{value:!0});var ht=B(),ca=ne(),_E={message:({params:{min:t,max:e}})=>e===void 0?(0,ht.str)`must contain at least ${t} valid item(s)`:(0,ht.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,ht._)`{minContains: ${t}}`:(0,ht._)`{minContains: ${t}, maxContains: ${e}}`},vE={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:_E,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,ht._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,ca.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ca.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,ca.alwaysValidSchema)(s,r)){let h=(0,ht._)`${l} >= ${i}`;a!==void 0&&(h=(0,ht._)`${h} && ${l} <= ${a}`),t.pass(h);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,ht._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let h=e.name("_valid"),g=e.let("count",0);m(h,()=>e.if(h,()=>f(g)))}function m(h,g){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:ca.Type.Num,compositeRule:!0},h),g()})}function f(h){e.code((0,ht._)`${h}++`),a===void 0?e.if((0,ht._)`${h} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,ht._)`${h} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,ht._)`${h} >= ${i}`,()=>e.assign(d,!0)))}}};Kd.default=vE});var c_=E(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.validateSchemaDeps=qt.validatePropertyDeps=qt.error=void 0;var Jd=B(),bE=ne(),fs=pt();qt.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Jd.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Jd._)`{property: ${t},
|
|
6
6
|
missingProperty: ${n},
|
|
7
7
|
depsCount: ${e},
|
|
8
|
-
deps: ${r}}`};var yE={keyword:"dependencies",type:"object",schemaType:"object",error:qt.error,code(t){let[e,r]=_E(t);n_(t,e),o_(t,r)}};function _E({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function n_(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,fs.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,fs.checkReportMissingProp)(t,u)}):(r.if((0,Bd._)`${c} && (${(0,fs.checkMissingProp)(t,a,s)})`),(0,fs.reportMissingProp)(t,s),r.else())}}qt.validatePropertyDeps=n_;function o_(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,gE.alwaysValidSchema)(s,e[a])||(r.if((0,fs.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}qt.validateSchemaDeps=o_;qt.default=yE});var a_=E(Kd=>{"use strict";Object.defineProperty(Kd,"__esModule",{value:!0});var i_=B(),vE=ne(),bE={message:"property name must be valid",params:({params:t})=>(0,i_._)`{propertyName: ${t.propertyName}}`},wE={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:bE,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,vE.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,i_.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Kd.default=wE});var Wd=E(Jd=>{"use strict";Object.defineProperty(Jd,"__esModule",{value:!0});var ua=pt(),Tt=B(),xE=tr(),la=ne(),kE={message:"must NOT have additional properties",params:({params:t})=>(0,Tt._)`{additionalProperty: ${t.additionalProperty}}`},SE={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:kE,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,la.alwaysValidSchema)(i,r))return;let u=(0,ua.allSchemaProperties)(n.properties),l=(0,ua.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Tt._)`${s} === ${xE.default.errors}`);function d(){e.forIn("key",o,g=>{!u.length&&!l.length?f(g):e.if(p(g),()=>f(g))})}function p(g){let y;if(u.length>8){let b=(0,la.schemaRefOrVal)(i,n.properties,"properties");y=(0,ua.isOwnProperty)(e,b,g)}else u.length?y=(0,Tt.or)(...u.map(b=>(0,Tt._)`${g} === ${b}`)):y=Tt.nil;return l.length&&(y=(0,Tt.or)(y,...l.map(b=>(0,Tt._)`${(0,ua.usePattern)(t,b)}.test(${g})`))),(0,Tt.not)(y)}function m(g){e.code((0,Tt._)`delete ${o}[${g}]`)}function f(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,la.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),e.if((0,Tt.not)(y),()=>{t.reset(),m(g)})):(h(g,y),a||e.if((0,Tt.not)(y),()=>e.break()))}}function h(g,y,b){let k={keyword:"additionalProperties",dataProp:g,dataPropType:la.Type.Str};b===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(k,y)}}};Jd.default=SE});var l_=E(Qd=>{"use strict";Object.defineProperty(Qd,"__esModule",{value:!0});var $E=Yo(),c_=pt(),Gd=ne(),u_=Wd(),TE={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&u_.default.code(new $E.KeywordCxt(s,u_.default,"additionalProperties"));let i=(0,c_.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Gd.mergeEvaluated.props(e,(0,Gd.toHash)(i),s.props));let a=i.filter(d=>!(0,Gd.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,c_.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Qd.default=TE});var m_=E(Yd=>{"use strict";Object.defineProperty(Yd,"__esModule",{value:!0});var d_=pt(),da=B(),f_=ne(),p_=ne(),zE={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,d_.allSchemaProperties)(r),c=a.filter(h=>(0,f_.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof da.Name)&&(s.props=(0,p_.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let h of a)u&&m(h),s.allErrors?f(h):(e.var(l,!0),f(h),e.if(l))}function m(h){for(let g in u)new RegExp(h).test(g)&&(0,f_.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function f(h){e.forIn("key",n,g=>{e.if((0,da._)`${(0,d_.usePattern)(t,h)}.test(${g})`,()=>{let y=c.includes(h);y||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:p_.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,da._)`${d}[${g}]`,!0):!y&&!s.allErrors&&e.if((0,da.not)(l),()=>e.break())})})}}};Yd.default=zE});var h_=E(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});var RE=ne(),EE={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,RE.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Xd.default=EE});var g_=E(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});var PE=pt(),AE={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:PE.validateUnion,error:{message:"must match a schema in anyOf"}};ef.default=AE});var y_=E(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var fa=B(),CE=ne(),OE={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,fa._)`{passingSchemas: ${t.passing}}`},NE={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:OE,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let p;(0,CE.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,fa._)`${c} && ${i}`).assign(i,!1).assign(a,(0,fa._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,fa.Name)})})}}};tf.default=NE});var __=E(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});var IE=ne(),ME={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,IE.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};rf.default=ME});var w_=E(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});var pa=B(),b_=ne(),jE={message:({params:t})=>(0,pa.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,pa._)`{failingKeyword: ${t.ifClause}}`},qE={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:jE,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,b_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=v_(n,"then"),s=v_(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,pa.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,pa._)`${l}`):t.setParams({ifClause:l})}}}};function v_(t,e){let r=t.schema[e];return r!==void 0&&!(0,b_.alwaysValidSchema)(t,r)}nf.default=qE});var x_=E(of=>{"use strict";Object.defineProperty(of,"__esModule",{value:!0});var DE=ne(),ZE={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,DE.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};of.default=ZE});var k_=E(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});var LE=Ld(),UE=Xy(),FE=Ud(),HE=t_(),VE=r_(),BE=s_(),KE=a_(),JE=Wd(),WE=l_(),GE=m_(),QE=h_(),YE=g_(),XE=y_(),eP=__(),tP=w_(),rP=x_();function nP(t=!1){let e=[QE.default,YE.default,XE.default,eP.default,tP.default,rP.default,KE.default,JE.default,BE.default,WE.default,GE.default];return t?e.push(UE.default,HE.default):e.push(LE.default,FE.default),e.push(VE.default),e}sf.default=nP});var S_=E(af=>{"use strict";Object.defineProperty(af,"__esModule",{value:!0});var $e=B(),oP={message:({schemaCode:t})=>(0,$e.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,$e._)`{format: ${t}}`},sP={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:oP,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():m();function p(){let f=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,$e._)`${f}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,$e._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,$e._)`${h}.type || "string"`).assign(y,(0,$e._)`${h}.validate`),()=>r.assign(g,(0,$e._)`"string"`).assign(y,h)),t.fail$data((0,$e.or)(b(),k()));function b(){return c.strictSchema===!1?$e.nil:(0,$e._)`${i} && !${y}`}function k(){let T=l.$async?(0,$e._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,$e._)`${y}(${n})`,R=(0,$e._)`(typeof ${y} == "function" ? ${T} : ${y}.test(${n}))`;return(0,$e._)`${y} && ${y} !== true && ${g} === ${e} && !${R}`}}function m(){let f=d.formats[s];if(!f){b();return}if(f===!0)return;let[h,g,y]=k(f);h===e&&t.pass(T());function b(){if(c.strictSchema===!1){d.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function k(R){let me=R instanceof RegExp?(0,$e.regexpCode)(R):c.code.formats?(0,$e._)`${c.code.formats}${(0,$e.getProperty)(s)}`:void 0,ie=r.scopeValue("formats",{key:s,ref:R,code:me});return typeof R=="object"&&!(R instanceof RegExp)?[R.type||"string",R.validate,(0,$e._)`${ie}.validate`]:["string",R,ie]}function T(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!l.$async)throw new Error("async format in sync schema");return(0,$e._)`await ${y}(${n})`}return typeof g=="function"?(0,$e._)`${y}(${n})`:(0,$e._)`${y}.test(${n})`}}}};af.default=sP});var $_=E(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});var iP=S_(),aP=[iP.default];cf.default=aP});var T_=E(Qn=>{"use strict";Object.defineProperty(Qn,"__esModule",{value:!0});Qn.contentVocabulary=Qn.metadataVocabulary=void 0;Qn.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Qn.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var R_=E(uf=>{"use strict";Object.defineProperty(uf,"__esModule",{value:!0});var cP=Iy(),uP=Wy(),lP=k_(),dP=$_(),z_=T_(),fP=[cP.default,uP.default,(0,lP.default)(),dP.default,z_.metadataVocabulary,z_.contentVocabulary];uf.default=fP});var P_=E(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.DiscrError=void 0;var E_;(function(t){t.Tag="tag",t.Mapping="mapping"})(E_||(ma.DiscrError=E_={}))});var C_=E(df=>{"use strict";Object.defineProperty(df,"__esModule",{value:!0});var Yn=B(),lf=P_(),A_=Wi(),pP=Xo(),mP=ne(),hP={message:({params:{discrError:t,tagName:e}})=>t===lf.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Yn._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},gP={keyword:"discriminator",type:"object",schemaType:"object",error:hP,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,Yn._)`${r}${(0,Yn.getProperty)(a)}`);e.if((0,Yn._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:lf.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=p();e.if(!1);for(let f in m)e.elseIf((0,Yn._)`${u} === ${f}`),e.assign(c,d(m[f]));e.else(),t.error(!1,{discrError:lf.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let f=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:m},f);return t.mergeEvaluated(h,Yn.Name),f}function p(){var m;let f={},h=y(o),g=!0;for(let T=0;T<i.length;T++){let R=i[T];if(R?.$ref&&!(0,mP.schemaHasRulesButRef)(R,s.self.RULES)){let ie=R.$ref;if(R=A_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,ie),R instanceof A_.SchemaEnv&&(R=R.schema),R===void 0)throw new pP.default(s.opts.uriResolver,s.baseId,ie)}let me=(m=R?.properties)===null||m===void 0?void 0:m[a];if(typeof me!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(R)),b(me,T)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return f;function y({required:T}){return Array.isArray(T)&&T.includes(a)}function b(T,R){if(T.const)k(T.const,R);else if(T.enum)for(let me of T.enum)k(me,R);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function k(T,R){if(typeof T!="string"||T in f)throw new Error(`discriminator: "${a}" values must be unique strings`);f[T]=R}}}};df.default=gP});var O_=E((Yq,yP)=>{yP.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var pf=E((ge,ff)=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.MissingRefError=ge.ValidationError=ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=ge.Ajv=void 0;var _P=Ey(),vP=R_(),bP=C_(),N_=O_(),wP=["/properties"],ha="http://json-schema.org/draft-07/schema",Xn=class extends _P.default{_addVocabularies(){super._addVocabularies(),vP.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(bP.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(N_,wP):N_;this.addMetaSchema(e,ha,!1),this.refs["http://json-schema.org/schema"]=ha}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ha)?ha:void 0)}};ge.Ajv=Xn;ff.exports=ge=Xn;ff.exports.Ajv=Xn;Object.defineProperty(ge,"__esModule",{value:!0});ge.default=Xn;var xP=Yo();Object.defineProperty(ge,"KeywordCxt",{enumerable:!0,get:function(){return xP.KeywordCxt}});var eo=B();Object.defineProperty(ge,"_",{enumerable:!0,get:function(){return eo._}});Object.defineProperty(ge,"str",{enumerable:!0,get:function(){return eo.str}});Object.defineProperty(ge,"stringify",{enumerable:!0,get:function(){return eo.stringify}});Object.defineProperty(ge,"nil",{enumerable:!0,get:function(){return eo.nil}});Object.defineProperty(ge,"Name",{enumerable:!0,get:function(){return eo.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:!0,get:function(){return eo.CodeGen}});var kP=Ki();Object.defineProperty(ge,"ValidationError",{enumerable:!0,get:function(){return kP.default}});var SP=Xo();Object.defineProperty(ge,"MissingRefError",{enumerable:!0,get:function(){return SP.default}})});var U_=E(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.formatNames=Zt.fastFormats=Zt.fullFormats=void 0;function Dt(t,e){return{validate:t,compare:e}}Zt.fullFormats={date:Dt(q_,yf),time:Dt(hf(!0),_f),"date-time":Dt(I_(!0),Z_),"iso-time":Dt(hf(),D_),"iso-date-time":Dt(I_(),L_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:PP,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:jP,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:AP,int32:{type:"number",validate:NP},int64:{type:"number",validate:IP},float:{type:"number",validate:j_},double:{type:"number",validate:j_},password:!0,binary:!0};Zt.fastFormats={...Zt.fullFormats,date:Dt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,yf),time:Dt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,_f),"date-time":Dt(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Z_),"iso-time":Dt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,D_),"iso-date-time":Dt(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,L_),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};Zt.formatNames=Object.keys(Zt.fullFormats);function $P(t){return t%4===0&&(t%100!==0||t%400===0)}var TP=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,zP=[0,31,28,31,30,31,30,31,31,30,31,30,31];function q_(t){let e=TP.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&$P(r)?29:zP[n])}function yf(t,e){if(t&&e)return t>e?1:t<e?-1:0}var mf=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function hf(t){return function(r){let n=mf.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function _f(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function D_(t,e){if(!(t&&e))return;let r=mf.exec(t),n=mf.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var gf=/t|\s/i;function I_(t){let e=hf(t);return function(n){let o=n.split(gf);return o.length===2&&q_(o[0])&&e(o[1])}}function Z_(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function L_(t,e){if(!(t&&e))return;let[r,n]=t.split(gf),[o,s]=e.split(gf),i=yf(r,o);if(i!==void 0)return i||_f(n,s)}var RP=/\/|:/,EP=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function PP(t){return RP.test(t)&&EP.test(t)}var M_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function AP(t){return M_.lastIndex=0,M_.test(t)}var CP=-(2**31),OP=2**31-1;function NP(t){return Number.isInteger(t)&&t<=OP&&t>=CP}function IP(t){return Number.isInteger(t)}function j_(){return!0}var MP=/[^\\]\\Z/;function jP(t){if(MP.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var F_=E(to=>{"use strict";Object.defineProperty(to,"__esModule",{value:!0});to.formatLimitDefinition=void 0;var qP=pf(),zt=B(),Rr=zt.operators,ga={formatMaximum:{okStr:"<=",ok:Rr.LTE,fail:Rr.GT},formatMinimum:{okStr:">=",ok:Rr.GTE,fail:Rr.LT},formatExclusiveMaximum:{okStr:"<",ok:Rr.LT,fail:Rr.GTE},formatExclusiveMinimum:{okStr:">",ok:Rr.GT,fail:Rr.LTE}},DP={message:({keyword:t,schemaCode:e})=>(0,zt.str)`should be ${ga[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,zt._)`{comparison: ${ga[t].okStr}, limit: ${e}}`};to.formatLimitDefinition={keyword:Object.keys(ga),type:"string",schemaType:"string",$data:!0,error:DP,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new qP.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,zt._)`${p}[${c.schemaCode}]`);t.fail$data((0,zt.or)((0,zt._)`typeof ${m} != "object"`,(0,zt._)`${m} instanceof RegExp`,(0,zt._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let p=c.schema,m=a.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let f=e.scopeValue("formats",{key:p,ref:m,code:i.code.formats?(0,zt._)`${i.code.formats}${(0,zt.getProperty)(p)}`:void 0});t.fail$data(d(f))}function d(p){return(0,zt._)`${p}.compare(${r}, ${n}) ${ga[o].fail} 0`}},dependencies:["format"]};var ZP=t=>(t.addKeyword(to.formatLimitDefinition),t);to.default=ZP});var K_=E((ps,B_)=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});var ro=U_(),LP=F_(),vf=B(),H_=new vf.Name("fullFormats"),UP=new vf.Name("fastFormats"),bf=(t,e={keywords:!0})=>{if(Array.isArray(e))return V_(t,e,ro.fullFormats,H_),t;let[r,n]=e.mode==="fast"?[ro.fastFormats,UP]:[ro.fullFormats,H_],o=e.formats||ro.formatNames;return V_(t,o,r,n),e.keywords&&(0,LP.default)(t),t};bf.get=(t,e="full")=>{let n=(e==="fast"?ro.fastFormats:ro.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function V_(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,vf._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}B_.exports=ps=bf;Object.defineProperty(ps,"__esModule",{value:!0});ps.default=bf});var v={};Os(v,{BRAND:()=>Ew,DIRTY:()=>Ir,EMPTY_PATH:()=>aw,INVALID:()=>j,NEVER:()=>fx,OK:()=>je,ParseStatus:()=>Pe,Schema:()=>V,ZodAny:()=>fr,ZodArray:()=>Gt,ZodBigInt:()=>jr,ZodBoolean:()=>qr,ZodBranded:()=>po,ZodCatch:()=>Wr,ZodDate:()=>Dr,ZodDefault:()=>Jr,ZodDiscriminatedUnion:()=>Ms,ZodEffects:()=>ct,ZodEnum:()=>Br,ZodError:()=>Ke,ZodFirstPartyTypeKind:()=>$,ZodFunction:()=>qs,ZodIntersection:()=>Fr,ZodIssueCode:()=>S,ZodLazy:()=>Hr,ZodLiteral:()=>Vr,ZodMap:()=>zn,ZodNaN:()=>En,ZodNativeEnum:()=>Kr,ZodNever:()=>vt,ZodNull:()=>Lr,ZodNullable:()=>Ot,ZodNumber:()=>Mr,ZodObject:()=>We,ZodOptional:()=>Je,ZodParsedType:()=>P,ZodPipeline:()=>mo,ZodPromise:()=>pr,ZodReadonly:()=>Gr,ZodRecord:()=>js,ZodSchema:()=>V,ZodSet:()=>Rn,ZodString:()=>dr,ZodSymbol:()=>$n,ZodTransformer:()=>ct,ZodTuple:()=>Ct,ZodType:()=>V,ZodUndefined:()=>Zr,ZodUnion:()=>Ur,ZodUnknown:()=>Wt,ZodVoid:()=>Tn,addIssueToContext:()=>z,any:()=>qw,array:()=>Uw,bigint:()=>Ow,boolean:()=>zp,coerce:()=>dx,custom:()=>Sp,date:()=>Nw,datetimeRegex:()=>xp,defaultErrorMap:()=>Kt,discriminatedUnion:()=>Vw,effect:()=>nx,enum:()=>ex,function:()=>Qw,getErrorMap:()=>xn,getParsedType:()=>At,instanceof:()=>Aw,intersection:()=>Bw,isAborted:()=>Ns,isAsync:()=>kn,isDirty:()=>Is,isValid:()=>lr,late:()=>Pw,lazy:()=>Yw,literal:()=>Xw,makeIssue:()=>fo,map:()=>Ww,nan:()=>Cw,nativeEnum:()=>tx,never:()=>Zw,null:()=>jw,nullable:()=>sx,number:()=>Tp,object:()=>Ga,objectUtil:()=>Ka,oboolean:()=>lx,onumber:()=>ux,optional:()=>ox,ostring:()=>cx,pipeline:()=>ax,preprocess:()=>ix,promise:()=>rx,quotelessJson:()=>ow,record:()=>Jw,set:()=>Gw,setErrorMap:()=>iw,strictObject:()=>Fw,string:()=>$p,symbol:()=>Iw,transformer:()=>nx,tuple:()=>Kw,undefined:()=>Mw,union:()=>Hw,unknown:()=>Dw,util:()=>G,void:()=>Lw});var G;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(G||(G={}));var Ka;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ka||(Ka={}));var P=G.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),At=t=>{switch(typeof t){case"undefined":return P.undefined;case"string":return P.string;case"number":return Number.isNaN(t)?P.nan:P.number;case"boolean":return P.boolean;case"function":return P.function;case"bigint":return P.bigint;case"symbol":return P.symbol;case"object":return Array.isArray(t)?P.array:t===null?P.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?P.promise:typeof Map<"u"&&t instanceof Map?P.map:typeof Set<"u"&&t instanceof Set?P.set:typeof Date<"u"&&t instanceof Date?P.date:P.object;default:return P.unknown}};var S=G.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ow=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ke=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,G.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ke.create=t=>new Ke(t);var sw=(t,e)=>{let r;switch(t.code){case S.invalid_type:t.received===P.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case S.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,G.jsonStringifyReplacer)}`;break;case S.unrecognized_keys:r=`Unrecognized key(s) in object: ${G.joinValues(t.keys,", ")}`;break;case S.invalid_union:r="Invalid input";break;case S.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${G.joinValues(t.options)}`;break;case S.invalid_enum_value:r=`Invalid enum value. Expected ${G.joinValues(t.options)}, received '${t.received}'`;break;case S.invalid_arguments:r="Invalid function arguments";break;case S.invalid_return_type:r="Invalid function return type";break;case S.invalid_date:r="Invalid date";break;case S.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:G.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case S.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case S.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case S.custom:r="Invalid input";break;case S.invalid_intersection_types:r="Intersection results could not be merged";break;case S.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case S.not_finite:r="Number must be finite";break;default:r=e.defaultError,G.assertNever(t)}return{message:r}},Kt=sw;var yp=Kt;function iw(t){yp=t}function xn(){return yp}var fo=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},aw=[];function z(t,e){let r=xn(),n=fo({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Kt?void 0:Kt].filter(o=>!!o)});t.common.issues.push(n)}var Pe=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return j;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,i=await o.value;n.push({key:s,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return j;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}},j=Object.freeze({status:"aborted"}),Ir=t=>({status:"dirty",value:t}),je=t=>({status:"valid",value:t}),Ns=t=>t.status==="aborted",Is=t=>t.status==="dirty",lr=t=>t.status==="valid",kn=t=>typeof Promise<"u"&&t instanceof Promise;var C;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(C||(C={}));var at=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},_p=(t,e)=>{if(lr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Ke(t.common.issues);return this._error=r,this._error}}};function F(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}var V=class{get description(){return this._def.description}_getType(e){return At(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Pe,ctx:{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(kn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},o=this._parseSync({data:e,path:n.path,parent:n});return _p(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return lr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>lr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(kn(o)?o:Promise.resolve(o));return _p(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:S.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new ct({schema:this,typeName:$.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Je.create(this,this._def)}nullable(){return Ot.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Gt.create(this)}promise(){return pr.create(this,this._def)}or(e){return Ur.create([this,e],this._def)}and(e){return Fr.create(this,e,this._def)}transform(e){return new ct({...F(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Jr({...F(this._def),innerType:this,defaultValue:r,typeName:$.ZodDefault})}brand(){return new po({typeName:$.ZodBranded,type:this,...F(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Wr({...F(this._def),innerType:this,catchValue:r,typeName:$.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return mo.create(this,e)}readonly(){return Gr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},cw=/^c[^\s-]{8,}$/i,uw=/^[0-9a-z]+$/,lw=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,fw=/^[a-z0-9_-]{21}$/i,pw=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,mw=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,hw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ja,yw=/^(?:(?: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])$/,_w=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,vw=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,bw=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ww=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xw=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,bp="((\\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])))",kw=new RegExp(`^${bp}$`);function wp(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Sw(t){return new RegExp(`^${wp(t)}$`)}function xp(t){let e=`${bp}T${wp(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function $w(t,e){return!!((e==="v4"||!e)&&yw.test(t)||(e==="v6"||!e)&&vw.test(t))}function Tw(t,e){if(!pw.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function zw(t,e){return!!((e==="v4"||!e)&&_w.test(t)||(e==="v6"||!e)&&bw.test(t))}var dr=class t extends V{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==P.string){let s=this._getOrReturnCtx(e);return z(s,{code:S.invalid_type,expected:P.string,received:s.parsedType}),j}let n=new Pe,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),z(o,{code:S.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),z(o,{code:S.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?z(o,{code:S.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&z(o,{code:S.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")hw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"email",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Ja||(Ja=new RegExp(gw,"u")),Ja.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"emoji",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")dw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"uuid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")fw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"nanoid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")cw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"cuid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")uw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"cuid2",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")lw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"ulid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),z(o,{validation:"url",code:S.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"regex",code:S.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?xp(s).test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?kw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Sw(s).test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?mw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"duration",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?$w(e.data,s.version)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"ip",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?Tw(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"jwt",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?zw(e.data,s.version)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"cidr",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?ww.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"base64",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?xw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"base64url",code:S.invalid_string,message:s.message}),n.dirty()):G.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:S.invalid_string,...C.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...C.errToObj(e)})}url(e){return this._addCheck({kind:"url",...C.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...C.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...C.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...C.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...C.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...C.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...C.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...C.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...C.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...C.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...C.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...C.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...C.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...C.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...C.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...C.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...C.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...C.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...C.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...C.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...C.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...C.errToObj(r)})}nonempty(e){return this.min(1,C.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};dr.create=t=>new dr({checks:[],typeName:$.ZodString,coerce:t?.coerce??!1,...F(t)});function Rw(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var Mr=class t extends V{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==P.number){let s=this._getOrReturnCtx(e);return z(s,{code:S.invalid_type,expected:P.number,received:s.parsedType}),j}let n,o=new Pe;for(let s of this._def.checks)s.kind==="int"?G.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:S.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?Rw(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:S.not_finite,message:s.message}),o.dirty()):G.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,C.toString(r))}gt(e,r){return this.setLimit("min",e,!1,C.toString(r))}lte(e,r){return this.setLimit("max",e,!0,C.toString(r))}lt(e,r){return this.setLimit("max",e,!1,C.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:C.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:C.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:C.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:C.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:C.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:C.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&G.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Mr.create=t=>new Mr({checks:[],typeName:$.ZodNumber,coerce:t?.coerce||!1,...F(t)});var jr=class t extends V{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==P.bigint)return this._getInvalidInput(e);let n,o=new Pe;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):G.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return z(r,{code:S.invalid_type,expected:P.bigint,received:r.parsedType}),j}gte(e,r){return this.setLimit("min",e,!0,C.toString(r))}gt(e,r){return this.setLimit("min",e,!1,C.toString(r))}lte(e,r){return this.setLimit("max",e,!0,C.toString(r))}lt(e,r){return this.setLimit("max",e,!1,C.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:C.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:C.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};jr.create=t=>new jr({checks:[],typeName:$.ZodBigInt,coerce:t?.coerce??!1,...F(t)});var qr=class extends V{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==P.boolean){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.boolean,received:n.parsedType}),j}return je(e.data)}};qr.create=t=>new qr({typeName:$.ZodBoolean,coerce:t?.coerce||!1,...F(t)});var Dr=class t extends V{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==P.date){let s=this._getOrReturnCtx(e);return z(s,{code:S.invalid_type,expected:P.date,received:s.parsedType}),j}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return z(s,{code:S.invalid_date}),j}let n=new Pe,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),z(o,{code:S.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),z(o,{code:S.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):G.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:C.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:C.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Dr.create=t=>new Dr({checks:[],coerce:t?.coerce||!1,typeName:$.ZodDate,...F(t)});var $n=class extends V{_parse(e){if(this._getType(e)!==P.symbol){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.symbol,received:n.parsedType}),j}return je(e.data)}};$n.create=t=>new $n({typeName:$.ZodSymbol,...F(t)});var Zr=class extends V{_parse(e){if(this._getType(e)!==P.undefined){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.undefined,received:n.parsedType}),j}return je(e.data)}};Zr.create=t=>new Zr({typeName:$.ZodUndefined,...F(t)});var Lr=class extends V{_parse(e){if(this._getType(e)!==P.null){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.null,received:n.parsedType}),j}return je(e.data)}};Lr.create=t=>new Lr({typeName:$.ZodNull,...F(t)});var fr=class extends V{constructor(){super(...arguments),this._any=!0}_parse(e){return je(e.data)}};fr.create=t=>new fr({typeName:$.ZodAny,...F(t)});var Wt=class extends V{constructor(){super(...arguments),this._unknown=!0}_parse(e){return je(e.data)}};Wt.create=t=>new Wt({typeName:$.ZodUnknown,...F(t)});var vt=class extends V{_parse(e){let r=this._getOrReturnCtx(e);return z(r,{code:S.invalid_type,expected:P.never,received:r.parsedType}),j}};vt.create=t=>new vt({typeName:$.ZodNever,...F(t)});var Tn=class extends V{_parse(e){if(this._getType(e)!==P.undefined){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.void,received:n.parsedType}),j}return je(e.data)}};Tn.create=t=>new Tn({typeName:$.ZodVoid,...F(t)});var Gt=class t extends V{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==P.array)return z(r,{code:S.invalid_type,expected:P.array,received:r.parsedType}),j;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&(z(r,{code:i?S.too_big:S.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(z(r,{code:S.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(z(r,{code:S.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>o.type._parseAsync(new at(r,i,r.path,a)))).then(i=>Pe.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new at(r,i,r.path,a)));return Pe.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:C.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:C.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:C.toString(r)}})}nonempty(e){return this.min(1,e)}};Gt.create=(t,e)=>new Gt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...F(e)});function Sn(t){if(t instanceof We){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Je.create(Sn(n))}return new We({...t._def,shape:()=>e})}else return t instanceof Gt?new Gt({...t._def,type:Sn(t.element)}):t instanceof Je?Je.create(Sn(t.unwrap())):t instanceof Ot?Ot.create(Sn(t.unwrap())):t instanceof Ct?Ct.create(t.items.map(e=>Sn(e))):t}var We=class t extends V{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=G.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==P.object){let u=this._getOrReturnCtx(e);return z(u,{code:S.invalid_type,expected:P.object,received:u.parsedType}),j}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof vt&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let l=s[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new at(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof vt){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&(z(o,{code:S.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new at(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>Pe.mergeObjectSync(n,u)):Pe.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return C.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:C.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of G.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of G.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Sn(this)}partial(e){let r={};for(let n of G.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of G.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Je;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return kp(G.objectKeys(this.shape))}};We.create=(t,e)=>new We({shape:()=>t,unknownKeys:"strip",catchall:vt.create(),typeName:$.ZodObject,...F(e)});We.strictCreate=(t,e)=>new We({shape:()=>t,unknownKeys:"strict",catchall:vt.create(),typeName:$.ZodObject,...F(e)});We.lazycreate=(t,e)=>new We({shape:t,unknownKeys:"strip",catchall:vt.create(),typeName:$.ZodObject,...F(e)});var Ur=class extends V{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new Ke(a.ctx.common.issues));return z(r,{code:S.invalid_union,unionErrors:i}),j}if(r.common.async)return Promise.all(n.map(async s=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!s&&(s={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new Ke(c));return z(r,{code:S.invalid_union,unionErrors:a}),j}}get options(){return this._def.options}};Ur.create=(t,e)=>new Ur({options:t,typeName:$.ZodUnion,...F(e)});var Jt=t=>t instanceof Hr?Jt(t.schema):t instanceof ct?Jt(t.innerType()):t instanceof Vr?[t.value]:t instanceof Br?t.options:t instanceof Kr?G.objectValues(t.enum):t instanceof Jr?Jt(t._def.innerType):t instanceof Zr?[void 0]:t instanceof Lr?[null]:t instanceof Je?[void 0,...Jt(t.unwrap())]:t instanceof Ot?[null,...Jt(t.unwrap())]:t instanceof po||t instanceof Gr?Jt(t.unwrap()):t instanceof Wr?Jt(t._def.innerType):[],Ms=class t extends V{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==P.object)return z(r,{code:S.invalid_type,expected:P.object,received:r.parsedType}),j;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(z(r,{code:S.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),j)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let i=Jt(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...F(n)})}};function Wa(t,e){let r=At(t),n=At(e);if(t===e)return{valid:!0,data:t};if(r===P.object&&n===P.object){let o=G.objectKeys(e),s=G.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=Wa(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===P.array&&n===P.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=Wa(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===P.date&&n===P.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Fr=class extends V{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(Ns(s)||Ns(i))return j;let a=Wa(s.value,i.value);return a.valid?((Is(s)||Is(i))&&r.dirty(),{status:r.value,value:a.data}):(z(n,{code:S.invalid_intersection_types}),j)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Fr.create=(t,e,r)=>new Fr({left:t,right:e,typeName:$.ZodIntersection,...F(r)});var Ct=class t extends V{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.array)return z(n,{code:S.invalid_type,expected:P.array,received:n.parsedType}),j;if(n.data.length<this._def.items.length)return z(n,{code:S.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;!this._def.rest&&n.data.length>this._def.items.length&&(z(n,{code:S.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new at(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>Pe.mergeArray(r,i)):Pe.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Ct.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ct({items:t,typeName:$.ZodTuple,rest:null,...F(e)})};var js=class t extends V{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.object)return z(n,{code:S.invalid_type,expected:P.object,received:n.parsedType}),j;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new at(n,a,n.path,a)),value:i._parse(new at(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Pe.mergeObjectAsync(r,o):Pe.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof V?new t({keyType:e,valueType:r,typeName:$.ZodRecord,...F(n)}):new t({keyType:dr.create(),valueType:e,typeName:$.ZodRecord,...F(r)})}},zn=class extends V{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.map)return z(n,{code:S.invalid_type,expected:P.map,received:n.parsedType}),j;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new at(n,a,n.path,[u,"key"])),value:s._parse(new at(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return j;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return j;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};zn.create=(t,e,r)=>new zn({valueType:e,keyType:t,typeName:$.ZodMap,...F(r)});var Rn=class t extends V{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.set)return z(n,{code:S.invalid_type,expected:P.set,received:n.parsedType}),j;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(z(n,{code:S.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(z(n,{code:S.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return j;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>s._parse(new at(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:C.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:C.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Rn.create=(t,e)=>new Rn({valueType:t,minSize:null,maxSize:null,typeName:$.ZodSet,...F(e)});var qs=class t extends V{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==P.function)return z(r,{code:S.invalid_type,expected:P.function,received:r.parsedType}),j;function n(a,c){return fo({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xn(),Kt].filter(u=>!!u),issueData:{code:S.invalid_arguments,argumentsError:c}})}function o(a,c){return fo({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xn(),Kt].filter(u=>!!u),issueData:{code:S.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof pr){let a=this;return je(async function(...c){let u=new Ke([]),l=await a._def.args.parseAsync(c,s).catch(m=>{throw u.addIssue(n(c,m)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,s).catch(m=>{throw u.addIssue(o(d,m)),u})})}else{let a=this;return je(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new Ke([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,s);if(!d.success)throw new Ke([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Ct.create(e).rest(Wt.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Ct.create([]).rest(Wt.create()),returns:r||Wt.create(),typeName:$.ZodFunction,...F(n)})}},Hr=class extends V{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Hr.create=(t,e)=>new Hr({getter:t,typeName:$.ZodLazy,...F(e)});var Vr=class extends V{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return z(r,{received:r.data,code:S.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:e.data}}get value(){return this._def.value}};Vr.create=(t,e)=>new Vr({value:t,typeName:$.ZodLiteral,...F(e)});function kp(t,e){return new Br({values:t,typeName:$.ZodEnum,...F(e)})}var Br=class t extends V{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return z(r,{expected:G.joinValues(n),received:r.parsedType,code:S.invalid_type}),j}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return z(r,{received:r.data,code:S.invalid_enum_value,options:n}),j}return je(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Br.create=kp;var Kr=class extends V{_parse(e){let r=G.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==P.string&&n.parsedType!==P.number){let o=G.objectValues(r);return z(n,{expected:G.joinValues(o),received:n.parsedType,code:S.invalid_type}),j}if(this._cache||(this._cache=new Set(G.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=G.objectValues(r);return z(n,{received:n.data,code:S.invalid_enum_value,options:o}),j}return je(e.data)}get enum(){return this._def.values}};Kr.create=(t,e)=>new Kr({values:t,typeName:$.ZodNativeEnum,...F(e)});var pr=class extends V{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==P.promise&&r.common.async===!1)return z(r,{code:S.invalid_type,expected:P.promise,received:r.parsedType}),j;let n=r.parsedType===P.promise?r.data:Promise.resolve(r.data);return je(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};pr.create=(t,e)=>new pr({type:t,typeName:$.ZodPromise,...F(e)});var ct=class extends V{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{z(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return j;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?j:c.status==="dirty"?Ir(c.value):r.value==="dirty"?Ir(c.value):c});{if(r.value==="aborted")return j;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?j:a.status==="dirty"?Ir(a.value):r.value==="dirty"?Ir(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?j:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?j:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!lr(i))return j;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>lr(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):j);G.assertNever(o)}};ct.create=(t,e,r)=>new ct({schema:t,typeName:$.ZodEffects,effect:e,...F(r)});ct.createWithPreprocess=(t,e,r)=>new ct({schema:e,effect:{type:"preprocess",transform:t},typeName:$.ZodEffects,...F(r)});var Je=class extends V{_parse(e){return this._getType(e)===P.undefined?je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Je.create=(t,e)=>new Je({innerType:t,typeName:$.ZodOptional,...F(e)});var Ot=class extends V{_parse(e){return this._getType(e)===P.null?je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ot.create=(t,e)=>new Ot({innerType:t,typeName:$.ZodNullable,...F(e)});var Jr=class extends V{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===P.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Jr.create=(t,e)=>new Jr({innerType:t,typeName:$.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...F(e)});var Wr=class extends V{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return kn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ke(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ke(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Wr.create=(t,e)=>new Wr({innerType:t,typeName:$.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...F(e)});var En=class extends V{_parse(e){if(this._getType(e)!==P.nan){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.nan,received:n.parsedType}),j}return{status:"valid",value:e.data}}};En.create=t=>new En({typeName:$.ZodNaN,...F(t)});var Ew=Symbol("zod_brand"),po=class extends V{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},mo=class t extends V{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?j:s.status==="dirty"?(r.dirty(),Ir(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?j:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:$.ZodPipeline})}},Gr=class extends V{_parse(e){let r=this._def.innerType._parse(e),n=o=>(lr(o)&&(o.value=Object.freeze(o.value)),o);return kn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};Gr.create=(t,e)=>new Gr({innerType:t,typeName:$.ZodReadonly,...F(e)});function vp(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Sp(t,e={},r){return t?fr.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=vp(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=vp(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):fr.create()}var Pw={object:We.lazycreate},$;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})($||($={}));var Aw=(t,e={message:`Input not instance of ${t.name}`})=>Sp(r=>r instanceof t,e),$p=dr.create,Tp=Mr.create,Cw=En.create,Ow=jr.create,zp=qr.create,Nw=Dr.create,Iw=$n.create,Mw=Zr.create,jw=Lr.create,qw=fr.create,Dw=Wt.create,Zw=vt.create,Lw=Tn.create,Uw=Gt.create,Ga=We.create,Fw=We.strictCreate,Hw=Ur.create,Vw=Ms.create,Bw=Fr.create,Kw=Ct.create,Jw=js.create,Ww=zn.create,Gw=Rn.create,Qw=qs.create,Yw=Hr.create,Xw=Vr.create,ex=Br.create,tx=Kr.create,rx=pr.create,nx=ct.create,ox=Je.create,sx=Ot.create,ix=ct.createWithPreprocess,ax=mo.create,cx=()=>$p().optional(),ux=()=>Tp().optional(),lx=()=>zp().optional(),dx={string:(t=>dr.create({...t,coerce:!0})),number:(t=>Mr.create({...t,coerce:!0})),boolean:(t=>qr.create({...t,coerce:!0})),bigint:(t=>jr.create({...t,coerce:!0})),date:(t=>Dr.create({...t,coerce:!0}))};var fx=j;var px=Object.freeze({status:"aborted"});function x(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var Qt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ds={};function nt(t){return t&&Object.assign(Ds,t),Ds}var Q={};Os(Q,{BIGINT_FORMAT_RANGES:()=>Ep,Class:()=>Ya,NUMBER_FORMAT_RANGES:()=>sc,aborted:()=>Yr,allowsEval:()=>rc,assert:()=>_x,assertEqual:()=>mx,assertIs:()=>gx,assertNever:()=>yx,assertNotEqual:()=>hx,assignProp:()=>tc,cached:()=>yo,captureStackTrace:()=>Ls,cleanEnum:()=>Ax,cleanRegex:()=>vo,clone:()=>ot,createTransparentProxy:()=>Sx,defineLazy:()=>le,esc:()=>Qr,escapeRegex:()=>mr,extend:()=>zx,finalizeIssue:()=>bt,floatSafeRemainder:()=>ec,getElementAtPath:()=>vx,getEnumValues:()=>go,getLengthableOrigin:()=>bo,getParsedType:()=>kx,getSizableOrigin:()=>Pp,isObject:()=>Pn,isPlainObject:()=>An,issue:()=>ic,joinValues:()=>Zs,jsonStringifyReplacer:()=>Xa,merge:()=>Rx,normalizeParams:()=>q,nullish:()=>_o,numKeys:()=>xx,omit:()=>Tx,optionalKeys:()=>oc,partial:()=>Ex,pick:()=>$x,prefixIssues:()=>Nt,primitiveTypes:()=>Rp,promiseAllObject:()=>bx,propertyKeyTypes:()=>nc,randomString:()=>wx,required:()=>Px,stringifyPrimitive:()=>Us,unwrapMessage:()=>ho});function mx(t){return t}function hx(t){return t}function gx(t){}function yx(t){throw new Error}function _x(t){}function go(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function Zs(t,e="|"){return t.map(r=>Us(r)).join(e)}function Xa(t,e){return typeof e=="bigint"?e.toString():e}function yo(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function _o(t){return t==null}function vo(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function ec(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}function le(t,e,r){Object.defineProperty(t,e,{get(){{let o=r();return t[e]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function tc(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function vx(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function bx(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function wx(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Qr(t){return JSON.stringify(t)}var Ls=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Pn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var rc=yo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function An(t){if(Pn(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Pn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function xx(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var kx=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},nc=new Set(["string","number","symbol"]),Rp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function mr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ot(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function q(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Sx(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function Us(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function oc(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var sc={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ep={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function $x(t,e){let r={},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(r[o]=n.shape[o])}return ot(t,{...t._zod.def,shape:r,checks:[]})}function Tx(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&delete r[o]}return ot(t,{...t._zod.def,shape:r,checks:[]})}function zx(t,e){if(!An(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return tc(this,"shape",n),n},checks:[]};return ot(t,r)}function Rx(t,e){return ot(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return tc(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function Ex(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=t?new t({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=t?new t({type:"optional",innerType:n[s]}):n[s];return ot(e,{...e._zod.def,shape:o,checks:[]})}function Px(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new t({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new t({type:"nonoptional",innerType:n[s]});return ot(e,{...e._zod.def,shape:o,checks:[]})}function Yr(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Nt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function ho(t){return typeof t=="string"?t:t?.message}function bt(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=ho(t.inst?._zod.def?.error?.(t))??ho(e?.error?.(t))??ho(r.customError?.(t))??ho(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Pp(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function bo(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function ic(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function Ax(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var Ya=class{constructor(...e){}};var Ap=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,Xa,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Fs=x("$ZodError",Ap),wo=x("$ZodError",Ap,{Parent:Error});function ac(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function cc(t,e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(t),n}var uc=t=>(e,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new Qt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>bt(c,s,nt())));throw Ls(a,o?.callee),a}return i.value},lc=uc(wo),dc=t=>async(e,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>bt(c,s,nt())));throw Ls(a,o?.callee),a}return i.value},fc=dc(wo),pc=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Qt;return s.issues.length?{success:!1,error:new(t??Fs)(s.issues.map(i=>bt(i,o,nt())))}:{success:!0,data:s.value}},Xr=pc(wo),mc=t=>async(e,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>bt(i,o,nt())))}:{success:!0,data:s.value}},en=mc(wo);var Cp=/^[cC][^\s-]{8,}$/,Op=/^[0-9a-z]+$/,Np=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ip=/^[0-9a-vA-V]{20}$/,Mp=/^[A-Za-z0-9]{27}$/,jp=/^[a-zA-Z0-9_-]{21}$/,qp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Dp=/^([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})$/,hc=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/;var Zp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Ox="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Lp(){return new RegExp(Ox,"u")}var Up=/^(?:(?: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])$/,Fp=/^(([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})$/,Hp=/^((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])$/,Vp=/^(([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])$/,Bp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,gc=/^[A-Za-z0-9_-]*$/,Kp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Jp=/^\+(?:[0-9]){6,14}[0-9]$/,Wp="(?:(?:\\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])))",Gp=new RegExp(`^${Wp}$`);function Qp(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Yp(t){return new RegExp(`^${Qp(t)}$`)}function Xp(t){let e=Qp({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Wp}T(?:${n})$`)}var em=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var tm=/^\d+$/,rm=/^-?\d+(?:\.\d+)?/i,nm=/true|false/i,om=/null/i;var sm=/^[^A-Z]*$/,im=/^[^a-z]*$/;var Ae=x("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),am={number:"number",bigint:"bigint",object:"date"},yc=x("$ZodCheckLessThan",(t,e)=>{Ae.init(t,e);let r=am[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),_c=x("$ZodCheckGreaterThan",(t,e)=>{Ae.init(t,e);let r=am[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),cm=x("$ZodCheckMultipleOf",(t,e)=>{Ae.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):ec(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),um=x("$ZodCheckNumberFormat",(t,e)=>{Ae.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=sc[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=tm)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:t})}});var lm=x("$ZodCheckMaxLength",(t,e)=>{var r;Ae.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!_o(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=bo(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),dm=x("$ZodCheckMinLength",(t,e)=>{var r;Ae.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!_o(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=bo(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),fm=x("$ZodCheckLengthEquals",(t,e)=>{var r;Ae.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!_o(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=bo(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),xo=x("$ZodCheckStringFormat",(t,e)=>{var r,n;Ae.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),pm=x("$ZodCheckRegex",(t,e)=>{xo.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),mm=x("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=sm),xo.init(t,e)}),hm=x("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=im),xo.init(t,e)}),gm=x("$ZodCheckIncludes",(t,e)=>{Ae.init(t,e);let r=mr(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),ym=x("$ZodCheckStartsWith",(t,e)=>{Ae.init(t,e);let r=new RegExp(`^${mr(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),_m=x("$ZodCheckEndsWith",(t,e)=>{Ae.init(t,e);let r=new RegExp(`.*${mr(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var vm=x("$ZodCheckOverwrite",(t,e)=>{Ae.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var Vs=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
8
|
+
deps: ${r}}`};var wE={keyword:"dependencies",type:"object",schemaType:"object",error:qt.error,code(t){let[e,r]=xE(t);i_(t,e),a_(t,r)}};function xE({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function i_(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,fs.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,fs.checkReportMissingProp)(t,u)}):(r.if((0,Jd._)`${c} && (${(0,fs.checkMissingProp)(t,a,s)})`),(0,fs.reportMissingProp)(t,s),r.else())}}qt.validatePropertyDeps=i_;function a_(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,bE.alwaysValidSchema)(s,e[a])||(r.if((0,fs.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}qt.validateSchemaDeps=a_;qt.default=wE});var l_=E(Wd=>{"use strict";Object.defineProperty(Wd,"__esModule",{value:!0});var u_=B(),kE=ne(),SE={message:"property name must be valid",params:({params:t})=>(0,u_._)`{propertyName: ${t.propertyName}}`},$E={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:SE,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,kE.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,u_.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Wd.default=$E});var Qd=E(Gd=>{"use strict";Object.defineProperty(Gd,"__esModule",{value:!0});var ua=pt(),Tt=B(),TE=tr(),la=ne(),zE={message:"must NOT have additional properties",params:({params:t})=>(0,Tt._)`{additionalProperty: ${t.additionalProperty}}`},RE={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:zE,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,la.alwaysValidSchema)(i,r))return;let u=(0,ua.allSchemaProperties)(n.properties),l=(0,ua.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Tt._)`${s} === ${TE.default.errors}`);function d(){e.forIn("key",o,g=>{!u.length&&!l.length?f(g):e.if(p(g),()=>f(g))})}function p(g){let y;if(u.length>8){let b=(0,la.schemaRefOrVal)(i,n.properties,"properties");y=(0,ua.isOwnProperty)(e,b,g)}else u.length?y=(0,Tt.or)(...u.map(b=>(0,Tt._)`${g} === ${b}`)):y=Tt.nil;return l.length&&(y=(0,Tt.or)(y,...l.map(b=>(0,Tt._)`${(0,ua.usePattern)(t,b)}.test(${g})`))),(0,Tt.not)(y)}function m(g){e.code((0,Tt._)`delete ${o}[${g}]`)}function f(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,la.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),e.if((0,Tt.not)(y),()=>{t.reset(),m(g)})):(h(g,y),a||e.if((0,Tt.not)(y),()=>e.break()))}}function h(g,y,b){let k={keyword:"additionalProperties",dataProp:g,dataPropType:la.Type.Str};b===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(k,y)}}};Gd.default=RE});var p_=E(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});var EE=Yo(),d_=pt(),Yd=ne(),f_=Qd(),PE={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&f_.default.code(new EE.KeywordCxt(s,f_.default,"additionalProperties"));let i=(0,d_.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Yd.mergeEvaluated.props(e,(0,Yd.toHash)(i),s.props));let a=i.filter(d=>!(0,Yd.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,d_.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Xd.default=PE});var y_=E(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});var m_=pt(),da=B(),h_=ne(),g_=ne(),AE={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,m_.allSchemaProperties)(r),c=a.filter(h=>(0,h_.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof da.Name)&&(s.props=(0,g_.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let h of a)u&&m(h),s.allErrors?f(h):(e.var(l,!0),f(h),e.if(l))}function m(h){for(let g in u)new RegExp(h).test(g)&&(0,h_.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function f(h){e.forIn("key",n,g=>{e.if((0,da._)`${(0,m_.usePattern)(t,h)}.test(${g})`,()=>{let y=c.includes(h);y||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:g_.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,da._)`${d}[${g}]`,!0):!y&&!s.allErrors&&e.if((0,da.not)(l),()=>e.break())})})}}};ef.default=AE});var __=E(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var CE=ne(),OE={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,CE.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};tf.default=OE});var v_=E(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});var NE=pt(),IE={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:NE.validateUnion,error:{message:"must match a schema in anyOf"}};rf.default=IE});var b_=E(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});var fa=B(),ME=ne(),jE={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,fa._)`{passingSchemas: ${t.passing}}`},qE={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:jE,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let p;(0,ME.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,fa._)`${c} && ${i}`).assign(i,!1).assign(a,(0,fa._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,fa.Name)})})}}};nf.default=qE});var w_=E(of=>{"use strict";Object.defineProperty(of,"__esModule",{value:!0});var DE=ne(),ZE={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,DE.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};of.default=ZE});var S_=E(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});var pa=B(),k_=ne(),LE={message:({params:t})=>(0,pa.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,pa._)`{failingKeyword: ${t.ifClause}}`},UE={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:LE,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,k_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=x_(n,"then"),s=x_(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,pa.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,pa._)`${l}`):t.setParams({ifClause:l})}}}};function x_(t,e){let r=t.schema[e];return r!==void 0&&!(0,k_.alwaysValidSchema)(t,r)}sf.default=UE});var $_=E(af=>{"use strict";Object.defineProperty(af,"__esModule",{value:!0});var FE=ne(),HE={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,FE.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};af.default=HE});var T_=E(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});var VE=Fd(),BE=r_(),KE=Hd(),JE=o_(),WE=s_(),GE=c_(),QE=l_(),YE=Qd(),XE=p_(),eP=y_(),tP=__(),rP=v_(),nP=b_(),oP=w_(),sP=S_(),iP=$_();function aP(t=!1){let e=[tP.default,rP.default,nP.default,oP.default,sP.default,iP.default,QE.default,YE.default,GE.default,XE.default,eP.default];return t?e.push(BE.default,JE.default):e.push(VE.default,KE.default),e.push(WE.default),e}cf.default=aP});var z_=E(uf=>{"use strict";Object.defineProperty(uf,"__esModule",{value:!0});var $e=B(),cP={message:({schemaCode:t})=>(0,$e.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,$e._)`{format: ${t}}`},uP={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:cP,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():m();function p(){let f=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,$e._)`${f}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,$e._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,$e._)`${h}.type || "string"`).assign(y,(0,$e._)`${h}.validate`),()=>r.assign(g,(0,$e._)`"string"`).assign(y,h)),t.fail$data((0,$e.or)(b(),k()));function b(){return c.strictSchema===!1?$e.nil:(0,$e._)`${i} && !${y}`}function k(){let T=l.$async?(0,$e._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,$e._)`${y}(${n})`,R=(0,$e._)`(typeof ${y} == "function" ? ${T} : ${y}.test(${n}))`;return(0,$e._)`${y} && ${y} !== true && ${g} === ${e} && !${R}`}}function m(){let f=d.formats[s];if(!f){b();return}if(f===!0)return;let[h,g,y]=k(f);h===e&&t.pass(T());function b(){if(c.strictSchema===!1){d.logger.warn(R());return}throw new Error(R());function R(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function k(R){let me=R instanceof RegExp?(0,$e.regexpCode)(R):c.code.formats?(0,$e._)`${c.code.formats}${(0,$e.getProperty)(s)}`:void 0,ie=r.scopeValue("formats",{key:s,ref:R,code:me});return typeof R=="object"&&!(R instanceof RegExp)?[R.type||"string",R.validate,(0,$e._)`${ie}.validate`]:["string",R,ie]}function T(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!l.$async)throw new Error("async format in sync schema");return(0,$e._)`await ${y}(${n})`}return typeof g=="function"?(0,$e._)`${y}(${n})`:(0,$e._)`${y}.test(${n})`}}}};uf.default=uP});var R_=E(lf=>{"use strict";Object.defineProperty(lf,"__esModule",{value:!0});var lP=z_(),dP=[lP.default];lf.default=dP});var E_=E(Qn=>{"use strict";Object.defineProperty(Qn,"__esModule",{value:!0});Qn.contentVocabulary=Qn.metadataVocabulary=void 0;Qn.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Qn.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var A_=E(df=>{"use strict";Object.defineProperty(df,"__esModule",{value:!0});var fP=qy(),pP=Yy(),mP=T_(),hP=R_(),P_=E_(),gP=[fP.default,pP.default,(0,mP.default)(),hP.default,P_.metadataVocabulary,P_.contentVocabulary];df.default=gP});var O_=E(ma=>{"use strict";Object.defineProperty(ma,"__esModule",{value:!0});ma.DiscrError=void 0;var C_;(function(t){t.Tag="tag",t.Mapping="mapping"})(C_||(ma.DiscrError=C_={}))});var I_=E(pf=>{"use strict";Object.defineProperty(pf,"__esModule",{value:!0});var Yn=B(),ff=O_(),N_=Wi(),yP=Xo(),_P=ne(),vP={message:({params:{discrError:t,tagName:e}})=>t===ff.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Yn._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},bP={keyword:"discriminator",type:"object",schemaType:"object",error:vP,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,Yn._)`${r}${(0,Yn.getProperty)(a)}`);e.if((0,Yn._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:ff.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=p();e.if(!1);for(let f in m)e.elseIf((0,Yn._)`${u} === ${f}`),e.assign(c,d(m[f]));e.else(),t.error(!1,{discrError:ff.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let f=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:m},f);return t.mergeEvaluated(h,Yn.Name),f}function p(){var m;let f={},h=y(o),g=!0;for(let T=0;T<i.length;T++){let R=i[T];if(R?.$ref&&!(0,_P.schemaHasRulesButRef)(R,s.self.RULES)){let ie=R.$ref;if(R=N_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,ie),R instanceof N_.SchemaEnv&&(R=R.schema),R===void 0)throw new yP.default(s.opts.uriResolver,s.baseId,ie)}let me=(m=R?.properties)===null||m===void 0?void 0:m[a];if(typeof me!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(R)),b(me,T)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return f;function y({required:T}){return Array.isArray(T)&&T.includes(a)}function b(T,R){if(T.const)k(T.const,R);else if(T.enum)for(let me of T.enum)k(me,R);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function k(T,R){if(typeof T!="string"||T in f)throw new Error(`discriminator: "${a}" values must be unique strings`);f[T]=R}}}};pf.default=bP});var M_=E((oD,wP)=>{wP.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var hf=E((ge,mf)=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.MissingRefError=ge.ValidationError=ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=ge.Ajv=void 0;var xP=Cy(),kP=A_(),SP=I_(),j_=M_(),$P=["/properties"],ha="http://json-schema.org/draft-07/schema",Xn=class extends xP.default{_addVocabularies(){super._addVocabularies(),kP.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(SP.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(j_,$P):j_;this.addMetaSchema(e,ha,!1),this.refs["http://json-schema.org/schema"]=ha}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ha)?ha:void 0)}};ge.Ajv=Xn;mf.exports=ge=Xn;mf.exports.Ajv=Xn;Object.defineProperty(ge,"__esModule",{value:!0});ge.default=Xn;var TP=Yo();Object.defineProperty(ge,"KeywordCxt",{enumerable:!0,get:function(){return TP.KeywordCxt}});var eo=B();Object.defineProperty(ge,"_",{enumerable:!0,get:function(){return eo._}});Object.defineProperty(ge,"str",{enumerable:!0,get:function(){return eo.str}});Object.defineProperty(ge,"stringify",{enumerable:!0,get:function(){return eo.stringify}});Object.defineProperty(ge,"nil",{enumerable:!0,get:function(){return eo.nil}});Object.defineProperty(ge,"Name",{enumerable:!0,get:function(){return eo.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:!0,get:function(){return eo.CodeGen}});var zP=Ki();Object.defineProperty(ge,"ValidationError",{enumerable:!0,get:function(){return zP.default}});var RP=Xo();Object.defineProperty(ge,"MissingRefError",{enumerable:!0,get:function(){return RP.default}})});var V_=E(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Zt.formatNames=Zt.fastFormats=Zt.fullFormats=void 0;function Dt(t,e){return{validate:t,compare:e}}Zt.fullFormats={date:Dt(L_,vf),time:Dt(yf(!0),bf),"date-time":Dt(q_(!0),F_),"iso-time":Dt(yf(),U_),"iso-date-time":Dt(q_(),H_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:NP,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:LP,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:IP,int32:{type:"number",validate:qP},int64:{type:"number",validate:DP},float:{type:"number",validate:Z_},double:{type:"number",validate:Z_},password:!0,binary:!0};Zt.fastFormats={...Zt.fullFormats,date:Dt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,vf),time:Dt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,bf),"date-time":Dt(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,F_),"iso-time":Dt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,U_),"iso-date-time":Dt(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,H_),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};Zt.formatNames=Object.keys(Zt.fullFormats);function EP(t){return t%4===0&&(t%100!==0||t%400===0)}var PP=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,AP=[0,31,28,31,30,31,30,31,31,30,31,30,31];function L_(t){let e=PP.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&EP(r)?29:AP[n])}function vf(t,e){if(t&&e)return t>e?1:t<e?-1:0}var gf=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function yf(t){return function(r){let n=gf.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function bf(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function U_(t,e){if(!(t&&e))return;let r=gf.exec(t),n=gf.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var _f=/t|\s/i;function q_(t){let e=yf(t);return function(n){let o=n.split(_f);return o.length===2&&L_(o[0])&&e(o[1])}}function F_(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function H_(t,e){if(!(t&&e))return;let[r,n]=t.split(_f),[o,s]=e.split(_f),i=vf(r,o);if(i!==void 0)return i||bf(n,s)}var CP=/\/|:/,OP=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function NP(t){return CP.test(t)&&OP.test(t)}var D_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function IP(t){return D_.lastIndex=0,D_.test(t)}var MP=-(2**31),jP=2**31-1;function qP(t){return Number.isInteger(t)&&t<=jP&&t>=MP}function DP(t){return Number.isInteger(t)}function Z_(){return!0}var ZP=/[^\\]\\Z/;function LP(t){if(ZP.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var B_=E(to=>{"use strict";Object.defineProperty(to,"__esModule",{value:!0});to.formatLimitDefinition=void 0;var UP=hf(),zt=B(),Rr=zt.operators,ga={formatMaximum:{okStr:"<=",ok:Rr.LTE,fail:Rr.GT},formatMinimum:{okStr:">=",ok:Rr.GTE,fail:Rr.LT},formatExclusiveMaximum:{okStr:"<",ok:Rr.LT,fail:Rr.GTE},formatExclusiveMinimum:{okStr:">",ok:Rr.GT,fail:Rr.LTE}},FP={message:({keyword:t,schemaCode:e})=>(0,zt.str)`should be ${ga[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,zt._)`{comparison: ${ga[t].okStr}, limit: ${e}}`};to.formatLimitDefinition={keyword:Object.keys(ga),type:"string",schemaType:"string",$data:!0,error:FP,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new UP.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,zt._)`${p}[${c.schemaCode}]`);t.fail$data((0,zt.or)((0,zt._)`typeof ${m} != "object"`,(0,zt._)`${m} instanceof RegExp`,(0,zt._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let p=c.schema,m=a.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let f=e.scopeValue("formats",{key:p,ref:m,code:i.code.formats?(0,zt._)`${i.code.formats}${(0,zt.getProperty)(p)}`:void 0});t.fail$data(d(f))}function d(p){return(0,zt._)`${p}.compare(${r}, ${n}) ${ga[o].fail} 0`}},dependencies:["format"]};var HP=t=>(t.addKeyword(to.formatLimitDefinition),t);to.default=HP});var G_=E((ps,W_)=>{"use strict";Object.defineProperty(ps,"__esModule",{value:!0});var ro=V_(),VP=B_(),wf=B(),K_=new wf.Name("fullFormats"),BP=new wf.Name("fastFormats"),xf=(t,e={keywords:!0})=>{if(Array.isArray(e))return J_(t,e,ro.fullFormats,K_),t;let[r,n]=e.mode==="fast"?[ro.fastFormats,BP]:[ro.fullFormats,K_],o=e.formats||ro.formatNames;return J_(t,o,r,n),e.keywords&&(0,VP.default)(t),t};xf.get=(t,e="full")=>{let n=(e==="fast"?ro.fastFormats:ro.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function J_(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,wf._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}W_.exports=ps=xf;Object.defineProperty(ps,"__esModule",{value:!0});ps.default=xf});var v={};Os(v,{BRAND:()=>Ow,DIRTY:()=>Ir,EMPTY_PATH:()=>dw,INVALID:()=>j,NEVER:()=>gx,OK:()=>je,ParseStatus:()=>Pe,Schema:()=>V,ZodAny:()=>fr,ZodArray:()=>Gt,ZodBigInt:()=>jr,ZodBoolean:()=>qr,ZodBranded:()=>po,ZodCatch:()=>Wr,ZodDate:()=>Dr,ZodDefault:()=>Jr,ZodDiscriminatedUnion:()=>Ms,ZodEffects:()=>ct,ZodEnum:()=>Br,ZodError:()=>Ke,ZodFirstPartyTypeKind:()=>$,ZodFunction:()=>qs,ZodIntersection:()=>Fr,ZodIssueCode:()=>S,ZodLazy:()=>Hr,ZodLiteral:()=>Vr,ZodMap:()=>zn,ZodNaN:()=>En,ZodNativeEnum:()=>Kr,ZodNever:()=>vt,ZodNull:()=>Lr,ZodNullable:()=>Ot,ZodNumber:()=>Mr,ZodObject:()=>We,ZodOptional:()=>Je,ZodParsedType:()=>P,ZodPipeline:()=>mo,ZodPromise:()=>pr,ZodReadonly:()=>Gr,ZodRecord:()=>js,ZodSchema:()=>V,ZodSet:()=>Rn,ZodString:()=>dr,ZodSymbol:()=>$n,ZodTransformer:()=>ct,ZodTuple:()=>Ct,ZodType:()=>V,ZodUndefined:()=>Zr,ZodUnion:()=>Ur,ZodUnknown:()=>Wt,ZodVoid:()=>Tn,addIssueToContext:()=>z,any:()=>Uw,array:()=>Bw,bigint:()=>jw,boolean:()=>Pp,coerce:()=>hx,custom:()=>zp,date:()=>qw,datetimeRegex:()=>$p,defaultErrorMap:()=>Kt,discriminatedUnion:()=>Ww,effect:()=>ax,enum:()=>ox,function:()=>tx,getErrorMap:()=>xn,getParsedType:()=>At,instanceof:()=>Iw,intersection:()=>Gw,isAborted:()=>Ns,isAsync:()=>kn,isDirty:()=>Is,isValid:()=>lr,late:()=>Nw,lazy:()=>rx,literal:()=>nx,makeIssue:()=>fo,map:()=>Xw,nan:()=>Mw,nativeEnum:()=>sx,never:()=>Hw,null:()=>Lw,nullable:()=>ux,number:()=>Ep,object:()=>Ya,objectUtil:()=>Wa,oboolean:()=>mx,onumber:()=>px,optional:()=>cx,ostring:()=>fx,pipeline:()=>dx,preprocess:()=>lx,promise:()=>ix,quotelessJson:()=>cw,record:()=>Yw,set:()=>ex,setErrorMap:()=>lw,strictObject:()=>Kw,string:()=>Rp,symbol:()=>Dw,transformer:()=>ax,tuple:()=>Qw,undefined:()=>Zw,union:()=>Jw,unknown:()=>Fw,util:()=>G,void:()=>Vw});var G;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(G||(G={}));var Wa;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Wa||(Wa={}));var P=G.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),At=t=>{switch(typeof t){case"undefined":return P.undefined;case"string":return P.string;case"number":return Number.isNaN(t)?P.nan:P.number;case"boolean":return P.boolean;case"function":return P.function;case"bigint":return P.bigint;case"symbol":return P.symbol;case"object":return Array.isArray(t)?P.array:t===null?P.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?P.promise:typeof Map<"u"&&t instanceof Map?P.map:typeof Set<"u"&&t instanceof Set?P.set:typeof Date<"u"&&t instanceof Date?P.date:P.object;default:return P.unknown}};var S=G.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),cw=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ke=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,G.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ke.create=t=>new Ke(t);var uw=(t,e)=>{let r;switch(t.code){case S.invalid_type:t.received===P.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case S.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,G.jsonStringifyReplacer)}`;break;case S.unrecognized_keys:r=`Unrecognized key(s) in object: ${G.joinValues(t.keys,", ")}`;break;case S.invalid_union:r="Invalid input";break;case S.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${G.joinValues(t.options)}`;break;case S.invalid_enum_value:r=`Invalid enum value. Expected ${G.joinValues(t.options)}, received '${t.received}'`;break;case S.invalid_arguments:r="Invalid function arguments";break;case S.invalid_return_type:r="Invalid function return type";break;case S.invalid_date:r="Invalid date";break;case S.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:G.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case S.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case S.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case S.custom:r="Invalid input";break;case S.invalid_intersection_types:r="Intersection results could not be merged";break;case S.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case S.not_finite:r="Number must be finite";break;default:r=e.defaultError,G.assertNever(t)}return{message:r}},Kt=uw;var bp=Kt;function lw(t){bp=t}function xn(){return bp}var fo=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},dw=[];function z(t,e){let r=xn(),n=fo({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Kt?void 0:Kt].filter(o=>!!o)});t.common.issues.push(n)}var Pe=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return j;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,i=await o.value;n.push({key:s,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return j;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}},j=Object.freeze({status:"aborted"}),Ir=t=>({status:"dirty",value:t}),je=t=>({status:"valid",value:t}),Ns=t=>t.status==="aborted",Is=t=>t.status==="dirty",lr=t=>t.status==="valid",kn=t=>typeof Promise<"u"&&t instanceof Promise;var C;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(C||(C={}));var at=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},wp=(t,e)=>{if(lr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Ke(t.common.issues);return this._error=r,this._error}}};function F(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}var V=class{get description(){return this._def.description}_getType(e){return At(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Pe,ctx:{common:e.parent.common,data:e.data,parsedType:At(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(kn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},o=this._parseSync({data:e,path:n.path,parent:n});return wp(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return lr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>lr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:At(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(kn(o)?o:Promise.resolve(o));return wp(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:S.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new ct({schema:this,typeName:$.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Je.create(this,this._def)}nullable(){return Ot.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Gt.create(this)}promise(){return pr.create(this,this._def)}or(e){return Ur.create([this,e],this._def)}and(e){return Fr.create(this,e,this._def)}transform(e){return new ct({...F(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Jr({...F(this._def),innerType:this,defaultValue:r,typeName:$.ZodDefault})}brand(){return new po({typeName:$.ZodBranded,type:this,...F(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Wr({...F(this._def),innerType:this,catchValue:r,typeName:$.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return mo.create(this,e)}readonly(){return Gr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},fw=/^c[^\s-]{8,}$/i,pw=/^[0-9a-z]+$/,mw=/^[0-9A-HJKMNP-TV-Z]{26}$/i,hw=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,gw=/^[a-z0-9_-]{21}$/i,yw=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_w=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,vw=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bw="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ga,ww=/^(?:(?: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])$/,xw=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,kw=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Sw=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$w=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Tw=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,kp="((\\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])))",zw=new RegExp(`^${kp}$`);function Sp(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Rw(t){return new RegExp(`^${Sp(t)}$`)}function $p(t){let e=`${kp}T${Sp(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Ew(t,e){return!!((e==="v4"||!e)&&ww.test(t)||(e==="v6"||!e)&&kw.test(t))}function Pw(t,e){if(!yw.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function Aw(t,e){return!!((e==="v4"||!e)&&xw.test(t)||(e==="v6"||!e)&&Sw.test(t))}var dr=class t extends V{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==P.string){let s=this._getOrReturnCtx(e);return z(s,{code:S.invalid_type,expected:P.string,received:s.parsedType}),j}let n=new Pe,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),z(o,{code:S.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),z(o,{code:S.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?z(o,{code:S.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&z(o,{code:S.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")vw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"email",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Ga||(Ga=new RegExp(bw,"u")),Ga.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"emoji",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")hw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"uuid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")gw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"nanoid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")fw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"cuid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")pw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"cuid2",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")mw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"ulid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),z(o,{validation:"url",code:S.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"regex",code:S.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?$p(s).test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?zw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Rw(s).test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{code:S.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?_w.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"duration",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Ew(e.data,s.version)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"ip",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?Pw(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"jwt",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?Aw(e.data,s.version)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"cidr",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?$w.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"base64",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?Tw.test(e.data)||(o=this._getOrReturnCtx(e,o),z(o,{validation:"base64url",code:S.invalid_string,message:s.message}),n.dirty()):G.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:S.invalid_string,...C.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...C.errToObj(e)})}url(e){return this._addCheck({kind:"url",...C.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...C.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...C.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...C.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...C.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...C.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...C.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...C.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...C.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...C.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...C.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...C.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...C.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...C.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...C.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...C.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...C.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...C.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...C.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...C.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...C.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...C.errToObj(r)})}nonempty(e){return this.min(1,C.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};dr.create=t=>new dr({checks:[],typeName:$.ZodString,coerce:t?.coerce??!1,...F(t)});function Cw(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var Mr=class t extends V{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==P.number){let s=this._getOrReturnCtx(e);return z(s,{code:S.invalid_type,expected:P.number,received:s.parsedType}),j}let n,o=new Pe;for(let s of this._def.checks)s.kind==="int"?G.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:S.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?Cw(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),z(n,{code:S.not_finite,message:s.message}),o.dirty()):G.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,C.toString(r))}gt(e,r){return this.setLimit("min",e,!1,C.toString(r))}lte(e,r){return this.setLimit("max",e,!0,C.toString(r))}lt(e,r){return this.setLimit("max",e,!1,C.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:C.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:C.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:C.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:C.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:C.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:C.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&G.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};Mr.create=t=>new Mr({checks:[],typeName:$.ZodNumber,coerce:t?.coerce||!1,...F(t)});var jr=class t extends V{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==P.bigint)return this._getInvalidInput(e);let n,o=new Pe;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),z(n,{code:S.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):G.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return z(r,{code:S.invalid_type,expected:P.bigint,received:r.parsedType}),j}gte(e,r){return this.setLimit("min",e,!0,C.toString(r))}gt(e,r){return this.setLimit("min",e,!1,C.toString(r))}lte(e,r){return this.setLimit("max",e,!0,C.toString(r))}lt(e,r){return this.setLimit("max",e,!1,C.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:C.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:C.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};jr.create=t=>new jr({checks:[],typeName:$.ZodBigInt,coerce:t?.coerce??!1,...F(t)});var qr=class extends V{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==P.boolean){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.boolean,received:n.parsedType}),j}return je(e.data)}};qr.create=t=>new qr({typeName:$.ZodBoolean,coerce:t?.coerce||!1,...F(t)});var Dr=class t extends V{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==P.date){let s=this._getOrReturnCtx(e);return z(s,{code:S.invalid_type,expected:P.date,received:s.parsedType}),j}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return z(s,{code:S.invalid_date}),j}let n=new Pe,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),z(o,{code:S.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),z(o,{code:S.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):G.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:C.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:C.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};Dr.create=t=>new Dr({checks:[],coerce:t?.coerce||!1,typeName:$.ZodDate,...F(t)});var $n=class extends V{_parse(e){if(this._getType(e)!==P.symbol){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.symbol,received:n.parsedType}),j}return je(e.data)}};$n.create=t=>new $n({typeName:$.ZodSymbol,...F(t)});var Zr=class extends V{_parse(e){if(this._getType(e)!==P.undefined){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.undefined,received:n.parsedType}),j}return je(e.data)}};Zr.create=t=>new Zr({typeName:$.ZodUndefined,...F(t)});var Lr=class extends V{_parse(e){if(this._getType(e)!==P.null){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.null,received:n.parsedType}),j}return je(e.data)}};Lr.create=t=>new Lr({typeName:$.ZodNull,...F(t)});var fr=class extends V{constructor(){super(...arguments),this._any=!0}_parse(e){return je(e.data)}};fr.create=t=>new fr({typeName:$.ZodAny,...F(t)});var Wt=class extends V{constructor(){super(...arguments),this._unknown=!0}_parse(e){return je(e.data)}};Wt.create=t=>new Wt({typeName:$.ZodUnknown,...F(t)});var vt=class extends V{_parse(e){let r=this._getOrReturnCtx(e);return z(r,{code:S.invalid_type,expected:P.never,received:r.parsedType}),j}};vt.create=t=>new vt({typeName:$.ZodNever,...F(t)});var Tn=class extends V{_parse(e){if(this._getType(e)!==P.undefined){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.void,received:n.parsedType}),j}return je(e.data)}};Tn.create=t=>new Tn({typeName:$.ZodVoid,...F(t)});var Gt=class t extends V{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==P.array)return z(r,{code:S.invalid_type,expected:P.array,received:r.parsedType}),j;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&(z(r,{code:i?S.too_big:S.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(z(r,{code:S.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(z(r,{code:S.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>o.type._parseAsync(new at(r,i,r.path,a)))).then(i=>Pe.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new at(r,i,r.path,a)));return Pe.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:C.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:C.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:C.toString(r)}})}nonempty(e){return this.min(1,e)}};Gt.create=(t,e)=>new Gt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...F(e)});function Sn(t){if(t instanceof We){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Je.create(Sn(n))}return new We({...t._def,shape:()=>e})}else return t instanceof Gt?new Gt({...t._def,type:Sn(t.element)}):t instanceof Je?Je.create(Sn(t.unwrap())):t instanceof Ot?Ot.create(Sn(t.unwrap())):t instanceof Ct?Ct.create(t.items.map(e=>Sn(e))):t}var We=class t extends V{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=G.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==P.object){let u=this._getOrReturnCtx(e);return z(u,{code:S.invalid_type,expected:P.object,received:u.parsedType}),j}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof vt&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let l=s[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new at(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof vt){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&(z(o,{code:S.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new at(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>Pe.mergeObjectSync(n,u)):Pe.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return C.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:C.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of G.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of G.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Sn(this)}partial(e){let r={};for(let n of G.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of G.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Je;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return Tp(G.objectKeys(this.shape))}};We.create=(t,e)=>new We({shape:()=>t,unknownKeys:"strip",catchall:vt.create(),typeName:$.ZodObject,...F(e)});We.strictCreate=(t,e)=>new We({shape:()=>t,unknownKeys:"strict",catchall:vt.create(),typeName:$.ZodObject,...F(e)});We.lazycreate=(t,e)=>new We({shape:t,unknownKeys:"strip",catchall:vt.create(),typeName:$.ZodObject,...F(e)});var Ur=class extends V{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new Ke(a.ctx.common.issues));return z(r,{code:S.invalid_union,unionErrors:i}),j}if(r.common.async)return Promise.all(n.map(async s=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!s&&(s={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new Ke(c));return z(r,{code:S.invalid_union,unionErrors:a}),j}}get options(){return this._def.options}};Ur.create=(t,e)=>new Ur({options:t,typeName:$.ZodUnion,...F(e)});var Jt=t=>t instanceof Hr?Jt(t.schema):t instanceof ct?Jt(t.innerType()):t instanceof Vr?[t.value]:t instanceof Br?t.options:t instanceof Kr?G.objectValues(t.enum):t instanceof Jr?Jt(t._def.innerType):t instanceof Zr?[void 0]:t instanceof Lr?[null]:t instanceof Je?[void 0,...Jt(t.unwrap())]:t instanceof Ot?[null,...Jt(t.unwrap())]:t instanceof po||t instanceof Gr?Jt(t.unwrap()):t instanceof Wr?Jt(t._def.innerType):[],Ms=class t extends V{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==P.object)return z(r,{code:S.invalid_type,expected:P.object,received:r.parsedType}),j;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(z(r,{code:S.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),j)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let i=Jt(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...F(n)})}};function Qa(t,e){let r=At(t),n=At(e);if(t===e)return{valid:!0,data:t};if(r===P.object&&n===P.object){let o=G.objectKeys(e),s=G.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=Qa(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===P.array&&n===P.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=Qa(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===P.date&&n===P.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Fr=class extends V{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(Ns(s)||Ns(i))return j;let a=Qa(s.value,i.value);return a.valid?((Is(s)||Is(i))&&r.dirty(),{status:r.value,value:a.data}):(z(n,{code:S.invalid_intersection_types}),j)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Fr.create=(t,e,r)=>new Fr({left:t,right:e,typeName:$.ZodIntersection,...F(r)});var Ct=class t extends V{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.array)return z(n,{code:S.invalid_type,expected:P.array,received:n.parsedType}),j;if(n.data.length<this._def.items.length)return z(n,{code:S.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;!this._def.rest&&n.data.length>this._def.items.length&&(z(n,{code:S.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new at(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>Pe.mergeArray(r,i)):Pe.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Ct.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ct({items:t,typeName:$.ZodTuple,rest:null,...F(e)})};var js=class t extends V{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.object)return z(n,{code:S.invalid_type,expected:P.object,received:n.parsedType}),j;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new at(n,a,n.path,a)),value:i._parse(new at(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Pe.mergeObjectAsync(r,o):Pe.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof V?new t({keyType:e,valueType:r,typeName:$.ZodRecord,...F(n)}):new t({keyType:dr.create(),valueType:e,typeName:$.ZodRecord,...F(r)})}},zn=class extends V{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.map)return z(n,{code:S.invalid_type,expected:P.map,received:n.parsedType}),j;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new at(n,a,n.path,[u,"key"])),value:s._parse(new at(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return j;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return j;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};zn.create=(t,e,r)=>new zn({valueType:e,keyType:t,typeName:$.ZodMap,...F(r)});var Rn=class t extends V{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.set)return z(n,{code:S.invalid_type,expected:P.set,received:n.parsedType}),j;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(z(n,{code:S.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(z(n,{code:S.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return j;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>s._parse(new at(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:C.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:C.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Rn.create=(t,e)=>new Rn({valueType:t,minSize:null,maxSize:null,typeName:$.ZodSet,...F(e)});var qs=class t extends V{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==P.function)return z(r,{code:S.invalid_type,expected:P.function,received:r.parsedType}),j;function n(a,c){return fo({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xn(),Kt].filter(u=>!!u),issueData:{code:S.invalid_arguments,argumentsError:c}})}function o(a,c){return fo({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,xn(),Kt].filter(u=>!!u),issueData:{code:S.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof pr){let a=this;return je(async function(...c){let u=new Ke([]),l=await a._def.args.parseAsync(c,s).catch(m=>{throw u.addIssue(n(c,m)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,s).catch(m=>{throw u.addIssue(o(d,m)),u})})}else{let a=this;return je(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new Ke([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,s);if(!d.success)throw new Ke([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Ct.create(e).rest(Wt.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||Ct.create([]).rest(Wt.create()),returns:r||Wt.create(),typeName:$.ZodFunction,...F(n)})}},Hr=class extends V{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Hr.create=(t,e)=>new Hr({getter:t,typeName:$.ZodLazy,...F(e)});var Vr=class extends V{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return z(r,{received:r.data,code:S.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:e.data}}get value(){return this._def.value}};Vr.create=(t,e)=>new Vr({value:t,typeName:$.ZodLiteral,...F(e)});function Tp(t,e){return new Br({values:t,typeName:$.ZodEnum,...F(e)})}var Br=class t extends V{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return z(r,{expected:G.joinValues(n),received:r.parsedType,code:S.invalid_type}),j}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return z(r,{received:r.data,code:S.invalid_enum_value,options:n}),j}return je(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};Br.create=Tp;var Kr=class extends V{_parse(e){let r=G.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==P.string&&n.parsedType!==P.number){let o=G.objectValues(r);return z(n,{expected:G.joinValues(o),received:n.parsedType,code:S.invalid_type}),j}if(this._cache||(this._cache=new Set(G.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=G.objectValues(r);return z(n,{received:n.data,code:S.invalid_enum_value,options:o}),j}return je(e.data)}get enum(){return this._def.values}};Kr.create=(t,e)=>new Kr({values:t,typeName:$.ZodNativeEnum,...F(e)});var pr=class extends V{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==P.promise&&r.common.async===!1)return z(r,{code:S.invalid_type,expected:P.promise,received:r.parsedType}),j;let n=r.parsedType===P.promise?r.data:Promise.resolve(r.data);return je(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};pr.create=(t,e)=>new pr({type:t,typeName:$.ZodPromise,...F(e)});var ct=class extends V{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{z(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return j;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?j:c.status==="dirty"?Ir(c.value):r.value==="dirty"?Ir(c.value):c});{if(r.value==="aborted")return j;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?j:a.status==="dirty"?Ir(a.value):r.value==="dirty"?Ir(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?j:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?j:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!lr(i))return j;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>lr(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):j);G.assertNever(o)}};ct.create=(t,e,r)=>new ct({schema:t,typeName:$.ZodEffects,effect:e,...F(r)});ct.createWithPreprocess=(t,e,r)=>new ct({schema:e,effect:{type:"preprocess",transform:t},typeName:$.ZodEffects,...F(r)});var Je=class extends V{_parse(e){return this._getType(e)===P.undefined?je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Je.create=(t,e)=>new Je({innerType:t,typeName:$.ZodOptional,...F(e)});var Ot=class extends V{_parse(e){return this._getType(e)===P.null?je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ot.create=(t,e)=>new Ot({innerType:t,typeName:$.ZodNullable,...F(e)});var Jr=class extends V{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===P.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Jr.create=(t,e)=>new Jr({innerType:t,typeName:$.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...F(e)});var Wr=class extends V{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return kn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ke(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ke(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Wr.create=(t,e)=>new Wr({innerType:t,typeName:$.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...F(e)});var En=class extends V{_parse(e){if(this._getType(e)!==P.nan){let n=this._getOrReturnCtx(e);return z(n,{code:S.invalid_type,expected:P.nan,received:n.parsedType}),j}return{status:"valid",value:e.data}}};En.create=t=>new En({typeName:$.ZodNaN,...F(t)});var Ow=Symbol("zod_brand"),po=class extends V{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},mo=class t extends V{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?j:s.status==="dirty"?(r.dirty(),Ir(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?j:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:$.ZodPipeline})}},Gr=class extends V{_parse(e){let r=this._def.innerType._parse(e),n=o=>(lr(o)&&(o.value=Object.freeze(o.value)),o);return kn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};Gr.create=(t,e)=>new Gr({innerType:t,typeName:$.ZodReadonly,...F(e)});function xp(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function zp(t,e={},r){return t?fr.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=xp(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=xp(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):fr.create()}var Nw={object:We.lazycreate},$;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})($||($={}));var Iw=(t,e={message:`Input not instance of ${t.name}`})=>zp(r=>r instanceof t,e),Rp=dr.create,Ep=Mr.create,Mw=En.create,jw=jr.create,Pp=qr.create,qw=Dr.create,Dw=$n.create,Zw=Zr.create,Lw=Lr.create,Uw=fr.create,Fw=Wt.create,Hw=vt.create,Vw=Tn.create,Bw=Gt.create,Ya=We.create,Kw=We.strictCreate,Jw=Ur.create,Ww=Ms.create,Gw=Fr.create,Qw=Ct.create,Yw=js.create,Xw=zn.create,ex=Rn.create,tx=qs.create,rx=Hr.create,nx=Vr.create,ox=Br.create,sx=Kr.create,ix=pr.create,ax=ct.create,cx=Je.create,ux=Ot.create,lx=ct.createWithPreprocess,dx=mo.create,fx=()=>Rp().optional(),px=()=>Ep().optional(),mx=()=>Pp().optional(),hx={string:(t=>dr.create({...t,coerce:!0})),number:(t=>Mr.create({...t,coerce:!0})),boolean:(t=>qr.create({...t,coerce:!0})),bigint:(t=>jr.create({...t,coerce:!0})),date:(t=>Dr.create({...t,coerce:!0}))};var gx=j;var yx=Object.freeze({status:"aborted"});function x(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var Qt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ds={};function nt(t){return t&&Object.assign(Ds,t),Ds}var Q={};Os(Q,{BIGINT_FORMAT_RANGES:()=>Cp,Class:()=>ec,NUMBER_FORMAT_RANGES:()=>ac,aborted:()=>Yr,allowsEval:()=>oc,assert:()=>xx,assertEqual:()=>_x,assertIs:()=>bx,assertNever:()=>wx,assertNotEqual:()=>vx,assignProp:()=>nc,cached:()=>yo,captureStackTrace:()=>Ls,cleanEnum:()=>Ix,cleanRegex:()=>vo,clone:()=>ot,createTransparentProxy:()=>Rx,defineLazy:()=>le,esc:()=>Qr,escapeRegex:()=>mr,extend:()=>Ax,finalizeIssue:()=>bt,floatSafeRemainder:()=>rc,getElementAtPath:()=>kx,getEnumValues:()=>go,getLengthableOrigin:()=>bo,getParsedType:()=>zx,getSizableOrigin:()=>Op,isObject:()=>Pn,isPlainObject:()=>An,issue:()=>cc,joinValues:()=>Zs,jsonStringifyReplacer:()=>tc,merge:()=>Cx,normalizeParams:()=>q,nullish:()=>_o,numKeys:()=>Tx,omit:()=>Px,optionalKeys:()=>ic,partial:()=>Ox,pick:()=>Ex,prefixIssues:()=>Nt,primitiveTypes:()=>Ap,promiseAllObject:()=>Sx,propertyKeyTypes:()=>sc,randomString:()=>$x,required:()=>Nx,stringifyPrimitive:()=>Us,unwrapMessage:()=>ho});function _x(t){return t}function vx(t){return t}function bx(t){}function wx(t){throw new Error}function xx(t){}function go(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function Zs(t,e="|"){return t.map(r=>Us(r)).join(e)}function tc(t,e){return typeof e=="bigint"?e.toString():e}function yo(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function _o(t){return t==null}function vo(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function rc(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}function le(t,e,r){Object.defineProperty(t,e,{get(){{let o=r();return t[e]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function nc(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function kx(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function Sx(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function $x(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Qr(t){return JSON.stringify(t)}var Ls=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Pn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var oc=yo(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function An(t){if(Pn(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Pn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Tx(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var zx=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},sc=new Set(["string","number","symbol"]),Ap=new Set(["string","number","bigint","boolean","symbol","undefined"]);function mr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ot(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function q(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Rx(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function Us(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function ic(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var ac={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Cp={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ex(t,e){let r={},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(r[o]=n.shape[o])}return ot(t,{...t._zod.def,shape:r,checks:[]})}function Px(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&delete r[o]}return ot(t,{...t._zod.def,shape:r,checks:[]})}function Ax(t,e){if(!An(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return nc(this,"shape",n),n},checks:[]};return ot(t,r)}function Cx(t,e){return ot(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return nc(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function Ox(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=t?new t({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=t?new t({type:"optional",innerType:n[s]}):n[s];return ot(e,{...e._zod.def,shape:o,checks:[]})}function Nx(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new t({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new t({type:"nonoptional",innerType:n[s]});return ot(e,{...e._zod.def,shape:o,checks:[]})}function Yr(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Nt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function ho(t){return typeof t=="string"?t:t?.message}function bt(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=ho(t.inst?._zod.def?.error?.(t))??ho(e?.error?.(t))??ho(r.customError?.(t))??ho(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Op(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function bo(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function cc(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function Ix(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var ec=class{constructor(...e){}};var Np=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,tc,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Fs=x("$ZodError",Np),wo=x("$ZodError",Np,{Parent:Error});function uc(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function lc(t,e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(t),n}var dc=t=>(e,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new Qt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>bt(c,s,nt())));throw Ls(a,o?.callee),a}return i.value},fc=dc(wo),pc=t=>async(e,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>bt(c,s,nt())));throw Ls(a,o?.callee),a}return i.value},mc=pc(wo),hc=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Qt;return s.issues.length?{success:!1,error:new(t??Fs)(s.issues.map(i=>bt(i,o,nt())))}:{success:!0,data:s.value}},Xr=hc(wo),gc=t=>async(e,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>bt(i,o,nt())))}:{success:!0,data:s.value}},en=gc(wo);var Ip=/^[cC][^\s-]{8,}$/,Mp=/^[0-9a-z]+$/,jp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,qp=/^[0-9a-vA-V]{20}$/,Dp=/^[A-Za-z0-9]{27}$/,Zp=/^[a-zA-Z0-9_-]{21}$/,Lp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Up=/^([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})$/,yc=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/;var Fp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var jx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Hp(){return new RegExp(jx,"u")}var Vp=/^(?:(?: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])$/,Bp=/^(([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})$/,Kp=/^((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])$/,Jp=/^(([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])$/,Wp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_c=/^[A-Za-z0-9_-]*$/,Gp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Qp=/^\+(?:[0-9]){6,14}[0-9]$/,Yp="(?:(?:\\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])))",Xp=new RegExp(`^${Yp}$`);function em(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tm(t){return new RegExp(`^${em(t)}$`)}function rm(t){let e=em({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Yp}T(?:${n})$`)}var nm=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var om=/^\d+$/,sm=/^-?\d+(?:\.\d+)?/i,im=/true|false/i,am=/null/i;var cm=/^[^A-Z]*$/,um=/^[^a-z]*$/;var Ae=x("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),lm={number:"number",bigint:"bigint",object:"date"},vc=x("$ZodCheckLessThan",(t,e)=>{Ae.init(t,e);let r=lm[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),bc=x("$ZodCheckGreaterThan",(t,e)=>{Ae.init(t,e);let r=lm[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),dm=x("$ZodCheckMultipleOf",(t,e)=>{Ae.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):rc(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),fm=x("$ZodCheckNumberFormat",(t,e)=>{Ae.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=ac[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=om)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:t})}});var pm=x("$ZodCheckMaxLength",(t,e)=>{var r;Ae.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!_o(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=bo(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),mm=x("$ZodCheckMinLength",(t,e)=>{var r;Ae.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!_o(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=bo(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),hm=x("$ZodCheckLengthEquals",(t,e)=>{var r;Ae.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!_o(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=bo(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),xo=x("$ZodCheckStringFormat",(t,e)=>{var r,n;Ae.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),gm=x("$ZodCheckRegex",(t,e)=>{xo.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),ym=x("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=cm),xo.init(t,e)}),_m=x("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=um),xo.init(t,e)}),vm=x("$ZodCheckIncludes",(t,e)=>{Ae.init(t,e);let r=mr(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),bm=x("$ZodCheckStartsWith",(t,e)=>{Ae.init(t,e);let r=new RegExp(`^${mr(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),wm=x("$ZodCheckEndsWith",(t,e)=>{Ae.init(t,e);let r=new RegExp(`.*${mr(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var xm=x("$ZodCheckOverwrite",(t,e)=>{Ae.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var Vs=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
9
9
|
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let e=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,o.join(`
|
|
10
|
-
`))}};var
|
|
10
|
+
`))}};var Sm={major:4,minor:0,patch:0};var ae=x("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Sm;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let o of n)for(let s of o._zod.onattach)s(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(s,i,a)=>{let c=Yr(s),u;for(let l of i){if(l._zod.def.when){if(!l._zod.def.when(s))continue}else if(c)continue;let d=s.issues.length,p=l._zod.check(s);if(p instanceof Promise&&a?.async===!1)throw new Qt;if(u||p instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await p,s.issues.length!==d&&(c||(c=Yr(s,d)))});else{if(s.issues.length===d)continue;c||(c=Yr(s,d))}}return u?u.then(()=>s):s};t._zod.run=(s,i)=>{let a=t._zod.parse(s,i);if(a instanceof Promise){if(i.async===!1)throw new Qt;return a.then(c=>o(c,n,i))}return o(a,n,i)}}t["~standard"]={validate:o=>{try{let s=Xr(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return en(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),ko=x("$ZodString",(t,e)=>{ae.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??nm(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),de=x("$ZodStringFormat",(t,e)=>{xo.init(t,e),ko.init(t,e)}),xc=x("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Up),de.init(t,e)}),kc=x("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=yc(n))}else e.pattern??(e.pattern=yc());de.init(t,e)}),Sc=x("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Fp),de.init(t,e)}),$c=x("$ZodURL",(t,e)=>{de.init(t,e),t._zod.check=r=>{try{let n=r.value,o=new URL(n),s=o.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Gp.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Tc=x("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Hp()),de.init(t,e)}),zc=x("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Zp),de.init(t,e)}),Rc=x("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Ip),de.init(t,e)}),Ec=x("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Mp),de.init(t,e)}),Pc=x("$ZodULID",(t,e)=>{e.pattern??(e.pattern=jp),de.init(t,e)}),Ac=x("$ZodXID",(t,e)=>{e.pattern??(e.pattern=qp),de.init(t,e)}),Cc=x("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Dp),de.init(t,e)}),Nm=x("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=rm(e)),de.init(t,e)}),Im=x("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Xp),de.init(t,e)}),Mm=x("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=tm(e)),de.init(t,e)}),jm=x("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Lp),de.init(t,e)}),Oc=x("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Vp),de.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Nc=x("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Bp),de.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}}),Ic=x("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Kp),de.init(t,e)}),Mc=x("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Jp),de.init(t,e),t._zod.check=r=>{let[n,o]=r.value.split("/");try{if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function qm(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var jc=x("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Wp),de.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{qm(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function qx(t){if(!_c.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return qm(r)}var qc=x("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=_c),de.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{qx(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Dc=x("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Qp),de.init(t,e)});function Dx(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||e&&(!("alg"in o)||o.alg!==e))}catch{return!1}}var Zc=x("$ZodJWT",(t,e)=>{de.init(t,e),t._zod.check=r=>{Dx(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var Ks=x("$ZodNumber",(t,e)=>{ae.init(t,e),t._zod.pattern=t._zod.bag.pattern??sm,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:t,...s?{received:s}:{}}),r}}),Lc=x("$ZodNumber",(t,e)=>{fm.init(t,e),Ks.init(t,e)}),Uc=x("$ZodBoolean",(t,e)=>{ae.init(t,e),t._zod.pattern=im,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:t}),r}});var Fc=x("$ZodNull",(t,e)=>{ae.init(t,e),t._zod.pattern=am,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:t}),r}});var Hc=x("$ZodUnknown",(t,e)=>{ae.init(t,e),t._zod.parse=r=>r}),Vc=x("$ZodNever",(t,e)=>{ae.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function $m(t,e,r){t.issues.length&&e.issues.push(...Nt(r,t.issues)),e.value[r]=t.value}var Bc=x("$ZodArray",(t,e)=>{ae.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>$m(u,r,i))):$m(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Bs(t,e,r){t.issues.length&&e.issues.push(...Nt(r,t.issues)),e.value[r]=t.value}function Tm(t,e,r,n){t.issues.length?n[r]===void 0?r in n?e.value[r]=void 0:e.value[r]=t.value:e.issues.push(...Nt(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}var Js=x("$ZodObject",(t,e)=>{ae.init(t,e);let r=yo(()=>{let d=Object.keys(e.shape);for(let m of d)if(!(e.shape[m]instanceof ae))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let p=ic(e.shape);return{shape:e.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(p)}});le(t._zod,"propValues",()=>{let d=e.shape,p={};for(let m in d){let f=d[m]._zod;if(f.values){p[m]??(p[m]=new Set);for(let h of f.values)p[m].add(h)}}return p});let n=d=>{let p=new Vs(["shape","payload","ctx"]),m=r.value,f=b=>{let k=Qr(b);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};p.write("const input = payload.value;");let h=Object.create(null),g=0;for(let b of m.keys)h[b]=`key_${g++}`;p.write("const newResult = {}");for(let b of m.keys)if(m.optionalKeys.has(b)){let k=h[b];p.write(`const ${k} = ${f(b)};`);let T=Qr(b);p.write(`
|
|
11
11
|
if (${k}.issues.length) {
|
|
12
12
|
if (input[${T}] === undefined) {
|
|
13
13
|
if (${T} in input) {
|
|
@@ -30,27 +30,27 @@ var Yb=Object.create;var Ba=Object.defineProperty;var Xb=Object.getOwnPropertyDe
|
|
|
30
30
|
if (${k}.issues.length) payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
31
31
|
...iss,
|
|
32
32
|
path: iss.path ? [${Qr(b)}, ...iss.path] : [${Qr(b)}]
|
|
33
|
-
})));`),p.write(`newResult[${Qr(b)}] = ${k}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");let y=p.compile();return(b,k)=>y(d,b,k)},o,s=Pn,i=!Ds.jitless,c=i&&rc.value,u=e.catchall,l;t._zod.parse=(d,p)=>{l??(l=r.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),d;let f=[];if(i&&c&&p?.async===!1&&p.jitless!==!0)o||(o=n(e.shape)),d=o(d,p);else{d.value={};let k=l.shape;for(let T of l.keys){let R=k[T],me=R._zod.run({value:m[T],issues:[]},p),ie=R._zod.optin==="optional"&&R._zod.optout==="optional";me instanceof Promise?f.push(me.then(Ve=>ie?km(Ve,d,T,m):Bs(Ve,d,T))):ie?km(me,d,T,m):Bs(me,d,T)}}if(!u)return f.length?Promise.all(f).then(()=>d):d;let h=[],g=l.keySet,y=u._zod,b=y.def.type;for(let k of Object.keys(m)){if(g.has(k))continue;if(b==="never"){h.push(k);continue}let T=y.run({value:m[k],issues:[]},p);T instanceof Promise?f.push(T.then(R=>Bs(R,d,k))):Bs(T,d,k)}return h.length&&d.issues.push({code:"unrecognized_keys",keys:h,input:m,inst:t}),f.length?Promise.all(f).then(()=>d):d}});function Sm(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>bt(s,n,nt())))}),e}var Ws=x("$ZodUnion",(t,e)=>{ae.init(t,e),le(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),le(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),le(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),le(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>vo(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let o=!1,s=[];for(let i of e.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>Sm(i,r,t,n)):Sm(s,r,t,n)}}),Vc=x("$ZodDiscriminatedUnion",(t,e)=>{Ws.init(t,e);let r=t._zod.parse;le(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=yo(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Pn(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),o)}}),Bc=x("$ZodIntersection",(t,e)=>{ae.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>$m(r,c,u)):$m(r,s,i)}});function vc(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(An(t)&&An(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=vc(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=vc(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function $m(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Yr(t))return t;let n=vc(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}var Kc=x("$ZodRecord",(t,e)=>{ae.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!An(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[];if(e.keyType._zod.values){let i=e.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=e.valueType._zod.run({value:o[c],issues:[]},n);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&r.issues.push(...Nt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...Nt(c,u.issues)),r.value[c]=u.value)}let a;for(let c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(o)){if(i==="__proto__")continue;let a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>bt(u,n,nt())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:o[i],issues:[]},n);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&r.issues.push(...Nt(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...Nt(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var Jc=x("$ZodEnum",(t,e)=>{ae.init(t,e);let r=go(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>nc.has(typeof n)).map(n=>typeof n=="string"?mr(n):n.toString()).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return t._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:t}),n}}),Wc=x("$ZodLiteral",(t,e)=>{ae.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?mr(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let o=r.value;return t._zod.values.has(o)||r.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),r}});var Gc=x("$ZodTransform",(t,e)=>{ae.init(t,e),t._zod.parse=(r,n)=>{let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new Qt;return r.value=o,r}}),Qc=x("$ZodOptional",(t,e)=>{ae.init(t,e),t._zod.optin="optional",t._zod.optout="optional",le(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),le(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${vo(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),Yc=x("$ZodNullable",(t,e)=>{ae.init(t,e),le(t._zod,"optin",()=>e.innerType._zod.optin),le(t._zod,"optout",()=>e.innerType._zod.optout),le(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${vo(r.source)}|null)$`):void 0}),le(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),Xc=x("$ZodDefault",(t,e)=>{ae.init(t,e),t._zod.optin="optional",le(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Tm(s,e)):Tm(o,e)}});function Tm(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var eu=x("$ZodPrefault",(t,e)=>{ae.init(t,e),t._zod.optin="optional",le(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),tu=x("$ZodNonOptional",(t,e)=>{ae.init(t,e),le(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>zm(s,t)):zm(o,t)}});function zm(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var ru=x("$ZodCatch",(t,e)=>{ae.init(t,e),t._zod.optin="optional",le(t._zod,"optout",()=>e.innerType._zod.optout),le(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>bt(i,n,nt()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>bt(s,n,nt()))},input:r.value}),r.issues=[]),r)}});var nu=x("$ZodPipe",(t,e)=>{ae.init(t,e),le(t._zod,"values",()=>e.in._zod.values),le(t._zod,"optin",()=>e.in._zod.optin),le(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Rm(s,e,n)):Rm(o,e,n)}});function Rm(t,e,r){return Yr(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var ou=x("$ZodReadonly",(t,e)=>{ae.init(t,e),le(t._zod,"propValues",()=>e.innerType._zod.propValues),le(t._zod,"values",()=>e.innerType._zod.values),le(t._zod,"optin",()=>e.innerType._zod.optin),le(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(Em):Em(o)}});function Em(t){return t.value=Object.freeze(t.value),t}var su=x("$ZodCustom",(t,e)=>{Ae.init(t,e),ae.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>Pm(s,r,n,t));Pm(o,r,n,t)}});function Pm(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(ic(o))}}var Mx=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},jx=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${Mx(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Us(n.values[0])}`:`Invalid option: expected one of ${Zs(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=e(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=e(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Zs(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Mm(){return{localeError:jx()}}var So=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function jm(){return new So}var hr=jm();function iu(t,e){return new t({type:"string",...q(e)})}function au(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...q(e)})}function Gs(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...q(e)})}function cu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...q(e)})}function uu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...q(e)})}function lu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...q(e)})}function du(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...q(e)})}function fu(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...q(e)})}function pu(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...q(e)})}function mu(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...q(e)})}function hu(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...q(e)})}function gu(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...q(e)})}function yu(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...q(e)})}function _u(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...q(e)})}function vu(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...q(e)})}function bu(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...q(e)})}function wu(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...q(e)})}function xu(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...q(e)})}function ku(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...q(e)})}function Su(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...q(e)})}function $u(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...q(e)})}function Tu(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...q(e)})}function zu(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...q(e)})}function qm(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...q(e)})}function Dm(t,e){return new t({type:"string",format:"date",check:"string_format",...q(e)})}function Zm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...q(e)})}function Lm(t,e){return new t({type:"string",format:"duration",check:"string_format",...q(e)})}function Ru(t,e){return new t({type:"number",checks:[],...q(e)})}function Eu(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...q(e)})}function Pu(t,e){return new t({type:"boolean",...q(e)})}function Au(t,e){return new t({type:"null",...q(e)})}function Cu(t){return new t({type:"unknown"})}function Ou(t,e){return new t({type:"never",...q(e)})}function Qs(t,e){return new yc({check:"less_than",...q(e),value:t,inclusive:!1})}function $o(t,e){return new yc({check:"less_than",...q(e),value:t,inclusive:!0})}function Ys(t,e){return new _c({check:"greater_than",...q(e),value:t,inclusive:!1})}function To(t,e){return new _c({check:"greater_than",...q(e),value:t,inclusive:!0})}function Xs(t,e){return new cm({check:"multiple_of",...q(e),value:t})}function ei(t,e){return new lm({check:"max_length",...q(e),maximum:t})}function Cn(t,e){return new dm({check:"min_length",...q(e),minimum:t})}function ti(t,e){return new fm({check:"length_equals",...q(e),length:t})}function Nu(t,e){return new pm({check:"string_format",format:"regex",...q(e),pattern:t})}function Iu(t){return new mm({check:"string_format",format:"lowercase",...q(t)})}function Mu(t){return new hm({check:"string_format",format:"uppercase",...q(t)})}function ju(t,e){return new gm({check:"string_format",format:"includes",...q(e),includes:t})}function qu(t,e){return new ym({check:"string_format",format:"starts_with",...q(e),prefix:t})}function Du(t,e){return new _m({check:"string_format",format:"ends_with",...q(e),suffix:t})}function tn(t){return new vm({check:"overwrite",tx:t})}function Zu(t){return tn(e=>e.normalize(t))}function Lu(){return tn(t=>t.trim())}function Uu(){return tn(t=>t.toLowerCase())}function Fu(){return tn(t=>t.toUpperCase())}function Um(t,e,r){return new t({type:"array",element:e,...q(r)})}function Hu(t,e,r){let n=q(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Vu(t,e,r){return new t({type:"custom",check:"custom",fn:e,...q(r)})}var ri=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??hr,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path},p=e._zod.parent;if(p)a.ref=p,this.process(p,d),this.seen.get(p).isParent=!0;else{let m=a.schema;switch(o.type){case"string":{let f=m;f.type="string";let{minimum:h,maximum:g,format:y,patterns:b,contentEncoding:k}=e._zod.bag;if(typeof h=="number"&&(f.minLength=h),typeof g=="number"&&(f.maxLength=g),y&&(f.format=s[y]??y,f.format===""&&delete f.format),k&&(f.contentEncoding=k),b&&b.size>0){let T=[...b];T.length===1?f.pattern=T[0].source:T.length>1&&(a.schema.allOf=[...T.map(R=>({...this.target==="draft-7"?{type:"string"}:{},pattern:R.source}))])}break}case"number":{let f=m,{minimum:h,maximum:g,format:y,multipleOf:b,exclusiveMaximum:k,exclusiveMinimum:T}=e._zod.bag;typeof y=="string"&&y.includes("int")?f.type="integer":f.type="number",typeof T=="number"&&(f.exclusiveMinimum=T),typeof h=="number"&&(f.minimum=h,typeof T=="number"&&(T>=h?delete f.minimum:delete f.exclusiveMinimum)),typeof k=="number"&&(f.exclusiveMaximum=k),typeof g=="number"&&(f.maximum=g,typeof k=="number"&&(k<=g?delete f.maximum:delete f.exclusiveMaximum)),typeof b=="number"&&(f.multipleOf=b);break}case"boolean":{let f=m;f.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{m.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{m.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let f=m,{minimum:h,maximum:g}=e._zod.bag;typeof h=="number"&&(f.minItems=h),typeof g=="number"&&(f.maxItems=g),f.type="array",f.items=this.process(o.element,{...d,path:[...d.path,"items"]});break}case"object":{let f=m;f.type="object",f.properties={};let h=o.shape;for(let b in h)f.properties[b]=this.process(h[b],{...d,path:[...d.path,"properties",b]});let g=new Set(Object.keys(h)),y=new Set([...g].filter(b=>{let k=o.shape[b]._zod;return this.io==="input"?k.optin===void 0:k.optout===void 0}));y.size>0&&(f.required=Array.from(y)),o.catchall?._zod.def.type==="never"?f.additionalProperties=!1:o.catchall?o.catchall&&(f.additionalProperties=this.process(o.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(f.additionalProperties=!1);break}case"union":{let f=m;f.anyOf=o.options.map((h,g)=>this.process(h,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let f=m,h=this.process(o.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(o.right,{...d,path:[...d.path,"allOf",1]}),y=k=>"allOf"in k&&Object.keys(k).length===1,b=[...y(h)?h.allOf:[h],...y(g)?g.allOf:[g]];f.allOf=b;break}case"tuple":{let f=m;f.type="array";let h=o.items.map((b,k)=>this.process(b,{...d,path:[...d.path,"prefixItems",k]}));if(this.target==="draft-2020-12"?f.prefixItems=h:f.items=h,o.rest){let b=this.process(o.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?f.items=b:f.additionalItems=b}o.rest&&(f.items=this.process(o.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(f.minItems=g),typeof y=="number"&&(f.maxItems=y);break}case"record":{let f=m;f.type="object",f.propertyNames=this.process(o.keyType,{...d,path:[...d.path,"propertyNames"]}),f.additionalProperties=this.process(o.valueType,{...d,path:[...d.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let f=m,h=go(o.entries);h.every(g=>typeof g=="number")&&(f.type="number"),h.every(g=>typeof g=="string")&&(f.type="string"),f.enum=h;break}case"literal":{let f=m,h=[];for(let g of o.values)if(g===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof g=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");h.push(Number(g))}else h.push(g);if(h.length!==0)if(h.length===1){let g=h[0];f.type=g===null?"null":typeof g,f.const=g}else h.every(g=>typeof g=="number")&&(f.type="number"),h.every(g=>typeof g=="string")&&(f.type="string"),h.every(g=>typeof g=="boolean")&&(f.type="string"),h.every(g=>g===null)&&(f.type="null"),f.enum=h;break}case"file":{let f=m,h={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:b}=e._zod.bag;g!==void 0&&(h.minLength=g),y!==void 0&&(h.maxLength=y),b?b.length===1?(h.contentMediaType=b[0],Object.assign(f,h)):f.anyOf=b.map(k=>({...h,contentMediaType:k})):Object.assign(f,h);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let f=this.process(o.innerType,d);m.anyOf=[f,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"success":{let f=m;f.type="boolean";break}case"default":{this.process(o.innerType,d),a.ref=o.innerType,m.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,d),a.ref=o.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,d),a.ref=o.innerType;let f;try{f=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}m.default=f;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let f=m,h=e._zod.pattern;if(!h)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=h.source;break}case"pipe":{let f=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(f,d),a.ref=f;break}case"readonly":{this.process(o.innerType,d),a.ref=o.innerType,m.readOnly=!0;break}case"promise":{this.process(o.innerType,d),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"lazy":{let f=e._zod.innerType;this.process(f,d),a.ref=f;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&ze(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},o=this.seen.get(e);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let s=l=>{let d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let h=n.external.registry.get(l[0])?.id,g=n.external.uri??(b=>b);if(h)return{ref:g(h)};let y=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=y,{defId:y,ref:`${g("__shared")}#/${d}/${y}`}}if(l[1]===o)return{ref:"#"};let m=`#/${d}/`,f=l[1].schema.id??`__schema${this.counter++}`;return{defId:f,ref:m+f}},i=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:p,defId:m}=s(l);d.def={...d.schema},m&&(d.defId=m);let f=d.schema;for(let h in f)delete f[h];f.$ref=p};if(n.cycles==="throw")for(let l of this.seen.entries()){let d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
33
|
+
})));`),p.write(`newResult[${Qr(b)}] = ${k}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");let y=p.compile();return(b,k)=>y(d,b,k)},o,s=Pn,i=!Ds.jitless,c=i&&oc.value,u=e.catchall,l;t._zod.parse=(d,p)=>{l??(l=r.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),d;let f=[];if(i&&c&&p?.async===!1&&p.jitless!==!0)o||(o=n(e.shape)),d=o(d,p);else{d.value={};let k=l.shape;for(let T of l.keys){let R=k[T],me=R._zod.run({value:m[T],issues:[]},p),ie=R._zod.optin==="optional"&&R._zod.optout==="optional";me instanceof Promise?f.push(me.then(Ve=>ie?Tm(Ve,d,T,m):Bs(Ve,d,T))):ie?Tm(me,d,T,m):Bs(me,d,T)}}if(!u)return f.length?Promise.all(f).then(()=>d):d;let h=[],g=l.keySet,y=u._zod,b=y.def.type;for(let k of Object.keys(m)){if(g.has(k))continue;if(b==="never"){h.push(k);continue}let T=y.run({value:m[k],issues:[]},p);T instanceof Promise?f.push(T.then(R=>Bs(R,d,k))):Bs(T,d,k)}return h.length&&d.issues.push({code:"unrecognized_keys",keys:h,input:m,inst:t}),f.length?Promise.all(f).then(()=>d):d}});function zm(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>bt(s,n,nt())))}),e}var Ws=x("$ZodUnion",(t,e)=>{ae.init(t,e),le(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),le(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),le(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),le(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>vo(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let o=!1,s=[];for(let i of e.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>zm(i,r,t,n)):zm(s,r,t,n)}}),Kc=x("$ZodDiscriminatedUnion",(t,e)=>{Ws.init(t,e);let r=t._zod.parse;le(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=yo(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Pn(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),o)}}),Jc=x("$ZodIntersection",(t,e)=>{ae.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Rm(r,c,u)):Rm(r,s,i)}});function wc(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(An(t)&&An(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=wc(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=wc(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Rm(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Yr(t))return t;let n=wc(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}var Wc=x("$ZodRecord",(t,e)=>{ae.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!An(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[];if(e.keyType._zod.values){let i=e.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=e.valueType._zod.run({value:o[c],issues:[]},n);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&r.issues.push(...Nt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...Nt(c,u.issues)),r.value[c]=u.value)}let a;for(let c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(o)){if(i==="__proto__")continue;let a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>bt(u,n,nt())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:o[i],issues:[]},n);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&r.issues.push(...Nt(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...Nt(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var Gc=x("$ZodEnum",(t,e)=>{ae.init(t,e);let r=go(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>sc.has(typeof n)).map(n=>typeof n=="string"?mr(n):n.toString()).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return t._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:t}),n}}),Qc=x("$ZodLiteral",(t,e)=>{ae.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?mr(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let o=r.value;return t._zod.values.has(o)||r.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),r}});var Yc=x("$ZodTransform",(t,e)=>{ae.init(t,e),t._zod.parse=(r,n)=>{let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new Qt;return r.value=o,r}}),Xc=x("$ZodOptional",(t,e)=>{ae.init(t,e),t._zod.optin="optional",t._zod.optout="optional",le(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),le(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${vo(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>e.innerType._zod.optin==="optional"?e.innerType._zod.run(r,n):r.value===void 0?r:e.innerType._zod.run(r,n)}),eu=x("$ZodNullable",(t,e)=>{ae.init(t,e),le(t._zod,"optin",()=>e.innerType._zod.optin),le(t._zod,"optout",()=>e.innerType._zod.optout),le(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${vo(r.source)}|null)$`):void 0}),le(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),tu=x("$ZodDefault",(t,e)=>{ae.init(t,e),t._zod.optin="optional",le(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Em(s,e)):Em(o,e)}});function Em(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var ru=x("$ZodPrefault",(t,e)=>{ae.init(t,e),t._zod.optin="optional",le(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),nu=x("$ZodNonOptional",(t,e)=>{ae.init(t,e),le(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Pm(s,t)):Pm(o,t)}});function Pm(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var ou=x("$ZodCatch",(t,e)=>{ae.init(t,e),t._zod.optin="optional",le(t._zod,"optout",()=>e.innerType._zod.optout),le(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>bt(i,n,nt()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>bt(s,n,nt()))},input:r.value}),r.issues=[]),r)}});var su=x("$ZodPipe",(t,e)=>{ae.init(t,e),le(t._zod,"values",()=>e.in._zod.values),le(t._zod,"optin",()=>e.in._zod.optin),le(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Am(s,e,n)):Am(o,e,n)}});function Am(t,e,r){return Yr(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var iu=x("$ZodReadonly",(t,e)=>{ae.init(t,e),le(t._zod,"propValues",()=>e.innerType._zod.propValues),le(t._zod,"values",()=>e.innerType._zod.values),le(t._zod,"optin",()=>e.innerType._zod.optin),le(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(Cm):Cm(o)}});function Cm(t){return t.value=Object.freeze(t.value),t}var au=x("$ZodCustom",(t,e)=>{Ae.init(t,e),ae.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>Om(s,r,n,t));Om(o,r,n,t)}});function Om(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(cc(o))}}var Zx=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},Lx=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${Zx(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Us(n.values[0])}`:`Invalid option: expected one of ${Zs(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=e(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=e(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Zs(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Dm(){return{localeError:Lx()}}var So=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let n=r[0];if(this._map.set(e,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function Zm(){return new So}var hr=Zm();function cu(t,e){return new t({type:"string",...q(e)})}function uu(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...q(e)})}function Gs(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...q(e)})}function lu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...q(e)})}function du(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...q(e)})}function fu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...q(e)})}function pu(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...q(e)})}function mu(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...q(e)})}function hu(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...q(e)})}function gu(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...q(e)})}function yu(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...q(e)})}function _u(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...q(e)})}function vu(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...q(e)})}function bu(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...q(e)})}function wu(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...q(e)})}function xu(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...q(e)})}function ku(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...q(e)})}function Su(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...q(e)})}function $u(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...q(e)})}function Tu(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...q(e)})}function zu(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...q(e)})}function Ru(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...q(e)})}function Eu(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...q(e)})}function Lm(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...q(e)})}function Um(t,e){return new t({type:"string",format:"date",check:"string_format",...q(e)})}function Fm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...q(e)})}function Hm(t,e){return new t({type:"string",format:"duration",check:"string_format",...q(e)})}function Pu(t,e){return new t({type:"number",checks:[],...q(e)})}function Au(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...q(e)})}function Cu(t,e){return new t({type:"boolean",...q(e)})}function Ou(t,e){return new t({type:"null",...q(e)})}function Nu(t){return new t({type:"unknown"})}function Iu(t,e){return new t({type:"never",...q(e)})}function Qs(t,e){return new vc({check:"less_than",...q(e),value:t,inclusive:!1})}function $o(t,e){return new vc({check:"less_than",...q(e),value:t,inclusive:!0})}function Ys(t,e){return new bc({check:"greater_than",...q(e),value:t,inclusive:!1})}function To(t,e){return new bc({check:"greater_than",...q(e),value:t,inclusive:!0})}function Xs(t,e){return new dm({check:"multiple_of",...q(e),value:t})}function ei(t,e){return new pm({check:"max_length",...q(e),maximum:t})}function Cn(t,e){return new mm({check:"min_length",...q(e),minimum:t})}function ti(t,e){return new hm({check:"length_equals",...q(e),length:t})}function Mu(t,e){return new gm({check:"string_format",format:"regex",...q(e),pattern:t})}function ju(t){return new ym({check:"string_format",format:"lowercase",...q(t)})}function qu(t){return new _m({check:"string_format",format:"uppercase",...q(t)})}function Du(t,e){return new vm({check:"string_format",format:"includes",...q(e),includes:t})}function Zu(t,e){return new bm({check:"string_format",format:"starts_with",...q(e),prefix:t})}function Lu(t,e){return new wm({check:"string_format",format:"ends_with",...q(e),suffix:t})}function tn(t){return new xm({check:"overwrite",tx:t})}function Uu(t){return tn(e=>e.normalize(t))}function Fu(){return tn(t=>t.trim())}function Hu(){return tn(t=>t.toLowerCase())}function Vu(){return tn(t=>t.toUpperCase())}function Vm(t,e,r){return new t({type:"array",element:e,...q(r)})}function Bu(t,e,r){let n=q(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Ku(t,e,r){return new t({type:"custom",check:"custom",fn:e,...q(r)})}var ri=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??hr,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path},p=e._zod.parent;if(p)a.ref=p,this.process(p,d),this.seen.get(p).isParent=!0;else{let m=a.schema;switch(o.type){case"string":{let f=m;f.type="string";let{minimum:h,maximum:g,format:y,patterns:b,contentEncoding:k}=e._zod.bag;if(typeof h=="number"&&(f.minLength=h),typeof g=="number"&&(f.maxLength=g),y&&(f.format=s[y]??y,f.format===""&&delete f.format),k&&(f.contentEncoding=k),b&&b.size>0){let T=[...b];T.length===1?f.pattern=T[0].source:T.length>1&&(a.schema.allOf=[...T.map(R=>({...this.target==="draft-7"?{type:"string"}:{},pattern:R.source}))])}break}case"number":{let f=m,{minimum:h,maximum:g,format:y,multipleOf:b,exclusiveMaximum:k,exclusiveMinimum:T}=e._zod.bag;typeof y=="string"&&y.includes("int")?f.type="integer":f.type="number",typeof T=="number"&&(f.exclusiveMinimum=T),typeof h=="number"&&(f.minimum=h,typeof T=="number"&&(T>=h?delete f.minimum:delete f.exclusiveMinimum)),typeof k=="number"&&(f.exclusiveMaximum=k),typeof g=="number"&&(f.maximum=g,typeof k=="number"&&(k<=g?delete f.maximum:delete f.exclusiveMaximum)),typeof b=="number"&&(f.multipleOf=b);break}case"boolean":{let f=m;f.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{m.type="null";break}case"any":break;case"unknown":break;case"undefined":{if(this.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema");break}case"void":{if(this.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema");break}case"never":{m.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let f=m,{minimum:h,maximum:g}=e._zod.bag;typeof h=="number"&&(f.minItems=h),typeof g=="number"&&(f.maxItems=g),f.type="array",f.items=this.process(o.element,{...d,path:[...d.path,"items"]});break}case"object":{let f=m;f.type="object",f.properties={};let h=o.shape;for(let b in h)f.properties[b]=this.process(h[b],{...d,path:[...d.path,"properties",b]});let g=new Set(Object.keys(h)),y=new Set([...g].filter(b=>{let k=o.shape[b]._zod;return this.io==="input"?k.optin===void 0:k.optout===void 0}));y.size>0&&(f.required=Array.from(y)),o.catchall?._zod.def.type==="never"?f.additionalProperties=!1:o.catchall?o.catchall&&(f.additionalProperties=this.process(o.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(f.additionalProperties=!1);break}case"union":{let f=m;f.anyOf=o.options.map((h,g)=>this.process(h,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let f=m,h=this.process(o.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(o.right,{...d,path:[...d.path,"allOf",1]}),y=k=>"allOf"in k&&Object.keys(k).length===1,b=[...y(h)?h.allOf:[h],...y(g)?g.allOf:[g]];f.allOf=b;break}case"tuple":{let f=m;f.type="array";let h=o.items.map((b,k)=>this.process(b,{...d,path:[...d.path,"prefixItems",k]}));if(this.target==="draft-2020-12"?f.prefixItems=h:f.items=h,o.rest){let b=this.process(o.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?f.items=b:f.additionalItems=b}o.rest&&(f.items=this.process(o.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(f.minItems=g),typeof y=="number"&&(f.maxItems=y);break}case"record":{let f=m;f.type="object",f.propertyNames=this.process(o.keyType,{...d,path:[...d.path,"propertyNames"]}),f.additionalProperties=this.process(o.valueType,{...d,path:[...d.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let f=m,h=go(o.entries);h.every(g=>typeof g=="number")&&(f.type="number"),h.every(g=>typeof g=="string")&&(f.type="string"),f.enum=h;break}case"literal":{let f=m,h=[];for(let g of o.values)if(g===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof g=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");h.push(Number(g))}else h.push(g);if(h.length!==0)if(h.length===1){let g=h[0];f.type=g===null?"null":typeof g,f.const=g}else h.every(g=>typeof g=="number")&&(f.type="number"),h.every(g=>typeof g=="string")&&(f.type="string"),h.every(g=>typeof g=="boolean")&&(f.type="string"),h.every(g=>g===null)&&(f.type="null"),f.enum=h;break}case"file":{let f=m,h={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:b}=e._zod.bag;g!==void 0&&(h.minLength=g),y!==void 0&&(h.maxLength=y),b?b.length===1?(h.contentMediaType=b[0],Object.assign(f,h)):f.anyOf=b.map(k=>({...h,contentMediaType:k})):Object.assign(f,h);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let f=this.process(o.innerType,d);m.anyOf=[f,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"success":{let f=m;f.type="boolean";break}case"default":{this.process(o.innerType,d),a.ref=o.innerType,m.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,d),a.ref=o.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,d),a.ref=o.innerType;let f;try{f=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}m.default=f;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let f=m,h=e._zod.pattern;if(!h)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=h.source;break}case"pipe":{let f=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(f,d),a.ref=f;break}case"readonly":{this.process(o.innerType,d),a.ref=o.innerType,m.readOnly=!0;break}case"promise":{this.process(o.innerType,d),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"lazy":{let f=e._zod.innerType;this.process(f,d),a.ref=f;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&ze(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},o=this.seen.get(e);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let s=l=>{let d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let h=n.external.registry.get(l[0])?.id,g=n.external.uri??(b=>b);if(h)return{ref:g(h)};let y=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=y,{defId:y,ref:`${g("__shared")}#/${d}/${y}`}}if(l[1]===o)return{ref:"#"};let m=`#/${d}/`,f=l[1].schema.id??`__schema${this.counter++}`;return{defId:f,ref:m+f}},i=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:p,defId:m}=s(l);d.def={...d.schema},m&&(d.defId=m);let f=d.schema;for(let h in f)delete f[h];f.$ref=p};if(n.cycles==="throw")for(let l of this.seen.entries()){let d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
34
34
|
|
|
35
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(e===l[0]){i(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(e!==l[0]&&m){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(d.cycle){i(l);continue}if(d.count>1&&n.reused==="ref"){i(l);continue}}let a=(l,d)=>{let p=this.seen.get(l),m=p.def??p.schema,f={...m};if(p.ref===null)return;let h=p.ref;if(p.ref=null,h){a(h,d);let g=this.seen.get(h).schema;g.$ref&&d.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(g)):(Object.assign(m,g),Object.assign(m,f))}p.isParent||this.override({zodSchema:l,jsonSchema:m,path:p.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,o.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}};function Bu(t,e){if(t instanceof So){let n=new ri(e),o={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let s={},i={registry:t,uri:e?.uri,defs:o};for(let a of t._idmap.entries()){let[c,u]=a;s[c]=n.emit(u,{...e,external:i})}if(Object.keys(o).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}let r=new ri(e);return r.process(t),r.emit(t,e)}function ze(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let o=t._zod.def;switch(o.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return ze(o.element,r);case"object":{for(let s in o.shape)if(ze(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(ze(s,r))return!0;return!1}case"intersection":return ze(o.left,r)||ze(o.right,r);case"tuple":{for(let s of o.items)if(ze(s,r))return!0;return!!(o.rest&&ze(o.rest,r))}case"record":return ze(o.keyType,r)||ze(o.valueType,r);case"map":return ze(o.keyType,r)||ze(o.valueType,r);case"set":return ze(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return ze(o.innerType,r);case"lazy":return ze(o.getter(),r);case"default":return ze(o.innerType,r);case"prefault":return ze(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return ze(o.in,r)||ze(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}var _0=x("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");ae.init(t,e),t.def=e,t.parse=(r,n)=>lc(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Xr(t,r,n),t.parseAsync=async(r,n)=>fc(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>en(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>ot(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var v0=x("ZodMiniObject",(t,e)=>{Js.init(t,e),_0.init(t,e),Q.defineLazy(t,"shape",()=>e.shape)});function Ku(t,e){let r={type:"object",get shape(){return Q.assignProp(this,"shape",{...t}),this.shape},...Q.normalizeParams(e)};return new v0(r)}function ut(t){return!!t._zod}function nn(t){let e=Object.values(t);if(e.length===0)return Ku({});let r=e.every(ut),n=e.every(o=>!ut(o));if(r)return Ku(t);if(n)return Ga(t);throw new Error("Mixed Zod versions detected in object shape.")}function gr(t,e){return ut(t)?Xr(t,e):t.safeParse(e)}async function ni(t,e){return ut(t)?await en(t,e):await t.safeParseAsync(e)}function yr(t){if(!t)return;let e;if(ut(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function On(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return nn(t)}}if(ut(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function oi(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function Hm(t){return t.description}function Vm(t){if(ut(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function si(t){if(ut(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var zo={};Os(zo,{ZodISODate:()=>Km,ZodISODateTime:()=>Bm,ZodISODuration:()=>Wm,ZodISOTime:()=>Jm,date:()=>Wu,datetime:()=>Ju,duration:()=>Qu,time:()=>Gu});var Bm=x("ZodISODateTime",(t,e)=>{Am.init(t,e),ye.init(t,e)});function Ju(t){return qm(Bm,t)}var Km=x("ZodISODate",(t,e)=>{Cm.init(t,e),ye.init(t,e)});function Wu(t){return Dm(Km,t)}var Jm=x("ZodISOTime",(t,e)=>{Om.init(t,e),ye.init(t,e)});function Gu(t){return Zm(Jm,t)}var Wm=x("ZodISODuration",(t,e)=>{Nm.init(t,e),ye.init(t,e)});function Qu(t){return Lm(Wm,t)}var Gm=(t,e)=>{Fs.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>cc(t,r)},flatten:{value:r=>ac(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},mI=x("ZodError",Gm),Ro=x("ZodError",Gm,{Parent:Error});var Qm=uc(Ro),Ym=dc(Ro),Xm=pc(Ro),eh=mc(Ro);var ke=x("ZodType",(t,e)=>(ae.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>ot(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Qm(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Xm(t,r,n),t.parseAsync=async(r,n)=>Ym(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>eh(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(gk(r,n)),t.superRefine=r=>t.check(yk(r)),t.overwrite=r=>t.check(tn(r)),t.optional=()=>xe(t),t.nullable=()=>nh(t),t.nullish=()=>xe(nh(t)),t.nonoptional=r=>uk(t,r),t.array=()=>Y(t),t.or=r=>fe([t,r]),t.and=r=>ai(t,r),t.transform=r=>Xu(t,ch(r)),t.default=r=>ik(t,r),t.prefault=r=>ck(t,r),t.catch=r=>dk(t,r),t.pipe=r=>Xu(t,r),t.readonly=()=>mk(t),t.describe=r=>{let n=t.clone();return hr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return hr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return hr.get(t);let n=t.clone();return hr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),oh=x("_ZodString",(t,e)=>{ko.init(t,e),ke.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(Nu(...n)),t.includes=(...n)=>t.check(ju(...n)),t.startsWith=(...n)=>t.check(qu(...n)),t.endsWith=(...n)=>t.check(Du(...n)),t.min=(...n)=>t.check(Cn(...n)),t.max=(...n)=>t.check(ei(...n)),t.length=(...n)=>t.check(ti(...n)),t.nonempty=(...n)=>t.check(Cn(1,...n)),t.lowercase=n=>t.check(Iu(n)),t.uppercase=n=>t.check(Mu(n)),t.trim=()=>t.check(Lu()),t.normalize=(...n)=>t.check(Zu(...n)),t.toLowerCase=()=>t.check(Uu()),t.toUpperCase=()=>t.check(Fu())}),R0=x("ZodString",(t,e)=>{ko.init(t,e),oh.init(t,e),t.email=r=>t.check(au(E0,r)),t.url=r=>t.check(fu(P0,r)),t.jwt=r=>t.check(zu(V0,r)),t.emoji=r=>t.check(pu(A0,r)),t.guid=r=>t.check(Gs(th,r)),t.uuid=r=>t.check(cu(ii,r)),t.uuidv4=r=>t.check(uu(ii,r)),t.uuidv6=r=>t.check(lu(ii,r)),t.uuidv7=r=>t.check(du(ii,r)),t.nanoid=r=>t.check(mu(C0,r)),t.guid=r=>t.check(Gs(th,r)),t.cuid=r=>t.check(hu(O0,r)),t.cuid2=r=>t.check(gu(N0,r)),t.ulid=r=>t.check(yu(I0,r)),t.base64=r=>t.check(Su(U0,r)),t.base64url=r=>t.check($u(F0,r)),t.xid=r=>t.check(_u(M0,r)),t.ksuid=r=>t.check(vu(j0,r)),t.ipv4=r=>t.check(bu(q0,r)),t.ipv6=r=>t.check(wu(D0,r)),t.cidrv4=r=>t.check(xu(Z0,r)),t.cidrv6=r=>t.check(ku(L0,r)),t.e164=r=>t.check(Tu(H0,r)),t.datetime=r=>t.check(Ju(r)),t.date=r=>t.check(Wu(r)),t.time=r=>t.check(Gu(r)),t.duration=r=>t.check(Qu(r))});function w(t){return iu(R0,t)}var ye=x("ZodStringFormat",(t,e)=>{de.init(t,e),oh.init(t,e)}),E0=x("ZodEmail",(t,e)=>{xc.init(t,e),ye.init(t,e)});var th=x("ZodGUID",(t,e)=>{bc.init(t,e),ye.init(t,e)});var ii=x("ZodUUID",(t,e)=>{wc.init(t,e),ye.init(t,e)});var P0=x("ZodURL",(t,e)=>{kc.init(t,e),ye.init(t,e)});var A0=x("ZodEmoji",(t,e)=>{Sc.init(t,e),ye.init(t,e)});var C0=x("ZodNanoID",(t,e)=>{$c.init(t,e),ye.init(t,e)});var O0=x("ZodCUID",(t,e)=>{Tc.init(t,e),ye.init(t,e)});var N0=x("ZodCUID2",(t,e)=>{zc.init(t,e),ye.init(t,e)});var I0=x("ZodULID",(t,e)=>{Rc.init(t,e),ye.init(t,e)});var M0=x("ZodXID",(t,e)=>{Ec.init(t,e),ye.init(t,e)});var j0=x("ZodKSUID",(t,e)=>{Pc.init(t,e),ye.init(t,e)});var q0=x("ZodIPv4",(t,e)=>{Ac.init(t,e),ye.init(t,e)});var D0=x("ZodIPv6",(t,e)=>{Cc.init(t,e),ye.init(t,e)});var Z0=x("ZodCIDRv4",(t,e)=>{Oc.init(t,e),ye.init(t,e)});var L0=x("ZodCIDRv6",(t,e)=>{Nc.init(t,e),ye.init(t,e)});var U0=x("ZodBase64",(t,e)=>{Ic.init(t,e),ye.init(t,e)});var F0=x("ZodBase64URL",(t,e)=>{Mc.init(t,e),ye.init(t,e)});var H0=x("ZodE164",(t,e)=>{jc.init(t,e),ye.init(t,e)});var V0=x("ZodJWT",(t,e)=>{qc.init(t,e),ye.init(t,e)});var sh=x("ZodNumber",(t,e)=>{Ks.init(t,e),ke.init(t,e),t.gt=(n,o)=>t.check(Ys(n,o)),t.gte=(n,o)=>t.check(To(n,o)),t.min=(n,o)=>t.check(To(n,o)),t.lt=(n,o)=>t.check(Qs(n,o)),t.lte=(n,o)=>t.check($o(n,o)),t.max=(n,o)=>t.check($o(n,o)),t.int=n=>t.check(rh(n)),t.safe=n=>t.check(rh(n)),t.positive=n=>t.check(Ys(0,n)),t.nonnegative=n=>t.check(To(0,n)),t.negative=n=>t.check(Qs(0,n)),t.nonpositive=n=>t.check($o(0,n)),t.multipleOf=(n,o)=>t.check(Xs(n,o)),t.step=(n,o)=>t.check(Xs(n,o)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function oe(t){return Ru(sh,t)}var B0=x("ZodNumberFormat",(t,e)=>{Dc.init(t,e),sh.init(t,e)});function rh(t){return Eu(B0,t)}var K0=x("ZodBoolean",(t,e)=>{Zc.init(t,e),ke.init(t,e)});function Ee(t){return Pu(K0,t)}var J0=x("ZodNull",(t,e)=>{Lc.init(t,e),ke.init(t,e)});function el(t){return Au(J0,t)}var W0=x("ZodUnknown",(t,e)=>{Uc.init(t,e),ke.init(t,e)});function _e(){return Cu(W0)}var G0=x("ZodNever",(t,e)=>{Fc.init(t,e),ke.init(t,e)});function Q0(t){return Ou(G0,t)}var Y0=x("ZodArray",(t,e)=>{Hc.init(t,e),ke.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Cn(r,n)),t.nonempty=r=>t.check(Cn(1,r)),t.max=(r,n)=>t.check(ei(r,n)),t.length=(r,n)=>t.check(ti(r,n)),t.unwrap=()=>t.element});function Y(t,e){return Um(Y0,t,e)}var ih=x("ZodObject",(t,e)=>{Js.init(t,e),ke.init(t,e),Q.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Ge(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:_e()}),t.loose=()=>t.clone({...t._zod.def,catchall:_e()}),t.strict=()=>t.clone({...t._zod.def,catchall:Q0()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>Q.extend(t,r),t.merge=r=>Q.merge(t,r),t.pick=r=>Q.pick(t,r),t.omit=r=>Q.omit(t,r),t.partial=(...r)=>Q.partial(uh,t,r[0]),t.required=(...r)=>Q.required(lh,t,r[0])});function A(t,e){let r={type:"object",get shape(){return Q.assignProp(this,"shape",{...t}),this.shape},...Q.normalizeParams(e)};return new ih(r)}function Le(t,e){return new ih({type:"object",get shape(){return Q.assignProp(this,"shape",{...t}),this.shape},catchall:_e(),...Q.normalizeParams(e)})}var ah=x("ZodUnion",(t,e)=>{Ws.init(t,e),ke.init(t,e),t.options=e.options});function fe(t,e){return new ah({type:"union",options:t,...Q.normalizeParams(e)})}var X0=x("ZodDiscriminatedUnion",(t,e)=>{ah.init(t,e),Vc.init(t,e)});function tl(t,e,r){return new X0({type:"union",options:e,discriminator:t,...Q.normalizeParams(r)})}var ek=x("ZodIntersection",(t,e)=>{Bc.init(t,e),ke.init(t,e)});function ai(t,e){return new ek({type:"intersection",left:t,right:e})}var tk=x("ZodRecord",(t,e)=>{Kc.init(t,e),ke.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function ve(t,e,r){return new tk({type:"record",keyType:t,valueType:e,...Q.normalizeParams(r)})}var Yu=x("ZodEnum",(t,e)=>{Jc.init(t,e),ke.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Yu({...e,checks:[],...Q.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Yu({...e,checks:[],...Q.normalizeParams(o),entries:s})}});function Ge(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Yu({type:"enum",entries:r,...Q.normalizeParams(e)})}var rk=x("ZodLiteral",(t,e)=>{Wc.init(t,e),ke.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function N(t,e){return new rk({type:"literal",values:Array.isArray(t)?t:[t],...Q.normalizeParams(e)})}var nk=x("ZodTransform",(t,e)=>{Gc.init(t,e),ke.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(Q.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!0),r.issues.push(Q.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function ch(t){return new nk({type:"transform",transform:t})}var uh=x("ZodOptional",(t,e)=>{Qc.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function xe(t){return new uh({type:"optional",innerType:t})}var ok=x("ZodNullable",(t,e)=>{Yc.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function nh(t){return new ok({type:"nullable",innerType:t})}var sk=x("ZodDefault",(t,e)=>{Xc.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function ik(t,e){return new sk({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var ak=x("ZodPrefault",(t,e)=>{eu.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ck(t,e){return new ak({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var lh=x("ZodNonOptional",(t,e)=>{tu.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function uk(t,e){return new lh({type:"nonoptional",innerType:t,...Q.normalizeParams(e)})}var lk=x("ZodCatch",(t,e)=>{ru.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function dk(t,e){return new lk({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var fk=x("ZodPipe",(t,e)=>{nu.init(t,e),ke.init(t,e),t.in=e.in,t.out=e.out});function Xu(t,e){return new fk({type:"pipe",in:t,out:e})}var pk=x("ZodReadonly",(t,e)=>{ou.init(t,e),ke.init(t,e)});function mk(t){return new pk({type:"readonly",innerType:t})}var dh=x("ZodCustom",(t,e)=>{su.init(t,e),ke.init(t,e)});function hk(t){let e=new Ae({check:"custom"});return e._zod.check=t,e}function fh(t,e){return Hu(dh,t??(()=>!0),e)}function gk(t,e={}){return Vu(dh,t,e)}function yk(t){let e=hk(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Q.issue(n,r.value,e._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),o.continue??(o.continue=!e._zod.def.abort),r.issues.push(Q.issue(o))}},t(r.value,r)));return e}function rl(t,e){return Xu(ch(t),e)}nt(Mm());var ol="2025-11-25",ph="2025-03-26",In=[ol,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],_r="io.modelcontextprotocol/related-task",ui="2.0",Ce=fh(t=>t!==null&&(typeof t=="object"||typeof t=="function")),mh=fe([w(),oe().int()]),hh=w(),RI=Le({ttl:fe([oe(),el()]).optional(),pollInterval:oe().optional()}),_k=A({ttl:oe().optional()}),vk=A({taskId:w()}),sl=Le({progressToken:mh.optional(),[_r]:vk.optional()}),st=A({_meta:sl.optional()}),Eo=st.extend({task:_k.optional()}),gh=t=>Eo.safeParse(t).success,Oe=A({method:w(),params:st.loose().optional()}),lt=A({_meta:sl.optional()}),dt=A({method:w(),params:lt.loose().optional()}),Ne=Le({_meta:sl.optional()}),li=fe([w(),oe().int()]),yh=A({jsonrpc:N(ui),id:li,...Oe.shape}).strict(),vr=t=>yh.safeParse(t).success,_h=A({jsonrpc:N(ui),...dt.shape}).strict(),vh=t=>_h.safeParse(t).success,il=A({jsonrpc:N(ui),id:li,result:Ne}).strict(),Yt=t=>il.safeParse(t).success;var M;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(M||(M={}));var al=A({jsonrpc:N(ui),id:li.optional(),error:A({code:oe().int(),message:w(),data:_e().optional()})}).strict();var Mn=t=>al.safeParse(t).success;var cl=fe([yh,_h,il,al]),EI=fe([il,al]),di=Ne.strict(),bk=lt.extend({requestId:li.optional(),reason:w().optional()}),fi=dt.extend({method:N("notifications/cancelled"),params:bk}),wk=A({src:w(),mimeType:w().optional(),sizes:Y(w()).optional(),theme:Ge(["light","dark"]).optional()}),Po=A({icons:Y(wk).optional()}),Nn=A({name:w(),title:w().optional()}),bh=Nn.extend({...Nn.shape,...Po.shape,version:w(),websiteUrl:w().optional(),description:w().optional()}),xk=ai(A({applyDefaults:Ee().optional()}),ve(w(),_e())),kk=rl(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ai(A({form:xk.optional(),url:Ce.optional()}),ve(w(),_e()).optional())),Sk=Le({list:Ce.optional(),cancel:Ce.optional(),requests:Le({sampling:Le({createMessage:Ce.optional()}).optional(),elicitation:Le({create:Ce.optional()}).optional()}).optional()}),$k=Le({list:Ce.optional(),cancel:Ce.optional(),requests:Le({tools:Le({call:Ce.optional()}).optional()}).optional()}),Tk=A({experimental:ve(w(),Ce).optional(),sampling:A({context:Ce.optional(),tools:Ce.optional()}).optional(),elicitation:kk.optional(),roots:A({listChanged:Ee().optional()}).optional(),tasks:Sk.optional()}),zk=st.extend({protocolVersion:w(),capabilities:Tk,clientInfo:bh}),pi=Oe.extend({method:N("initialize"),params:zk}),ul=t=>pi.safeParse(t).success,Rk=A({experimental:ve(w(),Ce).optional(),logging:Ce.optional(),completions:Ce.optional(),prompts:A({listChanged:Ee().optional()}).optional(),resources:A({subscribe:Ee().optional(),listChanged:Ee().optional()}).optional(),tools:A({listChanged:Ee().optional()}).optional(),tasks:$k.optional()}),Ek=Ne.extend({protocolVersion:w(),capabilities:Rk,serverInfo:bh,instructions:w().optional()}),ll=dt.extend({method:N("notifications/initialized"),params:lt.optional()});var mi=Oe.extend({method:N("ping"),params:st.optional()}),Pk=A({progress:oe(),total:xe(oe()),message:xe(w())}),Ak=A({...lt.shape,...Pk.shape,progressToken:mh}),hi=dt.extend({method:N("notifications/progress"),params:Ak}),Ck=st.extend({cursor:hh.optional()}),Ao=Oe.extend({params:Ck.optional()}),Co=Ne.extend({nextCursor:hh.optional()}),Ok=Ge(["working","input_required","completed","failed","cancelled"]),Oo=A({taskId:w(),status:Ok,ttl:fe([oe(),el()]),createdAt:w(),lastUpdatedAt:w(),pollInterval:xe(oe()),statusMessage:xe(w())}),jn=Ne.extend({task:Oo}),Nk=lt.merge(Oo),No=dt.extend({method:N("notifications/tasks/status"),params:Nk}),gi=Oe.extend({method:N("tasks/get"),params:st.extend({taskId:w()})}),yi=Ne.merge(Oo),_i=Oe.extend({method:N("tasks/result"),params:st.extend({taskId:w()})}),PI=Ne.loose(),vi=Ao.extend({method:N("tasks/list")}),bi=Co.extend({tasks:Y(Oo)}),wi=Oe.extend({method:N("tasks/cancel"),params:st.extend({taskId:w()})}),wh=Ne.merge(Oo),xh=A({uri:w(),mimeType:xe(w()),_meta:ve(w(),_e()).optional()}),kh=xh.extend({text:w()}),dl=w().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Sh=xh.extend({blob:dl}),Io=Ge(["user","assistant"]),qn=A({audience:Y(Io).optional(),priority:oe().min(0).max(1).optional(),lastModified:zo.datetime({offset:!0}).optional()}),$h=A({...Nn.shape,...Po.shape,uri:w(),description:xe(w()),mimeType:xe(w()),annotations:qn.optional(),_meta:xe(Le({}))}),Ik=A({...Nn.shape,...Po.shape,uriTemplate:w(),description:xe(w()),mimeType:xe(w()),annotations:qn.optional(),_meta:xe(Le({}))}),xi=Ao.extend({method:N("resources/list")}),Mk=Co.extend({resources:Y($h)}),ki=Ao.extend({method:N("resources/templates/list")}),jk=Co.extend({resourceTemplates:Y(Ik)}),fl=st.extend({uri:w()}),qk=fl,Si=Oe.extend({method:N("resources/read"),params:qk}),Dk=Ne.extend({contents:Y(fe([kh,Sh]))}),Zk=dt.extend({method:N("notifications/resources/list_changed"),params:lt.optional()}),Lk=fl,Uk=Oe.extend({method:N("resources/subscribe"),params:Lk}),Fk=fl,Hk=Oe.extend({method:N("resources/unsubscribe"),params:Fk}),Vk=lt.extend({uri:w()}),Bk=dt.extend({method:N("notifications/resources/updated"),params:Vk}),Kk=A({name:w(),description:xe(w()),required:xe(Ee())}),Jk=A({...Nn.shape,...Po.shape,description:xe(w()),arguments:xe(Y(Kk)),_meta:xe(Le({}))}),$i=Ao.extend({method:N("prompts/list")}),Wk=Co.extend({prompts:Y(Jk)}),Gk=st.extend({name:w(),arguments:ve(w(),w()).optional()}),Ti=Oe.extend({method:N("prompts/get"),params:Gk}),pl=A({type:N("text"),text:w(),annotations:qn.optional(),_meta:ve(w(),_e()).optional()}),ml=A({type:N("image"),data:dl,mimeType:w(),annotations:qn.optional(),_meta:ve(w(),_e()).optional()}),hl=A({type:N("audio"),data:dl,mimeType:w(),annotations:qn.optional(),_meta:ve(w(),_e()).optional()}),Qk=A({type:N("tool_use"),name:w(),id:w(),input:ve(w(),_e()),_meta:ve(w(),_e()).optional()}),Yk=A({type:N("resource"),resource:fe([kh,Sh]),annotations:qn.optional(),_meta:ve(w(),_e()).optional()}),Xk=$h.extend({type:N("resource_link")}),gl=fe([pl,ml,hl,Xk,Yk]),eS=A({role:Io,content:gl}),tS=Ne.extend({description:w().optional(),messages:Y(eS)}),rS=dt.extend({method:N("notifications/prompts/list_changed"),params:lt.optional()}),nS=A({title:w().optional(),readOnlyHint:Ee().optional(),destructiveHint:Ee().optional(),idempotentHint:Ee().optional(),openWorldHint:Ee().optional()}),oS=A({taskSupport:Ge(["required","optional","forbidden"]).optional()}),Th=A({...Nn.shape,...Po.shape,description:w().optional(),inputSchema:A({type:N("object"),properties:ve(w(),Ce).optional(),required:Y(w()).optional()}).catchall(_e()),outputSchema:A({type:N("object"),properties:ve(w(),Ce).optional(),required:Y(w()).optional()}).catchall(_e()).optional(),annotations:nS.optional(),execution:oS.optional(),_meta:ve(w(),_e()).optional()}),zi=Ao.extend({method:N("tools/list")}),sS=Co.extend({tools:Y(Th)}),Ri=Ne.extend({content:Y(gl).default([]),structuredContent:ve(w(),_e()).optional(),isError:Ee().optional()}),AI=Ri.or(Ne.extend({toolResult:_e()})),iS=Eo.extend({name:w(),arguments:ve(w(),_e()).optional()}),Dn=Oe.extend({method:N("tools/call"),params:iS}),aS=dt.extend({method:N("notifications/tools/list_changed"),params:lt.optional()}),CI=A({autoRefresh:Ee().default(!0),debounceMs:oe().int().nonnegative().default(300)}),Mo=Ge(["debug","info","notice","warning","error","critical","alert","emergency"]),cS=st.extend({level:Mo}),yl=Oe.extend({method:N("logging/setLevel"),params:cS}),uS=lt.extend({level:Mo,logger:w().optional(),data:_e()}),lS=dt.extend({method:N("notifications/message"),params:uS}),dS=A({name:w().optional()}),fS=A({hints:Y(dS).optional(),costPriority:oe().min(0).max(1).optional(),speedPriority:oe().min(0).max(1).optional(),intelligencePriority:oe().min(0).max(1).optional()}),pS=A({mode:Ge(["auto","required","none"]).optional()}),mS=A({type:N("tool_result"),toolUseId:w().describe("The unique identifier for the corresponding tool call."),content:Y(gl).default([]),structuredContent:A({}).loose().optional(),isError:Ee().optional(),_meta:ve(w(),_e()).optional()}),hS=tl("type",[pl,ml,hl]),ci=tl("type",[pl,ml,hl,Qk,mS]),gS=A({role:Io,content:fe([ci,Y(ci)]),_meta:ve(w(),_e()).optional()}),yS=Eo.extend({messages:Y(gS),modelPreferences:fS.optional(),systemPrompt:w().optional(),includeContext:Ge(["none","thisServer","allServers"]).optional(),temperature:oe().optional(),maxTokens:oe().int(),stopSequences:Y(w()).optional(),metadata:Ce.optional(),tools:Y(Th).optional(),toolChoice:pS.optional()}),_S=Oe.extend({method:N("sampling/createMessage"),params:yS}),jo=Ne.extend({model:w(),stopReason:xe(Ge(["endTurn","stopSequence","maxTokens"]).or(w())),role:Io,content:hS}),_l=Ne.extend({model:w(),stopReason:xe(Ge(["endTurn","stopSequence","maxTokens","toolUse"]).or(w())),role:Io,content:fe([ci,Y(ci)])}),vS=A({type:N("boolean"),title:w().optional(),description:w().optional(),default:Ee().optional()}),bS=A({type:N("string"),title:w().optional(),description:w().optional(),minLength:oe().optional(),maxLength:oe().optional(),format:Ge(["email","uri","date","date-time"]).optional(),default:w().optional()}),wS=A({type:Ge(["number","integer"]),title:w().optional(),description:w().optional(),minimum:oe().optional(),maximum:oe().optional(),default:oe().optional()}),xS=A({type:N("string"),title:w().optional(),description:w().optional(),enum:Y(w()),default:w().optional()}),kS=A({type:N("string"),title:w().optional(),description:w().optional(),oneOf:Y(A({const:w(),title:w()})),default:w().optional()}),SS=A({type:N("string"),title:w().optional(),description:w().optional(),enum:Y(w()),enumNames:Y(w()).optional(),default:w().optional()}),$S=fe([xS,kS]),TS=A({type:N("array"),title:w().optional(),description:w().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:A({type:N("string"),enum:Y(w())}),default:Y(w()).optional()}),zS=A({type:N("array"),title:w().optional(),description:w().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:A({anyOf:Y(A({const:w(),title:w()}))}),default:Y(w()).optional()}),RS=fe([TS,zS]),ES=fe([SS,$S,RS]),PS=fe([ES,vS,bS,wS]),AS=Eo.extend({mode:N("form").optional(),message:w(),requestedSchema:A({type:N("object"),properties:ve(w(),PS),required:Y(w()).optional()})}),CS=Eo.extend({mode:N("url"),message:w(),elicitationId:w(),url:w().url()}),OS=fe([AS,CS]),NS=Oe.extend({method:N("elicitation/create"),params:OS}),IS=lt.extend({elicitationId:w()}),MS=dt.extend({method:N("notifications/elicitation/complete"),params:IS}),Zn=Ne.extend({action:Ge(["accept","decline","cancel"]),content:rl(t=>t===null?void 0:t,ve(w(),fe([w(),oe(),Ee(),Y(w())])).optional())}),jS=A({type:N("ref/resource"),uri:w()});var qS=A({type:N("ref/prompt"),name:w()}),DS=st.extend({ref:fe([qS,jS]),argument:A({name:w(),value:w()}),context:A({arguments:ve(w(),w()).optional()}).optional()}),Ei=Oe.extend({method:N("completion/complete"),params:DS});function zh(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Rh(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var ZS=Ne.extend({completion:Le({values:Y(w()).max(100),total:xe(oe().int()),hasMore:xe(Ee())})}),LS=A({uri:w().startsWith("file://"),name:w().optional(),_meta:ve(w(),_e()).optional()}),US=Oe.extend({method:N("roots/list"),params:st.optional()}),vl=Ne.extend({roots:Y(LS)}),FS=dt.extend({method:N("notifications/roots/list_changed"),params:lt.optional()}),OI=fe([mi,pi,Ei,yl,Ti,$i,xi,ki,Si,Uk,Hk,Dn,zi,gi,_i,vi,wi]),NI=fe([fi,hi,ll,FS,No]),II=fe([di,jo,_l,Zn,vl,yi,bi,jn]),MI=fe([mi,_S,NS,US,gi,_i,vi,wi]),jI=fe([fi,hi,lS,Bk,Zk,aS,rS,No,MS]),qI=fe([di,Ek,ZS,tS,Wk,Mk,jk,Dk,Ri,sS,yi,bi,jn]),O=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===M.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new nl(o.elicitations,r)}return new t(e,r,n)}},nl=class extends O{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(M.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function br(t){return t==="completed"||t==="failed"||t==="cancelled"}var Ph=Symbol("Let zodToJsonSchema decide on which parser to use");var Eh={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Ah=t=>typeof t=="string"?{...Eh,name:t}:{...Eh,...t};var Ch=t=>{let e=Ah(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function bl(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function X(t,e,r,n,o){t[e]=r,bl(t,e,n,o)}var Pi=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function be(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Pi(e,t.currentPath):e.join("/")}}function Oh(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==$.ZodAny&&(r.items=D(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&X(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&X(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(X(r,"minItems",t.exactLength.value,t.exactLength.message,e),X(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function Nh(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?X(r,"minimum",n.value,n.message,e):X(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),X(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?X(r,"maximum",n.value,n.message,e):X(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),X(r,"maximum",n.value,n.message,e));break;case"multipleOf":X(r,"multipleOf",n.value,n.message,e);break}return r}function Ih(){return{type:"boolean"}}function Ai(t,e){return D(t.type._def,e)}var Mh=(t,e)=>D(t.innerType._def,e);function wl(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>wl(t,e,o))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return HS(t,e)}}var HS=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":X(r,"minimum",n.value,n.message,e);break;case"max":X(r,"maximum",n.value,n.message,e);break}return r};function jh(t,e){return{...D(t.innerType._def,e),default:t.defaultValue()}}function qh(t,e){return e.effectStrategy==="input"?D(t.schema._def,e):be(e)}function Dh(t){return{type:"string",enum:Array.from(t.values)}}var VS=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Zh(t,e){let r=[D(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),D(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(VS(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:a,...c}=s;i=c}else n=void 0;o.push(i)}}),o.length?{allOf:o,...n}:void 0}function Lh(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var xl,wt={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(xl===void 0&&(xl=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),xl),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Ci(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":X(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":X(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":xt(r,"email",n.message,e);break;case"format:idn-email":xt(r,"idn-email",n.message,e);break;case"pattern:zod":Ue(r,wt.email,n.message,e);break}break;case"url":xt(r,"uri",n.message,e);break;case"uuid":xt(r,"uuid",n.message,e);break;case"regex":Ue(r,n.regex,n.message,e);break;case"cuid":Ue(r,wt.cuid,n.message,e);break;case"cuid2":Ue(r,wt.cuid2,n.message,e);break;case"startsWith":Ue(r,RegExp(`^${kl(n.value,e)}`),n.message,e);break;case"endsWith":Ue(r,RegExp(`${kl(n.value,e)}$`),n.message,e);break;case"datetime":xt(r,"date-time",n.message,e);break;case"date":xt(r,"date",n.message,e);break;case"time":xt(r,"time",n.message,e);break;case"duration":xt(r,"duration",n.message,e);break;case"length":X(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),X(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Ue(r,RegExp(kl(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&xt(r,"ipv4",n.message,e),n.version!=="v4"&&xt(r,"ipv6",n.message,e);break}case"base64url":Ue(r,wt.base64url,n.message,e);break;case"jwt":Ue(r,wt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Ue(r,wt.ipv4Cidr,n.message,e),n.version!=="v4"&&Ue(r,wt.ipv6Cidr,n.message,e);break}case"emoji":Ue(r,wt.emoji(),n.message,e);break;case"ulid":{Ue(r,wt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{xt(r,"binary",n.message,e);break}case"contentEncoding:base64":{X(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Ue(r,wt.base64,n.message,e);break}}break}case"nanoid":Ue(r,wt.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function kl(t,e){return e.patternStrategy==="escape"?KS(t):t}var BS=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function KS(t){let e="";for(let r=0;r<t.length;r++)BS.has(t[r])||(e+="\\"),e+=t[r];return e}function xt(t,e,r,n){t.format||t.anyOf?.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):X(t,"format",e,r,n)}function Ue(t,e,r,n){t.pattern||t.allOf?.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:Uh(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):X(t,"pattern",Uh(e,n),r,n)}function Uh(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,o="",s=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(s){o+=n[c],s=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(o+=n[c],o+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(o+=n[c],a=!0):o+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){o+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){o+=`(^|(?<=[\r
|
|
35
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let d=l[1];if(e===l[0]){i(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(e!==l[0]&&m){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(d.cycle){i(l);continue}if(d.count>1&&n.reused==="ref"){i(l);continue}}let a=(l,d)=>{let p=this.seen.get(l),m=p.def??p.schema,f={...m};if(p.ref===null)return;let h=p.ref;if(p.ref=null,h){a(h,d);let g=this.seen.get(h).schema;g.$ref&&d.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(g)):(Object.assign(m,g),Object.assign(m,f))}p.isParent||this.override({zodSchema:l,jsonSchema:m,path:p.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let c={};if(this.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":this.target==="draft-7"?c.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),n.external?.uri){let l=n.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(l)}Object.assign(c,o.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}};function Ju(t,e){if(t instanceof So){let n=new ri(e),o={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let s={},i={registry:t,uri:e?.uri,defs:o};for(let a of t._idmap.entries()){let[c,u]=a;s[c]=n.emit(u,{...e,external:i})}if(Object.keys(o).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}let r=new ri(e);return r.process(t),r.emit(t,e)}function ze(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let o=t._zod.def;switch(o.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":return!1;case"array":return ze(o.element,r);case"object":{for(let s in o.shape)if(ze(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(ze(s,r))return!0;return!1}case"intersection":return ze(o.left,r)||ze(o.right,r);case"tuple":{for(let s of o.items)if(ze(s,r))return!0;return!!(o.rest&&ze(o.rest,r))}case"record":return ze(o.keyType,r)||ze(o.valueType,r);case"map":return ze(o.keyType,r)||ze(o.valueType,r);case"set":return ze(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return ze(o.innerType,r);case"lazy":return ze(o.getter(),r);case"default":return ze(o.innerType,r);case"prefault":return ze(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return ze(o.in,r)||ze(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}var x0=x("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");ae.init(t,e),t.def=e,t.parse=(r,n)=>fc(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Xr(t,r,n),t.parseAsync=async(r,n)=>mc(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>en(t,r,n),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>ot(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var k0=x("ZodMiniObject",(t,e)=>{Js.init(t,e),x0.init(t,e),Q.defineLazy(t,"shape",()=>e.shape)});function Wu(t,e){let r={type:"object",get shape(){return Q.assignProp(this,"shape",{...t}),this.shape},...Q.normalizeParams(e)};return new k0(r)}function ut(t){return!!t._zod}function nn(t){let e=Object.values(t);if(e.length===0)return Wu({});let r=e.every(ut),n=e.every(o=>!ut(o));if(r)return Wu(t);if(n)return Ya(t);throw new Error("Mixed Zod versions detected in object shape.")}function gr(t,e){return ut(t)?Xr(t,e):t.safeParse(e)}async function ni(t,e){return ut(t)?await en(t,e):await t.safeParseAsync(e)}function yr(t){if(!t)return;let e;if(ut(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function On(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return nn(t)}}if(ut(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function oi(t){if(t&&typeof t=="object"){if("message"in t&&typeof t.message=="string")return t.message;if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0){let e=t.issues[0];if(e&&typeof e=="object"&&"message"in e)return String(e.message)}try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function Km(t){return t.description}function Jm(t){if(ut(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function si(t){if(ut(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var zo={};Os(zo,{ZodISODate:()=>Gm,ZodISODateTime:()=>Wm,ZodISODuration:()=>Ym,ZodISOTime:()=>Qm,date:()=>Qu,datetime:()=>Gu,duration:()=>Xu,time:()=>Yu});var Wm=x("ZodISODateTime",(t,e)=>{Nm.init(t,e),ye.init(t,e)});function Gu(t){return Lm(Wm,t)}var Gm=x("ZodISODate",(t,e)=>{Im.init(t,e),ye.init(t,e)});function Qu(t){return Um(Gm,t)}var Qm=x("ZodISOTime",(t,e)=>{Mm.init(t,e),ye.init(t,e)});function Yu(t){return Fm(Qm,t)}var Ym=x("ZodISODuration",(t,e)=>{jm.init(t,e),ye.init(t,e)});function Xu(t){return Hm(Ym,t)}var Xm=(t,e)=>{Fs.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>lc(t,r)},flatten:{value:r=>uc(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},bI=x("ZodError",Xm),Ro=x("ZodError",Xm,{Parent:Error});var eh=dc(Ro),th=pc(Ro),rh=hc(Ro),nh=gc(Ro);var ke=x("ZodType",(t,e)=>(ae.init(t,e),t.def=e,Object.defineProperty(t,"_def",{value:e}),t.check=(...r)=>t.clone({...e,checks:[...e.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),t.clone=(r,n)=>ot(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>eh(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>rh(t,r,n),t.parseAsync=async(r,n)=>th(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>nh(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(bk(r,n)),t.superRefine=r=>t.check(wk(r)),t.overwrite=r=>t.check(tn(r)),t.optional=()=>xe(t),t.nullable=()=>ih(t),t.nullish=()=>xe(ih(t)),t.nonoptional=r=>pk(t,r),t.array=()=>Y(t),t.or=r=>fe([t,r]),t.and=r=>ai(t,r),t.transform=r=>tl(t,dh(r)),t.default=r=>lk(t,r),t.prefault=r=>fk(t,r),t.catch=r=>hk(t,r),t.pipe=r=>tl(t,r),t.readonly=()=>_k(t),t.describe=r=>{let n=t.clone();return hr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return hr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return hr.get(t);let n=t.clone();return hr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),ah=x("_ZodString",(t,e)=>{ko.init(t,e),ke.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(Mu(...n)),t.includes=(...n)=>t.check(Du(...n)),t.startsWith=(...n)=>t.check(Zu(...n)),t.endsWith=(...n)=>t.check(Lu(...n)),t.min=(...n)=>t.check(Cn(...n)),t.max=(...n)=>t.check(ei(...n)),t.length=(...n)=>t.check(ti(...n)),t.nonempty=(...n)=>t.check(Cn(1,...n)),t.lowercase=n=>t.check(ju(n)),t.uppercase=n=>t.check(qu(n)),t.trim=()=>t.check(Fu()),t.normalize=(...n)=>t.check(Uu(...n)),t.toLowerCase=()=>t.check(Hu()),t.toUpperCase=()=>t.check(Vu())}),C0=x("ZodString",(t,e)=>{ko.init(t,e),ah.init(t,e),t.email=r=>t.check(uu(O0,r)),t.url=r=>t.check(mu(N0,r)),t.jwt=r=>t.check(Eu(W0,r)),t.emoji=r=>t.check(hu(I0,r)),t.guid=r=>t.check(Gs(oh,r)),t.uuid=r=>t.check(lu(ii,r)),t.uuidv4=r=>t.check(du(ii,r)),t.uuidv6=r=>t.check(fu(ii,r)),t.uuidv7=r=>t.check(pu(ii,r)),t.nanoid=r=>t.check(gu(M0,r)),t.guid=r=>t.check(Gs(oh,r)),t.cuid=r=>t.check(yu(j0,r)),t.cuid2=r=>t.check(_u(q0,r)),t.ulid=r=>t.check(vu(D0,r)),t.base64=r=>t.check(Tu(B0,r)),t.base64url=r=>t.check(zu(K0,r)),t.xid=r=>t.check(bu(Z0,r)),t.ksuid=r=>t.check(wu(L0,r)),t.ipv4=r=>t.check(xu(U0,r)),t.ipv6=r=>t.check(ku(F0,r)),t.cidrv4=r=>t.check(Su(H0,r)),t.cidrv6=r=>t.check($u(V0,r)),t.e164=r=>t.check(Ru(J0,r)),t.datetime=r=>t.check(Gu(r)),t.date=r=>t.check(Qu(r)),t.time=r=>t.check(Yu(r)),t.duration=r=>t.check(Xu(r))});function w(t){return cu(C0,t)}var ye=x("ZodStringFormat",(t,e)=>{de.init(t,e),ah.init(t,e)}),O0=x("ZodEmail",(t,e)=>{Sc.init(t,e),ye.init(t,e)});var oh=x("ZodGUID",(t,e)=>{xc.init(t,e),ye.init(t,e)});var ii=x("ZodUUID",(t,e)=>{kc.init(t,e),ye.init(t,e)});var N0=x("ZodURL",(t,e)=>{$c.init(t,e),ye.init(t,e)});var I0=x("ZodEmoji",(t,e)=>{Tc.init(t,e),ye.init(t,e)});var M0=x("ZodNanoID",(t,e)=>{zc.init(t,e),ye.init(t,e)});var j0=x("ZodCUID",(t,e)=>{Rc.init(t,e),ye.init(t,e)});var q0=x("ZodCUID2",(t,e)=>{Ec.init(t,e),ye.init(t,e)});var D0=x("ZodULID",(t,e)=>{Pc.init(t,e),ye.init(t,e)});var Z0=x("ZodXID",(t,e)=>{Ac.init(t,e),ye.init(t,e)});var L0=x("ZodKSUID",(t,e)=>{Cc.init(t,e),ye.init(t,e)});var U0=x("ZodIPv4",(t,e)=>{Oc.init(t,e),ye.init(t,e)});var F0=x("ZodIPv6",(t,e)=>{Nc.init(t,e),ye.init(t,e)});var H0=x("ZodCIDRv4",(t,e)=>{Ic.init(t,e),ye.init(t,e)});var V0=x("ZodCIDRv6",(t,e)=>{Mc.init(t,e),ye.init(t,e)});var B0=x("ZodBase64",(t,e)=>{jc.init(t,e),ye.init(t,e)});var K0=x("ZodBase64URL",(t,e)=>{qc.init(t,e),ye.init(t,e)});var J0=x("ZodE164",(t,e)=>{Dc.init(t,e),ye.init(t,e)});var W0=x("ZodJWT",(t,e)=>{Zc.init(t,e),ye.init(t,e)});var ch=x("ZodNumber",(t,e)=>{Ks.init(t,e),ke.init(t,e),t.gt=(n,o)=>t.check(Ys(n,o)),t.gte=(n,o)=>t.check(To(n,o)),t.min=(n,o)=>t.check(To(n,o)),t.lt=(n,o)=>t.check(Qs(n,o)),t.lte=(n,o)=>t.check($o(n,o)),t.max=(n,o)=>t.check($o(n,o)),t.int=n=>t.check(sh(n)),t.safe=n=>t.check(sh(n)),t.positive=n=>t.check(Ys(0,n)),t.nonnegative=n=>t.check(To(0,n)),t.negative=n=>t.check(Qs(0,n)),t.nonpositive=n=>t.check($o(0,n)),t.multipleOf=(n,o)=>t.check(Xs(n,o)),t.step=(n,o)=>t.check(Xs(n,o)),t.finite=()=>t;let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function oe(t){return Pu(ch,t)}var G0=x("ZodNumberFormat",(t,e)=>{Lc.init(t,e),ch.init(t,e)});function sh(t){return Au(G0,t)}var Q0=x("ZodBoolean",(t,e)=>{Uc.init(t,e),ke.init(t,e)});function Ee(t){return Cu(Q0,t)}var Y0=x("ZodNull",(t,e)=>{Fc.init(t,e),ke.init(t,e)});function rl(t){return Ou(Y0,t)}var X0=x("ZodUnknown",(t,e)=>{Hc.init(t,e),ke.init(t,e)});function _e(){return Nu(X0)}var ek=x("ZodNever",(t,e)=>{Vc.init(t,e),ke.init(t,e)});function tk(t){return Iu(ek,t)}var rk=x("ZodArray",(t,e)=>{Bc.init(t,e),ke.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Cn(r,n)),t.nonempty=r=>t.check(Cn(1,r)),t.max=(r,n)=>t.check(ei(r,n)),t.length=(r,n)=>t.check(ti(r,n)),t.unwrap=()=>t.element});function Y(t,e){return Vm(rk,t,e)}var uh=x("ZodObject",(t,e)=>{Js.init(t,e),ke.init(t,e),Q.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Ge(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:_e()}),t.loose=()=>t.clone({...t._zod.def,catchall:_e()}),t.strict=()=>t.clone({...t._zod.def,catchall:tk()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>Q.extend(t,r),t.merge=r=>Q.merge(t,r),t.pick=r=>Q.pick(t,r),t.omit=r=>Q.omit(t,r),t.partial=(...r)=>Q.partial(fh,t,r[0]),t.required=(...r)=>Q.required(ph,t,r[0])});function A(t,e){let r={type:"object",get shape(){return Q.assignProp(this,"shape",{...t}),this.shape},...Q.normalizeParams(e)};return new uh(r)}function Le(t,e){return new uh({type:"object",get shape(){return Q.assignProp(this,"shape",{...t}),this.shape},catchall:_e(),...Q.normalizeParams(e)})}var lh=x("ZodUnion",(t,e)=>{Ws.init(t,e),ke.init(t,e),t.options=e.options});function fe(t,e){return new lh({type:"union",options:t,...Q.normalizeParams(e)})}var nk=x("ZodDiscriminatedUnion",(t,e)=>{lh.init(t,e),Kc.init(t,e)});function nl(t,e,r){return new nk({type:"union",options:e,discriminator:t,...Q.normalizeParams(r)})}var ok=x("ZodIntersection",(t,e)=>{Jc.init(t,e),ke.init(t,e)});function ai(t,e){return new ok({type:"intersection",left:t,right:e})}var sk=x("ZodRecord",(t,e)=>{Wc.init(t,e),ke.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function ve(t,e,r){return new sk({type:"record",keyType:t,valueType:e,...Q.normalizeParams(r)})}var el=x("ZodEnum",(t,e)=>{Gc.init(t,e),ke.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new el({...e,checks:[],...Q.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new el({...e,checks:[],...Q.normalizeParams(o),entries:s})}});function Ge(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new el({type:"enum",entries:r,...Q.normalizeParams(e)})}var ik=x("ZodLiteral",(t,e)=>{Qc.init(t,e),ke.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function N(t,e){return new ik({type:"literal",values:Array.isArray(t)?t:[t],...Q.normalizeParams(e)})}var ak=x("ZodTransform",(t,e)=>{Yc.init(t,e),ke.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(Q.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!0),r.issues.push(Q.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function dh(t){return new ak({type:"transform",transform:t})}var fh=x("ZodOptional",(t,e)=>{Xc.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function xe(t){return new fh({type:"optional",innerType:t})}var ck=x("ZodNullable",(t,e)=>{eu.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ih(t){return new ck({type:"nullable",innerType:t})}var uk=x("ZodDefault",(t,e)=>{tu.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function lk(t,e){return new uk({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var dk=x("ZodPrefault",(t,e)=>{ru.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function fk(t,e){return new dk({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var ph=x("ZodNonOptional",(t,e)=>{nu.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType});function pk(t,e){return new ph({type:"nonoptional",innerType:t,...Q.normalizeParams(e)})}var mk=x("ZodCatch",(t,e)=>{ou.init(t,e),ke.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function hk(t,e){return new mk({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var gk=x("ZodPipe",(t,e)=>{su.init(t,e),ke.init(t,e),t.in=e.in,t.out=e.out});function tl(t,e){return new gk({type:"pipe",in:t,out:e})}var yk=x("ZodReadonly",(t,e)=>{iu.init(t,e),ke.init(t,e)});function _k(t){return new yk({type:"readonly",innerType:t})}var mh=x("ZodCustom",(t,e)=>{au.init(t,e),ke.init(t,e)});function vk(t){let e=new Ae({check:"custom"});return e._zod.check=t,e}function hh(t,e){return Bu(mh,t??(()=>!0),e)}function bk(t,e={}){return Ku(mh,t,e)}function wk(t){let e=vk(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Q.issue(n,r.value,e._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),o.continue??(o.continue=!e._zod.def.abort),r.issues.push(Q.issue(o))}},t(r.value,r)));return e}function ol(t,e){return tl(dh(t),e)}nt(Dm());var il="2025-11-25",gh="2025-03-26",In=[il,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],_r="io.modelcontextprotocol/related-task",ui="2.0",Ce=hh(t=>t!==null&&(typeof t=="object"||typeof t=="function")),yh=fe([w(),oe().int()]),_h=w(),NI=Le({ttl:fe([oe(),rl()]).optional(),pollInterval:oe().optional()}),xk=A({ttl:oe().optional()}),kk=A({taskId:w()}),al=Le({progressToken:yh.optional(),[_r]:kk.optional()}),st=A({_meta:al.optional()}),Eo=st.extend({task:xk.optional()}),vh=t=>Eo.safeParse(t).success,Oe=A({method:w(),params:st.loose().optional()}),lt=A({_meta:al.optional()}),dt=A({method:w(),params:lt.loose().optional()}),Ne=Le({_meta:al.optional()}),li=fe([w(),oe().int()]),bh=A({jsonrpc:N(ui),id:li,...Oe.shape}).strict(),vr=t=>bh.safeParse(t).success,wh=A({jsonrpc:N(ui),...dt.shape}).strict(),xh=t=>wh.safeParse(t).success,cl=A({jsonrpc:N(ui),id:li,result:Ne}).strict(),Yt=t=>cl.safeParse(t).success;var M;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(M||(M={}));var ul=A({jsonrpc:N(ui),id:li.optional(),error:A({code:oe().int(),message:w(),data:_e().optional()})}).strict();var Mn=t=>ul.safeParse(t).success;var ll=fe([bh,wh,cl,ul]),II=fe([cl,ul]),di=Ne.strict(),Sk=lt.extend({requestId:li.optional(),reason:w().optional()}),fi=dt.extend({method:N("notifications/cancelled"),params:Sk}),$k=A({src:w(),mimeType:w().optional(),sizes:Y(w()).optional(),theme:Ge(["light","dark"]).optional()}),Po=A({icons:Y($k).optional()}),Nn=A({name:w(),title:w().optional()}),kh=Nn.extend({...Nn.shape,...Po.shape,version:w(),websiteUrl:w().optional(),description:w().optional()}),Tk=ai(A({applyDefaults:Ee().optional()}),ve(w(),_e())),zk=ol(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ai(A({form:Tk.optional(),url:Ce.optional()}),ve(w(),_e()).optional())),Rk=Le({list:Ce.optional(),cancel:Ce.optional(),requests:Le({sampling:Le({createMessage:Ce.optional()}).optional(),elicitation:Le({create:Ce.optional()}).optional()}).optional()}),Ek=Le({list:Ce.optional(),cancel:Ce.optional(),requests:Le({tools:Le({call:Ce.optional()}).optional()}).optional()}),Pk=A({experimental:ve(w(),Ce).optional(),sampling:A({context:Ce.optional(),tools:Ce.optional()}).optional(),elicitation:zk.optional(),roots:A({listChanged:Ee().optional()}).optional(),tasks:Rk.optional()}),Ak=st.extend({protocolVersion:w(),capabilities:Pk,clientInfo:kh}),pi=Oe.extend({method:N("initialize"),params:Ak}),dl=t=>pi.safeParse(t).success,Ck=A({experimental:ve(w(),Ce).optional(),logging:Ce.optional(),completions:Ce.optional(),prompts:A({listChanged:Ee().optional()}).optional(),resources:A({subscribe:Ee().optional(),listChanged:Ee().optional()}).optional(),tools:A({listChanged:Ee().optional()}).optional(),tasks:Ek.optional()}),Ok=Ne.extend({protocolVersion:w(),capabilities:Ck,serverInfo:kh,instructions:w().optional()}),fl=dt.extend({method:N("notifications/initialized"),params:lt.optional()});var mi=Oe.extend({method:N("ping"),params:st.optional()}),Nk=A({progress:oe(),total:xe(oe()),message:xe(w())}),Ik=A({...lt.shape,...Nk.shape,progressToken:yh}),hi=dt.extend({method:N("notifications/progress"),params:Ik}),Mk=st.extend({cursor:_h.optional()}),Ao=Oe.extend({params:Mk.optional()}),Co=Ne.extend({nextCursor:_h.optional()}),jk=Ge(["working","input_required","completed","failed","cancelled"]),Oo=A({taskId:w(),status:jk,ttl:fe([oe(),rl()]),createdAt:w(),lastUpdatedAt:w(),pollInterval:xe(oe()),statusMessage:xe(w())}),jn=Ne.extend({task:Oo}),qk=lt.merge(Oo),No=dt.extend({method:N("notifications/tasks/status"),params:qk}),gi=Oe.extend({method:N("tasks/get"),params:st.extend({taskId:w()})}),yi=Ne.merge(Oo),_i=Oe.extend({method:N("tasks/result"),params:st.extend({taskId:w()})}),MI=Ne.loose(),vi=Ao.extend({method:N("tasks/list")}),bi=Co.extend({tasks:Y(Oo)}),wi=Oe.extend({method:N("tasks/cancel"),params:st.extend({taskId:w()})}),Sh=Ne.merge(Oo),$h=A({uri:w(),mimeType:xe(w()),_meta:ve(w(),_e()).optional()}),Th=$h.extend({text:w()}),pl=w().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),zh=$h.extend({blob:pl}),Io=Ge(["user","assistant"]),qn=A({audience:Y(Io).optional(),priority:oe().min(0).max(1).optional(),lastModified:zo.datetime({offset:!0}).optional()}),Rh=A({...Nn.shape,...Po.shape,uri:w(),description:xe(w()),mimeType:xe(w()),annotations:qn.optional(),_meta:xe(Le({}))}),Dk=A({...Nn.shape,...Po.shape,uriTemplate:w(),description:xe(w()),mimeType:xe(w()),annotations:qn.optional(),_meta:xe(Le({}))}),xi=Ao.extend({method:N("resources/list")}),Zk=Co.extend({resources:Y(Rh)}),ki=Ao.extend({method:N("resources/templates/list")}),Lk=Co.extend({resourceTemplates:Y(Dk)}),ml=st.extend({uri:w()}),Uk=ml,Si=Oe.extend({method:N("resources/read"),params:Uk}),Fk=Ne.extend({contents:Y(fe([Th,zh]))}),Hk=dt.extend({method:N("notifications/resources/list_changed"),params:lt.optional()}),Vk=ml,Bk=Oe.extend({method:N("resources/subscribe"),params:Vk}),Kk=ml,Jk=Oe.extend({method:N("resources/unsubscribe"),params:Kk}),Wk=lt.extend({uri:w()}),Gk=dt.extend({method:N("notifications/resources/updated"),params:Wk}),Qk=A({name:w(),description:xe(w()),required:xe(Ee())}),Yk=A({...Nn.shape,...Po.shape,description:xe(w()),arguments:xe(Y(Qk)),_meta:xe(Le({}))}),$i=Ao.extend({method:N("prompts/list")}),Xk=Co.extend({prompts:Y(Yk)}),eS=st.extend({name:w(),arguments:ve(w(),w()).optional()}),Ti=Oe.extend({method:N("prompts/get"),params:eS}),hl=A({type:N("text"),text:w(),annotations:qn.optional(),_meta:ve(w(),_e()).optional()}),gl=A({type:N("image"),data:pl,mimeType:w(),annotations:qn.optional(),_meta:ve(w(),_e()).optional()}),yl=A({type:N("audio"),data:pl,mimeType:w(),annotations:qn.optional(),_meta:ve(w(),_e()).optional()}),tS=A({type:N("tool_use"),name:w(),id:w(),input:ve(w(),_e()),_meta:ve(w(),_e()).optional()}),rS=A({type:N("resource"),resource:fe([Th,zh]),annotations:qn.optional(),_meta:ve(w(),_e()).optional()}),nS=Rh.extend({type:N("resource_link")}),_l=fe([hl,gl,yl,nS,rS]),oS=A({role:Io,content:_l}),sS=Ne.extend({description:w().optional(),messages:Y(oS)}),iS=dt.extend({method:N("notifications/prompts/list_changed"),params:lt.optional()}),aS=A({title:w().optional(),readOnlyHint:Ee().optional(),destructiveHint:Ee().optional(),idempotentHint:Ee().optional(),openWorldHint:Ee().optional()}),cS=A({taskSupport:Ge(["required","optional","forbidden"]).optional()}),Eh=A({...Nn.shape,...Po.shape,description:w().optional(),inputSchema:A({type:N("object"),properties:ve(w(),Ce).optional(),required:Y(w()).optional()}).catchall(_e()),outputSchema:A({type:N("object"),properties:ve(w(),Ce).optional(),required:Y(w()).optional()}).catchall(_e()).optional(),annotations:aS.optional(),execution:cS.optional(),_meta:ve(w(),_e()).optional()}),zi=Ao.extend({method:N("tools/list")}),uS=Co.extend({tools:Y(Eh)}),Ri=Ne.extend({content:Y(_l).default([]),structuredContent:ve(w(),_e()).optional(),isError:Ee().optional()}),jI=Ri.or(Ne.extend({toolResult:_e()})),lS=Eo.extend({name:w(),arguments:ve(w(),_e()).optional()}),Dn=Oe.extend({method:N("tools/call"),params:lS}),dS=dt.extend({method:N("notifications/tools/list_changed"),params:lt.optional()}),qI=A({autoRefresh:Ee().default(!0),debounceMs:oe().int().nonnegative().default(300)}),Mo=Ge(["debug","info","notice","warning","error","critical","alert","emergency"]),fS=st.extend({level:Mo}),vl=Oe.extend({method:N("logging/setLevel"),params:fS}),pS=lt.extend({level:Mo,logger:w().optional(),data:_e()}),mS=dt.extend({method:N("notifications/message"),params:pS}),hS=A({name:w().optional()}),gS=A({hints:Y(hS).optional(),costPriority:oe().min(0).max(1).optional(),speedPriority:oe().min(0).max(1).optional(),intelligencePriority:oe().min(0).max(1).optional()}),yS=A({mode:Ge(["auto","required","none"]).optional()}),_S=A({type:N("tool_result"),toolUseId:w().describe("The unique identifier for the corresponding tool call."),content:Y(_l).default([]),structuredContent:A({}).loose().optional(),isError:Ee().optional(),_meta:ve(w(),_e()).optional()}),vS=nl("type",[hl,gl,yl]),ci=nl("type",[hl,gl,yl,tS,_S]),bS=A({role:Io,content:fe([ci,Y(ci)]),_meta:ve(w(),_e()).optional()}),wS=Eo.extend({messages:Y(bS),modelPreferences:gS.optional(),systemPrompt:w().optional(),includeContext:Ge(["none","thisServer","allServers"]).optional(),temperature:oe().optional(),maxTokens:oe().int(),stopSequences:Y(w()).optional(),metadata:Ce.optional(),tools:Y(Eh).optional(),toolChoice:yS.optional()}),xS=Oe.extend({method:N("sampling/createMessage"),params:wS}),jo=Ne.extend({model:w(),stopReason:xe(Ge(["endTurn","stopSequence","maxTokens"]).or(w())),role:Io,content:vS}),bl=Ne.extend({model:w(),stopReason:xe(Ge(["endTurn","stopSequence","maxTokens","toolUse"]).or(w())),role:Io,content:fe([ci,Y(ci)])}),kS=A({type:N("boolean"),title:w().optional(),description:w().optional(),default:Ee().optional()}),SS=A({type:N("string"),title:w().optional(),description:w().optional(),minLength:oe().optional(),maxLength:oe().optional(),format:Ge(["email","uri","date","date-time"]).optional(),default:w().optional()}),$S=A({type:Ge(["number","integer"]),title:w().optional(),description:w().optional(),minimum:oe().optional(),maximum:oe().optional(),default:oe().optional()}),TS=A({type:N("string"),title:w().optional(),description:w().optional(),enum:Y(w()),default:w().optional()}),zS=A({type:N("string"),title:w().optional(),description:w().optional(),oneOf:Y(A({const:w(),title:w()})),default:w().optional()}),RS=A({type:N("string"),title:w().optional(),description:w().optional(),enum:Y(w()),enumNames:Y(w()).optional(),default:w().optional()}),ES=fe([TS,zS]),PS=A({type:N("array"),title:w().optional(),description:w().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:A({type:N("string"),enum:Y(w())}),default:Y(w()).optional()}),AS=A({type:N("array"),title:w().optional(),description:w().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:A({anyOf:Y(A({const:w(),title:w()}))}),default:Y(w()).optional()}),CS=fe([PS,AS]),OS=fe([RS,ES,CS]),NS=fe([OS,kS,SS,$S]),IS=Eo.extend({mode:N("form").optional(),message:w(),requestedSchema:A({type:N("object"),properties:ve(w(),NS),required:Y(w()).optional()})}),MS=Eo.extend({mode:N("url"),message:w(),elicitationId:w(),url:w().url()}),jS=fe([IS,MS]),qS=Oe.extend({method:N("elicitation/create"),params:jS}),DS=lt.extend({elicitationId:w()}),ZS=dt.extend({method:N("notifications/elicitation/complete"),params:DS}),Zn=Ne.extend({action:Ge(["accept","decline","cancel"]),content:ol(t=>t===null?void 0:t,ve(w(),fe([w(),oe(),Ee(),Y(w())])).optional())}),LS=A({type:N("ref/resource"),uri:w()});var US=A({type:N("ref/prompt"),name:w()}),FS=st.extend({ref:fe([US,LS]),argument:A({name:w(),value:w()}),context:A({arguments:ve(w(),w()).optional()}).optional()}),Ei=Oe.extend({method:N("completion/complete"),params:FS});function Ph(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Ah(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var HS=Ne.extend({completion:Le({values:Y(w()).max(100),total:xe(oe().int()),hasMore:xe(Ee())})}),VS=A({uri:w().startsWith("file://"),name:w().optional(),_meta:ve(w(),_e()).optional()}),BS=Oe.extend({method:N("roots/list"),params:st.optional()}),wl=Ne.extend({roots:Y(VS)}),KS=dt.extend({method:N("notifications/roots/list_changed"),params:lt.optional()}),DI=fe([mi,pi,Ei,vl,Ti,$i,xi,ki,Si,Bk,Jk,Dn,zi,gi,_i,vi,wi]),ZI=fe([fi,hi,fl,KS,No]),LI=fe([di,jo,bl,Zn,wl,yi,bi,jn]),UI=fe([mi,xS,qS,BS,gi,_i,vi,wi]),FI=fe([fi,hi,mS,Gk,Hk,dS,iS,No,ZS]),HI=fe([di,Ok,HS,sS,Xk,Zk,Lk,Fk,Ri,uS,yi,bi,jn]),O=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===M.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new sl(o.elicitations,r)}return new t(e,r,n)}},sl=class extends O{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(M.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function br(t){return t==="completed"||t==="failed"||t==="cancelled"}var Oh=Symbol("Let zodToJsonSchema decide on which parser to use");var Ch={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Nh=t=>typeof t=="string"?{...Ch,name:t}:{...Ch,...t};var Ih=t=>{let e=Nh(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,o])=>[o._def,{def:o._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function xl(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function X(t,e,r,n,o){t[e]=r,xl(t,e,n,o)}var Pi=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function be(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?Pi(e,t.currentPath):e.join("/")}}function Mh(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==$.ZodAny&&(r.items=D(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&X(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&X(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(X(r,"minItems",t.exactLength.value,t.exactLength.message,e),X(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function jh(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?X(r,"minimum",n.value,n.message,e):X(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),X(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?X(r,"maximum",n.value,n.message,e):X(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),X(r,"maximum",n.value,n.message,e));break;case"multipleOf":X(r,"multipleOf",n.value,n.message,e);break}return r}function qh(){return{type:"boolean"}}function Ai(t,e){return D(t.type._def,e)}var Dh=(t,e)=>D(t.innerType._def,e);function kl(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>kl(t,e,o))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return JS(t,e)}}var JS=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":X(r,"minimum",n.value,n.message,e);break;case"max":X(r,"maximum",n.value,n.message,e);break}return r};function Zh(t,e){return{...D(t.innerType._def,e),default:t.defaultValue()}}function Lh(t,e){return e.effectStrategy==="input"?D(t.schema._def,e):be(e)}function Uh(t){return{type:"string",enum:Array.from(t.values)}}var WS=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Fh(t,e){let r=[D(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),D(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(WS(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:a,...c}=s;i=c}else n=void 0;o.push(i)}}),o.length?{allOf:o,...n}:void 0}function Hh(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}var Sl,wt={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Sl===void 0&&(Sl=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Sl),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Ci(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":X(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":X(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":xt(r,"email",n.message,e);break;case"format:idn-email":xt(r,"idn-email",n.message,e);break;case"pattern:zod":Ue(r,wt.email,n.message,e);break}break;case"url":xt(r,"uri",n.message,e);break;case"uuid":xt(r,"uuid",n.message,e);break;case"regex":Ue(r,n.regex,n.message,e);break;case"cuid":Ue(r,wt.cuid,n.message,e);break;case"cuid2":Ue(r,wt.cuid2,n.message,e);break;case"startsWith":Ue(r,RegExp(`^${$l(n.value,e)}`),n.message,e);break;case"endsWith":Ue(r,RegExp(`${$l(n.value,e)}$`),n.message,e);break;case"datetime":xt(r,"date-time",n.message,e);break;case"date":xt(r,"date",n.message,e);break;case"time":xt(r,"time",n.message,e);break;case"duration":xt(r,"duration",n.message,e);break;case"length":X(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),X(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Ue(r,RegExp($l(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&xt(r,"ipv4",n.message,e),n.version!=="v4"&&xt(r,"ipv6",n.message,e);break}case"base64url":Ue(r,wt.base64url,n.message,e);break;case"jwt":Ue(r,wt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Ue(r,wt.ipv4Cidr,n.message,e),n.version!=="v4"&&Ue(r,wt.ipv6Cidr,n.message,e);break}case"emoji":Ue(r,wt.emoji(),n.message,e);break;case"ulid":{Ue(r,wt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{xt(r,"binary",n.message,e);break}case"contentEncoding:base64":{X(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Ue(r,wt.base64,n.message,e);break}}break}case"nanoid":Ue(r,wt.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function $l(t,e){return e.patternStrategy==="escape"?QS(t):t}var GS=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function QS(t){let e="";for(let r=0;r<t.length;r++)GS.has(t[r])||(e+="\\"),e+=t[r];return e}function xt(t,e,r,n){t.format||t.anyOf?.some(o=>o.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):X(t,"format",e,r,n)}function Ue(t,e,r,n){t.pattern||t.allOf?.some(o=>o.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:Vh(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):X(t,"pattern",Vh(e,n),r,n)}function Vh(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,o="",s=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(s){o+=n[c],s=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(o+=n[c],o+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(o+=n[c],a=!0):o+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){o+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){o+=`(^|(?<=[\r
|
|
36
36
|
]))`;continue}else if(n[c]==="$"){o+=`($|(?=[\r
|
|
37
37
|
]))`;continue}}if(r.s&&n[c]==="."){o+=i?`${n[c]}\r
|
|
38
38
|
`:`[${n[c]}\r
|
|
39
|
-
]`;continue}o+=n[c],n[c]==="\\"?s=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return o}function Oi(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===$.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,o)=>({...n,[o]:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??be(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===$.ZodString&&t.keyType._def.checks?.length){let{type:n,...o}=Ci(t.keyType._def,e);return{...r,propertyNames:o}}else{if(t.keyType?._def.typeName===$.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===$.ZodBranded&&t.keyType._def.type._def.typeName===$.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...o}=Ai(t.keyType._def,e);return{...r,propertyNames:o}}}return r}function Fh(t,e){if(e.mapStrategy==="record")return Oi(t,e);let r=D(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||be(e),n=D(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||be(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function Hh(t){let e=t.values,n=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}function Vh(t){return t.target==="openAi"?void 0:{not:be({...t,currentPath:[...t.currentPath,"not"]})}}function Bh(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var qo={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Jh(t,e){if(e.target==="openApi3")return Kh(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in qo&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let i=qo[s._def.typeName];return i&&!o.includes(i)?[...o,i]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,s)=>{let i=typeof s._def.value;switch(i){case"string":case"number":case"boolean":return[...o,i];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];default:return o}},[]);if(n.length===r.length){let o=n.filter((s,i,a)=>a.indexOf(s)===i);return{type:o.length>1?o:o[0],enum:r.reduce((s,i)=>s.includes(i._def.value)?s:[...s,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return Kh(t,e)}var Kh=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,o)=>D(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function Wh(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:qo[t.innerType._def.typeName],nullable:!0}:{type:[qo[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=D(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=D(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function Gh(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",bl(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?X(r,"minimum",n.value,n.message,e):X(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),X(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?X(r,"maximum",n.value,n.message,e):X(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),X(r,"maximum",n.value,n.message,e));break;case"multipleOf":X(r,"multipleOf",n.value,n.message,e);break}return r}function Qh(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},o=[],s=t.shape();for(let a in s){let c=s[a];if(c===void 0||c._def===void 0)continue;let u=WS(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=D(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||o.push(a))}o.length&&(n.required=o);let i=JS(t,e);return i!==void 0&&(n.additionalProperties=i),n}function JS(t,e){if(t.catchall._def.typeName!=="ZodNever")return D(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function WS(t){try{return t.isOptional()}catch{return!0}}var Yh=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return D(t.innerType._def,e);let r=D(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:be(e)},r]}:be(e)};var Xh=(t,e)=>{if(e.pipeStrategy==="input")return D(t.in._def,e);if(e.pipeStrategy==="output")return D(t.out._def,e);let r=D(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=D(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};function eg(t,e){return D(t.type._def,e)}function tg(t,e){let n={type:"array",uniqueItems:!0,items:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&X(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&X(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function rg(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>D(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:D(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>D(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function ng(t){return{not:be(t)}}function og(t){return be(t)}var sg=(t,e)=>D(t.innerType._def,e);var ig=(t,e,r)=>{switch(e){case $.ZodString:return Ci(t,r);case $.ZodNumber:return Gh(t,r);case $.ZodObject:return Qh(t,r);case $.ZodBigInt:return Nh(t,r);case $.ZodBoolean:return Ih();case $.ZodDate:return wl(t,r);case $.ZodUndefined:return ng(r);case $.ZodNull:return Bh(r);case $.ZodArray:return Oh(t,r);case $.ZodUnion:case $.ZodDiscriminatedUnion:return Jh(t,r);case $.ZodIntersection:return Zh(t,r);case $.ZodTuple:return rg(t,r);case $.ZodRecord:return Oi(t,r);case $.ZodLiteral:return Lh(t,r);case $.ZodEnum:return Dh(t);case $.ZodNativeEnum:return Hh(t);case $.ZodNullable:return Wh(t,r);case $.ZodOptional:return Yh(t,r);case $.ZodMap:return Fh(t,r);case $.ZodSet:return tg(t,r);case $.ZodLazy:return()=>t.getter()._def;case $.ZodPromise:return eg(t,r);case $.ZodNaN:case $.ZodNever:return Vh(r);case $.ZodEffects:return qh(t,r);case $.ZodAny:return be(r);case $.ZodUnknown:return og(r);case $.ZodDefault:return jh(t,r);case $.ZodBranded:return Ai(t,r);case $.ZodReadonly:return sg(t,r);case $.ZodCatch:return Mh(t,r);case $.ZodPipeline:return Xh(t,r);case $.ZodFunction:case $.ZodVoid:case $.ZodSymbol:return;default:return(n=>{})(e)}};function D(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Ph)return a}if(n&&!r){let a=GS(n,e);if(a!==void 0)return a}let o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);let s=ig(t,t.typeName,e),i=typeof s=="function"?D(s(),e):s;if(i&&QS(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var GS=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Pi(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),be(e)):e.$refStrategy==="seen"?be(e):void 0}},QS=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var Sl=(t,e)=>{let r=Ch(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:D(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??be(r)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=D(t._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??be(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(s.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=o===void 0?n?{...s,[r.definitionPath]:n}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:s}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function YS(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function $l(t,e){return ut(t)?Bu(t,{target:YS(e?.target),io:e?.pipeStrategy??"input"}):Sl(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Tl(t){let r=yr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=si(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function zl(t,e){let r=gr(t,e);if(!r.success)throw r.error;return r.data}var XS=6e4,Ni=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(fi,r=>{this._oncancel(r)}),this.setNotificationHandler(hi,r=>{this._onprogress(r)}),this.setRequestHandler(mi,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(gi,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(M.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(_i,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new O(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new O(M.InvalidParams,`Task not found: ${s}`);if(!br(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(br(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[_r]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(vi,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new O(M.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(wi,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(M.InvalidParams,`Task not found: ${r.params.taskId}`);if(br(o.status))throw new O(M.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new O(M.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof O?o:new O(M.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),O.fromError(M.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new 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 r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Yt(s)||Mn(s)?this._onresponse(s):vr(s)?this._onrequest(s,i):vh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=O.fromError(M.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[_r]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:M.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=gh(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new O(M.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let f=m.relatedTask?.taskId??s;return f&&c&&await c.updateTaskStatus(f,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:M.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Yt(e))n(e);else{let i=new O(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Yt(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Yt(e))o(e);else{let i=O.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof O?i:new O(M.InternalError,String(i))}}return}let s;try{let i=await this.request(e,jn,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new O(M.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},br(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new O(M.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new O(M.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof O?i:new O(M.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=b=>{l(b)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(b){d(b);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[_r]:c}});let f=b=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(b)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));let k=b instanceof O?b:new O(M.RequestTimeout,String(b));l(k)};this._responseHandlers.set(p,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return l(b);try{let k=gr(r,b.result);k.success?u(k.data):l(k.error)}catch(k){l(k)}}}),n?.signal?.addEventListener("abort",()=>{f(n?.signal?.reason)});let h=n?.timeout??XS,g=()=>f(O.fromError(M.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(p,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let b=k=>{let T=this._responseHandlers.get(p);T?T(k):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,b),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(k=>{this._cleanupTimeout(p),l(k)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(b=>{this._cleanupTimeout(p),l(b)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},yi,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},bi,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},wh,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[_r]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.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 a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[_r]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[_r]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=Tl(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=zl(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=Tl(e);this._notificationHandlers.set(n,o=>{let s=zl(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&vr(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new O(M.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new O(M.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new O(M.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new O(M.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=No.parse({method:"notifications/tasks/status",params:a});await this.notification(c),br(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new O(M.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(br(a.status))throw new O(M.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=No.parse({method:"notifications/tasks/status",params:c});await this.notification(u),br(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function ag(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function cg(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];ag(i)&&ag(s)?r[o]={...i,...s}:r[o]=s}return r}var J_=gp(pf(),1),W_=gp(K_(),1);function FP(){let t=new J_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,W_.default)(t),t}var ya=class{constructor(e){this._ajv=e??FP()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var _a=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},jo,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},Zn,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function G_(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function Q_(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var va=class extends Ni{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Mo.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new ya,this.setRequestHandler(pi,n=>this._oninitialize(n)),this.setNotificationHandler(ll,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(yl,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Mo.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new _a(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=cg(this._capabilities,e)}setRequestHandler(e,r){let o=yr(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(ut(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=gr(Dn,c);if(!l.success){let f=l.error instanceof Error?l.error.message:String(l.error);throw new O(M.InvalidParams,`Invalid tools/call request: ${f}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let f=gr(jn,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new O(M.InvalidParams,`Invalid task creation result: ${h}`)}return f.data}let m=gr(Ri,p);if(!m.success){let f=m.error instanceof Error?m.error.message:String(m.error);throw new O(M.InvalidParams,`Invalid tools/call result: ${f}`)}return m.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){Q_(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&G_(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:In.includes(r)?r:ol,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},di)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},_l,r):this.request({method:"sampling/createMessage",params:e},jo,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},Zn,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Zn,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new O(M.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof O?i:new O(M.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},vl,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var X_=Symbol.for("mcp.completable");function wf(t){return!!t&&typeof t=="object"&&X_ in t}function ev(t){return t[X_]?.complete}var Y_;(function(t){t.Completable="McpCompletable"})(Y_||(Y_={}));var ba=class t{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,n){if(e.length>r)throw new Error(`${n} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){t.validateLength(e,1e6,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){let r=[],n="",o=0,s=0;for(;o<e.length;)if(e[o]==="{"){n&&(r.push(n),n="");let i=e.indexOf("}",o);if(i===-1)throw new Error("Unclosed template expression");if(s++,s>1e4)throw new Error("Template contains too many expressions (max 10000)");let a=e.slice(o+1,i),c=this.getOperator(a),u=a.includes("*"),l=this.getNames(a),d=l[0];for(let p of l)t.validateLength(p,1e6,"Variable name");r.push({name:d,operator:c,names:l,exploded:u}),o=i+1}else n+=e[o],o++;return n&&r.push(n),r}getOperator(e){return["+","#",".","/","?","&"].find(n=>e.startsWith(n))||""}getNames(e){let r=this.getOperator(e);return e.slice(r.length).split(",").map(n=>n.replace("*","").trim()).filter(n=>n.length>0)}encodeValue(e,r){return t.validateLength(e,1e6,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){let i=e.names.map(c=>{let u=r[c];if(u===void 0)return"";let l=Array.isArray(u)?u.map(d=>this.encodeValue(d,e.operator)).join(","):this.encodeValue(u.toString(),e.operator);return`${c}=${l}`}).filter(c=>c.length>0);return i.length===0?"":(e.operator==="?"?"?":"&")+i.join("&")}if(e.names.length>1){let i=e.names.map(a=>r[a]).filter(a=>a!==void 0);return i.length===0?"":i.map(a=>Array.isArray(a)?a[0]:a).join(",")}let n=r[e.name];if(n===void 0)return"";let s=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return s.join(",");case"+":return s.join(",");case"#":return"#"+s.join(",");case".":return"."+s.join(".");case"/":return"/"+s.join("/");default:return s.join(",")}}expand(e){let r="",n=!1;for(let o of this.parts){if(typeof o=="string"){r+=o;continue}let s=this.expandPart(o,e);s&&((o.operator==="?"||o.operator==="&")&&n?r+=s.replace("?","&"):r+=s,(o.operator==="?"||o.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){let r=[];for(let s of e.names)t.validateLength(s,1e6,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let s=0;s<e.names.length;s++){let i=e.names[s],a=s===0?"\\"+e.operator:"&";r.push({pattern:a+this.escapeRegExp(i)+"=([^&]+)",name:i})}return r}let n,o=e.name;switch(e.operator){case"":n=e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":n="(.+)";break;case".":n="\\.([^/,]+)";break;case"/":n="/"+(e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:n="([^/]+)"}return r.push({pattern:n,name:o}),r}match(e){t.validateLength(e,1e6,"URI");let r="^",n=[];for(let a of this.parts)if(typeof a=="string")r+=this.escapeRegExp(a);else{let c=this.partToRegExp(a);for(let{pattern:u,name:l}of c)r+=u,n.push({name:l,exploded:a.exploded})}r+="$",t.validateLength(r,1e6,"Generated regex pattern");let o=new RegExp(r),s=e.match(o);if(!s)return null;let i={};for(let a=0;a<n.length;a++){let{name:c,exploded:u}=n[a],l=s[a+1],d=c.replace("*","");u&&l.includes(",")?i[d]=l.split(","):i[d]=l}return i}};var HP=/^[A-Za-z0-9._-]{1,128}$/;function VP(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!HP.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,s)=>s.indexOf(n)===o);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function BP(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function xf(t){let e=VP(t);return BP(t,e.warnings),e.isValid}var wa=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};var xa=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new va(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new wa(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Er(zi)),this.server.assertCanSetRequestHandler(Er(Dn)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(zi,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let o=On(r.inputSchema);return o?$l(o,{strictUnions:!0,pipeStrategy:"input"}):KP})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=On(r.outputSchema);o&&(n.outputSchema=$l(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Dn,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new O(M.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new O(M.InvalidParams,`Tool ${e.params.name} disabled`);let o=!!e.params.task,s=n.execution?.taskSupport,i="createTask"in n.handler;if((s==="required"||s==="optional")&&!i)throw new O(M.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new O(M.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(s==="optional"&&!o&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof O&&n.code===M.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let s=On(e.inputSchema)??e.inputSchema,i=await ni(s,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=oi(a);throw new O(M.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new O(M.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=On(e.outputSchema),s=await ni(o,r.structuredContent);if(!s.success){let i="error"in s?s.error:"Unknown error",a=oi(i);throw new O(M.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let o=e.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,i))}else{let a=o;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=o;return await Promise.resolve(i(r,n))}else{let i=o;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(e,r.params.arguments,r.params.name),s=e.handler,i={...n,taskStore:n.taskStore},a=o?await Promise.resolve(s.createTask(o,i)):await Promise.resolve(s.createTask(i)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(p=>setTimeout(p,l));let d=await n.taskStore.getTask(c);if(!d)throw new O(M.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Er(Ei)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ei,async e=>{switch(e.params.ref.type){case"ref/prompt":return zh(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Rh(e),this.handleResourceCompletion(e,e.params.ref);default:throw new O(M.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new O(M.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new O(M.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return ms;let s=yr(n.argsSchema)?.[e.params.argument.name];if(!wf(s))return ms;let i=ev(s);if(!i)return ms;let a=await i(e.params.argument.value,e.params.context);return rv(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return ms;throw new O(M.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(e.params.argument.name);if(!o)return ms;let s=await o(e.params.argument.value,e.params.context);return rv(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Er(xi)),this.server.assertCanSetRequestHandler(Er(ki)),this.server.assertCanSetRequestHandler(Er(Si)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(xi,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([s,i])=>i.enabled).map(([s,i])=>({uri:s,name:i.name,...i.metadata})),o=[];for(let s of Object.values(this._registeredResourceTemplates)){if(!s.resourceTemplate.listCallback)continue;let i=await s.resourceTemplate.listCallback(r);for(let a of i.resources)o.push({...s.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(ki,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Si,async(e,r)=>{let n=new URL(e.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new O(M.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let s of Object.values(this._registeredResourceTemplates)){let i=s.resourceTemplate.uriTemplate.match(n.toString());if(i)return s.readCallback(n,i,r)}throw new O(M.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Er($i)),this.server.assertCanSetRequestHandler(Er(Ti)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler($i,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?WP(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ti,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new O(M.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new O(M.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let o=On(n.argsSchema),s=await ni(o,e.params.arguments);if(!s.success){let c="error"in s?s.error:"Unknown error",u=oi(c);throw new O(M.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let i=s.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let s=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,r,n,o,s){let i={name:e,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,o,s){let i={resourceTemplate:n,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=i)),typeof u.title<"u"&&(i.title=u.title),typeof u.template<"u"&&(i.resourceTemplate=u.template),typeof u.metadata<"u"&&(i.metadata=u.metadata),typeof u.callback<"u"&&(i.readCallback=u.callback),typeof u.enabled<"u"&&(i.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,o,s){let i={title:r,description:n,argsSchema:o===void 0?void 0:nn(o),callback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=nn(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,o&&Object.values(o).some(c=>{let u=c instanceof Je?c._def?.innerType:c;return wf(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,o,s,i,a,c,u){xf(e);let l={title:r,description:n,inputSchema:tv(o),outputSchema:tv(s),annotations:i,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&xf(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=nn(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=nn(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,o,s,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];kf(c)?(o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!kf(r[0])&&(i=r.shift())):typeof c=="object"&&c!==null&&(i=r.shift())}let a=r[0];return this._createRegisteredTool(e,void 0,n,o,s,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:o,description:s,inputSchema:i,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,o,s,i,a,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let s=r[0],i=this._createRegisteredPrompt(e,void 0,n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:o,description:s,argsSchema:i}=r,a=this._createRegisteredPrompt(e,o,s,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},Lt=class{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new ba(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}},KP={type:"object",properties:{}};function nv(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function JP(t){return"_def"in t||"_zod"in t||nv(t)}function kf(t){return typeof t!="object"||t===null||JP(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(nv)}function tv(t){if(t)return kf(t)?nn(t):t}function WP(t){let e=yr(t);return e?Object.entries(e).map(([r,n])=>{let o=Hm(n),s=Vm(n);return{name:r,description:o,required:!s}}):[]}function Er(t){let r=yr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=si(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function rv(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var ms={completion:{values:[],hasMore:!1}};var Ut=(r=>(r.MARKDOWN="markdown",r.JSON="json",r))(Ut||{}),pe=v.nativeEnum(Ut).default("markdown").describe("Output format: 'markdown' for human-readable or 'json' for machine-readable"),Pr=5e4;function hs(t,e){return function(){return t.apply(e,arguments)}}var{toString:GP}=Object.prototype,{getPrototypeOf:$f}=Object,{iterator:Sa,toStringTag:sv}=Symbol,$a=(t=>e=>{let r=GP.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Rt=t=>(t=t.toLowerCase(),e=>$a(e)===t),Ta=t=>e=>typeof e===t,{isArray:oo}=Array,no=Ta("undefined");function gs(t){return t!==null&&!no(t)&&t.constructor!==null&&!no(t.constructor)&&tt(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var iv=Rt("ArrayBuffer");function QP(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&iv(t.buffer),e}var YP=Ta("string"),tt=Ta("function"),av=Ta("number"),ys=t=>t!==null&&typeof t=="object",XP=t=>t===!0||t===!1,ka=t=>{if($a(t)!=="object")return!1;let e=$f(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(sv in t)&&!(Sa in t)},eA=t=>{if(!ys(t)||gs(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},tA=Rt("Date"),rA=Rt("File"),nA=Rt("Blob"),oA=Rt("FileList"),sA=t=>ys(t)&&tt(t.pipe),iA=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||tt(t.append)&&((e=$a(t))==="formdata"||e==="object"&&tt(t.toString)&&t.toString()==="[object FormData]"))},aA=Rt("URLSearchParams"),[cA,uA,lA,dA]=["ReadableStream","Request","Response","Headers"].map(Rt),fA=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _s(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,o;if(typeof t!="object"&&(t=[t]),oo(t))for(n=0,o=t.length;n<o;n++)e.call(null,t[n],n,t);else{if(gs(t))return;let s=r?Object.getOwnPropertyNames(t):Object.keys(t),i=s.length,a;for(n=0;n<i;n++)a=s[n],e.call(null,t[a],a,t)}}function cv(t,e){if(gs(t))return null;e=e.toLowerCase();let r=Object.keys(t),n=r.length,o;for(;n-- >0;)if(o=r[n],e===o.toLowerCase())return o;return null}var hn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,uv=t=>!no(t)&&t!==hn;function Sf(){let{caseless:t,skipUndefined:e}=uv(this)&&this||{},r={},n=(o,s)=>{let i=t&&cv(r,s)||s;ka(r[i])&&ka(o)?r[i]=Sf(r[i],o):ka(o)?r[i]=Sf({},o):oo(o)?r[i]=o.slice():(!e||!no(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&_s(arguments[o],n);return r}var pA=(t,e,r,{allOwnKeys:n}={})=>(_s(e,(o,s)=>{r&&tt(o)?t[s]=hs(o,r):t[s]=o},{allOwnKeys:n}),t),mA=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),hA=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},gA=(t,e,r,n)=>{let o,s,i,a={};if(e=e||{},t==null)return e;do{for(o=Object.getOwnPropertyNames(t),s=o.length;s-- >0;)i=o[s],(!n||n(i,t,e))&&!a[i]&&(e[i]=t[i],a[i]=!0);t=r!==!1&&$f(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},yA=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;let n=t.indexOf(e,r);return n!==-1&&n===r},_A=t=>{if(!t)return null;if(oo(t))return t;let e=t.length;if(!av(e))return null;let r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},vA=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&$f(Uint8Array)),bA=(t,e)=>{let n=(t&&t[Sa]).call(t),o;for(;(o=n.next())&&!o.done;){let s=o.value;e.call(t,s[0],s[1])}},wA=(t,e)=>{let r,n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},xA=Rt("HTMLFormElement"),kA=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),ov=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),SA=Rt("RegExp"),lv=(t,e)=>{let r=Object.getOwnPropertyDescriptors(t),n={};_s(r,(o,s)=>{let i;(i=e(o,s,t))!==!1&&(n[s]=i||o)}),Object.defineProperties(t,n)},$A=t=>{lv(t,(e,r)=>{if(tt(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=t[r];if(tt(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},TA=(t,e)=>{let r={},n=o=>{o.forEach(s=>{r[s]=!0})};return oo(t)?n(t):n(String(t).split(e)),r},zA=()=>{},RA=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function EA(t){return!!(t&&tt(t.append)&&t[sv]==="FormData"&&t[Sa])}var PA=t=>{let e=new Array(10),r=(n,o)=>{if(ys(n)){if(e.indexOf(n)>=0)return;if(gs(n))return n;if(!("toJSON"in n)){e[o]=n;let s=oo(n)?[]:{};return _s(n,(i,a)=>{let c=r(i,o+1);!no(c)&&(s[a]=c)}),e[o]=void 0,s}}return n};return r(t,0)},AA=Rt("AsyncFunction"),CA=t=>t&&(ys(t)||tt(t))&&tt(t.then)&&tt(t.catch),dv=((t,e)=>t?setImmediate:e?((r,n)=>(hn.addEventListener("message",({source:o,data:s})=>{o===hn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),hn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",tt(hn.postMessage)),OA=typeof queueMicrotask<"u"?queueMicrotask.bind(hn):typeof process<"u"&&process.nextTick||dv,NA=t=>t!=null&&tt(t[Sa]),_={isArray:oo,isArrayBuffer:iv,isBuffer:gs,isFormData:iA,isArrayBufferView:QP,isString:YP,isNumber:av,isBoolean:XP,isObject:ys,isPlainObject:ka,isEmptyObject:eA,isReadableStream:cA,isRequest:uA,isResponse:lA,isHeaders:dA,isUndefined:no,isDate:tA,isFile:rA,isBlob:nA,isRegExp:SA,isFunction:tt,isStream:sA,isURLSearchParams:aA,isTypedArray:vA,isFileList:oA,forEach:_s,merge:Sf,extend:pA,trim:fA,stripBOM:mA,inherits:hA,toFlatObject:gA,kindOf:$a,kindOfTest:Rt,endsWith:yA,toArray:_A,forEachEntry:bA,matchAll:wA,isHTMLForm:xA,hasOwnProperty:ov,hasOwnProp:ov,reduceDescriptors:lv,freezeMethods:$A,toObjectSet:TA,toCamelCase:kA,noop:zA,toFiniteNumber:RA,findKey:cv,global:hn,isContextDefined:uv,isSpecCompliantForm:EA,toJSONObject:PA,isAsyncFn:AA,isThenable:CA,setImmediate:dv,asap:OA,isIterable:NA};function so(t,e,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o,this.status=o.status?o.status:null)}_.inherits(so,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_.toJSONObject(this.config),code:this.code,status:this.status}}});var fv=so.prototype,pv={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{pv[t]={value:t}});Object.defineProperties(so,pv);Object.defineProperty(fv,"isAxiosError",{value:!0});so.from=(t,e,r,n,o,s)=>{let i=Object.create(fv);_.toFlatObject(t,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");let a=t&&t.message?t.message:"Error",c=e==null&&t?t.code:e;return so.call(i,a,c,r,n,o),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",s&&Object.assign(i,s),i};var Z=so;var za=null;function Tf(t){return _.isPlainObject(t)||_.isArray(t)}function hv(t){return _.endsWith(t,"[]")?t.slice(0,-2):t}function mv(t,e,r){return t?t.concat(e).map(function(o,s){return o=hv(o),!r&&s?"["+o+"]":o}).join(r?".":""):e}function IA(t){return _.isArray(t)&&!t.some(Tf)}var MA=_.toFlatObject(_,{},null,function(e){return/^is[A-Z]/.test(e)});function jA(t,e,r){if(!_.isObject(t))throw new TypeError("target must be an object");e=e||new(za||FormData),r=_.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,g){return!_.isUndefined(g[h])});let n=r.metaTokens,o=r.visitor||l,s=r.dots,i=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(e);if(!_.isFunction(o))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(_.isDate(f))return f.toISOString();if(_.isBoolean(f))return f.toString();if(!c&&_.isBlob(f))throw new Z("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(f)||_.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,h,g){let y=f;if(f&&!g&&typeof f=="object"){if(_.endsWith(h,"{}"))h=n?h:h.slice(0,-2),f=JSON.stringify(f);else if(_.isArray(f)&&IA(f)||(_.isFileList(f)||_.endsWith(h,"[]"))&&(y=_.toArray(f)))return h=hv(h),y.forEach(function(k,T){!(_.isUndefined(k)||k===null)&&e.append(i===!0?mv([h],T,s):i===null?h:h+"[]",u(k))}),!1}return Tf(f)?!0:(e.append(mv(g,h,s),u(f)),!1)}let d=[],p=Object.assign(MA,{defaultVisitor:l,convertValue:u,isVisitable:Tf});function m(f,h){if(!_.isUndefined(f)){if(d.indexOf(f)!==-1)throw Error("Circular reference detected in "+h.join("."));d.push(f),_.forEach(f,function(y,b){(!(_.isUndefined(y)||y===null)&&o.call(e,y,_.isString(b)?b.trim():b,h,p))===!0&&m(y,h?h.concat(b):[b])}),d.pop()}}if(!_.isObject(t))throw new TypeError("data must be an object");return m(t),e}var Ar=jA;function gv(t){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function yv(t,e){this._pairs=[],t&&Ar(t,this,e)}var _v=yv.prototype;_v.append=function(e,r){this._pairs.push([e,r])};_v.toString=function(e){let r=e?function(n){return e.call(this,n,gv)}:gv;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var Ra=yv;function qA(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function vs(t,e,r){if(!e)return t;let n=r&&r.encode||qA;_.isFunction(r)&&(r={serialize:r});let o=r&&r.serialize,s;if(o?s=o(e,r):s=_.isURLSearchParams(e)?e.toString():new Ra(e,r).toString(n),s){let i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}var zf=class{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){_.forEach(this.handlers,function(n){n!==null&&e(n)})}},Rf=zf;var Ea={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var vv=typeof URLSearchParams<"u"?URLSearchParams:Ra;var bv=typeof FormData<"u"?FormData:null;var wv=typeof Blob<"u"?Blob:null;var xv={isBrowser:!0,classes:{URLSearchParams:vv,FormData:bv,Blob:wv},protocols:["http","https","file","blob","url","data"]};var Af={};Os(Af,{hasBrowserEnv:()=>Pf,hasStandardBrowserEnv:()=>DA,hasStandardBrowserWebWorkerEnv:()=>ZA,navigator:()=>Ef,origin:()=>LA});var Pf=typeof window<"u"&&typeof document<"u",Ef=typeof navigator=="object"&&navigator||void 0,DA=Pf&&(!Ef||["ReactNative","NativeScript","NS"].indexOf(Ef.product)<0),ZA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",LA=Pf&&window.location.href||"http://localhost";var Se={...Af,...xv};function Cf(t,e){return Ar(t,new Se.classes.URLSearchParams,{visitor:function(r,n,o,s){return Se.isNode&&_.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function UA(t){return _.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function FA(t){let e={},r=Object.keys(t),n,o=r.length,s;for(n=0;n<o;n++)s=r[n],e[s]=t[s];return e}function HA(t){function e(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;let a=Number.isFinite(+i),c=s>=r.length;return i=!i&&_.isArray(o)?o.length:i,c?(_.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!_.isObject(o[i]))&&(o[i]=[]),e(r,n,o[i],s)&&_.isArray(o[i])&&(o[i]=FA(o[i])),!a)}if(_.isFormData(t)&&_.isFunction(t.entries)){let r={};return _.forEachEntry(t,(n,o)=>{e(UA(n),o,r,0)}),r}return null}var Pa=HA;function VA(t,e,r){if(_.isString(t))try{return(e||JSON.parse)(t),_.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Of={transitional:Ea,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=_.isObject(e);if(s&&_.isHTMLForm(e)&&(e=new FormData(e)),_.isFormData(e))return o?JSON.stringify(Pa(e)):e;if(_.isArrayBuffer(e)||_.isBuffer(e)||_.isStream(e)||_.isFile(e)||_.isBlob(e)||_.isReadableStream(e))return e;if(_.isArrayBufferView(e))return e.buffer;if(_.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Cf(e,this.formSerializer).toString();if((a=_.isFileList(e))||n.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return Ar(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),VA(e)):e}],transformResponse:[function(e){let r=this.transitional||Of.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(_.isResponse(e)||_.isReadableStream(e))return e;if(e&&_.isString(e)&&(n&&!this.responseType||o)){let i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(e,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Z.from(a,Z.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Se.classes.FormData,Blob:Se.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],t=>{Of.headers[t]={}});var io=Of;var BA=_.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),kv=t=>{let e={},r,n,o;return t&&t.split(`
|
|
40
|
-
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!r||e[r]&&
|
|
41
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){let n=new this(e);return r.forEach(o=>n.set(o)),n}static accessor(e){let n=(this[Sv]=this[Sv]={accessors:{}}).accessors,o=this.prototype;function s(i){let a=bs(i);n[a]||(GA(o,i),n[a]=!0)}return _.isArray(e)?e.forEach(s):s(e),this}};ao.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);_.reduceDescriptors(ao.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}});_.freezeMethods(ao);var Re=ao;function ws(t,e){let r=this||io,n=e||r,o=Re.from(n.headers),s=n.data;return _.forEach(t,function(a){s=a.call(r,s,o.normalize(),e?e.status:void 0)}),o.normalize(),s}function xs(t){return!!(t&&t.__CANCEL__)}function $v(t,e,r){Z.call(this,t??"canceled",Z.ERR_CANCELED,e,r),this.name="CanceledError"}_.inherits($v,Z,{__CANCEL__:!0});var Ft=$v;function ks(t,e,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new Z("Request failed with status code "+r.status,[Z.ERR_BAD_REQUEST,Z.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function If(t){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function QA(t,e){t=t||10;let r=new Array(t),n=new Array(t),o=0,s=0,i;return e=e!==void 0?e:1e3,function(c){let u=Date.now(),l=n[s];i||(i=u),r[o]=c,n[o]=u;let d=s,p=0;for(;d!==o;)p+=r[d++],d=d%t;if(o=(o+1)%t,o===s&&(s=(s+1)%t),u-i<e)return;let m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}var Tv=QA;function YA(t,e){let r=0,n=1e3/e,o,s,i=(u,l=Date.now())=>{r=l,o=null,s&&(clearTimeout(s),s=null),t(...u)};return[(...u)=>{let l=Date.now(),d=l-r;d>=n?i(u,l):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-d)))},()=>o&&i(o)]}var zv=YA;var co=(t,e,r=3)=>{let n=0,o=Tv(50,250);return zv(s=>{let i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-n,u=o(c),l=i<=a;n=i;let d={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&l?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(d)},r)},Mf=(t,e)=>{let r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},jf=t=>(...e)=>_.asap(()=>t(...e));var Rv=Se.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,Se.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(Se.origin),Se.navigator&&/(msie|trident)/i.test(Se.navigator.userAgent)):()=>!0;var Ev=Se.hasStandardBrowserEnv?{write(t,e,r,n,o,s,i){if(typeof document>"u")return;let a=[`${t}=${encodeURIComponent(e)}`];_.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),_.isString(n)&&a.push(`path=${n}`),_.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),_.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(t){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function qf(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Df(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Ss(t,e,r){let n=!qf(e);return t&&(n||r==!1)?Df(t,e):e}var Pv=t=>t instanceof Re?{...t}:t;function Et(t,e){e=e||{};let r={};function n(u,l,d,p){return _.isPlainObject(u)&&_.isPlainObject(l)?_.merge.call({caseless:p},u,l):_.isPlainObject(l)?_.merge({},l):_.isArray(l)?l.slice():l}function o(u,l,d,p){if(_.isUndefined(l)){if(!_.isUndefined(u))return n(void 0,u,d,p)}else return n(u,l,d,p)}function s(u,l){if(!_.isUndefined(l))return n(void 0,l)}function i(u,l){if(_.isUndefined(l)){if(!_.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,d){if(d in e)return n(u,l);if(d in t)return n(void 0,u)}let c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,l,d)=>o(Pv(u),Pv(l),d,!0)};return _.forEach(Object.keys({...t,...e}),function(l){let d=c[l]||o,p=d(t[l],e[l],l);_.isUndefined(p)&&d!==a||(r[l]=p)}),r}var Ca=t=>{let e=Et({},t),{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=e;if(e.headers=i=Re.from(i),e.url=vs(Ss(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),_.isFormData(r)){if(Se.hasStandardBrowserEnv||Se.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(_.isFunction(r.getHeaders)){let c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([l,d])=>{u.includes(l.toLowerCase())&&i.set(l,d)})}}if(Se.hasStandardBrowserEnv&&(n&&_.isFunction(n)&&(n=n(e)),n||n!==!1&&Rv(e.url))){let c=o&&s&&Ev.read(s);c&&i.set(o,c)}return e};var XA=typeof XMLHttpRequest<"u",Av=XA&&function(t){return new Promise(function(r,n){let o=Ca(t),s=o.data,i=Re.from(o.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,l,d,p,m,f;function h(){m&&m(),f&&f(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function y(){if(!g)return;let k=Re.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),R={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:k,config:t,request:g};ks(function(ie){r(ie),h()},function(ie){n(ie),h()},R),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(n(new Z("Request aborted",Z.ECONNABORTED,t,g)),g=null)},g.onerror=function(T){let R=T&&T.message?T.message:"Network Error",me=new Z(R,Z.ERR_NETWORK,t,g);me.event=T||null,n(me),g=null},g.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",R=o.transitional||Ea;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),n(new Z(T,R.clarifyTimeoutError?Z.ETIMEDOUT:Z.ECONNABORTED,t,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&_.forEach(i.toJSON(),function(T,R){g.setRequestHeader(R,T)}),_.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([p,f]=co(u,!0),g.addEventListener("progress",p)),c&&g.upload&&([d,m]=co(c),g.upload.addEventListener("progress",d),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=k=>{g&&(n(!k||k.type?new Ft(null,t,g):k),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));let b=If(o.url);if(b&&Se.protocols.indexOf(b)===-1){n(new Z("Unsupported protocol "+b+":",Z.ERR_BAD_REQUEST,t));return}g.send(s||null)})};var eC=(t,e)=>{let{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,o,s=function(u){if(!o){o=!0,a();let l=u instanceof Error?u:this.reason;n.abort(l instanceof Z?l:new Ft(l instanceof Error?l.message:l))}},i=e&&setTimeout(()=>{i=null,s(new Z(`timeout ${e} of ms exceeded`,Z.ETIMEDOUT))},e),a=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),t=null)};t.forEach(u=>u.addEventListener("abort",s));let{signal:c}=n;return c.unsubscribe=()=>_.asap(a),c}},Cv=eC;var tC=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,o;for(;n<r;)o=n+e,yield t.slice(n,o),n=o},rC=async function*(t,e){for await(let r of nC(t))yield*tC(r,e)},nC=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)break;yield n}}finally{await e.cancel()}},Zf=(t,e,r,n)=>{let o=rC(t,e),s=0,i,a=c=>{i||(i=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await o.next();if(u){a(),c.close();return}let d=l.byteLength;if(r){let p=s+=d;r(p)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})};var Ov=64*1024,{isFunction:Oa}=_,oC=(({Request:t,Response:e})=>({Request:t,Response:e}))(_.global),{ReadableStream:Nv,TextEncoder:Iv}=_.global,Mv=(t,...e)=>{try{return!!t(...e)}catch{return!1}},sC=t=>{t=_.merge.call({skipUndefined:!0},oC,t);let{fetch:e,Request:r,Response:n}=t,o=e?Oa(e):typeof fetch=="function",s=Oa(r),i=Oa(n);if(!o)return!1;let a=o&&Oa(Nv),c=o&&(typeof Iv=="function"?(f=>h=>f.encode(h))(new Iv):async f=>new Uint8Array(await new r(f).arrayBuffer())),u=s&&a&&Mv(()=>{let f=!1,h=new r(Se.origin,{body:new Nv,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!h}),l=i&&a&&Mv(()=>_.isReadableStream(new n("").body)),d={stream:l&&(f=>f.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!d[f]&&(d[f]=(h,g)=>{let y=h&&h[f];if(y)return y.call(h);throw new Z(`Response type '${f}' is not supported`,Z.ERR_NOT_SUPPORT,g)})});let p=async f=>{if(f==null)return 0;if(_.isBlob(f))return f.size;if(_.isSpecCompliantForm(f))return(await new r(Se.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(_.isArrayBufferView(f)||_.isArrayBuffer(f))return f.byteLength;if(_.isURLSearchParams(f)&&(f=f+""),_.isString(f))return(await c(f)).byteLength},m=async(f,h)=>{let g=_.toFiniteNumber(f.getContentLength());return g??p(h)};return async f=>{let{url:h,method:g,data:y,signal:b,cancelToken:k,timeout:T,onDownloadProgress:R,onUploadProgress:me,responseType:ie,headers:Ve,withCredentials:Be="same-origin",fetchOptions:ir}=Ca(f),bn=e||fetch;ie=ie?(ie+"").toLowerCase():"text";let Nr=Cv([b,k&&k.toAbortSignal()],T),ar=null,Bt=Nr&&Nr.unsubscribe&&(()=>{Nr.unsubscribe()}),fp;try{if(me&&u&&g!=="get"&&g!=="head"&&(fp=await m(Ve,y))!==0){let ur=new r(h,{method:"POST",body:y,duplex:"half"}),wn;if(_.isFormData(y)&&(wn=ur.headers.get("content-type"))&&Ve.setContentType(wn),ur.body){let[Va,Cs]=Mf(fp,co(jf(me)));y=Zf(ur.body,Ov,Va,Cs)}}_.isString(Be)||(Be=Be?"include":"omit");let Pt=s&&"credentials"in r.prototype,pp={...ir,signal:Nr,method:g.toUpperCase(),headers:Ve.normalize().toJSON(),body:y,duplex:"half",credentials:Pt?Be:void 0};ar=s&&new r(h,pp);let cr=await(s?bn(ar,ir):bn(h,pp)),mp=l&&(ie==="stream"||ie==="response");if(l&&(R||mp&&Bt)){let ur={};["status","statusText","headers"].forEach(hp=>{ur[hp]=cr[hp]});let wn=_.toFiniteNumber(cr.headers.get("content-length")),[Va,Cs]=R&&Mf(wn,co(jf(R),!0))||[];cr=new n(Zf(cr.body,Ov,Va,()=>{Cs&&Cs(),Bt&&Bt()}),ur)}ie=ie||"text";let Qb=await d[_.findKey(d,ie)||"text"](cr,f);return!mp&&Bt&&Bt(),await new Promise((ur,wn)=>{ks(ur,wn,{data:Qb,headers:Re.from(cr.headers),status:cr.status,statusText:cr.statusText,config:f,request:ar})})}catch(Pt){throw Bt&&Bt(),Pt&&Pt.name==="TypeError"&&/Load failed|fetch/i.test(Pt.message)?Object.assign(new Z("Network Error",Z.ERR_NETWORK,f,ar),{cause:Pt.cause||Pt}):Z.from(Pt,Pt&&Pt.code,f,ar)}}},iC=new Map,Lf=t=>{let e=t&&t.env||{},{fetch:r,Request:n,Response:o}=e,s=[n,o,r],i=s.length,a=i,c,u,l=iC;for(;a--;)c=s[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:sC(e)),l=u;return u},OL=Lf();var Uf={http:za,xhr:Av,fetch:{get:Lf}};_.forEach(Uf,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});var jv=t=>`- ${t}`,cC=t=>_.isFunction(t)||t===null||t===!1;function uC(t,e){t=_.isArray(t)?t:[t];let{length:r}=t,n,o,s={};for(let i=0;i<r;i++){n=t[i];let a;if(o=n,!cC(n)&&(o=Uf[(a=String(n)).toLowerCase()],o===void 0))throw new Z(`Unknown adapter '${a}'`);if(o&&(_.isFunction(o)||(o=o.get(e))))break;s[a||"#"+i]=o}if(!o){let i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),a=r?i.length>1?`since :
|
|
42
|
-
`+i.map(
|
|
43
|
-
`):" "+
|
|
44
|
-
`+s):n.stack=s}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=Et(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&$s.assertOptions(n,{silentJSONParsing:Ht.transitional(Ht.boolean),forcedJSONParsing:Ht.transitional(Ht.boolean),clarifyTimeoutError:Ht.transitional(Ht.boolean)},!1),o!=null&&(_.isFunction(o)?r.paramsSerializer={serialize:o}:$s.assertOptions(o,{encode:Ht.function,serialize:Ht.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),$s.assertOptions(r,{baseUrl:Ht.spelling("baseURL"),withXsrfToken:Ht.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&_.merge(s.common,s[r.method]);s&&_.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),r.headers=Re.concat(i,s);let a=[],c=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(c=c&&h.synchronous,a.unshift(h.fulfilled,h.rejected))});let u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let l,d=0,p;if(!c){let f=[Ia.bind(this),void 0];for(f.unshift(...a),f.push(...u),p=f.length,l=Promise.resolve(r);d<p;)l=l.then(f[d++],f[d++]);return l}p=a.length;let m=r;for(;d<p;){let f=a[d++],h=a[d++];try{m=f(m)}catch(g){h.call(this,g);break}}try{l=Ia.call(this,m)}catch(f){return Promise.reject(f)}for(d=0,p=u.length;d<p;)l=l.then(u[d++],u[d++]);return l}getUri(e){e=Et(this.defaults,e);let r=Ss(e.baseURL,e.url,e.allowAbsoluteUrls);return vs(r,e.params,e.paramsSerializer)}};_.forEach(["delete","get","head","options"],function(e){uo.prototype[e]=function(r,n){return this.request(Et(n||{},{method:e,url:r,data:(n||{}).data}))}});_.forEach(["post","put","patch"],function(e){function r(n){return function(s,i,a){return this.request(Et(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}uo.prototype[e]=r(),uo.prototype[e+"Form"]=r(!0)});var Ts=uo;var Hf=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});let n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s,i=new Promise(a=>{n.subscribe(a),s=a}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},e(function(s,i,a){n.reason||(n.reason=new Ft(s,i,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new t(function(o){e=o}),cancel:e}}},Dv=Hf;function Vf(t){return function(r){return t.apply(null,r)}}function Bf(t){return _.isObject(t)&&t.isAxiosError===!0}var Kf={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Kf).forEach(([t,e])=>{Kf[e]=t});var Zv=Kf;function Lv(t){let e=new Ts(t),r=hs(Ts.prototype.request,e);return _.extend(r,Ts.prototype,e,{allOwnKeys:!0}),_.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return Lv(Et(t,o))},r}var Te=Lv(io);Te.Axios=Ts;Te.CanceledError=Ft;Te.CancelToken=Dv;Te.isCancel=xs;Te.VERSION=Ma;Te.toFormData=Ar;Te.AxiosError=Z;Te.Cancel=Te.CanceledError;Te.all=function(e){return Promise.all(e)};Te.spread=Vf;Te.isAxiosError=Bf;Te.mergeConfig=Et;Te.AxiosHeaders=Re;Te.formToJSON=t=>Pa(_.isHTMLForm(t)?new FormData(t):t);Te.getAdapter=Na.getAdapter;Te.HttpStatusCode=Zv;Te.default=Te;var Vt=Te;var{Axios:P2,AxiosError:A2,CanceledError:C2,isCancel:O2,CancelToken:N2,VERSION:I2,all:M2,Cancel:j2,isAxiosError:q2,spread:D2,toFormData:Z2,AxiosHeaders:L2,HttpStatusCode:U2,formToJSON:F2,getAdapter:H2,mergeConfig:V2}=Vt;var Cr={portals:[{id:"dati-gov-it",name:"dati.gov.it",api_url:"https://www.dati.gov.it/opendata",api_url_aliases:["https://dati.gov.it/opendata","http://www.dati.gov.it/opendata","http://dati.gov.it/opendata","https://dati.gov.it","https://www.dati.gov.it"],search:{force_text_field:!0},hvd:{category_field:"hvd_category"},sparql:{endpoint_url:"https://lod.dati.gov.it/sparql",method:"GET"},dataset_view_url:"https://www.dati.gov.it/view-dataset/dataset?id={id}",organization_view_url:"https://www.dati.gov.it/view-dataset?organization={name}"},{id:"dati-arpae-it",name:"dati.arpae.it",api_url:"https://dati.arpae.it",api_url_aliases:["http://dati.arpae.it"],search:{force_text_field:!0}},{id:"anac-opendata",name:"dati.anticorruzione.it/opendata",api_url:"https://dati.anticorruzione.it/opendata",api_url_aliases:["http://dati.anticorruzione.it/opendata","https://dati.anticorruzione.it","http://dati.anticorruzione.it"]},{id:"data-gov-uk",name:"data.gov.uk",api_url:"https://data.gov.uk",api_url_aliases:["https://www.data.gov.uk","http://data.gov.uk","http://www.data.gov.uk"],api_path:"/api/action",search:{force_text_field:!0},dataset_view_url:"https://www.data.gov.uk/dataset/{id}/{name}",organization_view_url:"https://www.data.gov.uk/organization/{name}"},{id:"catalog-data-gov",name:"catalog.data.gov",api_url:"https://catalog.data.gov",api_url_aliases:["http://catalog.data.gov"],search:{force_text_field:!0}},{id:"open-canada",name:"open.canada.ca",api_url:"https://open.canada.ca/data",api_url_aliases:["http://open.canada.ca/data","https://open.canada.ca","http://open.canada.ca"],search:{force_text_field:!0}},{id:"data-gov-au",name:"data.gov.au",api_url:"https://data.gov.au",api_url_aliases:["http://data.gov.au","https://www.data.gov.au","http://www.data.gov.au"],dataset_view_url:"https://data.gov.au/data/dataset/{name}",organization_view_url:"https://data.gov.au/data/organization/{name}"},{id:"opendata-swiss",name:"opendata.swiss",api_url:"https://ckan.opendata.swiss",api_url_aliases:["https://opendata.swiss","http://opendata.swiss","https://www.opendata.swiss","http://www.opendata.swiss"]},{id:"data-stadt-zuerich-ch",name:"data.stadt-zuerich.ch",api_url:"https://data.stadt-zuerich.ch",api_url_aliases:["http://data.stadt-zuerich.ch","https://www.data.stadt-zuerich.ch","https://ckan-prod.zurich.datopian.com"],organization_view_url:"https://ckan-prod.zurich.datopian.com/organization/{name}"},{id:"data-gov-ua",name:"data.gov.ua",api_url:"https://data.gov.ua",api_url_aliases:["http://data.gov.ua"],search:{force_text_field:!1}},{id:"dati-regione-sicilia",name:"dati.regione.sicilia.it",api_url:"https://dati.regione.sicilia.it",api_url_aliases:["http://dati.regione.sicilia.it"],search:{force_text_field:!1}},{id:"bdap-rgs-mef",name:"bdap-opendata.rgs.mef.gov.it",api_url:"https://bdap-opendata.rgs.mef.gov.it/SpodCkanApi",api_url_aliases:["http://bdap-opendata.rgs.mef.gov.it/SpodCkanApi"],dataset_view_url:"https://bdap-opendata.rgs.mef.gov.it/SpodCkanApi/dataset/{name}",organization_view_url:"https://bdap-opendata.rgs.mef.gov.it/SpodCkanApi/organization/{name}"},{id:"govdata-de",name:"govdata.de",api_url:"https://ckan.govdata.de",api_url_aliases:["https://www.govdata.de","https://govdata.de","https://www.govdata.de/daten","https://data.gov.de","https://www.data.gov.de"],dataset_view_url:"https://ckan.govdata.de/dataset/{name}",organization_view_url:"https://ckan.govdata.de/organization/{name}"}],defaults:{dataset_view_url:"{server_url}/dataset/{name}",organization_view_url:"{server_url}/organization/{name}",search:{force_text_field:!1}}};function gn(t){return t.replace(/\/$/,"")}function fC(t){try{return new URL(t).hostname}catch{return null}}function or(t){let e=gn(t);return Cr.portals.find(n=>{let o=gn(n.api_url),s=(n.api_url_aliases||[]).map(gn);return o===e||s.includes(e)})||null}function Uv(t){let e=or(t),r=Cr.defaults?.search||{};return{force_text_field:e?.search?.force_text_field??r.force_text_field??!1}}function Fv(t){return or(t)?.search?.force_text_field!==void 0}function Jf(t){return gn(t)}function qa(t){let e=Cr.portals.find(r=>[r.api_url,...r.api_url_aliases||[]].some(o=>fC(o)===t));return e?gn(e.api_url):null}function lo(t){return or(t)?.hvd??null}function Hv(t){let e=gn(t);return Cr.portals.find(n=>n.sparql&&gn(n.sparql.endpoint_url)===e)?.sparql??null}function Vv(t){return or(t)?.sparql??null}function yn(t){return or(t)?.api_path||"/api/3/action"}function Wf(t){return or(t)?.normalize==="multilingual"}var pC=new Set(["package_search","package_show","current_package_list_with_resources","resource_show","organization_show","organization_list","organization_search","group_show","group_list","group_search","tag_list","tag_show","tag_search"]),mC=new Set(["status_show","site_read"]),hC=new Set(["datastore_search","datastore_search_sql"]);function Bv(t,e){return pC.has(t)?300:mC.has(t)?3600:hC.has(t)?60:e}function zs(t){if(typeof process>"u"||!process.env)return;let e=process.env[t];return e===void 0||e===""?void 0:e}function Yf(){let t=zs("CKAN_CACHE_ENABLED"),e=zs("VITEST")==="true",r=t!==void 0?t!=="false":!e,n=Number(zs("CKAN_CACHE_TTL_DEFAULT"))||300,o=Number(zs("CKAN_CACHE_MAX_ENTRIES"))||500,s=Number(zs("CKAN_CACHE_MAX_ENTRY_BYTES"))||1024*1024;return{enabled:r,ttlDefault:n,maxEntries:o,maxEntryBytes:s}}function gC(t){let e=Object.keys(t).sort(),r=[];for(let n of e){let o=t[n];if(o==null)continue;let s=typeof o=="object"?JSON.stringify(o):String(o);r.push(`${n}=${s}`)}return r.join("&")}async function yC(t){let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-1",e),n=new Uint8Array(r),o="";for(let s of n)o+=s.toString(16).padStart(2,"0");return o}async function Kv(t,e,r){let n=`${t}|${e}|${gC(r)}`;return yC(n)}var Gf=class{constructor(e){this.maxEntries=e}store=new Map;async get(e){let r=this.store.get(e);if(r){if(r.expiresAt<=Date.now()){this.store.delete(e);return}return this.store.delete(e),this.store.set(e,r),r.value}}async set(e,r,n){if(!(n<=0))for(this.store.has(e)&&this.store.delete(e),this.store.set(e,{value:r,expiresAt:Date.now()+n*1e3});this.store.size>this.maxEntries;){let o=this.store.keys().next().value;if(o===void 0)break;this.store.delete(o)}}clear(){this.store.clear()}size(){return this.store.size}},Qf=class{origin="https://ckan-mcp-cache.internal";async get(e){try{let r=await caches.default.match(`${this.origin}/${e}`);return r?await r.json():void 0}catch{return}}async set(e,r,n){if(!(n<=0))try{let o=JSON.stringify(r),s=new Response(o,{headers:{"Content-Type":"application/json","Cache-Control":`public, s-maxage=${n}`}});await caches.default.put(`${this.origin}/${e}`,s)}catch{}}},Rs=null;function Jv(){if(Rs)return Rs;let t=typeof caches<"u"&&typeof caches.default<"u",e=typeof process<"u"&&!!process.versions?.node;return t&&!e?Rs=new Qf:Rs=new Gf(Yf().maxEntries),Rs}var ep=class extends Error{constructor(e,r){super(`Rate limit exceeded for ${e}: would need to wait ${Math.round(r)}ms`),this.name="RateLimitError"}},_C=200;function Es(t){if(typeof process>"u"||!process.env)return;let e=process.env[t];return e===void 0||e===""?void 0:e}function rp(){let t=Es("CKAN_RATE_LIMIT_ENABLED"),e=Es("VITEST")==="true";return{enabled:t!==void 0?t!=="false":!e,rps:Number(Es("CKAN_RATE_LIMIT_RPS"))||5,burst:Number(Es("CKAN_RATE_LIMIT_BURST"))||10,maxWaitMs:Number(Es("CKAN_RATE_LIMIT_MAX_WAIT_MS"))||5e3}}function vC(t){return new Promise(e=>setTimeout(e,t))}var tp=class{constructor(e){this.config=e}buckets=new Map;async acquire(e){let{rps:r,burst:n,maxWaitMs:o}=this.config;if(!this.buckets.has(e)){if(this.buckets.size>=_C){let i=this.buckets.keys().next().value;i!==void 0&&this.buckets.delete(i)}this.buckets.set(e,{tokens:n,lastRefill:Date.now()})}let s=0;for(;;){let i=this.buckets.get(e),a=Date.now(),c=a-i.lastRefill;if(i.tokens=Math.min(n,i.tokens+c/1e3*r),i.lastRefill=a,i.tokens>=1){i.tokens-=1;return}let u=(1-i.tokens)/r*1e3;if(s+u>o)throw new ep(e,s+u);await vC(u),s+=u}}clear(){this.buckets.clear()}},Xf=null;function Wv(){return Xf||(Xf=new tp(rp())),Xf}var sr=class extends Error{status;action;constructor(e,r,n){super(e),this.name="CkanApiError",this.status=r,this.action=n}};function we(t,e){if(!(t instanceof sr))return t instanceof Error?t.message:String(t);let{status:r,action:n,message:o}=t,s="";return r===404?n.startsWith("datastore_search")?s="\u2192 Get a valid resource_id first: call `ckan_package_show` on a dataset, then pick a resource where `datastore_active` is true.":n==="package_show"?s="\u2192 Use `ckan_package_search` to find a valid dataset name or ID.":n==="organization_show"&&(s="\u2192 Use `ckan_organization_list` or `ckan_organization_search` to discover valid organization names."):r===400?n==="datastore_search_sql"?s="\u2192 Invalid SQL syntax or unknown column \u2014 check column names with `ckan_datastore_search` before writing SQL.":n.startsWith("datastore_search")&&(s="\u2192 Bad request \u2014 likely an invalid field name or filter syntax; check column names with a `SELECT *` query first."):r===409||r===422?s="\u2192 Portal rejected the request \u2014 parameters may conflict; simplify filters and retry.":r===503||r===502||r===504?s="\u2192 Portal temporarily unavailable \u2014 retry in a few seconds.":r===500?s="\u2192 Portal internal error \u2014 try a different portal or retry later.":r===void 0&&(s="\u2192 The portal may not support this action, or the endpoint is unavailable."),s?`${o}
|
|
45
|
-
${s}`:o}var
|
|
46
|
-
`)}catch{}}async function U(t,e,r={},n={}){let o=typeof process<"u"&&!!process.versions?.node;
|
|
39
|
+
]`;continue}o+=n[c],n[c]==="\\"?s=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return o}function Oi(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===$.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,o)=>({...n,[o]:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??be(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===$.ZodString&&t.keyType._def.checks?.length){let{type:n,...o}=Ci(t.keyType._def,e);return{...r,propertyNames:o}}else{if(t.keyType?._def.typeName===$.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===$.ZodBranded&&t.keyType._def.type._def.typeName===$.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...o}=Ai(t.keyType._def,e);return{...r,propertyNames:o}}}return r}function Bh(t,e){if(e.mapStrategy==="record")return Oi(t,e);let r=D(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||be(e),n=D(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||be(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function Kh(t){let e=t.values,n=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}function Jh(t){return t.target==="openAi"?void 0:{not:be({...t,currentPath:[...t.currentPath,"not"]})}}function Wh(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var qo={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Qh(t,e){if(e.target==="openApi3")return Gh(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in qo&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let i=qo[s._def.typeName];return i&&!o.includes(i)?[...o,i]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,s)=>{let i=typeof s._def.value;switch(i){case"string":case"number":case"boolean":return[...o,i];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];default:return o}},[]);if(n.length===r.length){let o=n.filter((s,i,a)=>a.indexOf(s)===i);return{type:o.length>1?o:o[0],enum:r.reduce((s,i)=>s.includes(i._def.value)?s:[...s,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return Gh(t,e)}var Gh=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,o)=>D(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function Yh(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:qo[t.innerType._def.typeName],nullable:!0}:{type:[qo[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=D(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=D(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function Xh(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",xl(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?X(r,"minimum",n.value,n.message,e):X(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),X(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?X(r,"maximum",n.value,n.message,e):X(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),X(r,"maximum",n.value,n.message,e));break;case"multipleOf":X(r,"multipleOf",n.value,n.message,e);break}return r}function eg(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},o=[],s=t.shape();for(let a in s){let c=s[a];if(c===void 0||c._def===void 0)continue;let u=XS(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=D(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||o.push(a))}o.length&&(n.required=o);let i=YS(t,e);return i!==void 0&&(n.additionalProperties=i),n}function YS(t,e){if(t.catchall._def.typeName!=="ZodNever")return D(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function XS(t){try{return t.isOptional()}catch{return!0}}var tg=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return D(t.innerType._def,e);let r=D(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:be(e)},r]}:be(e)};var rg=(t,e)=>{if(e.pipeStrategy==="input")return D(t.in._def,e);if(e.pipeStrategy==="output")return D(t.out._def,e);let r=D(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=D(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};function ng(t,e){return D(t.type._def,e)}function og(t,e){let n={type:"array",uniqueItems:!0,items:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&X(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&X(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function sg(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>D(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:D(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>D(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function ig(t){return{not:be(t)}}function ag(t){return be(t)}var cg=(t,e)=>D(t.innerType._def,e);var ug=(t,e,r)=>{switch(e){case $.ZodString:return Ci(t,r);case $.ZodNumber:return Xh(t,r);case $.ZodObject:return eg(t,r);case $.ZodBigInt:return jh(t,r);case $.ZodBoolean:return qh();case $.ZodDate:return kl(t,r);case $.ZodUndefined:return ig(r);case $.ZodNull:return Wh(r);case $.ZodArray:return Mh(t,r);case $.ZodUnion:case $.ZodDiscriminatedUnion:return Qh(t,r);case $.ZodIntersection:return Fh(t,r);case $.ZodTuple:return sg(t,r);case $.ZodRecord:return Oi(t,r);case $.ZodLiteral:return Hh(t,r);case $.ZodEnum:return Uh(t);case $.ZodNativeEnum:return Kh(t);case $.ZodNullable:return Yh(t,r);case $.ZodOptional:return tg(t,r);case $.ZodMap:return Bh(t,r);case $.ZodSet:return og(t,r);case $.ZodLazy:return()=>t.getter()._def;case $.ZodPromise:return ng(t,r);case $.ZodNaN:case $.ZodNever:return Jh(r);case $.ZodEffects:return Lh(t,r);case $.ZodAny:return be(r);case $.ZodUnknown:return ag(r);case $.ZodDefault:return Zh(t,r);case $.ZodBranded:return Ai(t,r);case $.ZodReadonly:return cg(t,r);case $.ZodCatch:return Dh(t,r);case $.ZodPipeline:return rg(t,r);case $.ZodFunction:case $.ZodVoid:case $.ZodSymbol:return;default:return(n=>{})(e)}};function D(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Oh)return a}if(n&&!r){let a=e$(n,e);if(a!==void 0)return a}let o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);let s=ug(t,t.typeName,e),i=typeof s=="function"?D(s(),e):s;if(i&&t$(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var e$=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Pi(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),be(e)):e.$refStrategy==="seen"?be(e):void 0}},t$=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var Tl=(t,e)=>{let r=Ih(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:D(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??be(r)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=D(t._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??be(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(s.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let a=o===void 0?n?{...s,[r.definitionPath]:n}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:s}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function r$(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function zl(t,e){return ut(t)?Ju(t,{target:r$(e?.target),io:e?.pipeStrategy??"input"}):Tl(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Rl(t){let r=yr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=si(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function El(t,e){let r=gr(t,e);if(!r.success)throw r.error;return r.data}var n$=6e4,Ni=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(fi,r=>{this._oncancel(r)}),this.setNotificationHandler(hi,r=>{this._onprogress(r)}),this.setRequestHandler(mi,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(gi,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(M.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(_i,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new O(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new O(M.InvalidParams,`Task not found: ${s}`);if(!br(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(br(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[_r]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(vi,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new O(M.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(wi,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(M.InvalidParams,`Task not found: ${r.params.taskId}`);if(br(o.status))throw new O(M.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new O(M.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof O?o:new O(M.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),O.fromError(M.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new 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 r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Yt(s)||Mn(s)?this._onresponse(s):vr(s)?this._onrequest(s,i):xh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=O.fromError(M.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[_r]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:M.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=vh(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new O(M.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let f=m.relatedTask?.taskId??s;return f&&c&&await c.updateTaskStatus(f,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:M.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Yt(e))n(e);else{let i=new O(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Yt(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Yt(e))o(e);else{let i=O.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof O?i:new O(M.InternalError,String(i))}}return}let s;try{let i=await this.request(e,jn,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new O(M.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},br(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new O(M.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new O(M.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof O?i:new O(M.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=b=>{l(b)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(b){d(b);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[_r]:c}});let f=b=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(b)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));let k=b instanceof O?b:new O(M.RequestTimeout,String(b));l(k)};this._responseHandlers.set(p,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return l(b);try{let k=gr(r,b.result);k.success?u(k.data):l(k.error)}catch(k){l(k)}}}),n?.signal?.addEventListener("abort",()=>{f(n?.signal?.reason)});let h=n?.timeout??n$,g=()=>f(O.fromError(M.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(p,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let b=k=>{let T=this._responseHandlers.get(p);T?T(k):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,b),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(k=>{this._cleanupTimeout(p),l(k)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(b=>{this._cleanupTimeout(p),l(b)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},yi,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},bi,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Sh,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[_r]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.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 a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[_r]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[_r]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=Rl(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=El(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=Rl(e);this._notificationHandlers.set(n,o=>{let s=El(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&vr(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new O(M.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new O(M.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new O(M.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new O(M.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=No.parse({method:"notifications/tasks/status",params:a});await this.notification(c),br(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new O(M.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(br(a.status))throw new O(M.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=No.parse({method:"notifications/tasks/status",params:c});await this.notification(u),br(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function lg(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function dg(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];lg(i)&&lg(s)?r[o]={...i,...s}:r[o]=s}return r}var Q_=vp(hf(),1),Y_=vp(G_(),1);function KP(){let t=new Q_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Y_.default)(t),t}var ya=class{constructor(e){this._ajv=e??KP()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var _a=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},jo,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},Zn,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function X_(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function ev(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var va=class extends Ni{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Mo.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new ya,this.setRequestHandler(pi,n=>this._oninitialize(n)),this.setNotificationHandler(fl,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(vl,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Mo.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new _a(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=dg(this._capabilities,e)}setRequestHandler(e,r){let o=yr(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(ut(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=gr(Dn,c);if(!l.success){let f=l.error instanceof Error?l.error.message:String(l.error);throw new O(M.InvalidParams,`Invalid tools/call request: ${f}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let f=gr(jn,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new O(M.InvalidParams,`Invalid task creation result: ${h}`)}return f.data}let m=gr(Ri,p);if(!m.success){let f=m.error instanceof Error?m.error.message:String(m.error);throw new O(M.InvalidParams,`Invalid tools/call result: ${f}`)}return m.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){ev(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&X_(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:In.includes(r)?r:il,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},di)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},bl,r):this.request({method:"sampling/createMessage",params:e},jo,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},Zn,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Zn,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new O(M.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof O?i:new O(M.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},wl,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var rv=Symbol.for("mcp.completable");function kf(t){return!!t&&typeof t=="object"&&rv in t}function nv(t){return t[rv]?.complete}var tv;(function(t){t.Completable="McpCompletable"})(tv||(tv={}));var ba=class t{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,r,n){if(e.length>r)throw new Error(`${n} exceeds maximum length of ${r} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){t.validateLength(e,1e6,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){let r=[],n="",o=0,s=0;for(;o<e.length;)if(e[o]==="{"){n&&(r.push(n),n="");let i=e.indexOf("}",o);if(i===-1)throw new Error("Unclosed template expression");if(s++,s>1e4)throw new Error("Template contains too many expressions (max 10000)");let a=e.slice(o+1,i),c=this.getOperator(a),u=a.includes("*"),l=this.getNames(a),d=l[0];for(let p of l)t.validateLength(p,1e6,"Variable name");r.push({name:d,operator:c,names:l,exploded:u}),o=i+1}else n+=e[o],o++;return n&&r.push(n),r}getOperator(e){return["+","#",".","/","?","&"].find(n=>e.startsWith(n))||""}getNames(e){let r=this.getOperator(e);return e.slice(r.length).split(",").map(n=>n.replace("*","").trim()).filter(n=>n.length>0)}encodeValue(e,r){return t.validateLength(e,1e6,"Variable value"),r==="+"||r==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,r){if(e.operator==="?"||e.operator==="&"){let i=e.names.map(c=>{let u=r[c];if(u===void 0)return"";let l=Array.isArray(u)?u.map(d=>this.encodeValue(d,e.operator)).join(","):this.encodeValue(u.toString(),e.operator);return`${c}=${l}`}).filter(c=>c.length>0);return i.length===0?"":(e.operator==="?"?"?":"&")+i.join("&")}if(e.names.length>1){let i=e.names.map(a=>r[a]).filter(a=>a!==void 0);return i.length===0?"":i.map(a=>Array.isArray(a)?a[0]:a).join(",")}let n=r[e.name];if(n===void 0)return"";let s=(Array.isArray(n)?n:[n]).map(i=>this.encodeValue(i,e.operator));switch(e.operator){case"":return s.join(",");case"+":return s.join(",");case"#":return"#"+s.join(",");case".":return"."+s.join(".");case"/":return"/"+s.join("/");default:return s.join(",")}}expand(e){let r="",n=!1;for(let o of this.parts){if(typeof o=="string"){r+=o;continue}let s=this.expandPart(o,e);s&&((o.operator==="?"||o.operator==="&")&&n?r+=s.replace("?","&"):r+=s,(o.operator==="?"||o.operator==="&")&&(n=!0))}return r}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){let r=[];for(let s of e.names)t.validateLength(s,1e6,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let s=0;s<e.names.length;s++){let i=e.names[s],a=s===0?"\\"+e.operator:"&";r.push({pattern:a+this.escapeRegExp(i)+"=([^&]+)",name:i})}return r}let n,o=e.name;switch(e.operator){case"":n=e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":n="(.+)";break;case".":n="\\.([^/,]+)";break;case"/":n="/"+(e.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:n="([^/]+)"}return r.push({pattern:n,name:o}),r}match(e){t.validateLength(e,1e6,"URI");let r="^",n=[];for(let a of this.parts)if(typeof a=="string")r+=this.escapeRegExp(a);else{let c=this.partToRegExp(a);for(let{pattern:u,name:l}of c)r+=u,n.push({name:l,exploded:a.exploded})}r+="$",t.validateLength(r,1e6,"Generated regex pattern");let o=new RegExp(r),s=e.match(o);if(!s)return null;let i={};for(let a=0;a<n.length;a++){let{name:c,exploded:u}=n[a],l=s[a+1],d=c.replace("*","");u&&l.includes(",")?i[d]=l.split(","):i[d]=l}return i}};var JP=/^[A-Za-z0-9._-]{1,128}$/;function WP(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!JP.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,s)=>s.indexOf(n)===o);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function GP(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function Sf(t){let e=WP(t);return GP(t,e.warnings),e.isValid}var wa=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let o={taskSupport:"required",...r.execution};if(o.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,o,r._meta,n)}};var xa=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new va(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new wa(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Er(zi)),this.server.assertCanSetRequestHandler(Er(Dn)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(zi,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let o=On(r.inputSchema);return o?zl(o,{strictUnions:!0,pipeStrategy:"input"}):QP})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=On(r.outputSchema);o&&(n.outputSchema=zl(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Dn,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new O(M.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new O(M.InvalidParams,`Tool ${e.params.name} disabled`);let o=!!e.params.task,s=n.execution?.taskSupport,i="createTask"in n.handler;if((s==="required"||s==="optional")&&!i)throw new O(M.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new O(M.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(s==="optional"&&!o&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof O&&n.code===M.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let s=On(e.inputSchema)??e.inputSchema,i=await ni(s,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=oi(a);throw new O(M.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new O(M.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=On(e.outputSchema),s=await ni(o,r.structuredContent);if(!s.success){let i="error"in s?s.error:"Unknown error",a=oi(i);throw new O(M.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let o=e.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,i))}else{let a=o;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=o;return await Promise.resolve(i(r,n))}else{let i=o;return await Promise.resolve(i(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let o=await this.validateToolInput(e,r.params.arguments,r.params.name),s=e.handler,i={...n,taskStore:n.taskStore},a=o?await Promise.resolve(s.createTask(o,i)):await Promise.resolve(s.createTask(i)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(p=>setTimeout(p,l));let d=await n.taskStore.getTask(c);if(!d)throw new O(M.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Er(Ei)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ei,async e=>{switch(e.params.ref.type){case"ref/prompt":return Ph(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Ah(e),this.handleResourceCompletion(e,e.params.ref);default:throw new O(M.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new O(M.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new O(M.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return ms;let s=yr(n.argsSchema)?.[e.params.argument.name];if(!kf(s))return ms;let i=nv(s);if(!i)return ms;let a=await i(e.params.argument.value,e.params.context);return sv(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return ms;throw new O(M.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(e.params.argument.name);if(!o)return ms;let s=await o(e.params.argument.value,e.params.context);return sv(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Er(xi)),this.server.assertCanSetRequestHandler(Er(ki)),this.server.assertCanSetRequestHandler(Er(Si)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(xi,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([s,i])=>i.enabled).map(([s,i])=>({uri:s,name:i.name,...i.metadata})),o=[];for(let s of Object.values(this._registeredResourceTemplates)){if(!s.resourceTemplate.listCallback)continue;let i=await s.resourceTemplate.listCallback(r);for(let a of i.resources)o.push({...s.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(ki,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Si,async(e,r)=>{let n=new URL(e.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new O(M.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let s of Object.values(this._registeredResourceTemplates)){let i=s.resourceTemplate.uriTemplate.match(n.toString());if(i)return s.readCallback(n,i,r)}throw new O(M.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Er($i)),this.server.assertCanSetRequestHandler(Er(Ti)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler($i,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?XP(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ti,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new O(M.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new O(M.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let o=On(n.argsSchema),s=await ni(o,e.params.arguments);if(!s.success){let c="error"in s?s.error:"Unknown error",u=oi(c);throw new O(M.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let i=s.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let s=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,r,n,o,s){let i={name:e,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,o,s){let i={resourceTemplate:n,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=i)),typeof u.title<"u"&&(i.title=u.title),typeof u.template<"u"&&(i.resourceTemplate=u.template),typeof u.metadata<"u"&&(i.metadata=u.metadata),typeof u.callback<"u"&&(i.readCallback=u.callback),typeof u.enabled<"u"&&(i.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,o,s){let i={title:r,description:n,argsSchema:o===void 0?void 0:nn(o),callback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=nn(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,o&&Object.values(o).some(c=>{let u=c instanceof Je?c._def?.innerType:c;return kf(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,o,s,i,a,c,u){Sf(e);let l={title:r,description:n,inputSchema:ov(o),outputSchema:ov(s),annotations:i,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&Sf(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=nn(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=nn(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,o,s,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];$f(c)?(o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!$f(r[0])&&(i=r.shift())):typeof c=="object"&&c!==null&&(i=r.shift())}let a=r[0];return this._createRegisteredTool(e,void 0,n,o,s,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:o,description:s,inputSchema:i,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,o,s,i,a,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let o;r.length>1&&(o=r.shift());let s=r[0],i=this._createRegisteredPrompt(e,void 0,n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:o,description:s,argsSchema:i}=r,a=this._createRegisteredPrompt(e,o,s,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}},Lt=class{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new ba(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}},QP={type:"object",properties:{}};function iv(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function YP(t){return"_def"in t||"_zod"in t||iv(t)}function $f(t){return typeof t!="object"||t===null||YP(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(iv)}function ov(t){if(t)return $f(t)?nn(t):t}function XP(t){let e=yr(t);return e?Object.entries(e).map(([r,n])=>{let o=Km(n),s=Jm(n);return{name:r,description:o,required:!s}}):[]}function Er(t){let r=yr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=si(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function sv(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var ms={completion:{values:[],hasMore:!1}};var Ut=(r=>(r.MARKDOWN="markdown",r.JSON="json",r))(Ut||{}),pe=v.nativeEnum(Ut).default("markdown").describe("Output format: 'markdown' for human-readable or 'json' for machine-readable"),Pr=5e4;function hs(t,e){return function(){return t.apply(e,arguments)}}var{toString:eA}=Object.prototype,{getPrototypeOf:zf}=Object,{iterator:Sa,toStringTag:cv}=Symbol,$a=(t=>e=>{let r=eA.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Rt=t=>(t=t.toLowerCase(),e=>$a(e)===t),Ta=t=>e=>typeof e===t,{isArray:oo}=Array,no=Ta("undefined");function gs(t){return t!==null&&!no(t)&&t.constructor!==null&&!no(t.constructor)&&tt(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var uv=Rt("ArrayBuffer");function tA(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&uv(t.buffer),e}var rA=Ta("string"),tt=Ta("function"),lv=Ta("number"),ys=t=>t!==null&&typeof t=="object",nA=t=>t===!0||t===!1,ka=t=>{if($a(t)!=="object")return!1;let e=zf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(cv in t)&&!(Sa in t)},oA=t=>{if(!ys(t)||gs(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},sA=Rt("Date"),iA=Rt("File"),aA=Rt("Blob"),cA=Rt("FileList"),uA=t=>ys(t)&&tt(t.pipe),lA=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||tt(t.append)&&((e=$a(t))==="formdata"||e==="object"&&tt(t.toString)&&t.toString()==="[object FormData]"))},dA=Rt("URLSearchParams"),[fA,pA,mA,hA]=["ReadableStream","Request","Response","Headers"].map(Rt),gA=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function _s(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,o;if(typeof t!="object"&&(t=[t]),oo(t))for(n=0,o=t.length;n<o;n++)e.call(null,t[n],n,t);else{if(gs(t))return;let s=r?Object.getOwnPropertyNames(t):Object.keys(t),i=s.length,a;for(n=0;n<i;n++)a=s[n],e.call(null,t[a],a,t)}}function dv(t,e){if(gs(t))return null;e=e.toLowerCase();let r=Object.keys(t),n=r.length,o;for(;n-- >0;)if(o=r[n],e===o.toLowerCase())return o;return null}var hn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,fv=t=>!no(t)&&t!==hn;function Tf(){let{caseless:t,skipUndefined:e}=fv(this)&&this||{},r={},n=(o,s)=>{let i=t&&dv(r,s)||s;ka(r[i])&&ka(o)?r[i]=Tf(r[i],o):ka(o)?r[i]=Tf({},o):oo(o)?r[i]=o.slice():(!e||!no(o))&&(r[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&_s(arguments[o],n);return r}var yA=(t,e,r,{allOwnKeys:n}={})=>(_s(e,(o,s)=>{r&&tt(o)?t[s]=hs(o,r):t[s]=o},{allOwnKeys:n}),t),_A=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),vA=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},bA=(t,e,r,n)=>{let o,s,i,a={};if(e=e||{},t==null)return e;do{for(o=Object.getOwnPropertyNames(t),s=o.length;s-- >0;)i=o[s],(!n||n(i,t,e))&&!a[i]&&(e[i]=t[i],a[i]=!0);t=r!==!1&&zf(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},wA=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;let n=t.indexOf(e,r);return n!==-1&&n===r},xA=t=>{if(!t)return null;if(oo(t))return t;let e=t.length;if(!lv(e))return null;let r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},kA=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&zf(Uint8Array)),SA=(t,e)=>{let n=(t&&t[Sa]).call(t),o;for(;(o=n.next())&&!o.done;){let s=o.value;e.call(t,s[0],s[1])}},$A=(t,e)=>{let r,n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},TA=Rt("HTMLFormElement"),zA=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),av=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),RA=Rt("RegExp"),pv=(t,e)=>{let r=Object.getOwnPropertyDescriptors(t),n={};_s(r,(o,s)=>{let i;(i=e(o,s,t))!==!1&&(n[s]=i||o)}),Object.defineProperties(t,n)},EA=t=>{pv(t,(e,r)=>{if(tt(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=t[r];if(tt(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},PA=(t,e)=>{let r={},n=o=>{o.forEach(s=>{r[s]=!0})};return oo(t)?n(t):n(String(t).split(e)),r},AA=()=>{},CA=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function OA(t){return!!(t&&tt(t.append)&&t[cv]==="FormData"&&t[Sa])}var NA=t=>{let e=new Array(10),r=(n,o)=>{if(ys(n)){if(e.indexOf(n)>=0)return;if(gs(n))return n;if(!("toJSON"in n)){e[o]=n;let s=oo(n)?[]:{};return _s(n,(i,a)=>{let c=r(i,o+1);!no(c)&&(s[a]=c)}),e[o]=void 0,s}}return n};return r(t,0)},IA=Rt("AsyncFunction"),MA=t=>t&&(ys(t)||tt(t))&&tt(t.then)&&tt(t.catch),mv=((t,e)=>t?setImmediate:e?((r,n)=>(hn.addEventListener("message",({source:o,data:s})=>{o===hn&&s===r&&n.length&&n.shift()()},!1),o=>{n.push(o),hn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",tt(hn.postMessage)),jA=typeof queueMicrotask<"u"?queueMicrotask.bind(hn):typeof process<"u"&&process.nextTick||mv,qA=t=>t!=null&&tt(t[Sa]),_={isArray:oo,isArrayBuffer:uv,isBuffer:gs,isFormData:lA,isArrayBufferView:tA,isString:rA,isNumber:lv,isBoolean:nA,isObject:ys,isPlainObject:ka,isEmptyObject:oA,isReadableStream:fA,isRequest:pA,isResponse:mA,isHeaders:hA,isUndefined:no,isDate:sA,isFile:iA,isBlob:aA,isRegExp:RA,isFunction:tt,isStream:uA,isURLSearchParams:dA,isTypedArray:kA,isFileList:cA,forEach:_s,merge:Tf,extend:yA,trim:gA,stripBOM:_A,inherits:vA,toFlatObject:bA,kindOf:$a,kindOfTest:Rt,endsWith:wA,toArray:xA,forEachEntry:SA,matchAll:$A,isHTMLForm:TA,hasOwnProperty:av,hasOwnProp:av,reduceDescriptors:pv,freezeMethods:EA,toObjectSet:PA,toCamelCase:zA,noop:AA,toFiniteNumber:CA,findKey:dv,global:hn,isContextDefined:fv,isSpecCompliantForm:OA,toJSONObject:NA,isAsyncFn:IA,isThenable:MA,setImmediate:mv,asap:jA,isIterable:qA};function so(t,e,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o,this.status=o.status?o.status:null)}_.inherits(so,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:_.toJSONObject(this.config),code:this.code,status:this.status}}});var hv=so.prototype,gv={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{gv[t]={value:t}});Object.defineProperties(so,gv);Object.defineProperty(hv,"isAxiosError",{value:!0});so.from=(t,e,r,n,o,s)=>{let i=Object.create(hv);_.toFlatObject(t,i,function(l){return l!==Error.prototype},u=>u!=="isAxiosError");let a=t&&t.message?t.message:"Error",c=e==null&&t?t.code:e;return so.call(i,a,c,r,n,o),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",s&&Object.assign(i,s),i};var Z=so;var za=null;function Rf(t){return _.isPlainObject(t)||_.isArray(t)}function _v(t){return _.endsWith(t,"[]")?t.slice(0,-2):t}function yv(t,e,r){return t?t.concat(e).map(function(o,s){return o=_v(o),!r&&s?"["+o+"]":o}).join(r?".":""):e}function DA(t){return _.isArray(t)&&!t.some(Rf)}var ZA=_.toFlatObject(_,{},null,function(e){return/^is[A-Z]/.test(e)});function LA(t,e,r){if(!_.isObject(t))throw new TypeError("target must be an object");e=e||new(za||FormData),r=_.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,g){return!_.isUndefined(g[h])});let n=r.metaTokens,o=r.visitor||l,s=r.dots,i=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(e);if(!_.isFunction(o))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(_.isDate(f))return f.toISOString();if(_.isBoolean(f))return f.toString();if(!c&&_.isBlob(f))throw new Z("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(f)||_.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,h,g){let y=f;if(f&&!g&&typeof f=="object"){if(_.endsWith(h,"{}"))h=n?h:h.slice(0,-2),f=JSON.stringify(f);else if(_.isArray(f)&&DA(f)||(_.isFileList(f)||_.endsWith(h,"[]"))&&(y=_.toArray(f)))return h=_v(h),y.forEach(function(k,T){!(_.isUndefined(k)||k===null)&&e.append(i===!0?yv([h],T,s):i===null?h:h+"[]",u(k))}),!1}return Rf(f)?!0:(e.append(yv(g,h,s),u(f)),!1)}let d=[],p=Object.assign(ZA,{defaultVisitor:l,convertValue:u,isVisitable:Rf});function m(f,h){if(!_.isUndefined(f)){if(d.indexOf(f)!==-1)throw Error("Circular reference detected in "+h.join("."));d.push(f),_.forEach(f,function(y,b){(!(_.isUndefined(y)||y===null)&&o.call(e,y,_.isString(b)?b.trim():b,h,p))===!0&&m(y,h?h.concat(b):[b])}),d.pop()}}if(!_.isObject(t))throw new TypeError("data must be an object");return m(t),e}var Ar=LA;function vv(t){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function bv(t,e){this._pairs=[],t&&Ar(t,this,e)}var wv=bv.prototype;wv.append=function(e,r){this._pairs.push([e,r])};wv.toString=function(e){let r=e?function(n){return e.call(this,n,vv)}:vv;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var Ra=bv;function UA(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function vs(t,e,r){if(!e)return t;let n=r&&r.encode||UA;_.isFunction(r)&&(r={serialize:r});let o=r&&r.serialize,s;if(o?s=o(e,r):s=_.isURLSearchParams(e)?e.toString():new Ra(e,r).toString(n),s){let i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}var Ef=class{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){_.forEach(this.handlers,function(n){n!==null&&e(n)})}},Pf=Ef;var Ea={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var xv=typeof URLSearchParams<"u"?URLSearchParams:Ra;var kv=typeof FormData<"u"?FormData:null;var Sv=typeof Blob<"u"?Blob:null;var $v={isBrowser:!0,classes:{URLSearchParams:xv,FormData:kv,Blob:Sv},protocols:["http","https","file","blob","url","data"]};var Of={};Os(Of,{hasBrowserEnv:()=>Cf,hasStandardBrowserEnv:()=>FA,hasStandardBrowserWebWorkerEnv:()=>HA,navigator:()=>Af,origin:()=>VA});var Cf=typeof window<"u"&&typeof document<"u",Af=typeof navigator=="object"&&navigator||void 0,FA=Cf&&(!Af||["ReactNative","NativeScript","NS"].indexOf(Af.product)<0),HA=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",VA=Cf&&window.location.href||"http://localhost";var Se={...Of,...$v};function Nf(t,e){return Ar(t,new Se.classes.URLSearchParams,{visitor:function(r,n,o,s){return Se.isNode&&_.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function BA(t){return _.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function KA(t){let e={},r=Object.keys(t),n,o=r.length,s;for(n=0;n<o;n++)s=r[n],e[s]=t[s];return e}function JA(t){function e(r,n,o,s){let i=r[s++];if(i==="__proto__")return!0;let a=Number.isFinite(+i),c=s>=r.length;return i=!i&&_.isArray(o)?o.length:i,c?(_.hasOwnProp(o,i)?o[i]=[o[i],n]:o[i]=n,!a):((!o[i]||!_.isObject(o[i]))&&(o[i]=[]),e(r,n,o[i],s)&&_.isArray(o[i])&&(o[i]=KA(o[i])),!a)}if(_.isFormData(t)&&_.isFunction(t.entries)){let r={};return _.forEachEntry(t,(n,o)=>{e(BA(n),o,r,0)}),r}return null}var Pa=JA;function WA(t,e,r){if(_.isString(t))try{return(e||JSON.parse)(t),_.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var If={transitional:Ea,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,s=_.isObject(e);if(s&&_.isHTMLForm(e)&&(e=new FormData(e)),_.isFormData(e))return o?JSON.stringify(Pa(e)):e;if(_.isArrayBuffer(e)||_.isBuffer(e)||_.isStream(e)||_.isFile(e)||_.isBlob(e)||_.isReadableStream(e))return e;if(_.isArrayBufferView(e))return e.buffer;if(_.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Nf(e,this.formSerializer).toString();if((a=_.isFileList(e))||n.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return Ar(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return s||o?(r.setContentType("application/json",!1),WA(e)):e}],transformResponse:[function(e){let r=this.transitional||If.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(_.isResponse(e)||_.isReadableStream(e))return e;if(e&&_.isString(e)&&(n&&!this.responseType||o)){let i=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(e,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Z.from(a,Z.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Se.classes.FormData,Blob:Se.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],t=>{If.headers[t]={}});var io=If;var GA=_.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Tv=t=>{let e={},r,n,o;return t&&t.split(`
|
|
40
|
+
`).forEach(function(i){o=i.indexOf(":"),r=i.substring(0,o).trim().toLowerCase(),n=i.substring(o+1).trim(),!(!r||e[r]&&GA[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e};var zv=Symbol("internals");function bs(t){return t&&String(t).trim().toLowerCase()}function Aa(t){return t===!1||t==null?t:_.isArray(t)?t.map(Aa):String(t)}function QA(t){let e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}var YA=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Mf(t,e,r,n,o){if(_.isFunction(n))return n.call(this,e,r);if(o&&(e=r),!!_.isString(e)){if(_.isString(n))return e.indexOf(n)!==-1;if(_.isRegExp(n))return n.test(e)}}function XA(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function eC(t,e){let r=_.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(o,s,i){return this[n].call(this,e,o,s,i)},configurable:!0})})}var ao=class{constructor(e){e&&this.set(e)}set(e,r,n){let o=this;function s(a,c,u){let l=bs(c);if(!l)throw new Error("header name must be a non-empty string");let d=_.findKey(o,l);(!d||o[d]===void 0||u===!0||u===void 0&&o[d]!==!1)&&(o[d||c]=Aa(a))}let i=(a,c)=>_.forEach(a,(u,l)=>s(u,l,c));if(_.isPlainObject(e)||e instanceof this.constructor)i(e,r);else if(_.isString(e)&&(e=e.trim())&&!YA(e))i(Tv(e),r);else if(_.isObject(e)&&_.isIterable(e)){let a={},c,u;for(let l of e){if(!_.isArray(l))throw TypeError("Object iterator must return a key-value pair");a[u=l[0]]=(c=a[u])?_.isArray(c)?[...c,l[1]]:[c,l[1]]:l[1]}i(a,r)}else e!=null&&s(r,e,n);return this}get(e,r){if(e=bs(e),e){let n=_.findKey(this,e);if(n){let o=this[n];if(!r)return o;if(r===!0)return QA(o);if(_.isFunction(r))return r.call(this,o,n);if(_.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=bs(e),e){let n=_.findKey(this,e);return!!(n&&this[n]!==void 0&&(!r||Mf(this,this[n],n,r)))}return!1}delete(e,r){let n=this,o=!1;function s(i){if(i=bs(i),i){let a=_.findKey(n,i);a&&(!r||Mf(n,n[a],a,r))&&(delete n[a],o=!0)}}return _.isArray(e)?e.forEach(s):s(e),o}clear(e){let r=Object.keys(this),n=r.length,o=!1;for(;n--;){let s=r[n];(!e||Mf(this,this[s],s,e,!0))&&(delete this[s],o=!0)}return o}normalize(e){let r=this,n={};return _.forEach(this,(o,s)=>{let i=_.findKey(n,s);if(i){r[i]=Aa(o),delete r[s];return}let a=e?XA(s):String(s).trim();a!==s&&delete r[s],r[a]=Aa(o),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let r=Object.create(null);return _.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=e&&_.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(`
|
|
41
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){let n=new this(e);return r.forEach(o=>n.set(o)),n}static accessor(e){let n=(this[zv]=this[zv]={accessors:{}}).accessors,o=this.prototype;function s(i){let a=bs(i);n[a]||(eC(o,i),n[a]=!0)}return _.isArray(e)?e.forEach(s):s(e),this}};ao.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);_.reduceDescriptors(ao.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}});_.freezeMethods(ao);var Re=ao;function ws(t,e){let r=this||io,n=e||r,o=Re.from(n.headers),s=n.data;return _.forEach(t,function(a){s=a.call(r,s,o.normalize(),e?e.status:void 0)}),o.normalize(),s}function xs(t){return!!(t&&t.__CANCEL__)}function Rv(t,e,r){Z.call(this,t??"canceled",Z.ERR_CANCELED,e,r),this.name="CanceledError"}_.inherits(Rv,Z,{__CANCEL__:!0});var Ft=Rv;function ks(t,e,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new Z("Request failed with status code "+r.status,[Z.ERR_BAD_REQUEST,Z.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function jf(t){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function tC(t,e){t=t||10;let r=new Array(t),n=new Array(t),o=0,s=0,i;return e=e!==void 0?e:1e3,function(c){let u=Date.now(),l=n[s];i||(i=u),r[o]=c,n[o]=u;let d=s,p=0;for(;d!==o;)p+=r[d++],d=d%t;if(o=(o+1)%t,o===s&&(s=(s+1)%t),u-i<e)return;let m=l&&u-l;return m?Math.round(p*1e3/m):void 0}}var Ev=tC;function rC(t,e){let r=0,n=1e3/e,o,s,i=(u,l=Date.now())=>{r=l,o=null,s&&(clearTimeout(s),s=null),t(...u)};return[(...u)=>{let l=Date.now(),d=l-r;d>=n?i(u,l):(o=u,s||(s=setTimeout(()=>{s=null,i(o)},n-d)))},()=>o&&i(o)]}var Pv=rC;var co=(t,e,r=3)=>{let n=0,o=Ev(50,250);return Pv(s=>{let i=s.loaded,a=s.lengthComputable?s.total:void 0,c=i-n,u=o(c),l=i<=a;n=i;let d={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:u||void 0,estimated:u&&a&&l?(a-i)/u:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(d)},r)},qf=(t,e)=>{let r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},Df=t=>(...e)=>_.asap(()=>t(...e));var Av=Se.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,Se.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(Se.origin),Se.navigator&&/(msie|trident)/i.test(Se.navigator.userAgent)):()=>!0;var Cv=Se.hasStandardBrowserEnv?{write(t,e,r,n,o,s,i){if(typeof document>"u")return;let a=[`${t}=${encodeURIComponent(e)}`];_.isNumber(r)&&a.push(`expires=${new Date(r).toUTCString()}`),_.isString(n)&&a.push(`path=${n}`),_.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),_.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(t){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Zf(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Lf(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Ss(t,e,r){let n=!Zf(e);return t&&(n||r==!1)?Lf(t,e):e}var Ov=t=>t instanceof Re?{...t}:t;function Et(t,e){e=e||{};let r={};function n(u,l,d,p){return _.isPlainObject(u)&&_.isPlainObject(l)?_.merge.call({caseless:p},u,l):_.isPlainObject(l)?_.merge({},l):_.isArray(l)?l.slice():l}function o(u,l,d,p){if(_.isUndefined(l)){if(!_.isUndefined(u))return n(void 0,u,d,p)}else return n(u,l,d,p)}function s(u,l){if(!_.isUndefined(l))return n(void 0,l)}function i(u,l){if(_.isUndefined(l)){if(!_.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function a(u,l,d){if(d in e)return n(u,l);if(d in t)return n(void 0,u)}let c={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(u,l,d)=>o(Ov(u),Ov(l),d,!0)};return _.forEach(Object.keys({...t,...e}),function(l){let d=c[l]||o,p=d(t[l],e[l],l);_.isUndefined(p)&&d!==a||(r[l]=p)}),r}var Ca=t=>{let e=Et({},t),{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=e;if(e.headers=i=Re.from(i),e.url=vs(Ss(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),_.isFormData(r)){if(Se.hasStandardBrowserEnv||Se.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(_.isFunction(r.getHeaders)){let c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([l,d])=>{u.includes(l.toLowerCase())&&i.set(l,d)})}}if(Se.hasStandardBrowserEnv&&(n&&_.isFunction(n)&&(n=n(e)),n||n!==!1&&Av(e.url))){let c=o&&s&&Cv.read(s);c&&i.set(o,c)}return e};var nC=typeof XMLHttpRequest<"u",Nv=nC&&function(t){return new Promise(function(r,n){let o=Ca(t),s=o.data,i=Re.from(o.headers).normalize(),{responseType:a,onUploadProgress:c,onDownloadProgress:u}=o,l,d,p,m,f;function h(){m&&m(),f&&f(),o.cancelToken&&o.cancelToken.unsubscribe(l),o.signal&&o.signal.removeEventListener("abort",l)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function y(){if(!g)return;let k=Re.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),R={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:k,config:t,request:g};ks(function(ie){r(ie),h()},function(ie){n(ie),h()},R),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(n(new Z("Request aborted",Z.ECONNABORTED,t,g)),g=null)},g.onerror=function(T){let R=T&&T.message?T.message:"Network Error",me=new Z(R,Z.ERR_NETWORK,t,g);me.event=T||null,n(me),g=null},g.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded",R=o.transitional||Ea;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),n(new Z(T,R.clarifyTimeoutError?Z.ETIMEDOUT:Z.ECONNABORTED,t,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&_.forEach(i.toJSON(),function(T,R){g.setRequestHeader(R,T)}),_.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),u&&([p,f]=co(u,!0),g.addEventListener("progress",p)),c&&g.upload&&([d,m]=co(c),g.upload.addEventListener("progress",d),g.upload.addEventListener("loadend",m)),(o.cancelToken||o.signal)&&(l=k=>{g&&(n(!k||k.type?new Ft(null,t,g):k),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(l),o.signal&&(o.signal.aborted?l():o.signal.addEventListener("abort",l)));let b=jf(o.url);if(b&&Se.protocols.indexOf(b)===-1){n(new Z("Unsupported protocol "+b+":",Z.ERR_BAD_REQUEST,t));return}g.send(s||null)})};var oC=(t,e)=>{let{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,o,s=function(u){if(!o){o=!0,a();let l=u instanceof Error?u:this.reason;n.abort(l instanceof Z?l:new Ft(l instanceof Error?l.message:l))}},i=e&&setTimeout(()=>{i=null,s(new Z(`timeout ${e} of ms exceeded`,Z.ETIMEDOUT))},e),a=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),t=null)};t.forEach(u=>u.addEventListener("abort",s));let{signal:c}=n;return c.unsubscribe=()=>_.asap(a),c}},Iv=oC;var sC=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,o;for(;n<r;)o=n+e,yield t.slice(n,o),n=o},iC=async function*(t,e){for await(let r of aC(t))yield*sC(r,e)},aC=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)break;yield n}}finally{await e.cancel()}},Uf=(t,e,r,n)=>{let o=iC(t,e),s=0,i,a=c=>{i||(i=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await o.next();if(u){a(),c.close();return}let d=l.byteLength;if(r){let p=s+=d;r(p)}c.enqueue(new Uint8Array(l))}catch(u){throw a(u),u}},cancel(c){return a(c),o.return()}},{highWaterMark:2})};var Mv=64*1024,{isFunction:Oa}=_,cC=(({Request:t,Response:e})=>({Request:t,Response:e}))(_.global),{ReadableStream:jv,TextEncoder:qv}=_.global,Dv=(t,...e)=>{try{return!!t(...e)}catch{return!1}},uC=t=>{t=_.merge.call({skipUndefined:!0},cC,t);let{fetch:e,Request:r,Response:n}=t,o=e?Oa(e):typeof fetch=="function",s=Oa(r),i=Oa(n);if(!o)return!1;let a=o&&Oa(jv),c=o&&(typeof qv=="function"?(f=>h=>f.encode(h))(new qv):async f=>new Uint8Array(await new r(f).arrayBuffer())),u=s&&a&&Dv(()=>{let f=!1,h=new r(Se.origin,{body:new jv,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!h}),l=i&&a&&Dv(()=>_.isReadableStream(new n("").body)),d={stream:l&&(f=>f.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!d[f]&&(d[f]=(h,g)=>{let y=h&&h[f];if(y)return y.call(h);throw new Z(`Response type '${f}' is not supported`,Z.ERR_NOT_SUPPORT,g)})});let p=async f=>{if(f==null)return 0;if(_.isBlob(f))return f.size;if(_.isSpecCompliantForm(f))return(await new r(Se.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(_.isArrayBufferView(f)||_.isArrayBuffer(f))return f.byteLength;if(_.isURLSearchParams(f)&&(f=f+""),_.isString(f))return(await c(f)).byteLength},m=async(f,h)=>{let g=_.toFiniteNumber(f.getContentLength());return g??p(h)};return async f=>{let{url:h,method:g,data:y,signal:b,cancelToken:k,timeout:T,onDownloadProgress:R,onUploadProgress:me,responseType:ie,headers:Ve,withCredentials:Be="same-origin",fetchOptions:ir}=Ca(f),bn=e||fetch;ie=ie?(ie+"").toLowerCase():"text";let Nr=Iv([b,k&&k.toAbortSignal()],T),ar=null,Bt=Nr&&Nr.unsubscribe&&(()=>{Nr.unsubscribe()}),hp;try{if(me&&u&&g!=="get"&&g!=="head"&&(hp=await m(Ve,y))!==0){let ur=new r(h,{method:"POST",body:y,duplex:"half"}),wn;if(_.isFormData(y)&&(wn=ur.headers.get("content-type"))&&Ve.setContentType(wn),ur.body){let[Ka,Cs]=qf(hp,co(Df(me)));y=Uf(ur.body,Mv,Ka,Cs)}}_.isString(Be)||(Be=Be?"include":"omit");let Pt=s&&"credentials"in r.prototype,gp={...ir,signal:Nr,method:g.toUpperCase(),headers:Ve.normalize().toJSON(),body:y,duplex:"half",credentials:Pt?Be:void 0};ar=s&&new r(h,gp);let cr=await(s?bn(ar,ir):bn(h,gp)),yp=l&&(ie==="stream"||ie==="response");if(l&&(R||yp&&Bt)){let ur={};["status","statusText","headers"].forEach(_p=>{ur[_p]=cr[_p]});let wn=_.toFiniteNumber(cr.headers.get("content-length")),[Ka,Cs]=R&&qf(wn,co(Df(R),!0))||[];cr=new n(Uf(cr.body,Mv,Ka,()=>{Cs&&Cs(),Bt&&Bt()}),ur)}ie=ie||"text";let tw=await d[_.findKey(d,ie)||"text"](cr,f);return!yp&&Bt&&Bt(),await new Promise((ur,wn)=>{ks(ur,wn,{data:tw,headers:Re.from(cr.headers),status:cr.status,statusText:cr.statusText,config:f,request:ar})})}catch(Pt){throw Bt&&Bt(),Pt&&Pt.name==="TypeError"&&/Load failed|fetch/i.test(Pt.message)?Object.assign(new Z("Network Error",Z.ERR_NETWORK,f,ar),{cause:Pt.cause||Pt}):Z.from(Pt,Pt&&Pt.code,f,ar)}}},lC=new Map,Ff=t=>{let e=t&&t.env||{},{fetch:r,Request:n,Response:o}=e,s=[n,o,r],i=s.length,a=i,c,u,l=lC;for(;a--;)c=s[a],u=l.get(c),u===void 0&&l.set(c,u=a?new Map:uC(e)),l=u;return u},DL=Ff();var Hf={http:za,xhr:Nv,fetch:{get:Ff}};_.forEach(Hf,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});var Zv=t=>`- ${t}`,fC=t=>_.isFunction(t)||t===null||t===!1;function pC(t,e){t=_.isArray(t)?t:[t];let{length:r}=t,n,o,s={};for(let i=0;i<r;i++){n=t[i];let a;if(o=n,!fC(n)&&(o=Hf[(a=String(n)).toLowerCase()],o===void 0))throw new Z(`Unknown adapter '${a}'`);if(o&&(_.isFunction(o)||(o=o.get(e))))break;s[a||"#"+i]=o}if(!o){let i=Object.entries(s).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),a=r?i.length>1?`since :
|
|
42
|
+
`+i.map(Zv).join(`
|
|
43
|
+
`):" "+Zv(i[0]):"as no adapter specified";throw new Z("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}var Na={getAdapter:pC,adapters:Hf};function Vf(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ft(null,t)}function Ia(t){return Vf(t),t.headers=Re.from(t.headers),t.data=ws.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Na.getAdapter(t.adapter||io.adapter,t)(t).then(function(n){return Vf(t),n.data=ws.call(t,t.transformResponse,n),n.headers=Re.from(n.headers),n},function(n){return xs(n)||(Vf(t),n&&n.response&&(n.response.data=ws.call(t,t.transformResponse,n.response),n.response.headers=Re.from(n.response.headers))),Promise.reject(n)})}var Ma="1.13.2";var ja={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{ja[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var Lv={};ja.transitional=function(e,r,n){function o(s,i){return"[Axios v"+Ma+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,a)=>{if(e===!1)throw new Z(o(i," has been removed"+(r?" in "+r:"")),Z.ERR_DEPRECATED);return r&&!Lv[i]&&(Lv[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,i,a):!0}};ja.spelling=function(e){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function mC(t,e,r){if(typeof t!="object")throw new Z("options must be an object",Z.ERR_BAD_OPTION_VALUE);let n=Object.keys(t),o=n.length;for(;o-- >0;){let s=n[o],i=e[s];if(i){let a=t[s],c=a===void 0||i(a,s,t);if(c!==!0)throw new Z("option "+s+" must be "+c,Z.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new Z("Unknown option "+s,Z.ERR_BAD_OPTION)}}var $s={assertOptions:mC,validators:ja};var Ht=$s.validators,uo=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Pf,response:new Pf}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;let s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
44
|
+
`+s):n.stack=s}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=Et(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&$s.assertOptions(n,{silentJSONParsing:Ht.transitional(Ht.boolean),forcedJSONParsing:Ht.transitional(Ht.boolean),clarifyTimeoutError:Ht.transitional(Ht.boolean)},!1),o!=null&&(_.isFunction(o)?r.paramsSerializer={serialize:o}:$s.assertOptions(o,{encode:Ht.function,serialize:Ht.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),$s.assertOptions(r,{baseUrl:Ht.spelling("baseURL"),withXsrfToken:Ht.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&_.merge(s.common,s[r.method]);s&&_.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),r.headers=Re.concat(i,s);let a=[],c=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(c=c&&h.synchronous,a.unshift(h.fulfilled,h.rejected))});let u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let l,d=0,p;if(!c){let f=[Ia.bind(this),void 0];for(f.unshift(...a),f.push(...u),p=f.length,l=Promise.resolve(r);d<p;)l=l.then(f[d++],f[d++]);return l}p=a.length;let m=r;for(;d<p;){let f=a[d++],h=a[d++];try{m=f(m)}catch(g){h.call(this,g);break}}try{l=Ia.call(this,m)}catch(f){return Promise.reject(f)}for(d=0,p=u.length;d<p;)l=l.then(u[d++],u[d++]);return l}getUri(e){e=Et(this.defaults,e);let r=Ss(e.baseURL,e.url,e.allowAbsoluteUrls);return vs(r,e.params,e.paramsSerializer)}};_.forEach(["delete","get","head","options"],function(e){uo.prototype[e]=function(r,n){return this.request(Et(n||{},{method:e,url:r,data:(n||{}).data}))}});_.forEach(["post","put","patch"],function(e){function r(n){return function(s,i,a){return this.request(Et(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}uo.prototype[e]=r(),uo.prototype[e+"Form"]=r(!0)});var Ts=uo;var Bf=class t{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});let n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s,i=new Promise(a=>{n.subscribe(a),s=a}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},e(function(s,i,a){n.reason||(n.reason=new Ft(s,i,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){let e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new t(function(o){e=o}),cancel:e}}},Uv=Bf;function Kf(t){return function(r){return t.apply(null,r)}}function Jf(t){return _.isObject(t)&&t.isAxiosError===!0}var Wf={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Wf).forEach(([t,e])=>{Wf[e]=t});var Fv=Wf;function Hv(t){let e=new Ts(t),r=hs(Ts.prototype.request,e);return _.extend(r,Ts.prototype,e,{allOwnKeys:!0}),_.extend(r,e,null,{allOwnKeys:!0}),r.create=function(o){return Hv(Et(t,o))},r}var Te=Hv(io);Te.Axios=Ts;Te.CanceledError=Ft;Te.CancelToken=Uv;Te.isCancel=xs;Te.VERSION=Ma;Te.toFormData=Ar;Te.AxiosError=Z;Te.Cancel=Te.CanceledError;Te.all=function(e){return Promise.all(e)};Te.spread=Kf;Te.isAxiosError=Jf;Te.mergeConfig=Et;Te.AxiosHeaders=Re;Te.formToJSON=t=>Pa(_.isHTMLForm(t)?new FormData(t):t);Te.getAdapter=Na.getAdapter;Te.HttpStatusCode=Fv;Te.default=Te;var Vt=Te;var{Axios:M2,AxiosError:j2,CanceledError:q2,isCancel:D2,CancelToken:Z2,VERSION:L2,all:U2,Cancel:F2,isAxiosError:H2,spread:V2,toFormData:B2,AxiosHeaders:K2,HttpStatusCode:J2,formToJSON:W2,getAdapter:G2,mergeConfig:Q2}=Vt;var Cr={portals:[{id:"dati-gov-it",name:"dati.gov.it",api_url:"https://www.dati.gov.it/opendata",api_url_aliases:["https://dati.gov.it/opendata","http://www.dati.gov.it/opendata","http://dati.gov.it/opendata","https://dati.gov.it","https://www.dati.gov.it"],search:{force_text_field:!0},hvd:{category_field:"hvd_category"},sparql:{endpoint_url:"https://lod.dati.gov.it/sparql",method:"GET"},dataset_view_url:"https://www.dati.gov.it/view-dataset/dataset?id={id}",organization_view_url:"https://www.dati.gov.it/view-dataset?organization={name}"},{id:"dati-arpae-it",name:"dati.arpae.it",api_url:"https://dati.arpae.it",api_url_aliases:["http://dati.arpae.it"],search:{force_text_field:!0}},{id:"anac-opendata",name:"dati.anticorruzione.it/opendata",api_url:"https://dati.anticorruzione.it/opendata",api_url_aliases:["http://dati.anticorruzione.it/opendata","https://dati.anticorruzione.it","http://dati.anticorruzione.it"]},{id:"data-gov-uk",name:"data.gov.uk",api_url:"https://data.gov.uk",api_url_aliases:["https://www.data.gov.uk","http://data.gov.uk","http://www.data.gov.uk"],api_path:"/api/action",search:{force_text_field:!0},dataset_view_url:"https://www.data.gov.uk/dataset/{id}/{name}",organization_view_url:"https://www.data.gov.uk/organization/{name}"},{id:"catalog-data-gov",name:"catalog.data.gov",api_url:"https://catalog.data.gov",api_url_aliases:["http://catalog.data.gov"],search:{force_text_field:!0}},{id:"open-canada",name:"open.canada.ca",api_url:"https://open.canada.ca/data",api_url_aliases:["http://open.canada.ca/data","https://open.canada.ca","http://open.canada.ca"],search:{force_text_field:!0}},{id:"data-gov-au",name:"data.gov.au",api_url:"https://data.gov.au",api_url_aliases:["http://data.gov.au","https://www.data.gov.au","http://www.data.gov.au"],dataset_view_url:"https://data.gov.au/data/dataset/{name}",organization_view_url:"https://data.gov.au/data/organization/{name}"},{id:"opendata-swiss",name:"opendata.swiss",api_url:"https://ckan.opendata.swiss",api_url_aliases:["https://opendata.swiss","http://opendata.swiss","https://www.opendata.swiss","http://www.opendata.swiss"]},{id:"data-stadt-zuerich-ch",name:"data.stadt-zuerich.ch",api_url:"https://data.stadt-zuerich.ch",api_url_aliases:["http://data.stadt-zuerich.ch","https://www.data.stadt-zuerich.ch","https://ckan-prod.zurich.datopian.com"],organization_view_url:"https://ckan-prod.zurich.datopian.com/organization/{name}"},{id:"data-gov-ua",name:"data.gov.ua",api_url:"https://data.gov.ua",api_url_aliases:["http://data.gov.ua"],search:{force_text_field:!1}},{id:"dati-regione-sicilia",name:"dati.regione.sicilia.it",api_url:"https://dati.regione.sicilia.it",api_url_aliases:["http://dati.regione.sicilia.it"],search:{force_text_field:!1}},{id:"bdap-rgs-mef",name:"bdap-opendata.rgs.mef.gov.it",api_url:"https://bdap-opendata.rgs.mef.gov.it/SpodCkanApi",api_url_aliases:["http://bdap-opendata.rgs.mef.gov.it/SpodCkanApi"],dataset_view_url:"https://bdap-opendata.rgs.mef.gov.it/SpodCkanApi/dataset/{name}",organization_view_url:"https://bdap-opendata.rgs.mef.gov.it/SpodCkanApi/organization/{name}"},{id:"govdata-de",name:"govdata.de",api_url:"https://ckan.govdata.de",api_url_aliases:["https://www.govdata.de","https://govdata.de","https://www.govdata.de/daten","https://data.gov.de","https://www.data.gov.de"],dataset_view_url:"https://ckan.govdata.de/dataset/{name}",organization_view_url:"https://ckan.govdata.de/organization/{name}"}],defaults:{dataset_view_url:"{server_url}/dataset/{name}",organization_view_url:"{server_url}/organization/{name}",search:{force_text_field:!1}}};function gn(t){return t.replace(/\/$/,"")}function gC(t){try{return new URL(t).hostname}catch{return null}}function or(t){let e=gn(t);return Cr.portals.find(n=>{let o=gn(n.api_url),s=(n.api_url_aliases||[]).map(gn);return o===e||s.includes(e)})||null}function Vv(t){let e=or(t),r=Cr.defaults?.search||{};return{force_text_field:e?.search?.force_text_field??r.force_text_field??!1}}function Bv(t){return or(t)?.search?.force_text_field!==void 0}function Gf(t){return gn(t)}function qa(t){let e=Cr.portals.find(r=>[r.api_url,...r.api_url_aliases||[]].some(o=>gC(o)===t));return e?gn(e.api_url):null}function lo(t){return or(t)?.hvd??null}function Kv(t){let e=gn(t);return Cr.portals.find(n=>n.sparql&&gn(n.sparql.endpoint_url)===e)?.sparql??null}function Jv(t){return or(t)?.sparql??null}function yn(t){return or(t)?.api_path||"/api/3/action"}function Qf(t){return or(t)?.normalize==="multilingual"}var yC=new Set(["package_search","package_show","current_package_list_with_resources","resource_show","organization_show","organization_list","organization_search","group_show","group_list","group_search","tag_list","tag_show","tag_search"]),_C=new Set(["status_show","site_read"]),vC=new Set(["datastore_search","datastore_search_sql"]);function Wv(t,e){return yC.has(t)?300:_C.has(t)?3600:vC.has(t)?60:e}function zs(t){if(typeof process>"u"||!process.env)return;let e=process.env[t];return e===void 0||e===""?void 0:e}function ep(){let t=zs("CKAN_CACHE_ENABLED"),e=zs("VITEST")==="true",r=t!==void 0?t!=="false":!e,n=Number(zs("CKAN_CACHE_TTL_DEFAULT"))||300,o=Number(zs("CKAN_CACHE_MAX_ENTRIES"))||500,s=Number(zs("CKAN_CACHE_MAX_ENTRY_BYTES"))||1024*1024;return{enabled:r,ttlDefault:n,maxEntries:o,maxEntryBytes:s}}function bC(t){let e=Object.keys(t).sort(),r=[];for(let n of e){let o=t[n];if(o==null)continue;let s=typeof o=="object"?JSON.stringify(o):String(o);r.push(`${n}=${s}`)}return r.join("&")}async function wC(t){let e=new TextEncoder().encode(t),r=await crypto.subtle.digest("SHA-1",e),n=new Uint8Array(r),o="";for(let s of n)o+=s.toString(16).padStart(2,"0");return o}async function Gv(t,e,r){let n=`${t}|${e}|${bC(r)}`;return wC(n)}var Yf=class{constructor(e){this.maxEntries=e}store=new Map;async get(e){let r=this.store.get(e);if(r){if(r.expiresAt<=Date.now()){this.store.delete(e);return}return this.store.delete(e),this.store.set(e,r),r.value}}async set(e,r,n){if(!(n<=0))for(this.store.has(e)&&this.store.delete(e),this.store.set(e,{value:r,expiresAt:Date.now()+n*1e3});this.store.size>this.maxEntries;){let o=this.store.keys().next().value;if(o===void 0)break;this.store.delete(o)}}clear(){this.store.clear()}size(){return this.store.size}},Xf=class{origin="https://ckan-mcp-cache.internal";async get(e){try{let r=await caches.default.match(`${this.origin}/${e}`);return r?await r.json():void 0}catch{return}}async set(e,r,n){if(!(n<=0))try{let o=JSON.stringify(r),s=new Response(o,{headers:{"Content-Type":"application/json","Cache-Control":`public, s-maxage=${n}`}});await caches.default.put(`${this.origin}/${e}`,s)}catch{}}},Rs=null;function Qv(){if(Rs)return Rs;let t=typeof caches<"u"&&typeof caches.default<"u",e=typeof process<"u"&&!!process.versions?.node;return t&&!e?Rs=new Xf:Rs=new Yf(ep().maxEntries),Rs}var rp=class extends Error{constructor(e,r){super(`Rate limit exceeded for ${e}: would need to wait ${Math.round(r)}ms`),this.name="RateLimitError"}},xC=200;function Es(t){if(typeof process>"u"||!process.env)return;let e=process.env[t];return e===void 0||e===""?void 0:e}function op(){let t=Es("CKAN_RATE_LIMIT_ENABLED"),e=Es("VITEST")==="true";return{enabled:t!==void 0?t!=="false":!e,rps:Number(Es("CKAN_RATE_LIMIT_RPS"))||5,burst:Number(Es("CKAN_RATE_LIMIT_BURST"))||10,maxWaitMs:Number(Es("CKAN_RATE_LIMIT_MAX_WAIT_MS"))||5e3}}function kC(t){return new Promise(e=>setTimeout(e,t))}var np=class{constructor(e){this.config=e}buckets=new Map;async acquire(e){let{rps:r,burst:n,maxWaitMs:o}=this.config;if(!this.buckets.has(e)){if(this.buckets.size>=xC){let i=this.buckets.keys().next().value;i!==void 0&&this.buckets.delete(i)}this.buckets.set(e,{tokens:n,lastRefill:Date.now()})}let s=0;for(;;){let i=this.buckets.get(e),a=Date.now(),c=a-i.lastRefill;if(i.tokens=Math.min(n,i.tokens+c/1e3*r),i.lastRefill=a,i.tokens>=1){i.tokens-=1;return}let u=(1-i.tokens)/r*1e3;if(s+u>o)throw new rp(e,s+u);await kC(u),s+=u}}clear(){this.buckets.clear()}},tp=null;function Yv(){return tp||(tp=new np(op())),tp}var sr=class extends Error{status;action;constructor(e,r,n){super(e),this.name="CkanApiError",this.status=r,this.action=n}};function we(t,e){if(!(t instanceof sr))return t instanceof Error?t.message:String(t);let{status:r,action:n,message:o}=t,s="";return r===404?n.startsWith("datastore_search")?s="\u2192 Get a valid resource_id first: call `ckan_package_show` on a dataset, then pick a resource where `datastore_active` is true.":n==="package_show"?s="\u2192 Use `ckan_package_search` to find a valid dataset name or ID.":n==="organization_show"&&(s="\u2192 Use `ckan_organization_list` or `ckan_organization_search` to discover valid organization names."):r===400?n==="datastore_search_sql"?s="\u2192 Invalid SQL syntax or unknown column \u2014 check column names with `ckan_datastore_search` before writing SQL.":n.startsWith("datastore_search")&&(s="\u2192 Bad request \u2014 likely an invalid field name or filter syntax; check column names with a `SELECT *` query first."):r===409||r===422?s="\u2192 Portal rejected the request \u2014 parameters may conflict; simplify filters and retry.":r===503||r===502||r===504?s="\u2192 Portal temporarily unavailable \u2014 retry in a few seconds.":r===500?s="\u2192 Portal internal error \u2014 try a different portal or retry later.":r===void 0&&(s="\u2192 The portal may not support this action, or the endpoint is unavailable."),s?`${o}
|
|
45
|
+
${s}`:o}var ip=null;function nb(){return ip}var SC=(()=>{let t=null;return async()=>(t||(t=(async()=>{try{return await import("node:zlib")}catch{return null}})()),t)})();function Xv(t,e){if(!t)return;let r=e.toLowerCase();for(let[n,o]of Object.entries(t))if(n.toLowerCase()===r)return Array.isArray(o)?o.join(","):String(o)}function $C(t){if(t&&!(typeof Buffer>"u")){if(Buffer.isBuffer(t))return t;if(t instanceof ArrayBuffer)return Buffer.from(t);if(ArrayBuffer.isView(t))return Buffer.from(t.buffer,t.byteOffset,t.byteLength)}}function TC(t){if(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}}async function zC(t,e){if(e&&typeof DecompressionStream<"u")try{let r=new DecompressionStream(e.includes("br")?"br":e.includes("deflate")?"deflate":"gzip"),n=await new Response(new Blob([t]).stream().pipeThrough(r)).arrayBuffer();return new TextDecoder("utf-8").decode(n).trim()}catch{}return new TextDecoder("utf-8").decode(t).trim()}async function eb(t,e){if(t==null)return t;let r=TC(t);if(r&&typeof Buffer>"u"){let c=Xv(e,"content-encoding"),u=await zC(r,c);if(!u)return u;try{return JSON.parse(u)}catch{return u}}if(typeof t=="string")try{return JSON.parse(t)}catch{return t}let n=$C(t);if(!n)return t;let o=Xv(e,"content-encoding"),s=n,i=await SC();try{i&&(o?.includes("gzip")?s=i.gunzipSync(n):o?.includes("br")?s=i.brotliDecompressSync(n):o?.includes("deflate")?s=i.inflateSync(n):n.length>=2&&n[0]===31&&n[1]===139&&(s=i.gunzipSync(n)))}catch{s=n}let a=s.toString("utf-8").trim();if(!a)return a;try{return JSON.parse(a)}catch{return a}}function Da(t){let e=t.toLowerCase().trim();if(e.includes(":"))return!!(e==="::1"||e==="::"||e.startsWith("fc")||e.startsWith("fd")||e.startsWith("fe80")||e.startsWith("::ffff:"));let r=e.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);if(!r)return!1;let n=Number(r[1]),o=Number(r[2]);return n===0||n===10||n===127||n===100&&o>=64&&o<=127||n===169&&o===254||n===172&&o>=16&&o<=31||n===192&&o===168||n===255}function ap(t){let e;try{e=new URL(t)}catch{throw new Error(`Invalid URL: ${t}`)}if(e.protocol!=="http:"&&e.protocol!=="https:")throw new Error(`Disallowed protocol "${e.protocol}". Only http and https are allowed.`);let r=e.hostname.toLowerCase();if(new Set(["localhost","ip6-localhost","ip6-loopback"]).has(r))throw new Error(`Access to "${r}" is not allowed.`);if(/^\d+\.\d+\.\d+\.\d+$/.test(r)&&Da(r))throw new Error("Access to private/internal IP addresses is not allowed.");if(r.startsWith("[")&&Da(r.slice(1,-1)))throw new Error("Access to private/internal IPv6 addresses is not allowed.");let s=(typeof process<"u"?process.env.CKAN_ALLOWED_DOMAINS??"":"").split(",").map(i=>i.trim()).filter(Boolean);if(s.length>0&&!s.includes(r))throw new Error(`Domain "${r}" is not in the allowed list (CKAN_ALLOWED_DOMAINS).`)}function RC(t){return function(r,n,o){typeof n=="function"&&(o=n,n={});let s=n&&typeof n=="object"?n.family:void 0;t.lookup(r,{all:!0,family:s||0},(i,a)=>{if(i){o(i);return}let c=Array.isArray(a)?a:[a];for(let u of c)if(Da(u.address)){o(new Error(`Access to private/internal IP addresses is not allowed ("${r}" resolves to ${u.address}).`));return}if(n&&n.all){o(null,c);return}o(null,c[0].address,c[0].family)})}}var sp=null;function EC(){return sp||(sp=(async()=>{try{let t=await import("node:dns"),e=await import("node:http"),r=await import("node:https"),n=RC(t);return{httpAgent:new e.Agent({lookup:n}),httpsAgent:new r.Agent({lookup:n})}}catch{return null}})()),sp}var tb=null;async function ob(t){let e;try{tb?e=await tb(t):e=await(await import("node:dns")).promises.lookup(t,{all:!0})}catch{return}for(let r of e)if(Da(r.address))throw new Error(`Access to private/internal IP addresses is not allowed ("${t}" resolves to ${r.address}).`)}function rb(t,e,r,n){if(typeof process>"u"||!process.versions?.node)return;let o={ts:new Date().toISOString(),server:t,action:e,cache_hit:n};r.q!==void 0&&(o.q=r.q),r.fq!==void 0&&(o.fq=r.fq),r.sql!==void 0&&(o.sql=String(r.sql).slice(0,200)),r.id!==void 0&&(o.id=r.id),r.rows!==void 0&&(o.rows=r.rows),r.limit!==void 0&&(o.limit=r.limit);try{process.stderr.write(JSON.stringify(o)+`
|
|
46
|
+
`)}catch{}}async function U(t,e,r={},n={}){let o=typeof process<"u"&&!!process.versions?.node;ap(t);let s=t;try{let g=new URL(t).hostname,y=qa(g);y&&(s=y)}catch{}let i=s.replace(/\/$/,""),a=yn(s),c=`${i}${a}/${e}`,u=ep(),l=u.enabled&&n.cache!==!1,d=Wv(e,u.ttlDefault),p=l&&d>0?Qv():null,m=p?await Gv(s,e,r):"";if(p){let g=await p.get(m);if(g!==void 0)return ip=!0,rb(t,e,r,!0),g}if(ip=!1,op().enabled&&n.rateLimit!==!1){let g=new URL(s).hostname;await Yv().acquire(g)}try{let g;if(o){let y=await EC(),b=await Vt.get(c,{params:r,timeout:3e4,responseType:"arraybuffer",maxRedirects:5,...y?{httpAgent:y.httpAgent,httpsAgent:y.httpsAgent}:{},headers:{Accept:"application/json, text/plain, */*","Accept-Language":"en-US,en;q=0.9,it;q=0.8","Accept-Encoding":"gzip, deflate, br",Connection:"keep-alive","Sec-CH-UA":'"Chromium";v="120", "Not?A_Brand";v="24", "Google Chrome";v="120"',"Sec-CH-UA-Mobile":"?0","Sec-CH-UA-Platform":'"Linux"',"User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"}});g=await eb(b.data,b.headers)}else{let y=new URLSearchParams;for(let[Ve,Be]of Object.entries(r))Be!=null&&y.set(Ve,String(Be));let b=y.toString()?`${c}?${y.toString()}`:c,k=new AbortController,T=setTimeout(()=>k.abort(),3e4),R;try{R=await fetch(b,{method:"GET",signal:k.signal,headers:{Accept:"application/json, text/plain, */*","Accept-Encoding":"identity","User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"}})}finally{clearTimeout(T)}if(!R.ok)throw new sr(`CKAN API error (${R.status}): ${R.statusText}`,R.status,e);let me=await R.arrayBuffer(),ie={};R.headers.forEach((Ve,Be)=>{ie[Be]=Ve}),g=await eb(me,ie)}if(g&&g.success===!0){let y=g.result;if(p)try{JSON.stringify(y).length<=u.maxEntryBytes&&await p.set(m,y,d)}catch{}return rb(t,e,r,!1),y}else throw new sr(`CKAN API returned success=false: ${JSON.stringify(g)}`,void 0,e)}catch(g){if(g instanceof sr)throw g;if(Vt.isAxiosError(g)){let y=g;if(y.response){let b=y.response.status,k=y.response.data,T=k?.error?.message||k?.error||"Unknown error";throw new sr(`CKAN API error (${b}): ${T}`,b,e)}else throw y.code==="ECONNABORTED"?new Error(`Request timeout connecting to ${t}`):y.code==="ENOTFOUND"?new Error(`Server not found: ${t}`):new Error(`Network error: ${y.message}`)}throw g}}function W(t,e=Pr){return t.length<=e?t:t.substring(0,e)+`
|
|
47
47
|
|
|
48
|
-
... [Response truncated at ${e} characters]`}function it(t,e=Pr){let r=JSON.stringify(t,null,2);if(r.length<=e||(r=JSON.stringify(t),r.length<=e))return r;let n=structuredClone(t),o=["results","records","resources","packages","organizations","groups","tags"];for(let s of o)if(Array.isArray(n[s])&&n[s].length>0){let i=n[s].length;for(;n[s].length>1;)if(n[s].pop(),n._truncated=!0,n._original_count=i,r=JSON.stringify(n),r.length<=e)return r}return W(JSON.stringify(n),e)}function rt(t){try{if(!t)return"Invalid Date";let e=new Date(t);return Number.isNaN(e.getTime())?"Invalid Date":e.toISOString().slice(0,10)}catch{return"Invalid Date"}}function
|
|
48
|
+
... [Response truncated at ${e} characters]`}function it(t,e=Pr){let r=JSON.stringify(t,null,2);if(r.length<=e||(r=JSON.stringify(t),r.length<=e))return r;let n=structuredClone(t),o=["results","records","resources","packages","organizations","groups","tags"];for(let s of o)if(Array.isArray(n[s])&&n[s].length>0){let i=n[s].length;for(;n[s].length>1;)if(n[s].pop(),n._truncated=!0,n._original_count=i,r=JSON.stringify(n),r.length<=e)return r}return W(JSON.stringify(n),e)}function rt(t){try{if(!t)return"Invalid Date";let e=new Date(t);return Number.isNaN(e.getTime())?"Invalid Date":e.toISOString().slice(0,10)}catch{return"Invalid Date"}}function sb(t){if(!t||t===0)return"0 B";let e=1024,r=["B","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,n)).toFixed(2))+" "+r[n]}function PC(){try{return typeof WorkerGlobalScope<"u"}catch{return!1}}function se(t){return PC()?t+`
|
|
49
49
|
|
|
50
50
|
---
|
|
51
|
-
\u2139\uFE0F Demo instance (100k requests/day shared quota). For unlimited access: https://github.com/ondata/ckan-mcp-server#installation`:t}var
|
|
51
|
+
\u2139\uFE0F Demo instance (100k requests/day shared quota). For unlimited access: https://github.com/ondata/ckan-mcp-server#installation`:t}var AC=/\/resource\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i;function ib(t,e){if(!t)return null;let r,n;try{r=new URL(t),n=new URL(e)}catch{return null}if(r.hostname===n.hostname)return null;let o=r.pathname.match(AC);return o?{portalUrl:`${r.protocol}//${r.host}`,resourceId:o[1]}:null}function Ps(t,e){let r=Gf(t);return(or(t)?.dataset_view_url||Cr.defaults.dataset_view_url).replace("{server_url}",r).replace("{id}",e.id).replace("{name}",e.name)}function _n(t,e){let r=Gf(t);return(or(t)?.organization_view_url||Cr.defaults.organization_view_url).replace("{server_url}",r).replace("{id}",e.id).replace("{name}",e.name)}var ab="*:*",ub=/\b[a-zA-Z_][\w-]*:/,CC=/[+\-!(){}[\]^~*?:\\/|&]/g;function cb(t){return ub.test(t)}function OC(t){return t.replace(CC,"\\$&")}function NC(t){let e=new Date,r=e.toISOString(),n=/\b(?!metadata_)(modified|issued):\[NOW-(\d+)(DAYS?|MONTHS?|YEARS?)\s+TO\s+NOW\]/gi;return t.replace(n,(o,s,i,a)=>{let c=parseInt(i,10),u=new Date(e);switch(a.toLowerCase().replace(/s$/,"")){case"day":u.setDate(u.getDate()-c);break;case"month":u.setMonth(u.getMonth()-c);break;case"year":u.setFullYear(u.getFullYear()-c);break;default:return o}let d=u.toISOString();return`${s}:[${d} TO ${r}]`})}var IC=/\b(AND|OR|NOT)\b|[+\-!]/;function lb(t){let e=t.trim();return e==="*:*"||e===""||ub.test(e)||IC.test(e)?!1:e.split(/\s+/).filter(Boolean).length>1}function db(t){return t.trim().split(/\s+/).filter(Boolean).join(" OR ")}function Za(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function fb(t){return t!==Za(t)}function La(t,e,r){let o=Vv(t).force_text_field??!1,s=!1;if(r==="text"){let a=e.trim();s=a!==ab&&!cb(a)}else if(r==="default")s=!1;else if(o){let a=e.trim();s=a!==ab&&!cb(a)}let i=s?`text:(${OC(e)})`:e;return i=NC(i),{effectiveQuery:i,forcedTextField:s}}var cp=new Map;async function MC(t){let e=t.replace(/\/$/,"").toLowerCase();if(cp.has(e))return cp.get(e);let r="data OR dati",[n,o]=await Promise.allSettled([U(t,"package_search",{q:r,rows:0}),U(t,"package_search",{q:`text:(${r})`,rows:0})]),s=n.status==="fulfilled"?n.value.count??0:0,i=o.status==="fulfilled"?o.value.count??0:0,a=i>0&&(s===0||i>s*2);return cp.set(e,a),a}var mb={title:4,notes:2,tags:3,organization:1,holder:4,publisher:2},jC=new Set(["a","an","the","and","or","but","in","on","at","to","for","of","with","by","from","as","is","was","are","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","must","can","this","that","these","those"]),hb=t=>{let r=(t.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(n=>n.length>1&&!jC.has(n));return Array.from(new Set(r))},qC=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),gb=(t,e)=>{if(!t||e.length===0)return!1;let r=t.toLowerCase().replace(/_/g," ");return e.some(n=>new RegExp(`\\b${qC(n)}\\b`,"i").test(r))},As=(t,e,r)=>gb(t,e)?r:0,Ua=(t,e)=>{let r=Array.isArray(t.extras)?t.extras:[];for(let o of r)if(o&&typeof o=="object"&&o.key===e){let s=o.value;if(typeof s=="string"&&s.length>0)return s}let n=t[e];return typeof n=="string"?n:""},DC=(t,e,r=mb)=>{let n=hb(t),o=e.title||e.name||"",s=e.notes||"",i=e.organization?.title||e.organization?.name||e.owner_org||"",a=Ua(e,"holder_name"),c=Ua(e,"publisher_name"),u={title:As(o,n,r.title),notes:As(s,n,r.notes),tags:0,organization:As(i,n,r.organization),holder:As(a,n,r.holder),publisher:As(c,n,r.publisher),total:0};if(Array.isArray(e.tags)&&e.tags.length>0&&n.length>0){let l=e.tags.some(d=>{let p=typeof d=="string"?d:d?.name;return gb(p,n)});u.tags=l?r.tags:0}return u.total=u.title+u.notes+u.tags+u.organization+u.holder+u.publisher,{total:u.total,breakdown:u,terms:n}},yb=t=>{if(!t||t.access_services==null)return[];let e=t.access_services;if(Array.isArray(e))return e;if(typeof e=="string"&&e.trim().length>0)try{let r=JSON.parse(e);return Array.isArray(r)?r:[]}catch{return[]}return[]},_b=t=>{let e=[];for(let r of t){let n=r.endpoint_url;if(Array.isArray(n))for(let o of n)typeof o=="string"&&o.trim().length>0&&e.push(o.trim());else typeof n=="string"&&n.trim().length>0&&e.push(n.trim())}return Array.from(new Set(e))},up=t=>{if(!t)return null;let e=typeof t.download_url=="string"?t.download_url.trim():"",r=typeof t.access_url=="string"?t.access_url.trim():"",n=typeof t.url=="string"?t.url.trim():"";return e||r||n||null},ZC=t=>({...t,metadata_harvested_at:t.metadata_modified??null,resources:Array.isArray(t.resources)?t.resources.map(e=>{let r=yb(e),n=_b(r),o=up(e);return n.length===0&&!o?e:{...e,...n.length>0?{access_service_endpoints:n}:{},...o?{effective_download_url:o}:{}}}):t.resources}),LC=(t,e)=>{let r=`# Dataset: ${t.title||t.name}
|
|
52
52
|
|
|
53
|
-
`;
|
|
53
|
+
`;r+=`**Server**: ${e}
|
|
54
54
|
`,r+=`**Link**: ${Ps(e,t)}
|
|
55
55
|
`,r+=`**Full JSON metadata**: ${e.replace(/\/$/,"")}${yn(e)}/package_show?id=${t.id}
|
|
56
56
|
|
|
@@ -69,7 +69,12 @@ ${s}`:o}var np=null;function Xv(){return np}var bC=(()=>{let t=null;return async
|
|
|
69
69
|
`:r+=`- **Issued**: (missing in CKAN; downstream RDF may default to metadata_created, which is a record timestamp)
|
|
70
70
|
`,t.modified&&(r+=`- **Modified (Content)**: ${rt(t.modified)}
|
|
71
71
|
`),r+=`- **Metadata Modified (Record)**: ${rt(t.metadata_modified)}
|
|
72
|
-
|
|
72
|
+
`;let n=Ua(t,"holder_name");n&&(r+=`- **Rights Holder (dct:rightsHolder)**: ${n}
|
|
73
|
+
`);let o=Ua(t,"publisher_name");o&&(r+=`- **Publisher (dct:publisher)**: ${o}
|
|
74
|
+
`);let s=u=>typeof t[u]=="string"?t[u]:"",i=s("frequency");i&&(r+=`- **Update Frequency (dct:accrualPeriodicity)**: ${i}
|
|
75
|
+
`);let a=s("language");a&&(r+=`- **Language (dct:language)**: ${a}
|
|
76
|
+
`);let c=s("access_rights");if(c&&(r+=`- **Access Rights (dct:accessRights)**: ${c}
|
|
77
|
+
`),r+=`
|
|
73
78
|
`,t.organization&&(r+=`## Organization
|
|
74
79
|
|
|
75
80
|
`,r+=`- **Name**: ${t.organization.title||t.organization.name}
|
|
@@ -81,37 +86,37 @@ ${t.notes}
|
|
|
81
86
|
|
|
82
87
|
`),t.tags&&t.tags.length>0&&(r+=`## Tags
|
|
83
88
|
|
|
84
|
-
`,r+=t.tags.map(
|
|
89
|
+
`,r+=t.tags.map(u=>`- ${u.name}`).join(`
|
|
85
90
|
`)+`
|
|
86
91
|
|
|
87
92
|
`),t.groups&&t.groups.length>0){r+=`## Groups
|
|
88
93
|
|
|
89
|
-
`;for(let
|
|
94
|
+
`;for(let u of t.groups)r+=`- **${u.title||u.name}** (\`${u.name}\`)
|
|
90
95
|
`;r+=`
|
|
91
96
|
`}if(t.resources&&t.resources.length>0){r+=`## Resources (${t.resources.length})
|
|
92
97
|
|
|
93
|
-
`;for(let
|
|
94
|
-
|
|
95
|
-
`,r+=`- **ID**: \`${
|
|
96
|
-
`,r+=`- **Format**: ${
|
|
97
|
-
`,
|
|
98
|
-
`),r+=`- **URL**: ${
|
|
99
|
-
`;let
|
|
100
|
-
`);let
|
|
101
|
-
`),
|
|
102
|
-
`),
|
|
103
|
-
`),r+=`- **Created**: ${rt(
|
|
104
|
-
`,
|
|
105
|
-
`),
|
|
106
|
-
`:
|
|
98
|
+
`;for(let u of t.resources){r+=`### ${u.name||"Unnamed Resource"}
|
|
99
|
+
|
|
100
|
+
`,r+=`- **ID**: \`${u.id}\`
|
|
101
|
+
`,r+=`- **Format**: ${u.format||"Unknown"}
|
|
102
|
+
`,u.description&&(r+=`- **Description**: ${u.description}
|
|
103
|
+
`),r+=`- **URL**: ${u.url}
|
|
104
|
+
`;let l=yb(u),d=_b(l);d.length>0&&(r+=`- **Access Service Endpoints**: ${d.join(", ")}
|
|
105
|
+
`);let p=up(u);p&&(r+=`- **Effective Download URL**: ${p}
|
|
106
|
+
`),u.size&&(r+=`- **Size**: ${(f=>{if(!f||f===0)return"0 B";let h=1024,g=["B","KB","MB","GB"],y=Math.floor(Math.log(f)/Math.log(h));return parseFloat((f/Math.pow(h,y)).toFixed(2))+" "+g[y]})(u.size)}
|
|
107
|
+
`),u.mimetype&&(r+=`- **MIME Type**: ${u.mimetype}
|
|
108
|
+
`),r+=`- **Created**: ${rt(u.created)}
|
|
109
|
+
`,u.last_modified&&(r+=`- **Modified**: ${rt(u.last_modified)}
|
|
110
|
+
`),u.datastore_active===!0?r+=`- **DataStore**: \u2705 Available
|
|
111
|
+
`:u.datastore_active===!1?r+=`- **DataStore**: \u274C Not available
|
|
107
112
|
`:r+=`- **DataStore**: \u2753 Not reported by portal
|
|
108
|
-
`,r+=`- **Full JSON metadata**: ${e.replace(/\/$/,"")}${yn(e)}/resource_show?id=${
|
|
113
|
+
`,r+=`- **Full JSON metadata**: ${e.replace(/\/$/,"")}${yn(e)}/resource_show?id=${u.id}
|
|
109
114
|
`,r+=`
|
|
110
115
|
`}}if(t.extras&&t.extras.length>0){r+=`## Extra Fields
|
|
111
116
|
|
|
112
|
-
`;for(let
|
|
117
|
+
`;for(let u of t.extras)r+=`- **${u.key}**: ${u.value}
|
|
113
118
|
`;r+=`
|
|
114
|
-
`}return r};function
|
|
119
|
+
`}return r};function UC(t,e,r,n){return t!==void 0?{effectiveStart:(t-1)*e,effectiveRows:e}:{effectiveStart:r,effectiveRows:n}}function FC(t){let e=t.toUpperCase(),r=new Date;if(e==="NOW")return r.toISOString();let n=e.match(/^NOW\/(DAY|MONTH)$/);if(n)return n[1]==="DAY"||r.setUTCDate(1),r.setUTCHours(0,0,0,0),r.toISOString();let o=e.match(/^NOW([+-])(\d+)(YEARS?|MONTHS?|DAYS?|HOURS?|MINUTES?|SECONDS?)$/);if(o){let s=o[1]==="+"?1:-1,i=parseInt(o[2]);switch(o[3].replace(/S$/,"")){case"YEAR":r.setUTCFullYear(r.getUTCFullYear()+s*i);break;case"MONTH":r.setUTCMonth(r.getUTCMonth()+s*i);break;case"DAY":r.setUTCDate(r.getUTCDate()+s*i);break;case"HOUR":r.setUTCHours(r.getUTCHours()+s*i);break;case"MINUTE":r.setUTCMinutes(r.getUTCMinutes()+s*i);break;case"SECOND":r.setUTCSeconds(r.getUTCSeconds()+s*i);break}return r.toISOString()}return t}function pb(t){return t.replace(/\b(issued|modified):\[([^\]]*)\]/gi,(e,r,n)=>{let o=n.replace(/\bNOW(?:[+-]\d+(?:YEARS?|MONTHS?|DAYS?|HOURS?|MINUTES?|SECONDS?)|\/(?:DAY|MONTH))?\b/gi,s=>FC(s));return`${r}:[${o}]`})}function vb(t){let e=t.translation;if(!t.title&&e&&(t={...t,title:e.en?.title||Object.values(e)[0]?.title}),t.name||(t={...t,name:t.id}),t.organization?.title&&typeof t.organization.title=="object"){let r=t.organization.title;t={...t,organization:{...t.organization,title:r.en||Object.values(r)[0]}}}return t.tags&&(t={...t,tags:t.tags.map(r=>r.name?r:{...r,name:r.id||r["display-name"]||""})}),t}function HC(t,e){return{count:t.count,results:(t.results||[]).map(r=>{let n=e&&Qf(e)?vb(r):r;return{id:n.id,name:n.name,title:n.title||n.name,notes:n.notes?n.notes.substring(0,200)+(n.notes.length>200?"...":""):null,organization:n.organization?.title||n.organization?.name||null,tags:(n.tags||[]).map(o=>o.name),num_resources:n.num_resources??0,metadata_modified:n.metadata_modified,...e?{view_url:Ps(e,n)}:{}}}),...t.facets&&Object.keys(t.facets).length>0?{facets:t.facets}:{},...t.search_facets&&Object.keys(t.search_facets).length>0?{search_facets:t.search_facets}:{}}}function VC(t,e){return{id:t.id,name:t.name,title:t.title||t.name,notes:t.notes||null,organization:t.organization?{name:t.organization.name,title:t.organization.title}:null,tags:(t.tags||[]).map(r=>r.name),state:t.state,license_title:t.license_title||t.license_id||null,metadata_created:t.metadata_created,metadata_modified:t.metadata_modified,issued:t.issued||null,modified:t.modified||null,author:t.author||null,maintainer:t.maintainer||null,frequency:t.frequency||null,language:t.language||null,publisher_name:t.publisher_name||null,holder_name:t.holder_name||null,hvd_category:t.hvd_category||null,applicable_legislation:t.applicable_legislation||null,resources:(t.resources||[]).map(r=>({id:r.id,name:r.name||null,format:r.format||null,url:r.url||null,size:r.size||null,datastore_active:r.datastore_active??null,created:r.created||null,last_modified:r.last_modified||null,...e?{api_json_url:`${e.replace(/\/$/,"")}${yn(e)}/resource_show?id=${r.id}`}:{}})),...e?{view_url:Ps(e,t),api_json_url:`${e.replace(/\/$/,"")}${yn(e)}/package_show?id=${t.id}`}:{}}}function bb(t){t.registerTool("ckan_package_search",{title:"Search CKAN Datasets",description:`Search for datasets (packages) on a CKAN server using Solr query syntax.
|
|
115
120
|
|
|
116
121
|
Supports full Solr search capabilities including filters, facets, and sorting.
|
|
117
122
|
Use this to discover datasets matching specific criteria.
|
|
@@ -233,7 +238,7 @@ Query language:
|
|
|
233
238
|
Examples: locale "it" \u2192 Italian terms; "uk_UA" \u2192 Ukrainian (Cyrillic); "fr_FR" \u2192 French.
|
|
234
239
|
Exception: multilingual portals (e.g. data.europa.eu, open.canada.ca) accept EN + native terms joined with OR.
|
|
235
240
|
|
|
236
|
-
Typical workflow: ckan_status_show (check locale) \u2192 ckan_package_search (query in portal's language) \u2192 ckan_package_show (get full metadata + resource IDs) \u2192 ckan_datastore_search (query tabular data)`,inputSchema:v.object({server_url:v.string().url("Must be a valid URL").describe("Base URL of the CKAN server"),q:v.string().optional().default("*:*").describe("Search query in Solr syntax"),fq:v.string().optional().describe(`Filter query in Solr syntax; applied after scoring, does not affect relevance. CKAN extras fields use prefix 'extras_' (e.g. extras_hvd_category). For OR on same field use field:(val1 OR val2), never field:val1 OR field:val2 (silently breaks). Examples: 'organization:comune-palermo', 'res_format:CSV', 'extras_hvd_category:("uri1" OR "uri2")'.`),rows:v.coerce.number().int().min(0).max(1e3).optional().default(10).describe("Number of results to return"),start:v.coerce.number().int().min(0).optional().default(0).describe("Offset for pagination"),sort:v.string().optional().describe("Sort field and direction (e.g., 'metadata_modified desc')"),facet_field:v.array(v.string()).optional().describe("Fields to facet on"),facet_limit:v.coerce.number().int().min(1).optional().default(50).describe("Maximum facet values per field"),page:v.coerce.number().int().min(1).optional().describe("Page number (1-based); alias for start. Overrides start if provided."),page_size:v.coerce.number().int().min(1).max(1e3).optional().default(10).describe("Results per page when using page (default: 10)"),include_drafts:v.boolean().optional().default(!1).describe("Include draft datasets"),content_recent:v.boolean().optional().default(!1).describe("Use issued date with fallback to metadata_created for recent content"),content_recent_days:v.coerce.number().int().min(1).optional().default(30).describe("Day window for content_recent (default 30)"),query_parser:v.enum(["default","text"]).optional().describe("Override search parser ('text' forces text:(...) on non-fielded queries)"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async r=>{try{let n=r.q,o=n,s=r.sort;if(r.content_recent){let g=r.content_recent_days??30,y=new Date;y.setUTCDate(y.getUTCDate()-g);let b=y.toISOString(),k=new Date().toISOString(),T=`(issued:[${b} TO ${k}]) OR (-issued:* AND metadata_created:[NOW-${g}DAYS TO NOW])`;o=n&&n!=="*:*"?`(${n}) AND (${T})`:T,s||(s="issued desc, metadata_created desc")}let i=r.query_parser;!i&&!
|
|
241
|
+
Typical workflow: ckan_status_show (check locale) \u2192 ckan_package_search (query in portal's language) \u2192 ckan_package_show (get full metadata + resource IDs) \u2192 ckan_datastore_search (query tabular data)`,inputSchema:v.object({server_url:v.string().url("Must be a valid URL").describe("Base URL of the CKAN server"),q:v.string().optional().default("*:*").describe("Search query in Solr syntax"),fq:v.string().optional().describe(`Filter query in Solr syntax; applied after scoring, does not affect relevance. CKAN extras fields use prefix 'extras_' (e.g. extras_hvd_category). For OR on same field use field:(val1 OR val2), never field:val1 OR field:val2 (silently breaks). Examples: 'organization:comune-palermo', 'res_format:CSV', 'extras_hvd_category:("uri1" OR "uri2")'.`),rows:v.coerce.number().int().min(0).max(1e3).optional().default(10).describe("Number of results to return"),start:v.coerce.number().int().min(0).optional().default(0).describe("Offset for pagination"),sort:v.string().optional().describe("Sort field and direction (e.g., 'metadata_modified desc')"),facet_field:v.array(v.string()).optional().describe("Fields to facet on"),facet_limit:v.coerce.number().int().min(1).optional().default(50).describe("Maximum facet values per field"),page:v.coerce.number().int().min(1).optional().describe("Page number (1-based); alias for start. Overrides start if provided."),page_size:v.coerce.number().int().min(1).max(1e3).optional().default(10).describe("Results per page when using page (default: 10)"),include_drafts:v.boolean().optional().default(!1).describe("Include draft datasets"),content_recent:v.boolean().optional().default(!1).describe("Use issued date with fallback to metadata_created for recent content"),content_recent_days:v.coerce.number().int().min(1).optional().default(30).describe("Day window for content_recent (default 30)"),query_parser:v.enum(["default","text"]).optional().describe("Override search parser ('text' forces text:(...) on non-fielded queries)"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async r=>{try{let n=r.q,o=n,s=r.sort;if(r.content_recent){let g=r.content_recent_days??30,y=new Date;y.setUTCDate(y.getUTCDate()-g);let b=y.toISOString(),k=new Date().toISOString(),T=`(issued:[${b} TO ${k}]) OR (-issued:* AND metadata_created:[NOW-${g}DAYS TO NOW])`;o=n&&n!=="*:*"?`(${n}) AND (${T})`:T,s||(s="issued desc, metadata_created desc")}let i=r.query_parser;!i&&!Bv(r.server_url)&&await MC(r.server_url)&&(i="text");let{effectiveQuery:a}=La(r.server_url,o,i),{effectiveRows:c,effectiveStart:u}=UC(r.page,r.page_size,r.start,r.rows),l={q:pb(a),rows:c,start:u,include_private:r.include_drafts};r.fq&&(l.fq=pb(r.fq)),s&&(l.sort=s),r.facet_field&&r.facet_field.length>0&&(l["facet.field"]=JSON.stringify(r.facet_field),l["facet.limit"]=r.facet_limit);let d=await U(r.server_url,"package_search",l),p=!1;if(d.count===0&&fb(r.q)){let g=Za(r.q),{effectiveQuery:y}=La(r.server_url,g,r.query_parser),b=await U(r.server_url,"package_search",{...l,q:y});b.count>0&&(d=b,p=!0)}if(r.response_format==="json"){let g=HC(d,r.server_url);return{content:[{type:"text",text:it(g)}]}}let m="";if((r.q==="*:*"||r.q===void 0)&&(c===0||r.facet_field&&r.facet_field.some(g=>["organization","tags","groups","res_format"].includes(g)))){let g=lo(r.server_url);if(g)try{let y=await U(r.server_url,"package_search",{q:`${g.category_field}:*`,rows:0});y.count>0&&(m=`> **High Value Datasets (HVD)**: This portal contains **${y.count} datasets** classified as High Value Datasets under EU Regulation 2023/138.
|
|
237
242
|
|
|
238
243
|
`)}catch{}}let h=`# CKAN Package Search Results
|
|
239
244
|
|
|
@@ -243,7 +248,7 @@ ${r.content_recent?`**Content Recent**: last ${r.content_recent_days??30} days (
|
|
|
243
248
|
`:""}
|
|
244
249
|
${a!==n?`**Effective Query**: ${a}
|
|
245
250
|
`:""}
|
|
246
|
-
${p?`**Note**: Original query returned 0 results; retried with accent-stripped query "${
|
|
251
|
+
${p?`**Note**: Original query returned 0 results; retried with accent-stripped query "${Za(r.q)}".
|
|
247
252
|
`:""}
|
|
248
253
|
${r.fq?`**Filter**: ${r.fq}
|
|
249
254
|
`:""}
|
|
@@ -262,7 +267,7 @@ Note: showing top ${k.length} only. Use \`response_format: json\` for full list.
|
|
|
262
267
|
`,h+=`
|
|
263
268
|
`}}if(d.results&&d.results.length>0){h+=`## Datasets
|
|
264
269
|
|
|
265
|
-
`;for(let g of d.results){let y=
|
|
270
|
+
`;for(let g of d.results){let y=Qf(r.server_url)?vb(g):g;if(h+=`### ${y.title||y.name}
|
|
266
271
|
|
|
267
272
|
`,h+=`- **ID**: \`${y.id}\`
|
|
268
273
|
`,h+=`- **Name**: \`${y.name}\`
|
|
@@ -276,9 +281,9 @@ Note: showing top ${k.length} only. Use \`response_format: json\` for full list.
|
|
|
276
281
|
`}}else h+=`No datasets found matching your query.
|
|
277
282
|
`,h+=`
|
|
278
283
|
> **Note**: No data was found on this portal. Do not use information from other sources to supplement this result.
|
|
279
|
-
`,
|
|
284
|
+
`,lb(r.q)&&(h+=`
|
|
280
285
|
> **Tip**: Multi-term queries use AND by default (all terms must match). Try OR to broaden the search:
|
|
281
|
-
`,h+=`> \`q: "${
|
|
286
|
+
`,h+=`> \`q: "${db(r.q)}"\`
|
|
282
287
|
`);if(d.count>u+c)if(r.page!==void 0)h+=`
|
|
283
288
|
---
|
|
284
289
|
**More results available**: Use \`page: ${r.page+1}\` to see next page.
|
|
@@ -316,7 +321,7 @@ Examples:
|
|
|
316
321
|
- { server_url: "...", query: "trasporti", limit: 5, weights: { title: 5, notes: 2 } }
|
|
317
322
|
- { server_url: "...", query: "defibrillatori Comune di Lecce", weights: { holder: 5 } }
|
|
318
323
|
|
|
319
|
-
Typical workflow: ckan_find_relevant_datasets \u2192 ckan_package_show (inspect top results) \u2192 ckan_datastore_search (query data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),query:v.string().min(2).describe("Natural language or keyword query to match against dataset title, notes, tags, organization, holder and publisher"),limit:v.coerce.number().int().min(1).max(50).optional().default(10).describe("Number of datasets to return"),weights:v.object({title:v.coerce.number().min(0).optional().describe("Weight for title match (default 4)"),notes:v.coerce.number().min(0).optional().describe("Weight for description match (default 2)"),tags:v.coerce.number().min(0).optional().describe("Weight for tag match (default 3)"),organization:v.coerce.number().min(0).optional().describe("Weight for organization (CKAN catalog / harvester) match (default 1)"),holder:v.coerce.number().min(0).optional().describe("Weight for holder_name match \u2014 DCAT-AP_IT dct:rightsHolder, the actual data owner (default 4)"),publisher:v.coerce.number().min(0).optional().describe("Weight for publisher_name match \u2014 DCAT-AP_IT dct:publisher (default 2)")}).optional().describe("Per-field scoring weights; unspecified fields use defaults"),query_parser:v.enum(["default","text"]).optional().describe("Override search parser ('text' forces text:(...) on non-fielded queries)"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async r=>{try{let n={...
|
|
324
|
+
Typical workflow: ckan_find_relevant_datasets \u2192 ckan_package_show (inspect top results) \u2192 ckan_datastore_search (query data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),query:v.string().min(2).describe("Natural language or keyword query to match against dataset title, notes, tags, organization, holder and publisher"),limit:v.coerce.number().int().min(1).max(50).optional().default(10).describe("Number of datasets to return"),weights:v.object({title:v.coerce.number().min(0).optional().describe("Weight for title match (default 4)"),notes:v.coerce.number().min(0).optional().describe("Weight for description match (default 2)"),tags:v.coerce.number().min(0).optional().describe("Weight for tag match (default 3)"),organization:v.coerce.number().min(0).optional().describe("Weight for organization (CKAN catalog / harvester) match (default 1)"),holder:v.coerce.number().min(0).optional().describe("Weight for holder_name match \u2014 DCAT-AP_IT dct:rightsHolder, the actual data owner (default 4)"),publisher:v.coerce.number().min(0).optional().describe("Weight for publisher_name match \u2014 DCAT-AP_IT dct:publisher (default 2)")}).optional().describe("Per-field scoring weights; unspecified fields use defaults"),query_parser:v.enum(["default","text"]).optional().describe("Override search parser ('text' forces text:(...) on non-fielded queries)"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async r=>{try{let n={...mb,...r.weights??{}},o=Math.min(Math.max(r.limit*5,r.limit),100),{effectiveQuery:s}=La(r.server_url,r.query,r.query_parser),i=await U(r.server_url,"package_search",{q:s,rows:o,start:0}),a=(i.results||[]).map(d=>{let{total:p,breakdown:m}=DC(r.query,d,n);return{dataset:d,score:p,breakdown:m}});a.sort((d,p)=>p.score-d.score);let c=a.slice(0,r.limit).map(d=>{let p=d.dataset;return{id:p.id,name:p.name,title:p.title||p.name,organization:p.organization?.title||p.organization?.name||p.owner_org,tags:Array.isArray(p.tags)?p.tags.map(m=>m.name):[],metadata_modified:p.metadata_modified,score:d.score,breakdown:d.breakdown}}),u={query:r.query,terms:hb(r.query),weights:n,total_results:i.count??0,returned:c.length,results:c};if(r.response_format==="json")return{content:[{type:"text",text:W(JSON.stringify(u,null,2))}],structuredContent:u};let l=`# Relevant CKAN Datasets
|
|
320
325
|
|
|
321
326
|
`;return l+=`**Server**: ${r.server_url}
|
|
322
327
|
`,l+=`**Query**: ${r.query}
|
|
@@ -382,7 +387,7 @@ Examples:
|
|
|
382
387
|
- { server_url: "https://dati.gov.it/opendata", id: "dataset-name" }
|
|
383
388
|
- { server_url: "...", id: "abc-123-def", include_tracking: true }
|
|
384
389
|
|
|
385
|
-
Typical workflow: ckan_package_show \u2192 pick a resource with datastore_active=true \u2192 ckan_datastore_search (query its data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),id:v.string().min(1).describe("Dataset ID (UUID) or machine-readable name slug (e.g., 'raccolta-differenziata-comuni')"),include_tracking:v.boolean().optional().default(!1).describe("Include tracking statistics"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async r=>{try{let n=await U(r.server_url,"package_show",{id:r.id,include_tracking:r.include_tracking});if(r.response_format==="json"){let s=
|
|
390
|
+
Typical workflow: ckan_package_show \u2192 pick a resource with datastore_active=true \u2192 ckan_datastore_search (query its data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),id:v.string().min(1).describe("Dataset ID (UUID) or machine-readable name slug (e.g., 'raccolta-differenziata-comuni')"),include_tracking:v.boolean().optional().default(!1).describe("Include tracking statistics"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async r=>{try{let n=await U(r.server_url,"package_show",{id:r.id,include_tracking:r.include_tracking});if(r.response_format==="json"){let s=VC(ZC(n),r.server_url);return{content:[{type:"text",text:it(s)}],structuredContent:s}}let o=LC(n,r.server_url);return{content:[{type:"text",text:W(se(o))}]}}catch(n){return{content:[{type:"text",text:we(n,"ckan_package_show")}],isError:!0}}});async function e(r,n){try{return await U(r,"datastore_search",{resource_id:n,limit:0},{cache:!1}),!0}catch{return!1}}t.registerTool("ckan_list_resources",{title:"List CKAN Dataset Resources",description:`List all resources in a dataset with a compact summary.
|
|
386
391
|
|
|
387
392
|
Returns a focused table of resources showing format, size, DataStore availability, and download URL.
|
|
388
393
|
Use this to quickly assess what files a dataset contains before deciding how to access the data.
|
|
@@ -405,7 +410,7 @@ Typical workflow: ckan_package_search \u2192 ckan_list_resources (assess availab
|
|
|
405
410
|
When a resource has DataStore=false but its download URL belongs to a different (source) portal,
|
|
406
411
|
the tool automatically probes the source portal for DataStore availability and reports
|
|
407
412
|
source_datastore_active and source_portal_url so you can query the data there instead.
|
|
408
|
-
Set check_source_portal=false to skip these extra HTTP calls.`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server"),id:v.string().min(1).describe("Dataset ID or name"),format_filter:v.string().optional().describe("Filter resources by format, case-insensitive (e.g., 'CSV', 'json', 'XLSX')"),check_source_portal:v.boolean().optional().describe("When true (default), probes the source portal for DataStore availability when a resource URL points to a different CKAN instance"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async r=>{try{let n=await U(r.server_url,"package_show",{id:r.id}),o=Array.isArray(n.resources)?n.resources:[],s=r.format_filter?.toUpperCase(),i=r.check_source_portal!==!1,a=o.filter(u=>!s||(u.format||"").toUpperCase()===s).map(u=>{let l=
|
|
413
|
+
Set check_source_portal=false to skip these extra HTTP calls.`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server"),id:v.string().min(1).describe("Dataset ID or name"),format_filter:v.string().optional().describe("Filter resources by format, case-insensitive (e.g., 'CSV', 'json', 'XLSX')"),check_source_portal:v.boolean().optional().describe("When true (default), probes the source portal for DataStore availability when a resource URL points to a different CKAN instance"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async r=>{try{let n=await U(r.server_url,"package_show",{id:r.id}),o=Array.isArray(n.resources)?n.resources:[],s=r.format_filter?.toUpperCase(),i=r.check_source_portal!==!1,a=o.filter(u=>!s||(u.format||"").toUpperCase()===s).map(u=>{let l=up(u);return{name:u.name||"Unnamed Resource",id:u.id,format:u.format||"Unknown",size:u.size?sb(u.size):null,datastore_active:u.datastore_active===!0,url:l}});if(i&&await Promise.all(a.map(async(u,l)=>{if(u.datastore_active)return;let d=ib(u.url,r.server_url);if(!d)return;let p=await e(d.portalUrl,d.resourceId);a[l].source_datastore_active=p,a[l].source_portal_url=p?d.portalUrl:null})),r.response_format==="json"){let u={dataset_id:n.id,dataset_name:n.name,dataset_title:n.title||n.name,total_resources:o.length,filtered_resources:a.length,format_filter:s??null,resources:a};return{content:[{type:"text",text:W(JSON.stringify(u,null,2))}],structuredContent:u}}let c=`# Resources: ${n.title||n.name}
|
|
409
414
|
|
|
410
415
|
`;if(c+=`**Server**: ${r.server_url}
|
|
411
416
|
`,c+=`**Dataset**: \`${n.name}\` (\`${n.id}\`)
|
|
@@ -419,7 +424,7 @@ Set check_source_portal=false to skip these extra HTTP calls.`,inputSchema:v.obj
|
|
|
419
424
|
`;for(let d of a){let p=d.name.length>40?d.name.substring(0,37)+"...":d.name,m=d.datastore_active?"Yes":"No",f=d.size||"-";c+=`| ${p} | ${d.format} | ${f} | ${m} | \`${d.id}\` |
|
|
420
425
|
`}let u=a.filter(d=>d.datastore_active);if(u.length>0){c+="\n**DataStore-enabled resources** (queryable with `ckan_datastore_search`):\n";for(let d of u)c+=`- **${d.name}** (${d.format}): \`${d.id}\`
|
|
421
426
|
`}let l=a.filter(d=>d.source_datastore_active&&d.source_portal_url);if(l.length>0){c+="\n**Available on source portal** (use `ckan_datastore_search` with the source portal URL):\n";for(let d of l)c+=`- **${d.name}** (${d.format}): \`${d.id}\` on ${d.source_portal_url}
|
|
422
|
-
`}}return{content:[{type:"text",text:W(se(c))}]}}catch(n){return{content:[{type:"text",text:we(n,"ckan_list_resources")}],isError:!0}}})}function
|
|
427
|
+
`}}return{content:[{type:"text",text:W(se(c))}]}}catch(n){return{content:[{type:"text",text:we(n,"ckan_list_resources")}],isError:!0}}})}function BC(t,e){let r=`# Organization: ${t.title||t.name}
|
|
423
428
|
|
|
424
429
|
`;if(r+=`**Server**: ${e}
|
|
425
430
|
`,r+=`**Link**: ${_n(e,t)}
|
|
@@ -446,7 +451,7 @@ ${t.description}
|
|
|
446
451
|
|
|
447
452
|
`;for(let n of t.users)r+=`- **${n.name}** (${n.capacity})
|
|
448
453
|
`;r+=`
|
|
449
|
-
`}return r}function
|
|
454
|
+
`}return r}function KC(t){return Array.isArray(t)?{count:t.length,organizations:t.map(e=>typeof e=="string"?e:{id:e.id,name:e.name,title:e.title||e.name,package_count:e.package_count??0})}:t}function JC(t,e){return{id:t.id,name:t.name,title:t.title||t.name,description:t.description||null,image_url:t.image_url||null,package_count:t.package_count??0,created:t.created||null,view_url:_n(e,t),packages:(t.packages||[]).map(r=>({id:r.id,name:r.name,title:r.title||r.name,metadata_modified:r.metadata_modified||null}))}}function wb(t){t.registerTool("ckan_organization_list",{title:"List CKAN Organizations",description:`List all organizations on a CKAN server.
|
|
450
455
|
|
|
451
456
|
Organizations are entities that publish and manage datasets.
|
|
452
457
|
|
|
@@ -478,7 +483,7 @@ Note: organization_list returned 500; using package_search facets.
|
|
|
478
483
|
`,d+=`- **Datasets**: ${p.package_count||0}
|
|
479
484
|
`,d+=`- **Link**: ${_n(e.server_url,p)}
|
|
480
485
|
|
|
481
|
-
`;return{content:[{type:"text",text:W(se(d))}]}}throw o}if(e.response_format==="json"){let o=
|
|
486
|
+
`;return{content:[{type:"text",text:W(se(d))}]}}throw o}if(e.response_format==="json"){let o=KC(r);return{content:[{type:"text",text:it(o)}],structuredContent:o}}let n=`# CKAN Organizations
|
|
482
487
|
|
|
483
488
|
`;if(n+=`**Server**: ${e.server_url}
|
|
484
489
|
`,n+=`**Total**: ${Array.isArray(r)?r.length:"Unknown"}
|
|
@@ -505,7 +510,7 @@ Args:
|
|
|
505
510
|
Returns:
|
|
506
511
|
Organization details with optional datasets and users
|
|
507
512
|
|
|
508
|
-
Typical workflow: ckan_organization_show \u2192 ckan_package_show (inspect a dataset) \u2192 ckan_datastore_search (query its data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),id:v.string().min(1).describe("Organization ID (UUID) or machine-readable name slug (e.g., 'regione-siciliana')"),include_datasets:v.boolean().optional().default(!0).describe("Include the list of datasets published by this organization"),include_users:v.boolean().optional().default(!1).describe("Include the list of users belonging to this organization"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=await U(e.server_url,"organization_show",{id:e.id,include_datasets:e.include_datasets,include_users:e.include_users});if(e.response_format==="json"){let o=
|
|
513
|
+
Typical workflow: ckan_organization_show \u2192 ckan_package_show (inspect a dataset) \u2192 ckan_datastore_search (query its data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),id:v.string().min(1).describe("Organization ID (UUID) or machine-readable name slug (e.g., 'regione-siciliana')"),include_datasets:v.boolean().optional().default(!0).describe("Include the list of datasets published by this organization"),include_users:v.boolean().optional().default(!1).describe("Include the list of users belonging to this organization"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=await U(e.server_url,"organization_show",{id:e.id,include_datasets:e.include_datasets,include_users:e.include_users});if(e.response_format==="json"){let o=JC(r,e.server_url);return{content:[{type:"text",text:it(o)}],structuredContent:o}}let n=BC(r,e.server_url);return{content:[{type:"text",text:W(se(n))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_organization_show")}],isError:!0}}}),t.registerTool("ckan_organization_search",{title:"Search CKAN Organizations by Name",description:`Search for organizations by name pattern.
|
|
509
514
|
|
|
510
515
|
This tool provides a simpler interface than package_search for finding organizations.
|
|
511
516
|
Wildcards are automatically added around the search pattern.
|
|
@@ -537,7 +542,7 @@ Typical workflow: ckan_organization_search \u2192 ckan_organization_show (get de
|
|
|
537
542
|
`,i+=`| Organization | Datasets | Link |
|
|
538
543
|
`,i+=`|--------------|----------|------|
|
|
539
544
|
`;for(let a of o){let c=_n(e.server_url,{name:a.name});i+=`| ${a.display_name||a.name} | ${a.count} | ${c} |
|
|
540
|
-
`}}return{content:[{type:"text",text:W(se(i))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_organization_search")}],isError:!0}}})}function
|
|
545
|
+
`}}return{content:[{type:"text",text:W(se(i))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_organization_search")}],isError:!0}}})}function WC(t,e,r,n,o){let s=`# DataStore Query Results
|
|
541
546
|
|
|
542
547
|
`;if(s+=`**Server**: ${e}
|
|
543
548
|
`,s+=`**Resource ID**: \`${r}\`
|
|
@@ -561,7 +566,7 @@ Typical workflow: ckan_organization_search \u2192 ckan_organization_show (get de
|
|
|
561
566
|
`,s+=`
|
|
562
567
|
> **Note**: No data was found on this portal. Do not use information from other sources to supplement this result.
|
|
563
568
|
`;if(t.total&&t.total>n+(t.records?.length||0)){let i=n+o;s+=`**More results available**: Use \`offset: ${i}\` for next page.
|
|
564
|
-
`}return s}function
|
|
569
|
+
`}return s}function GC(t,e,r){let n=t.records||[],o=(t.fields?.map(i=>i.id)||Object.keys(n[0]||{})).filter(i=>i!=="_id"),s=`# DataStore SQL Results
|
|
565
570
|
|
|
566
571
|
`;if(s+=`**Server**: ${e}
|
|
567
572
|
`,s+=`**SQL**: \`${r}\`
|
|
@@ -583,7 +588,7 @@ Typical workflow: ckan_organization_search \u2192 ckan_organization_show (get de
|
|
|
583
588
|
`}else s+=`No records returned by the SQL query.
|
|
584
589
|
`,s+=`
|
|
585
590
|
> **Note**: No data was found on this portal. Do not use information from other sources to supplement this result.
|
|
586
|
-
`;return s}function
|
|
591
|
+
`;return s}function xb(t){let e=(t.fields||[]).filter(n=>n.id!=="_id"),r=(t.records||[]).map(n=>{let{_id:o,...s}=n;return s});return{resource_id:t.resource_id||null,fields:e,records:r,total:t.total??0}}function kb(t){t.registerTool("ckan_datastore_search",{title:"Search CKAN DataStore",description:`Query data from a CKAN DataStore resource.
|
|
587
592
|
|
|
588
593
|
The DataStore allows SQL-like queries on tabular data. Not all resources have DataStore enabled.
|
|
589
594
|
|
|
@@ -612,7 +617,7 @@ Examples:
|
|
|
612
617
|
- { server_url: "...", resource_id: "...", filters: { "regione": "Sicilia" } }
|
|
613
618
|
- { server_url: "...", resource_id: "...", sort: "anno desc", limit: 100 }
|
|
614
619
|
|
|
615
|
-
Typical workflow: ckan_package_search \u2192 ckan_package_show (find resource_id with datastore_active=true) \u2192 ckan_datastore_search (limit=0 to get columns) \u2192 ckan_datastore_search (with filters)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),resource_id:v.string().min(1).describe("UUID of the DataStore resource (from ckan_package_show resource.id where datastore_active is true)"),q:v.string().optional().describe("Full-text search across all fields"),filters:v.record(v.any()).optional().describe('Key-value filters for exact matches (e.g., { "regione": "Sicilia", "anno": 2023 })'),limit:v.coerce.number().int().min(0).max(32e3).optional().default(100).describe("Max rows to return (default 100, max 32000); use 0 to get only column names without data"),offset:v.coerce.number().int().min(0).optional().default(0).describe("Pagination offset"),fields:v.array(v.string()).optional().describe("Specific field names to return; omit to return all fields"),sort:v.string().optional().describe("Sort expression (e.g., 'anno desc', 'nome asc')"),distinct:v.boolean().optional().default(!1).describe("Return only distinct rows"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r={resource_id:e.resource_id,limit:e.limit,offset:e.offset,distinct:e.distinct};e.q&&(r.q=e.q),e.filters&&(r.filters=JSON.stringify(e.filters)),e.fields&&(r.fields=e.fields.join(",")),e.sort&&(r.sort=e.sort);let n=await U(e.server_url,"datastore_search",r);if(e.response_format==="json"){let s=
|
|
620
|
+
Typical workflow: ckan_package_search \u2192 ckan_package_show (find resource_id with datastore_active=true) \u2192 ckan_datastore_search (limit=0 to get columns) \u2192 ckan_datastore_search (with filters)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),resource_id:v.string().min(1).describe("UUID of the DataStore resource (from ckan_package_show resource.id where datastore_active is true)"),q:v.string().optional().describe("Full-text search across all fields"),filters:v.record(v.any()).optional().describe('Key-value filters for exact matches (e.g., { "regione": "Sicilia", "anno": 2023 })'),limit:v.coerce.number().int().min(0).max(32e3).optional().default(100).describe("Max rows to return (default 100, max 32000); use 0 to get only column names without data"),offset:v.coerce.number().int().min(0).optional().default(0).describe("Pagination offset"),fields:v.array(v.string()).optional().describe("Specific field names to return; omit to return all fields"),sort:v.string().optional().describe("Sort expression (e.g., 'anno desc', 'nome asc')"),distinct:v.boolean().optional().default(!1).describe("Return only distinct rows"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r={resource_id:e.resource_id,limit:e.limit,offset:e.offset,distinct:e.distinct};e.q&&(r.q=e.q),e.filters&&(r.filters=JSON.stringify(e.filters)),e.fields&&(r.fields=e.fields.join(",")),e.sort&&(r.sort=e.sort);let n=await U(e.server_url,"datastore_search",r);if(e.response_format==="json"){let s=xb(n);return{content:[{type:"text",text:it(s)}]}}let o=WC(n,e.server_url,e.resource_id,e.offset,e.limit);return{content:[{type:"text",text:W(se(o))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_datastore_search")}],isError:!0}}}),t.registerTool("ckan_datastore_search_sql",{title:"Search CKAN DataStore with SQL",description:`Run SQL queries on a CKAN DataStore resource.
|
|
616
621
|
|
|
617
622
|
This endpoint is only available on CKAN portals with DataStore enabled and SQL access exposed.
|
|
618
623
|
|
|
@@ -630,7 +635,7 @@ Examples:
|
|
|
630
635
|
|
|
631
636
|
Typical workflow: ckan_package_show (get resource_id) \u2192 ckan_datastore_search_sql (run SQL on it)
|
|
632
637
|
|
|
633
|
-
Security note: SQL queries are forwarded directly to the CKAN DataStore API. The CKAN server enforces its own access controls and read-only permissions. No local database is exposed. Queries are limited to public DataStore resources on the target portal.`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),sql:v.string().min(1).describe('SQL SELECT query; resource_id is the table name, must be double-quoted (e.g., SELECT * FROM "abc-123" LIMIT 10)'),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=await U(e.server_url,"datastore_search_sql",{sql:e.sql});if(e.response_format==="json"){let o=
|
|
638
|
+
Security note: SQL queries are forwarded directly to the CKAN DataStore API. The CKAN server enforces its own access controls and read-only permissions. No local database is exposed. Queries are limited to public DataStore resources on the target portal.`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),sql:v.string().min(1).describe('SQL SELECT query; resource_id is the table name, must be double-quoted (e.g., SELECT * FROM "abc-123" LIMIT 10)'),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=await U(e.server_url,"datastore_search_sql",{sql:e.sql});if(e.response_format==="json"){let o=xb(r);return{content:[{type:"text",text:it(o)}],structuredContent:o}}let n=GC(r,e.server_url,e.sql);return{content:[{type:"text",text:W(se(n))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_datastore_search_sql")}],isError:!0}}})}function QC(t,e,r){let n=Jv(e),o=n?`**SPARQL Endpoint**: ${n.endpoint_url}
|
|
634
639
|
`:"",s=r!==void 0?`**HVD Datasets**: ${r}
|
|
635
640
|
`:"",i=t.locale_default?`**Portal Locale**: ${t.locale_default}
|
|
636
641
|
`:"";return`# CKAN Server Status
|
|
@@ -640,7 +645,7 @@ Security note: SQL queries are forwarded directly to the CKAN DataStore API. The
|
|
|
640
645
|
**CKAN Version**: ${t.ckan_version||"Unknown"}
|
|
641
646
|
**Site Title**: ${t.site_title||"N/A"}
|
|
642
647
|
**Site URL**: ${t.site_url||"N/A"}
|
|
643
|
-
`+i+o+s}function
|
|
648
|
+
`+i+o+s}function Sb(t){t.registerTool("ckan_status_show",{title:"Check CKAN Server Status",description:`Check if a CKAN server is available and get version information.
|
|
644
649
|
|
|
645
650
|
Useful to verify server accessibility before making other requests.
|
|
646
651
|
Also shows the count of High-Value Datasets (HVD) when the portal supports it.
|
|
@@ -651,8 +656,8 @@ Args:
|
|
|
651
656
|
Returns:
|
|
652
657
|
Server status, version information, and HVD dataset count (if available)
|
|
653
658
|
|
|
654
|
-
Typical workflow: ckan_status_show (verify server is up) \u2192 ckan_package_search (discover datasets)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server")}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=lo(e.server_url),[n,o]=await Promise.all([U(e.server_url,"status_show",{}),r?U(e.server_url,"package_search",{fq:`${r.category_field}:*`,rows:0}).then(i=>i.count).catch(()=>{}):Promise.resolve(void 0)]),s=
|
|
655
|
-
${r instanceof Error?r.message:String(r)}`}],isError:!0}}})}function
|
|
659
|
+
Typical workflow: ckan_status_show (verify server is up) \u2192 ckan_package_search (discover datasets)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server")}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=lo(e.server_url),[n,o]=await Promise.all([U(e.server_url,"status_show",{}),r?U(e.server_url,"package_search",{fq:`${r.category_field}:*`,rows:0}).then(i=>i.count).catch(()=>{}):Promise.resolve(void 0)]),s=QC(n,e.server_url,o);return{content:[{type:"text",text:se(s)}],structuredContent:n}}catch(r){return{content:[{type:"text",text:`Server appears to be offline or not a valid CKAN instance:
|
|
660
|
+
${r instanceof Error?r.message:String(r)}`}],isError:!0}}})}function YC(t){let e=t,o=e?.search_facets?.tags?.items;if(Array.isArray(o))return o.map(i=>({name:i?.name||i?.display_name||String(i),count:typeof i?.count=="number"?i.count:0,display_name:i?.display_name}));let s=e?.facets?.tags;return Array.isArray(s)?s.length>0&&typeof s[0]=="object"?s.map(i=>({name:i?.name||i?.display_name||String(i),count:typeof i?.count=="number"?i.count:0,display_name:i?.display_name})):s.map(i=>({name:i,count:0})):s&&typeof s=="object"?Object.entries(s).map(([i,a])=>({name:i,count:typeof a=="number"?a:Number(a)||0})):[]}function $b(t){t.registerTool("ckan_tag_list",{title:"List CKAN Tags",description:`List tags from a CKAN server using faceting.
|
|
656
661
|
|
|
657
662
|
This returns tag names with counts, optionally filtered by dataset query or tag substring.
|
|
658
663
|
|
|
@@ -667,7 +672,7 @@ Args:
|
|
|
667
672
|
Returns:
|
|
668
673
|
List of tags with counts (from faceting)
|
|
669
674
|
|
|
670
|
-
Typical workflow: ckan_tag_list \u2192 ckan_package_search with fq="tags:tag_name" (find datasets by tag) \u2192 ckan_package_show`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),q:v.string().optional().default("*:*").describe("Dataset search query in Solr syntax to scope the tag facet (default: '*:*' for all datasets)"),fq:v.string().optional().describe("Filter query in Solr syntax (e.g., 'organization:comune-palermo') to restrict which datasets contribute to tag counts"),tag_query:v.string().optional().describe("Substring filter applied to tag names after faceting (e.g., 'acqua' to keep only tags containing 'acqua')"),limit:v.number().int().min(1).max(1e3).optional().default(100).describe("Max tags to return (default 100, max 1000); tags are sorted by count descending"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{let r={q:e.q,rows:0,"facet.field":JSON.stringify(["tags"]),"facet.limit":e.limit};e.fq&&(r.fq=e.fq);let n=await U(e.server_url,"package_search",r),o=
|
|
675
|
+
Typical workflow: ckan_tag_list \u2192 ckan_package_search with fq="tags:tag_name" (find datasets by tag) \u2192 ckan_package_show`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),q:v.string().optional().default("*:*").describe("Dataset search query in Solr syntax to scope the tag facet (default: '*:*' for all datasets)"),fq:v.string().optional().describe("Filter query in Solr syntax (e.g., 'organization:comune-palermo') to restrict which datasets contribute to tag counts"),tag_query:v.string().optional().describe("Substring filter applied to tag names after faceting (e.g., 'acqua' to keep only tags containing 'acqua')"),limit:v.number().int().min(1).max(1e3).optional().default(100).describe("Max tags to return (default 100, max 1000); tags are sorted by count descending"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{let r={q:e.q,rows:0,"facet.field":JSON.stringify(["tags"]),"facet.limit":e.limit};e.fq&&(r.fq=e.fq);let n=await U(e.server_url,"package_search",r),o=YC(n);if(e.tag_query){let i=e.tag_query.toLowerCase();o=o.filter(a=>a.name.toLowerCase().includes(i))}if(o=o.sort((i,a)=>a.count-i.count||i.name.localeCompare(a.name)).slice(0,e.limit),e.response_format==="json"){let i={count:o.length,tags:o};return{content:[{type:"text",text:W(JSON.stringify(i,null,2))}],structuredContent:i}}let s=`# CKAN Tags
|
|
671
676
|
|
|
672
677
|
`;if(s+=`**Server**: ${e.server_url}
|
|
673
678
|
`,s+=`**Query**: ${e.q}
|
|
@@ -677,10 +682,10 @@ Typical workflow: ckan_tag_list \u2192 ckan_package_search with fq="tags:tag_nam
|
|
|
677
682
|
|
|
678
683
|
`,o.length===0)s+=`No tags found.
|
|
679
684
|
`;else for(let i of o)s+=`- **${i.name}**: ${i.count}
|
|
680
|
-
`;return{content:[{type:"text",text:W(se(s))}]}}catch(r){return{content:[{type:"text",text:`Error listing tags: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}})}function
|
|
685
|
+
`;return{content:[{type:"text",text:W(se(s))}]}}catch(r){return{content:[{type:"text",text:`Error listing tags: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}})}function Tb(t,e){return`${t.replace(/\/$/,"")}/group/${e.name}`}function XC(t,e){let r=`# Group: ${t.title||t.name}
|
|
681
686
|
|
|
682
687
|
`;if(r+=`**Server**: ${e}
|
|
683
|
-
`,r+=`**Link**: ${
|
|
688
|
+
`,r+=`**Link**: ${Tb(e,t)}
|
|
684
689
|
|
|
685
690
|
`,r+=`## Details
|
|
686
691
|
|
|
@@ -700,7 +705,7 @@ ${t.description}
|
|
|
700
705
|
`;t.packages.length>20&&(r+=`
|
|
701
706
|
... and ${t.packages.length-20} more datasets
|
|
702
707
|
`),r+=`
|
|
703
|
-
`}return r}function
|
|
708
|
+
`}return r}function eO(t){let e=t,n=e?.search_facets?.groups?.items;if(Array.isArray(n))return n.map(s=>({name:s?.name||s?.display_name||String(s),display_name:s?.display_name,count:typeof s?.count=="number"?s.count:0}));let o=e?.facets?.groups;return Array.isArray(o)?o.length>0&&typeof o[0]=="object"?o.map(s=>({name:s?.name||s?.display_name||String(s),display_name:s?.display_name,count:typeof s?.count=="number"?s.count:0})):o.map(s=>({name:s,count:0})):o&&typeof o=="object"?Object.entries(o).map(([s,i])=>({name:s,count:typeof i=="number"?i:Number(i)||0})):[]}function tO(t){return Array.isArray(t)?{count:t.length,groups:t.map(e=>typeof e=="string"?e:{id:e.id,name:e.name,title:e.title||e.name,package_count:e.package_count??0})}:t}function rO(t){return{id:t.id,name:t.name,title:t.title||t.name,description:t.description||null,package_count:t.package_count??0,created:t.created||null,packages:(t.packages||[]).map(e=>({id:e.id,name:e.name,title:e.title||e.name,metadata_modified:e.metadata_modified||null}))}}function zb(t){t.registerTool("ckan_group_list",{title:"List CKAN Groups",description:`List all groups on a CKAN server.
|
|
704
709
|
|
|
705
710
|
Groups are thematic collections of datasets.
|
|
706
711
|
|
|
@@ -719,7 +724,7 @@ Typical workflow: ckan_group_list \u2192 ckan_group_show (inspect one) \u2192 ck
|
|
|
719
724
|
|
|
720
725
|
**Server**: ${e.server_url}
|
|
721
726
|
**Total groups (with datasets)**: ${s}
|
|
722
|
-
`}]}}let r=await U(e.server_url,"group_list",{all_fields:e.all_fields,sort:e.sort,limit:e.limit,offset:e.offset});if(e.response_format==="json"){let o=
|
|
727
|
+
`}]}}let r=await U(e.server_url,"group_list",{all_fields:e.all_fields,sort:e.sort,limit:e.limit,offset:e.offset});if(e.response_format==="json"){let o=tO(r);return{content:[{type:"text",text:it(o)}],structuredContent:o}}let n=`# CKAN Groups
|
|
723
728
|
|
|
724
729
|
`;if(n+=`**Server**: ${e.server_url}
|
|
725
730
|
`,n+=`**Total**: ${Array.isArray(r)?r.length:"Unknown"}
|
|
@@ -731,7 +736,7 @@ Typical workflow: ckan_group_list \u2192 ckan_group_show (inspect one) \u2192 ck
|
|
|
731
736
|
`,o.description&&(n+=`- **Description**: ${o.description.substring(0,200)}
|
|
732
737
|
`),n+=`- **Datasets**: ${o.package_count||0}
|
|
733
738
|
`,n+=`- **Created**: ${rt(o.created)}
|
|
734
|
-
`,n+=`- **Link**: ${
|
|
739
|
+
`,n+=`- **Link**: ${Tb(e.server_url,o)}
|
|
735
740
|
|
|
736
741
|
`;else n+=r.map(o=>`- ${o}`).join(`
|
|
737
742
|
`);return{content:[{type:"text",text:W(se(n))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_group_list")}],isError:!0}}}),t.registerTool("ckan_group_show",{title:"Show CKAN Group Details",description:`Get details of a specific group.
|
|
@@ -745,7 +750,7 @@ Args:
|
|
|
745
750
|
Returns:
|
|
746
751
|
Group details with optional datasets
|
|
747
752
|
|
|
748
|
-
Typical workflow: ckan_group_show \u2192 ckan_package_show (inspect a dataset) \u2192 ckan_datastore_search (query its data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),id:v.string().min(1).describe("Group ID (UUID) or machine-readable name slug (e.g., 'transport', 'energia')"),include_datasets:v.boolean().optional().default(!0).describe("Include the list of datasets belonging to this group"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=await U(e.server_url,"group_show",{id:e.id,include_datasets:e.include_datasets});if(e.response_format==="json"){let o=
|
|
753
|
+
Typical workflow: ckan_group_show \u2192 ckan_package_show (inspect a dataset) \u2192 ckan_datastore_search (query its data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),id:v.string().min(1).describe("Group ID (UUID) or machine-readable name slug (e.g., 'transport', 'energia')"),include_datasets:v.boolean().optional().default(!0).describe("Include the list of datasets belonging to this group"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=await U(e.server_url,"group_show",{id:e.id,include_datasets:e.include_datasets});if(e.response_format==="json"){let o=rO(r);return{content:[{type:"text",text:it(o)}],structuredContent:o}}let n=XC(r,e.server_url);return{content:[{type:"text",text:W(se(n))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_group_show")}],isError:!0}}}),t.registerTool("ckan_group_search",{title:"Search CKAN Groups by Name",description:`Search for groups by name pattern.
|
|
749
754
|
|
|
750
755
|
This tool provides a simpler interface than package_search for finding groups.
|
|
751
756
|
Wildcards are automatically added around the search pattern.
|
|
@@ -758,7 +763,7 @@ Args:
|
|
|
758
763
|
Returns:
|
|
759
764
|
List of matching groups with dataset counts
|
|
760
765
|
|
|
761
|
-
Typical workflow: ckan_group_search \u2192 ckan_group_show (get details) \u2192 ckan_package_search with fq="groups:name"`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),pattern:v.string().min(1).describe("Name pattern to search for (wildcards added automatically, e.g., 'energia', 'salute')"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{let r=`groups:*${e.pattern}*`,n=await U(e.server_url,"package_search",{q:r,rows:0,"facet.field":JSON.stringify(["groups"]),"facet.limit":500}),o=
|
|
766
|
+
Typical workflow: ckan_group_search \u2192 ckan_group_show (get details) \u2192 ckan_package_search with fq="groups:name"`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.gov.it/opendata)"),pattern:v.string().min(1).describe("Name pattern to search for (wildcards added automatically, e.g., 'energia', 'salute')"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{let r=`groups:*${e.pattern}*`,n=await U(e.server_url,"package_search",{q:r,rows:0,"facet.field":JSON.stringify(["groups"]),"facet.limit":500}),o=eO(n),s=n.count||0;if(e.response_format==="json"){let a={count:o.length,total_datasets:s,groups:o.map(c=>({name:c.name,display_name:c.display_name,dataset_count:c.count}))};return{content:[{type:"text",text:W(JSON.stringify(a,null,2))}],structuredContent:a}}let i=`# CKAN Group Search Results
|
|
762
767
|
|
|
763
768
|
`;if(i+=`**Server**: ${e.server_url}
|
|
764
769
|
`,i+=`**Pattern**: "${e.pattern}"
|
|
@@ -773,13 +778,13 @@ Typical workflow: ckan_group_search \u2192 ckan_group_show (get details) \u2192
|
|
|
773
778
|
`,i+=`| Group | Datasets |
|
|
774
779
|
`,i+=`|-------|----------|
|
|
775
780
|
`;for(let a of o)i+=`| ${a.display_name||a.name} | ${a.count} |
|
|
776
|
-
`}return{content:[{type:"text",text:W(se(i))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_group_search")}],isError:!0}}})}var up="https://data.europa.eu/api/mqa/cache/datasets",lp="https://data.europa.eu/api/hub/repo/datasets",QC=[/^https?:\/\/(www\.)?dati\.gov\.it/i];function Sb(t){return QC.some(e=>e.test(t))}function YC(t){return t.trim().replace(/:/g,"-").replace(/\./g,"-").replace(/-+/g,"-").toLowerCase()}function XC(t){let e=YC(t);if(!e)return[];let r=[e];return e.includes("~~")||r.push(`${e}~~1`,`${e}~~2`),r}var yt={accessibility:100,findability:100,interoperability:110,reusability:75,contextuality:20},ap={accessibility:"Accessibility",findability:"Findability",interoperability:"Interoperability",reusability:"Reusability",contextuality:"Contextuality"},$b={accessUrlAvailability:{dimension:"accessibility",reason:"accessUrlAvailability=false"},downloadUrlAvailability:{dimension:"accessibility",reason:"downloadUrlAvailability=false"},accessUrlStatusCode:{dimension:"accessibility",expectsStatusCode:!0},downloadUrlStatusCode:{dimension:"accessibility",expectsStatusCode:!0},keywordAvailability:{dimension:"findability",reason:"keywordAvailability=false"},categoryAvailability:{dimension:"findability",reason:"categoryAvailability=false"},spatialAvailability:{dimension:"findability",reason:"spatialAvailability=false"},temporalAvailability:{dimension:"findability",reason:"temporalAvailability=false"},dcatApCompliance:{dimension:"interoperability",reason:"dcatApCompliance=false"},formatAvailability:{dimension:"interoperability",reason:"formatAvailability=false"},mediaTypeAvailability:{dimension:"interoperability",reason:"mediaTypeAvailability=false"},formatMediaTypeVocabularyAlignment:{dimension:"interoperability",reason:"formatMediaTypeVocabularyAlignment=false"},formatMediaTypeMachineInterpretable:{dimension:"interoperability",reason:"formatMediaTypeMachineInterpretable=false"},accessRightsAvailability:{dimension:"reusability",reason:"accessRightsAvailability=false"},accessRightsVocabularyAlignment:{dimension:"reusability",reason:"accessRightsVocabularyAlignment=false"},licenceAvailability:{dimension:"reusability",reason:"licenceAvailability=false"},knownLicence:{dimension:"reusability",reason:"knownLicence=false (licence not aligned to controlled vocabulary)"},contactPointAvailability:{dimension:"reusability",reason:"contactPointAvailability=false"},publisherAvailability:{dimension:"reusability",reason:"publisherAvailability=false"},byteSizeAvailability:{dimension:"contextuality",reason:"byteSizeAvailability=false"},rightsAvailability:{dimension:"contextuality",reason:"rightsAvailability=false"},dateModifiedAvailability:{dimension:"contextuality",reason:"dateModifiedAvailability=false"},dateIssuedAvailability:{dimension:"contextuality",reason:"dateIssuedAvailability=false"}};function eO(t){if(!t||typeof t!="object")return;let e=t["@value"];if(typeof e=="number")return e;if(typeof e=="string"){let r=Number(e);return Number.isFinite(r)?r:void 0}}function tO(t){if(!t||typeof t!="object")return typeof t=="boolean"||typeof t=="number"||typeof t=="string"?t:void 0;let e=t["@value"];if(typeof e=="boolean"||typeof e=="number")return e;if(typeof e=="string"){let r=e.toLowerCase();if(r==="true"||r==="false")return r==="true";let n=Number(e);return Number.isFinite(n)?n:e}}function rO(t){let e=t.lastIndexOf("#");if(e>=0&&e<t.length-1)return t.slice(e+1);let r=t.lastIndexOf("/");return r>=0&&r<t.length-1?t.slice(r+1):t}function zb(t){if(t&&typeof t=="object"&&"@graph"in t)return t;if(typeof t=="string")try{return JSON.parse(t)}catch{return}if(t instanceof ArrayBuffer)try{let e=new TextDecoder().decode(new Uint8Array(t));return JSON.parse(e)}catch{return}if(ArrayBuffer.isView(t))try{let e=t,r=new TextDecoder().decode(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return JSON.parse(r)}catch{return}return t}function nO(t){let e={},r=zb(t);if(!r||typeof r!="object")return e;let n=r["@graph"];if(!Array.isArray(n))return e;for(let o of n){if(!o||typeof o!="object")continue;let s=o["dqv:isMeasurementOf"];if(!s)continue;let i=typeof s=="string"?s:s["@id"];if(typeof i!="string")continue;let a=eO(o["dqv:value"]);a!==void 0&&(i.endsWith("#accessibilityScoring")?e.accessibility=a:i.endsWith("#findabilityScoring")?e.findability=a:i.endsWith("#interoperabilityScoring")?e.interoperability=a:i.endsWith("#reusabilityScoring")?e.reusability=a:i.endsWith("#contextualityScoring")?e.contextuality=a:i.endsWith("#scoring")&&(e.total=a))}return e}function oO(t,e){let r=zb(t);if(!r||typeof r!="object")return{flags:[],reasons:{}};let n=r["@graph"];if(!Array.isArray(n))return{flags:[],reasons:{}};let o=new Map;for(let c of n){if(!c||typeof c!="object")continue;let u=c["dqv:isMeasurementOf"];if(!u)continue;let l=typeof u=="string"?u:u["@id"];if(typeof l!="string")continue;let d=rO(l),p=$b[d];if(!p)continue;let m=tO(c["dqv:value"]);if(m===void 0)continue;let f=o.get(d);if(f){f.values.add(m);continue}o.set(d,{metricId:l,metricKey:d,dimension:p.dimension,values:new Set([m])})}let s={},i=new Map;for(let c of e)i.set(c,new Set);for(let c of o.values()){let u=$b[c.metricKey];if(!u)continue;let l=i.get(c.dimension);if(l)for(let d of c.values){if(typeof d=="boolean"&&d===!1){l.add(u.reason||`${c.metricKey}=false`);continue}u.expectsStatusCode&&typeof d=="number"&&d!==200&&l.add(`${c.metricKey}=${d}`)}}for(let[c,u]of i.entries())u.size>0&&(s[c]=Array.from(u.values()));return{flags:Array.from(o.values()).map(c=>({metricId:c.metricId,metricKey:c.metricKey,dimension:c.dimension,values:Array.from(c.values)})),reasons:s}}function sO(t){let e=[];return Object.keys(yt).forEach(r=>{let n=t[r];typeof n=="number"&&n<yt[r]&&e.push(r)}),e}async function Rb(t,e){let r=await U(t,"package_show",{id:e}),n=r.identifier||r.name,o=XC(n);if(o.length===0)throw new Error("Dataset identifier is empty; cannot query MQA API");for(let s of o){let i=`${up}/${s}`,a=`${lp}/${s}/metrics`;try{let c=await Vt.get(i,{timeout:3e4,headers:{"User-Agent":"CKAN-MCP-Server/1.0"}}),u;try{let f=await fetch(a,{headers:{"User-Agent":"CKAN-MCP-Server/1.0"}});if(!f.ok)throw new Error(`MQA metrics error: ${f.status} ${f.statusText}`);try{u=await f.json()}catch{u=await f.text()}}catch(f){throw f instanceof Error?new Error(`MQA metrics error: ${f.message}`):f}let l=nO(u),p=c.data?.result?.results?.[0]?.info?.["dataset-id"]||s,m={scores:l,nonMaxDimensions:sO(l),metricsUrl:a,mqaUrl:i,portalId:p};return{mqa:c.data,metrics:u,breakdown:m}}catch(c){if(Vt.isAxiosError(c)){if(c.response?.status===404)continue;throw new Error(`MQA API error: ${c.message}`)}throw c}}throw new Error(`Quality metrics not found or identifier not aligned on data.europa.eu. Tried: ${o.join(", ")}. Check the dataset quality page on data.europa.eu to confirm the identifier (it may include a '~~1' suffix) or verify alignment on dati.gov.it (quality may be marked as 'Non disponibile o identificativo non allineato').`)}async function iO(t,e){let r=await Rb(t,e);return{mqa:r.mqa,breakdown:r.breakdown}}async function aO(t,e){let r=await Rb(t,e),n=oO(r.metrics,r.breakdown.nonMaxDimensions);return{breakdown:r.breakdown,details:n}}function cp(t,e){if(Array.isArray(t)){for(let r of t)if(r&&typeof r=="object"&&e in r)return r[e]}}function Tb(t){if(!Array.isArray(t))return;let e=new Map;for(let r of t){if(!r||typeof r!="object")continue;let n=r.name,o=r.percentage;typeof n=="string"&&typeof o=="number"&&e.set(n.toLowerCase(),o)}if(e.has("yes"))return(e.get("yes")||0)>0;if(e.size>0){for(let[r,n]of e.entries())if(r.startsWith("2")&&n>0)return!0;return!1}}function gt(t,e){let r=cp(t,e);if(typeof r=="boolean")return r}function vn(t,e,r){let n=cp(t,e),o=Tb(n);if(o!==void 0)return{available:o};if(r){let s=cp(t,r),i=Tb(s);if(i!==void 0)return{available:i}}}function cO(t){let e=t,r=e?.mqa??t,n=e?.breakdown,o=r?.result?.results?.[0];return!o||typeof o!="object"?{...t,breakdown:n}:{id:o.info?.["dataset-id"],info:{score:o.info?.score},accessibility:{accessUrl:vn(o.accessibility,"accessUrlAvailability","accessUrlStatusCode"),downloadUrl:vn(o.accessibility,"downloadUrlAvailability","downloadUrlStatusCode")},reusability:{licence:vn(o.reusability,"licenceAvailability"),contactPoint:gt(o.reusability,"contactPointAvailability")!==void 0?{available:gt(o.reusability,"contactPointAvailability")}:void 0,publisher:gt(o.reusability,"publisherAvailability")!==void 0?{available:gt(o.reusability,"publisherAvailability")}:void 0},interoperability:{format:vn(o.interoperability,"formatAvailability"),mediaType:vn(o.interoperability,"mediaTypeAvailability")},findability:{keyword:gt(o.findability,"keywordAvailability")!==void 0?{available:gt(o.findability,"keywordAvailability")}:void 0,category:gt(o.findability,"categoryAvailability")!==void 0?{available:gt(o.findability,"categoryAvailability")}:void 0,spatial:gt(o.findability,"spatialAvailability")!==void 0?{available:gt(o.findability,"spatialAvailability")}:void 0,temporal:gt(o.findability,"temporalAvailability")!==void 0?{available:gt(o.findability,"temporalAvailability")}:void 0},contextuality:{byteSize:vn(o.contextuality,"byteSizeAvailability"),rights:vn(o.contextuality,"rightsAvailability")},breakdown:n}}function uO(t,e){let r=cO(t),n=[];if(n.push(`# Quality Metrics for Dataset: ${e}`),n.push(""),r.info?.score!==void 0&&(n.push(`**Overall Score**: ${r.info.score}/405`),n.push("")),r.breakdown?.scores){n.push("## Dimension Scores");let i=r.breakdown.scores,a=[["accessibility","Accessibility",yt.accessibility],["findability","Findability",yt.findability],["interoperability","Interoperability",yt.interoperability],["reusability","Reusability",yt.reusability],["contextuality","Contextuality",yt.contextuality]];for(let[c,u,l]of a){let d=i[c];if(typeof d=="number"){let p=d>=l,m=p?"\u2705":"\u26A0\uFE0F";n.push(`- ${u}: ${d}/${l} ${m}${p?"":` (max ${l})`}`)}}r.breakdown.nonMaxDimensions.length>0?n.push(`- Non-max dimension(s): ${r.breakdown.nonMaxDimensions.join(", ")}`):Object.keys(i).length>0&&n.push("- Non-max dimension(s): none"),n.push("")}r.accessibility&&(n.push("## Accessibility"),r.accessibility.accessUrl!==void 0&&n.push(`- Access URL: ${r.accessibility.accessUrl.available?"\u2713":"\u2717"} Available`),r.accessibility.downloadUrl!==void 0&&n.push(`- Download URL: ${r.accessibility.downloadUrl.available?"\u2713":"\u2717"} Available`),n.push("")),r.reusability&&(n.push("## Reusability"),r.reusability.licence!==void 0&&n.push(`- License: ${r.reusability.licence.available?"\u2713":"\u2717"} Available`),r.reusability.contactPoint!==void 0&&n.push(`- Contact Point: ${r.reusability.contactPoint.available?"\u2713":"\u2717"} Available`),r.reusability.publisher!==void 0&&n.push(`- Publisher: ${r.reusability.publisher.available?"\u2713":"\u2717"} Available`),n.push("")),r.interoperability&&(n.push("## Interoperability"),r.interoperability.format!==void 0&&n.push(`- Format: ${r.interoperability.format.available?"\u2713":"\u2717"} Available`),r.interoperability.mediaType!==void 0&&n.push(`- Media Type: ${r.interoperability.mediaType.available?"\u2713":"\u2717"} Available`),n.push("")),r.findability&&(n.push("## Findability"),r.findability.keyword!==void 0&&n.push(`- Keywords: ${r.findability.keyword.available?"\u2713":"\u2717"} Available`),r.findability.category!==void 0&&n.push(`- Category: ${r.findability.category.available?"\u2713":"\u2717"} Available`),r.findability.spatial!==void 0&&n.push(`- Spatial: ${r.findability.spatial.available?"\u2713":"\u2717"} Available`),r.findability.temporal!==void 0&&n.push(`- Temporal: ${r.findability.temporal.available?"\u2713":"\u2717"} Available`),n.push("")),r.contextuality&&(n.push("## Contextuality"),r.contextuality.byteSize!==void 0&&n.push(`- Byte Size: ${r.contextuality.byteSize.available?"\u2713":"\u2717"} Available`),r.contextuality.rights!==void 0&&n.push(`- Rights: ${r.contextuality.rights.available?"\u2713":"\u2717"} Available`),n.push("")),n.push("---");let o=r.breakdown?.portalId||r.id||e;n.push(`Portal: https://data.europa.eu/data/datasets/${o}/quality?locale=it`),n.push(`MQA source: ${up}/${o}`);let s=r.breakdown?.metricsUrl||`${lp}/${o}/metrics`;return n.push(`Metrics endpoint: ${s}`),n.push("Tip: Use the metrics endpoint to explain score deductions (e.g., failing measurements such as knownLicence = false)."),n.join(`
|
|
777
|
-
`)}function
|
|
778
|
-
`)}function
|
|
781
|
+
`}return{content:[{type:"text",text:W(se(i))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_group_search")}],isError:!0}}})}var fp="https://data.europa.eu/api/mqa/cache/datasets",pp="https://data.europa.eu/api/hub/repo/datasets",nO=[/^https?:\/\/(www\.)?dati\.gov\.it/i];function Rb(t){return nO.some(e=>e.test(t))}function oO(t){return t.trim().replace(/:/g,"-").replace(/\./g,"-").replace(/-+/g,"-").toLowerCase()}function sO(t){let e=oO(t);if(!e)return[];let r=[e];return e.includes("~~")||r.push(`${e}~~1`,`${e}~~2`),r}var yt={accessibility:100,findability:100,interoperability:110,reusability:75,contextuality:20},lp={accessibility:"Accessibility",findability:"Findability",interoperability:"Interoperability",reusability:"Reusability",contextuality:"Contextuality"},Eb={accessUrlAvailability:{dimension:"accessibility",reason:"accessUrlAvailability=false"},downloadUrlAvailability:{dimension:"accessibility",reason:"downloadUrlAvailability=false"},accessUrlStatusCode:{dimension:"accessibility",expectsStatusCode:!0},downloadUrlStatusCode:{dimension:"accessibility",expectsStatusCode:!0},keywordAvailability:{dimension:"findability",reason:"keywordAvailability=false"},categoryAvailability:{dimension:"findability",reason:"categoryAvailability=false"},spatialAvailability:{dimension:"findability",reason:"spatialAvailability=false"},temporalAvailability:{dimension:"findability",reason:"temporalAvailability=false"},dcatApCompliance:{dimension:"interoperability",reason:"dcatApCompliance=false"},formatAvailability:{dimension:"interoperability",reason:"formatAvailability=false"},mediaTypeAvailability:{dimension:"interoperability",reason:"mediaTypeAvailability=false"},formatMediaTypeVocabularyAlignment:{dimension:"interoperability",reason:"formatMediaTypeVocabularyAlignment=false"},formatMediaTypeMachineInterpretable:{dimension:"interoperability",reason:"formatMediaTypeMachineInterpretable=false"},accessRightsAvailability:{dimension:"reusability",reason:"accessRightsAvailability=false"},accessRightsVocabularyAlignment:{dimension:"reusability",reason:"accessRightsVocabularyAlignment=false"},licenceAvailability:{dimension:"reusability",reason:"licenceAvailability=false"},knownLicence:{dimension:"reusability",reason:"knownLicence=false (licence not aligned to controlled vocabulary)"},contactPointAvailability:{dimension:"reusability",reason:"contactPointAvailability=false"},publisherAvailability:{dimension:"reusability",reason:"publisherAvailability=false"},byteSizeAvailability:{dimension:"contextuality",reason:"byteSizeAvailability=false"},rightsAvailability:{dimension:"contextuality",reason:"rightsAvailability=false"},dateModifiedAvailability:{dimension:"contextuality",reason:"dateModifiedAvailability=false"},dateIssuedAvailability:{dimension:"contextuality",reason:"dateIssuedAvailability=false"}};function iO(t){if(!t||typeof t!="object")return;let e=t["@value"];if(typeof e=="number")return e;if(typeof e=="string"){let r=Number(e);return Number.isFinite(r)?r:void 0}}function aO(t){if(!t||typeof t!="object")return typeof t=="boolean"||typeof t=="number"||typeof t=="string"?t:void 0;let e=t["@value"];if(typeof e=="boolean"||typeof e=="number")return e;if(typeof e=="string"){let r=e.toLowerCase();if(r==="true"||r==="false")return r==="true";let n=Number(e);return Number.isFinite(n)?n:e}}function cO(t){let e=t.lastIndexOf("#");if(e>=0&&e<t.length-1)return t.slice(e+1);let r=t.lastIndexOf("/");return r>=0&&r<t.length-1?t.slice(r+1):t}function Ab(t){if(t&&typeof t=="object"&&"@graph"in t)return t;if(typeof t=="string")try{return JSON.parse(t)}catch{return}if(t instanceof ArrayBuffer)try{let e=new TextDecoder().decode(new Uint8Array(t));return JSON.parse(e)}catch{return}if(ArrayBuffer.isView(t))try{let e=t,r=new TextDecoder().decode(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));return JSON.parse(r)}catch{return}return t}function uO(t){let e={},r=Ab(t);if(!r||typeof r!="object")return e;let n=r["@graph"];if(!Array.isArray(n))return e;for(let o of n){if(!o||typeof o!="object")continue;let s=o["dqv:isMeasurementOf"];if(!s)continue;let i=typeof s=="string"?s:s["@id"];if(typeof i!="string")continue;let a=iO(o["dqv:value"]);a!==void 0&&(i.endsWith("#accessibilityScoring")?e.accessibility=a:i.endsWith("#findabilityScoring")?e.findability=a:i.endsWith("#interoperabilityScoring")?e.interoperability=a:i.endsWith("#reusabilityScoring")?e.reusability=a:i.endsWith("#contextualityScoring")?e.contextuality=a:i.endsWith("#scoring")&&(e.total=a))}return e}function lO(t,e){let r=Ab(t);if(!r||typeof r!="object")return{flags:[],reasons:{}};let n=r["@graph"];if(!Array.isArray(n))return{flags:[],reasons:{}};let o=new Map;for(let c of n){if(!c||typeof c!="object")continue;let u=c["dqv:isMeasurementOf"];if(!u)continue;let l=typeof u=="string"?u:u["@id"];if(typeof l!="string")continue;let d=cO(l),p=Eb[d];if(!p)continue;let m=aO(c["dqv:value"]);if(m===void 0)continue;let f=o.get(d);if(f){f.values.add(m);continue}o.set(d,{metricId:l,metricKey:d,dimension:p.dimension,values:new Set([m])})}let s={},i=new Map;for(let c of e)i.set(c,new Set);for(let c of o.values()){let u=Eb[c.metricKey];if(!u)continue;let l=i.get(c.dimension);if(l)for(let d of c.values){if(typeof d=="boolean"&&d===!1){l.add(u.reason||`${c.metricKey}=false`);continue}u.expectsStatusCode&&typeof d=="number"&&d!==200&&l.add(`${c.metricKey}=${d}`)}}for(let[c,u]of i.entries())u.size>0&&(s[c]=Array.from(u.values()));return{flags:Array.from(o.values()).map(c=>({metricId:c.metricId,metricKey:c.metricKey,dimension:c.dimension,values:Array.from(c.values)})),reasons:s}}function dO(t){let e=[];return Object.keys(yt).forEach(r=>{let n=t[r];typeof n=="number"&&n<yt[r]&&e.push(r)}),e}async function Cb(t,e){let r=await U(t,"package_show",{id:e}),n=r.identifier||r.name,o=sO(n);if(o.length===0)throw new Error("Dataset identifier is empty; cannot query MQA API");for(let s of o){let i=`${fp}/${s}`,a=`${pp}/${s}/metrics`;try{let c=await Vt.get(i,{timeout:3e4,headers:{"User-Agent":"CKAN-MCP-Server/1.0"}}),u;try{let f=await fetch(a,{headers:{"User-Agent":"CKAN-MCP-Server/1.0"}});if(!f.ok)throw new Error(`MQA metrics error: ${f.status} ${f.statusText}`);try{u=await f.json()}catch{u=await f.text()}}catch(f){throw f instanceof Error?new Error(`MQA metrics error: ${f.message}`):f}let l=uO(u),p=c.data?.result?.results?.[0]?.info?.["dataset-id"]||s,m={scores:l,nonMaxDimensions:dO(l),metricsUrl:a,mqaUrl:i,portalId:p};return{mqa:c.data,metrics:u,breakdown:m}}catch(c){if(Vt.isAxiosError(c)){if(c.response?.status===404)continue;throw new Error(`MQA API error: ${c.message}`)}throw c}}throw new Error(`Quality metrics not found or identifier not aligned on data.europa.eu. Tried: ${o.join(", ")}. Check the dataset quality page on data.europa.eu to confirm the identifier (it may include a '~~1' suffix) or verify alignment on dati.gov.it (quality may be marked as 'Non disponibile o identificativo non allineato').`)}async function fO(t,e){let r=await Cb(t,e);return{mqa:r.mqa,breakdown:r.breakdown}}async function pO(t,e){let r=await Cb(t,e),n=lO(r.metrics,r.breakdown.nonMaxDimensions);return{breakdown:r.breakdown,details:n}}function dp(t,e){if(Array.isArray(t)){for(let r of t)if(r&&typeof r=="object"&&e in r)return r[e]}}function Pb(t){if(!Array.isArray(t))return;let e=new Map;for(let r of t){if(!r||typeof r!="object")continue;let n=r.name,o=r.percentage;typeof n=="string"&&typeof o=="number"&&e.set(n.toLowerCase(),o)}if(e.has("yes"))return(e.get("yes")||0)>0;if(e.size>0){for(let[r,n]of e.entries())if(r.startsWith("2")&&n>0)return!0;return!1}}function gt(t,e){let r=dp(t,e);if(typeof r=="boolean")return r}function vn(t,e,r){let n=dp(t,e),o=Pb(n);if(o!==void 0)return{available:o};if(r){let s=dp(t,r),i=Pb(s);if(i!==void 0)return{available:i}}}function mO(t){let e=t,r=e?.mqa??t,n=e?.breakdown,o=r?.result?.results?.[0];return!o||typeof o!="object"?{...t,breakdown:n}:{id:o.info?.["dataset-id"],info:{score:o.info?.score},accessibility:{accessUrl:vn(o.accessibility,"accessUrlAvailability","accessUrlStatusCode"),downloadUrl:vn(o.accessibility,"downloadUrlAvailability","downloadUrlStatusCode")},reusability:{licence:vn(o.reusability,"licenceAvailability"),contactPoint:gt(o.reusability,"contactPointAvailability")!==void 0?{available:gt(o.reusability,"contactPointAvailability")}:void 0,publisher:gt(o.reusability,"publisherAvailability")!==void 0?{available:gt(o.reusability,"publisherAvailability")}:void 0},interoperability:{format:vn(o.interoperability,"formatAvailability"),mediaType:vn(o.interoperability,"mediaTypeAvailability")},findability:{keyword:gt(o.findability,"keywordAvailability")!==void 0?{available:gt(o.findability,"keywordAvailability")}:void 0,category:gt(o.findability,"categoryAvailability")!==void 0?{available:gt(o.findability,"categoryAvailability")}:void 0,spatial:gt(o.findability,"spatialAvailability")!==void 0?{available:gt(o.findability,"spatialAvailability")}:void 0,temporal:gt(o.findability,"temporalAvailability")!==void 0?{available:gt(o.findability,"temporalAvailability")}:void 0},contextuality:{byteSize:vn(o.contextuality,"byteSizeAvailability"),rights:vn(o.contextuality,"rightsAvailability")},breakdown:n}}function hO(t,e){let r=mO(t),n=[];if(n.push(`# Quality Metrics for Dataset: ${e}`),n.push(""),r.info?.score!==void 0&&(n.push(`**Overall Score**: ${r.info.score}/405`),n.push("")),r.breakdown?.scores){n.push("## Dimension Scores");let i=r.breakdown.scores,a=[["accessibility","Accessibility",yt.accessibility],["findability","Findability",yt.findability],["interoperability","Interoperability",yt.interoperability],["reusability","Reusability",yt.reusability],["contextuality","Contextuality",yt.contextuality]];for(let[c,u,l]of a){let d=i[c];if(typeof d=="number"){let p=d>=l,m=p?"\u2705":"\u26A0\uFE0F";n.push(`- ${u}: ${d}/${l} ${m}${p?"":` (max ${l})`}`)}}r.breakdown.nonMaxDimensions.length>0?n.push(`- Non-max dimension(s): ${r.breakdown.nonMaxDimensions.join(", ")}`):Object.keys(i).length>0&&n.push("- Non-max dimension(s): none"),n.push("")}r.accessibility&&(n.push("## Accessibility"),r.accessibility.accessUrl!==void 0&&n.push(`- Access URL: ${r.accessibility.accessUrl.available?"\u2713":"\u2717"} Available`),r.accessibility.downloadUrl!==void 0&&n.push(`- Download URL: ${r.accessibility.downloadUrl.available?"\u2713":"\u2717"} Available`),n.push("")),r.reusability&&(n.push("## Reusability"),r.reusability.licence!==void 0&&n.push(`- License: ${r.reusability.licence.available?"\u2713":"\u2717"} Available`),r.reusability.contactPoint!==void 0&&n.push(`- Contact Point: ${r.reusability.contactPoint.available?"\u2713":"\u2717"} Available`),r.reusability.publisher!==void 0&&n.push(`- Publisher: ${r.reusability.publisher.available?"\u2713":"\u2717"} Available`),n.push("")),r.interoperability&&(n.push("## Interoperability"),r.interoperability.format!==void 0&&n.push(`- Format: ${r.interoperability.format.available?"\u2713":"\u2717"} Available`),r.interoperability.mediaType!==void 0&&n.push(`- Media Type: ${r.interoperability.mediaType.available?"\u2713":"\u2717"} Available`),n.push("")),r.findability&&(n.push("## Findability"),r.findability.keyword!==void 0&&n.push(`- Keywords: ${r.findability.keyword.available?"\u2713":"\u2717"} Available`),r.findability.category!==void 0&&n.push(`- Category: ${r.findability.category.available?"\u2713":"\u2717"} Available`),r.findability.spatial!==void 0&&n.push(`- Spatial: ${r.findability.spatial.available?"\u2713":"\u2717"} Available`),r.findability.temporal!==void 0&&n.push(`- Temporal: ${r.findability.temporal.available?"\u2713":"\u2717"} Available`),n.push("")),r.contextuality&&(n.push("## Contextuality"),r.contextuality.byteSize!==void 0&&n.push(`- Byte Size: ${r.contextuality.byteSize.available?"\u2713":"\u2717"} Available`),r.contextuality.rights!==void 0&&n.push(`- Rights: ${r.contextuality.rights.available?"\u2713":"\u2717"} Available`),n.push("")),n.push("---");let o=r.breakdown?.portalId||r.id||e;n.push(`Portal: https://data.europa.eu/data/datasets/${o}/quality?locale=it`),n.push(`MQA source: ${fp}/${o}`);let s=r.breakdown?.metricsUrl||`${pp}/${o}/metrics`;return n.push(`Metrics endpoint: ${s}`),n.push("Tip: Use the metrics endpoint to explain score deductions (e.g., failing measurements such as knownLicence = false)."),n.join(`
|
|
782
|
+
`)}function gO(t,e){let r=[],n=t.breakdown;if(r.push(`# Quality Details for Dataset: ${e}`),r.push(""),typeof n.scores.total=="number"&&(r.push(`**Overall Score**: ${n.scores.total}/405`),r.push("")),n.scores){r.push("## Dimension Scores");let s=[["accessibility",yt.accessibility],["findability",yt.findability],["interoperability",yt.interoperability],["reusability",yt.reusability],["contextuality",yt.contextuality]];for(let[i,a]of s){let c=n.scores[i];if(typeof c=="number"){let u=c>=a?"\u2705":"\u26A0\uFE0F";r.push(`- ${lp[i]}: ${c}/${a} ${u}${c>=a?"":` (max ${a})`}`)}}r.push("")}if(r.push("## Non-max Reasons"),n.nonMaxDimensions.length===0)r.push("- All dimensions are at max score.");else for(let s of n.nonMaxDimensions){let i=t.details.reasons[s]||[];i.length===0?r.push(`- ${lp[s]}: no failing flags detected in metrics payload`):r.push(`- ${lp[s]}: ${i.join("; ")}`)}r.push(""),r.push("---");let o=n.portalId||e;return r.push(`Portal: https://data.europa.eu/data/datasets/${o}/quality?locale=it`),r.push(`MQA source: ${fp}/${o}`),r.push(`Metrics endpoint: ${n.metricsUrl||`${pp}/${o}/metrics`}`),r.join(`
|
|
783
|
+
`)}function Ob(t){t.registerTool("ckan_get_mqa_quality",{title:"Get MQA Quality Score",description:"Get MQA (Metadata Quality Assurance) quality metrics for a dataset on dati.gov.it. Returns quality score and detailed metrics (accessibility, reusability, interoperability, findability, contextuality) from data.europa.eu. Only works with dati.gov.it server. Typical workflow: ckan_package_show (get dataset ID) \u2192 ckan_get_mqa_quality \u2192 ckan_get_mqa_quality_details (for non-max dimensions)",inputSchema:v.object({server_url:v.string().url().describe("Base URL of dati.gov.it (e.g., https://www.dati.gov.it/opendata)"),dataset_id:v.string().describe("Dataset ID or name"),response_format:pe.optional()}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async({server_url:e,dataset_id:r,response_format:n})=>{if(!Rb(e))return{content:[{type:"text",text:`Error: MQA quality metrics are only available for dati.gov.it datasets. Provided server: ${e}
|
|
779
784
|
|
|
780
|
-
The MQA (Metadata Quality Assurance) system is operated by data.europa.eu and only evaluates datasets from Italian open data portal.`}]};try{let o=await
|
|
785
|
+
The MQA (Metadata Quality Assurance) system is operated by data.europa.eu and only evaluates datasets from Italian open data portal.`}]};try{let o=await fO(e,r),i=(n||"markdown")==="json"?JSON.stringify(o,null,2):hO(o,r);return{content:[{type:"text",text:se(i)}]}}catch(o){return{content:[{type:"text",text:`Error retrieving quality metrics: ${we(o,"ckan_get_mqa_quality")}`}]}}}),t.registerTool("ckan_get_mqa_quality_details",{title:"Get MQA Quality Details",description:"Get detailed MQA (Metadata Quality Assurance) quality reasons for a dataset on dati.gov.it. Returns dimension scores, non-max reasons, and raw MQA flags from data.europa.eu. Only works with dati.gov.it server. Typical workflow: ckan_get_mqa_quality (get overview scores) \u2192 ckan_get_mqa_quality_details (inspect failing metrics)",inputSchema:v.object({server_url:v.string().url().describe("Base URL of dati.gov.it (e.g., https://www.dati.gov.it/opendata)"),dataset_id:v.string().describe("Dataset ID or name"),response_format:pe.optional()}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async({server_url:e,dataset_id:r,response_format:n})=>{if(!Rb(e))return{content:[{type:"text",text:`Error: MQA quality details are only available for dati.gov.it datasets. Provided server: ${e}
|
|
781
786
|
|
|
782
|
-
The MQA (Metadata Quality Assurance) system is operated by data.europa.eu and only evaluates datasets from Italian open data portal.`}]};try{let o=await
|
|
787
|
+
The MQA (Metadata Quality Assurance) system is operated by data.europa.eu and only evaluates datasets from Italian open data portal.`}]};try{let o=await pO(e,r),i=(n||"markdown")==="json"?JSON.stringify(o,null,2):gO(o,r);return{content:[{type:"text",text:se(i)}]}}catch(o){return{content:[{type:"text",text:`Error retrieving quality details: ${we(o,"ckan_get_mqa_quality_details")}`}]}}})}function yO(t,e,r,n){let o=`# Dataset Analysis
|
|
783
788
|
|
|
784
789
|
`;o+=`**Server**: ${t}
|
|
785
790
|
`,o+=`**Query**: ${e}
|
|
@@ -813,7 +818,7 @@ The MQA (Metadata Quality Assurance) system is operated by data.europa.eu and on
|
|
|
813
818
|
`;o+=`
|
|
814
819
|
`}i.length===0&&a.length===0&&(o+=`_No resources available._
|
|
815
820
|
|
|
816
|
-
`)}return o}function
|
|
821
|
+
`)}return o}function Nb(t){t.registerTool("ckan_analyze_datasets",{title:"Analyze CKAN Datasets and DataStore Schema",description:`Search datasets and inspect the DataStore schema of queryable resources.
|
|
817
822
|
|
|
818
823
|
For each dataset found, lists all resources. For DataStore-enabled resources, fetches the full
|
|
819
824
|
field schema (name, type, and label/notes when available) plus total record count \u2014 all in one call.
|
|
@@ -830,7 +835,7 @@ Returns:
|
|
|
830
835
|
For each dataset: title, ID, organization, and per DataStore resource: field schema with
|
|
831
836
|
label/notes (when available from DataStore Dictionary) and record count.
|
|
832
837
|
|
|
833
|
-
Typical workflow: ckan_analyze_datasets \u2192 ckan_datastore_search (with known field names)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.comune.messina.it)"),q:v.string().min(1).describe("Solr search query (e.g. 'incidenti', 'title:ambiente')"),rows:v.number().int().min(1).max(20).optional().default(5).describe("Max datasets to analyze (default 5, max 20)"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{let r=await U(e.server_url,"package_search",{q:e.q,rows:e.rows}),n=r.results||[],o=await Promise.all(n.map(async i=>{let a=i.resources||[],c=[],u=[];for(let l of a)if(l.datastore_active===!0)try{let d=await U(e.server_url,"datastore_search",{resource_id:l.id,limit:0});c.push({resource:{id:l.id,name:l.name,format:l.format},schema:d})}catch(d){c.push({resource:{id:l.id,name:l.name,format:l.format},schema:null,error:d instanceof Error?d.message:String(d)})}else u.push({name:l.name,format:l.format});return{dataset:i,datastoreResources:c,nonDatastoreResources:u}}));if(e.response_format==="json")return{content:[{type:"text",text:W(JSON.stringify({total:r.count,datasets:o},null,2))}]};let s=
|
|
838
|
+
Typical workflow: ckan_analyze_datasets \u2192 ckan_datastore_search (with known field names)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.comune.messina.it)"),q:v.string().min(1).describe("Solr search query (e.g. 'incidenti', 'title:ambiente')"),rows:v.number().int().min(1).max(20).optional().default(5).describe("Max datasets to analyze (default 5, max 20)"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{let r=await U(e.server_url,"package_search",{q:e.q,rows:e.rows}),n=r.results||[],o=await Promise.all(n.map(async i=>{let a=i.resources||[],c=[],u=[];for(let l of a)if(l.datastore_active===!0)try{let d=await U(e.server_url,"datastore_search",{resource_id:l.id,limit:0});c.push({resource:{id:l.id,name:l.name,format:l.format},schema:d})}catch(d){c.push({resource:{id:l.id,name:l.name,format:l.format},schema:null,error:d instanceof Error?d.message:String(d)})}else u.push({name:l.name,format:l.format});return{dataset:i,datastoreResources:c,nonDatastoreResources:u}}));if(e.response_format==="json")return{content:[{type:"text",text:W(JSON.stringify({total:r.count,datasets:o},null,2))}]};let s=yO(e.server_url,e.q,r.count,o);return{content:[{type:"text",text:W(se(s))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_analyze_datasets")}],isError:!0}}})}function _O(t,e,r){let n={groups:"Categories",res_format:"Formats",organization:"Organizations"},o=`# CKAN Portal Statistics
|
|
834
839
|
|
|
835
840
|
`;o+=`**Server**: ${t}
|
|
836
841
|
`,o+=`**Total datasets**: ${e}
|
|
@@ -838,7 +843,7 @@ Typical workflow: ckan_analyze_datasets \u2192 ckan_datastore_search (with known
|
|
|
838
843
|
## ${i}
|
|
839
844
|
|
|
840
845
|
`;for(let[u,l]of c)o+=`- **${u}**: ${l}
|
|
841
|
-
`}return o}function
|
|
846
|
+
`}return o}function Ib(t){t.registerTool("ckan_catalog_stats",{title:"Get CKAN Portal Statistics",description:`Get a statistical overview of a CKAN portal: total dataset count and breakdown by category, format, and organization.
|
|
842
847
|
|
|
843
848
|
Single CKAN call (package_search with rows=0 and facets). No query needed.
|
|
844
849
|
|
|
@@ -850,8 +855,8 @@ Args:
|
|
|
850
855
|
Returns:
|
|
851
856
|
Total dataset count, categories ranked by count, file formats ranked by count, organizations ranked by count.
|
|
852
857
|
|
|
853
|
-
Typical workflow: ckan_catalog_stats (understand the portal) \u2192 ckan_package_search (query specific data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.comune.messina.it)"),facet_limit:v.number().int().min(1).max(100).optional().default(20).describe("Max entries per facet section (default 20)"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=await U(e.server_url,"package_search",{q:"*:*",rows:0,"facet.field":JSON.stringify(["groups","res_format","organization"]),"facet.limit":e.facet_limit});if(e.response_format==="json")return{content:[{type:"text",text:W(JSON.stringify({total:r.count,facets:r.facets},null,2))}]};let n=
|
|
854
|
-
LIMIT ${e}`}async function
|
|
858
|
+
Typical workflow: ckan_catalog_stats (understand the portal) \u2192 ckan_package_search (query specific data)`,inputSchema:v.object({server_url:v.string().url().describe("Base URL of the CKAN server (e.g., https://dati.comune.messina.it)"),facet_limit:v.number().int().min(1).max(100).optional().default(20).describe("Max entries per facet section (default 20)"),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}},async e=>{try{let r=await U(e.server_url,"package_search",{q:"*:*",rows:0,"facet.field":JSON.stringify(["groups","res_format","organization"]),"facet.limit":e.facet_limit});if(e.response_format==="json")return{content:[{type:"text",text:W(JSON.stringify({total:r.count,facets:r.facets},null,2))}]};let n=_O(e.server_url,r.count,r.facets);return{content:[{type:"text",text:W(se(n))}]}}catch(r){return{content:[{type:"text",text:we(r,"ckan_catalog_stats")}],isError:!0}}})}var Fa=25,mp=1e3;function vO(t){let e=t.replace(/#[^\n]*/g,"");if(!/\bSELECT\b/i.test(e))throw new Error("Only SELECT queries are supported (not CONSTRUCT, ASK, DESCRIBE, or write operations).")}function bO(t,e){return/\bLIMIT\b/i.test(t)?t:`${t.trimEnd()}
|
|
859
|
+
LIMIT ${e}`}async function wO(t,e){ap(t);let r=new URL(t);if(r.protocol!=="https:")throw new Error("Only HTTPS endpoints are allowed");await ob(r.hostname);let o=Kv(t)?.method??"POST",s={Accept:"application/sparql-results+json","User-Agent":"Mozilla/5.0 (compatible; CKAN-MCP-Server/1.0)"},i=new AbortController,a=setTimeout(()=>i.abort(),15e3),c;try{if(o==="GET"){let u=new URL(t);u.searchParams.set("query",e),c=await fetch(u.toString(),{method:"GET",signal:i.signal,headers:s})}else if(c=await fetch(t,{method:"POST",signal:i.signal,headers:{...s,"Content-Type":"application/sparql-query; charset=utf-8"},body:e}),c.status===403||c.status===405){let u=new URL(t);u.searchParams.set("query",e),c=await fetch(u.toString(),{method:"GET",signal:i.signal,headers:s})}}finally{clearTimeout(a)}if(!c.ok)throw new Error(`SPARQL endpoint error (${c.status}): ${c.statusText}`);return c.json()}function xO(t,e){let r=t.head.vars,n=t.results.bindings,o=`# SPARQL Query Results
|
|
855
860
|
|
|
856
861
|
`;if(o+=`**Endpoint**: ${e}
|
|
857
862
|
`,o+=`**Rows**: ${n.length}
|
|
@@ -860,7 +865,7 @@ LIMIT ${e}`}async function hO(t,e){if(op(t),new URL(t).protocol!=="https:")throw
|
|
|
860
865
|
`;o+=`| ${r.join(" | ")} |
|
|
861
866
|
`,o+=`| ${r.map(()=>"---").join(" | ")} |
|
|
862
867
|
`;for(let s of n){let i=r.map(a=>(s[a]?.value??"").replace(/\|/g,"\\|"));o+=`| ${i.join(" | ")} |
|
|
863
|
-
`}return o}function
|
|
868
|
+
`}return o}function kO(t){let e=t.head.vars,r=t.results.bindings.map(n=>{let o={};for(let s of e)o[s]=n[s]?.value??"";return o});return{count:r.length,columns:e,rows:r}}function Mb(t){t.registerTool("sparql_query",{title:"SPARQL Query",description:`Execute a SPARQL SELECT query against any public HTTPS SPARQL endpoint.
|
|
864
869
|
|
|
865
870
|
Useful for querying open data portals and knowledge graphs that expose SPARQL endpoints, including:
|
|
866
871
|
- data.europa.eu (European open data portal)
|
|
@@ -871,12 +876,12 @@ Useful for querying open data portals and knowledge graphs that expose SPARQL en
|
|
|
871
876
|
Only HTTPS endpoints are allowed. Queries timeout after 15 seconds.
|
|
872
877
|
Only SELECT queries are supported (read-only).
|
|
873
878
|
|
|
874
|
-
If the query does not contain a LIMIT clause, one is injected automatically (default: ${
|
|
879
|
+
If the query does not contain a LIMIT clause, one is injected automatically (default: ${Fa}, max: ${mp}).
|
|
875
880
|
|
|
876
881
|
Args:
|
|
877
882
|
- endpoint_url (string): HTTPS URL of the SPARQL endpoint
|
|
878
883
|
- query (string): SPARQL SELECT query to execute
|
|
879
|
-
- limit (number): Max rows to return (default: ${
|
|
884
|
+
- limit (number): Max rows to return (default: ${Fa}). Ignored if query already contains LIMIT.
|
|
880
885
|
- response_format ('markdown' | 'json'): Output format
|
|
881
886
|
|
|
882
887
|
Examples:
|
|
@@ -884,11 +889,11 @@ Examples:
|
|
|
884
889
|
- Query Wikidata for entities related to a dataset topic
|
|
885
890
|
- Explore EU controlled vocabularies on publications.europa.eu
|
|
886
891
|
|
|
887
|
-
Typical workflow: sparql_query (explore schema) \u2192 sparql_query (targeted query) \u2192 ckan_package_search (get dataset details)`,inputSchema:v.object({endpoint_url:v.string().url().describe("HTTPS URL of the SPARQL endpoint"),query:v.string().min(1).describe("SPARQL SELECT query to execute"),limit:v.number().int().min(1).max(
|
|
888
|
-
/* output truncated */`),{content:[{type:"text",text:i}],structuredContent:s}}let o=
|
|
892
|
+
Typical workflow: sparql_query (explore schema) \u2192 sparql_query (targeted query) \u2192 ckan_package_search (get dataset details)`,inputSchema:v.object({endpoint_url:v.string().url().describe("HTTPS URL of the SPARQL endpoint"),query:v.string().min(1).describe("SPARQL SELECT query to execute"),limit:v.number().int().min(1).max(mp).default(Fa).describe(`Max rows to return (default: ${Fa}, max: ${mp}). Injected as SPARQL LIMIT if not already present in query.`),response_format:pe}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{vO(e.query);let r=bO(e.query,e.limit),n=await wO(e.endpoint_url,r);if(e.response_format==="json"){let s=kO(n),i=JSON.stringify(s,null,2);return i.length>Pr&&(i=i.slice(0,Pr)+`
|
|
893
|
+
/* output truncated */`),{content:[{type:"text",text:i}],structuredContent:s}}let o=xO(n,e.endpoint_url);return o.length>Pr&&(o=o.slice(0,Pr)+`
|
|
889
894
|
|
|
890
895
|
_Output truncated._`),{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`SPARQL query failed:
|
|
891
|
-
${r instanceof Error?r.message:String(r)}`}],isError:!0}}})}var
|
|
896
|
+
${r instanceof Error?r.message:String(r)}`}],isError:!0}}})}var SO="https://datashades.info/api/portal/list";async function $O(){return(await Vt.get(SO,{timeout:15e3,headers:{"User-Agent":"CKAN-MCP-Server/1.0"}})).data.portals}function TO(t){let e=new Map;for(let r of t)try{let n=new URL(r.Href).hostname;(!e.get(n)||r.Href.startsWith("https://"))&&e.set(n,r)}catch{}return Array.from(e.values())}function zO(t,e){let r=t.filter(n=>n.status==="active"&&n.Href).filter(n=>!e.country||n.Coordinates.country_name.toLowerCase().includes(e.country.toLowerCase())).filter(n=>!e.query||n.SiteInfo.site_title.toLowerCase().includes(e.query.toLowerCase())).filter(n=>e.min_datasets===void 0||n.DatasetsNumber>=e.min_datasets).filter(n=>!e.language||n.SiteInfo.locale_default.toLowerCase().startsWith(e.language.toLowerCase())).filter(n=>!e.has_datastore||(n.Plugins||[]).includes("datastore"));return TO(r).sort((n,o)=>o.DatasetsNumber-n.DatasetsNumber).slice(0,e.limit)}function RO(t,e,r){if(t.length===0)return"No CKAN portals found matching the given filters.";let n=t.map(o=>`| [${o.SiteInfo.site_title||o.Href}](${o.Href}) | ${o.Coordinates.country_name} | ${o.Version} | ${o.DatasetsNumber.toLocaleString()} | ${o.SiteInfo.locale_default} | ${(o.Plugins||[]).includes("datastore")?"\u2705":"\u274C"} |`).join(`
|
|
892
897
|
`);return`# CKAN Portals
|
|
893
898
|
|
|
894
899
|
**Source**: [datashades.info](https://datashades.info/portals) \u2014 live registry of ${e} active portals
|
|
@@ -899,7 +904,7 @@ ${r instanceof Error?r.message:String(r)}`}],isError:!0}}})}var _O="https://data
|
|
|
899
904
|
${n}
|
|
900
905
|
|
|
901
906
|
---
|
|
902
|
-
\u{1F4A1} Use the portal URL as \`server_url\` in any CKAN tool.`}function
|
|
907
|
+
\u{1F4A1} Use the portal URL as \`server_url\` in any CKAN tool.`}function jb(t){t.registerTool("ckan_find_portals",{title:"Find CKAN Portals",description:`Search the live datashades.info registry of ~950 CKAN portals worldwide.
|
|
903
908
|
|
|
904
909
|
Use this tool to discover which CKAN portals exist for a country, language, or topic
|
|
905
910
|
before querying them with other CKAN tools.
|
|
@@ -919,8 +924,8 @@ Args:
|
|
|
919
924
|
Returns:
|
|
920
925
|
Ranked list of matching portals with URL, country, CKAN version, dataset count, and DataStore status.
|
|
921
926
|
|
|
922
|
-
Typical workflow: ckan_find_portals (discover portal URL) \u2192 ckan_status_show (verify) \u2192 ckan_package_search (search datasets)`,inputSchema:v.object({country:v.string().optional().describe("Country name in English (e.g. 'Italy', 'Brazil'). Translate from any language before passing."),query:v.string().optional().describe("Keyword matched against portal title (case-insensitive)"),min_datasets:v.coerce.number().int().min(0).optional().describe("Minimum number of datasets"),language:v.string().optional().describe("Portal default locale code (e.g. 'it', 'en', 'pt_BR')"),has_datastore:v.boolean().optional().describe("If true, return only portals with DataStore plugin (required for SQL queries)"),limit:v.coerce.number().int().min(1).max(50).optional().default(10).describe("Max results (default 10, max 50)")}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{let r=await
|
|
923
|
-
${we(r,"ckan_find_portals")}`}],isError:!0}}})}function Or(t){let e=t.hostname;if(!e)throw new Error("Invalid ckan:// URI: missing server hostname");let r=t.pathname.split("/").filter(a=>a.length>0);if(r.length<2)throw new Error(`Invalid ckan:// URI: expected /{type}/{id}, got ${t.pathname}`);let[n,...o]=r,s=o.join("/");if(!n||!s)throw new Error("Invalid ckan:// URI: missing type or id");return{server:qa(e)||`https://${e}`,type:n,id:s}}function
|
|
927
|
+
Typical workflow: ckan_find_portals (discover portal URL) \u2192 ckan_status_show (verify) \u2192 ckan_package_search (search datasets)`,inputSchema:v.object({country:v.string().optional().describe("Country name in English (e.g. 'Italy', 'Brazil'). Translate from any language before passing."),query:v.string().optional().describe("Keyword matched against portal title (case-insensitive)"),min_datasets:v.coerce.number().int().min(0).optional().describe("Minimum number of datasets"),language:v.string().optional().describe("Portal default locale code (e.g. 'it', 'en', 'pt_BR')"),has_datastore:v.boolean().optional().describe("If true, return only portals with DataStore plugin (required for SQL queries)"),limit:v.coerce.number().int().min(1).max(50).optional().default(10).describe("Max results (default 10, max 50)")}).strict(),annotations:{readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0}},async e=>{try{let r=await $O(),n=r.filter(i=>i.status==="active"),o=zO(r,{country:e.country,query:e.query,min_datasets:e.min_datasets,language:e.language,has_datastore:e.has_datastore,limit:e.limit}),s=RO(o,n.length,e.limit);return{content:[{type:"text",text:se(s)}],structuredContent:{portals:o.map(i=>({url:i.Href,title:i.SiteInfo.site_title,country:i.Coordinates.country_name,version:i.Version,datasets:i.DatasetsNumber,locale:i.SiteInfo.locale_default,has_datastore:(i.Plugins||[]).includes("datastore")}))}}}catch(r){return{content:[{type:"text",text:`Could not fetch portal list from datashades.info:
|
|
928
|
+
${we(r,"ckan_find_portals")}`}],isError:!0}}})}function Or(t){let e=t.hostname;if(!e)throw new Error("Invalid ckan:// URI: missing server hostname");let r=t.pathname.split("/").filter(a=>a.length>0);if(r.length<2)throw new Error(`Invalid ckan:// URI: expected /{type}/{id}, got ${t.pathname}`);let[n,...o]=r,s=o.join("/");if(!n||!s)throw new Error("Invalid ckan:// URI: missing type or id");return{server:qa(e)||`https://${e}`,type:n,id:s}}function qb(t){t.registerResource("ckan-dataset",new Lt("ckan://{server}/dataset/{id}",{list:void 0}),{title:"CKAN Dataset",description:"Access dataset metadata from any CKAN server. URI format: ckan://{server}/dataset/{id}",mimeType:"application/json"},async(e,r)=>{try{let{server:n}=Or(e),o=r.id,s=await U(n,"package_show",{id:o}),i=W(JSON.stringify(s,null,2));return{contents:[{uri:e.href,mimeType:"application/json",text:i}]}}catch(n){let o=n instanceof Error?n.message:String(n);return{contents:[{uri:e.href,mimeType:"text/plain",text:`Error fetching dataset: ${o}`}]}}})}function Db(t){t.registerResource("ckan-resource",new Lt("ckan://{server}/resource/{id}",{list:void 0}),{title:"CKAN Resource",description:"Access resource metadata and download URL from any CKAN server. URI format: ckan://{server}/resource/{id}",mimeType:"application/json"},async(e,r)=>{try{let{server:n}=Or(e),o=r.id,s=await U(n,"resource_show",{id:o}),i=W(JSON.stringify(s,null,2));return{contents:[{uri:e.href,mimeType:"application/json",text:i}]}}catch(n){let o=n instanceof Error?n.message:String(n);return{contents:[{uri:e.href,mimeType:"text/plain",text:`Error fetching resource: ${o}`}]}}})}function Zb(t){t.registerResource("ckan-organization",new Lt("ckan://{server}/organization/{name}",{list:void 0}),{title:"CKAN Organization",description:"Access organization metadata from any CKAN server. URI format: ckan://{server}/organization/{name}",mimeType:"application/json"},async(e,r)=>{try{let{server:n}=Or(e),o=r.name,s=await U(n,"organization_show",{id:o,include_datasets:!1}),i=W(JSON.stringify(s,null,2));return{contents:[{uri:e.href,mimeType:"application/json",text:i}]}}catch(n){let o=n instanceof Error?n.message:String(n);return{contents:[{uri:e.href,mimeType:"text/plain",text:`Error fetching organization: ${o}`}]}}})}var Ha=t=>t.replace(/["\\]/g,"\\$&"),EO=t=>{let e=t.trim(),r=[e],n=e.toUpperCase();return n!==e&&r.push(n),`(${["res_format","distribution_format"].flatMap(i=>r.map(a=>`${i}:"${Ha(a)}"`)).join(" OR ")})`},Va=(t,e)=>{t.registerResource(e.name,new Lt(e.template,{list:void 0}),{title:e.title,description:e.description,mimeType:"application/json"},async(r,n)=>{try{let{server:o}=Or(r),s=e.buildFq(n),i=await U(o,"package_search",{q:"*:*",fq:s}),a=W(JSON.stringify(i,null,2));return{contents:[{uri:r.href,mimeType:"application/json",text:a}]}}catch(o){let s=o instanceof Error?o.message:String(o);return{contents:[{uri:r.href,mimeType:"text/plain",text:`Error fetching datasets: ${s}`}]}}})};function Lb(t){Va(t,{name:"ckan-group-datasets",template:"ckan://{server}/group/{name}/datasets",title:"CKAN Group Datasets",description:"List datasets in a CKAN group (theme). URI format: ckan://{server}/group/{name}/datasets",buildFq:e=>`groups:"${Ha(e.name)}"`})}function Ub(t){Va(t,{name:"ckan-organization-datasets",template:"ckan://{server}/organization/{name}/datasets",title:"CKAN Organization Datasets",description:"List datasets for a CKAN organization. URI format: ckan://{server}/organization/{name}/datasets",buildFq:e=>`organization:"${Ha(e.name)}"`})}function Fb(t){Va(t,{name:"ckan-tag-datasets",template:"ckan://{server}/tag/{name}/datasets",title:"CKAN Tag Datasets",description:"List datasets matching a CKAN tag. URI format: ckan://{server}/tag/{name}/datasets",buildFq:e=>`tags:"${Ha(e.name)}"`})}function Hb(t){Va(t,{name:"ckan-format-datasets",template:"ckan://{server}/format/{format}/datasets",title:"CKAN Format Datasets",description:"List datasets by resource format. URI format: ckan://{server}/format/{format}/datasets",buildFq:e=>EO(e.format)})}function Vb(t){qb(t),Db(t),Zb(t),Lb(t),Ub(t),Fb(t),Hb(t)}var _t=t=>({messages:[{role:"user",content:{type:"text",text:t}}]});var PO="ckan-search-by-theme",AO=(t,e,r)=>`# Guided search: datasets by theme
|
|
924
929
|
|
|
925
930
|
## Step 1: Find the theme/group
|
|
926
931
|
Use \`ckan_group_search\` to locate the group that matches the theme.
|
|
@@ -956,7 +961,7 @@ ckan_package_search({
|
|
|
956
961
|
|
|
957
962
|
Note: metadata_modified is a CKAN record timestamp (publish time on source portals,
|
|
958
963
|
harvest time on aggregators). If the user asks for
|
|
959
|
-
content publication dates, prefer issued (or modified) with explicit ISO ranges.`,
|
|
964
|
+
content publication dates, prefer issued (or modified) with explicit ISO ranges.`,Bb=t=>{t.registerPrompt(PO,{title:"Search datasets by theme",description:"Guided prompt to discover a theme and search datasets under it.",argsSchema:{server_url:v.string().url().describe("Base URL of the CKAN server"),theme:v.string().min(1).describe("Theme or group name to search"),rows:v.coerce.number().int().positive().default(10).describe("Max results to return")}},async({server_url:e,theme:r,rows:n})=>_t(AO(e,r,n)))};var CO="ckan-search-by-organization",OO=(t,e,r)=>`# Guided search: datasets by organization
|
|
960
965
|
|
|
961
966
|
## Step 1: Discover matching organizations
|
|
962
967
|
Use \`ckan_package_search\` with an organization wildcard and facets:
|
|
@@ -981,7 +986,7 @@ ckan_package_search({
|
|
|
981
986
|
|
|
982
987
|
Note: metadata_modified is a CKAN record timestamp (publish time on source portals,
|
|
983
988
|
harvest time on aggregators). If the user asks for
|
|
984
|
-
content publication dates, prefer issued (or modified) with explicit ISO ranges.`,
|
|
989
|
+
content publication dates, prefer issued (or modified) with explicit ISO ranges.`,Kb=t=>{t.registerPrompt(CO,{title:"Search datasets by organization",description:"Guided prompt to find a publisher and list its datasets.",argsSchema:{server_url:v.string().url().describe("Base URL of the CKAN server"),organization:v.string().min(1).describe("Organization name or keyword"),rows:v.coerce.number().int().positive().default(10).describe("Max results to return")}},async({server_url:e,organization:r,rows:n})=>_t(OO(e,r,n)))};var NO="ckan-search-by-format",IO=(t,e,r)=>`# Guided search: datasets by resource format
|
|
985
990
|
|
|
986
991
|
Use \`ckan_package_search\` with a format filter:
|
|
987
992
|
|
|
@@ -995,7 +1000,7 @@ ckan_package_search({
|
|
|
995
1000
|
Tip: try uppercase (CSV/JSON) or common variants if results are sparse.
|
|
996
1001
|
Note: metadata_modified is a CKAN record timestamp (publish time on source portals,
|
|
997
1002
|
harvest time on aggregators). If the user asks for
|
|
998
|
-
content publication dates, prefer issued (or modified) with explicit ISO ranges.`,
|
|
1003
|
+
content publication dates, prefer issued (or modified) with explicit ISO ranges.`,Jb=t=>{t.registerPrompt(NO,{title:"Search datasets by resource format",description:"Guided prompt to find datasets with a given resource format.",argsSchema:{server_url:v.string().url().describe("Base URL of the CKAN server"),format:v.string().min(1).describe("Resource format (e.g., CSV, JSON)"),rows:v.coerce.number().int().positive().default(10).describe("Max results to return")}},async({server_url:e,format:r,rows:n})=>_t(IO(e,r,n)))};var MO="ckan-recent-datasets",jO=(t,e)=>`# Guided search: recent datasets
|
|
999
1004
|
|
|
1000
1005
|
Use \`ckan_package_search\` sorted by metadata modification date (CKAN record updates,
|
|
1001
1006
|
publish time on source portals, harvest time on aggregators):
|
|
@@ -1033,7 +1038,7 @@ ckan_package_search({
|
|
|
1033
1038
|
content_recent: true,
|
|
1034
1039
|
content_recent_days: 30,
|
|
1035
1040
|
rows: ${e}
|
|
1036
|
-
})`,
|
|
1041
|
+
})`,Wb=t=>{t.registerPrompt(MO,{title:"Find recently updated datasets",description:"Guided prompt to list recently updated datasets on a CKAN portal.",argsSchema:{server_url:v.string().url().describe("Base URL of the CKAN server"),rows:v.coerce.number().int().positive().default(10).describe("Max results to return")}},async({server_url:e,rows:r})=>_t(jO(e,r)))};var qO="ckan-analyze-dataset",DO=(t,e)=>`# Guided analysis: dataset
|
|
1037
1042
|
|
|
1038
1043
|
## Step 1: Get dataset metadata
|
|
1039
1044
|
Use \`ckan_package_show\` to load full metadata and resources:
|
|
@@ -1065,7 +1070,7 @@ For aggregates, use SQL:
|
|
|
1065
1070
|
ckan_datastore_search_sql({
|
|
1066
1071
|
server_url: "${t}",
|
|
1067
1072
|
sql: "SELECT * FROM "<resource-id>" LIMIT 10"
|
|
1068
|
-
})`,
|
|
1073
|
+
})`,Gb=t=>{t.registerPrompt(qO,{title:"Analyze a dataset",description:"Guided prompt to inspect dataset metadata and explore DataStore tables.",argsSchema:{server_url:v.string().url().describe("Base URL of the CKAN server"),id:v.string().min(1).describe("Dataset id or name (CKAN package id)")}},async({server_url:e,id:r})=>_t(DO(e,r)))};var ZO="ckan-search-hvd",LO=(t,e,r)=>r?`# High-Value Datasets (HVD) search
|
|
1069
1074
|
|
|
1070
1075
|
The portal **${t}** classifies HVDs using the field \`${r}\`.
|
|
1071
1076
|
|
|
@@ -1112,7 +1117,7 @@ ckan_package_search({
|
|
|
1112
1117
|
})
|
|
1113
1118
|
\`\`\`
|
|
1114
1119
|
|
|
1115
|
-
If the portal supports HVD classification, look for datasets with fields like \`hvd_category\` or \`applicable_legislation\`.`,
|
|
1120
|
+
If the portal supports HVD classification, look for datasets with fields like \`hvd_category\` or \`applicable_legislation\`.`,Qb=t=>{t.registerPrompt(ZO,{title:"Search High-Value Datasets (HVD)",description:"Guided prompt to find High-Value Datasets (HVD) on a CKAN portal. Automatically uses the correct filter field from portal configuration.",argsSchema:{server_url:v.string().url().describe("Base URL of the CKAN server"),rows:v.coerce.number().int().positive().default(10).describe("Max results to return")}},async({server_url:e,rows:r})=>{let n=lo(e);return _t(LO(e,r,n?.category_field??null))})};var Yb=t=>{Bb(t),Kb(t),Jb(t),Wb(t),Gb(t),Qb(t)};function Xb(){return new xa({name:"ckan-mcp-server",version:"0.4.108"})}function ew(t){bb(t),wb(t),kb(t),Sb(t),$b(t),zb(t),Ob(t),Nb(t),Ib(t),Mb(t),jb(t),Vb(t),Yb(t)}var Ba=class{constructor(e={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}createJsonErrorResponse(e,r,n,o){let s={code:r,message:n};return o?.data!==void 0&&(s.data=o.data),new Response(JSON.stringify({jsonrpc:"2.0",error:s,id:null}),{status:e,headers:{"Content-Type":"application/json",...o?.headers}})}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let r=e.headers.get("host");if(!r||!this._allowedHosts.includes(r)){let n=`Invalid Host header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let r=e.headers.get("origin");if(r&&!this._allowedOrigins.includes(r)){let n=`Invalid Origin header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}}}async handleRequest(e,r){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let n=this.validateRequestHeaders(e);if(n)return n;switch(e.method){case"POST":return this.handlePostRequest(e,r);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(e,r,n,o){if(!this._eventStore||o<"2025-11-25")return;let s=await this._eventStore.storeEvent(n,{}),i=`id: ${s}
|
|
1116
1121
|
data:
|
|
1117
1122
|
|
|
1118
1123
|
`;this._retryInterval!==void 0&&(i=`id: ${s}
|
|
@@ -1123,7 +1128,7 @@ data:
|
|
|
1123
1128
|
`;return o&&(s+=`id: ${o}
|
|
1124
1129
|
`),s+=`data: ${JSON.stringify(n)}
|
|
1125
1130
|
|
|
1126
|
-
`,e.enqueue(r.encode(s)),!0}catch(s){return this.onerror?.(s),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,r){try{let n=e.headers.get("accept");if(!n?.includes("application/json")||!n.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let o=e.headers.get("content-type");if(!o||!o.includes("application/json"))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let s={headers:Object.fromEntries(e.headers.entries()),url:new URL(e.url)},i;if(r?.parsedBody!==void 0)i=r.parsedBody;else try{i=await e.json()}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let a;try{Array.isArray(i)?a=i.map(y=>
|
|
1131
|
+
`,e.enqueue(r.encode(s)),!0}catch(s){return this.onerror?.(s),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,r){try{let n=e.headers.get("accept");if(!n?.includes("application/json")||!n.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let o=e.headers.get("content-type");if(!o||!o.includes("application/json"))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let s={headers:Object.fromEntries(e.headers.entries()),url:new URL(e.url)},i;if(r?.parsedBody!==void 0)i=r.parsedBody;else try{i=await e.json()}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let a;try{Array.isArray(i)?a=i.map(y=>ll.parse(y)):a=[ll.parse(i)]}catch{return this.onerror?.(new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}let c=a.some(dl);if(c){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(a.length>1)return this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!c){let y=this.validateSession(e);if(y)return y;let b=this.validateProtocolVersion(e);if(b)return b}if(!a.some(vr)){for(let y of a)this.onmessage?.(y,{authInfo:r?.authInfo,requestInfo:s});return new Response(null,{status:202})}let l=crypto.randomUUID(),d=a.find(y=>dl(y)),p=d?d.params.protocolVersion:e.headers.get("mcp-protocol-version")??gh;if(this._enableJsonResponse)return new Promise(y=>{this._streamMapping.set(l,{resolveJson:y,cleanup:()=>{this._streamMapping.delete(l)}});for(let b of a)vr(b)&&this._requestToStreamMapping.set(b.id,l);for(let b of a)this.onmessage?.(b,{authInfo:r?.authInfo,requestInfo:s})});let m=new TextEncoder,f,h=new ReadableStream({start:y=>{f=y},cancel:()=>{this._streamMapping.delete(l)}}),g={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};this.sessionId!==void 0&&(g["mcp-session-id"]=this.sessionId);for(let y of a)vr(y)&&(this._streamMapping.set(l,{controller:f,encoder:m,cleanup:()=>{this._streamMapping.delete(l);try{f.close()}catch{}}}),this._requestToStreamMapping.set(y.id,l));await this.writePrimingEvent(f,m,l,p);for(let y of a){let b,k;vr(y)&&this._eventStore&&p>="2025-11-25"&&(b=()=>{this.closeSSEStream(y.id)},k=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(y,{authInfo:r?.authInfo,requestInfo:s,closeSSEStream:b,closeStandaloneSSEStream:k})}return new Response(h,{status:200,headers:g})}catch(n){return this.onerror?.(n),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(n)})}}async handleDeleteRequest(e){let r=this.validateSession(e);if(r)return r;let n=this.validateProtocolVersion(e);return n||(await Promise.resolve(this._onsessionclosed?.(this.sessionId)),await this.close(),new Response(null,{status:200}))}validateSession(e){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let r=e.headers.get("mcp-session-id");if(!r)return this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(r!==this.sessionId)return this.onerror?.(new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(e){let r=e.headers.get("mcp-protocol-version");if(r!==null&&!In.includes(r))return this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${r} (supported versions: ${In.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${r} (supported versions: ${In.join(", ")})`)}async close(){this._streamMapping.forEach(({cleanup:e})=>{e()}),this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}closeSSEStream(e){let r=this._requestToStreamMapping.get(e);if(!r)return;let n=this._streamMapping.get(r);n&&n.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,r){let n=r?.relatedRequestId;if((Yt(e)||Mn(e))&&(n=e.id),n===void 0){if(Yt(e)||Mn(e))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let i;this._eventStore&&(i=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let a=this._streamMapping.get(this._standaloneSseStreamId);if(a===void 0)return;a.controller&&a.encoder&&this.writeSSEEvent(a.controller,a.encoder,e,i);return}let o=this._requestToStreamMapping.get(n);if(!o)throw new Error(`No connection established for request ID: ${String(n)}`);let s=this._streamMapping.get(o);if(!this._enableJsonResponse&&s?.controller&&s?.encoder){let i;this._eventStore&&(i=await this._eventStore.storeEvent(o,e)),this.writeSSEEvent(s.controller,s.encoder,e,i)}if(Yt(e)||Mn(e)){this._requestResponseMap.set(n,e);let i=Array.from(this._requestToStreamMapping.entries()).filter(([c,u])=>u===o).map(([c])=>c);if(i.every(c=>this._requestResponseMap.has(c))){if(!s)throw new Error(`No connection established for request ID: ${String(n)}`);if(this._enableJsonResponse&&s.resolveJson){let c={"Content-Type":"application/json"};this.sessionId!==void 0&&(c["mcp-session-id"]=this.sessionId);let u=i.map(l=>this._requestResponseMap.get(l));u.length===1?s.resolveJson(new Response(JSON.stringify(u[0]),{status:200,headers:c})):s.resolveJson(new Response(JSON.stringify(u),{status:200,headers:c}))}else s.cleanup();for(let c of i)this._requestResponseMap.delete(c),this._requestToStreamMapping.delete(c)}}}};var HF={async fetch(t,e){let r=new URL(t.url);if(t.method==="GET"&&r.pathname==="/")return new Response(`<!DOCTYPE html>
|
|
1127
1132
|
<html lang="en">
|
|
1128
1133
|
<head>
|
|
1129
1134
|
<meta charset="UTF-8">
|
|
@@ -1309,4 +1314,4 @@ data:
|
|
|
1309
1314
|
</div>
|
|
1310
1315
|
</div>
|
|
1311
1316
|
</body>
|
|
1312
|
-
</html>`,{headers:{"Content-Type":"text/html; charset=utf-8","Access-Control-Allow-Origin":"*"}});if(t.method==="GET"&&r.pathname==="/health")return new Response(JSON.stringify({status:"ok",version:"0.4.
|
|
1317
|
+
</html>`,{headers:{"Content-Type":"text/html; charset=utf-8","Access-Control-Allow-Origin":"*"}});if(t.method==="GET"&&r.pathname==="/health")return new Response(JSON.stringify({status:"ok",version:"0.4.108",tools:20,resources:7,prompts:6,runtime:"cloudflare-workers"}),{headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}});if(r.pathname==="/mcp"){if(t.method!=="POST"&&t.method!=="OPTIONS")return new Response("Method Not Allowed",{status:405,headers:{Allow:"POST, OPTIONS","Access-Control-Allow-Origin":"*"}});if(t.method==="OPTIONS")return new Response(null,{status:204,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, POST, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Accept, Authorization, Mcp-Session-Id","Access-Control-Max-Age":"86400"}});try{let n=Xb();ew(n);let o=new Ba({sessionIdGenerator:void 0,enableJsonResponse:!0});await n.connect(o);let s=t.clone(),i=null;try{let d=await s.json();if(d?.method==="tools/call"&&d?.params?.name){let p=d.params.name,m=d.params.arguments??{};i={tool:p,server:m.server_url??m.endpoint_url??""},m.q!==void 0&&(i.q=m.q),m.fq!==void 0&&(i.fq=m.fq),m.query!==void 0&&(i.query=m.query),m.id!==void 0&&(i.id=m.id),m.name!==void 0&&(i.name=m.name),m.pattern!==void 0&&(i.pattern=m.pattern),m.resource_id!==void 0&&(i.resource_id=m.resource_id),m.format_filter!==void 0&&(i.format_filter=m.format_filter),m.sort!==void 0&&(i.sort=m.sort),m.rows!==void 0&&(i.rows=m.rows),m.limit!==void 0&&(i.limit=m.limit),m.sql!==void 0&&(i.sql=String(m.sql).slice(0,200)),m.country!==void 0&&(i.country=m.country),m.language!==void 0&&(i.language=m.language),m.has_datastore!==void 0&&(i.has_datastore=m.has_datastore),m.min_datasets!==void 0&&(i.min_datasets=m.min_datasets)}}catch{}let a=Date.now(),c=await o.handleRequest(t),u=Date.now()-a;if(i){let d=nb();d!==null&&(i.cache_hit=d),i.duration_ms=u;let p="ok";try{let m=await c.clone().json();(m?.result?.isError||m?.error)&&(p="error")}catch{}i.status=p,console.log(JSON.stringify(i)),e.ANALYTICS&&e.ANALYTICS.writeDataPoint({blobs:[String(i.tool??""),String(i.server??""),String(i.q??i.query??i.id??""),p,String(i.country??"")],doubles:[u,d?1:0],indexes:[String(i.tool??"")]})}let l=new Headers(c.headers);return l.set("Access-Control-Allow-Origin","*"),l.set("X-Service-Notice","Demo instance - 100k requests/day shared quota"),l.set("X-Recommendation","https://github.com/ondata/ckan-mcp-server#installation"),new Response(c.body,{status:c.status,statusText:c.statusText,headers:l})}catch(n){return console.error("Worker error:",n),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal error",data:n instanceof Error?n.message:String(n)},id:null}),{status:500,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}})}}return new Response("Not Found",{status:404,headers:{"Access-Control-Allow-Origin":"*"}})}};export{HF as default};
|