From 29e6441d32d25872ed3ac66ca8e8d1639ddac1af Mon Sep 17 00:00:00 2001 From: Alex Newman Date: Sun, 14 Dec 2025 19:23:48 -0500 Subject: [PATCH] Refactor mem-search documentation and optimize API tool definitions - Updated SKILL.md to emphasize batch fetching for observations, clarifying usage and efficiency. - Removed deprecated tools from mcp-server.ts and streamlined tool definitions for clarity. - Enhanced formatting in FormattingService.ts for better output readability. - Adjusted SearchManager.ts to improve result headers and removed unnecessary search tips from combined text. --- plugin/scripts/mcp-server.cjs | 16 +- plugin/scripts/worker-service.cjs | 48 ++-- plugin/skills/mem-search/SKILL.md | 57 +++-- src/servers/mcp-server.ts | 293 ++++------------------- src/services/worker/FormattingService.ts | 12 +- src/services/worker/SearchManager.ts | 34 +-- 6 files changed, 138 insertions(+), 322 deletions(-) diff --git a/plugin/scripts/mcp-server.cjs b/plugin/scripts/mcp-server.cjs index 76e54b92..5166536b 100755 --- a/plugin/scripts/mcp-server.cjs +++ b/plugin/scripts/mcp-server.cjs @@ -1,15 +1,15 @@ #!/usr/bin/env bun -"use strict";var Ml=Object.create;var Da=Object.defineProperty;var Fl=Object.getOwnPropertyDescriptor;var Ll=Object.getOwnPropertyNames;var ql=Object.getPrototypeOf,Ul=Object.prototype.hasOwnProperty;var W=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),Vl=(a,e)=>{for(var t in e)Da(a,t,{get:e[t],enumerable:!0})},zl=(a,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ll(e))!Ul.call(a,r)&&r!==t&&Da(a,r,{get:()=>e[r],enumerable:!(s=Fl(e,r))||s.enumerable});return a};var Ia=(a,e,t)=>(t=a!=null?Ml(ql(a)):{},zl(e||!a||!a.__esModule?Da(t,"default",{value:a,enumerable:!0}):t,a));var Sn=W((Xt,En)=>{(function(a,e){typeof Xt=="object"&&typeof En<"u"?e(Xt):typeof define=="function"&&define.amd?define(["exports"],e):e(a.URI=a.URI||{})})(Xt,(function(a){"use strict";function e(){for(var h=arguments.length,d=Array(h),g=0;g1){d[0]=d[0].slice(0,-1);for(var E=d.length-1,S=1;S= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=c-y,U=Math.floor,L=String.fromCharCode;function M(h){throw new RangeError(q[h])}function A(h,d){for(var g=[],E=h.length;E--;)g[E]=d(h[E]);return g}function $(h,d){var g=h.split("@"),E="";g.length>1&&(E=g[0]+"@",h=g[1]),h=h.replace(z,".");var S=h.split("."),j=A(S,d).join(".");return E+j}function F(h){for(var d=[],g=0,E=h.length;g=55296&&S<=56319&&g>1,d+=U(d/g);d>k*_>>1;S+=c)d=U(d/k);return U(S+(k+1)*d/(d+v))},H=function(d){var g=[],E=d.length,S=0,j=P,Q=T,ae=d.lastIndexOf(O);ae<0&&(ae=0);for(var oe=0;oe=128&&M("not-basic"),g.push(d.charCodeAt(oe));for(var be=ae>0?ae+1:0;be=E&&M("invalid-input");var de=Y(d.charCodeAt(be++));(de>=c||de>U((b-S)/pe))&&M("overflow"),S+=de*pe;var ne=Ee<=Q?y:Ee>=Q+_?_:Ee-Q;if(deU(b/he)&&M("overflow"),pe*=he}var ce=g.length+1;Q=G(S-te,ce,te==0),U(S/ce)>b-j&&M("overflow"),j+=U(S/ce),S%=ce,g.splice(S++,0,j)}return String.fromCodePoint.apply(String,g)},me=function(d){var g=[];d=F(d);var E=d.length,S=P,j=0,Q=T,ae=!0,oe=!1,be=void 0;try{for(var te=d[Symbol.iterator](),pe;!(ae=(pe=te.next()).done);ae=!0){var Ee=pe.value;Ee<128&&g.push(L(Ee))}}catch(Nr){oe=!0,be=Nr}finally{try{!ae&&te.return&&te.return()}finally{if(oe)throw be}}var de=g.length,ne=de;for(de&&g.push(O);ne=S&&VeU((b-j)/Ze)&&M("overflow"),j+=(he-S)*Ze,S=he;var ir=!0,Cr=!1,hr=void 0;try{for(var bt=d[Symbol.iterator](),jt;!(ir=(jt=bt.next()).done);ir=!0){var Mt=jt.value;if(Mtb&&M("overflow"),Mt==S){for(var rt=j,tt=c;;tt+=c){var mr=tt<=Q?y:tt>=Q+_?_:tt-Q;if(rt>6|192).toString(16).toUpperCase()+"%"+(d&63|128).toString(16).toUpperCase():g="%"+(d>>12|224).toString(16).toUpperCase()+"%"+(d>>6&63|128).toString(16).toUpperCase()+"%"+(d&63|128).toString(16).toUpperCase(),g}function De(h){for(var d="",g=0,E=h.length;g=194&&S<224){if(E-g>=6){var j=parseInt(h.substr(g+4,2),16);d+=String.fromCharCode((S&31)<<6|j&63)}else d+=h.substr(g,6);g+=6}else if(S>=224){if(E-g>=9){var Q=parseInt(h.substr(g+4,2),16),ae=parseInt(h.substr(g+7,2),16);d+=String.fromCharCode((S&15)<<12|(Q&63)<<6|ae&63)}else d+=h.substr(g,9);g+=9}else d+=h.substr(g,3),g+=3}return d}function Er(h,d){function g(E){var S=De(E);return S.match(d.UNRESERVED)?S:E}return h.scheme&&(h.scheme=String(h.scheme).replace(d.PCT_ENCODED,g).toLowerCase().replace(d.NOT_SCHEME,"")),h.userinfo!==void 0&&(h.userinfo=String(h.userinfo).replace(d.PCT_ENCODED,g).replace(d.NOT_USERINFO,Se).replace(d.PCT_ENCODED,r)),h.host!==void 0&&(h.host=String(h.host).replace(d.PCT_ENCODED,g).toLowerCase().replace(d.NOT_HOST,Se).replace(d.PCT_ENCODED,r)),h.path!==void 0&&(h.path=String(h.path).replace(d.PCT_ENCODED,g).replace(h.scheme?d.NOT_PATH:d.NOT_PATH_NOSCHEME,Se).replace(d.PCT_ENCODED,r)),h.query!==void 0&&(h.query=String(h.query).replace(d.PCT_ENCODED,g).replace(d.NOT_QUERY,Se).replace(d.PCT_ENCODED,r)),h.fragment!==void 0&&(h.fragment=String(h.fragment).replace(d.PCT_ENCODED,g).replace(d.NOT_FRAGMENT,Se).replace(d.PCT_ENCODED,r)),h}function fr(h){return h.replace(/^0*(.*)/,"$1")||"0"}function _e(h,d){var g=h.match(d.IPV4ADDRESS)||[],E=p(g,2),S=E[1];return S?S.split(".").map(fr).join("."):h}function ve(h,d){var g=h.match(d.IPV6ADDRESS)||[],E=p(g,3),S=E[1],j=E[2];if(S){for(var Q=S.toLowerCase().split("::").reverse(),ae=p(Q,2),oe=ae[0],be=ae[1],te=be?be.split(":").map(fr):[],pe=oe.split(":").map(fr),Ee=d.IPV4ADDRESS.test(pe[pe.length-1]),de=Ee?7:8,ne=pe.length-de,he=Array(de),ce=0;ce1){var ue=he.slice(0,Ue.index),Ve=he.slice(Ue.index+Ue.length);He=ue.join(":")+"::"+Ve.join(":")}else He=he.join(":");return j&&(He+="%"+j),He}else return h}var Dr=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Re="".match(/(){0}/)[1]===void 0;function ie(h){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g={},E=d.iri!==!1?f:u;d.reference==="suffix"&&(h=(d.scheme?d.scheme+":":"")+"//"+h);var S=h.match(Dr);if(S){Re?(g.scheme=S[1],g.userinfo=S[3],g.host=S[4],g.port=parseInt(S[5],10),g.path=S[6]||"",g.query=S[7],g.fragment=S[8],isNaN(g.port)&&(g.port=S[5])):(g.scheme=S[1]||void 0,g.userinfo=h.indexOf("@")!==-1?S[3]:void 0,g.host=h.indexOf("//")!==-1?S[4]:void 0,g.port=parseInt(S[5],10),g.path=S[6]||"",g.query=h.indexOf("?")!==-1?S[7]:void 0,g.fragment=h.indexOf("#")!==-1?S[8]:void 0,isNaN(g.port)&&(g.port=h.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?S[4]:void 0)),g.host&&(g.host=ve(_e(g.host,E),E)),g.scheme===void 0&&g.userinfo===void 0&&g.host===void 0&&g.port===void 0&&!g.path&&g.query===void 0?g.reference="same-document":g.scheme===void 0?g.reference="relative":g.fragment===void 0?g.reference="absolute":g.reference="uri",d.reference&&d.reference!=="suffix"&&d.reference!==g.reference&&(g.error=g.error||"URI is not a "+d.reference+" reference.");var j=ye[(d.scheme||g.scheme||"").toLowerCase()];if(!d.unicodeSupport&&(!j||!j.unicodeSupport)){if(g.host&&(d.domainHost||j&&j.domainHost))try{g.host=se.toASCII(g.host.replace(E.PCT_ENCODED,De).toLowerCase())}catch(Q){g.error=g.error||"Host's domain name can not be converted to ASCII via punycode: "+Q}Er(g,u)}else Er(g,E);j&&j.parse&&j.parse(g,d)}else g.error=g.error||"URI can not be parsed.";return g}function Sr(h,d){var g=d.iri!==!1?f:u,E=[];return h.userinfo!==void 0&&(E.push(h.userinfo),E.push("@")),h.host!==void 0&&E.push(ve(_e(String(h.host),g),g).replace(g.IPV6ADDRESS,function(S,j,Q){return"["+j+(Q?"%25"+Q:"")+"]"})),(typeof h.port=="number"||typeof h.port=="string")&&(E.push(":"),E.push(String(h.port))),E.length?E.join(""):void 0}var pr=/^\.\.?\//,Ir=/^\/\.(\/|$)/,kr=/^\/\.\.(\/|$)/,xe=/^\/?(?:.|\n)*?(?=\/|$)/;function ze(h){for(var d=[];h.length;)if(h.match(pr))h=h.replace(pr,"");else if(h.match(Ir))h=h.replace(Ir,"/");else if(h.match(kr))h=h.replace(kr,"/"),d.pop();else if(h==="."||h==="..")h="";else{var g=h.match(xe);if(g){var E=g[0];h=h.slice(E.length),d.push(E)}else throw new Error("Unexpected dot segment condition")}return d.join("")}function je(h){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g=d.iri?f:u,E=[],S=ye[(d.scheme||h.scheme||"").toLowerCase()];if(S&&S.serialize&&S.serialize(h,d),h.host&&!g.IPV6ADDRESS.test(h.host)){if(d.domainHost||S&&S.domainHost)try{h.host=d.iri?se.toUnicode(h.host):se.toASCII(h.host.replace(g.PCT_ENCODED,De).toLowerCase())}catch(ae){h.error=h.error||"Host's domain name can not be converted to "+(d.iri?"Unicode":"ASCII")+" via punycode: "+ae}}Er(h,g),d.reference!=="suffix"&&h.scheme&&(E.push(h.scheme),E.push(":"));var j=Sr(h,d);if(j!==void 0&&(d.reference!=="suffix"&&E.push("//"),E.push(j),h.path&&h.path.charAt(0)!=="/"&&E.push("/")),h.path!==void 0){var Q=h.path;!d.absolutePath&&(!S||!S.absolutePath)&&(Q=ze(Q)),j===void 0&&(Q=Q.replace(/^\/\//,"/%2F")),E.push(Q)}return h.query!==void 0&&(E.push("?"),E.push(h.query)),h.fragment!==void 0&&(E.push("#"),E.push(h.fragment)),E.join("")}function Ie(h,d){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},E=arguments[3],S={};return E||(h=ie(je(h,g),g),d=ie(je(d,g),g)),g=g||{},!g.tolerant&&d.scheme?(S.scheme=d.scheme,S.userinfo=d.userinfo,S.host=d.host,S.port=d.port,S.path=ze(d.path||""),S.query=d.query):(d.userinfo!==void 0||d.host!==void 0||d.port!==void 0?(S.userinfo=d.userinfo,S.host=d.host,S.port=d.port,S.path=ze(d.path||""),S.query=d.query):(d.path?(d.path.charAt(0)==="/"?S.path=ze(d.path):((h.userinfo!==void 0||h.host!==void 0||h.port!==void 0)&&!h.path?S.path="/"+d.path:h.path?S.path=h.path.slice(0,h.path.lastIndexOf("/")+1)+d.path:S.path=d.path,S.path=ze(S.path)),S.query=d.query):(S.path=h.path,d.query!==void 0?S.query=d.query:S.query=h.query),S.userinfo=h.userinfo,S.host=h.host,S.port=h.port),S.scheme=h.scheme),S.fragment=d.fragment,S}function sr(h,d,g){var E=l({scheme:"null"},g);return je(Ie(ie(h,E),ie(d,E),E,!0),E)}function qe(h,d){return typeof h=="string"?h=je(ie(h,d),d):s(h)==="object"&&(h=ie(je(h,d),d)),h}function Nt(h,d,g){return typeof h=="string"?h=je(ie(h,g),g):s(h)==="object"&&(h=je(h,g)),typeof d=="string"?d=je(ie(d,g),g):s(d)==="object"&&(d=je(d,g)),h===d}function Oa(h,d){return h&&h.toString().replace(!d||!d.iri?u.ESCAPE:f.ESCAPE,Se)}function Ge(h,d){return h&&h.toString().replace(!d||!d.iri?u.PCT_ENCODED:f.PCT_ENCODED,De)}var yt={scheme:"http",domainHost:!0,parse:function(d,g){return d.host||(d.error=d.error||"HTTP URIs must have a host."),d},serialize:function(d,g){var E=String(d.scheme).toLowerCase()==="https";return(d.port===(E?443:80)||d.port==="")&&(d.port=void 0),d.path||(d.path="/"),d}},ks={scheme:"https",domainHost:yt.domainHost,parse:yt.parse,serialize:yt.serialize};function $s(h){return typeof h.secure=="boolean"?h.secure:String(h.scheme).toLowerCase()==="wss"}var _t={scheme:"ws",domainHost:!0,parse:function(d,g){var E=d;return E.secure=$s(E),E.resourceName=(E.path||"/")+(E.query?"?"+E.query:""),E.path=void 0,E.query=void 0,E},serialize:function(d,g){if((d.port===($s(d)?443:80)||d.port==="")&&(d.port=void 0),typeof d.secure=="boolean"&&(d.scheme=d.secure?"wss":"ws",d.secure=void 0),d.resourceName){var E=d.resourceName.split("?"),S=p(E,2),j=S[0],Q=S[1];d.path=j&&j!=="/"?j:void 0,d.query=Q,d.resourceName=void 0}return d.fragment=void 0,d}},Cs={scheme:"wss",domainHost:_t.domainHost,parse:_t.parse,serialize:_t.serialize},yl={},_l=!0,Ns="[A-Za-z0-9\\-\\.\\_\\~"+(_l?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",nr="[0-9A-Fa-f]",bl=t(t("%[EFef]"+nr+"%"+nr+nr+"%"+nr+nr)+"|"+t("%[89A-Fa-f]"+nr+"%"+nr+nr)+"|"+t("%"+nr+nr)),El="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Sl="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",xl=e(Sl,'[\\"\\\\]'),Pl="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",wl=new RegExp(Ns,"g"),et=new RegExp(bl,"g"),Ol=new RegExp(e("[^]",El,"[\\.]",'[\\"]',xl),"g"),js=new RegExp(e("[^]",Ns,Pl),"g"),Rl=js;function Ra(h){var d=De(h);return d.match(wl)?d:h}var Ms={scheme:"mailto",parse:function(d,g){var E=d,S=E.to=E.path?E.path.split(","):[];if(E.path=void 0,E.query){for(var j=!1,Q={},ae=E.query.split("&"),oe=0,be=ae.length;oe{"use strict";xn.exports=function a(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var s,r,n;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(r=s;r--!==0;)if(!a(e[r],t[r]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(n=Object.keys(e),s=n.length,s!==Object.keys(t).length)return!1;for(r=s;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,n[r]))return!1;for(r=s;r--!==0;){var l=n[r];if(!a(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}});var wn=W((Up,Pn)=>{"use strict";Pn.exports=function(e){for(var t=0,s=e.length,r=0,n;r=55296&&n<=56319&&r{"use strict";Tn.exports={copy:Ju,checkDataType:Qa,checkDataTypes:Gu,coerceToTypes:Yu,toHash:Ga,getProperty:Ya,escapeQuotes:Xa,equal:ea(),ucs2length:wn(),varOccurences:rd,varReplace:td,schemaHasRules:ad,schemaHasRulesExcept:sd,schemaUnknownRules:nd,toQuotedString:Ja,getPathExpr:id,getPath:od,getData:ud,unescapeFragment:dd,unescapeJsonPointer:rs,escapeFragment:fd,escapeJsonPointer:es};function Ju(a,e){e=e||{};for(var t in a)e[t]=a[t];return e}function Qa(a,e,t,s){var r=s?" !== ":" === ",n=s?" || ":" && ",l=s?"!":"",o=s?"":"!";switch(a){case"null":return e+r+"null";case"array":return l+"Array.isArray("+e+")";case"object":return"("+l+e+n+"typeof "+e+r+'"object"'+n+o+"Array.isArray("+e+"))";case"integer":return"(typeof "+e+r+'"number"'+n+o+"("+e+" % 1)"+n+e+r+e+(t?n+l+"isFinite("+e+")":"")+")";case"number":return"(typeof "+e+r+'"'+a+'"'+(t?n+l+"isFinite("+e+")":"")+")";default:return"typeof "+e+r+'"'+a+'"'}}function Gu(a,e,t){switch(a.length){case 1:return Qa(a[0],e,t,!0);default:var s="",r=Ga(a);r.array&&r.object&&(s=r.null?"(":"(!"+e+" || ",s+="typeof "+e+' !== "object")',delete r.null,delete r.array,delete r.object),r.number&&delete r.integer;for(var n in r)s+=(s?" && ":"")+Qa(n,e,t,!0);return s}}var On=Ga(["string","number","integer","boolean","null"]);function Yu(a,e){if(Array.isArray(e)){for(var t=[],s=0;s=e)throw new Error("Cannot access property/index "+s+" levels up, current level is "+e);return t[e-s]}if(s>e)throw new Error("Cannot access data "+s+" levels up, current level is "+e);if(n="data"+(e-s||""),!r)return n}for(var o=n,u=r.split("/"),f=0;f{"use strict";var pd=Yr();An.exports=hd;function hd(a){pd.copy(a,this)}});var In=W((Hp,Dn)=>{"use strict";var Rr=Dn.exports=function(a,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var s=typeof t=="function"?t:t.pre||function(){},r=t.post||function(){};ra(e,s,r,a,"",a)};Rr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0};Rr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Rr.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Rr.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 ra(a,e,t,s,r,n,l,o,u,f){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,r,n,l,o,u,f);for(var p in s){var m=s[p];if(Array.isArray(m)){if(p in Rr.arrayKeywords)for(var b=0;b{"use strict";var kt=Sn(),kn=ea(),na=Yr(),ta=ts(),vd=In();Nn.exports=Ar;Ar.normalizeId=Tr;Ar.fullPath=aa;Ar.url=sa;Ar.ids=Ed;Ar.inlineRef=as;Ar.schema=ia;function Ar(a,e,t){var s=this._refs[t];if(typeof s=="string")if(this._refs[s])s=this._refs[s];else return Ar.call(this,a,e,s);if(s=s||this._schemas[t],s instanceof ta)return as(s.schema,this._opts.inlineRefs)?s.schema:s.validate||this._compile(s);var r=ia.call(this,e,t),n,l,o;return r&&(n=r.schema,e=r.root,o=r.baseId),n instanceof ta?l=n.validate||a.call(this,n.schema,e,void 0,o):n!==void 0&&(l=as(n,this._opts.inlineRefs)?n:a.call(this,n,e,void 0,o)),l}function ia(a,e){var t=kt.parse(e),s=Cn(t),r=aa(this._getId(a.schema));if(Object.keys(a.schema).length===0||s!==r){var n=Tr(s),l=this._refs[n];if(typeof l=="string")return gd.call(this,a,l,t);if(l instanceof ta)l.validate||this._compile(l),a=l;else if(l=this._schemas[n],l instanceof ta){if(l.validate||this._compile(l),n==Tr(e))return{schema:l,root:a,baseId:r};a=l}else return;if(!a.schema)return;r=aa(this._getId(a.schema))}return $n.call(this,t,r,a.schema,a)}function gd(a,e,t){var s=ia.call(this,a,e);if(s){var r=s.schema,n=s.baseId;a=s.root;var l=this._getId(r);return l&&(n=sa(n,l)),$n.call(this,t,n,r,a)}}var yd=na.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function $n(a,e,t,s){if(a.fragment=a.fragment||"",a.fragment.slice(0,1)=="/"){for(var r=a.fragment.split("/"),n=1;n{"use strict";var is=oa();Mn.exports={Validation:jn(Sd),MissingRef:jn(os)};function Sd(a){this.message="validation failed",this.errors=a,this.ajv=this.validation=!0}os.message=function(a,e){return"can't resolve reference "+e+" from id "+a};function os(a,e,t){this.message=t||os.message(a,e),this.missingRef=is.url(a,e),this.missingSchema=is.normalizeId(is.fullPath(this.missingRef))}function jn(a){return a.prototype=Object.create(Error.prototype),a.prototype.constructor=a,a}});var ls=W((Wp,Fn)=>{"use strict";Fn.exports=function(a,e){e||(e={}),typeof e=="function"&&(e={cmp:e});var t=typeof e.cycles=="boolean"?e.cycles:!1,s=e.cmp&&(function(n){return function(l){return function(o,u){var f={key:o,value:l[o]},p={key:u,value:l[u]};return n(f,p)}}})(e.cmp),r=[];return(function n(l){if(l&&l.toJSON&&typeof l.toJSON=="function"&&(l=l.toJSON()),l!==void 0){if(typeof l=="number")return isFinite(l)?""+l:"null";if(typeof l!="object")return JSON.stringify(l);var o,u;if(Array.isArray(l)){for(u="[",o=0;o{"use strict";Ln.exports=function(e,t,s){var r="",n=e.schema.$async===!0,l=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),o=e.self._getId(e.schema);if(e.opts.strictKeywords){var u=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(u){var f="unknown keyword: "+u;if(e.opts.strictKeywords==="log")e.logger.warn(f);else throw new Error(f)}}if(e.isTop&&(r+=" var validate = ",n&&(e.async=!0,r+="async "),r+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",o&&(e.opts.sourceCode||e.opts.processCode)&&(r+=" "+("/*# sourceURL="+o+" */")+" ")),typeof e.schema=="boolean"||!(l||e.schema.$ref)){var t="false schema",p=e.level,m=e.dataLevel,b=e.schema[t],c=e.schemaPath+e.util.getProperty(t),y=e.errSchemaPath+"/"+t,D=!e.opts.allErrors,q,_="data"+(m||""),O="valid"+p;if(e.schema===!1){e.isTop?D=!0:r+=" var "+O+" = false; ";var v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(q||"false schema")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(y)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'boolean schema is false' "),e.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+_+" "),r+=" } "):r+=" {} ";var x=r;r=v.pop(),!e.compositeRule&&D?e.async?r+=" throw new ValidationError(["+x+"]); ":r+=" validate.errors = ["+x+"]; return false; ":r+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else e.isTop?n?r+=" return data; ":r+=" validate.errors = null; return true; ":r+=" var "+O+" = true; ";return e.isTop&&(r+=" }; return validate; "),r}if(e.isTop){var T=e.isTop,p=e.level=0,m=e.dataLevel=0,_="data";if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[""],e.schema.default!==void 0&&e.opts.useDefaults&&e.opts.strictDefaults){var P="default is ignored in the schema root";if(e.opts.strictDefaults==="log")e.logger.warn(P);else throw new Error(P)}r+=" var vErrors = null; ",r+=" var errors = 0; ",r+=" if (rootData === undefined) rootData = data; "}else{var p=e.level,m=e.dataLevel,_="data"+(m||"");if(o&&(e.baseId=e.resolve.url(e.baseId,o)),n&&!e.async)throw new Error("async schema in sync schema");r+=" var errs_"+p+" = errors;"}var O="valid"+p,D=!e.opts.allErrors,I="",z="",q,k=e.schema.type,U=Array.isArray(k);if(k&&e.opts.nullable&&e.schema.nullable===!0&&(U?k.indexOf("null")==-1&&(k=k.concat("null")):k!="null"&&(k=[k,"null"],U=!0)),U&&k.length==1&&(k=k[0],U=!1),e.schema.$ref&&l){if(e.opts.extendRefs=="fail")throw new Error('$ref: validation keywords used in schema at path "'+e.errSchemaPath+'" (see option extendRefs)');e.opts.extendRefs!==!0&&(l=!1,e.logger.warn('$ref: keywords ignored in schema at path "'+e.errSchemaPath+'"'))}if(e.schema.$comment&&e.opts.$comment&&(r+=" "+e.RULES.all.$comment.code(e,"$comment")),k){if(e.opts.coerceTypes)var L=e.util.coerceToTypes(e.opts.coerceTypes,k);var M=e.RULES.types[k];if(L||U||M===!0||M&&!xe(M)){var c=e.schemaPath+".type",y=e.errSchemaPath+"/type",c=e.schemaPath+".type",y=e.errSchemaPath+"/type",A=U?"checkDataTypes":"checkDataType";if(r+=" if ("+e.util[A](k,_,e.opts.strictNumbers,!0)+") { ",L){var $="dataType"+p,F="coerced"+p;r+=" var "+$+" = typeof "+_+"; var "+F+" = undefined; ",e.opts.coerceTypes=="array"&&(r+=" if ("+$+" == 'object' && Array.isArray("+_+") && "+_+".length == 1) { "+_+" = "+_+"[0]; "+$+" = typeof "+_+"; if ("+e.util.checkDataType(e.schema.type,_,e.opts.strictNumbers)+") "+F+" = "+_+"; } "),r+=" if ("+F+" !== undefined) ; ";var le=L;if(le)for(var Y,re=-1,G=le.length-1;re{"use strict";var ca=oa(),da=Yr(),Un=la(),xd=ls(),qn=cs(),Pd=da.ucs2length,wd=ea(),Od=Un.Validation;zn.exports=us;function us(a,e,t,s){var r=this,n=this._opts,l=[void 0],o={},u=[],f={},p=[],m={},b=[];e=e||{schema:a,refVal:l,refs:o};var c=Rd.call(this,a,e,s),y=this._compilations[c.index];if(c.compiling)return y.callValidate=P;var _=this._formats,v=this.RULES;try{var x=O(a,e,t,s);y.validate=x;var T=y.callValidate;return T&&(T.schema=x.schema,T.errors=null,T.refs=x.refs,T.refVal=x.refVal,T.root=x.root,T.$async=x.$async,n.sourceCode&&(T.source=x.source)),x}finally{Td.call(this,a,e,s)}function P(){var A=y.validate,$=A.apply(this,arguments);return P.errors=A.errors,$}function O(A,$,F,le){var Y=!$||$&&$.schema==A;if($.schema!=e.schema)return us.call(r,A,$,F,le);var re=A.$async===!0,G=qn({isTop:!0,schema:A,isRoot:Y,baseId:le,root:$,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:Un.MissingRef,RULES:v,validate:qn,util:da,resolve:ca,resolveRef:D,usePattern:U,useDefault:L,useCustomRule:M,opts:n,formats:_,logger:r.logger,self:r});G=ua(l,Id)+ua(u,Ad)+ua(p,Dd)+ua(b,kd)+G,n.processCode&&(G=n.processCode(G,A));var H;try{var me=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",G);H=me(r,v,_,e,l,p,b,wd,Pd,Od),l[0]=H}catch(Oe){throw r.logger.error("Error compiling schema, function code:",G),Oe}return H.schema=A,H.errors=null,H.refs=o,H.refVal=l,H.root=Y?H:$,re&&(H.$async=!0),n.sourceCode===!0&&(H.source={code:G,patterns:u,defaults:p}),H}function D(A,$,F){$=ca.url(A,$);var le=o[$],Y,re;if(le!==void 0)return Y=l[le],re="refVal["+le+"]",k(Y,re);if(!F&&e.refs){var G=e.refs[$];if(G!==void 0)return Y=e.refVal[G],re=I($,Y),k(Y,re)}re=I($);var H=ca.call(r,O,e,$);if(H===void 0){var me=t&&t[$];me&&(H=ca.inlineRef(me,n.inlineRefs)?me:us.call(r,me,e,t,A))}if(H===void 0)z($);else return q($,H),k(H,re)}function I(A,$){var F=l.length;return l[F]=$,o[A]=F,"refVal"+F}function z(A){delete o[A]}function q(A,$){var F=o[A];l[F]=$}function k(A,$){return typeof A=="object"||typeof A=="boolean"?{code:$,schema:A,inline:!0}:{code:$,$async:A&&!!A.$async}}function U(A){var $=f[A];return $===void 0&&($=f[A]=u.length,u[$]=A),"pattern"+$}function L(A){switch(typeof A){case"boolean":case"number":return""+A;case"string":return da.toQuotedString(A);case"object":if(A===null)return"null";var $=xd(A),F=m[$];return F===void 0&&(F=m[$]=p.length,p[F]=A),"default"+F}}function M(A,$,F,le){if(r._opts.validateSchema!==!1){var Y=A.definition.dependencies;if(Y&&!Y.every(function(Se){return Object.prototype.hasOwnProperty.call(F,Se)}))throw new Error("parent schema must have all required keywords: "+Y.join(","));var re=A.definition.validateSchema;if(re){var G=re($);if(!G){var H="keyword schema is invalid: "+r.errorsText(re.errors);if(r._opts.validateSchema=="log")r.logger.error(H);else throw new Error(H)}}}var me=A.definition.compile,Oe=A.definition.inline,Ae=A.definition.macro,se;if(me)se=me.call(r,$,F,le);else if(Ae)se=Ae.call(r,$,F,le),n.validateSchema!==!1&&r.validateSchema(se,!0);else if(Oe)se=Oe.call(r,le,A.keyword,$,F);else if(se=A.definition.validate,!se)return;if(se===void 0)throw new Error('custom keyword "'+A.keyword+'"failed to compile');var ye=b.length;return b[ye]=se,{code:"customRule"+ye,validate:se}}}function Rd(a,e,t){var s=Vn.call(this,a,e,t);return s>=0?{index:s,compiling:!0}:(s=this._compilations.length,this._compilations[s]={schema:a,root:e,baseId:t},{index:s,compiling:!1})}function Td(a,e,t){var s=Vn.call(this,a,e,t);s>=0&&this._compilations.splice(s,1)}function Vn(a,e,t){for(var s=0;s{"use strict";var fa=Zn.exports=function(){this._cache={}};fa.prototype.put=function(e,t){this._cache[e]=t};fa.prototype.get=function(e){return this._cache[e]};fa.prototype.del=function(e){delete this._cache[e]};fa.prototype.clear=function(){this._cache={}}});var si=W((Gp,ai)=>{"use strict";var $d=Yr(),Cd=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Nd=[0,31,28,31,30,31,30,31,31,30,31,30,31],jd=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Wn=/^(?=.{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,Md=/^(?:[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,Fd=/^(?:[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,Kn=/^(?:(?:[^\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,Qn=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,Jn=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Gn=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Yn=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Xn=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;ai.exports=pa;function pa(a){return a=a=="full"?"full":"fast",$d.copy(pa[a])}pa.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\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,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":Kn,url:Qn,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,hostname:Wn,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[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}))|:)))(?:%.+)?\s*$/i,regex:ti,uuid:Jn,"json-pointer":Gn,"json-pointer-uri-fragment":Yn,"relative-json-pointer":Xn};pa.full={date:ei,time:ri,"date-time":Ud,uri:zd,"uri-reference":Fd,"uri-template":Kn,url:Qn,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:Wn,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[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}))|:)))(?:%.+)?\s*$/i,regex:ti,uuid:Jn,"json-pointer":Gn,"json-pointer-uri-fragment":Yn,"relative-json-pointer":Xn};function Ld(a){return a%4===0&&(a%100!==0||a%400===0)}function ei(a){var e=a.match(Cd);if(!e)return!1;var t=+e[1],s=+e[2],r=+e[3];return s>=1&&s<=12&&r>=1&&r<=(s==2&&Ld(t)?29:Nd[s])}function ri(a,e){var t=a.match(jd);if(!t)return!1;var s=t[1],r=t[2],n=t[3],l=t[5];return(s<=23&&r<=59&&n<=59||s==23&&r==59&&n==60)&&(!e||l)}var qd=/t|\s/i;function Ud(a){var e=a.split(qd);return e.length==2&&ei(e[0])&&ri(e[1],!0)}var Vd=/\/|:/;function zd(a){return Vd.test(a)&&Md.test(a)}var Hd=/[^\\]\\Z/;function ti(a){if(Hd.test(a))return!1;try{return new RegExp(a),!0}catch{return!1}}});var ii=W((Yp,ni)=>{"use strict";ni.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.errSchemaPath+"/"+t,f=!e.opts.allErrors,p="data"+(l||""),m="valid"+n,b,c;if(o=="#"||o=="#/")e.isRoot?(b=e.async,c="validate"):(b=e.root.schema.$async===!0,c="root.refVal[0]");else{var y=e.resolveRef(e.baseId,o,e.isRoot);if(y===void 0){var _=e.MissingRefError.message(e.baseId,o);if(e.opts.missingRefs=="fail"){e.logger.error(_);var v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { ref: '"+e.util.escapeQuotes(o)+"' } ",e.opts.messages!==!1&&(r+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(o)+"' "),e.opts.verbose&&(r+=" , schema: "+e.util.toQuotedString(o)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+p+" "),r+=" } "):r+=" {} ";var x=r;r=v.pop(),!e.compositeRule&&f?e.async?r+=" throw new ValidationError(["+x+"]); ":r+=" validate.errors = ["+x+"]; return false; ":r+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f&&(r+=" if (false) { ")}else if(e.opts.missingRefs=="ignore")e.logger.warn(_),f&&(r+=" if (true) { ");else throw new e.MissingRefError(e.baseId,o,_)}else if(y.inline){var T=e.util.copy(e);T.level++;var P="valid"+T.level;T.schema=y.schema,T.schemaPath="",T.errSchemaPath=o;var O=e.validate(T).replace(/validate\.schema/g,y.code);r+=" "+O+" ",f&&(r+=" if ("+P+") { ")}else b=y.$async===!0||e.async&&y.$async!==!1,c=y.code}if(c){var v=v||[];v.push(r),r="",e.opts.passContext?r+=" "+c+".call(this, ":r+=" "+c+"( ",r+=" "+p+", (dataPath || '')",e.errorPath!='""'&&(r+=" + "+e.errorPath);var D=l?"data"+(l-1||""):"parentData",I=l?e.dataPathArr[l]:"parentDataProperty";r+=" , "+D+" , "+I+", rootData) ";var z=r;if(r=v.pop(),b){if(!e.async)throw new Error("async schema referenced by sync schema");f&&(r+=" var "+m+"; "),r+=" try { await "+z+"; ",f&&(r+=" "+m+" = true; "),r+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",f&&(r+=" "+m+" = false; "),r+=" } ",f&&(r+=" if ("+m+") { ")}else r+=" if (!"+z+") { if (vErrors === null) vErrors = "+c+".errors; else vErrors = vErrors.concat("+c+".errors); errors = vErrors.length; } ",f&&(r+=" else { ")}return r}});var li=W((Xp,oi)=>{"use strict";oi.exports=function(e,t,s){var r=" ",n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),o=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,f=e.util.copy(e),p="";f.level++;var m="valid"+f.level,b=f.baseId,c=!0,y=n;if(y)for(var _,v=-1,x=y.length-1;v0||_===!1:e.util.schemaHasRules(_,e.RULES.all))&&(c=!1,f.schema=_,f.schemaPath=l+"["+v+"]",f.errSchemaPath=o+"/"+v,r+=" "+e.validate(f)+" ",f.baseId=b,u&&(r+=" if ("+m+") { ",p+="}"));return u&&(c?r+=" if (true) { ":r+=" "+p.slice(0,-1)+" "),r}});var ui=W((eh,ci)=>{"use strict";ci.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c="errs__"+n,y=e.util.copy(e),_="";y.level++;var v="valid"+y.level,x=o.every(function(q){return e.opts.strictKeywords?typeof q=="object"&&Object.keys(q).length>0||q===!1:e.util.schemaHasRules(q,e.RULES.all)});if(x){var T=y.baseId;r+=" var "+c+" = errors; var "+b+" = false; ";var P=e.compositeRule;e.compositeRule=y.compositeRule=!0;var O=o;if(O)for(var D,I=-1,z=O.length-1;I{"use strict";di.exports=function(e,t,s){var r=" ",n=e.schema[t],l=e.errSchemaPath+"/"+t,o=!e.opts.allErrors,u=e.util.toQuotedString(n);return e.opts.$comment===!0?r+=" console.log("+u+");":typeof e.opts.$comment=="function"&&(r+=" self._opts.$comment("+u+", "+e.util.toQuotedString(l)+", validate.root.schema);"),r}});var hi=W((th,pi)=>{"use strict";pi.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c=e.opts.$data&&o&&o.$data,y;c?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",y="schema"+n):y=o,c||(r+=" var schema"+n+" = validate.schema"+u+";"),r+="var "+b+" = equal("+m+", schema"+n+"); if (!"+b+") { ";var _=_||[];_.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { allowedValue: schema"+n+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be equal to constant' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var v=r;return r=_.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+v+"]); ":r+=" validate.errors = ["+v+"]; return false; ":r+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" }",p&&(r+=" else { "),r}});var vi=W((ah,mi)=>{"use strict";mi.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c="errs__"+n,y=e.util.copy(e),_="";y.level++;var v="valid"+y.level,x="i"+n,T=y.dataLevel=e.dataLevel+1,P="data"+T,O=e.baseId,D=e.opts.strictKeywords?typeof o=="object"&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all);if(r+="var "+c+" = errors;var "+b+";",D){var I=e.compositeRule;e.compositeRule=y.compositeRule=!0,y.schema=o,y.schemaPath=u,y.errSchemaPath=f,r+=" var "+v+" = false; for (var "+x+" = 0; "+x+" < "+m+".length; "+x+"++) { ",y.errorPath=e.util.getPathExpr(e.errorPath,x,e.opts.jsonPointers,!0);var z=m+"["+x+"]";y.dataPathArr[T]=x;var q=e.validate(y);y.baseId=O,e.util.varOccurences(q,P)<2?r+=" "+e.util.varReplace(q,P,z)+" ":r+=" var "+P+" = "+z+"; "+q+" ",r+=" if ("+v+") break; } ",e.compositeRule=y.compositeRule=I,r+=" "+_+" if (!"+v+") {"}else r+=" if ("+m+".length == 0) {";var k=k||[];k.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should contain a valid item' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var U=r;return r=k.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+U+"]); ":r+=" validate.errors = ["+U+"]; return false; ":r+=" var err = "+U+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { ",D&&(r+=" errors = "+c+"; if (vErrors !== null) { if ("+c+") vErrors.length = "+c+"; else vErrors = null; } "),e.opts.allErrors&&(r+=" } "),r}});var yi=W((sh,gi)=>{"use strict";gi.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="errs__"+n,c=e.util.copy(e),y="";c.level++;var _="valid"+c.level,v={},x={},T=e.opts.ownProperties;for(I in o)if(I!="__proto__"){var P=o[I],O=Array.isArray(P)?x:v;O[I]=P}r+="var "+b+" = errors;";var D=e.errorPath;r+="var missing"+n+";";for(var I in x)if(O=x[I],O.length){if(r+=" if ( "+m+e.util.getProperty(I)+" !== undefined ",T&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(I)+"') "),p){r+=" && ( ";var z=O;if(z)for(var q,k=-1,U=z.length-1;k0||P===!1:e.util.schemaHasRules(P,e.RULES.all))&&(r+=" "+_+" = true; if ( "+m+e.util.getProperty(I)+" !== undefined ",T&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(I)+"') "),r+=") { ",c.schema=P,c.schemaPath=u+e.util.getProperty(I),c.errSchemaPath=f+"/"+e.util.escapeFragment(I),r+=" "+e.validate(c)+" ",c.baseId=H,r+=" } ",p&&(r+=" if ("+_+") { ",y+="}"))}return p&&(r+=" "+y+" if ("+b+" == errors) {"),r}});var bi=W((nh,_i)=>{"use strict";_i.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c=e.opts.$data&&o&&o.$data,y;c?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",y="schema"+n):y=o;var _="i"+n,v="schema"+n;c||(r+=" var "+v+" = validate.schema"+u+";"),r+="var "+b+";",c&&(r+=" if (schema"+n+" === undefined) "+b+" = true; else if (!Array.isArray(schema"+n+")) "+b+" = false; else {"),r+=""+b+" = false;for (var "+_+"=0; "+_+"<"+v+".length; "+_+"++) if (equal("+m+", "+v+"["+_+"])) { "+b+" = true; break; }",c&&(r+=" } "),r+=" if (!"+b+") { ";var x=x||[];x.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { allowedValues: schema"+n+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var T=r;return r=x.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+T+"]); ":r+=" validate.errors = ["+T+"]; return false; ":r+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" }",p&&(r+=" else { "),r}});var Si=W((ih,Ei)=>{"use strict";Ei.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||"");if(e.opts.format===!1)return p&&(r+=" if (true) { "),r;var b=e.opts.$data&&o&&o.$data,c;b?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=o;var y=e.opts.unknownFormats,_=Array.isArray(y);if(b){var v="format"+n,x="isObject"+n,T="formatType"+n;r+=" var "+v+" = formats["+c+"]; var "+x+" = typeof "+v+" == 'object' && !("+v+" instanceof RegExp) && "+v+".validate; var "+T+" = "+x+" && "+v+".type || 'string'; if ("+x+") { ",e.async&&(r+=" var async"+n+" = "+v+".async; "),r+=" "+v+" = "+v+".validate; } if ( ",b&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'string') || "),r+=" (",y!="ignore"&&(r+=" ("+c+" && !"+v+" ",_&&(r+=" && self._opts.unknownFormats.indexOf("+c+") == -1 "),r+=") || "),r+=" ("+v+" && "+T+" == '"+s+"' && !(typeof "+v+" == 'function' ? ",e.async?r+=" (async"+n+" ? await "+v+"("+m+") : "+v+"("+m+")) ":r+=" "+v+"("+m+") ",r+=" : "+v+".test("+m+"))))) {"}else{var v=e.formats[o];if(!v){if(y=="ignore")return e.logger.warn('unknown format "'+o+'" ignored in schema at path "'+e.errSchemaPath+'"'),p&&(r+=" if (true) { "),r;if(_&&y.indexOf(o)>=0)return p&&(r+=" if (true) { "),r;throw new Error('unknown format "'+o+'" is used in schema at path "'+e.errSchemaPath+'"')}var x=typeof v=="object"&&!(v instanceof RegExp)&&v.validate,T=x&&v.type||"string";if(x){var P=v.async===!0;v=v.validate}if(T!=s)return p&&(r+=" if (true) { "),r;if(P){if(!e.async)throw new Error("async format in sync schema");var O="formats"+e.util.getProperty(o)+".validate";r+=" if (!(await "+O+"("+m+"))) { "}else{r+=" if (! ";var O="formats"+e.util.getProperty(o);x&&(O+=".validate"),typeof v=="function"?r+=" "+O+"("+m+") ":r+=" "+O+".test("+m+") ",r+=") { "}}var D=D||[];D.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { format: ",b?r+=""+c:r+=""+e.util.toQuotedString(o),r+=" } ",e.opts.messages!==!1&&(r+=` , message: 'should match format "`,b?r+="' + "+c+" + '":r+=""+e.util.escapeQuotes(o),r+=`"' `),e.opts.verbose&&(r+=" , schema: ",b?r+="validate.schema"+u:r+=""+e.util.toQuotedString(o),r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var I=r;return r=D.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+I+"]); ":r+=" validate.errors = ["+I+"]; return false; ":r+=" var err = "+I+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",p&&(r+=" else { "),r}});var Pi=W((oh,xi)=>{"use strict";xi.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c="errs__"+n,y=e.util.copy(e);y.level++;var _="valid"+y.level,v=e.schema.then,x=e.schema.else,T=v!==void 0&&(e.opts.strictKeywords?typeof v=="object"&&Object.keys(v).length>0||v===!1:e.util.schemaHasRules(v,e.RULES.all)),P=x!==void 0&&(e.opts.strictKeywords?typeof x=="object"&&Object.keys(x).length>0||x===!1:e.util.schemaHasRules(x,e.RULES.all)),O=y.baseId;if(T||P){var D;y.createErrors=!1,y.schema=o,y.schemaPath=u,y.errSchemaPath=f,r+=" var "+c+" = errors; var "+b+" = true; ";var I=e.compositeRule;e.compositeRule=y.compositeRule=!0,r+=" "+e.validate(y)+" ",y.baseId=O,y.createErrors=!0,r+=" errors = "+c+"; if (vErrors !== null) { if ("+c+") vErrors.length = "+c+"; else vErrors = null; } ",e.compositeRule=y.compositeRule=I,T?(r+=" if ("+_+") { ",y.schema=e.schema.then,y.schemaPath=e.schemaPath+".then",y.errSchemaPath=e.errSchemaPath+"/then",r+=" "+e.validate(y)+" ",y.baseId=O,r+=" "+b+" = "+_+"; ",T&&P?(D="ifClause"+n,r+=" var "+D+" = 'then'; "):D="'then'",r+=" } ",P&&(r+=" else { ")):r+=" if (!"+_+") { ",P&&(y.schema=e.schema.else,y.schemaPath=e.schemaPath+".else",y.errSchemaPath=e.errSchemaPath+"/else",r+=" "+e.validate(y)+" ",y.baseId=O,r+=" "+b+" = "+_+"; ",T&&P?(D="ifClause"+n,r+=" var "+D+" = 'else'; "):D="'else'",r+=" } "),r+=" if (!"+b+") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { failingKeyword: "+D+" } ",e.opts.messages!==!1&&(r+=` , message: 'should match "' + `+D+` + '" schema' `),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?r+=" throw new ValidationError(vErrors); ":r+=" validate.errors = vErrors; return false; "),r+=" } ",p&&(r+=" else { ")}else p&&(r+=" if (true) { ");return r}});var Oi=W((lh,wi)=>{"use strict";wi.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c="errs__"+n,y=e.util.copy(e),_="";y.level++;var v="valid"+y.level,x="i"+n,T=y.dataLevel=e.dataLevel+1,P="data"+T,O=e.baseId;if(r+="var "+c+" = errors;var "+b+";",Array.isArray(o)){var D=e.schema.additionalItems;if(D===!1){r+=" "+b+" = "+m+".length <= "+o.length+"; ";var I=f;f=e.errSchemaPath+"/additionalItems",r+=" if (!"+b+") { ";var z=z||[];z.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { limit: "+o.length+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have more than "+o.length+" items' "),e.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var q=r;r=z.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+q+"]); ":r+=" validate.errors = ["+q+"]; return false; ":r+=" var err = "+q+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",f=I,p&&(_+="}",r+=" else { ")}var k=o;if(k){for(var U,L=-1,M=k.length-1;L0||U===!1:e.util.schemaHasRules(U,e.RULES.all)){r+=" "+v+" = true; if ("+m+".length > "+L+") { ";var A=m+"["+L+"]";y.schema=U,y.schemaPath=u+"["+L+"]",y.errSchemaPath=f+"/"+L,y.errorPath=e.util.getPathExpr(e.errorPath,L,e.opts.jsonPointers,!0),y.dataPathArr[T]=L;var $=e.validate(y);y.baseId=O,e.util.varOccurences($,P)<2?r+=" "+e.util.varReplace($,P,A)+" ":r+=" var "+P+" = "+A+"; "+$+" ",r+=" } ",p&&(r+=" if ("+v+") { ",_+="}")}}if(typeof D=="object"&&(e.opts.strictKeywords?typeof D=="object"&&Object.keys(D).length>0||D===!1:e.util.schemaHasRules(D,e.RULES.all))){y.schema=D,y.schemaPath=e.schemaPath+".additionalItems",y.errSchemaPath=e.errSchemaPath+"/additionalItems",r+=" "+v+" = true; if ("+m+".length > "+o.length+") { for (var "+x+" = "+o.length+"; "+x+" < "+m+".length; "+x+"++) { ",y.errorPath=e.util.getPathExpr(e.errorPath,x,e.opts.jsonPointers,!0);var A=m+"["+x+"]";y.dataPathArr[T]=x;var $=e.validate(y);y.baseId=O,e.util.varOccurences($,P)<2?r+=" "+e.util.varReplace($,P,A)+" ":r+=" var "+P+" = "+A+"; "+$+" ",p&&(r+=" if (!"+v+") break; "),r+=" } } ",p&&(r+=" if ("+v+") { ",_+="}")}}else if(e.opts.strictKeywords?typeof o=="object"&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all)){y.schema=o,y.schemaPath=u,y.errSchemaPath=f,r+=" for (var "+x+" = 0; "+x+" < "+m+".length; "+x+"++) { ",y.errorPath=e.util.getPathExpr(e.errorPath,x,e.opts.jsonPointers,!0);var A=m+"["+x+"]";y.dataPathArr[T]=x;var $=e.validate(y);y.baseId=O,e.util.varOccurences($,P)<2?r+=" "+e.util.varReplace($,P,A)+" ":r+=" var "+P+" = "+A+"; "+$+" ",p&&(r+=" if (!"+v+") break; "),r+=" }"}return p&&(r+=" "+_+" if ("+c+" == errors) {"),r}});var ds=W((ch,Ri)=>{"use strict";Ri.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,O,m="data"+(l||""),b=e.opts.$data&&o&&o.$data,c;b?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=o;var y=t=="maximum",_=y?"exclusiveMaximum":"exclusiveMinimum",v=e.schema[_],x=e.opts.$data&&v&&v.$data,T=y?"<":">",P=y?">":"<",O=void 0;if(!(b||typeof o=="number"||o===void 0))throw new Error(t+" must be number");if(!(x||v===void 0||typeof v=="number"||typeof v=="boolean"))throw new Error(_+" must be number or boolean");if(x){var D=e.util.getData(v.$data,l,e.dataPathArr),I="exclusive"+n,z="exclType"+n,q="exclIsNumber"+n,k="op"+n,U="' + "+k+" + '";r+=" var schemaExcl"+n+" = "+D+"; ",D="schemaExcl"+n,r+=" var "+I+"; var "+z+" = typeof "+D+"; if ("+z+" != 'boolean' && "+z+" != 'undefined' && "+z+" != 'number') { ";var O=_,L=L||[];L.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(O||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: '"+_+" should be boolean' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var M=r;r=L.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+M+"]); ":r+=" validate.errors = ["+M+"]; return false; ":r+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else if ( ",b&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" "+z+" == 'number' ? ( ("+I+" = "+c+" === undefined || "+D+" "+T+"= "+c+") ? "+m+" "+P+"= "+D+" : "+m+" "+P+" "+c+" ) : ( ("+I+" = "+D+" === true) ? "+m+" "+P+"= "+c+" : "+m+" "+P+" "+c+" ) || "+m+" !== "+m+") { var op"+n+" = "+I+" ? '"+T+"' : '"+T+"='; ",o===void 0&&(O=_,f=e.errSchemaPath+"/"+_,c=D,b=x)}else{var q=typeof v=="number",U=T;if(q&&b){var k="'"+U+"'";r+=" if ( ",b&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" ( "+c+" === undefined || "+v+" "+T+"= "+c+" ? "+m+" "+P+"= "+v+" : "+m+" "+P+" "+c+" ) || "+m+" !== "+m+") { "}else{q&&o===void 0?(I=!0,O=_,f=e.errSchemaPath+"/"+_,c=v,P+="="):(q&&(c=Math[y?"min":"max"](v,o)),v===(q?c:!0)?(I=!0,O=_,f=e.errSchemaPath+"/"+_,P+="="):(I=!1,U+="="));var k="'"+U+"'";r+=" if ( ",b&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" "+m+" "+P+" "+c+" || "+m+" !== "+m+") { "}}O=O||t;var L=L||[];L.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(O||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { comparison: "+k+", limit: "+c+", exclusive: "+I+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be "+U+" ",b?r+="' + "+c:r+=""+c+"'"),e.opts.verbose&&(r+=" , schema: ",b?r+="validate.schema"+u:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var M=r;return r=L.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+M+"]); ":r+=" validate.errors = ["+M+"]; return false; ":r+=" var err = "+M+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",p&&(r+=" else { "),r}});var fs=W((uh,Ti)=>{"use strict";Ti.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(l||""),b=e.opts.$data&&o&&o.$data,c;if(b?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=o,!(b||typeof o=="number"))throw new Error(t+" must be number");var y=t=="maxItems"?">":"<";r+="if ( ",b&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" "+m+".length "+y+" "+c+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { limit: "+c+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have ",t=="maxItems"?r+="more":r+="fewer",r+=" than ",b?r+="' + "+c+" + '":r+=""+o,r+=" items' "),e.opts.verbose&&(r+=" , schema: ",b?r+="validate.schema"+u:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var x=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+x+"]); ":r+=" validate.errors = ["+x+"]; return false; ":r+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var ps=W((dh,Ai)=>{"use strict";Ai.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(l||""),b=e.opts.$data&&o&&o.$data,c;if(b?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=o,!(b||typeof o=="number"))throw new Error(t+" must be number");var y=t=="maxLength"?">":"<";r+="if ( ",b&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),e.opts.unicode===!1?r+=" "+m+".length ":r+=" ucs2length("+m+") ",r+=" "+y+" "+c+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { limit: "+c+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be ",t=="maxLength"?r+="longer":r+="shorter",r+=" than ",b?r+="' + "+c+" + '":r+=""+o,r+=" characters' "),e.opts.verbose&&(r+=" , schema: ",b?r+="validate.schema"+u:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var x=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+x+"]); ":r+=" validate.errors = ["+x+"]; return false; ":r+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var hs=W((fh,Di)=>{"use strict";Di.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(l||""),b=e.opts.$data&&o&&o.$data,c;if(b?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=o,!(b||typeof o=="number"))throw new Error(t+" must be number");var y=t=="maxProperties"?">":"<";r+="if ( ",b&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" Object.keys("+m+").length "+y+" "+c+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { limit: "+c+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have ",t=="maxProperties"?r+="more":r+="fewer",r+=" than ",b?r+="' + "+c+" + '":r+=""+o,r+=" properties' "),e.opts.verbose&&(r+=" , schema: ",b?r+="validate.schema"+u:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var x=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+x+"]); ":r+=" validate.errors = ["+x+"]; return false; ":r+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var ki=W((ph,Ii)=>{"use strict";Ii.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b=e.opts.$data&&o&&o.$data,c;if(b?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=o,!(b||typeof o=="number"))throw new Error(t+" must be number");r+="var division"+n+";if (",b&&(r+=" "+c+" !== undefined && ( typeof "+c+" != 'number' || "),r+=" (division"+n+" = "+m+" / "+c+", ",e.opts.multipleOfPrecision?r+=" Math.abs(Math.round(division"+n+") - division"+n+") > 1e-"+e.opts.multipleOfPrecision+" ":r+=" division"+n+" !== parseInt(division"+n+") ",r+=" ) ",b&&(r+=" ) "),r+=" ) { ";var y=y||[];y.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { multipleOf: "+c+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be multiple of ",b?r+="' + "+c:r+=""+c+"'"),e.opts.verbose&&(r+=" , schema: ",b?r+="validate.schema"+u:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var _=r;return r=y.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+_+"]); ":r+=" validate.errors = ["+_+"]; return false; ":r+=" var err = "+_+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var Ci=W((hh,$i)=>{"use strict";$i.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="errs__"+n,c=e.util.copy(e);c.level++;var y="valid"+c.level;if(e.opts.strictKeywords?typeof o=="object"&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all)){c.schema=o,c.schemaPath=u,c.errSchemaPath=f,r+=" var "+b+" = errors; ";var _=e.compositeRule;e.compositeRule=c.compositeRule=!0,c.createErrors=!1;var v;c.opts.allErrors&&(v=c.opts.allErrors,c.opts.allErrors=!1),r+=" "+e.validate(c)+" ",c.createErrors=!0,v&&(c.opts.allErrors=v),e.compositeRule=c.compositeRule=_,r+=" if ("+y+") { ";var x=x||[];x.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be valid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var T=r;r=x.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+T+"]); ":r+=" validate.errors = ["+T+"]; return false; ":r+=" var err = "+T+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { errors = "+b+"; if (vErrors !== null) { if ("+b+") vErrors.length = "+b+"; else vErrors = null; } ",e.opts.allErrors&&(r+=" } ")}else r+=" var err = ",e.createErrors!==!1?(r+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be valid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",p&&(r+=" if (false) { ");return r}});var ji=W((mh,Ni)=>{"use strict";Ni.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c="errs__"+n,y=e.util.copy(e),_="";y.level++;var v="valid"+y.level,x=y.baseId,T="prevValid"+n,P="passingSchemas"+n;r+="var "+c+" = errors , "+T+" = false , "+b+" = false , "+P+" = null; ";var O=e.compositeRule;e.compositeRule=y.compositeRule=!0;var D=o;if(D)for(var I,z=-1,q=D.length-1;z0||I===!1:e.util.schemaHasRules(I,e.RULES.all))?(y.schema=I,y.schemaPath=u+"["+z+"]",y.errSchemaPath=f+"/"+z,r+=" "+e.validate(y)+" ",y.baseId=x):r+=" var "+v+" = true; ",z&&(r+=" if ("+v+" && "+T+") { "+b+" = false; "+P+" = ["+P+", "+z+"]; } else { ",_+="}"),r+=" if ("+v+") { "+b+" = "+T+" = true; "+P+" = "+z+"; }";return e.compositeRule=y.compositeRule=O,r+=""+_+"if (!"+b+") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { passingSchemas: "+P+" } ",e.opts.messages!==!1&&(r+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?r+=" throw new ValidationError(vErrors); ":r+=" validate.errors = vErrors; return false; "),r+="} else { errors = "+c+"; if (vErrors !== null) { if ("+c+") vErrors.length = "+c+"; else vErrors = null; }",e.opts.allErrors&&(r+=" } "),r}});var Fi=W((vh,Mi)=>{"use strict";Mi.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b=e.opts.$data&&o&&o.$data,c;b?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=o;var y=b?"(new RegExp("+c+"))":e.usePattern(o);r+="if ( ",b&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'string') || "),r+=" !"+y+".test("+m+") ) { ";var _=_||[];_.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { pattern: ",b?r+=""+c:r+=""+e.util.toQuotedString(o),r+=" } ",e.opts.messages!==!1&&(r+=` , message: 'should match pattern "`,b?r+="' + "+c+" + '":r+=""+e.util.escapeQuotes(o),r+=`"' `),e.opts.verbose&&(r+=" , schema: ",b?r+="validate.schema"+u:r+=""+e.util.toQuotedString(o),r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var v=r;return r=_.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+v+"]); ":r+=" validate.errors = ["+v+"]; return false; ":r+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var qi=W((gh,Li)=>{"use strict";Li.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="errs__"+n,c=e.util.copy(e),y="";c.level++;var _="valid"+c.level,v="key"+n,x="idx"+n,T=c.dataLevel=e.dataLevel+1,P="data"+T,O="dataProperties"+n,D=Object.keys(o||{}).filter(re),I=e.schema.patternProperties||{},z=Object.keys(I).filter(re),q=e.schema.additionalProperties,k=D.length||z.length,U=q===!1,L=typeof q=="object"&&Object.keys(q).length,M=e.opts.removeAdditional,A=U||L||M,$=e.opts.ownProperties,F=e.baseId,le=e.schema.required;if(le&&!(e.opts.$data&&le.$data)&&le.length8)r+=" || validate.schema"+u+".hasOwnProperty("+v+") ";else{var G=D;if(G)for(var H,me=-1,Oe=G.length-1;me0||xe===!1:e.util.schemaHasRules(xe,e.RULES.all)){var ze=e.util.getProperty(H),Re=m+ze,je=Sr&&xe.default!==void 0;c.schema=xe,c.schemaPath=u+ze,c.errSchemaPath=f+"/"+e.util.escapeFragment(H),c.errorPath=e.util.getPath(e.errorPath,H,e.opts.jsonPointers),c.dataPathArr[T]=e.util.toQuotedString(H);var ie=e.validate(c);if(c.baseId=F,e.util.varOccurences(ie,P)<2){ie=e.util.varReplace(ie,P,Re);var Ie=Re}else{var Ie=P;r+=" var "+P+" = "+Re+"; "}if(je)r+=" "+ie+" ";else{if(Y&&Y[H]){r+=" if ( "+Ie+" === undefined ",$&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=") { "+_+" = false; ";var De=e.errorPath,fr=f,sr=e.util.escapeQuotes(H);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(De,H,e.opts.jsonPointers)),f=e.errSchemaPath+"/required";var _e=_e||[];_e.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { missingProperty: '"+sr+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+sr+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var ve=r;r=_e.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+ve+"]); ":r+=" validate.errors = ["+ve+"]; return false; ":r+=" var err = "+ve+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f=fr,e.errorPath=De,r+=" } else { "}else p?(r+=" if ( "+Ie+" === undefined ",$&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=") { "+_+" = true; } else { "):(r+=" if ("+Ie+" !== undefined ",$&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=" ) { ");r+=" "+ie+" } "}}p&&(r+=" if ("+_+") { ",y+="}")}}if(z.length){var qe=z;if(qe)for(var se,Nt=-1,Oa=qe.length-1;Nt0||xe===!1:e.util.schemaHasRules(xe,e.RULES.all)){c.schema=xe,c.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(se),c.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(se),$?r+=" "+O+" = "+O+" || Object.keys("+m+"); for (var "+x+"=0; "+x+"<"+O+".length; "+x+"++) { var "+v+" = "+O+"["+x+"]; ":r+=" for (var "+v+" in "+m+") { ",r+=" if ("+e.usePattern(se)+".test("+v+")) { ",c.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers);var Re=m+"["+v+"]";c.dataPathArr[T]=v;var ie=e.validate(c);c.baseId=F,e.util.varOccurences(ie,P)<2?r+=" "+e.util.varReplace(ie,P,Re)+" ":r+=" var "+P+" = "+Re+"; "+ie+" ",p&&(r+=" if (!"+_+") break; "),r+=" } ",p&&(r+=" else "+_+" = true; "),r+=" } ",p&&(r+=" if ("+_+") { ",y+="}")}}}return p&&(r+=" "+y+" if ("+b+" == errors) {"),r}});var Vi=W((yh,Ui)=>{"use strict";Ui.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="errs__"+n,c=e.util.copy(e),y="";c.level++;var _="valid"+c.level;if(r+="var "+b+" = errors;",e.opts.strictKeywords?typeof o=="object"&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all)){c.schema=o,c.schemaPath=u,c.errSchemaPath=f;var v="key"+n,x="idx"+n,T="i"+n,P="' + "+v+" + '",O=c.dataLevel=e.dataLevel+1,D="data"+O,I="dataProperties"+n,z=e.opts.ownProperties,q=e.baseId;z&&(r+=" var "+I+" = undefined; "),z?r+=" "+I+" = "+I+" || Object.keys("+m+"); for (var "+x+"=0; "+x+"<"+I+".length; "+x+"++) { var "+v+" = "+I+"["+x+"]; ":r+=" for (var "+v+" in "+m+") { ",r+=" var startErrs"+n+" = errors; ";var k=v,U=e.compositeRule;e.compositeRule=c.compositeRule=!0;var L=e.validate(c);c.baseId=q,e.util.varOccurences(L,D)<2?r+=" "+e.util.varReplace(L,D,k)+" ":r+=" var "+D+" = "+k+"; "+L+" ",e.compositeRule=c.compositeRule=U,r+=" if (!"+_+") { for (var "+T+"=startErrs"+n+"; "+T+"{"use strict";zi.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c=e.opts.$data&&o&&o.$data,y;c?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",y="schema"+n):y=o;var _="schema"+n;if(!c)if(o.length0||D===!1:e.util.schemaHasRules(D,e.RULES.all))||(v[v.length]=T)}}else var v=o;if(c||v.length){var I=e.errorPath,z=c||v.length>=e.opts.loopRequired,q=e.opts.ownProperties;if(p)if(r+=" var missing"+n+"; ",z){c||(r+=" var "+_+" = validate.schema"+u+"; ");var k="i"+n,U="schema"+n+"["+k+"]",L="' + "+U+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(I,U,e.opts.jsonPointers)),r+=" var "+b+" = true; ",c&&(r+=" if (schema"+n+" === undefined) "+b+" = true; else if (!Array.isArray(schema"+n+")) "+b+" = false; else {"),r+=" for (var "+k+" = 0; "+k+" < "+_+".length; "+k+"++) { "+b+" = "+m+"["+_+"["+k+"]] !== undefined ",q&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", "+_+"["+k+"]) "),r+="; if (!"+b+") break; } ",c&&(r+=" } "),r+=" if (!"+b+") { ";var M=M||[];M.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { missingProperty: '"+L+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+L+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var A=r;r=M.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+A+"]); ":r+=" validate.errors = ["+A+"]; return false; ":r+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { "}else{r+=" if ( ";var $=v;if($)for(var F,k=-1,le=$.length-1;k{"use strict";Zi.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),b="valid"+n,c=e.opts.$data&&o&&o.$data,y;if(c?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",y="schema"+n):y=o,(o||c)&&e.opts.uniqueItems!==!1){c&&(r+=" var "+b+"; if ("+y+" === false || "+y+" === undefined) "+b+" = true; else if (typeof "+y+" != 'boolean') "+b+" = false; else { "),r+=" var i = "+m+".length , "+b+" = true , j; if (i > 1) { ";var _=e.schema.items&&e.schema.items.type,v=Array.isArray(_);if(!_||_=="object"||_=="array"||v&&(_.indexOf("object")>=0||_.indexOf("array")>=0))r+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+m+"[i], "+m+"[j])) { "+b+" = false; break outer; } } } ";else{r+=" var itemIndices = {}, item; for (;i--;) { var item = "+m+"[i]; ";var x="checkDataType"+(v?"s":"");r+=" if ("+e.util[x](_,"item",e.opts.strictNumbers,!0)+") continue; ",v&&(r+=` if (typeof item == 'string') item = '"' + item; `),r+=" if (typeof itemIndices[item] == 'number') { "+b+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}r+=" } ",c&&(r+=" } "),r+=" if (!"+b+") { ";var T=T||[];T.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { i: i, j: j } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(r+=" , schema: ",c?r+="validate.schema"+u:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var P=r;r=T.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+P+"]); ":r+=" validate.errors = ["+P+"]; return false; ":r+=" var err = "+P+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",p&&(r+=" else { ")}else p&&(r+=" if (true) { ");return r}});var Ki=W((Eh,Wi)=>{"use strict";Wi.exports={$ref:ii(),allOf:li(),anyOf:ui(),$comment:fi(),const:hi(),contains:vi(),dependencies:yi(),enum:bi(),format:Si(),if:Pi(),items:Oi(),maximum:ds(),minimum:ds(),maxItems:fs(),minItems:fs(),maxLength:ps(),minLength:ps(),maxProperties:hs(),minProperties:hs(),multipleOf:ki(),not:Ci(),oneOf:ji(),pattern:Fi(),properties:qi(),propertyNames:Vi(),required:Hi(),uniqueItems:Bi(),validate:cs()}});var Gi=W((Sh,Ji)=>{"use strict";var Qi=Ki(),ms=Yr().toHash;Ji.exports=function(){var e=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],t=["type","$comment"],s=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],r=["number","integer","string","array","object","boolean","null"];return e.all=ms(t),e.types=ms(r),e.forEach(function(n){n.rules=n.rules.map(function(l){var o;if(typeof l=="object"){var u=Object.keys(l)[0];o=l[u],l=u,o.forEach(function(p){t.push(p),e.all[p]=!0})}t.push(l);var f=e.all[l]={keyword:l,code:Qi[l],implements:o};return f}),e.all.$comment={keyword:"$comment",code:Qi.$comment},n.type&&(e.types[n.type]=n)}),e.keywords=ms(t.concat(s)),e.custom={},e}});var eo=W((xh,Xi)=>{"use strict";var Yi=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"];Xi.exports=function(a,e){for(var t=0;t{"use strict";var Zd=la().MissingRef;to.exports=ro;function ro(a,e,t){var s=this;if(typeof this._opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");typeof e=="function"&&(t=e,e=void 0);var r=n(a).then(function(){var o=s._addSchema(a,void 0,e);return o.validate||l(o)});return t&&r.then(function(o){t(null,o)},t),r;function n(o){var u=o.$schema;return u&&!s.getSchema(u)?ro.call(s,{$ref:u},!0):Promise.resolve()}function l(o){try{return s._compile(o)}catch(f){if(f instanceof Zd)return u(f);throw f}function u(f){var p=f.missingSchema;if(c(p))throw new Error("Schema "+p+" is loaded but "+f.missingRef+" cannot be resolved");var m=s._loadingSchemas[p];return m||(m=s._loadingSchemas[p]=s._opts.loadSchema(p),m.then(b,b)),m.then(function(y){if(!c(p))return n(y).then(function(){c(p)||s.addSchema(y,p,void 0,e)})}).then(function(){return l(o)});function b(){delete s._loadingSchemas[p]}function c(y){return s._refs[y]||s._schemas[y]}}}}});var no=W((wh,so)=>{"use strict";so.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,o=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m,b="data"+(l||""),c="valid"+n,y="errs__"+n,_=e.opts.$data&&o&&o.$data,v;_?(r+=" var schema"+n+" = "+e.util.getData(o.$data,l,e.dataPathArr)+"; ",v="schema"+n):v=o;var x=this,T="definition"+n,P=x.definition,O="",D,I,z,q,k;if(_&&P.$data){k="keywordValidate"+n;var U=P.validateSchema;r+=" var "+T+" = RULES.custom['"+t+"'].definition; var "+k+" = "+T+".validate;"}else{if(q=e.useCustomRule(x,o,e.schema,e),!q)return;v="validate.schema"+u,k=q.code,D=P.compile,I=P.inline,z=P.macro}var L=k+".errors",M="i"+n,A="ruleErr"+n,$=P.async;if($&&!e.async)throw new Error("async keyword in sync schema");if(I||z||(r+=""+L+" = null;"),r+="var "+y+" = errors;var "+c+";",_&&P.$data&&(O+="}",r+=" if ("+v+" === undefined) { "+c+" = true; } else { ",U&&(O+="}",r+=" "+c+" = "+T+".validateSchema("+v+"); if ("+c+") { ")),I)P.statements?r+=" "+q.validate+" ":r+=" "+c+" = "+q.validate+"; ";else if(z){var F=e.util.copy(e),O="";F.level++;var le="valid"+F.level;F.schema=q.validate,F.schemaPath="";var Y=e.compositeRule;e.compositeRule=F.compositeRule=!0;var re=e.validate(F).replace(/validate\.schema/g,k);e.compositeRule=F.compositeRule=Y,r+=" "+re}else{var G=G||[];G.push(r),r="",r+=" "+k+".call( ",e.opts.passContext?r+="this":r+="self",D||P.schema===!1?r+=" , "+b+" ":r+=" , "+v+" , "+b+" , validate.schema"+e.schemaPath+" ",r+=" , (dataPath || '')",e.errorPath!='""'&&(r+=" + "+e.errorPath);var H=l?"data"+(l-1||""):"parentData",me=l?e.dataPathArr[l]:"parentDataProperty";r+=" , "+H+" , "+me+" , rootData ) ";var Oe=r;r=G.pop(),P.errors===!1?(r+=" "+c+" = ",$&&(r+="await "),r+=""+Oe+"; "):$?(L="customErrors"+n,r+=" var "+L+" = null; try { "+c+" = await "+Oe+"; } catch (e) { "+c+" = false; if (e instanceof ValidationError) "+L+" = e.errors; else throw e; } "):r+=" "+L+" = null; "+c+" = "+Oe+"; "}if(P.modifying&&(r+=" if ("+H+") "+b+" = "+H+"["+me+"];"),r+=""+O,P.valid)p&&(r+=" if (true) { ");else{r+=" if ( ",P.valid===void 0?(r+=" !",z?r+=""+le:r+=""+c):r+=" "+!P.valid+" ",r+=") { ",m=x.keyword;var G=G||[];G.push(r),r="";var G=G||[];G.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(m||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { keyword: '"+x.keyword+"' } ",e.opts.messages!==!1&&(r+=` , message: 'should pass "`+x.keyword+`" keyword validation' `),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+b+" "),r+=" } "):r+=" {} ";var Ae=r;r=G.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+Ae+"]); ":r+=" validate.errors = ["+Ae+"]; return false; ":r+=" var err = "+Ae+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var se=r;r=G.pop(),I?P.errors?P.errors!="full"&&(r+=" for (var "+M+"="+y+"; "+M+"{Bd.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 lo=W((Rh,oo)=>{"use strict";var io=vs();oo.exports={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:io.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:io.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}}});var uo=W((Th,co)=>{"use strict";var Wd=/^[a-z_$][a-z0-9_$-]*$/i,Kd=no(),Qd=lo();co.exports={add:Jd,get:Gd,remove:Yd,validate:gs};function Jd(a,e){var t=this.RULES;if(t.keywords[a])throw new Error("Keyword "+a+" is already defined");if(!Wd.test(a))throw new Error("Keyword "+a+" is not a valid identifier");if(e){this.validateKeyword(e,!0);var s=e.type;if(Array.isArray(s))for(var r=0;r{Xd.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON Schema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var So=W((Dh,Eo)=>{"use strict";var ho=Hn(),Xr=oa(),ef=Bn(),mo=ts(),rf=ls(),tf=si(),af=Gi(),vo=eo(),go=Yr();Eo.exports=ge;ge.prototype.validate=nf;ge.prototype.compile=of;ge.prototype.addSchema=lf;ge.prototype.addMetaSchema=cf;ge.prototype.validateSchema=uf;ge.prototype.getSchema=ff;ge.prototype.removeSchema=hf;ge.prototype.addFormat=Sf;ge.prototype.errorsText=Ef;ge.prototype._addSchema=mf;ge.prototype._compile=vf;ge.prototype.compileAsync=ao();var va=uo();ge.prototype.addKeyword=va.add;ge.prototype.getKeyword=va.get;ge.prototype.removeKeyword=va.remove;ge.prototype.validateKeyword=va.validate;var yo=la();ge.ValidationError=yo.Validation;ge.MissingRefError=yo.MissingRef;ge.$dataMetaSchema=vo;var ma="http://json-schema.org/draft-07/schema",po=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],sf=["/properties"];function ge(a){if(!(this instanceof ge))return new ge(a);a=this._opts=go.copy(a)||{},Tf(this),this._schemas={},this._refs={},this._fragments={},this._formats=tf(a.format),this._cache=a.cache||new ef,this._loadingSchemas={},this._compilations=[],this.RULES=af(),this._getId=gf(a),a.loopRequired=a.loopRequired||1/0,a.errorDataPath=="property"&&(a._errorDataPathProperty=!0),a.serialize===void 0&&(a.serialize=rf),this._metaOpts=Rf(this),a.formats&&wf(this),a.keywords&&Of(this),xf(this),typeof a.meta=="object"&&this.addMetaSchema(a.meta),a.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),Pf(this)}function nf(a,e){var t;if(typeof a=="string"){if(t=this.getSchema(a),!t)throw new Error('no schema with key or ref "'+a+'"')}else{var s=this._addSchema(a);t=s.validate||this._compile(s)}var r=t(e);return t.$async!==!0&&(this.errors=t.errors),r}function of(a,e){var t=this._addSchema(a,void 0,e);return t.validate||this._compile(t)}function lf(a,e,t,s){if(Array.isArray(a)){for(var r=0;rmc,DIRTY:()=>jr,EMPTY_PATH:()=>Wl,INVALID:()=>Z,NEVER:()=>Xc,OK:()=>Te,ParseStatus:()=>Pe,Schema:()=>J,ZodAny:()=>wr,ZodArray:()=>br,ZodBigInt:()=>Fr,ZodBoolean:()=>Lr,ZodBranded:()=>Ot,ZodCatch:()=>Jr,ZodDate:()=>qr,ZodDefault:()=>Qr,ZodDiscriminatedUnion:()=>Ut,ZodEffects:()=>Ke,ZodEnum:()=>Wr,ZodError:()=>Me,ZodFirstPartyTypeKind:()=>R,ZodFunction:()=>zt,ZodIntersection:()=>Hr,ZodIssueCode:()=>w,ZodLazy:()=>Zr,ZodLiteral:()=>Br,ZodMap:()=>ft,ZodNaN:()=>ht,ZodNativeEnum:()=>Kr,ZodNever:()=>Ye,ZodNull:()=>Vr,ZodNullable:()=>cr,ZodNumber:()=>Mr,ZodObject:()=>Fe,ZodOptional:()=>Be,ZodParsedType:()=>N,ZodPipeline:()=>Rt,ZodPromise:()=>Or,ZodReadonly:()=>Gr,ZodRecord:()=>Vt,ZodSchema:()=>J,ZodSet:()=>pt,ZodString:()=>Pr,ZodSymbol:()=>ut,ZodTransformer:()=>Ke,ZodTuple:()=>lr,ZodType:()=>J,ZodUndefined:()=>Ur,ZodUnion:()=>zr,ZodUnknown:()=>_r,ZodVoid:()=>dt,addIssueToContext:()=>C,any:()=>Pc,array:()=>Tc,bigint:()=>_c,boolean:()=>en,coerce:()=>Yc,custom:()=>Gs,date:()=>bc,datetimeRegex:()=>Qs,defaultErrorMap:()=>gr,discriminatedUnion:()=>kc,effect:()=>Hc,enum:()=>Uc,function:()=>Fc,getErrorMap:()=>ot,getParsedType:()=>or,instanceof:()=>gc,intersection:()=>$c,isAborted:()=>Lt,isAsync:()=>lt,isDirty:()=>qt,isValid:()=>xr,late:()=>vc,lazy:()=>Lc,literal:()=>qc,makeIssue:()=>wt,map:()=>jc,nan:()=>yc,nativeEnum:()=>Vc,never:()=>Oc,null:()=>xc,nullable:()=>Bc,number:()=>Xs,object:()=>Ac,objectUtil:()=>ka,oboolean:()=>Gc,onumber:()=>Jc,optional:()=>Zc,ostring:()=>Qc,pipeline:()=>Kc,preprocess:()=>Wc,promise:()=>zc,quotelessJson:()=>Hl,record:()=>Nc,set:()=>Mc,setErrorMap:()=>Bl,strictObject:()=>Dc,string:()=>Ys,symbol:()=>Ec,transformer:()=>Hc,tuple:()=>Cc,undefined:()=>Sc,union:()=>Ic,unknown:()=>wc,util:()=>X,void:()=>Rc});var X;(function(a){a.assertEqual=r=>{};function e(r){}a.assertIs=e;function t(r){throw new Error}a.assertNever=t,a.arrayToEnum=r=>{let n={};for(let l of r)n[l]=l;return n},a.getValidEnumValues=r=>{let n=a.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),l={};for(let o of n)l[o]=r[o];return a.objectValues(l)},a.objectValues=r=>a.objectKeys(r).map(function(n){return r[n]}),a.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let n=[];for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&n.push(l);return n},a.find=(r,n)=>{for(let l of r)if(n(l))return l},a.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,n=" | "){return r.map(l=>typeof l=="string"?`'${l}'`:l).join(n)}a.joinValues=s,a.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(X||(X={}));var ka;(function(a){a.mergeShapes=(e,t)=>({...e,...t})})(ka||(ka={}));var N=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),or=a=>{switch(typeof a){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(a)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(a)?N.array:a===null?N.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?N.promise:typeof Map<"u"&&a instanceof Map?N.map:typeof Set<"u"&&a instanceof Set?N.set:typeof Date<"u"&&a instanceof Date?N.date:N.object;default:return N.unknown}};var w=X.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"]),Hl=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:"),Me=class a extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(n){return n.message},s={_errors:[]},r=n=>{for(let l of n.issues)if(l.code==="invalid_union")l.unionErrors.map(r);else if(l.code==="invalid_return_type")r(l.returnTypeError);else if(l.code==="invalid_arguments")r(l.argumentsError);else if(l.path.length===0)s._errors.push(t(l));else{let o=s,u=0;for(;ut.message){let t={},s=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};Me.create=a=>new Me(a);var Zl=(a,e)=>{let t;switch(a.code){case w.invalid_type:a.received===N.undefined?t="Required":t=`Expected ${a.expected}, received ${a.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(a.expected,X.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${X.joinValues(a.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${X.joinValues(a.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${X.joinValues(a.options)}, received '${a.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(t=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?t=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?t=`Invalid input: must end with "${a.validation.endsWith}"`:X.assertNever(a.validation):a.validation!=="regex"?t=`Invalid ${a.validation}`:t="Invalid";break;case w.too_small:a.type==="array"?t=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?t=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?t=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="bigint"?t=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?t=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:t="Invalid input";break;case w.too_big:a.type==="array"?t=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?t=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?t=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?t=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?t=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:t="Invalid input";break;case w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${a.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,X.assertNever(a)}return{message:t}},gr=Zl;var Hs=gr;function Bl(a){Hs=a}function ot(){return Hs}var wt=a=>{let{data:e,path:t,errorMaps:s,issueData:r}=a,n=[...t,...r.path||[]],l={...r,path:n};if(r.message!==void 0)return{...r,path:n,message:r.message};let o="",u=s.filter(f=>!!f).slice().reverse();for(let f of u)o=f(l,{data:e,defaultError:o}).message;return{...r,path:n,message:o}},Wl=[];function C(a,e){let t=ot(),s=wt({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,t,t===gr?void 0:gr].filter(r=>!!r)});a.common.issues.push(s)}var Pe=class a{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let r of t){if(r.status==="aborted")return Z;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let r of t){let n=await r.key,l=await r.value;s.push({key:n,value:l})}return a.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let r of t){let{key:n,value:l}=r;if(n.status==="aborted"||l.status==="aborted")return Z;n.status==="dirty"&&e.dirty(),l.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof l.value<"u"||r.alwaysSet)&&(s[n.value]=l.value)}return{status:e.value,value:s}}},Z=Object.freeze({status:"aborted"}),jr=a=>({status:"dirty",value:a}),Te=a=>({status:"valid",value:a}),Lt=a=>a.status==="aborted",qt=a=>a.status==="dirty",xr=a=>a.status==="valid",lt=a=>typeof Promise<"u"&&a instanceof Promise;var V;(function(a){a.errToObj=e=>typeof e=="string"?{message:e}:e||{},a.toString=e=>typeof e=="string"?e:e?.message})(V||(V={}));var We=class{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}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}},Zs=(a,e)=>{if(xr(e))return{success:!0,data:e.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new Me(a.common.issues);return this._error=t,this._error}}};function K(a){if(!a)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:r}=a;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(l,o)=>{let{message:u}=a;return l.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:u??s??o.defaultError}:l.code!=="invalid_type"?{message:o.defaultError}:{message:u??t??o.defaultError}},description:r}}var J=class{get description(){return this._def.description}_getType(e){return or(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:or(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:or(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(lt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:or(e)},r=this._parseSync({data:e,path:s.path,parent:s});return Zs(s,r)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:or(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return xr(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>xr(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:or(e)},r=this._parse({data:e,path:s.path,parent:s}),n=await(lt(r)?r:Promise.resolve(r));return Zs(s,n)}refine(e,t){let s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,n)=>{let l=e(r),o=()=>n.addIssue({code:w.custom,...s(r)});return typeof Promise<"u"&&l instanceof Promise?l.then(u=>u?!0:(o(),!1)):l?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new Ke({schema:this,typeName:R.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:t=>this["~validate"](t)}}optional(){return Be.create(this,this._def)}nullable(){return cr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return br.create(this)}promise(){return Or.create(this,this._def)}or(e){return zr.create([this,e],this._def)}and(e){return Hr.create(this,e,this._def)}transform(e){return new Ke({...K(this._def),schema:this,typeName:R.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Qr({...K(this._def),innerType:this,defaultValue:t,typeName:R.ZodDefault})}brand(){return new Ot({typeName:R.ZodBranded,type:this,...K(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Jr({...K(this._def),innerType:this,catchValue:t,typeName:R.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Rt.create(this,e)}readonly(){return Gr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Kl=/^c[^\s-]{8,}$/i,Ql=/^[0-9a-z]+$/,Jl=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Gl=/^[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,Yl=/^[a-z0-9_-]{21}$/i,Xl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ec=/^[-+]?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)?)??$/,rc=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",$a,ac=/^(?:(?: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])$/,sc=/^(?:(?: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])$/,nc=/^(([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]))$/,ic=/^(([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])$/,oc=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lc=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ws="((\\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])))",cc=new RegExp(`^${Ws}$`);function Ks(a){let e="[0-5]\\d";a.precision?e=`${e}\\.\\d{${a.precision}}`:a.precision==null&&(e=`${e}(\\.\\d+)?`);let t=a.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function uc(a){return new RegExp(`^${Ks(a)}$`)}function Qs(a){let e=`${Ws}T${Ks(a)}`,t=[];return t.push(a.local?"Z?":"Z"),a.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function dc(a,e){return!!((e==="v4"||!e)&&ac.test(a)||(e==="v6"||!e)&&nc.test(a))}function fc(a,e){if(!Xl.test(a))return!1;try{let[t]=a.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function pc(a,e){return!!((e==="v4"||!e)&&sc.test(a)||(e==="v6"||!e)&&ic.test(a))}var Pr=class a extends J{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){let n=this._getOrReturnCtx(e);return C(n,{code:w.invalid_type,expected:N.string,received:n.parsedType}),Z}let s=new Pe,r;for(let n of this._def.checks)if(n.kind==="min")e.data.lengthn.value&&(r=this._getOrReturnCtx(e,r),C(r,{code:w.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="length"){let l=e.data.length>n.value,o=e.data.lengthe.test(r),{validation:t,code:w.invalid_string,...V.errToObj(s)})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...V.errToObj(e)})}url(e){return this._addCheck({kind:"url",...V.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...V.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...V.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...V.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...V.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...V.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...V.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...V.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...V.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...V.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...V.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...V.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,...V.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,...V.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...V.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...V.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...V.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...V.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...V.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...V.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...V.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...V.errToObj(t)})}nonempty(e){return this.min(1,V.errToObj(e))}trim(){return new a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew Pr({checks:[],typeName:R.ZodString,coerce:a?.coerce??!1,...K(a)});function hc(a,e){let t=(a.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,n=Number.parseInt(a.toFixed(r).replace(".","")),l=Number.parseInt(e.toFixed(r).replace(".",""));return n%l/10**r}var Mr=class a extends J{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)!==N.number){let n=this._getOrReturnCtx(e);return C(n,{code:w.invalid_type,expected:N.number,received:n.parsedType}),Z}let s,r=new Pe;for(let n of this._def.checks)n.kind==="int"?X.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),C(s,{code:w.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),C(s,{code:w.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="multipleOf"?hc(e.data,n.value)!==0&&(s=this._getOrReturnCtx(e,s),C(s,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),C(s,{code:w.not_finite,message:n.message}),r.dirty()):X.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,V.toString(t))}gt(e,t){return this.setLimit("min",e,!1,V.toString(t))}lte(e,t){return this.setLimit("max",e,!0,V.toString(t))}lt(e,t){return this.setLimit("max",e,!1,V.toString(t))}setLimit(e,t,s,r){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:V.toString(r)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:V.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:V.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:V.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&X.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.valuenew Mr({checks:[],typeName:R.ZodNumber,coerce:a?.coerce||!1,...K(a)});var Fr=class a extends J{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)!==N.bigint)return this._getInvalidInput(e);let s,r=new Pe;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),C(s,{code:w.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),C(s,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):X.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return C(t,{code:w.invalid_type,expected:N.bigint,received:t.parsedType}),Z}gte(e,t){return this.setLimit("min",e,!0,V.toString(t))}gt(e,t){return this.setLimit("min",e,!1,V.toString(t))}lte(e,t){return this.setLimit("max",e,!0,V.toString(t))}lt(e,t){return this.setLimit("max",e,!1,V.toString(t))}setLimit(e,t,s,r){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:V.toString(r)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:V.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew Fr({checks:[],typeName:R.ZodBigInt,coerce:a?.coerce??!1,...K(a)});var Lr=class extends J{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==N.boolean){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.boolean,received:s.parsedType}),Z}return Te(e.data)}};Lr.create=a=>new Lr({typeName:R.ZodBoolean,coerce:a?.coerce||!1,...K(a)});var qr=class a extends J{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){let n=this._getOrReturnCtx(e);return C(n,{code:w.invalid_type,expected:N.date,received:n.parsedType}),Z}if(Number.isNaN(e.data.getTime())){let n=this._getOrReturnCtx(e);return C(n,{code:w.invalid_date}),Z}let s=new Pe,r;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()n.value&&(r=this._getOrReturnCtx(e,r),C(r,{code:w.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):X.assertNever(n);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:V.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:V.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew qr({checks:[],coerce:a?.coerce||!1,typeName:R.ZodDate,...K(a)});var ut=class extends J{_parse(e){if(this._getType(e)!==N.symbol){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.symbol,received:s.parsedType}),Z}return Te(e.data)}};ut.create=a=>new ut({typeName:R.ZodSymbol,...K(a)});var Ur=class extends J{_parse(e){if(this._getType(e)!==N.undefined){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.undefined,received:s.parsedType}),Z}return Te(e.data)}};Ur.create=a=>new Ur({typeName:R.ZodUndefined,...K(a)});var Vr=class extends J{_parse(e){if(this._getType(e)!==N.null){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.null,received:s.parsedType}),Z}return Te(e.data)}};Vr.create=a=>new Vr({typeName:R.ZodNull,...K(a)});var wr=class extends J{constructor(){super(...arguments),this._any=!0}_parse(e){return Te(e.data)}};wr.create=a=>new wr({typeName:R.ZodAny,...K(a)});var _r=class extends J{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Te(e.data)}};_r.create=a=>new _r({typeName:R.ZodUnknown,...K(a)});var Ye=class extends J{_parse(e){let t=this._getOrReturnCtx(e);return C(t,{code:w.invalid_type,expected:N.never,received:t.parsedType}),Z}};Ye.create=a=>new Ye({typeName:R.ZodNever,...K(a)});var dt=class extends J{_parse(e){if(this._getType(e)!==N.undefined){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.void,received:s.parsedType}),Z}return Te(e.data)}};dt.create=a=>new dt({typeName:R.ZodVoid,...K(a)});var br=class a extends J{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==N.array)return C(t,{code:w.invalid_type,expected:N.array,received:t.parsedType}),Z;if(r.exactLength!==null){let l=t.data.length>r.exactLength.value,o=t.data.lengthr.maxLength.value&&(C(t,{code:w.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((l,o)=>r.type._parseAsync(new We(t,l,t.path,o)))).then(l=>Pe.mergeArray(s,l));let n=[...t.data].map((l,o)=>r.type._parseSync(new We(t,l,t.path,o)));return Pe.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new a({...this._def,minLength:{value:e,message:V.toString(t)}})}max(e,t){return new a({...this._def,maxLength:{value:e,message:V.toString(t)}})}length(e,t){return new a({...this._def,exactLength:{value:e,message:V.toString(t)}})}nonempty(e){return this.min(1,e)}};br.create=(a,e)=>new br({type:a,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...K(e)});function ct(a){if(a instanceof Fe){let e={};for(let t in a.shape){let s=a.shape[t];e[t]=Be.create(ct(s))}return new Fe({...a._def,shape:()=>e})}else return a instanceof br?new br({...a._def,type:ct(a.element)}):a instanceof Be?Be.create(ct(a.unwrap())):a instanceof cr?cr.create(ct(a.unwrap())):a instanceof lr?lr.create(a.items.map(e=>ct(e))):a}var Fe=class a extends J{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(),t=X.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==N.object){let f=this._getOrReturnCtx(e);return C(f,{code:w.invalid_type,expected:N.object,received:f.parsedType}),Z}let{status:s,ctx:r}=this._processInputParams(e),{shape:n,keys:l}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ye&&this._def.unknownKeys==="strip"))for(let f in r.data)l.includes(f)||o.push(f);let u=[];for(let f of l){let p=n[f],m=r.data[f];u.push({key:{status:"valid",value:f},value:p._parse(new We(r,m,r.path,f)),alwaysSet:f in r.data})}if(this._def.catchall instanceof Ye){let f=this._def.unknownKeys;if(f==="passthrough")for(let p of o)u.push({key:{status:"valid",value:p},value:{status:"valid",value:r.data[p]}});else if(f==="strict")o.length>0&&(C(r,{code:w.unrecognized_keys,keys:o}),s.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let f=this._def.catchall;for(let p of o){let m=r.data[p];u.push({key:{status:"valid",value:p},value:f._parse(new We(r,m,r.path,p)),alwaysSet:p in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let f=[];for(let p of u){let m=await p.key,b=await p.value;f.push({key:m,value:b,alwaysSet:p.alwaysSet})}return f}).then(f=>Pe.mergeObjectSync(s,f)):Pe.mergeObjectSync(s,u)}get shape(){return this._def.shape()}strict(e){return V.errToObj,new a({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let r=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:V.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new a({...this._def,unknownKeys:"strip"})}passthrough(){return new a({...this._def,unknownKeys:"passthrough"})}extend(e){return new a({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new a({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:R.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new a({...this._def,catchall:e})}pick(e){let t={};for(let s of X.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new a({...this._def,shape:()=>t})}omit(e){let t={};for(let s of X.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new a({...this._def,shape:()=>t})}deepPartial(){return ct(this)}partial(e){let t={};for(let s of X.objectKeys(this.shape)){let r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}return new a({...this._def,shape:()=>t})}required(e){let t={};for(let s of X.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Be;)n=n._def.innerType;t[s]=n}return new a({...this._def,shape:()=>t})}keyof(){return Js(X.objectKeys(this.shape))}};Fe.create=(a,e)=>new Fe({shape:()=>a,unknownKeys:"strip",catchall:Ye.create(),typeName:R.ZodObject,...K(e)});Fe.strictCreate=(a,e)=>new Fe({shape:()=>a,unknownKeys:"strict",catchall:Ye.create(),typeName:R.ZodObject,...K(e)});Fe.lazycreate=(a,e)=>new Fe({shape:a,unknownKeys:"strip",catchall:Ye.create(),typeName:R.ZodObject,...K(e)});var zr=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function r(n){for(let o of n)if(o.result.status==="valid")return o.result;for(let o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let l=n.map(o=>new Me(o.ctx.common.issues));return C(t,{code:w.invalid_union,unionErrors:l}),Z}if(t.common.async)return Promise.all(s.map(async n=>{let l={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:l}),ctx:l}})).then(r);{let n,l=[];for(let u of s){let f={...t,common:{...t.common,issues:[]},parent:null},p=u._parseSync({data:t.data,path:t.path,parent:f});if(p.status==="valid")return p;p.status==="dirty"&&!n&&(n={result:p,ctx:f}),f.common.issues.length&&l.push(f.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;let o=l.map(u=>new Me(u));return C(t,{code:w.invalid_union,unionErrors:o}),Z}}get options(){return this._def.options}};zr.create=(a,e)=>new zr({options:a,typeName:R.ZodUnion,...K(e)});var yr=a=>a instanceof Zr?yr(a.schema):a instanceof Ke?yr(a.innerType()):a instanceof Br?[a.value]:a instanceof Wr?a.options:a instanceof Kr?X.objectValues(a.enum):a instanceof Qr?yr(a._def.innerType):a instanceof Ur?[void 0]:a instanceof Vr?[null]:a instanceof Be?[void 0,...yr(a.unwrap())]:a instanceof cr?[null,...yr(a.unwrap())]:a instanceof Ot||a instanceof Gr?yr(a.unwrap()):a instanceof Jr?yr(a._def.innerType):[],Ut=class a extends J{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.object)return C(t,{code:w.invalid_type,expected:N.object,received:t.parsedType}),Z;let s=this.discriminator,r=t.data[s],n=this.optionsMap.get(r);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(C(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let r=new Map;for(let n of t){let l=yr(n.shape[e]);if(!l.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of l){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,n)}}return new a({typeName:R.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...K(s)})}};function Ca(a,e){let t=or(a),s=or(e);if(a===e)return{valid:!0,data:a};if(t===N.object&&s===N.object){let r=X.objectKeys(e),n=X.objectKeys(a).filter(o=>r.indexOf(o)!==-1),l={...a,...e};for(let o of n){let u=Ca(a[o],e[o]);if(!u.valid)return{valid:!1};l[o]=u.data}return{valid:!0,data:l}}else if(t===N.array&&s===N.array){if(a.length!==e.length)return{valid:!1};let r=[];for(let n=0;n{if(Lt(n)||Lt(l))return Z;let o=Ca(n.value,l.value);return o.valid?((qt(n)||qt(l))&&t.dirty(),{status:t.value,value:o.data}):(C(s,{code:w.invalid_intersection_types}),Z)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([n,l])=>r(n,l)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};Hr.create=(a,e,t)=>new Hr({left:a,right:e,typeName:R.ZodIntersection,...K(t)});var lr=class a extends J{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.array)return C(s,{code:w.invalid_type,expected:N.array,received:s.parsedType}),Z;if(s.data.lengththis._def.items.length&&(C(s,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...s.data].map((l,o)=>{let u=this._def.items[o]||this._def.rest;return u?u._parse(new We(s,l,s.path,o)):null}).filter(l=>!!l);return s.common.async?Promise.all(n).then(l=>Pe.mergeArray(t,l)):Pe.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new a({...this._def,rest:e})}};lr.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new lr({items:a,typeName:R.ZodTuple,rest:null,...K(e)})};var Vt=class a extends J{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.object)return C(s,{code:w.invalid_type,expected:N.object,received:s.parsedType}),Z;let r=[],n=this._def.keyType,l=this._def.valueType;for(let o in s.data)r.push({key:n._parse(new We(s,o,s.path,o)),value:l._parse(new We(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?Pe.mergeObjectAsync(t,r):Pe.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof J?new a({keyType:e,valueType:t,typeName:R.ZodRecord,...K(s)}):new a({keyType:Pr.create(),valueType:e,typeName:R.ZodRecord,...K(t)})}},ft=class extends J{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.map)return C(s,{code:w.invalid_type,expected:N.map,received:s.parsedType}),Z;let r=this._def.keyType,n=this._def.valueType,l=[...s.data.entries()].map(([o,u],f)=>({key:r._parse(new We(s,o,s.path,[f,"key"])),value:n._parse(new We(s,u,s.path,[f,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let u of l){let f=await u.key,p=await u.value;if(f.status==="aborted"||p.status==="aborted")return Z;(f.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(f.value,p.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let u of l){let f=u.key,p=u.value;if(f.status==="aborted"||p.status==="aborted")return Z;(f.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(f.value,p.value)}return{status:t.value,value:o}}}};ft.create=(a,e,t)=>new ft({valueType:e,keyType:a,typeName:R.ZodMap,...K(t)});var pt=class a extends J{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.set)return C(s,{code:w.invalid_type,expected:N.set,received:s.parsedType}),Z;let r=this._def;r.minSize!==null&&s.data.sizer.maxSize.value&&(C(s,{code:w.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let n=this._def.valueType;function l(u){let f=new Set;for(let p of u){if(p.status==="aborted")return Z;p.status==="dirty"&&t.dirty(),f.add(p.value)}return{status:t.value,value:f}}let o=[...s.data.values()].map((u,f)=>n._parse(new We(s,u,s.path,f)));return s.common.async?Promise.all(o).then(u=>l(u)):l(o)}min(e,t){return new a({...this._def,minSize:{value:e,message:V.toString(t)}})}max(e,t){return new a({...this._def,maxSize:{value:e,message:V.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};pt.create=(a,e)=>new pt({valueType:a,minSize:null,maxSize:null,typeName:R.ZodSet,...K(e)});var zt=class a extends J{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.function)return C(t,{code:w.invalid_type,expected:N.function,received:t.parsedType}),Z;function s(o,u){return wt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ot(),gr].filter(f=>!!f),issueData:{code:w.invalid_arguments,argumentsError:u}})}function r(o,u){return wt({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ot(),gr].filter(f=>!!f),issueData:{code:w.invalid_return_type,returnTypeError:u}})}let n={errorMap:t.common.contextualErrorMap},l=t.data;if(this._def.returns instanceof Or){let o=this;return Te(async function(...u){let f=new Me([]),p=await o._def.args.parseAsync(u,n).catch(c=>{throw f.addIssue(s(u,c)),f}),m=await Reflect.apply(l,this,p);return await o._def.returns._def.type.parseAsync(m,n).catch(c=>{throw f.addIssue(r(m,c)),f})})}else{let o=this;return Te(function(...u){let f=o._def.args.safeParse(u,n);if(!f.success)throw new Me([s(u,f.error)]);let p=Reflect.apply(l,this,f.data),m=o._def.returns.safeParse(p,n);if(!m.success)throw new Me([r(p,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new a({...this._def,args:lr.create(e).rest(_r.create())})}returns(e){return new a({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new a({args:e||lr.create([]).rest(_r.create()),returns:t||_r.create(),typeName:R.ZodFunction,...K(s)})}},Zr=class extends J{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Zr.create=(a,e)=>new Zr({getter:a,typeName:R.ZodLazy,...K(e)});var Br=class extends J{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return C(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:e.data}}get value(){return this._def.value}};Br.create=(a,e)=>new Br({value:a,typeName:R.ZodLiteral,...K(e)});function Js(a,e){return new Wr({values:a,typeName:R.ZodEnum,...K(e)})}var Wr=class a extends J{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return C(t,{expected:X.joinValues(s),received:t.parsedType,code:w.invalid_type}),Z}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return C(t,{received:t.data,code:w.invalid_enum_value,options:s}),Z}return Te(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return a.create(e,{...this._def,...t})}exclude(e,t=this._def){return a.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};Wr.create=Js;var Kr=class extends J{_parse(e){let t=X.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==N.string&&s.parsedType!==N.number){let r=X.objectValues(t);return C(s,{expected:X.joinValues(r),received:s.parsedType,code:w.invalid_type}),Z}if(this._cache||(this._cache=new Set(X.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=X.objectValues(t);return C(s,{received:s.data,code:w.invalid_enum_value,options:r}),Z}return Te(e.data)}get enum(){return this._def.values}};Kr.create=(a,e)=>new Kr({values:a,typeName:R.ZodNativeEnum,...K(e)});var Or=class extends J{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.promise&&t.common.async===!1)return C(t,{code:w.invalid_type,expected:N.promise,received:t.parsedType}),Z;let s=t.parsedType===N.promise?t.data:Promise.resolve(t.data);return Te(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Or.create=(a,e)=>new Or({type:a,typeName:R.ZodPromise,...K(e)});var Ke=class extends J{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:l=>{C(s,l),l.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),r.type==="preprocess"){let l=r.transform(s.data,n);if(s.common.async)return Promise.resolve(l).then(async o=>{if(t.value==="aborted")return Z;let u=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return u.status==="aborted"?Z:u.status==="dirty"?jr(u.value):t.value==="dirty"?jr(u.value):u});{if(t.value==="aborted")return Z;let o=this._def.schema._parseSync({data:l,path:s.path,parent:s});return o.status==="aborted"?Z:o.status==="dirty"?jr(o.value):t.value==="dirty"?jr(o.value):o}}if(r.type==="refinement"){let l=o=>{let u=r.refinement(o,n);if(s.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?Z:(o.status==="dirty"&&t.dirty(),l(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?Z:(o.status==="dirty"&&t.dirty(),l(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){let l=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!xr(l))return Z;let o=r.transform(l.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(l=>xr(l)?Promise.resolve(r.transform(l.value,n)).then(o=>({status:t.value,value:o})):Z);X.assertNever(r)}};Ke.create=(a,e,t)=>new Ke({schema:a,typeName:R.ZodEffects,effect:e,...K(t)});Ke.createWithPreprocess=(a,e,t)=>new Ke({schema:e,effect:{type:"preprocess",transform:a},typeName:R.ZodEffects,...K(t)});var Be=class extends J{_parse(e){return this._getType(e)===N.undefined?Te(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Be.create=(a,e)=>new Be({innerType:a,typeName:R.ZodOptional,...K(e)});var cr=class extends J{_parse(e){return this._getType(e)===N.null?Te(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};cr.create=(a,e)=>new cr({innerType:a,typeName:R.ZodNullable,...K(e)});var Qr=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===N.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Qr.create=(a,e)=>new Qr({innerType:a,typeName:R.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...K(e)});var Jr=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return lt(r)?r.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Me(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Me(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Jr.create=(a,e)=>new Jr({innerType:a,typeName:R.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...K(e)});var ht=class extends J{_parse(e){if(this._getType(e)!==N.nan){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.nan,received:s.parsedType}),Z}return{status:"valid",value:e.data}}};ht.create=a=>new ht({typeName:R.ZodNaN,...K(a)});var mc=Symbol("zod_brand"),Ot=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},Rt=class a extends J{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?Z:n.status==="dirty"?(t.dirty(),jr(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{let r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?Z:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new a({in:e,out:t,typeName:R.ZodPipeline})}},Gr=class extends J{_parse(e){let t=this._def.innerType._parse(e),s=r=>(xr(r)&&(r.value=Object.freeze(r.value)),r);return lt(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}};Gr.create=(a,e)=>new Gr({innerType:a,typeName:R.ZodReadonly,...K(e)});function Bs(a,e){let t=typeof a=="function"?a(e):typeof a=="string"?{message:a}:a;return typeof t=="string"?{message:t}:t}function Gs(a,e={},t){return a?wr.create().superRefine((s,r)=>{let n=a(s);if(n instanceof Promise)return n.then(l=>{if(!l){let o=Bs(e,s),u=o.fatal??t??!0;r.addIssue({code:"custom",...o,fatal:u})}});if(!n){let l=Bs(e,s),o=l.fatal??t??!0;r.addIssue({code:"custom",...l,fatal:o})}}):wr.create()}var vc={object:Fe.lazycreate},R;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(R||(R={}));var gc=(a,e={message:`Input not instance of ${a.name}`})=>Gs(t=>t instanceof a,e),Ys=Pr.create,Xs=Mr.create,yc=ht.create,_c=Fr.create,en=Lr.create,bc=qr.create,Ec=ut.create,Sc=Ur.create,xc=Vr.create,Pc=wr.create,wc=_r.create,Oc=Ye.create,Rc=dt.create,Tc=br.create,Ac=Fe.create,Dc=Fe.strictCreate,Ic=zr.create,kc=Ut.create,$c=Hr.create,Cc=lr.create,Nc=Vt.create,jc=ft.create,Mc=pt.create,Fc=zt.create,Lc=Zr.create,qc=Br.create,Uc=Wr.create,Vc=Kr.create,zc=Or.create,Hc=Ke.create,Zc=Be.create,Bc=cr.create,Wc=Ke.createWithPreprocess,Kc=Rt.create,Qc=()=>Ys().optional(),Jc=()=>Xs().optional(),Gc=()=>en().optional(),Yc={string:(a=>Pr.create({...a,coerce:!0})),number:(a=>Mr.create({...a,coerce:!0})),boolean:(a=>Lr.create({...a,coerce:!0})),bigint:(a=>Fr.create({...a,coerce:!0})),date:(a=>qr.create({...a,coerce:!0}))};var Xc=Z;var Na="2025-06-18";var rn=[Na,"2025-03-26","2024-11-05","2024-10-07"],Ht="2.0",tn=i.union([i.string(),i.number().int()]),an=i.string(),eu=i.object({progressToken:i.optional(tn)}).passthrough(),Qe=i.object({_meta:i.optional(eu)}).passthrough(),Le=i.object({method:i.string(),params:i.optional(Qe)}),Tt=i.object({_meta:i.optional(i.object({}).passthrough())}).passthrough(),ur=i.object({method:i.string(),params:i.optional(Tt)}),Je=i.object({_meta:i.optional(i.object({}).passthrough())}).passthrough(),Zt=i.union([i.string(),i.number().int()]),sn=i.object({jsonrpc:i.literal(Ht),id:Zt}).merge(Le).strict(),nn=a=>sn.safeParse(a).success,on=i.object({jsonrpc:i.literal(Ht)}).merge(ur).strict(),ln=a=>on.safeParse(a).success,cn=i.object({jsonrpc:i.literal(Ht),id:Zt,result:Je}).strict(),ja=a=>cn.safeParse(a).success,Xe;(function(a){a[a.ConnectionClosed=-32e3]="ConnectionClosed",a[a.RequestTimeout=-32001]="RequestTimeout",a[a.ParseError=-32700]="ParseError",a[a.InvalidRequest=-32600]="InvalidRequest",a[a.MethodNotFound=-32601]="MethodNotFound",a[a.InvalidParams=-32602]="InvalidParams",a[a.InternalError=-32603]="InternalError"})(Xe||(Xe={}));var un=i.object({jsonrpc:i.literal(Ht),id:Zt,error:i.object({code:i.number().int(),message:i.string(),data:i.optional(i.unknown())})}).strict(),dn=a=>un.safeParse(a).success,fn=i.union([sn,on,cn,un]),Bt=Je.strict(),Wt=ur.extend({method:i.literal("notifications/cancelled"),params:Tt.extend({requestId:Zt,reason:i.string().optional()})}),ru=i.object({src:i.string(),mimeType:i.optional(i.string()),sizes:i.optional(i.array(i.string()))}).passthrough(),At=i.object({icons:i.array(ru).optional()}).passthrough(),Dt=i.object({name:i.string(),title:i.optional(i.string())}).passthrough(),pn=Dt.extend({version:i.string(),websiteUrl:i.optional(i.string())}).merge(At),tu=i.object({experimental:i.optional(i.object({}).passthrough()),sampling:i.optional(i.object({}).passthrough()),elicitation:i.optional(i.object({}).passthrough()),roots:i.optional(i.object({listChanged:i.optional(i.boolean())}).passthrough())}).passthrough(),Ma=Le.extend({method:i.literal("initialize"),params:Qe.extend({protocolVersion:i.string(),capabilities:tu,clientInfo:pn})});var au=i.object({experimental:i.optional(i.object({}).passthrough()),logging:i.optional(i.object({}).passthrough()),completions:i.optional(i.object({}).passthrough()),prompts:i.optional(i.object({listChanged:i.optional(i.boolean())}).passthrough()),resources:i.optional(i.object({subscribe:i.optional(i.boolean()),listChanged:i.optional(i.boolean())}).passthrough()),tools:i.optional(i.object({listChanged:i.optional(i.boolean())}).passthrough())}).passthrough(),su=Je.extend({protocolVersion:i.string(),capabilities:au,serverInfo:pn,instructions:i.optional(i.string())}),Fa=ur.extend({method:i.literal("notifications/initialized")});var Kt=Le.extend({method:i.literal("ping")}),nu=i.object({progress:i.number(),total:i.optional(i.number()),message:i.optional(i.string())}).passthrough(),Qt=ur.extend({method:i.literal("notifications/progress"),params:Tt.merge(nu).extend({progressToken:tn})}),Jt=Le.extend({params:Qe.extend({cursor:i.optional(an)}).optional()}),Gt=Je.extend({nextCursor:i.optional(an)}),hn=i.object({uri:i.string(),mimeType:i.optional(i.string()),_meta:i.optional(i.object({}).passthrough())}).passthrough(),mn=hn.extend({text:i.string()}),La=i.string().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),vn=hn.extend({blob:La}),gn=Dt.extend({uri:i.string(),description:i.optional(i.string()),mimeType:i.optional(i.string()),_meta:i.optional(i.object({}).passthrough())}).merge(At),iu=Dt.extend({uriTemplate:i.string(),description:i.optional(i.string()),mimeType:i.optional(i.string()),_meta:i.optional(i.object({}).passthrough())}).merge(At),ou=Jt.extend({method:i.literal("resources/list")}),lu=Gt.extend({resources:i.array(gn)}),cu=Jt.extend({method:i.literal("resources/templates/list")}),uu=Gt.extend({resourceTemplates:i.array(iu)}),du=Le.extend({method:i.literal("resources/read"),params:Qe.extend({uri:i.string()})}),fu=Je.extend({contents:i.array(i.union([mn,vn]))}),pu=ur.extend({method:i.literal("notifications/resources/list_changed")}),hu=Le.extend({method:i.literal("resources/subscribe"),params:Qe.extend({uri:i.string()})}),mu=Le.extend({method:i.literal("resources/unsubscribe"),params:Qe.extend({uri:i.string()})}),vu=ur.extend({method:i.literal("notifications/resources/updated"),params:Tt.extend({uri:i.string()})}),gu=i.object({name:i.string(),description:i.optional(i.string()),required:i.optional(i.boolean())}).passthrough(),yu=Dt.extend({description:i.optional(i.string()),arguments:i.optional(i.array(gu)),_meta:i.optional(i.object({}).passthrough())}).merge(At),_u=Jt.extend({method:i.literal("prompts/list")}),bu=Gt.extend({prompts:i.array(yu)}),Eu=Le.extend({method:i.literal("prompts/get"),params:Qe.extend({name:i.string(),arguments:i.optional(i.record(i.string()))})}),qa=i.object({type:i.literal("text"),text:i.string(),_meta:i.optional(i.object({}).passthrough())}).passthrough(),Ua=i.object({type:i.literal("image"),data:La,mimeType:i.string(),_meta:i.optional(i.object({}).passthrough())}).passthrough(),Va=i.object({type:i.literal("audio"),data:La,mimeType:i.string(),_meta:i.optional(i.object({}).passthrough())}).passthrough(),Su=i.object({type:i.literal("resource"),resource:i.union([mn,vn]),_meta:i.optional(i.object({}).passthrough())}).passthrough(),xu=gn.extend({type:i.literal("resource_link")}),yn=i.union([qa,Ua,Va,xu,Su]),Pu=i.object({role:i.enum(["user","assistant"]),content:yn}).passthrough(),wu=Je.extend({description:i.optional(i.string()),messages:i.array(Pu)}),Ou=ur.extend({method:i.literal("notifications/prompts/list_changed")}),Ru=i.object({title:i.optional(i.string()),readOnlyHint:i.optional(i.boolean()),destructiveHint:i.optional(i.boolean()),idempotentHint:i.optional(i.boolean()),openWorldHint:i.optional(i.boolean())}).passthrough(),Tu=Dt.extend({description:i.optional(i.string()),inputSchema:i.object({type:i.literal("object"),properties:i.optional(i.object({}).passthrough()),required:i.optional(i.array(i.string()))}).passthrough(),outputSchema:i.optional(i.object({type:i.literal("object"),properties:i.optional(i.object({}).passthrough()),required:i.optional(i.array(i.string()))}).passthrough()),annotations:i.optional(Ru),_meta:i.optional(i.object({}).passthrough())}).merge(At),za=Jt.extend({method:i.literal("tools/list")}),Au=Gt.extend({tools:i.array(Tu)}),_n=Je.extend({content:i.array(yn).default([]),structuredContent:i.object({}).passthrough().optional(),isError:i.optional(i.boolean())}),Dp=_n.or(Je.extend({toolResult:i.unknown()})),Ha=Le.extend({method:i.literal("tools/call"),params:Qe.extend({name:i.string(),arguments:i.optional(i.record(i.unknown()))})}),Du=ur.extend({method:i.literal("notifications/tools/list_changed")}),It=i.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),Za=Le.extend({method:i.literal("logging/setLevel"),params:Qe.extend({level:It})}),Iu=ur.extend({method:i.literal("notifications/message"),params:Tt.extend({level:It,logger:i.optional(i.string()),data:i.unknown()})}),ku=i.object({name:i.string().optional()}).passthrough(),$u=i.object({hints:i.optional(i.array(ku)),costPriority:i.optional(i.number().min(0).max(1)),speedPriority:i.optional(i.number().min(0).max(1)),intelligencePriority:i.optional(i.number().min(0).max(1))}).passthrough(),Cu=i.object({role:i.enum(["user","assistant"]),content:i.union([qa,Ua,Va])}).passthrough(),Nu=Le.extend({method:i.literal("sampling/createMessage"),params:Qe.extend({messages:i.array(Cu),systemPrompt:i.optional(i.string()),includeContext:i.optional(i.enum(["none","thisServer","allServers"])),temperature:i.optional(i.number()),maxTokens:i.number().int(),stopSequences:i.optional(i.array(i.string())),metadata:i.optional(i.object({}).passthrough()),modelPreferences:i.optional($u)})}),Ba=Je.extend({model:i.string(),stopReason:i.optional(i.enum(["endTurn","stopSequence","maxTokens"]).or(i.string())),role:i.enum(["user","assistant"]),content:i.discriminatedUnion("type",[qa,Ua,Va])}),ju=i.object({type:i.literal("boolean"),title:i.optional(i.string()),description:i.optional(i.string()),default:i.optional(i.boolean())}).passthrough(),Mu=i.object({type:i.literal("string"),title:i.optional(i.string()),description:i.optional(i.string()),minLength:i.optional(i.number()),maxLength:i.optional(i.number()),format:i.optional(i.enum(["email","uri","date","date-time"]))}).passthrough(),Fu=i.object({type:i.enum(["number","integer"]),title:i.optional(i.string()),description:i.optional(i.string()),minimum:i.optional(i.number()),maximum:i.optional(i.number())}).passthrough(),Lu=i.object({type:i.literal("string"),title:i.optional(i.string()),description:i.optional(i.string()),enum:i.array(i.string()),enumNames:i.optional(i.array(i.string()))}).passthrough(),qu=i.union([ju,Mu,Fu,Lu]),Uu=Le.extend({method:i.literal("elicitation/create"),params:Qe.extend({message:i.string(),requestedSchema:i.object({type:i.literal("object"),properties:i.record(i.string(),qu),required:i.optional(i.array(i.string()))}).passthrough()})}),Wa=Je.extend({action:i.enum(["accept","decline","cancel"]),content:i.optional(i.record(i.string(),i.unknown()))}),Vu=i.object({type:i.literal("ref/resource"),uri:i.string()}).passthrough();var zu=i.object({type:i.literal("ref/prompt"),name:i.string()}).passthrough(),Hu=Le.extend({method:i.literal("completion/complete"),params:Qe.extend({ref:i.union([zu,Vu]),argument:i.object({name:i.string(),value:i.string()}).passthrough(),context:i.optional(i.object({arguments:i.optional(i.record(i.string(),i.string()))}))})}),Zu=Je.extend({completion:i.object({values:i.array(i.string()).max(100),total:i.optional(i.number().int()),hasMore:i.optional(i.boolean())}).passthrough()}),Bu=i.object({uri:i.string().startsWith("file://"),name:i.optional(i.string()),_meta:i.optional(i.object({}).passthrough())}).passthrough(),Wu=Le.extend({method:i.literal("roots/list")}),Ka=Je.extend({roots:i.array(Bu)}),Ku=ur.extend({method:i.literal("notifications/roots/list_changed")}),Ip=i.union([Kt,Ma,Hu,Za,Eu,_u,ou,cu,du,hu,mu,Ha,za]),kp=i.union([Wt,Qt,Fa,Ku]),$p=i.union([Bt,Ba,Wa,Ka]),Cp=i.union([Kt,Nu,Uu,Wu]),Np=i.union([Wt,Qt,Iu,vu,pu,Du,Ou]),jp=i.union([Bt,su,Zu,wu,bu,lu,uu,fu,_n,Au]),er=class extends Error{constructor(e,t,s){super(`MCP error ${e}: ${t}`),this.code=e,this.data=s,this.name="McpError"}};var Qu=6e4,Yt=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.setNotificationHandler(Wt,t=>{let s=this._requestHandlerAbortControllers.get(t.params.requestId);s?.abort(t.params.reason)}),this.setNotificationHandler(Qt,t=>{this._onprogress(t)}),this.setRequestHandler(Kt,t=>({}))}_setupTimeout(e,t,s,r,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:n,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new er(Xe.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var t,s,r;this._transport=e;let n=(t=this.transport)===null||t===void 0?void 0:t.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};let l=(s=this.transport)===null||s===void 0?void 0:s.onerror;this._transport.onerror=u=>{l?.(u),this._onerror(u)};let o=(r=this._transport)===null||r===void 0?void 0:r.onmessage;this._transport.onmessage=(u,f)=>{o?.(u,f),ja(u)||dn(u)?this._onresponse(u):nn(u)?this._onrequest(u,f):ln(u)?this._onnotification(u):this._onerror(new Error(`Unknown message type: ${JSON.stringify(u)}`))},await this._transport.start()}_onclose(){var e;let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let s=new er(Xe.ConnectionClosed,"Connection closed");for(let r of t.values())r(s)}_onerror(e){var t;(t=this.onerror)===null||t===void 0||t.call(this,e)}_onnotification(e){var t;let s=(t=this._notificationHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackNotificationHandler;s!==void 0&&Promise.resolve().then(()=>s(e)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(e,t){var s,r;let n=(s=this._requestHandlers.get(e.method))!==null&&s!==void 0?s:this.fallbackRequestHandler,l=this._transport;if(n===void 0){l?.send({jsonrpc:"2.0",id:e.id,error:{code:Xe.MethodNotFound,message:"Method not found"}}).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)));return}let o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);let u={signal:o.signal,sessionId:l?.sessionId,_meta:(r=e.params)===null||r===void 0?void 0:r._meta,sendNotification:f=>this.notification(f,{relatedRequestId:e.id}),sendRequest:(f,p,m)=>this.request(f,p,{...m,relatedRequestId:e.id}),authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo};Promise.resolve().then(()=>n(e,u)).then(f=>{if(!o.signal.aborted)return l?.send({result:f,jsonrpc:"2.0",id:e.id})},f=>{var p;if(!o.signal.aborted)return l?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(f.code)?f.code:Xe.InternalError,message:(p=f.message)!==null&&p!==void 0?p:"Internal error"}})}).catch(f=>this._onerror(new Error(`Failed to send response: ${f}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...s}=e.params,r=Number(t),n=this._progressHandlers.get(r);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let l=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&l&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){l(u);return}n(s)}_onresponse(e){let t=Number(e.id),s=this._responseHandlers.get(t);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),ja(e))s(e);else{let r=new er(e.error.code,e.error.message,e.error.data);s(r)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,t,s){let{relatedRequestId:r,resumptionToken:n,onresumptiontoken:l}=s??{};return new Promise((o,u)=>{var f,p,m,b,c,y;if(!this._transport){u(new Error("Not connected"));return}((f=this._options)===null||f===void 0?void 0:f.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(p=s?.signal)===null||p===void 0||p.throwIfAborted();let _=this._requestMessageId++,v={...e,jsonrpc:"2.0",id:_};s?.onprogress&&(this._progressHandlers.set(_,s.onprogress),v.params={...e.params,_meta:{...((m=e.params)===null||m===void 0?void 0:m._meta)||{},progressToken:_}});let x=O=>{var D;this._responseHandlers.delete(_),this._progressHandlers.delete(_),this._cleanupTimeout(_),(D=this._transport)===null||D===void 0||D.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:_,reason:String(O)}},{relatedRequestId:r,resumptionToken:n,onresumptiontoken:l}).catch(I=>this._onerror(new Error(`Failed to send cancellation: ${I}`))),u(O)};this._responseHandlers.set(_,O=>{var D;if(!(!((D=s?.signal)===null||D===void 0)&&D.aborted)){if(O instanceof Error)return u(O);try{let I=t.parse(O.result);o(I)}catch(I){u(I)}}}),(b=s?.signal)===null||b===void 0||b.addEventListener("abort",()=>{var O;x((O=s?.signal)===null||O===void 0?void 0:O.reason)});let T=(c=s?.timeout)!==null&&c!==void 0?c:Qu,P=()=>x(new er(Xe.RequestTimeout,"Request timed out",{timeout:T}));this._setupTimeout(_,T,s?.maxTotalTimeout,P,(y=s?.resetTimeoutOnProgress)!==null&&y!==void 0?y:!1),this._transport.send(v,{relatedRequestId:r,resumptionToken:n,onresumptiontoken:l}).catch(O=>{this._cleanupTimeout(_),u(O)})})}async notification(e,t){var s,r;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((r=(s=this._options)===null||s===void 0?void 0:s.debouncedNotificationMethods)!==null&&r!==void 0?r:[]).includes(e.method)&&!e.params&&!t?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var u;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let f={...e,jsonrpc:"2.0"};(u=this._transport)===null||u===void 0||u.send(f,t).catch(p=>this._onerror(p))});return}let o={...e,jsonrpc:"2.0"};await this._transport.send(o,t)}setRequestHandler(e,t){let s=e.shape.method.value;this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(r,n)=>Promise.resolve(t(e.parse(r),n)))}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,t){this._notificationHandlers.set(e.shape.method.value,s=>Promise.resolve(t(e.parse(s))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function bn(a,e){return Object.entries(e).reduce((t,[s,r])=>(r&&typeof r=="object"?t[s]=t[s]?{...t[s],...r}:r:t[s]=r,t),{...a})}var xo=Ia(So(),1),ga=class extends Yt{constructor(e,t){var s;super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(It.options.map((r,n)=>[r,n])),this.isMessageIgnored=(r,n)=>{let l=this._loggingLevels.get(n);return l?this.LOG_LEVEL_SEVERITY.get(r)this._oninitialize(r)),this.setNotificationHandler(Fa,()=>{var r;return(r=this.oninitialized)===null||r===void 0?void 0:r.call(this)}),this._capabilities.logging&&this.setRequestHandler(Za,async(r,n)=>{var l;let o=n.sessionId||((l=n.requestInfo)===null||l===void 0?void 0:l.headers["mcp-session-id"])||void 0,{level:u}=r.params,f=It.safeParse(u);return f.success&&this._loggingLevels.set(o,f.data),{}})}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=bn(this._capabilities,e)}assertCapabilityForMethod(e){var t,s,r;switch(e){case"sampling/createMessage":if(!(!((t=this._clientCapabilities)===null||t===void 0)&&t.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!(!((s=this._clientCapabilities)===null||s===void 0)&&s.elicitation))throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!(!((r=this._clientCapabilities)===null||r===void 0)&&r.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/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (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"ping":case"initialize":break}}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:rn.includes(t)?t:Na,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"},Bt)}async createMessage(e,t){return this.request({method:"sampling/createMessage",params:e},Ba,t)}async elicitInput(e,t){let s=await this.request({method:"elicitation/create",params:e},Wa,t);if(s.action==="accept"&&s.content)try{let r=new xo.default,n=r.compile(e.requestedSchema);if(!n(s.content))throw new er(Xe.InvalidParams,`Elicitation response content does not match requested schema: ${r.errorsText(n.errors)}`)}catch(r){throw r instanceof er?r:new er(Xe.InternalError,`Error validating elicitation response: ${r}`)}return s}async listRoots(e,t){return this.request({method:"roots/list",params:e},Ka,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))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 _s=Ia(require("node:process"),1);var ya=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(` -`);if(e===-1)return null;let t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),Af(t)}clear(){this._buffer=void 0}};function Af(a){return fn.parse(JSON.parse(a))}function Po(a){return JSON.stringify(a)+` -`}var _a=class{constructor(e=_s.default.stdin,t=_s.default.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new ya,this._started=!1,this._ondata=s=>{this._readBuffer.append(s),this.processReadBuffer()},this._onerror=s=>{var r;(r=this.onerror)===null||r===void 0||r.call(this,s)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(var e,t;;)try{let s=this._readBuffer.readMessage();if(s===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,s)}catch(s){(t=this.onerror)===null||t===void 0||t.call(this,s)}}async close(){var e;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),(e=this.onclose)===null||e===void 0||e.call(this)}send(e){return new Promise(t=>{let s=Po(e);this._stdout.write(s)?t():this._stdout.once("drain",t)})}};var Oo=Symbol("Let zodToJsonSchema decide on which parser to use");var wo={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"},Ro=a=>typeof a=="string"?{...wo,name:a}:{...wo,...a};var To=a=>{let e=Ro(a),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[r._def,{def:r._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}};function bs(a,e,t,s){s?.errorMessages&&t&&(a.errorMessage={...a.errorMessage,[e]:t})}function ee(a,e,t,s,r){a[e]=t,bs(a,e,s,r)}var ba=(a,e)=>{let t=0;for(;tB(a.innerType._def,e);function Es(a,e,t){let s=t??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,n)=>Es(a,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Df(a,e)}}var Df=(a,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let s of a.checks)switch(s.kind){case"min":ee(t,"minimum",s.value,s.message,e);break;case"max":ee(t,"maximum",s.value,s.message,e);break}return t};function $o(a,e){return{...B(a.innerType._def,e),default:a.defaultValue()}}function Co(a,e){return e.effectStrategy==="input"?B(a.schema._def,e):fe(e)}function No(a){return{type:"string",enum:Array.from(a.values)}}var If=a=>"type"in a&&a.type==="string"?!1:"allOf"in a;function jo(a,e){let t=[B(a.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),B(a.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(n=>!!n),s=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,r=[];return t.forEach(n=>{if(If(n))r.push(...n.allOf),n.unevaluatedProperties===void 0&&(s=void 0);else{let l=n;if("additionalProperties"in n&&n.additionalProperties===!1){let{additionalProperties:o,...u}=n;l=u}else s=void 0;r.push(l)}}),r.length?{allOf:r,...s}:void 0}function Mo(a,e){let t=typeof a.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(a.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[a.value]}:{type:t==="bigint"?"integer":t,const:a.value}}var Ss,rr={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:()=>(Ss===void 0&&(Ss=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ss),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 Sa(a,e){let t={type:"string"};if(a.checks)for(let s of a.checks)switch(s.kind){case"min":ee(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,s.value):s.value,s.message,e);break;case"max":ee(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":tr(t,"email",s.message,e);break;case"format:idn-email":tr(t,"idn-email",s.message,e);break;case"pattern:zod":ke(t,rr.email,s.message,e);break}break;case"url":tr(t,"uri",s.message,e);break;case"uuid":tr(t,"uuid",s.message,e);break;case"regex":ke(t,s.regex,s.message,e);break;case"cuid":ke(t,rr.cuid,s.message,e);break;case"cuid2":ke(t,rr.cuid2,s.message,e);break;case"startsWith":ke(t,RegExp(`^${xs(s.value,e)}`),s.message,e);break;case"endsWith":ke(t,RegExp(`${xs(s.value,e)}$`),s.message,e);break;case"datetime":tr(t,"date-time",s.message,e);break;case"date":tr(t,"date",s.message,e);break;case"time":tr(t,"time",s.message,e);break;case"duration":tr(t,"duration",s.message,e);break;case"length":ee(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,s.value):s.value,s.message,e),ee(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,s.value):s.value,s.message,e);break;case"includes":{ke(t,RegExp(xs(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&tr(t,"ipv4",s.message,e),s.version!=="v4"&&tr(t,"ipv6",s.message,e);break}case"base64url":ke(t,rr.base64url,s.message,e);break;case"jwt":ke(t,rr.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&ke(t,rr.ipv4Cidr,s.message,e),s.version!=="v4"&&ke(t,rr.ipv6Cidr,s.message,e);break}case"emoji":ke(t,rr.emoji(),s.message,e);break;case"ulid":{ke(t,rr.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{tr(t,"binary",s.message,e);break}case"contentEncoding:base64":{ee(t,"contentEncoding","base64",s.message,e);break}case"pattern:zod":{ke(t,rr.base64,s.message,e);break}}break}case"nanoid":ke(t,rr.nanoid,s.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return t}function xs(a,e){return e.patternStrategy==="escape"?$f(a):a}var kf=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function $f(a){let e="";for(let t=0;tr.format)?(a.anyOf||(a.anyOf=[]),a.format&&(a.anyOf.push({format:a.format,...a.errorMessage&&s.errorMessages&&{errorMessage:{format:a.errorMessage.format}}}),delete a.format,a.errorMessage&&(delete a.errorMessage.format,Object.keys(a.errorMessage).length===0&&delete a.errorMessage)),a.anyOf.push({format:e,...t&&s.errorMessages&&{errorMessage:{format:t}}})):ee(a,"format",e,t,s)}function ke(a,e,t,s){a.pattern||a.allOf?.some(r=>r.pattern)?(a.allOf||(a.allOf=[]),a.pattern&&(a.allOf.push({pattern:a.pattern,...a.errorMessage&&s.errorMessages&&{errorMessage:{pattern:a.errorMessage.pattern}}}),delete a.pattern,a.errorMessage&&(delete a.errorMessage.pattern,Object.keys(a.errorMessage).length===0&&delete a.errorMessage)),a.allOf.push({pattern:Fo(e,s),...t&&s.errorMessages&&{errorMessage:{pattern:t}}})):ee(a,"pattern",Fo(e,s),t,s)}function Fo(a,e){if(!e.applyRegexFlags||!a.flags)return a.source;let t={i:a.flags.includes("i"),m:a.flags.includes("m"),s:a.flags.includes("s")},s=t.i?a.source.toLowerCase():a.source,r="",n=!1,l=!1,o=!1;for(let u=0;u()=>(e||a((e={exports:{}}).exports,e),e.exports),Vl=(a,e)=>{for(var t in e)Da(a,t,{get:e[t],enumerable:!0})},zl=(a,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Fl(e))!ql.call(a,r)&&r!==t&&Da(a,r,{get:()=>e[r],enumerable:!(s=Ml(e,r))||s.enumerable});return a};var Ia=(a,e,t)=>(t=a!=null?Ll(Ul(a)):{},zl(e||!a||!a.__esModule?Da(t,"default",{value:a,enumerable:!0}):t,a));var Sn=W((Xt,bn)=>{(function(a,e){typeof Xt=="object"&&typeof bn<"u"?e(Xt):typeof define=="function"&&define.amd?define(["exports"],e):e(a.URI=a.URI||{})})(Xt,(function(a){"use strict";function e(){for(var h=arguments.length,d=Array(h),g=0;g1){d[0]=d[0].slice(0,-1);for(var b=d.length-1,S=1;S= 0x80 (not a basic code point)","invalid-input":"Invalid input"},$=c-y,q=Math.floor,F=String.fromCharCode;function L(h){throw new RangeError(U[h])}function A(h,d){for(var g=[],b=h.length;b--;)g[b]=d(h[b]);return g}function k(h,d){var g=h.split("@"),b="";g.length>1&&(b=g[0]+"@",h=g[1]),h=h.replace(z,".");var S=h.split("."),j=A(S,d).join(".");return b+j}function M(h){for(var d=[],g=0,b=h.length;g=55296&&S<=56319&&g>1,d+=q(d/g);d>$*_>>1;S+=c)d=q(d/$);return q(S+($+1)*d/(d+v))},H=function(d){var g=[],b=d.length,S=0,j=x,Q=O,ae=d.lastIndexOf(R);ae<0&&(ae=0);for(var ie=0;ie=128&&L("not-basic"),g.push(d.charCodeAt(ie));for(var Ee=ae>0?ae+1:0;Ee=b&&L("invalid-input");var de=Y(d.charCodeAt(Ee++));(de>=c||de>q((E-S)/pe))&&L("overflow"),S+=de*pe;var ne=be<=Q?y:be>=Q+_?_:be-Q;if(deq(E/he)&&L("overflow"),pe*=he}var ce=g.length+1;Q=G(S-te,ce,te==0),q(S/ce)>E-j&&L("overflow"),j+=q(S/ce),S%=ce,g.splice(S++,0,j)}return String.fromCodePoint.apply(String,g)},me=function(d){var g=[];d=M(d);var b=d.length,S=x,j=0,Q=O,ae=!0,ie=!1,Ee=void 0;try{for(var te=d[Symbol.iterator](),pe;!(ae=(pe=te.next()).done);ae=!0){var be=pe.value;be<128&&g.push(F(be))}}catch(kr){ie=!0,Ee=kr}finally{try{!ae&&te.return&&te.return()}finally{if(ie)throw Ee}}var de=g.length,ne=de;for(de&&g.push(R);ne=S&&Ueq((E-j)/ze)&&L("overflow"),j+=(he-S)*ze,S=he;var sr=!0,$r=!1,fr=void 0;try{for(var yt=d[Symbol.iterator](),jt;!(sr=(jt=yt.next()).done);sr=!0){var Lt=jt.value;if(LtE&&L("overflow"),Lt==S){for(var Xr=j,et=c;;et+=c){var pr=et<=Q?y:et>=Q+_?_:et-Q;if(Xr>6|192).toString(16).toUpperCase()+"%"+(d&63|128).toString(16).toUpperCase():g="%"+(d>>12|224).toString(16).toUpperCase()+"%"+(d>>6&63|128).toString(16).toUpperCase()+"%"+(d&63|128).toString(16).toUpperCase(),g}function De(h){for(var d="",g=0,b=h.length;g=194&&S<224){if(b-g>=6){var j=parseInt(h.substr(g+4,2),16);d+=String.fromCharCode((S&31)<<6|j&63)}else d+=h.substr(g,6);g+=6}else if(S>=224){if(b-g>=9){var Q=parseInt(h.substr(g+4,2),16),ae=parseInt(h.substr(g+7,2),16);d+=String.fromCharCode((S&15)<<12|(Q&63)<<6|ae&63)}else d+=h.substr(g,9);g+=9}else d+=h.substr(g,3),g+=3}return d}function _r(h,d){function g(b){var S=De(b);return S.match(d.UNRESERVED)?S:b}return h.scheme&&(h.scheme=String(h.scheme).replace(d.PCT_ENCODED,g).toLowerCase().replace(d.NOT_SCHEME,"")),h.userinfo!==void 0&&(h.userinfo=String(h.userinfo).replace(d.PCT_ENCODED,g).replace(d.NOT_USERINFO,Se).replace(d.PCT_ENCODED,r)),h.host!==void 0&&(h.host=String(h.host).replace(d.PCT_ENCODED,g).toLowerCase().replace(d.NOT_HOST,Se).replace(d.PCT_ENCODED,r)),h.path!==void 0&&(h.path=String(h.path).replace(d.PCT_ENCODED,g).replace(h.scheme?d.NOT_PATH:d.NOT_PATH_NOSCHEME,Se).replace(d.PCT_ENCODED,r)),h.query!==void 0&&(h.query=String(h.query).replace(d.PCT_ENCODED,g).replace(d.NOT_QUERY,Se).replace(d.PCT_ENCODED,r)),h.fragment!==void 0&&(h.fragment=String(h.fragment).replace(d.PCT_ENCODED,g).replace(d.NOT_FRAGMENT,Se).replace(d.PCT_ENCODED,r)),h}function ur(h){return h.replace(/^0*(.*)/,"$1")||"0"}function _e(h,d){var g=h.match(d.IPV4ADDRESS)||[],b=p(g,2),S=b[1];return S?S.split(".").map(ur).join("."):h}function ve(h,d){var g=h.match(d.IPV6ADDRESS)||[],b=p(g,3),S=b[1],j=b[2];if(S){for(var Q=S.toLowerCase().split("::").reverse(),ae=p(Q,2),ie=ae[0],Ee=ae[1],te=Ee?Ee.split(":").map(ur):[],pe=ie.split(":").map(ur),be=d.IPV4ADDRESS.test(pe[pe.length-1]),de=be?7:8,ne=pe.length-de,he=Array(de),ce=0;ce1){var ue=he.slice(0,Fe.index),Ue=he.slice(Fe.index+Fe.length);Ve=ue.join(":")+"::"+Ue.join(":")}else Ve=he.join(":");return j&&(Ve+="%"+j),Ve}else return h}var Or=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Te="".match(/(){0}/)[1]===void 0;function oe(h){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g={},b=d.iri!==!1?f:u;d.reference==="suffix"&&(h=(d.scheme?d.scheme+":":"")+"//"+h);var S=h.match(Or);if(S){Te?(g.scheme=S[1],g.userinfo=S[3],g.host=S[4],g.port=parseInt(S[5],10),g.path=S[6]||"",g.query=S[7],g.fragment=S[8],isNaN(g.port)&&(g.port=S[5])):(g.scheme=S[1]||void 0,g.userinfo=h.indexOf("@")!==-1?S[3]:void 0,g.host=h.indexOf("//")!==-1?S[4]:void 0,g.port=parseInt(S[5],10),g.path=S[6]||"",g.query=h.indexOf("?")!==-1?S[7]:void 0,g.fragment=h.indexOf("#")!==-1?S[8]:void 0,isNaN(g.port)&&(g.port=h.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?S[4]:void 0)),g.host&&(g.host=ve(_e(g.host,b),b)),g.scheme===void 0&&g.userinfo===void 0&&g.host===void 0&&g.port===void 0&&!g.path&&g.query===void 0?g.reference="same-document":g.scheme===void 0?g.reference="relative":g.fragment===void 0?g.reference="absolute":g.reference="uri",d.reference&&d.reference!=="suffix"&&d.reference!==g.reference&&(g.error=g.error||"URI is not a "+d.reference+" reference.");var j=ye[(d.scheme||g.scheme||"").toLowerCase()];if(!d.unicodeSupport&&(!j||!j.unicodeSupport)){if(g.host&&(d.domainHost||j&&j.domainHost))try{g.host=se.toASCII(g.host.replace(b.PCT_ENCODED,De).toLowerCase())}catch(Q){g.error=g.error||"Host's domain name can not be converted to ASCII via punycode: "+Q}_r(g,u)}else _r(g,b);j&&j.parse&&j.parse(g,d)}else g.error=g.error||"URI can not be parsed.";return g}function Er(h,d){var g=d.iri!==!1?f:u,b=[];return h.userinfo!==void 0&&(b.push(h.userinfo),b.push("@")),h.host!==void 0&&b.push(ve(_e(String(h.host),g),g).replace(g.IPV6ADDRESS,function(S,j,Q){return"["+j+(Q?"%25"+Q:"")+"]"})),(typeof h.port=="number"||typeof h.port=="string")&&(b.push(":"),b.push(String(h.port))),b.length?b.join(""):void 0}var dr=/^\.\.?\//,Ar=/^\/\.(\/|$)/,Dr=/^\/\.\.(\/|$)/,Pe=/^\/?(?:.|\n)*?(?=\/|$)/;function qe(h){for(var d=[];h.length;)if(h.match(dr))h=h.replace(dr,"");else if(h.match(Ar))h=h.replace(Ar,"/");else if(h.match(Dr))h=h.replace(Dr,"/"),d.pop();else if(h==="."||h==="..")h="";else{var g=h.match(Pe);if(g){var b=g[0];h=h.slice(b.length),d.push(b)}else throw new Error("Unexpected dot segment condition")}return d.join("")}function Ce(h){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},g=d.iri?f:u,b=[],S=ye[(d.scheme||h.scheme||"").toLowerCase()];if(S&&S.serialize&&S.serialize(h,d),h.host&&!g.IPV6ADDRESS.test(h.host)){if(d.domainHost||S&&S.domainHost)try{h.host=d.iri?se.toUnicode(h.host):se.toASCII(h.host.replace(g.PCT_ENCODED,De).toLowerCase())}catch(ae){h.error=h.error||"Host's domain name can not be converted to "+(d.iri?"Unicode":"ASCII")+" via punycode: "+ae}}_r(h,g),d.reference!=="suffix"&&h.scheme&&(b.push(h.scheme),b.push(":"));var j=Er(h,d);if(j!==void 0&&(d.reference!=="suffix"&&b.push("//"),b.push(j),h.path&&h.path.charAt(0)!=="/"&&b.push("/")),h.path!==void 0){var Q=h.path;!d.absolutePath&&(!S||!S.absolutePath)&&(Q=qe(Q)),j===void 0&&(Q=Q.replace(/^\/\//,"/%2F")),b.push(Q)}return h.query!==void 0&&(b.push("?"),b.push(h.query)),h.fragment!==void 0&&(b.push("#"),b.push(h.fragment)),b.join("")}function Ie(h,d){var g=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},b=arguments[3],S={};return b||(h=oe(Ce(h,g),g),d=oe(Ce(d,g),g)),g=g||{},!g.tolerant&&d.scheme?(S.scheme=d.scheme,S.userinfo=d.userinfo,S.host=d.host,S.port=d.port,S.path=qe(d.path||""),S.query=d.query):(d.userinfo!==void 0||d.host!==void 0||d.port!==void 0?(S.userinfo=d.userinfo,S.host=d.host,S.port=d.port,S.path=qe(d.path||""),S.query=d.query):(d.path?(d.path.charAt(0)==="/"?S.path=qe(d.path):((h.userinfo!==void 0||h.host!==void 0||h.port!==void 0)&&!h.path?S.path="/"+d.path:h.path?S.path=h.path.slice(0,h.path.lastIndexOf("/")+1)+d.path:S.path=d.path,S.path=qe(S.path)),S.query=d.query):(S.path=h.path,d.query!==void 0?S.query=d.query:S.query=h.query),S.userinfo=h.userinfo,S.host=h.host,S.port=h.port),S.scheme=h.scheme),S.fragment=d.fragment,S}function tr(h,d,g){var b=l({scheme:"null"},g);return Ce(Ie(oe(h,b),oe(d,b),b,!0),b)}function Me(h,d){return typeof h=="string"?h=Ce(oe(h,d),d):s(h)==="object"&&(h=oe(Ce(h,d),d)),h}function Nt(h,d,g){return typeof h=="string"?h=Ce(oe(h,g),g):s(h)==="object"&&(h=Ce(h,g)),typeof d=="string"?d=Ce(oe(d,g),g):s(d)==="object"&&(d=Ce(d,g)),h===d}function Ra(h,d){return h&&h.toString().replace(!d||!d.iri?u.ESCAPE:f.ESCAPE,Se)}function Qe(h,d){return h&&h.toString().replace(!d||!d.iri?u.PCT_ENCODED:f.PCT_ENCODED,De)}var vt={scheme:"http",domainHost:!0,parse:function(d,g){return d.host||(d.error=d.error||"HTTP URIs must have a host."),d},serialize:function(d,g){var b=String(d.scheme).toLowerCase()==="https";return(d.port===(b?443:80)||d.port==="")&&(d.port=void 0),d.path||(d.path="/"),d}},$s={scheme:"https",domainHost:vt.domainHost,parse:vt.parse,serialize:vt.serialize};function ks(h){return typeof h.secure=="boolean"?h.secure:String(h.scheme).toLowerCase()==="wss"}var gt={scheme:"ws",domainHost:!0,parse:function(d,g){var b=d;return b.secure=ks(b),b.resourceName=(b.path||"/")+(b.query?"?"+b.query:""),b.path=void 0,b.query=void 0,b},serialize:function(d,g){if((d.port===(ks(d)?443:80)||d.port==="")&&(d.port=void 0),typeof d.secure=="boolean"&&(d.scheme=d.secure?"wss":"ws",d.secure=void 0),d.resourceName){var b=d.resourceName.split("?"),S=p(b,2),j=S[0],Q=S[1];d.path=j&&j!=="/"?j:void 0,d.query=Q,d.resourceName=void 0}return d.fragment=void 0,d}},Cs={scheme:"wss",domainHost:gt.domainHost,parse:gt.parse,serialize:gt.serialize},yl={},_l=!0,Ns="[A-Za-z0-9\\-\\.\\_\\~"+(_l?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",ar="[0-9A-Fa-f]",El=t(t("%[EFef]"+ar+"%"+ar+ar+"%"+ar+ar)+"|"+t("%[89A-Fa-f]"+ar+"%"+ar+ar)+"|"+t("%"+ar+ar)),bl="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Sl="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",Pl=e(Sl,'[\\"\\\\]'),xl="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",wl=new RegExp(Ns,"g"),Yr=new RegExp(El,"g"),Rl=new RegExp(e("[^]",bl,"[\\.]",'[\\"]',Pl),"g"),js=new RegExp(e("[^]",Ns,xl),"g"),Tl=js;function Ta(h){var d=De(h);return d.match(wl)?d:h}var Ls={scheme:"mailto",parse:function(d,g){var b=d,S=b.to=b.path?b.path.split(","):[];if(b.path=void 0,b.query){for(var j=!1,Q={},ae=b.query.split("&"),ie=0,Ee=ae.length;ie{"use strict";Pn.exports=function a(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var s,r,n;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(r=s;r--!==0;)if(!a(e[r],t[r]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(n=Object.keys(e),s=n.length,s!==Object.keys(t).length)return!1;for(r=s;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,n[r]))return!1;for(r=s;r--!==0;){var l=n[r];if(!a(e[l],t[l]))return!1}return!0}return e!==e&&t!==t}});var wn=W((qp,xn)=>{"use strict";xn.exports=function(e){for(var t=0,s=e.length,r=0,n;r=55296&&n<=56319&&r{"use strict";On.exports={copy:Ju,checkDataType:Qa,checkDataTypes:Gu,coerceToTypes:Yu,toHash:Ga,getProperty:Ya,escapeQuotes:Xa,equal:ea(),ucs2length:wn(),varOccurences:rd,varReplace:td,schemaHasRules:ad,schemaHasRulesExcept:sd,schemaUnknownRules:nd,toQuotedString:Ja,getPathExpr:od,getPath:id,getData:ud,unescapeFragment:dd,unescapeJsonPointer:rs,escapeFragment:fd,escapeJsonPointer:es};function Ju(a,e){e=e||{};for(var t in a)e[t]=a[t];return e}function Qa(a,e,t,s){var r=s?" !== ":" === ",n=s?" || ":" && ",l=s?"!":"",i=s?"":"!";switch(a){case"null":return e+r+"null";case"array":return l+"Array.isArray("+e+")";case"object":return"("+l+e+n+"typeof "+e+r+'"object"'+n+i+"Array.isArray("+e+"))";case"integer":return"(typeof "+e+r+'"number"'+n+i+"("+e+" % 1)"+n+e+r+e+(t?n+l+"isFinite("+e+")":"")+")";case"number":return"(typeof "+e+r+'"'+a+'"'+(t?n+l+"isFinite("+e+")":"")+")";default:return"typeof "+e+r+'"'+a+'"'}}function Gu(a,e,t){switch(a.length){case 1:return Qa(a[0],e,t,!0);default:var s="",r=Ga(a);r.array&&r.object&&(s=r.null?"(":"(!"+e+" || ",s+="typeof "+e+' !== "object")',delete r.null,delete r.array,delete r.object),r.number&&delete r.integer;for(var n in r)s+=(s?" && ":"")+Qa(n,e,t,!0);return s}}var Rn=Ga(["string","number","integer","boolean","null"]);function Yu(a,e){if(Array.isArray(e)){for(var t=[],s=0;s=e)throw new Error("Cannot access property/index "+s+" levels up, current level is "+e);return t[e-s]}if(s>e)throw new Error("Cannot access data "+s+" levels up, current level is "+e);if(n="data"+(e-s||""),!r)return n}for(var i=n,u=r.split("/"),f=0;f{"use strict";var pd=Jr();An.exports=hd;function hd(a){pd.copy(a,this)}});var In=W((Hp,Dn)=>{"use strict";var wr=Dn.exports=function(a,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var s=typeof t=="function"?t:t.pre||function(){},r=t.post||function(){};ra(e,s,r,a,"",a)};wr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0};wr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};wr.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};wr.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 ra(a,e,t,s,r,n,l,i,u,f){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,r,n,l,i,u,f);for(var p in s){var m=s[p];if(Array.isArray(m)){if(p in wr.arrayKeywords)for(var E=0;E{"use strict";var Dt=Sn(),$n=ea(),na=Jr(),ta=ts(),vd=In();Nn.exports=Tr;Tr.normalizeId=Rr;Tr.fullPath=aa;Tr.url=sa;Tr.ids=bd;Tr.inlineRef=as;Tr.schema=oa;function Tr(a,e,t){var s=this._refs[t];if(typeof s=="string")if(this._refs[s])s=this._refs[s];else return Tr.call(this,a,e,s);if(s=s||this._schemas[t],s instanceof ta)return as(s.schema,this._opts.inlineRefs)?s.schema:s.validate||this._compile(s);var r=oa.call(this,e,t),n,l,i;return r&&(n=r.schema,e=r.root,i=r.baseId),n instanceof ta?l=n.validate||a.call(this,n.schema,e,void 0,i):n!==void 0&&(l=as(n,this._opts.inlineRefs)?n:a.call(this,n,e,void 0,i)),l}function oa(a,e){var t=Dt.parse(e),s=Cn(t),r=aa(this._getId(a.schema));if(Object.keys(a.schema).length===0||s!==r){var n=Rr(s),l=this._refs[n];if(typeof l=="string")return gd.call(this,a,l,t);if(l instanceof ta)l.validate||this._compile(l),a=l;else if(l=this._schemas[n],l instanceof ta){if(l.validate||this._compile(l),n==Rr(e))return{schema:l,root:a,baseId:r};a=l}else return;if(!a.schema)return;r=aa(this._getId(a.schema))}return kn.call(this,t,r,a.schema,a)}function gd(a,e,t){var s=oa.call(this,a,e);if(s){var r=s.schema,n=s.baseId;a=s.root;var l=this._getId(r);return l&&(n=sa(n,l)),kn.call(this,t,n,r,a)}}var yd=na.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function kn(a,e,t,s){if(a.fragment=a.fragment||"",a.fragment.slice(0,1)=="/"){for(var r=a.fragment.split("/"),n=1;n{"use strict";var os=ia();Ln.exports={Validation:jn(Sd),MissingRef:jn(is)};function Sd(a){this.message="validation failed",this.errors=a,this.ajv=this.validation=!0}is.message=function(a,e){return"can't resolve reference "+e+" from id "+a};function is(a,e,t){this.message=t||is.message(a,e),this.missingRef=os.url(a,e),this.missingSchema=os.normalizeId(os.fullPath(this.missingRef))}function jn(a){return a.prototype=Object.create(Error.prototype),a.prototype.constructor=a,a}});var ls=W((Wp,Mn)=>{"use strict";Mn.exports=function(a,e){e||(e={}),typeof e=="function"&&(e={cmp:e});var t=typeof e.cycles=="boolean"?e.cycles:!1,s=e.cmp&&(function(n){return function(l){return function(i,u){var f={key:i,value:l[i]},p={key:u,value:l[u]};return n(f,p)}}})(e.cmp),r=[];return(function n(l){if(l&&l.toJSON&&typeof l.toJSON=="function"&&(l=l.toJSON()),l!==void 0){if(typeof l=="number")return isFinite(l)?""+l:"null";if(typeof l!="object")return JSON.stringify(l);var i,u;if(Array.isArray(l)){for(u="[",i=0;i{"use strict";Fn.exports=function(e,t,s){var r="",n=e.schema.$async===!0,l=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),i=e.self._getId(e.schema);if(e.opts.strictKeywords){var u=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(u){var f="unknown keyword: "+u;if(e.opts.strictKeywords==="log")e.logger.warn(f);else throw new Error(f)}}if(e.isTop&&(r+=" var validate = ",n&&(e.async=!0,r+="async "),r+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",i&&(e.opts.sourceCode||e.opts.processCode)&&(r+=" "+("/*# sourceURL="+i+" */")+" ")),typeof e.schema=="boolean"||!(l||e.schema.$ref)){var t="false schema",p=e.level,m=e.dataLevel,E=e.schema[t],c=e.schemaPath+e.util.getProperty(t),y=e.errSchemaPath+"/"+t,D=!e.opts.allErrors,U,_="data"+(m||""),R="valid"+p;if(e.schema===!1){e.isTop?D=!0:r+=" var "+R+" = false; ";var v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(U||"false schema")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(y)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'boolean schema is false' "),e.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+_+" "),r+=" } "):r+=" {} ";var P=r;r=v.pop(),!e.compositeRule&&D?e.async?r+=" throw new ValidationError(["+P+"]); ":r+=" validate.errors = ["+P+"]; return false; ":r+=" var err = "+P+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else e.isTop?n?r+=" return data; ":r+=" validate.errors = null; return true; ":r+=" var "+R+" = true; ";return e.isTop&&(r+=" }; return validate; "),r}if(e.isTop){var O=e.isTop,p=e.level=0,m=e.dataLevel=0,_="data";if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[""],e.schema.default!==void 0&&e.opts.useDefaults&&e.opts.strictDefaults){var x="default is ignored in the schema root";if(e.opts.strictDefaults==="log")e.logger.warn(x);else throw new Error(x)}r+=" var vErrors = null; ",r+=" var errors = 0; ",r+=" if (rootData === undefined) rootData = data; "}else{var p=e.level,m=e.dataLevel,_="data"+(m||"");if(i&&(e.baseId=e.resolve.url(e.baseId,i)),n&&!e.async)throw new Error("async schema in sync schema");r+=" var errs_"+p+" = errors;"}var R="valid"+p,D=!e.opts.allErrors,I="",z="",U,$=e.schema.type,q=Array.isArray($);if($&&e.opts.nullable&&e.schema.nullable===!0&&(q?$.indexOf("null")==-1&&($=$.concat("null")):$!="null"&&($=[$,"null"],q=!0)),q&&$.length==1&&($=$[0],q=!1),e.schema.$ref&&l){if(e.opts.extendRefs=="fail")throw new Error('$ref: validation keywords used in schema at path "'+e.errSchemaPath+'" (see option extendRefs)');e.opts.extendRefs!==!0&&(l=!1,e.logger.warn('$ref: keywords ignored in schema at path "'+e.errSchemaPath+'"'))}if(e.schema.$comment&&e.opts.$comment&&(r+=" "+e.RULES.all.$comment.code(e,"$comment")),$){if(e.opts.coerceTypes)var F=e.util.coerceToTypes(e.opts.coerceTypes,$);var L=e.RULES.types[$];if(F||q||L===!0||L&&!Pe(L)){var c=e.schemaPath+".type",y=e.errSchemaPath+"/type",c=e.schemaPath+".type",y=e.errSchemaPath+"/type",A=q?"checkDataTypes":"checkDataType";if(r+=" if ("+e.util[A]($,_,e.opts.strictNumbers,!0)+") { ",F){var k="dataType"+p,M="coerced"+p;r+=" var "+k+" = typeof "+_+"; var "+M+" = undefined; ",e.opts.coerceTypes=="array"&&(r+=" if ("+k+" == 'object' && Array.isArray("+_+") && "+_+".length == 1) { "+_+" = "+_+"[0]; "+k+" = typeof "+_+"; if ("+e.util.checkDataType(e.schema.type,_,e.opts.strictNumbers)+") "+M+" = "+_+"; } "),r+=" if ("+M+" !== undefined) ; ";var le=F;if(le)for(var Y,re=-1,G=le.length-1;re{"use strict";var ca=ia(),da=Jr(),qn=la(),Pd=ls(),Un=cs(),xd=da.ucs2length,wd=ea(),Rd=qn.Validation;zn.exports=us;function us(a,e,t,s){var r=this,n=this._opts,l=[void 0],i={},u=[],f={},p=[],m={},E=[];e=e||{schema:a,refVal:l,refs:i};var c=Td.call(this,a,e,s),y=this._compilations[c.index];if(c.compiling)return y.callValidate=x;var _=this._formats,v=this.RULES;try{var P=R(a,e,t,s);y.validate=P;var O=y.callValidate;return O&&(O.schema=P.schema,O.errors=null,O.refs=P.refs,O.refVal=P.refVal,O.root=P.root,O.$async=P.$async,n.sourceCode&&(O.source=P.source)),P}finally{Od.call(this,a,e,s)}function x(){var A=y.validate,k=A.apply(this,arguments);return x.errors=A.errors,k}function R(A,k,M,le){var Y=!k||k&&k.schema==A;if(k.schema!=e.schema)return us.call(r,A,k,M,le);var re=A.$async===!0,G=Un({isTop:!0,schema:A,isRoot:Y,baseId:le,root:k,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:qn.MissingRef,RULES:v,validate:Un,util:da,resolve:ca,resolveRef:D,usePattern:q,useDefault:F,useCustomRule:L,opts:n,formats:_,logger:r.logger,self:r});G=ua(l,Id)+ua(u,Ad)+ua(p,Dd)+ua(E,$d)+G,n.processCode&&(G=n.processCode(G,A));var H;try{var me=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",G);H=me(r,v,_,e,l,p,E,wd,xd,Rd),l[0]=H}catch(Re){throw r.logger.error("Error compiling schema, function code:",G),Re}return H.schema=A,H.errors=null,H.refs=i,H.refVal=l,H.root=Y?H:k,re&&(H.$async=!0),n.sourceCode===!0&&(H.source={code:G,patterns:u,defaults:p}),H}function D(A,k,M){k=ca.url(A,k);var le=i[k],Y,re;if(le!==void 0)return Y=l[le],re="refVal["+le+"]",$(Y,re);if(!M&&e.refs){var G=e.refs[k];if(G!==void 0)return Y=e.refVal[G],re=I(k,Y),$(Y,re)}re=I(k);var H=ca.call(r,R,e,k);if(H===void 0){var me=t&&t[k];me&&(H=ca.inlineRef(me,n.inlineRefs)?me:us.call(r,me,e,t,A))}if(H===void 0)z(k);else return U(k,H),$(H,re)}function I(A,k){var M=l.length;return l[M]=k,i[A]=M,"refVal"+M}function z(A){delete i[A]}function U(A,k){var M=i[A];l[M]=k}function $(A,k){return typeof A=="object"||typeof A=="boolean"?{code:k,schema:A,inline:!0}:{code:k,$async:A&&!!A.$async}}function q(A){var k=f[A];return k===void 0&&(k=f[A]=u.length,u[k]=A),"pattern"+k}function F(A){switch(typeof A){case"boolean":case"number":return""+A;case"string":return da.toQuotedString(A);case"object":if(A===null)return"null";var k=Pd(A),M=m[k];return M===void 0&&(M=m[k]=p.length,p[M]=A),"default"+M}}function L(A,k,M,le){if(r._opts.validateSchema!==!1){var Y=A.definition.dependencies;if(Y&&!Y.every(function(Se){return Object.prototype.hasOwnProperty.call(M,Se)}))throw new Error("parent schema must have all required keywords: "+Y.join(","));var re=A.definition.validateSchema;if(re){var G=re(k);if(!G){var H="keyword schema is invalid: "+r.errorsText(re.errors);if(r._opts.validateSchema=="log")r.logger.error(H);else throw new Error(H)}}}var me=A.definition.compile,Re=A.definition.inline,Ae=A.definition.macro,se;if(me)se=me.call(r,k,M,le);else if(Ae)se=Ae.call(r,k,M,le),n.validateSchema!==!1&&r.validateSchema(se,!0);else if(Re)se=Re.call(r,le,A.keyword,k,M);else if(se=A.definition.validate,!se)return;if(se===void 0)throw new Error('custom keyword "'+A.keyword+'"failed to compile');var ye=E.length;return E[ye]=se,{code:"customRule"+ye,validate:se}}}function Td(a,e,t){var s=Vn.call(this,a,e,t);return s>=0?{index:s,compiling:!0}:(s=this._compilations.length,this._compilations[s]={schema:a,root:e,baseId:t},{index:s,compiling:!1})}function Od(a,e,t){var s=Vn.call(this,a,e,t);s>=0&&this._compilations.splice(s,1)}function Vn(a,e,t){for(var s=0;s{"use strict";var fa=Zn.exports=function(){this._cache={}};fa.prototype.put=function(e,t){this._cache[e]=t};fa.prototype.get=function(e){return this._cache[e]};fa.prototype.del=function(e){delete this._cache[e]};fa.prototype.clear=function(){this._cache={}}});var so=W((Gp,ao)=>{"use strict";var kd=Jr(),Cd=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Nd=[0,31,28,31,30,31,30,31,31,30,31,30,31],jd=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Wn=/^(?=.{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,Ld=/^(?:[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,Md=/^(?:[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,Kn=/^(?:(?:[^\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,Qn=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,Jn=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Gn=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Yn=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Xn=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;ao.exports=pa;function pa(a){return a=a=="full"?"full":"fast",kd.copy(pa[a])}pa.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\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,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":Kn,url:Qn,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,hostname:Wn,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[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}))|:)))(?:%.+)?\s*$/i,regex:to,uuid:Jn,"json-pointer":Gn,"json-pointer-uri-fragment":Yn,"relative-json-pointer":Xn};pa.full={date:eo,time:ro,"date-time":qd,uri:zd,"uri-reference":Md,"uri-template":Kn,url:Qn,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:Wn,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[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}))|:)))(?:%.+)?\s*$/i,regex:to,uuid:Jn,"json-pointer":Gn,"json-pointer-uri-fragment":Yn,"relative-json-pointer":Xn};function Fd(a){return a%4===0&&(a%100!==0||a%400===0)}function eo(a){var e=a.match(Cd);if(!e)return!1;var t=+e[1],s=+e[2],r=+e[3];return s>=1&&s<=12&&r>=1&&r<=(s==2&&Fd(t)?29:Nd[s])}function ro(a,e){var t=a.match(jd);if(!t)return!1;var s=t[1],r=t[2],n=t[3],l=t[5];return(s<=23&&r<=59&&n<=59||s==23&&r==59&&n==60)&&(!e||l)}var Ud=/t|\s/i;function qd(a){var e=a.split(Ud);return e.length==2&&eo(e[0])&&ro(e[1],!0)}var Vd=/\/|:/;function zd(a){return Vd.test(a)&&Ld.test(a)}var Hd=/[^\\]\\Z/;function to(a){if(Hd.test(a))return!1;try{return new RegExp(a),!0}catch{return!1}}});var oo=W((Yp,no)=>{"use strict";no.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.errSchemaPath+"/"+t,f=!e.opts.allErrors,p="data"+(l||""),m="valid"+n,E,c;if(i=="#"||i=="#/")e.isRoot?(E=e.async,c="validate"):(E=e.root.schema.$async===!0,c="root.refVal[0]");else{var y=e.resolveRef(e.baseId,i,e.isRoot);if(y===void 0){var _=e.MissingRefError.message(e.baseId,i);if(e.opts.missingRefs=="fail"){e.logger.error(_);var v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { ref: '"+e.util.escapeQuotes(i)+"' } ",e.opts.messages!==!1&&(r+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(i)+"' "),e.opts.verbose&&(r+=" , schema: "+e.util.toQuotedString(i)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+p+" "),r+=" } "):r+=" {} ";var P=r;r=v.pop(),!e.compositeRule&&f?e.async?r+=" throw new ValidationError(["+P+"]); ":r+=" validate.errors = ["+P+"]; return false; ":r+=" var err = "+P+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f&&(r+=" if (false) { ")}else if(e.opts.missingRefs=="ignore")e.logger.warn(_),f&&(r+=" if (true) { ");else throw new e.MissingRefError(e.baseId,i,_)}else if(y.inline){var O=e.util.copy(e);O.level++;var x="valid"+O.level;O.schema=y.schema,O.schemaPath="",O.errSchemaPath=i;var R=e.validate(O).replace(/validate\.schema/g,y.code);r+=" "+R+" ",f&&(r+=" if ("+x+") { ")}else E=y.$async===!0||e.async&&y.$async!==!1,c=y.code}if(c){var v=v||[];v.push(r),r="",e.opts.passContext?r+=" "+c+".call(this, ":r+=" "+c+"( ",r+=" "+p+", (dataPath || '')",e.errorPath!='""'&&(r+=" + "+e.errorPath);var D=l?"data"+(l-1||""):"parentData",I=l?e.dataPathArr[l]:"parentDataProperty";r+=" , "+D+" , "+I+", rootData) ";var z=r;if(r=v.pop(),E){if(!e.async)throw new Error("async schema referenced by sync schema");f&&(r+=" var "+m+"; "),r+=" try { await "+z+"; ",f&&(r+=" "+m+" = true; "),r+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",f&&(r+=" "+m+" = false; "),r+=" } ",f&&(r+=" if ("+m+") { ")}else r+=" if (!"+z+") { if (vErrors === null) vErrors = "+c+".errors; else vErrors = vErrors.concat("+c+".errors); errors = vErrors.length; } ",f&&(r+=" else { ")}return r}});var lo=W((Xp,io)=>{"use strict";io.exports=function(e,t,s){var r=" ",n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),i=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,f=e.util.copy(e),p="";f.level++;var m="valid"+f.level,E=f.baseId,c=!0,y=n;if(y)for(var _,v=-1,P=y.length-1;v0||_===!1:e.util.schemaHasRules(_,e.RULES.all))&&(c=!1,f.schema=_,f.schemaPath=l+"["+v+"]",f.errSchemaPath=i+"/"+v,r+=" "+e.validate(f)+" ",f.baseId=E,u&&(r+=" if ("+m+") { ",p+="}"));return u&&(c?r+=" if (true) { ":r+=" "+p.slice(0,-1)+" "),r}});var uo=W((eh,co)=>{"use strict";co.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c="errs__"+n,y=e.util.copy(e),_="";y.level++;var v="valid"+y.level,P=i.every(function(U){return e.opts.strictKeywords?typeof U=="object"&&Object.keys(U).length>0||U===!1:e.util.schemaHasRules(U,e.RULES.all)});if(P){var O=y.baseId;r+=" var "+c+" = errors; var "+E+" = false; ";var x=e.compositeRule;e.compositeRule=y.compositeRule=!0;var R=i;if(R)for(var D,I=-1,z=R.length-1;I{"use strict";fo.exports=function(e,t,s){var r=" ",n=e.schema[t],l=e.errSchemaPath+"/"+t,i=!e.opts.allErrors,u=e.util.toQuotedString(n);return e.opts.$comment===!0?r+=" console.log("+u+");":typeof e.opts.$comment=="function"&&(r+=" self._opts.$comment("+u+", "+e.util.toQuotedString(l)+", validate.root.schema);"),r}});var mo=W((th,ho)=>{"use strict";ho.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c=e.opts.$data&&i&&i.$data,y;c?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",y="schema"+n):y=i,c||(r+=" var schema"+n+" = validate.schema"+u+";"),r+="var "+E+" = equal("+m+", schema"+n+"); if (!"+E+") { ";var _=_||[];_.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { allowedValue: schema"+n+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be equal to constant' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var v=r;return r=_.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+v+"]); ":r+=" validate.errors = ["+v+"]; return false; ":r+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" }",p&&(r+=" else { "),r}});var go=W((ah,vo)=>{"use strict";vo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c="errs__"+n,y=e.util.copy(e),_="";y.level++;var v="valid"+y.level,P="i"+n,O=y.dataLevel=e.dataLevel+1,x="data"+O,R=e.baseId,D=e.opts.strictKeywords?typeof i=="object"&&Object.keys(i).length>0||i===!1:e.util.schemaHasRules(i,e.RULES.all);if(r+="var "+c+" = errors;var "+E+";",D){var I=e.compositeRule;e.compositeRule=y.compositeRule=!0,y.schema=i,y.schemaPath=u,y.errSchemaPath=f,r+=" var "+v+" = false; for (var "+P+" = 0; "+P+" < "+m+".length; "+P+"++) { ",y.errorPath=e.util.getPathExpr(e.errorPath,P,e.opts.jsonPointers,!0);var z=m+"["+P+"]";y.dataPathArr[O]=P;var U=e.validate(y);y.baseId=R,e.util.varOccurences(U,x)<2?r+=" "+e.util.varReplace(U,x,z)+" ":r+=" var "+x+" = "+z+"; "+U+" ",r+=" if ("+v+") break; } ",e.compositeRule=y.compositeRule=I,r+=" "+_+" if (!"+v+") {"}else r+=" if ("+m+".length == 0) {";var $=$||[];$.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should contain a valid item' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var q=r;return r=$.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+q+"]); ":r+=" validate.errors = ["+q+"]; return false; ":r+=" var err = "+q+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { ",D&&(r+=" errors = "+c+"; if (vErrors !== null) { if ("+c+") vErrors.length = "+c+"; else vErrors = null; } "),e.opts.allErrors&&(r+=" } "),r}});var _o=W((sh,yo)=>{"use strict";yo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="errs__"+n,c=e.util.copy(e),y="";c.level++;var _="valid"+c.level,v={},P={},O=e.opts.ownProperties;for(I in i)if(I!="__proto__"){var x=i[I],R=Array.isArray(x)?P:v;R[I]=x}r+="var "+E+" = errors;";var D=e.errorPath;r+="var missing"+n+";";for(var I in P)if(R=P[I],R.length){if(r+=" if ( "+m+e.util.getProperty(I)+" !== undefined ",O&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(I)+"') "),p){r+=" && ( ";var z=R;if(z)for(var U,$=-1,q=z.length-1;$0||x===!1:e.util.schemaHasRules(x,e.RULES.all))&&(r+=" "+_+" = true; if ( "+m+e.util.getProperty(I)+" !== undefined ",O&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(I)+"') "),r+=") { ",c.schema=x,c.schemaPath=u+e.util.getProperty(I),c.errSchemaPath=f+"/"+e.util.escapeFragment(I),r+=" "+e.validate(c)+" ",c.baseId=H,r+=" } ",p&&(r+=" if ("+_+") { ",y+="}"))}return p&&(r+=" "+y+" if ("+E+" == errors) {"),r}});var bo=W((nh,Eo)=>{"use strict";Eo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c=e.opts.$data&&i&&i.$data,y;c?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",y="schema"+n):y=i;var _="i"+n,v="schema"+n;c||(r+=" var "+v+" = validate.schema"+u+";"),r+="var "+E+";",c&&(r+=" if (schema"+n+" === undefined) "+E+" = true; else if (!Array.isArray(schema"+n+")) "+E+" = false; else {"),r+=""+E+" = false;for (var "+_+"=0; "+_+"<"+v+".length; "+_+"++) if (equal("+m+", "+v+"["+_+"])) { "+E+" = true; break; }",c&&(r+=" } "),r+=" if (!"+E+") { ";var P=P||[];P.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { allowedValues: schema"+n+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var O=r;return r=P.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+O+"]); ":r+=" validate.errors = ["+O+"]; return false; ":r+=" var err = "+O+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" }",p&&(r+=" else { "),r}});var Po=W((oh,So)=>{"use strict";So.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||"");if(e.opts.format===!1)return p&&(r+=" if (true) { "),r;var E=e.opts.$data&&i&&i.$data,c;E?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=i;var y=e.opts.unknownFormats,_=Array.isArray(y);if(E){var v="format"+n,P="isObject"+n,O="formatType"+n;r+=" var "+v+" = formats["+c+"]; var "+P+" = typeof "+v+" == 'object' && !("+v+" instanceof RegExp) && "+v+".validate; var "+O+" = "+P+" && "+v+".type || 'string'; if ("+P+") { ",e.async&&(r+=" var async"+n+" = "+v+".async; "),r+=" "+v+" = "+v+".validate; } if ( ",E&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'string') || "),r+=" (",y!="ignore"&&(r+=" ("+c+" && !"+v+" ",_&&(r+=" && self._opts.unknownFormats.indexOf("+c+") == -1 "),r+=") || "),r+=" ("+v+" && "+O+" == '"+s+"' && !(typeof "+v+" == 'function' ? ",e.async?r+=" (async"+n+" ? await "+v+"("+m+") : "+v+"("+m+")) ":r+=" "+v+"("+m+") ",r+=" : "+v+".test("+m+"))))) {"}else{var v=e.formats[i];if(!v){if(y=="ignore")return e.logger.warn('unknown format "'+i+'" ignored in schema at path "'+e.errSchemaPath+'"'),p&&(r+=" if (true) { "),r;if(_&&y.indexOf(i)>=0)return p&&(r+=" if (true) { "),r;throw new Error('unknown format "'+i+'" is used in schema at path "'+e.errSchemaPath+'"')}var P=typeof v=="object"&&!(v instanceof RegExp)&&v.validate,O=P&&v.type||"string";if(P){var x=v.async===!0;v=v.validate}if(O!=s)return p&&(r+=" if (true) { "),r;if(x){if(!e.async)throw new Error("async format in sync schema");var R="formats"+e.util.getProperty(i)+".validate";r+=" if (!(await "+R+"("+m+"))) { "}else{r+=" if (! ";var R="formats"+e.util.getProperty(i);P&&(R+=".validate"),typeof v=="function"?r+=" "+R+"("+m+") ":r+=" "+R+".test("+m+") ",r+=") { "}}var D=D||[];D.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { format: ",E?r+=""+c:r+=""+e.util.toQuotedString(i),r+=" } ",e.opts.messages!==!1&&(r+=` , message: 'should match format "`,E?r+="' + "+c+" + '":r+=""+e.util.escapeQuotes(i),r+=`"' `),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+u:r+=""+e.util.toQuotedString(i),r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var I=r;return r=D.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+I+"]); ":r+=" validate.errors = ["+I+"]; return false; ":r+=" var err = "+I+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",p&&(r+=" else { "),r}});var wo=W((ih,xo)=>{"use strict";xo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c="errs__"+n,y=e.util.copy(e);y.level++;var _="valid"+y.level,v=e.schema.then,P=e.schema.else,O=v!==void 0&&(e.opts.strictKeywords?typeof v=="object"&&Object.keys(v).length>0||v===!1:e.util.schemaHasRules(v,e.RULES.all)),x=P!==void 0&&(e.opts.strictKeywords?typeof P=="object"&&Object.keys(P).length>0||P===!1:e.util.schemaHasRules(P,e.RULES.all)),R=y.baseId;if(O||x){var D;y.createErrors=!1,y.schema=i,y.schemaPath=u,y.errSchemaPath=f,r+=" var "+c+" = errors; var "+E+" = true; ";var I=e.compositeRule;e.compositeRule=y.compositeRule=!0,r+=" "+e.validate(y)+" ",y.baseId=R,y.createErrors=!0,r+=" errors = "+c+"; if (vErrors !== null) { if ("+c+") vErrors.length = "+c+"; else vErrors = null; } ",e.compositeRule=y.compositeRule=I,O?(r+=" if ("+_+") { ",y.schema=e.schema.then,y.schemaPath=e.schemaPath+".then",y.errSchemaPath=e.errSchemaPath+"/then",r+=" "+e.validate(y)+" ",y.baseId=R,r+=" "+E+" = "+_+"; ",O&&x?(D="ifClause"+n,r+=" var "+D+" = 'then'; "):D="'then'",r+=" } ",x&&(r+=" else { ")):r+=" if (!"+_+") { ",x&&(y.schema=e.schema.else,y.schemaPath=e.schemaPath+".else",y.errSchemaPath=e.errSchemaPath+"/else",r+=" "+e.validate(y)+" ",y.baseId=R,r+=" "+E+" = "+_+"; ",O&&x?(D="ifClause"+n,r+=" var "+D+" = 'else'; "):D="'else'",r+=" } "),r+=" if (!"+E+") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { failingKeyword: "+D+" } ",e.opts.messages!==!1&&(r+=` , message: 'should match "' + `+D+` + '" schema' `),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?r+=" throw new ValidationError(vErrors); ":r+=" validate.errors = vErrors; return false; "),r+=" } ",p&&(r+=" else { ")}else p&&(r+=" if (true) { ");return r}});var To=W((lh,Ro)=>{"use strict";Ro.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c="errs__"+n,y=e.util.copy(e),_="";y.level++;var v="valid"+y.level,P="i"+n,O=y.dataLevel=e.dataLevel+1,x="data"+O,R=e.baseId;if(r+="var "+c+" = errors;var "+E+";",Array.isArray(i)){var D=e.schema.additionalItems;if(D===!1){r+=" "+E+" = "+m+".length <= "+i.length+"; ";var I=f;f=e.errSchemaPath+"/additionalItems",r+=" if (!"+E+") { ";var z=z||[];z.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { limit: "+i.length+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have more than "+i.length+" items' "),e.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var U=r;r=z.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+U+"]); ":r+=" validate.errors = ["+U+"]; return false; ":r+=" var err = "+U+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",f=I,p&&(_+="}",r+=" else { ")}var $=i;if($){for(var q,F=-1,L=$.length-1;F0||q===!1:e.util.schemaHasRules(q,e.RULES.all)){r+=" "+v+" = true; if ("+m+".length > "+F+") { ";var A=m+"["+F+"]";y.schema=q,y.schemaPath=u+"["+F+"]",y.errSchemaPath=f+"/"+F,y.errorPath=e.util.getPathExpr(e.errorPath,F,e.opts.jsonPointers,!0),y.dataPathArr[O]=F;var k=e.validate(y);y.baseId=R,e.util.varOccurences(k,x)<2?r+=" "+e.util.varReplace(k,x,A)+" ":r+=" var "+x+" = "+A+"; "+k+" ",r+=" } ",p&&(r+=" if ("+v+") { ",_+="}")}}if(typeof D=="object"&&(e.opts.strictKeywords?typeof D=="object"&&Object.keys(D).length>0||D===!1:e.util.schemaHasRules(D,e.RULES.all))){y.schema=D,y.schemaPath=e.schemaPath+".additionalItems",y.errSchemaPath=e.errSchemaPath+"/additionalItems",r+=" "+v+" = true; if ("+m+".length > "+i.length+") { for (var "+P+" = "+i.length+"; "+P+" < "+m+".length; "+P+"++) { ",y.errorPath=e.util.getPathExpr(e.errorPath,P,e.opts.jsonPointers,!0);var A=m+"["+P+"]";y.dataPathArr[O]=P;var k=e.validate(y);y.baseId=R,e.util.varOccurences(k,x)<2?r+=" "+e.util.varReplace(k,x,A)+" ":r+=" var "+x+" = "+A+"; "+k+" ",p&&(r+=" if (!"+v+") break; "),r+=" } } ",p&&(r+=" if ("+v+") { ",_+="}")}}else if(e.opts.strictKeywords?typeof i=="object"&&Object.keys(i).length>0||i===!1:e.util.schemaHasRules(i,e.RULES.all)){y.schema=i,y.schemaPath=u,y.errSchemaPath=f,r+=" for (var "+P+" = 0; "+P+" < "+m+".length; "+P+"++) { ",y.errorPath=e.util.getPathExpr(e.errorPath,P,e.opts.jsonPointers,!0);var A=m+"["+P+"]";y.dataPathArr[O]=P;var k=e.validate(y);y.baseId=R,e.util.varOccurences(k,x)<2?r+=" "+e.util.varReplace(k,x,A)+" ":r+=" var "+x+" = "+A+"; "+k+" ",p&&(r+=" if (!"+v+") break; "),r+=" }"}return p&&(r+=" "+_+" if ("+c+" == errors) {"),r}});var ds=W((ch,Oo)=>{"use strict";Oo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,R,m="data"+(l||""),E=e.opts.$data&&i&&i.$data,c;E?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=i;var y=t=="maximum",_=y?"exclusiveMaximum":"exclusiveMinimum",v=e.schema[_],P=e.opts.$data&&v&&v.$data,O=y?"<":">",x=y?">":"<",R=void 0;if(!(E||typeof i=="number"||i===void 0))throw new Error(t+" must be number");if(!(P||v===void 0||typeof v=="number"||typeof v=="boolean"))throw new Error(_+" must be number or boolean");if(P){var D=e.util.getData(v.$data,l,e.dataPathArr),I="exclusive"+n,z="exclType"+n,U="exclIsNumber"+n,$="op"+n,q="' + "+$+" + '";r+=" var schemaExcl"+n+" = "+D+"; ",D="schemaExcl"+n,r+=" var "+I+"; var "+z+" = typeof "+D+"; if ("+z+" != 'boolean' && "+z+" != 'undefined' && "+z+" != 'number') { ";var R=_,F=F||[];F.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(R||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: '"+_+" should be boolean' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var L=r;r=F.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+L+"]); ":r+=" validate.errors = ["+L+"]; return false; ":r+=" var err = "+L+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else if ( ",E&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" "+z+" == 'number' ? ( ("+I+" = "+c+" === undefined || "+D+" "+O+"= "+c+") ? "+m+" "+x+"= "+D+" : "+m+" "+x+" "+c+" ) : ( ("+I+" = "+D+" === true) ? "+m+" "+x+"= "+c+" : "+m+" "+x+" "+c+" ) || "+m+" !== "+m+") { var op"+n+" = "+I+" ? '"+O+"' : '"+O+"='; ",i===void 0&&(R=_,f=e.errSchemaPath+"/"+_,c=D,E=P)}else{var U=typeof v=="number",q=O;if(U&&E){var $="'"+q+"'";r+=" if ( ",E&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" ( "+c+" === undefined || "+v+" "+O+"= "+c+" ? "+m+" "+x+"= "+v+" : "+m+" "+x+" "+c+" ) || "+m+" !== "+m+") { "}else{U&&i===void 0?(I=!0,R=_,f=e.errSchemaPath+"/"+_,c=v,x+="="):(U&&(c=Math[y?"min":"max"](v,i)),v===(U?c:!0)?(I=!0,R=_,f=e.errSchemaPath+"/"+_,x+="="):(I=!1,q+="="));var $="'"+q+"'";r+=" if ( ",E&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" "+m+" "+x+" "+c+" || "+m+" !== "+m+") { "}}R=R||t;var F=F||[];F.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(R||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { comparison: "+$+", limit: "+c+", exclusive: "+I+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be "+q+" ",E?r+="' + "+c:r+=""+c+"'"),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+u:r+=""+i,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var L=r;return r=F.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+L+"]); ":r+=" validate.errors = ["+L+"]; return false; ":r+=" var err = "+L+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",p&&(r+=" else { "),r}});var fs=W((uh,Ao)=>{"use strict";Ao.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(l||""),E=e.opts.$data&&i&&i.$data,c;if(E?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=i,!(E||typeof i=="number"))throw new Error(t+" must be number");var y=t=="maxItems"?">":"<";r+="if ( ",E&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" "+m+".length "+y+" "+c+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { limit: "+c+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have ",t=="maxItems"?r+="more":r+="fewer",r+=" than ",E?r+="' + "+c+" + '":r+=""+i,r+=" items' "),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+u:r+=""+i,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var P=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+P+"]); ":r+=" validate.errors = ["+P+"]; return false; ":r+=" var err = "+P+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var ps=W((dh,Do)=>{"use strict";Do.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(l||""),E=e.opts.$data&&i&&i.$data,c;if(E?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=i,!(E||typeof i=="number"))throw new Error(t+" must be number");var y=t=="maxLength"?">":"<";r+="if ( ",E&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),e.opts.unicode===!1?r+=" "+m+".length ":r+=" ucs2length("+m+") ",r+=" "+y+" "+c+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { limit: "+c+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be ",t=="maxLength"?r+="longer":r+="shorter",r+=" than ",E?r+="' + "+c+" + '":r+=""+i,r+=" characters' "),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+u:r+=""+i,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var P=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+P+"]); ":r+=" validate.errors = ["+P+"]; return false; ":r+=" var err = "+P+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var hs=W((fh,Io)=>{"use strict";Io.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(l||""),E=e.opts.$data&&i&&i.$data,c;if(E?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=i,!(E||typeof i=="number"))throw new Error(t+" must be number");var y=t=="maxProperties"?">":"<";r+="if ( ",E&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'number') || "),r+=" Object.keys("+m+").length "+y+" "+c+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { limit: "+c+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have ",t=="maxProperties"?r+="more":r+="fewer",r+=" than ",E?r+="' + "+c+" + '":r+=""+i,r+=" properties' "),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+u:r+=""+i,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var P=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+P+"]); ":r+=" validate.errors = ["+P+"]; return false; ":r+=" var err = "+P+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var ko=W((ph,$o)=>{"use strict";$o.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E=e.opts.$data&&i&&i.$data,c;if(E?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=i,!(E||typeof i=="number"))throw new Error(t+" must be number");r+="var division"+n+";if (",E&&(r+=" "+c+" !== undefined && ( typeof "+c+" != 'number' || "),r+=" (division"+n+" = "+m+" / "+c+", ",e.opts.multipleOfPrecision?r+=" Math.abs(Math.round(division"+n+") - division"+n+") > 1e-"+e.opts.multipleOfPrecision+" ":r+=" division"+n+" !== parseInt(division"+n+") ",r+=" ) ",E&&(r+=" ) "),r+=" ) { ";var y=y||[];y.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { multipleOf: "+c+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be multiple of ",E?r+="' + "+c:r+=""+c+"'"),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+u:r+=""+i,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var _=r;return r=y.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+_+"]); ":r+=" validate.errors = ["+_+"]; return false; ":r+=" var err = "+_+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var No=W((hh,Co)=>{"use strict";Co.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="errs__"+n,c=e.util.copy(e);c.level++;var y="valid"+c.level;if(e.opts.strictKeywords?typeof i=="object"&&Object.keys(i).length>0||i===!1:e.util.schemaHasRules(i,e.RULES.all)){c.schema=i,c.schemaPath=u,c.errSchemaPath=f,r+=" var "+E+" = errors; ";var _=e.compositeRule;e.compositeRule=c.compositeRule=!0,c.createErrors=!1;var v;c.opts.allErrors&&(v=c.opts.allErrors,c.opts.allErrors=!1),r+=" "+e.validate(c)+" ",c.createErrors=!0,v&&(c.opts.allErrors=v),e.compositeRule=c.compositeRule=_,r+=" if ("+y+") { ";var P=P||[];P.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be valid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var O=r;r=P.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+O+"]); ":r+=" validate.errors = ["+O+"]; return false; ":r+=" var err = "+O+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { errors = "+E+"; if (vErrors !== null) { if ("+E+") vErrors.length = "+E+"; else vErrors = null; } ",e.opts.allErrors&&(r+=" } ")}else r+=" var err = ",e.createErrors!==!1?(r+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be valid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",p&&(r+=" if (false) { ");return r}});var Lo=W((mh,jo)=>{"use strict";jo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c="errs__"+n,y=e.util.copy(e),_="";y.level++;var v="valid"+y.level,P=y.baseId,O="prevValid"+n,x="passingSchemas"+n;r+="var "+c+" = errors , "+O+" = false , "+E+" = false , "+x+" = null; ";var R=e.compositeRule;e.compositeRule=y.compositeRule=!0;var D=i;if(D)for(var I,z=-1,U=D.length-1;z0||I===!1:e.util.schemaHasRules(I,e.RULES.all))?(y.schema=I,y.schemaPath=u+"["+z+"]",y.errSchemaPath=f+"/"+z,r+=" "+e.validate(y)+" ",y.baseId=P):r+=" var "+v+" = true; ",z&&(r+=" if ("+v+" && "+O+") { "+E+" = false; "+x+" = ["+x+", "+z+"]; } else { ",_+="}"),r+=" if ("+v+") { "+E+" = "+O+" = true; "+x+" = "+z+"; }";return e.compositeRule=y.compositeRule=R,r+=""+_+"if (!"+E+") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { passingSchemas: "+x+" } ",e.opts.messages!==!1&&(r+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&p&&(e.async?r+=" throw new ValidationError(vErrors); ":r+=" validate.errors = vErrors; return false; "),r+="} else { errors = "+c+"; if (vErrors !== null) { if ("+c+") vErrors.length = "+c+"; else vErrors = null; }",e.opts.allErrors&&(r+=" } "),r}});var Fo=W((vh,Mo)=>{"use strict";Mo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E=e.opts.$data&&i&&i.$data,c;E?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",c="schema"+n):c=i;var y=E?"(new RegExp("+c+"))":e.usePattern(i);r+="if ( ",E&&(r+=" ("+c+" !== undefined && typeof "+c+" != 'string') || "),r+=" !"+y+".test("+m+") ) { ";var _=_||[];_.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { pattern: ",E?r+=""+c:r+=""+e.util.toQuotedString(i),r+=" } ",e.opts.messages!==!1&&(r+=` , message: 'should match pattern "`,E?r+="' + "+c+" + '":r+=""+e.util.escapeQuotes(i),r+=`"' `),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+u:r+=""+e.util.toQuotedString(i),r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var v=r;return r=_.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+v+"]); ":r+=" validate.errors = ["+v+"]; return false; ":r+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var qo=W((gh,Uo)=>{"use strict";Uo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="errs__"+n,c=e.util.copy(e),y="";c.level++;var _="valid"+c.level,v="key"+n,P="idx"+n,O=c.dataLevel=e.dataLevel+1,x="data"+O,R="dataProperties"+n,D=Object.keys(i||{}).filter(re),I=e.schema.patternProperties||{},z=Object.keys(I).filter(re),U=e.schema.additionalProperties,$=D.length||z.length,q=U===!1,F=typeof U=="object"&&Object.keys(U).length,L=e.opts.removeAdditional,A=q||F||L,k=e.opts.ownProperties,M=e.baseId,le=e.schema.required;if(le&&!(e.opts.$data&&le.$data)&&le.length8)r+=" || validate.schema"+u+".hasOwnProperty("+v+") ";else{var G=D;if(G)for(var H,me=-1,Re=G.length-1;me0||Pe===!1:e.util.schemaHasRules(Pe,e.RULES.all)){var qe=e.util.getProperty(H),Te=m+qe,Ce=Er&&Pe.default!==void 0;c.schema=Pe,c.schemaPath=u+qe,c.errSchemaPath=f+"/"+e.util.escapeFragment(H),c.errorPath=e.util.getPath(e.errorPath,H,e.opts.jsonPointers),c.dataPathArr[O]=e.util.toQuotedString(H);var oe=e.validate(c);if(c.baseId=M,e.util.varOccurences(oe,x)<2){oe=e.util.varReplace(oe,x,Te);var Ie=Te}else{var Ie=x;r+=" var "+x+" = "+Te+"; "}if(Ce)r+=" "+oe+" ";else{if(Y&&Y[H]){r+=" if ( "+Ie+" === undefined ",k&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=") { "+_+" = false; ";var De=e.errorPath,ur=f,tr=e.util.escapeQuotes(H);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(De,H,e.opts.jsonPointers)),f=e.errSchemaPath+"/required";var _e=_e||[];_e.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { missingProperty: '"+tr+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+tr+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var ve=r;r=_e.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+ve+"]); ":r+=" validate.errors = ["+ve+"]; return false; ":r+=" var err = "+ve+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f=ur,e.errorPath=De,r+=" } else { "}else p?(r+=" if ( "+Ie+" === undefined ",k&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=") { "+_+" = true; } else { "):(r+=" if ("+Ie+" !== undefined ",k&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=" ) { ");r+=" "+oe+" } "}}p&&(r+=" if ("+_+") { ",y+="}")}}if(z.length){var Me=z;if(Me)for(var se,Nt=-1,Ra=Me.length-1;Nt0||Pe===!1:e.util.schemaHasRules(Pe,e.RULES.all)){c.schema=Pe,c.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(se),c.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(se),k?r+=" "+R+" = "+R+" || Object.keys("+m+"); for (var "+P+"=0; "+P+"<"+R+".length; "+P+"++) { var "+v+" = "+R+"["+P+"]; ":r+=" for (var "+v+" in "+m+") { ",r+=" if ("+e.usePattern(se)+".test("+v+")) { ",c.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers);var Te=m+"["+v+"]";c.dataPathArr[O]=v;var oe=e.validate(c);c.baseId=M,e.util.varOccurences(oe,x)<2?r+=" "+e.util.varReplace(oe,x,Te)+" ":r+=" var "+x+" = "+Te+"; "+oe+" ",p&&(r+=" if (!"+_+") break; "),r+=" } ",p&&(r+=" else "+_+" = true; "),r+=" } ",p&&(r+=" if ("+_+") { ",y+="}")}}}return p&&(r+=" "+y+" if ("+E+" == errors) {"),r}});var zo=W((yh,Vo)=>{"use strict";Vo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="errs__"+n,c=e.util.copy(e),y="";c.level++;var _="valid"+c.level;if(r+="var "+E+" = errors;",e.opts.strictKeywords?typeof i=="object"&&Object.keys(i).length>0||i===!1:e.util.schemaHasRules(i,e.RULES.all)){c.schema=i,c.schemaPath=u,c.errSchemaPath=f;var v="key"+n,P="idx"+n,O="i"+n,x="' + "+v+" + '",R=c.dataLevel=e.dataLevel+1,D="data"+R,I="dataProperties"+n,z=e.opts.ownProperties,U=e.baseId;z&&(r+=" var "+I+" = undefined; "),z?r+=" "+I+" = "+I+" || Object.keys("+m+"); for (var "+P+"=0; "+P+"<"+I+".length; "+P+"++) { var "+v+" = "+I+"["+P+"]; ":r+=" for (var "+v+" in "+m+") { ",r+=" var startErrs"+n+" = errors; ";var $=v,q=e.compositeRule;e.compositeRule=c.compositeRule=!0;var F=e.validate(c);c.baseId=U,e.util.varOccurences(F,D)<2?r+=" "+e.util.varReplace(F,D,$)+" ":r+=" var "+D+" = "+$+"; "+F+" ",e.compositeRule=c.compositeRule=q,r+=" if (!"+_+") { for (var "+O+"=startErrs"+n+"; "+O+"{"use strict";Ho.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c=e.opts.$data&&i&&i.$data,y;c?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",y="schema"+n):y=i;var _="schema"+n;if(!c)if(i.length0||D===!1:e.util.schemaHasRules(D,e.RULES.all))||(v[v.length]=O)}}else var v=i;if(c||v.length){var I=e.errorPath,z=c||v.length>=e.opts.loopRequired,U=e.opts.ownProperties;if(p)if(r+=" var missing"+n+"; ",z){c||(r+=" var "+_+" = validate.schema"+u+"; ");var $="i"+n,q="schema"+n+"["+$+"]",F="' + "+q+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(I,q,e.opts.jsonPointers)),r+=" var "+E+" = true; ",c&&(r+=" if (schema"+n+" === undefined) "+E+" = true; else if (!Array.isArray(schema"+n+")) "+E+" = false; else {"),r+=" for (var "+$+" = 0; "+$+" < "+_+".length; "+$+"++) { "+E+" = "+m+"["+_+"["+$+"]] !== undefined ",U&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", "+_+"["+$+"]) "),r+="; if (!"+E+") break; } ",c&&(r+=" } "),r+=" if (!"+E+") { ";var L=L||[];L.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { missingProperty: '"+F+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+F+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var A=r;r=L.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+A+"]); ":r+=" validate.errors = ["+A+"]; return false; ":r+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else { "}else{r+=" if ( ";var k=v;if(k)for(var M,$=-1,le=k.length-1;${"use strict";Bo.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(l||""),E="valid"+n,c=e.opts.$data&&i&&i.$data,y;if(c?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",y="schema"+n):y=i,(i||c)&&e.opts.uniqueItems!==!1){c&&(r+=" var "+E+"; if ("+y+" === false || "+y+" === undefined) "+E+" = true; else if (typeof "+y+" != 'boolean') "+E+" = false; else { "),r+=" var i = "+m+".length , "+E+" = true , j; if (i > 1) { ";var _=e.schema.items&&e.schema.items.type,v=Array.isArray(_);if(!_||_=="object"||_=="array"||v&&(_.indexOf("object")>=0||_.indexOf("array")>=0))r+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+m+"[i], "+m+"[j])) { "+E+" = false; break outer; } } } ";else{r+=" var itemIndices = {}, item; for (;i--;) { var item = "+m+"[i]; ";var P="checkDataType"+(v?"s":"");r+=" if ("+e.util[P](_,"item",e.opts.strictNumbers,!0)+") continue; ",v&&(r+=` if (typeof item == 'string') item = '"' + item; `),r+=" if (typeof itemIndices[item] == 'number') { "+E+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}r+=" } ",c&&(r+=" } "),r+=" if (!"+E+") { ";var O=O||[];O.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { i: i, j: j } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(r+=" , schema: ",c?r+="validate.schema"+u:r+=""+i,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var x=r;r=O.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+x+"]); ":r+=" validate.errors = ["+x+"]; return false; ":r+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",p&&(r+=" else { ")}else p&&(r+=" if (true) { ");return r}});var Qo=W((bh,Ko)=>{"use strict";Ko.exports={$ref:oo(),allOf:lo(),anyOf:uo(),$comment:po(),const:mo(),contains:go(),dependencies:_o(),enum:bo(),format:Po(),if:wo(),items:To(),maximum:ds(),minimum:ds(),maxItems:fs(),minItems:fs(),maxLength:ps(),minLength:ps(),maxProperties:hs(),minProperties:hs(),multipleOf:ko(),not:No(),oneOf:Lo(),pattern:Fo(),properties:qo(),propertyNames:zo(),required:Zo(),uniqueItems:Wo(),validate:cs()}});var Yo=W((Sh,Go)=>{"use strict";var Jo=Qo(),ms=Jr().toHash;Go.exports=function(){var e=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],t=["type","$comment"],s=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],r=["number","integer","string","array","object","boolean","null"];return e.all=ms(t),e.types=ms(r),e.forEach(function(n){n.rules=n.rules.map(function(l){var i;if(typeof l=="object"){var u=Object.keys(l)[0];i=l[u],l=u,i.forEach(function(p){t.push(p),e.all[p]=!0})}t.push(l);var f=e.all[l]={keyword:l,code:Jo[l],implements:i};return f}),e.all.$comment={keyword:"$comment",code:Jo.$comment},n.type&&(e.types[n.type]=n)}),e.keywords=ms(t.concat(s)),e.custom={},e}});var ri=W((Ph,ei)=>{"use strict";var Xo=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"];ei.exports=function(a,e){for(var t=0;t{"use strict";var Zd=la().MissingRef;ai.exports=ti;function ti(a,e,t){var s=this;if(typeof this._opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");typeof e=="function"&&(t=e,e=void 0);var r=n(a).then(function(){var i=s._addSchema(a,void 0,e);return i.validate||l(i)});return t&&r.then(function(i){t(null,i)},t),r;function n(i){var u=i.$schema;return u&&!s.getSchema(u)?ti.call(s,{$ref:u},!0):Promise.resolve()}function l(i){try{return s._compile(i)}catch(f){if(f instanceof Zd)return u(f);throw f}function u(f){var p=f.missingSchema;if(c(p))throw new Error("Schema "+p+" is loaded but "+f.missingRef+" cannot be resolved");var m=s._loadingSchemas[p];return m||(m=s._loadingSchemas[p]=s._opts.loadSchema(p),m.then(E,E)),m.then(function(y){if(!c(p))return n(y).then(function(){c(p)||s.addSchema(y,p,void 0,e)})}).then(function(){return l(i)});function E(){delete s._loadingSchemas[p]}function c(y){return s._refs[y]||s._schemas[y]}}}}});var oi=W((wh,ni)=>{"use strict";ni.exports=function(e,t,s){var r=" ",n=e.level,l=e.dataLevel,i=e.schema[t],u=e.schemaPath+e.util.getProperty(t),f=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m,E="data"+(l||""),c="valid"+n,y="errs__"+n,_=e.opts.$data&&i&&i.$data,v;_?(r+=" var schema"+n+" = "+e.util.getData(i.$data,l,e.dataPathArr)+"; ",v="schema"+n):v=i;var P=this,O="definition"+n,x=P.definition,R="",D,I,z,U,$;if(_&&x.$data){$="keywordValidate"+n;var q=x.validateSchema;r+=" var "+O+" = RULES.custom['"+t+"'].definition; var "+$+" = "+O+".validate;"}else{if(U=e.useCustomRule(P,i,e.schema,e),!U)return;v="validate.schema"+u,$=U.code,D=x.compile,I=x.inline,z=x.macro}var F=$+".errors",L="i"+n,A="ruleErr"+n,k=x.async;if(k&&!e.async)throw new Error("async keyword in sync schema");if(I||z||(r+=""+F+" = null;"),r+="var "+y+" = errors;var "+c+";",_&&x.$data&&(R+="}",r+=" if ("+v+" === undefined) { "+c+" = true; } else { ",q&&(R+="}",r+=" "+c+" = "+O+".validateSchema("+v+"); if ("+c+") { ")),I)x.statements?r+=" "+U.validate+" ":r+=" "+c+" = "+U.validate+"; ";else if(z){var M=e.util.copy(e),R="";M.level++;var le="valid"+M.level;M.schema=U.validate,M.schemaPath="";var Y=e.compositeRule;e.compositeRule=M.compositeRule=!0;var re=e.validate(M).replace(/validate\.schema/g,$);e.compositeRule=M.compositeRule=Y,r+=" "+re}else{var G=G||[];G.push(r),r="",r+=" "+$+".call( ",e.opts.passContext?r+="this":r+="self",D||x.schema===!1?r+=" , "+E+" ":r+=" , "+v+" , "+E+" , validate.schema"+e.schemaPath+" ",r+=" , (dataPath || '')",e.errorPath!='""'&&(r+=" + "+e.errorPath);var H=l?"data"+(l-1||""):"parentData",me=l?e.dataPathArr[l]:"parentDataProperty";r+=" , "+H+" , "+me+" , rootData ) ";var Re=r;r=G.pop(),x.errors===!1?(r+=" "+c+" = ",k&&(r+="await "),r+=""+Re+"; "):k?(F="customErrors"+n,r+=" var "+F+" = null; try { "+c+" = await "+Re+"; } catch (e) { "+c+" = false; if (e instanceof ValidationError) "+F+" = e.errors; else throw e; } "):r+=" "+F+" = null; "+c+" = "+Re+"; "}if(x.modifying&&(r+=" if ("+H+") "+E+" = "+H+"["+me+"];"),r+=""+R,x.valid)p&&(r+=" if (true) { ");else{r+=" if ( ",x.valid===void 0?(r+=" !",z?r+=""+le:r+=""+c):r+=" "+!x.valid+" ",r+=") { ",m=P.keyword;var G=G||[];G.push(r),r="";var G=G||[];G.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(m||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { keyword: '"+P.keyword+"' } ",e.opts.messages!==!1&&(r+=` , message: 'should pass "`+P.keyword+`" keyword validation' `),e.opts.verbose&&(r+=" , schema: validate.schema"+u+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+E+" "),r+=" } "):r+=" {} ";var Ae=r;r=G.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+Ae+"]); ":r+=" validate.errors = ["+Ae+"]; return false; ":r+=" var err = "+Ae+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var se=r;r=G.pop(),I?x.errors?x.errors!="full"&&(r+=" for (var "+L+"="+y+"; "+L+"{Bd.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 ci=W((Th,li)=>{"use strict";var ii=vs();li.exports={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:ii.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:ii.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}}});var di=W((Oh,ui)=>{"use strict";var Wd=/^[a-z_$][a-z0-9_$-]*$/i,Kd=oi(),Qd=ci();ui.exports={add:Jd,get:Gd,remove:Yd,validate:gs};function Jd(a,e){var t=this.RULES;if(t.keywords[a])throw new Error("Keyword "+a+" is already defined");if(!Wd.test(a))throw new Error("Keyword "+a+" is not a valid identifier");if(e){this.validateKeyword(e,!0);var s=e.type;if(Array.isArray(s))for(var r=0;r{Xd.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON Schema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Si=W((Dh,bi)=>{"use strict";var hi=Hn(),Gr=ia(),ef=Bn(),mi=ts(),rf=ls(),tf=so(),af=Yo(),vi=ri(),gi=Jr();bi.exports=ge;ge.prototype.validate=nf;ge.prototype.compile=of;ge.prototype.addSchema=lf;ge.prototype.addMetaSchema=cf;ge.prototype.validateSchema=uf;ge.prototype.getSchema=ff;ge.prototype.removeSchema=hf;ge.prototype.addFormat=Sf;ge.prototype.errorsText=bf;ge.prototype._addSchema=mf;ge.prototype._compile=vf;ge.prototype.compileAsync=si();var va=di();ge.prototype.addKeyword=va.add;ge.prototype.getKeyword=va.get;ge.prototype.removeKeyword=va.remove;ge.prototype.validateKeyword=va.validate;var yi=la();ge.ValidationError=yi.Validation;ge.MissingRefError=yi.MissingRef;ge.$dataMetaSchema=vi;var ma="http://json-schema.org/draft-07/schema",pi=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],sf=["/properties"];function ge(a){if(!(this instanceof ge))return new ge(a);a=this._opts=gi.copy(a)||{},Of(this),this._schemas={},this._refs={},this._fragments={},this._formats=tf(a.format),this._cache=a.cache||new ef,this._loadingSchemas={},this._compilations=[],this.RULES=af(),this._getId=gf(a),a.loopRequired=a.loopRequired||1/0,a.errorDataPath=="property"&&(a._errorDataPathProperty=!0),a.serialize===void 0&&(a.serialize=rf),this._metaOpts=Tf(this),a.formats&&wf(this),a.keywords&&Rf(this),Pf(this),typeof a.meta=="object"&&this.addMetaSchema(a.meta),a.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),xf(this)}function nf(a,e){var t;if(typeof a=="string"){if(t=this.getSchema(a),!t)throw new Error('no schema with key or ref "'+a+'"')}else{var s=this._addSchema(a);t=s.validate||this._compile(s)}var r=t(e);return t.$async!==!0&&(this.errors=t.errors),r}function of(a,e){var t=this._addSchema(a,void 0,e);return t.validate||this._compile(t)}function lf(a,e,t,s){if(Array.isArray(a)){for(var r=0;rmc,DIRTY:()=>Cr,EMPTY_PATH:()=>Wl,INVALID:()=>Z,NEVER:()=>Xc,OK:()=>Oe,ParseStatus:()=>xe,Schema:()=>J,ZodAny:()=>Pr,ZodArray:()=>yr,ZodBigInt:()=>jr,ZodBoolean:()=>Lr,ZodBranded:()=>xt,ZodCatch:()=>Kr,ZodDate:()=>Mr,ZodDefault:()=>Wr,ZodDiscriminatedUnion:()=>qt,ZodEffects:()=>Be,ZodEnum:()=>Zr,ZodError:()=>Ne,ZodFirstPartyTypeKind:()=>T,ZodFunction:()=>zt,ZodIntersection:()=>Vr,ZodIssueCode:()=>w,ZodLazy:()=>zr,ZodLiteral:()=>Hr,ZodMap:()=>ut,ZodNaN:()=>ft,ZodNativeEnum:()=>Br,ZodNever:()=>Je,ZodNull:()=>Ur,ZodNullable:()=>ir,ZodNumber:()=>Nr,ZodObject:()=>je,ZodOptional:()=>He,ZodParsedType:()=>N,ZodPipeline:()=>wt,ZodPromise:()=>xr,ZodReadonly:()=>Qr,ZodRecord:()=>Vt,ZodSchema:()=>J,ZodSet:()=>dt,ZodString:()=>Sr,ZodSymbol:()=>lt,ZodTransformer:()=>Be,ZodTuple:()=>or,ZodType:()=>J,ZodUndefined:()=>Fr,ZodUnion:()=>qr,ZodUnknown:()=>gr,ZodVoid:()=>ct,addIssueToContext:()=>C,any:()=>xc,array:()=>Oc,bigint:()=>_c,boolean:()=>en,coerce:()=>Yc,custom:()=>Gs,date:()=>Ec,datetimeRegex:()=>Qs,defaultErrorMap:()=>mr,discriminatedUnion:()=>$c,effect:()=>Hc,enum:()=>qc,function:()=>Mc,getErrorMap:()=>nt,getParsedType:()=>nr,instanceof:()=>gc,intersection:()=>kc,isAborted:()=>Ft,isAsync:()=>ot,isDirty:()=>Ut,isValid:()=>br,late:()=>vc,lazy:()=>Fc,literal:()=>Uc,makeIssue:()=>Pt,map:()=>jc,nan:()=>yc,nativeEnum:()=>Vc,never:()=>Rc,null:()=>Pc,nullable:()=>Bc,number:()=>Xs,object:()=>Ac,objectUtil:()=>$a,oboolean:()=>Gc,onumber:()=>Jc,optional:()=>Zc,ostring:()=>Qc,pipeline:()=>Kc,preprocess:()=>Wc,promise:()=>zc,quotelessJson:()=>Hl,record:()=>Nc,set:()=>Lc,setErrorMap:()=>Bl,strictObject:()=>Dc,string:()=>Ys,symbol:()=>bc,transformer:()=>Hc,tuple:()=>Cc,undefined:()=>Sc,union:()=>Ic,unknown:()=>wc,util:()=>X,void:()=>Tc});var X;(function(a){a.assertEqual=r=>{};function e(r){}a.assertIs=e;function t(r){throw new Error}a.assertNever=t,a.arrayToEnum=r=>{let n={};for(let l of r)n[l]=l;return n},a.getValidEnumValues=r=>{let n=a.objectKeys(r).filter(i=>typeof r[r[i]]!="number"),l={};for(let i of n)l[i]=r[i];return a.objectValues(l)},a.objectValues=r=>a.objectKeys(r).map(function(n){return r[n]}),a.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let n=[];for(let l in r)Object.prototype.hasOwnProperty.call(r,l)&&n.push(l);return n},a.find=(r,n)=>{for(let l of r)if(n(l))return l},a.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,n=" | "){return r.map(l=>typeof l=="string"?`'${l}'`:l).join(n)}a.joinValues=s,a.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(X||(X={}));var $a;(function(a){a.mergeShapes=(e,t)=>({...e,...t})})($a||($a={}));var N=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),nr=a=>{switch(typeof a){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(a)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(a)?N.array:a===null?N.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?N.promise:typeof Map<"u"&&a instanceof Map?N.map:typeof Set<"u"&&a instanceof Set?N.set:typeof Date<"u"&&a instanceof Date?N.date:N.object;default:return N.unknown}};var w=X.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"]),Hl=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:"),Ne=class a extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(n){return n.message},s={_errors:[]},r=n=>{for(let l of n.issues)if(l.code==="invalid_union")l.unionErrors.map(r);else if(l.code==="invalid_return_type")r(l.returnTypeError);else if(l.code==="invalid_arguments")r(l.argumentsError);else if(l.path.length===0)s._errors.push(t(l));else{let i=s,u=0;for(;ut.message){let t={},s=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};Ne.create=a=>new Ne(a);var Zl=(a,e)=>{let t;switch(a.code){case w.invalid_type:a.received===N.undefined?t="Required":t=`Expected ${a.expected}, received ${a.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(a.expected,X.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${X.joinValues(a.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${X.joinValues(a.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${X.joinValues(a.options)}, received '${a.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(t=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?t=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?t=`Invalid input: must end with "${a.validation.endsWith}"`:X.assertNever(a.validation):a.validation!=="regex"?t=`Invalid ${a.validation}`:t="Invalid";break;case w.too_small:a.type==="array"?t=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?t=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?t=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="bigint"?t=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?t=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:t="Invalid input";break;case w.too_big:a.type==="array"?t=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?t=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?t=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?t=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?t=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:t="Invalid input";break;case w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${a.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,X.assertNever(a)}return{message:t}},mr=Zl;var Hs=mr;function Bl(a){Hs=a}function nt(){return Hs}var Pt=a=>{let{data:e,path:t,errorMaps:s,issueData:r}=a,n=[...t,...r.path||[]],l={...r,path:n};if(r.message!==void 0)return{...r,path:n,message:r.message};let i="",u=s.filter(f=>!!f).slice().reverse();for(let f of u)i=f(l,{data:e,defaultError:i}).message;return{...r,path:n,message:i}},Wl=[];function C(a,e){let t=nt(),s=Pt({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,t,t===mr?void 0:mr].filter(r=>!!r)});a.common.issues.push(s)}var xe=class a{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let r of t){if(r.status==="aborted")return Z;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let r of t){let n=await r.key,l=await r.value;s.push({key:n,value:l})}return a.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let r of t){let{key:n,value:l}=r;if(n.status==="aborted"||l.status==="aborted")return Z;n.status==="dirty"&&e.dirty(),l.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof l.value<"u"||r.alwaysSet)&&(s[n.value]=l.value)}return{status:e.value,value:s}}},Z=Object.freeze({status:"aborted"}),Cr=a=>({status:"dirty",value:a}),Oe=a=>({status:"valid",value:a}),Ft=a=>a.status==="aborted",Ut=a=>a.status==="dirty",br=a=>a.status==="valid",ot=a=>typeof Promise<"u"&&a instanceof Promise;var V;(function(a){a.errToObj=e=>typeof e=="string"?{message:e}:e||{},a.toString=e=>typeof e=="string"?e:e?.message})(V||(V={}));var Ze=class{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}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}},Zs=(a,e)=>{if(br(e))return{success:!0,data:e.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new Ne(a.common.issues);return this._error=t,this._error}}};function K(a){if(!a)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:r}=a;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(l,i)=>{let{message:u}=a;return l.code==="invalid_enum_value"?{message:u??i.defaultError}:typeof i.data>"u"?{message:u??s??i.defaultError}:l.code!=="invalid_type"?{message:i.defaultError}:{message:u??t??i.defaultError}},description:r}}var J=class{get description(){return this._def.description}_getType(e){return nr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:nr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new xe,ctx:{common:e.parent.common,data:e.data,parsedType:nr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ot(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:nr(e)},r=this._parseSync({data:e,path:s.path,parent:s});return Zs(s,r)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:nr(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return br(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>br(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:nr(e)},r=this._parse({data:e,path:s.path,parent:s}),n=await(ot(r)?r:Promise.resolve(r));return Zs(s,n)}refine(e,t){let s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,n)=>{let l=e(r),i=()=>n.addIssue({code:w.custom,...s(r)});return typeof Promise<"u"&&l instanceof Promise?l.then(u=>u?!0:(i(),!1)):l?!0:(i(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new Be({schema:this,typeName:T.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:t=>this["~validate"](t)}}optional(){return He.create(this,this._def)}nullable(){return ir.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return yr.create(this)}promise(){return xr.create(this,this._def)}or(e){return qr.create([this,e],this._def)}and(e){return Vr.create(this,e,this._def)}transform(e){return new Be({...K(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Wr({...K(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new xt({typeName:T.ZodBranded,type:this,...K(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Kr({...K(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return wt.create(this,e)}readonly(){return Qr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Kl=/^c[^\s-]{8,}$/i,Ql=/^[0-9a-z]+$/,Jl=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Gl=/^[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,Yl=/^[a-z0-9_-]{21}$/i,Xl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ec=/^[-+]?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)?)??$/,rc=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ka,ac=/^(?:(?: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])$/,sc=/^(?:(?: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])$/,nc=/^(([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]))$/,oc=/^(([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])$/,ic=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lc=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ws="((\\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])))",cc=new RegExp(`^${Ws}$`);function Ks(a){let e="[0-5]\\d";a.precision?e=`${e}\\.\\d{${a.precision}}`:a.precision==null&&(e=`${e}(\\.\\d+)?`);let t=a.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function uc(a){return new RegExp(`^${Ks(a)}$`)}function Qs(a){let e=`${Ws}T${Ks(a)}`,t=[];return t.push(a.local?"Z?":"Z"),a.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function dc(a,e){return!!((e==="v4"||!e)&&ac.test(a)||(e==="v6"||!e)&&nc.test(a))}function fc(a,e){if(!Xl.test(a))return!1;try{let[t]=a.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function pc(a,e){return!!((e==="v4"||!e)&&sc.test(a)||(e==="v6"||!e)&&oc.test(a))}var Sr=class a extends J{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){let n=this._getOrReturnCtx(e);return C(n,{code:w.invalid_type,expected:N.string,received:n.parsedType}),Z}let s=new xe,r;for(let n of this._def.checks)if(n.kind==="min")e.data.lengthn.value&&(r=this._getOrReturnCtx(e,r),C(r,{code:w.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="length"){let l=e.data.length>n.value,i=e.data.lengthe.test(r),{validation:t,code:w.invalid_string,...V.errToObj(s)})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...V.errToObj(e)})}url(e){return this._addCheck({kind:"url",...V.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...V.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...V.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...V.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...V.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...V.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...V.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...V.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...V.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...V.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...V.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...V.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,...V.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,...V.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...V.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...V.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...V.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...V.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...V.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...V.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...V.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...V.errToObj(t)})}nonempty(e){return this.min(1,V.errToObj(e))}trim(){return new a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew Sr({checks:[],typeName:T.ZodString,coerce:a?.coerce??!1,...K(a)});function hc(a,e){let t=(a.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,n=Number.parseInt(a.toFixed(r).replace(".","")),l=Number.parseInt(e.toFixed(r).replace(".",""));return n%l/10**r}var Nr=class a extends J{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)!==N.number){let n=this._getOrReturnCtx(e);return C(n,{code:w.invalid_type,expected:N.number,received:n.parsedType}),Z}let s,r=new xe;for(let n of this._def.checks)n.kind==="int"?X.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),C(s,{code:w.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),C(s,{code:w.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="multipleOf"?hc(e.data,n.value)!==0&&(s=this._getOrReturnCtx(e,s),C(s,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),C(s,{code:w.not_finite,message:n.message}),r.dirty()):X.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,V.toString(t))}gt(e,t){return this.setLimit("min",e,!1,V.toString(t))}lte(e,t){return this.setLimit("max",e,!0,V.toString(t))}lt(e,t){return this.setLimit("max",e,!1,V.toString(t))}setLimit(e,t,s,r){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:V.toString(r)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:V.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:V.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:V.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&X.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.valuenew Nr({checks:[],typeName:T.ZodNumber,coerce:a?.coerce||!1,...K(a)});var jr=class a extends J{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)!==N.bigint)return this._getInvalidInput(e);let s,r=new xe;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.datan.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),C(s,{code:w.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),C(s,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):X.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return C(t,{code:w.invalid_type,expected:N.bigint,received:t.parsedType}),Z}gte(e,t){return this.setLimit("min",e,!0,V.toString(t))}gt(e,t){return this.setLimit("min",e,!1,V.toString(t))}lte(e,t){return this.setLimit("max",e,!0,V.toString(t))}lt(e,t){return this.setLimit("max",e,!1,V.toString(t))}setLimit(e,t,s,r){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:V.toString(r)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:V.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew jr({checks:[],typeName:T.ZodBigInt,coerce:a?.coerce??!1,...K(a)});var Lr=class extends J{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==N.boolean){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.boolean,received:s.parsedType}),Z}return Oe(e.data)}};Lr.create=a=>new Lr({typeName:T.ZodBoolean,coerce:a?.coerce||!1,...K(a)});var Mr=class a extends J{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){let n=this._getOrReturnCtx(e);return C(n,{code:w.invalid_type,expected:N.date,received:n.parsedType}),Z}if(Number.isNaN(e.data.getTime())){let n=this._getOrReturnCtx(e);return C(n,{code:w.invalid_date}),Z}let s=new xe,r;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()n.value&&(r=this._getOrReturnCtx(e,r),C(r,{code:w.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):X.assertNever(n);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:V.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:V.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.valuenew Mr({checks:[],coerce:a?.coerce||!1,typeName:T.ZodDate,...K(a)});var lt=class extends J{_parse(e){if(this._getType(e)!==N.symbol){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.symbol,received:s.parsedType}),Z}return Oe(e.data)}};lt.create=a=>new lt({typeName:T.ZodSymbol,...K(a)});var Fr=class extends J{_parse(e){if(this._getType(e)!==N.undefined){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.undefined,received:s.parsedType}),Z}return Oe(e.data)}};Fr.create=a=>new Fr({typeName:T.ZodUndefined,...K(a)});var Ur=class extends J{_parse(e){if(this._getType(e)!==N.null){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.null,received:s.parsedType}),Z}return Oe(e.data)}};Ur.create=a=>new Ur({typeName:T.ZodNull,...K(a)});var Pr=class extends J{constructor(){super(...arguments),this._any=!0}_parse(e){return Oe(e.data)}};Pr.create=a=>new Pr({typeName:T.ZodAny,...K(a)});var gr=class extends J{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Oe(e.data)}};gr.create=a=>new gr({typeName:T.ZodUnknown,...K(a)});var Je=class extends J{_parse(e){let t=this._getOrReturnCtx(e);return C(t,{code:w.invalid_type,expected:N.never,received:t.parsedType}),Z}};Je.create=a=>new Je({typeName:T.ZodNever,...K(a)});var ct=class extends J{_parse(e){if(this._getType(e)!==N.undefined){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.void,received:s.parsedType}),Z}return Oe(e.data)}};ct.create=a=>new ct({typeName:T.ZodVoid,...K(a)});var yr=class a extends J{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==N.array)return C(t,{code:w.invalid_type,expected:N.array,received:t.parsedType}),Z;if(r.exactLength!==null){let l=t.data.length>r.exactLength.value,i=t.data.lengthr.maxLength.value&&(C(t,{code:w.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((l,i)=>r.type._parseAsync(new Ze(t,l,t.path,i)))).then(l=>xe.mergeArray(s,l));let n=[...t.data].map((l,i)=>r.type._parseSync(new Ze(t,l,t.path,i)));return xe.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new a({...this._def,minLength:{value:e,message:V.toString(t)}})}max(e,t){return new a({...this._def,maxLength:{value:e,message:V.toString(t)}})}length(e,t){return new a({...this._def,exactLength:{value:e,message:V.toString(t)}})}nonempty(e){return this.min(1,e)}};yr.create=(a,e)=>new yr({type:a,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...K(e)});function it(a){if(a instanceof je){let e={};for(let t in a.shape){let s=a.shape[t];e[t]=He.create(it(s))}return new je({...a._def,shape:()=>e})}else return a instanceof yr?new yr({...a._def,type:it(a.element)}):a instanceof He?He.create(it(a.unwrap())):a instanceof ir?ir.create(it(a.unwrap())):a instanceof or?or.create(a.items.map(e=>it(e))):a}var je=class a extends J{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(),t=X.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==N.object){let f=this._getOrReturnCtx(e);return C(f,{code:w.invalid_type,expected:N.object,received:f.parsedType}),Z}let{status:s,ctx:r}=this._processInputParams(e),{shape:n,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof Je&&this._def.unknownKeys==="strip"))for(let f in r.data)l.includes(f)||i.push(f);let u=[];for(let f of l){let p=n[f],m=r.data[f];u.push({key:{status:"valid",value:f},value:p._parse(new Ze(r,m,r.path,f)),alwaysSet:f in r.data})}if(this._def.catchall instanceof Je){let f=this._def.unknownKeys;if(f==="passthrough")for(let p of i)u.push({key:{status:"valid",value:p},value:{status:"valid",value:r.data[p]}});else if(f==="strict")i.length>0&&(C(r,{code:w.unrecognized_keys,keys:i}),s.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let f=this._def.catchall;for(let p of i){let m=r.data[p];u.push({key:{status:"valid",value:p},value:f._parse(new Ze(r,m,r.path,p)),alwaysSet:p in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let f=[];for(let p of u){let m=await p.key,E=await p.value;f.push({key:m,value:E,alwaysSet:p.alwaysSet})}return f}).then(f=>xe.mergeObjectSync(s,f)):xe.mergeObjectSync(s,u)}get shape(){return this._def.shape()}strict(e){return V.errToObj,new a({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let r=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:V.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new a({...this._def,unknownKeys:"strip"})}passthrough(){return new a({...this._def,unknownKeys:"passthrough"})}extend(e){return new a({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new a({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new a({...this._def,catchall:e})}pick(e){let t={};for(let s of X.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new a({...this._def,shape:()=>t})}omit(e){let t={};for(let s of X.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new a({...this._def,shape:()=>t})}deepPartial(){return it(this)}partial(e){let t={};for(let s of X.objectKeys(this.shape)){let r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}return new a({...this._def,shape:()=>t})}required(e){let t={};for(let s of X.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof He;)n=n._def.innerType;t[s]=n}return new a({...this._def,shape:()=>t})}keyof(){return Js(X.objectKeys(this.shape))}};je.create=(a,e)=>new je({shape:()=>a,unknownKeys:"strip",catchall:Je.create(),typeName:T.ZodObject,...K(e)});je.strictCreate=(a,e)=>new je({shape:()=>a,unknownKeys:"strict",catchall:Je.create(),typeName:T.ZodObject,...K(e)});je.lazycreate=(a,e)=>new je({shape:a,unknownKeys:"strip",catchall:Je.create(),typeName:T.ZodObject,...K(e)});var qr=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function r(n){for(let i of n)if(i.result.status==="valid")return i.result;for(let i of n)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;let l=n.map(i=>new Ne(i.ctx.common.issues));return C(t,{code:w.invalid_union,unionErrors:l}),Z}if(t.common.async)return Promise.all(s.map(async n=>{let l={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:l}),ctx:l}})).then(r);{let n,l=[];for(let u of s){let f={...t,common:{...t.common,issues:[]},parent:null},p=u._parseSync({data:t.data,path:t.path,parent:f});if(p.status==="valid")return p;p.status==="dirty"&&!n&&(n={result:p,ctx:f}),f.common.issues.length&&l.push(f.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;let i=l.map(u=>new Ne(u));return C(t,{code:w.invalid_union,unionErrors:i}),Z}}get options(){return this._def.options}};qr.create=(a,e)=>new qr({options:a,typeName:T.ZodUnion,...K(e)});var vr=a=>a instanceof zr?vr(a.schema):a instanceof Be?vr(a.innerType()):a instanceof Hr?[a.value]:a instanceof Zr?a.options:a instanceof Br?X.objectValues(a.enum):a instanceof Wr?vr(a._def.innerType):a instanceof Fr?[void 0]:a instanceof Ur?[null]:a instanceof He?[void 0,...vr(a.unwrap())]:a instanceof ir?[null,...vr(a.unwrap())]:a instanceof xt||a instanceof Qr?vr(a.unwrap()):a instanceof Kr?vr(a._def.innerType):[],qt=class a extends J{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.object)return C(t,{code:w.invalid_type,expected:N.object,received:t.parsedType}),Z;let s=this.discriminator,r=t.data[s],n=this.optionsMap.get(r);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(C(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let r=new Map;for(let n of t){let l=vr(n.shape[e]);if(!l.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of l){if(r.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);r.set(i,n)}}return new a({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...K(s)})}};function Ca(a,e){let t=nr(a),s=nr(e);if(a===e)return{valid:!0,data:a};if(t===N.object&&s===N.object){let r=X.objectKeys(e),n=X.objectKeys(a).filter(i=>r.indexOf(i)!==-1),l={...a,...e};for(let i of n){let u=Ca(a[i],e[i]);if(!u.valid)return{valid:!1};l[i]=u.data}return{valid:!0,data:l}}else if(t===N.array&&s===N.array){if(a.length!==e.length)return{valid:!1};let r=[];for(let n=0;n{if(Ft(n)||Ft(l))return Z;let i=Ca(n.value,l.value);return i.valid?((Ut(n)||Ut(l))&&t.dirty(),{status:t.value,value:i.data}):(C(s,{code:w.invalid_intersection_types}),Z)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([n,l])=>r(n,l)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};Vr.create=(a,e,t)=>new Vr({left:a,right:e,typeName:T.ZodIntersection,...K(t)});var or=class a extends J{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.array)return C(s,{code:w.invalid_type,expected:N.array,received:s.parsedType}),Z;if(s.data.lengththis._def.items.length&&(C(s,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...s.data].map((l,i)=>{let u=this._def.items[i]||this._def.rest;return u?u._parse(new Ze(s,l,s.path,i)):null}).filter(l=>!!l);return s.common.async?Promise.all(n).then(l=>xe.mergeArray(t,l)):xe.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new a({...this._def,rest:e})}};or.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new or({items:a,typeName:T.ZodTuple,rest:null,...K(e)})};var Vt=class a extends J{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.object)return C(s,{code:w.invalid_type,expected:N.object,received:s.parsedType}),Z;let r=[],n=this._def.keyType,l=this._def.valueType;for(let i in s.data)r.push({key:n._parse(new Ze(s,i,s.path,i)),value:l._parse(new Ze(s,s.data[i],s.path,i)),alwaysSet:i in s.data});return s.common.async?xe.mergeObjectAsync(t,r):xe.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof J?new a({keyType:e,valueType:t,typeName:T.ZodRecord,...K(s)}):new a({keyType:Sr.create(),valueType:e,typeName:T.ZodRecord,...K(t)})}},ut=class extends J{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.map)return C(s,{code:w.invalid_type,expected:N.map,received:s.parsedType}),Z;let r=this._def.keyType,n=this._def.valueType,l=[...s.data.entries()].map(([i,u],f)=>({key:r._parse(new Ze(s,i,s.path,[f,"key"])),value:n._parse(new Ze(s,u,s.path,[f,"value"]))}));if(s.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let u of l){let f=await u.key,p=await u.value;if(f.status==="aborted"||p.status==="aborted")return Z;(f.status==="dirty"||p.status==="dirty")&&t.dirty(),i.set(f.value,p.value)}return{status:t.value,value:i}})}else{let i=new Map;for(let u of l){let f=u.key,p=u.value;if(f.status==="aborted"||p.status==="aborted")return Z;(f.status==="dirty"||p.status==="dirty")&&t.dirty(),i.set(f.value,p.value)}return{status:t.value,value:i}}}};ut.create=(a,e,t)=>new ut({valueType:e,keyType:a,typeName:T.ZodMap,...K(t)});var dt=class a extends J{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==N.set)return C(s,{code:w.invalid_type,expected:N.set,received:s.parsedType}),Z;let r=this._def;r.minSize!==null&&s.data.sizer.maxSize.value&&(C(s,{code:w.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let n=this._def.valueType;function l(u){let f=new Set;for(let p of u){if(p.status==="aborted")return Z;p.status==="dirty"&&t.dirty(),f.add(p.value)}return{status:t.value,value:f}}let i=[...s.data.values()].map((u,f)=>n._parse(new Ze(s,u,s.path,f)));return s.common.async?Promise.all(i).then(u=>l(u)):l(i)}min(e,t){return new a({...this._def,minSize:{value:e,message:V.toString(t)}})}max(e,t){return new a({...this._def,maxSize:{value:e,message:V.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};dt.create=(a,e)=>new dt({valueType:a,minSize:null,maxSize:null,typeName:T.ZodSet,...K(e)});var zt=class a extends J{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.function)return C(t,{code:w.invalid_type,expected:N.function,received:t.parsedType}),Z;function s(i,u){return Pt({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,nt(),mr].filter(f=>!!f),issueData:{code:w.invalid_arguments,argumentsError:u}})}function r(i,u){return Pt({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,nt(),mr].filter(f=>!!f),issueData:{code:w.invalid_return_type,returnTypeError:u}})}let n={errorMap:t.common.contextualErrorMap},l=t.data;if(this._def.returns instanceof xr){let i=this;return Oe(async function(...u){let f=new Ne([]),p=await i._def.args.parseAsync(u,n).catch(c=>{throw f.addIssue(s(u,c)),f}),m=await Reflect.apply(l,this,p);return await i._def.returns._def.type.parseAsync(m,n).catch(c=>{throw f.addIssue(r(m,c)),f})})}else{let i=this;return Oe(function(...u){let f=i._def.args.safeParse(u,n);if(!f.success)throw new Ne([s(u,f.error)]);let p=Reflect.apply(l,this,f.data),m=i._def.returns.safeParse(p,n);if(!m.success)throw new Ne([r(p,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new a({...this._def,args:or.create(e).rest(gr.create())})}returns(e){return new a({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new a({args:e||or.create([]).rest(gr.create()),returns:t||gr.create(),typeName:T.ZodFunction,...K(s)})}},zr=class extends J{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};zr.create=(a,e)=>new zr({getter:a,typeName:T.ZodLazy,...K(e)});var Hr=class extends J{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return C(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:e.data}}get value(){return this._def.value}};Hr.create=(a,e)=>new Hr({value:a,typeName:T.ZodLiteral,...K(e)});function Js(a,e){return new Zr({values:a,typeName:T.ZodEnum,...K(e)})}var Zr=class a extends J{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return C(t,{expected:X.joinValues(s),received:t.parsedType,code:w.invalid_type}),Z}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return C(t,{received:t.data,code:w.invalid_enum_value,options:s}),Z}return Oe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return a.create(e,{...this._def,...t})}exclude(e,t=this._def){return a.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};Zr.create=Js;var Br=class extends J{_parse(e){let t=X.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==N.string&&s.parsedType!==N.number){let r=X.objectValues(t);return C(s,{expected:X.joinValues(r),received:s.parsedType,code:w.invalid_type}),Z}if(this._cache||(this._cache=new Set(X.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=X.objectValues(t);return C(s,{received:s.data,code:w.invalid_enum_value,options:r}),Z}return Oe(e.data)}get enum(){return this._def.values}};Br.create=(a,e)=>new Br({values:a,typeName:T.ZodNativeEnum,...K(e)});var xr=class extends J{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==N.promise&&t.common.async===!1)return C(t,{code:w.invalid_type,expected:N.promise,received:t.parsedType}),Z;let s=t.parsedType===N.promise?t.data:Promise.resolve(t.data);return Oe(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};xr.create=(a,e)=>new xr({type:a,typeName:T.ZodPromise,...K(e)});var Be=class extends J{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,n={addIssue:l=>{C(s,l),l.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),r.type==="preprocess"){let l=r.transform(s.data,n);if(s.common.async)return Promise.resolve(l).then(async i=>{if(t.value==="aborted")return Z;let u=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return u.status==="aborted"?Z:u.status==="dirty"?Cr(u.value):t.value==="dirty"?Cr(u.value):u});{if(t.value==="aborted")return Z;let i=this._def.schema._parseSync({data:l,path:s.path,parent:s});return i.status==="aborted"?Z:i.status==="dirty"?Cr(i.value):t.value==="dirty"?Cr(i.value):i}}if(r.type==="refinement"){let l=i=>{let u=r.refinement(i,n);if(s.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?Z:(i.status==="dirty"&&t.dirty(),l(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>i.status==="aborted"?Z:(i.status==="dirty"&&t.dirty(),l(i.value).then(()=>({status:t.value,value:i.value}))))}if(r.type==="transform")if(s.common.async===!1){let l=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!br(l))return Z;let i=r.transform(l.value,n);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(l=>br(l)?Promise.resolve(r.transform(l.value,n)).then(i=>({status:t.value,value:i})):Z);X.assertNever(r)}};Be.create=(a,e,t)=>new Be({schema:a,typeName:T.ZodEffects,effect:e,...K(t)});Be.createWithPreprocess=(a,e,t)=>new Be({schema:e,effect:{type:"preprocess",transform:a},typeName:T.ZodEffects,...K(t)});var He=class extends J{_parse(e){return this._getType(e)===N.undefined?Oe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};He.create=(a,e)=>new He({innerType:a,typeName:T.ZodOptional,...K(e)});var ir=class extends J{_parse(e){return this._getType(e)===N.null?Oe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ir.create=(a,e)=>new ir({innerType:a,typeName:T.ZodNullable,...K(e)});var Wr=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===N.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Wr.create=(a,e)=>new Wr({innerType:a,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...K(e)});var Kr=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ot(r)?r.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ne(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ne(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Kr.create=(a,e)=>new Kr({innerType:a,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...K(e)});var ft=class extends J{_parse(e){if(this._getType(e)!==N.nan){let s=this._getOrReturnCtx(e);return C(s,{code:w.invalid_type,expected:N.nan,received:s.parsedType}),Z}return{status:"valid",value:e.data}}};ft.create=a=>new ft({typeName:T.ZodNaN,...K(a)});var mc=Symbol("zod_brand"),xt=class extends J{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},wt=class a extends J{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?Z:n.status==="dirty"?(t.dirty(),Cr(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{let r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?Z:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new a({in:e,out:t,typeName:T.ZodPipeline})}},Qr=class extends J{_parse(e){let t=this._def.innerType._parse(e),s=r=>(br(r)&&(r.value=Object.freeze(r.value)),r);return ot(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}};Qr.create=(a,e)=>new Qr({innerType:a,typeName:T.ZodReadonly,...K(e)});function Bs(a,e){let t=typeof a=="function"?a(e):typeof a=="string"?{message:a}:a;return typeof t=="string"?{message:t}:t}function Gs(a,e={},t){return a?Pr.create().superRefine((s,r)=>{let n=a(s);if(n instanceof Promise)return n.then(l=>{if(!l){let i=Bs(e,s),u=i.fatal??t??!0;r.addIssue({code:"custom",...i,fatal:u})}});if(!n){let l=Bs(e,s),i=l.fatal??t??!0;r.addIssue({code:"custom",...l,fatal:i})}}):Pr.create()}var vc={object:je.lazycreate},T;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(T||(T={}));var gc=(a,e={message:`Input not instance of ${a.name}`})=>Gs(t=>t instanceof a,e),Ys=Sr.create,Xs=Nr.create,yc=ft.create,_c=jr.create,en=Lr.create,Ec=Mr.create,bc=lt.create,Sc=Fr.create,Pc=Ur.create,xc=Pr.create,wc=gr.create,Rc=Je.create,Tc=ct.create,Oc=yr.create,Ac=je.create,Dc=je.strictCreate,Ic=qr.create,$c=qt.create,kc=Vr.create,Cc=or.create,Nc=Vt.create,jc=ut.create,Lc=dt.create,Mc=zt.create,Fc=zr.create,Uc=Hr.create,qc=Zr.create,Vc=Br.create,zc=xr.create,Hc=Be.create,Zc=He.create,Bc=ir.create,Wc=Be.createWithPreprocess,Kc=wt.create,Qc=()=>Ys().optional(),Jc=()=>Xs().optional(),Gc=()=>en().optional(),Yc={string:(a=>Sr.create({...a,coerce:!0})),number:(a=>Nr.create({...a,coerce:!0})),boolean:(a=>Lr.create({...a,coerce:!0})),bigint:(a=>jr.create({...a,coerce:!0})),date:(a=>Mr.create({...a,coerce:!0}))};var Xc=Z;var Na="2025-06-18";var rn=[Na,"2025-03-26","2024-11-05","2024-10-07"],Ht="2.0",tn=o.union([o.string(),o.number().int()]),an=o.string(),eu=o.object({progressToken:o.optional(tn)}).passthrough(),We=o.object({_meta:o.optional(eu)}).passthrough(),Le=o.object({method:o.string(),params:o.optional(We)}),Rt=o.object({_meta:o.optional(o.object({}).passthrough())}).passthrough(),lr=o.object({method:o.string(),params:o.optional(Rt)}),Ke=o.object({_meta:o.optional(o.object({}).passthrough())}).passthrough(),Zt=o.union([o.string(),o.number().int()]),sn=o.object({jsonrpc:o.literal(Ht),id:Zt}).merge(Le).strict(),nn=a=>sn.safeParse(a).success,on=o.object({jsonrpc:o.literal(Ht)}).merge(lr).strict(),ln=a=>on.safeParse(a).success,cn=o.object({jsonrpc:o.literal(Ht),id:Zt,result:Ke}).strict(),ja=a=>cn.safeParse(a).success,Ge;(function(a){a[a.ConnectionClosed=-32e3]="ConnectionClosed",a[a.RequestTimeout=-32001]="RequestTimeout",a[a.ParseError=-32700]="ParseError",a[a.InvalidRequest=-32600]="InvalidRequest",a[a.MethodNotFound=-32601]="MethodNotFound",a[a.InvalidParams=-32602]="InvalidParams",a[a.InternalError=-32603]="InternalError"})(Ge||(Ge={}));var un=o.object({jsonrpc:o.literal(Ht),id:Zt,error:o.object({code:o.number().int(),message:o.string(),data:o.optional(o.unknown())})}).strict(),dn=a=>un.safeParse(a).success,fn=o.union([sn,on,cn,un]),Bt=Ke.strict(),Wt=lr.extend({method:o.literal("notifications/cancelled"),params:Rt.extend({requestId:Zt,reason:o.string().optional()})}),ru=o.object({src:o.string(),mimeType:o.optional(o.string()),sizes:o.optional(o.array(o.string()))}).passthrough(),Tt=o.object({icons:o.array(ru).optional()}).passthrough(),Ot=o.object({name:o.string(),title:o.optional(o.string())}).passthrough(),pn=Ot.extend({version:o.string(),websiteUrl:o.optional(o.string())}).merge(Tt),tu=o.object({experimental:o.optional(o.object({}).passthrough()),sampling:o.optional(o.object({}).passthrough()),elicitation:o.optional(o.object({}).passthrough()),roots:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough())}).passthrough(),La=Le.extend({method:o.literal("initialize"),params:We.extend({protocolVersion:o.string(),capabilities:tu,clientInfo:pn})});var au=o.object({experimental:o.optional(o.object({}).passthrough()),logging:o.optional(o.object({}).passthrough()),completions:o.optional(o.object({}).passthrough()),prompts:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough()),resources:o.optional(o.object({subscribe:o.optional(o.boolean()),listChanged:o.optional(o.boolean())}).passthrough()),tools:o.optional(o.object({listChanged:o.optional(o.boolean())}).passthrough())}).passthrough(),su=Ke.extend({protocolVersion:o.string(),capabilities:au,serverInfo:pn,instructions:o.optional(o.string())}),Ma=lr.extend({method:o.literal("notifications/initialized")});var Kt=Le.extend({method:o.literal("ping")}),nu=o.object({progress:o.number(),total:o.optional(o.number()),message:o.optional(o.string())}).passthrough(),Qt=lr.extend({method:o.literal("notifications/progress"),params:Rt.merge(nu).extend({progressToken:tn})}),Jt=Le.extend({params:We.extend({cursor:o.optional(an)}).optional()}),Gt=Ke.extend({nextCursor:o.optional(an)}),hn=o.object({uri:o.string(),mimeType:o.optional(o.string()),_meta:o.optional(o.object({}).passthrough())}).passthrough(),mn=hn.extend({text:o.string()}),Fa=o.string().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),vn=hn.extend({blob:Fa}),gn=Ot.extend({uri:o.string(),description:o.optional(o.string()),mimeType:o.optional(o.string()),_meta:o.optional(o.object({}).passthrough())}).merge(Tt),ou=Ot.extend({uriTemplate:o.string(),description:o.optional(o.string()),mimeType:o.optional(o.string()),_meta:o.optional(o.object({}).passthrough())}).merge(Tt),iu=Jt.extend({method:o.literal("resources/list")}),lu=Gt.extend({resources:o.array(gn)}),cu=Jt.extend({method:o.literal("resources/templates/list")}),uu=Gt.extend({resourceTemplates:o.array(ou)}),du=Le.extend({method:o.literal("resources/read"),params:We.extend({uri:o.string()})}),fu=Ke.extend({contents:o.array(o.union([mn,vn]))}),pu=lr.extend({method:o.literal("notifications/resources/list_changed")}),hu=Le.extend({method:o.literal("resources/subscribe"),params:We.extend({uri:o.string()})}),mu=Le.extend({method:o.literal("resources/unsubscribe"),params:We.extend({uri:o.string()})}),vu=lr.extend({method:o.literal("notifications/resources/updated"),params:Rt.extend({uri:o.string()})}),gu=o.object({name:o.string(),description:o.optional(o.string()),required:o.optional(o.boolean())}).passthrough(),yu=Ot.extend({description:o.optional(o.string()),arguments:o.optional(o.array(gu)),_meta:o.optional(o.object({}).passthrough())}).merge(Tt),_u=Jt.extend({method:o.literal("prompts/list")}),Eu=Gt.extend({prompts:o.array(yu)}),bu=Le.extend({method:o.literal("prompts/get"),params:We.extend({name:o.string(),arguments:o.optional(o.record(o.string()))})}),Ua=o.object({type:o.literal("text"),text:o.string(),_meta:o.optional(o.object({}).passthrough())}).passthrough(),qa=o.object({type:o.literal("image"),data:Fa,mimeType:o.string(),_meta:o.optional(o.object({}).passthrough())}).passthrough(),Va=o.object({type:o.literal("audio"),data:Fa,mimeType:o.string(),_meta:o.optional(o.object({}).passthrough())}).passthrough(),Su=o.object({type:o.literal("resource"),resource:o.union([mn,vn]),_meta:o.optional(o.object({}).passthrough())}).passthrough(),Pu=gn.extend({type:o.literal("resource_link")}),yn=o.union([Ua,qa,Va,Pu,Su]),xu=o.object({role:o.enum(["user","assistant"]),content:yn}).passthrough(),wu=Ke.extend({description:o.optional(o.string()),messages:o.array(xu)}),Ru=lr.extend({method:o.literal("notifications/prompts/list_changed")}),Tu=o.object({title:o.optional(o.string()),readOnlyHint:o.optional(o.boolean()),destructiveHint:o.optional(o.boolean()),idempotentHint:o.optional(o.boolean()),openWorldHint:o.optional(o.boolean())}).passthrough(),Ou=Ot.extend({description:o.optional(o.string()),inputSchema:o.object({type:o.literal("object"),properties:o.optional(o.object({}).passthrough()),required:o.optional(o.array(o.string()))}).passthrough(),outputSchema:o.optional(o.object({type:o.literal("object"),properties:o.optional(o.object({}).passthrough()),required:o.optional(o.array(o.string()))}).passthrough()),annotations:o.optional(Tu),_meta:o.optional(o.object({}).passthrough())}).merge(Tt),za=Jt.extend({method:o.literal("tools/list")}),Au=Gt.extend({tools:o.array(Ou)}),_n=Ke.extend({content:o.array(yn).default([]),structuredContent:o.object({}).passthrough().optional(),isError:o.optional(o.boolean())}),Dp=_n.or(Ke.extend({toolResult:o.unknown()})),Ha=Le.extend({method:o.literal("tools/call"),params:We.extend({name:o.string(),arguments:o.optional(o.record(o.unknown()))})}),Du=lr.extend({method:o.literal("notifications/tools/list_changed")}),At=o.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),Za=Le.extend({method:o.literal("logging/setLevel"),params:We.extend({level:At})}),Iu=lr.extend({method:o.literal("notifications/message"),params:Rt.extend({level:At,logger:o.optional(o.string()),data:o.unknown()})}),$u=o.object({name:o.string().optional()}).passthrough(),ku=o.object({hints:o.optional(o.array($u)),costPriority:o.optional(o.number().min(0).max(1)),speedPriority:o.optional(o.number().min(0).max(1)),intelligencePriority:o.optional(o.number().min(0).max(1))}).passthrough(),Cu=o.object({role:o.enum(["user","assistant"]),content:o.union([Ua,qa,Va])}).passthrough(),Nu=Le.extend({method:o.literal("sampling/createMessage"),params:We.extend({messages:o.array(Cu),systemPrompt:o.optional(o.string()),includeContext:o.optional(o.enum(["none","thisServer","allServers"])),temperature:o.optional(o.number()),maxTokens:o.number().int(),stopSequences:o.optional(o.array(o.string())),metadata:o.optional(o.object({}).passthrough()),modelPreferences:o.optional(ku)})}),Ba=Ke.extend({model:o.string(),stopReason:o.optional(o.enum(["endTurn","stopSequence","maxTokens"]).or(o.string())),role:o.enum(["user","assistant"]),content:o.discriminatedUnion("type",[Ua,qa,Va])}),ju=o.object({type:o.literal("boolean"),title:o.optional(o.string()),description:o.optional(o.string()),default:o.optional(o.boolean())}).passthrough(),Lu=o.object({type:o.literal("string"),title:o.optional(o.string()),description:o.optional(o.string()),minLength:o.optional(o.number()),maxLength:o.optional(o.number()),format:o.optional(o.enum(["email","uri","date","date-time"]))}).passthrough(),Mu=o.object({type:o.enum(["number","integer"]),title:o.optional(o.string()),description:o.optional(o.string()),minimum:o.optional(o.number()),maximum:o.optional(o.number())}).passthrough(),Fu=o.object({type:o.literal("string"),title:o.optional(o.string()),description:o.optional(o.string()),enum:o.array(o.string()),enumNames:o.optional(o.array(o.string()))}).passthrough(),Uu=o.union([ju,Lu,Mu,Fu]),qu=Le.extend({method:o.literal("elicitation/create"),params:We.extend({message:o.string(),requestedSchema:o.object({type:o.literal("object"),properties:o.record(o.string(),Uu),required:o.optional(o.array(o.string()))}).passthrough()})}),Wa=Ke.extend({action:o.enum(["accept","decline","cancel"]),content:o.optional(o.record(o.string(),o.unknown()))}),Vu=o.object({type:o.literal("ref/resource"),uri:o.string()}).passthrough();var zu=o.object({type:o.literal("ref/prompt"),name:o.string()}).passthrough(),Hu=Le.extend({method:o.literal("completion/complete"),params:We.extend({ref:o.union([zu,Vu]),argument:o.object({name:o.string(),value:o.string()}).passthrough(),context:o.optional(o.object({arguments:o.optional(o.record(o.string(),o.string()))}))})}),Zu=Ke.extend({completion:o.object({values:o.array(o.string()).max(100),total:o.optional(o.number().int()),hasMore:o.optional(o.boolean())}).passthrough()}),Bu=o.object({uri:o.string().startsWith("file://"),name:o.optional(o.string()),_meta:o.optional(o.object({}).passthrough())}).passthrough(),Wu=Le.extend({method:o.literal("roots/list")}),Ka=Ke.extend({roots:o.array(Bu)}),Ku=lr.extend({method:o.literal("notifications/roots/list_changed")}),Ip=o.union([Kt,La,Hu,Za,bu,_u,iu,cu,du,hu,mu,Ha,za]),$p=o.union([Wt,Qt,Ma,Ku]),kp=o.union([Bt,Ba,Wa,Ka]),Cp=o.union([Kt,Nu,qu,Wu]),Np=o.union([Wt,Qt,Iu,vu,pu,Du,Ru]),jp=o.union([Bt,su,Zu,wu,Eu,lu,uu,fu,_n,Au]),Ye=class extends Error{constructor(e,t,s){super(`MCP error ${e}: ${t}`),this.code=e,this.data=s,this.name="McpError"}};var Qu=6e4,Yt=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.setNotificationHandler(Wt,t=>{let s=this._requestHandlerAbortControllers.get(t.params.requestId);s?.abort(t.params.reason)}),this.setNotificationHandler(Qt,t=>{this._onprogress(t)}),this.setRequestHandler(Kt,t=>({}))}_setupTimeout(e,t,s,r,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:n,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Ye(Ge.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var t,s,r;this._transport=e;let n=(t=this.transport)===null||t===void 0?void 0:t.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};let l=(s=this.transport)===null||s===void 0?void 0:s.onerror;this._transport.onerror=u=>{l?.(u),this._onerror(u)};let i=(r=this._transport)===null||r===void 0?void 0:r.onmessage;this._transport.onmessage=(u,f)=>{i?.(u,f),ja(u)||dn(u)?this._onresponse(u):nn(u)?this._onrequest(u,f):ln(u)?this._onnotification(u):this._onerror(new Error(`Unknown message type: ${JSON.stringify(u)}`))},await this._transport.start()}_onclose(){var e;let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let s=new Ye(Ge.ConnectionClosed,"Connection closed");for(let r of t.values())r(s)}_onerror(e){var t;(t=this.onerror)===null||t===void 0||t.call(this,e)}_onnotification(e){var t;let s=(t=this._notificationHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackNotificationHandler;s!==void 0&&Promise.resolve().then(()=>s(e)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(e,t){var s,r;let n=(s=this._requestHandlers.get(e.method))!==null&&s!==void 0?s:this.fallbackRequestHandler,l=this._transport;if(n===void 0){l?.send({jsonrpc:"2.0",id:e.id,error:{code:Ge.MethodNotFound,message:"Method not found"}}).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let u={signal:i.signal,sessionId:l?.sessionId,_meta:(r=e.params)===null||r===void 0?void 0:r._meta,sendNotification:f=>this.notification(f,{relatedRequestId:e.id}),sendRequest:(f,p,m)=>this.request(f,p,{...m,relatedRequestId:e.id}),authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo};Promise.resolve().then(()=>n(e,u)).then(f=>{if(!i.signal.aborted)return l?.send({result:f,jsonrpc:"2.0",id:e.id})},f=>{var p;if(!i.signal.aborted)return l?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(f.code)?f.code:Ge.InternalError,message:(p=f.message)!==null&&p!==void 0?p:"Internal error"}})}).catch(f=>this._onerror(new Error(`Failed to send response: ${f}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...s}=e.params,r=Number(t),n=this._progressHandlers.get(r);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let l=this._responseHandlers.get(r),i=this._timeoutInfo.get(r);if(i&&l&&i.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){l(u);return}n(s)}_onresponse(e){let t=Number(e.id),s=this._responseHandlers.get(t);if(s===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),ja(e))s(e);else{let r=new Ye(e.error.code,e.error.message,e.error.data);s(r)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,t,s){let{relatedRequestId:r,resumptionToken:n,onresumptiontoken:l}=s??{};return new Promise((i,u)=>{var f,p,m,E,c,y;if(!this._transport){u(new Error("Not connected"));return}((f=this._options)===null||f===void 0?void 0:f.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(p=s?.signal)===null||p===void 0||p.throwIfAborted();let _=this._requestMessageId++,v={...e,jsonrpc:"2.0",id:_};s?.onprogress&&(this._progressHandlers.set(_,s.onprogress),v.params={...e.params,_meta:{...((m=e.params)===null||m===void 0?void 0:m._meta)||{},progressToken:_}});let P=R=>{var D;this._responseHandlers.delete(_),this._progressHandlers.delete(_),this._cleanupTimeout(_),(D=this._transport)===null||D===void 0||D.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:_,reason:String(R)}},{relatedRequestId:r,resumptionToken:n,onresumptiontoken:l}).catch(I=>this._onerror(new Error(`Failed to send cancellation: ${I}`))),u(R)};this._responseHandlers.set(_,R=>{var D;if(!(!((D=s?.signal)===null||D===void 0)&&D.aborted)){if(R instanceof Error)return u(R);try{let I=t.parse(R.result);i(I)}catch(I){u(I)}}}),(E=s?.signal)===null||E===void 0||E.addEventListener("abort",()=>{var R;P((R=s?.signal)===null||R===void 0?void 0:R.reason)});let O=(c=s?.timeout)!==null&&c!==void 0?c:Qu,x=()=>P(new Ye(Ge.RequestTimeout,"Request timed out",{timeout:O}));this._setupTimeout(_,O,s?.maxTotalTimeout,x,(y=s?.resetTimeoutOnProgress)!==null&&y!==void 0?y:!1),this._transport.send(v,{relatedRequestId:r,resumptionToken:n,onresumptiontoken:l}).catch(R=>{this._cleanupTimeout(_),u(R)})})}async notification(e,t){var s,r;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((r=(s=this._options)===null||s===void 0?void 0:s.debouncedNotificationMethods)!==null&&r!==void 0?r:[]).includes(e.method)&&!e.params&&!t?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var u;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let f={...e,jsonrpc:"2.0"};(u=this._transport)===null||u===void 0||u.send(f,t).catch(p=>this._onerror(p))});return}let i={...e,jsonrpc:"2.0"};await this._transport.send(i,t)}setRequestHandler(e,t){let s=e.shape.method.value;this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(r,n)=>Promise.resolve(t(e.parse(r),n)))}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,t){this._notificationHandlers.set(e.shape.method.value,s=>Promise.resolve(t(e.parse(s))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function En(a,e){return Object.entries(e).reduce((t,[s,r])=>(r&&typeof r=="object"?t[s]=t[s]?{...t[s],...r}:r:t[s]=r,t),{...a})}var Pi=Ia(Si(),1),ga=class extends Yt{constructor(e,t){var s;super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(At.options.map((r,n)=>[r,n])),this.isMessageIgnored=(r,n)=>{let l=this._loggingLevels.get(n);return l?this.LOG_LEVEL_SEVERITY.get(r)this._oninitialize(r)),this.setNotificationHandler(Ma,()=>{var r;return(r=this.oninitialized)===null||r===void 0?void 0:r.call(this)}),this._capabilities.logging&&this.setRequestHandler(Za,async(r,n)=>{var l;let i=n.sessionId||((l=n.requestInfo)===null||l===void 0?void 0:l.headers["mcp-session-id"])||void 0,{level:u}=r.params,f=At.safeParse(u);return f.success&&this._loggingLevels.set(i,f.data),{}})}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=En(this._capabilities,e)}assertCapabilityForMethod(e){var t,s,r;switch(e){case"sampling/createMessage":if(!(!((t=this._clientCapabilities)===null||t===void 0)&&t.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!(!((s=this._clientCapabilities)===null||s===void 0)&&s.elicitation))throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!(!((r=this._clientCapabilities)===null||r===void 0)&&r.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/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (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"ping":case"initialize":break}}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:rn.includes(t)?t:Na,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"},Bt)}async createMessage(e,t){return this.request({method:"sampling/createMessage",params:e},Ba,t)}async elicitInput(e,t){let s=await this.request({method:"elicitation/create",params:e},Wa,t);if(s.action==="accept"&&s.content)try{let r=new Pi.default,n=r.compile(e.requestedSchema);if(!n(s.content))throw new Ye(Ge.InvalidParams,`Elicitation response content does not match requested schema: ${r.errorsText(n.errors)}`)}catch(r){throw r instanceof Ye?r:new Ye(Ge.InternalError,`Error validating elicitation response: ${r}`)}return s}async listRoots(e,t){return this.request({method:"roots/list",params:e},Ka,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))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 _s=Ia(require("node:process"),1);var ya=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(` +`);if(e===-1)return null;let t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),Af(t)}clear(){this._buffer=void 0}};function Af(a){return fn.parse(JSON.parse(a))}function xi(a){return JSON.stringify(a)+` +`}var _a=class{constructor(e=_s.default.stdin,t=_s.default.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new ya,this._started=!1,this._ondata=s=>{this._readBuffer.append(s),this.processReadBuffer()},this._onerror=s=>{var r;(r=this.onerror)===null||r===void 0||r.call(this,s)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(var e,t;;)try{let s=this._readBuffer.readMessage();if(s===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,s)}catch(s){(t=this.onerror)===null||t===void 0||t.call(this,s)}}async close(){var e;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),(e=this.onclose)===null||e===void 0||e.call(this)}send(e){return new Promise(t=>{let s=xi(e);this._stdout.write(s)?t():this._stdout.once("drain",t)})}};var Ri=Symbol("Let zodToJsonSchema decide on which parser to use");var wi={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"},Ti=a=>typeof a=="string"?{...wi,name:a}:{...wi,...a};var Oi=a=>{let e=Ti(a),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,flags:{hasReferencedOpenAiAnyType:!1},currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,r])=>[r._def,{def:r._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}};function Es(a,e,t,s){s?.errorMessages&&t&&(a.errorMessage={...a.errorMessage,[e]:t})}function ee(a,e,t,s,r){a[e]=t,Es(a,e,s,r)}var Ea=(a,e)=>{let t=0;for(;tB(a.innerType._def,e);function bs(a,e,t){let s=t??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,n)=>bs(a,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Df(a,e)}}var Df=(a,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let s of a.checks)switch(s.kind){case"min":ee(t,"minimum",s.value,s.message,e);break;case"max":ee(t,"maximum",s.value,s.message,e);break}return t};function ki(a,e){return{...B(a.innerType._def,e),default:a.defaultValue()}}function Ci(a,e){return e.effectStrategy==="input"?B(a.schema._def,e):fe(e)}function Ni(a){return{type:"string",enum:Array.from(a.values)}}var If=a=>"type"in a&&a.type==="string"?!1:"allOf"in a;function ji(a,e){let t=[B(a.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),B(a.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(n=>!!n),s=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,r=[];return t.forEach(n=>{if(If(n))r.push(...n.allOf),n.unevaluatedProperties===void 0&&(s=void 0);else{let l=n;if("additionalProperties"in n&&n.additionalProperties===!1){let{additionalProperties:i,...u}=n;l=u}else s=void 0;r.push(l)}}),r.length?{allOf:r,...s}:void 0}function Li(a,e){let t=typeof a.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(a.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[a.value]}:{type:t==="bigint"?"integer":t,const:a.value}}var Ss,Xe={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:()=>(Ss===void 0&&(Ss=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ss),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 Sa(a,e){let t={type:"string"};if(a.checks)for(let s of a.checks)switch(s.kind){case"min":ee(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,s.value):s.value,s.message,e);break;case"max":ee(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":er(t,"email",s.message,e);break;case"format:idn-email":er(t,"idn-email",s.message,e);break;case"pattern:zod":$e(t,Xe.email,s.message,e);break}break;case"url":er(t,"uri",s.message,e);break;case"uuid":er(t,"uuid",s.message,e);break;case"regex":$e(t,s.regex,s.message,e);break;case"cuid":$e(t,Xe.cuid,s.message,e);break;case"cuid2":$e(t,Xe.cuid2,s.message,e);break;case"startsWith":$e(t,RegExp(`^${Ps(s.value,e)}`),s.message,e);break;case"endsWith":$e(t,RegExp(`${Ps(s.value,e)}$`),s.message,e);break;case"datetime":er(t,"date-time",s.message,e);break;case"date":er(t,"date",s.message,e);break;case"time":er(t,"time",s.message,e);break;case"duration":er(t,"duration",s.message,e);break;case"length":ee(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,s.value):s.value,s.message,e),ee(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,s.value):s.value,s.message,e);break;case"includes":{$e(t,RegExp(Ps(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&er(t,"ipv4",s.message,e),s.version!=="v4"&&er(t,"ipv6",s.message,e);break}case"base64url":$e(t,Xe.base64url,s.message,e);break;case"jwt":$e(t,Xe.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&$e(t,Xe.ipv4Cidr,s.message,e),s.version!=="v4"&&$e(t,Xe.ipv6Cidr,s.message,e);break}case"emoji":$e(t,Xe.emoji(),s.message,e);break;case"ulid":{$e(t,Xe.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{er(t,"binary",s.message,e);break}case"contentEncoding:base64":{ee(t,"contentEncoding","base64",s.message,e);break}case"pattern:zod":{$e(t,Xe.base64,s.message,e);break}}break}case"nanoid":$e(t,Xe.nanoid,s.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return t}function Ps(a,e){return e.patternStrategy==="escape"?kf(a):a}var $f=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function kf(a){let e="";for(let t=0;tr.format)?(a.anyOf||(a.anyOf=[]),a.format&&(a.anyOf.push({format:a.format,...a.errorMessage&&s.errorMessages&&{errorMessage:{format:a.errorMessage.format}}}),delete a.format,a.errorMessage&&(delete a.errorMessage.format,Object.keys(a.errorMessage).length===0&&delete a.errorMessage)),a.anyOf.push({format:e,...t&&s.errorMessages&&{errorMessage:{format:t}}})):ee(a,"format",e,t,s)}function $e(a,e,t,s){a.pattern||a.allOf?.some(r=>r.pattern)?(a.allOf||(a.allOf=[]),a.pattern&&(a.allOf.push({pattern:a.pattern,...a.errorMessage&&s.errorMessages&&{errorMessage:{pattern:a.errorMessage.pattern}}}),delete a.pattern,a.errorMessage&&(delete a.errorMessage.pattern,Object.keys(a.errorMessage).length===0&&delete a.errorMessage)),a.allOf.push({pattern:Mi(e,s),...t&&s.errorMessages&&{errorMessage:{pattern:t}}})):ee(a,"pattern",Mi(e,s),t,s)}function Mi(a,e){if(!e.applyRegexFlags||!a.flags)return a.source;let t={i:a.flags.includes("i"),m:a.flags.includes("m"),s:a.flags.includes("s")},s=t.i?a.source.toLowerCase():a.source,r="",n=!1,l=!1,i=!1;for(let u=0;u({...s,[r]:B(a.valueType._def,{...e,currentPath:[...e.currentPath,"properties",r]})??fe(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let t={type:"object",additionalProperties:B(a.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return t;if(a.keyType?._def.typeName===R.ZodString&&a.keyType._def.checks?.length){let{type:s,...r}=Sa(a.keyType._def,e);return{...t,propertyNames:r}}else{if(a.keyType?._def.typeName===R.ZodEnum)return{...t,propertyNames:{enum:a.keyType._def.values}};if(a.keyType?._def.typeName===R.ZodBranded&&a.keyType._def.type._def.typeName===R.ZodString&&a.keyType._def.type._def.checks?.length){let{type:s,...r}=Ea(a.keyType._def,e);return{...t,propertyNames:r}}}return t}function Lo(a,e){if(e.mapStrategy==="record")return xa(a,e);let t=B(a.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||fe(e),s=B(a.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||fe(e);return{type:"array",maxItems:125,items:{type:"array",items:[t,s],minItems:2,maxItems:2}}}function qo(a){let e=a.values,s=Object.keys(a.values).filter(n=>typeof e[e[n]]!="number").map(n=>e[n]),r=Array.from(new Set(s.map(n=>typeof n)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:s}}function Uo(a){return a.target==="openAi"?void 0:{not:fe({...a,currentPath:[...a.currentPath,"not"]})}}function Vo(a){return a.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var $t={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Ho(a,e){if(e.target==="openApi3")return zo(a,e);let t=a.options instanceof Map?Array.from(a.options.values()):a.options;if(t.every(s=>s._def.typeName in $t&&(!s._def.checks||!s._def.checks.length))){let s=t.reduce((r,n)=>{let l=$t[n._def.typeName];return l&&!r.includes(l)?[...r,l]:r},[]);return{type:s.length>1?s:s[0]}}else if(t.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){let s=t.reduce((r,n)=>{let l=typeof n._def.value;switch(l){case"string":case"number":case"boolean":return[...r,l];case"bigint":return[...r,"integer"];case"object":if(n._def.value===null)return[...r,"null"];case"symbol":case"undefined":case"function":default:return r}},[]);if(s.length===t.length){let r=s.filter((n,l,o)=>o.indexOf(n)===l);return{type:r.length>1?r:r[0],enum:t.reduce((n,l)=>n.includes(l._def.value)?n:[...n,l._def.value],[])}}}else if(t.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:t.reduce((s,r)=>[...s,...r._def.values.filter(n=>!s.includes(n))],[])};return zo(a,e)}var zo=(a,e)=>{let t=(a.options instanceof Map?Array.from(a.options.values()):a.options).map((s,r)=>B(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${r}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return t.length?{anyOf:t}:void 0};function Zo(a,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(a.innerType._def.typeName)&&(!a.innerType._def.checks||!a.innerType._def.checks.length))return e.target==="openApi3"?{type:$t[a.innerType._def.typeName],nullable:!0}:{type:[$t[a.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let s=B(a.innerType._def,{...e,currentPath:[...e.currentPath]});return s&&"$ref"in s?{allOf:[s],nullable:!0}:s&&{...s,nullable:!0}}let t=B(a.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}function Bo(a,e){let t={type:"number"};if(!a.checks)return t;for(let s of a.checks)switch(s.kind){case"int":t.type="integer",bs(t,"type",s.message,e);break;case"min":e.target==="jsonSchema7"?s.inclusive?ee(t,"minimum",s.value,s.message,e):ee(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),ee(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?ee(t,"maximum",s.value,s.message,e):ee(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),ee(t,"maximum",s.value,s.message,e));break;case"multipleOf":ee(t,"multipleOf",s.value,s.message,e);break}return t}function Wo(a,e){let t=e.target==="openAi",s={type:"object",properties:{}},r=[],n=a.shape();for(let o in n){let u=n[o];if(u===void 0||u._def===void 0)continue;let f=Nf(u);f&&t&&(u._def.typeName==="ZodOptional"&&(u=u._def.innerType),u.isNullable()||(u=u.nullable()),f=!1);let p=B(u._def,{...e,currentPath:[...e.currentPath,"properties",o],propertyPath:[...e.currentPath,"properties",o]});p!==void 0&&(s.properties[o]=p,f||r.push(o))}r.length&&(s.required=r);let l=Cf(a,e);return l!==void 0&&(s.additionalProperties=l),s}function Cf(a,e){if(a.catchall._def.typeName!=="ZodNever")return B(a.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(a.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function Nf(a){try{return a.isOptional()}catch{return!0}}var Ko=(a,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return B(a.innerType._def,e);let t=B(a.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:fe(e)},t]}:fe(e)};var Qo=(a,e)=>{if(e.pipeStrategy==="input")return B(a.in._def,e);if(e.pipeStrategy==="output")return B(a.out._def,e);let t=B(a.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=B(a.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return{allOf:[t,s].filter(r=>r!==void 0)}};function Jo(a,e){return B(a.type._def,e)}function Go(a,e){let s={type:"array",uniqueItems:!0,items:B(a.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return a.minSize&&ee(s,"minItems",a.minSize.value,a.minSize.message,e),a.maxSize&&ee(s,"maxItems",a.maxSize.value,a.maxSize.message,e),s}function Yo(a,e){return a.rest?{type:"array",minItems:a.items.length,items:a.items.map((t,s)=>B(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[]),additionalItems:B(a.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:a.items.length,maxItems:a.items.length,items:a.items.map((t,s)=>B(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[])}}function Xo(a){return{not:fe(a)}}function el(a){return fe(a)}var rl=(a,e)=>B(a.innerType._def,e);var tl=(a,e,t)=>{switch(e){case R.ZodString:return Sa(a,t);case R.ZodNumber:return Bo(a,t);case R.ZodObject:return Wo(a,t);case R.ZodBigInt:return Do(a,t);case R.ZodBoolean:return Io();case R.ZodDate:return Es(a,t);case R.ZodUndefined:return Xo(t);case R.ZodNull:return Vo(t);case R.ZodArray:return Ao(a,t);case R.ZodUnion:case R.ZodDiscriminatedUnion:return Ho(a,t);case R.ZodIntersection:return jo(a,t);case R.ZodTuple:return Yo(a,t);case R.ZodRecord:return xa(a,t);case R.ZodLiteral:return Mo(a,t);case R.ZodEnum:return No(a);case R.ZodNativeEnum:return qo(a);case R.ZodNullable:return Zo(a,t);case R.ZodOptional:return Ko(a,t);case R.ZodMap:return Lo(a,t);case R.ZodSet:return Go(a,t);case R.ZodLazy:return()=>a.getter()._def;case R.ZodPromise:return Jo(a,t);case R.ZodNaN:case R.ZodNever:return Uo(t);case R.ZodEffects:return Co(a,t);case R.ZodAny:return fe(t);case R.ZodUnknown:return el(t);case R.ZodDefault:return $o(a,t);case R.ZodBranded:return Ea(a,t);case R.ZodReadonly:return rl(a,t);case R.ZodCatch:return ko(a,t);case R.ZodPipeline:return Qo(a,t);case R.ZodFunction:case R.ZodVoid:case R.ZodSymbol:return;default:return(s=>{})(e)}};function B(a,e,t=!1){let s=e.seen.get(a);if(e.override){let o=e.override?.(a,e,s,t);if(o!==Oo)return o}if(s&&!t){let o=jf(s,e);if(o!==void 0)return o}let r={def:a,path:e.currentPath,jsonSchema:void 0};e.seen.set(a,r);let n=tl(a,a.typeName,e),l=typeof n=="function"?B(n(),e):n;if(l&&Mf(a,e,l),e.postProcess){let o=e.postProcess(l,a,e);return r.jsonSchema=l,o}return r.jsonSchema=l,l}var jf=(a,e)=>{switch(e.$refStrategy){case"root":return{$ref:a.path.join("/")};case"relative":return{$ref:ba(e.currentPath,a.path)};case"none":case"seen":return a.path.lengthe.currentPath[s]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),fe(e)):e.$refStrategy==="seen"?fe(e):void 0}},Mf=(a,e,t)=>(a.description&&(t.description=a.description,e.markdownDescription&&(t.markdownDescription=a.description)),t);var Ps=(a,e)=>{let t=To(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[f,p])=>({...u,[f]:B(p._def,{...t,currentPath:[...t.basePath,t.definitionPath,f]},!0)??fe(t)}),{}):void 0,r=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,n=B(a._def,r===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,r]},!1)??fe(t),l=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;l!==void 0&&(n.title=l),t.flags.hasReferencedOpenAiAnyType&&(s||(s={}),s[t.openAiAnyTypeName]||(s[t.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:t.$refStrategy==="relative"?"1":[...t.basePath,t.definitionPath,t.openAiAnyTypeName].join("/")}}));let o=r===void 0?s?{...n,[t.definitionPath]:s}:n:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,r].join("/"),[t.definitionPath]:{...s,[r]:n}};return t.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":(t.target==="jsonSchema2019-09"||t.target==="openAi")&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),t.target==="openAi"&&("anyOf"in o||"oneOf"in o||"allOf"in o||"type"in o&&Array.isArray(o.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),o};var al=require("fs"),sl=require("os"),nl=require("path"),Ff=(0,nl.join)((0,sl.homedir)(),".claude-mem","silent.log");function we(a,e,t=""){let s=new Date().toISOString(),o=((new Error().stack||"").split(` -`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),u=o?`${o[1].split("/").pop()}:${o[2]}`:"unknown",f=`[${s}] [HAPPY-PATH-ERROR] [${u}] ${a}`;if(e!==void 0)try{f+=` ${JSON.stringify(e)}`}catch(p){f+=` [stringify error: ${p}]`}f+=` -`;try{(0,al.appendFileSync)(Ff,f)}catch(p){console.error("[silent-debug] Failed to write to log:",p)}return t}var wa=Ia(require("path"),1),As=require("os");var mt=require("fs"),ll=require("path"),cl=require("os");var Lf=["bugfix","feature","refactor","discovery","decision","change"],qf=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var il=Lf.join(","),ol=qf.join(",");var ar=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:(0,ll.join)((0,cl.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:il,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:ol,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return this.DEFAULTS[e]}static getInt(e){let t=this.get(e);return parseInt(t,10)}static getBool(e){return this.get(e)==="true"}static loadFromFile(e){if(!(0,mt.existsSync)(e))return this.getAllDefaults();let t=(0,mt.readFileSync)(e,"utf-8"),s=JSON.parse(t),r=s;if(s.env&&typeof s.env=="object"){r=s.env;try{(0,mt.writeFileSync)(e,JSON.stringify(r,null,2),"utf-8"),Ct.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:e})}catch(l){Ct.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:e},l)}}let n={...this.DEFAULTS};for(let l of Object.keys(this.DEFAULTS))r[l]!==void 0&&(n[l]=r[l]);return n}};var ws=(n=>(n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR",n[n.SILENT=4]="SILENT",n))(ws||{}),Os=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let e=ar.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=ws[e]??1}return this.level}correlationId(e,t){return`obs-${e}-${t}`}sessionId(e){return`session-${e}`}formatData(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="object"){if(e instanceof Error)return this.getLevel()===0?`${e.message} -${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let t=Object.keys(e);return t.length===0?"{}":t.length<=3?JSON.stringify(e):`{${t.length} keys: ${t.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,t){if(!t)return e;try{let s=typeof t=="string"?JSON.parse(t):t;if(e==="Bash"&&s.command){let r=s.command.length>50?s.command.substring(0,50)+"...":s.command;return`${e}(${r})`}if(e==="Read"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}if(e==="Edit"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}if(e==="Write"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}return e}catch{return e}}formatTimestamp(e){let t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),n=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0"),u=String(e.getMilliseconds()).padStart(3,"0");return`${t}-${s}-${r} ${n}:${l}:${o}.${u}`}log(e,t,s,r,n){if(e0&&(m=` {${Object.entries(v).map(([T,P])=>`${T}=${P}`).join(", ")}}`)}let b=`[${l}] [${o}] [${u}] ${f}${s}${m}${p}`;e===3?console.error(b):console.log(b)}debug(e,t,s,r){this.log(0,e,t,s,r)}info(e,t,s,r){this.log(1,e,t,s,r)}warn(e,t,s,r){this.log(2,e,t,s,r)}error(e,t,s,r){this.log(3,e,t,s,r)}dataIn(e,t,s,r){this.info(e,`\u2192 ${t}`,s,r)}dataOut(e,t,s,r){this.info(e,`\u2190 ${t}`,s,r)}success(e,t,s,r){this.info(e,`\u2713 ${t}`,s,r)}failure(e,t,s,r){this.error(e,`\u2717 ${t}`,s,r)}timing(e,t,s,r){this.info(e,`\u23F1 ${t}`,r,{duration:`${s}ms`})}},Ct=new Os;var Rs={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function ul(a){return process.platform==="win32"?Math.round(a*Rs.WINDOWS_MULTIPLIER):a}var Pa=require("path");var pl=require("os");var $e=require("path"),dl=require("os");var fl=require("url");var Vf={};function Uf(){return typeof __dirname<"u"?__dirname:(0,$e.dirname)((0,fl.fileURLToPath)(Vf.url))}var Lg=Uf(),dr=ar.get("CLAUDE_MEM_DATA_DIR"),Ts=process.env.CLAUDE_CONFIG_DIR||(0,$e.join)((0,dl.homedir)(),".claude"),qg=(0,$e.join)(dr,"archives"),Ug=(0,$e.join)(dr,"logs"),Vg=(0,$e.join)(dr,"trash"),zg=(0,$e.join)(dr,"backups"),Hg=(0,$e.join)(dr,"settings.json"),Zg=(0,$e.join)(dr,"claude-mem.db"),Bg=(0,$e.join)(dr,"vector-db"),Wg=(0,$e.join)(Ts,"settings.json"),Kg=(0,$e.join)(Ts,"commands"),Qg=(0,$e.join)(Ts,"CLAUDE.md");var ty=(0,Pa.join)(dr,"worker.pid"),ay=(0,Pa.join)(dr,"logs"),sy=(0,Pa.join)((0,pl.homedir)(),".claude","plugins","marketplaces","thedotmack");var hy=wa.default.join((0,As.homedir)(),".claude","plugins","marketplaces","thedotmack"),my=ul(Rs.HEALTH_CHECK),vt=null;function hl(){if(vt!==null)return vt;try{let a=wa.default.join(ar.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=ar.loadFromFile(a);return vt=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),vt}catch(a){return Ct.debug("SYSTEM","Failed to load port from settings, using default",{error:a}),vt=parseInt(ar.get("CLAUDE_MEM_WORKER_PORT"),10),vt}}function ml(){let a=wa.default.join((0,As.homedir)(),".claude-mem","settings.json");return ar.loadFromFile(a).CLAUDE_MEM_WORKER_HOST}var zf=hl(),Hf=ml(),gt=`http://${Hf}:${zf}`,Ce={search:"/api/search",timeline:"/api/timeline",decisions:"/api/decisions",changes:"/api/changes",how_it_works:"/api/how-it-works",search_observations:"/api/search/observations",search_sessions:"/api/search/sessions",search_user_prompts:"/api/search/prompts",find_by_concept:"/api/search/by-concept",find_by_file:"/api/search/by-file",find_by_type:"/api/search/by-type",get_recent_context:"/api/context/recent",get_context_timeline:"/api/context/timeline",get_timeline_by_query:"/api/timeline/by-query",progressive_ix:"/api/instructions"};async function Ne(a,e){we("[mcp-server] \u2192 Worker API",{endpoint:a,params:e});try{let t=new URLSearchParams;for(let[l,o]of Object.entries(e))o!=null&&t.append(l,String(o));let s=`${gt}${a}?${t}`,r=await fetch(s);if(!r.ok){let l=await r.text();throw new Error(`Worker API error (${r.status}): ${l}`)}let n=await r.json();return we("[mcp-server] \u2190 Worker API success",{endpoint:a}),n}catch(t){return we("[mcp-server] \u2190 Worker API error",{endpoint:a,error:t.message}),{content:[{type:"text",text:`Error calling Worker API: ${t.message}`}],isError:!0}}}async function Ds(a,e){we("[mcp-server] \u2192 Worker API (path)",{endpoint:a,id:e});try{let t=`${gt}${a}/${e}`,s=await fetch(t);if(!s.ok){let n=await s.text();throw new Error(`Worker API error (${s.status}): ${n}`)}let r=await s.json();return we("[mcp-server] \u2190 Worker API success (path)",{endpoint:a,id:e}),{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}catch(t){return we("[mcp-server] \u2190 Worker API error (path)",{endpoint:a,id:e,error:t.message}),{content:[{type:"text",text:`Error calling Worker API: ${t.message}`}],isError:!0}}}async function Zf(a,e){we("[mcp-server] \u2192 Worker API (POST)",{endpoint:a,body:e});try{let t=`${gt}${a}`,s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok){let n=await s.text();throw new Error(`Worker API error (${s.status}): ${n}`)}let r=await s.json();return we("[mcp-server] \u2190 Worker API success (POST)",{endpoint:a}),{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}catch(t){return we("[mcp-server] \u2190 Worker API error (POST)",{endpoint:a,error:t.message}),{content:[{type:"text",text:`Error calling Worker API: ${t.message}`}],isError:!0}}}async function Bf(){try{return(await fetch(`${gt}/api/health`)).ok}catch{return!1}}var vl=[{name:"search",description:"Search observations, sessions, and prompts",inputSchema:i.object({query:i.string().optional().describe("Natural language search query for semantic ranking via ChromaDB vector search. Optional - omit for date-filtered queries only (Chroma cannot filter by date, requires direct SQLite)."),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED for initial search), "full" for complete details (use only after reviewing index results)'),type:i.enum(["observations","sessions","prompts"]).optional().describe("Filter by document type (observations, sessions, or prompts). Omit to search all types."),obs_type:i.string().optional().describe('Filter observations by type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change). Only applies when type="observations"'),concepts:i.string().optional().describe('Filter by concept tags (single value or comma-separated list). Only applies when type="observations"'),files:i.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match). Only applies when type="observations"'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Ce.search;return await Ne(e,a)}},{name:"timeline",description:"Get timeline around observation ID or query",inputSchema:i.object({query:i.string().optional().describe("Natural language query to find anchor observation (query-based mode). Mutually exclusive with anchor."),anchor:i.number().optional().describe("Observation ID to use as anchor (anchor-based mode). Mutually exclusive with query."),depth_before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),depth_after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter observations by type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name")}),handler:async a=>{let e=Ce.timeline;return await Ne(e,a)}},{name:"decisions",description:"Find architectural and design decisions",inputSchema:i.object({query:i.string().describe("Natural language query for finding decisions"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Ce.decisions;return await Ne(e,a)}},{name:"changes",description:"Find code changes and refactorings",inputSchema:i.object({query:i.string().describe("Natural language query for finding changes"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Ce.changes;return await Ne(e,a)}},{name:"how_it_works",description:"Understand system architecture",inputSchema:i.object({query:i.string().describe("Natural language query for understanding how something works"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Ce.how_it_works;return await Ne(e,a)}},{name:"search_observations",description:"[DEPRECATED] Search observations only",inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Ce.search_observations;return await Ne(e,a)}},{name:"search_sessions",description:"[DEPRECATED] Search sessions only",inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Ce.search_sessions;return await Ne(e,a)}},{name:"search_user_prompts",description:"[DEPRECATED] Search prompts only",inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Ce.search_user_prompts;return await Ne(e,a)}},{name:"find_by_concept",description:"Find observations by concept tags",inputSchema:i.object({concepts:i.string().describe("Concept tag(s) to filter by (single value or comma-separated list)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Ce.find_by_concept;return await Ne(e,a)}},{name:"find_by_file",description:"Find observations by file paths",inputSchema:i.object({files:i.string().describe("File path(s) to filter by (single value or comma-separated list for partial match)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Ce.find_by_file;return await Ne(e,a)}},{name:"find_by_type",description:"Find observations by type",inputSchema:i.object({type:i.string().describe("Observation type(s) to filter by (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Ce.find_by_type;return await Ne(e,a)}},{name:"get_recent_context",description:"Get recent timeline items",inputSchema:i.object({limit:i.number().min(1).max(100).default(30).describe("Maximum number of timeline items to return"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Ce.get_recent_context;return await Ne(e,a)}},{name:"get_context_timeline",description:"Get timeline around specific observation",inputSchema:i.object({anchor:i.number().describe("Observation ID to use as anchor point"),depth_before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),depth_after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name")}),handler:async a=>{let e=Ce.get_context_timeline;return await Ne(e,a)}},{name:"get_timeline_by_query",description:"Search and get timeline in one call",inputSchema:i.object({query:i.string().describe("Natural language query to find anchor observation"),depth_before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),depth_after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Ce.get_timeline_by_query;return await Ne(e,a)}},{name:"progressive_ix",description:"Load detailed instructions for mem-search tools",inputSchema:i.object({topic:i.enum(["workflow","search_params","examples","all"]).default("all").describe("Which instruction section to load: workflow (4-step process), search_params (parameters reference), examples (usage examples), all (complete guide)")}),handler:async a=>{let e=Ce.progressive_ix;return await Ne(e,a)}},{name:"get_observation",description:"Get full details for a single observation by ID",inputSchema:i.object({id:i.number().describe("Observation ID from search/timeline results")}),handler:async a=>await Ds("/api/observation",a.id)},{name:"get_batch_observations",description:"Get full details for multiple observations by IDs in one request",inputSchema:i.object({ids:i.array(i.number()).describe("Array of observation IDs to fetch"),orderBy:i.enum(["date_desc","date_asc"]).optional().describe("Sort order for results"),limit:i.number().optional().describe("Maximum number of results to return"),project:i.string().optional().describe("Filter by project name")}),handler:async a=>await Zf("/api/observations/batch",a)},{name:"get_session",description:"Get full session summary by ID",inputSchema:i.object({id:i.number().describe("Session ID (just the number from S1234)")}),handler:async a=>await Ds("/api/session",a.id)},{name:"get_prompt",description:"Get user prompt by ID",inputSchema:i.object({id:i.number().describe("Prompt ID from search results")}),handler:async a=>await Ds("/api/prompt",a.id)}],Is=new ga({name:"claude-mem-search-server",version:"1.0.0"},{capabilities:{tools:{}}});Is.setRequestHandler(za,async()=>({tools:vl.map(a=>({name:a.name,description:a.description,inputSchema:Ps(a.inputSchema)}))}));Is.setRequestHandler(Ha,async a=>{let e=vl.find(t=>t.name===a.params.name);if(!e)throw new Error(`Unknown tool: ${a.params.name}`);try{return await e.handler(a.params.arguments||{})}catch(t){return{content:[{type:"text",text:`Tool execution failed: ${t.message}`}],isError:!0}}});async function gl(){we("[mcp-server] Shutting down..."),process.exit(0)}process.on("SIGTERM",gl);process.on("SIGINT",gl);async function Wf(){let a=new _a;await Is.connect(a),we("[mcp-server] Claude-mem search server started"),setTimeout(async()=>{await Bf()?we("[mcp-server] Worker available at",gt):(we("[mcp-server] WARNING: Worker not available at",gt),we("[mcp-server] Tools will fail until Worker is started"),we("[mcp-server] Start Worker with: npm run worker:restart"))},0)}Wf().catch(a=>{we("[mcp-server] Fatal error:",a),process.exit(1)}); +]`;continue}r+=s[u],s[u]==="\\"?n=!0:l&&s[u]==="]"?l=!1:!l&&s[u]==="["&&(l=!0)}try{new RegExp(r)}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`),a.source}return r}function Pa(a,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"&&a.keyType?._def.typeName===T.ZodEnum)return{type:"object",required:a.keyType._def.values,properties:a.keyType._def.values.reduce((s,r)=>({...s,[r]:B(a.valueType._def,{...e,currentPath:[...e.currentPath,"properties",r]})??fe(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let t={type:"object",additionalProperties:B(a.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return t;if(a.keyType?._def.typeName===T.ZodString&&a.keyType._def.checks?.length){let{type:s,...r}=Sa(a.keyType._def,e);return{...t,propertyNames:r}}else{if(a.keyType?._def.typeName===T.ZodEnum)return{...t,propertyNames:{enum:a.keyType._def.values}};if(a.keyType?._def.typeName===T.ZodBranded&&a.keyType._def.type._def.typeName===T.ZodString&&a.keyType._def.type._def.checks?.length){let{type:s,...r}=ba(a.keyType._def,e);return{...t,propertyNames:r}}}return t}function Fi(a,e){if(e.mapStrategy==="record")return Pa(a,e);let t=B(a.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||fe(e),s=B(a.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||fe(e);return{type:"array",maxItems:125,items:{type:"array",items:[t,s],minItems:2,maxItems:2}}}function Ui(a){let e=a.values,s=Object.keys(a.values).filter(n=>typeof e[e[n]]!="number").map(n=>e[n]),r=Array.from(new Set(s.map(n=>typeof n)));return{type:r.length===1?r[0]==="string"?"string":"number":["string","number"],enum:s}}function qi(a){return a.target==="openAi"?void 0:{not:fe({...a,currentPath:[...a.currentPath,"not"]})}}function Vi(a){return a.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var It={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Hi(a,e){if(e.target==="openApi3")return zi(a,e);let t=a.options instanceof Map?Array.from(a.options.values()):a.options;if(t.every(s=>s._def.typeName in It&&(!s._def.checks||!s._def.checks.length))){let s=t.reduce((r,n)=>{let l=It[n._def.typeName];return l&&!r.includes(l)?[...r,l]:r},[]);return{type:s.length>1?s:s[0]}}else if(t.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){let s=t.reduce((r,n)=>{let l=typeof n._def.value;switch(l){case"string":case"number":case"boolean":return[...r,l];case"bigint":return[...r,"integer"];case"object":if(n._def.value===null)return[...r,"null"];case"symbol":case"undefined":case"function":default:return r}},[]);if(s.length===t.length){let r=s.filter((n,l,i)=>i.indexOf(n)===l);return{type:r.length>1?r:r[0],enum:t.reduce((n,l)=>n.includes(l._def.value)?n:[...n,l._def.value],[])}}}else if(t.every(s=>s._def.typeName==="ZodEnum"))return{type:"string",enum:t.reduce((s,r)=>[...s,...r._def.values.filter(n=>!s.includes(n))],[])};return zi(a,e)}var zi=(a,e)=>{let t=(a.options instanceof Map?Array.from(a.options.values()):a.options).map((s,r)=>B(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${r}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return t.length?{anyOf:t}:void 0};function Zi(a,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(a.innerType._def.typeName)&&(!a.innerType._def.checks||!a.innerType._def.checks.length))return e.target==="openApi3"?{type:It[a.innerType._def.typeName],nullable:!0}:{type:[It[a.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let s=B(a.innerType._def,{...e,currentPath:[...e.currentPath]});return s&&"$ref"in s?{allOf:[s],nullable:!0}:s&&{...s,nullable:!0}}let t=B(a.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}function Bi(a,e){let t={type:"number"};if(!a.checks)return t;for(let s of a.checks)switch(s.kind){case"int":t.type="integer",Es(t,"type",s.message,e);break;case"min":e.target==="jsonSchema7"?s.inclusive?ee(t,"minimum",s.value,s.message,e):ee(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),ee(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?ee(t,"maximum",s.value,s.message,e):ee(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),ee(t,"maximum",s.value,s.message,e));break;case"multipleOf":ee(t,"multipleOf",s.value,s.message,e);break}return t}function Wi(a,e){let t=e.target==="openAi",s={type:"object",properties:{}},r=[],n=a.shape();for(let i in n){let u=n[i];if(u===void 0||u._def===void 0)continue;let f=Nf(u);f&&t&&(u._def.typeName==="ZodOptional"&&(u=u._def.innerType),u.isNullable()||(u=u.nullable()),f=!1);let p=B(u._def,{...e,currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]});p!==void 0&&(s.properties[i]=p,f||r.push(i))}r.length&&(s.required=r);let l=Cf(a,e);return l!==void 0&&(s.additionalProperties=l),s}function Cf(a,e){if(a.catchall._def.typeName!=="ZodNever")return B(a.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(a.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function Nf(a){try{return a.isOptional()}catch{return!0}}var Ki=(a,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return B(a.innerType._def,e);let t=B(a.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:fe(e)},t]}:fe(e)};var Qi=(a,e)=>{if(e.pipeStrategy==="input")return B(a.in._def,e);if(e.pipeStrategy==="output")return B(a.out._def,e);let t=B(a.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=B(a.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return{allOf:[t,s].filter(r=>r!==void 0)}};function Ji(a,e){return B(a.type._def,e)}function Gi(a,e){let s={type:"array",uniqueItems:!0,items:B(a.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return a.minSize&&ee(s,"minItems",a.minSize.value,a.minSize.message,e),a.maxSize&&ee(s,"maxItems",a.maxSize.value,a.maxSize.message,e),s}function Yi(a,e){return a.rest?{type:"array",minItems:a.items.length,items:a.items.map((t,s)=>B(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[]),additionalItems:B(a.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:a.items.length,maxItems:a.items.length,items:a.items.map((t,s)=>B(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[])}}function Xi(a){return{not:fe(a)}}function el(a){return fe(a)}var rl=(a,e)=>B(a.innerType._def,e);var tl=(a,e,t)=>{switch(e){case T.ZodString:return Sa(a,t);case T.ZodNumber:return Bi(a,t);case T.ZodObject:return Wi(a,t);case T.ZodBigInt:return Di(a,t);case T.ZodBoolean:return Ii();case T.ZodDate:return bs(a,t);case T.ZodUndefined:return Xi(t);case T.ZodNull:return Vi(t);case T.ZodArray:return Ai(a,t);case T.ZodUnion:case T.ZodDiscriminatedUnion:return Hi(a,t);case T.ZodIntersection:return ji(a,t);case T.ZodTuple:return Yi(a,t);case T.ZodRecord:return Pa(a,t);case T.ZodLiteral:return Li(a,t);case T.ZodEnum:return Ni(a);case T.ZodNativeEnum:return Ui(a);case T.ZodNullable:return Zi(a,t);case T.ZodOptional:return Ki(a,t);case T.ZodMap:return Fi(a,t);case T.ZodSet:return Gi(a,t);case T.ZodLazy:return()=>a.getter()._def;case T.ZodPromise:return Ji(a,t);case T.ZodNaN:case T.ZodNever:return qi(t);case T.ZodEffects:return Ci(a,t);case T.ZodAny:return fe(t);case T.ZodUnknown:return el(t);case T.ZodDefault:return ki(a,t);case T.ZodBranded:return ba(a,t);case T.ZodReadonly:return rl(a,t);case T.ZodCatch:return $i(a,t);case T.ZodPipeline:return Qi(a,t);case T.ZodFunction:case T.ZodVoid:case T.ZodSymbol:return;default:return(s=>{})(e)}};function B(a,e,t=!1){let s=e.seen.get(a);if(e.override){let i=e.override?.(a,e,s,t);if(i!==Ri)return i}if(s&&!t){let i=jf(s,e);if(i!==void 0)return i}let r={def:a,path:e.currentPath,jsonSchema:void 0};e.seen.set(a,r);let n=tl(a,a.typeName,e),l=typeof n=="function"?B(n(),e):n;if(l&&Lf(a,e,l),e.postProcess){let i=e.postProcess(l,a,e);return r.jsonSchema=l,i}return r.jsonSchema=l,l}var jf=(a,e)=>{switch(e.$refStrategy){case"root":return{$ref:a.path.join("/")};case"relative":return{$ref:Ea(e.currentPath,a.path)};case"none":case"seen":return a.path.lengthe.currentPath[s]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),fe(e)):e.$refStrategy==="seen"?fe(e):void 0}},Lf=(a,e,t)=>(a.description&&(t.description=a.description,e.markdownDescription&&(t.markdownDescription=a.description)),t);var xs=(a,e)=>{let t=Oi(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[f,p])=>({...u,[f]:B(p._def,{...t,currentPath:[...t.basePath,t.definitionPath,f]},!0)??fe(t)}),{}):void 0,r=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,n=B(a._def,r===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,r]},!1)??fe(t),l=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;l!==void 0&&(n.title=l),t.flags.hasReferencedOpenAiAnyType&&(s||(s={}),s[t.openAiAnyTypeName]||(s[t.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:t.$refStrategy==="relative"?"1":[...t.basePath,t.definitionPath,t.openAiAnyTypeName].join("/")}}));let i=r===void 0?s?{...n,[t.definitionPath]:s}:n:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,r].join("/"),[t.definitionPath]:{...s,[r]:n}};return t.target==="jsonSchema7"?i.$schema="http://json-schema.org/draft-07/schema#":(t.target==="jsonSchema2019-09"||t.target==="openAi")&&(i.$schema="https://json-schema.org/draft/2019-09/schema#"),t.target==="openAi"&&("anyOf"in i||"oneOf"in i||"allOf"in i||"type"in i&&Array.isArray(i.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),i};var al=require("fs"),sl=require("os"),nl=require("path"),Mf=(0,nl.join)((0,sl.homedir)(),".claude-mem","silent.log");function we(a,e,t=""){let s=new Date().toISOString(),i=((new Error().stack||"").split(` +`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),u=i?`${i[1].split("/").pop()}:${i[2]}`:"unknown",f=`[${s}] [HAPPY-PATH-ERROR] [${u}] ${a}`;if(e!==void 0)try{f+=` ${JSON.stringify(e)}`}catch(p){f+=` [stringify error: ${p}]`}f+=` +`;try{(0,al.appendFileSync)(Mf,f)}catch(p){console.error("[silent-debug] Failed to write to log:",p)}return t}var wa=Ia(require("path"),1),As=require("os");var pt=require("fs"),ll=require("path"),cl=require("os");var Ff=["bugfix","feature","refactor","discovery","decision","change"],Uf=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var ol=Ff.join(","),il=Uf.join(",");var rr=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:(0,ll.join)((0,cl.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:ol,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:il,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return this.DEFAULTS[e]}static getInt(e){let t=this.get(e);return parseInt(t,10)}static getBool(e){return this.get(e)==="true"}static loadFromFile(e){if(!(0,pt.existsSync)(e))return this.getAllDefaults();let t=(0,pt.readFileSync)(e,"utf-8"),s=JSON.parse(t),r=s;if(s.env&&typeof s.env=="object"){r=s.env;try{(0,pt.writeFileSync)(e,JSON.stringify(r,null,2),"utf-8"),$t.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:e})}catch(l){$t.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:e},l)}}let n={...this.DEFAULTS};for(let l of Object.keys(this.DEFAULTS))r[l]!==void 0&&(n[l]=r[l]);return n}};var ws=(n=>(n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR",n[n.SILENT=4]="SILENT",n))(ws||{}),Rs=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let e=rr.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=ws[e]??1}return this.level}correlationId(e,t){return`obs-${e}-${t}`}sessionId(e){return`session-${e}`}formatData(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="object"){if(e instanceof Error)return this.getLevel()===0?`${e.message} +${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let t=Object.keys(e);return t.length===0?"{}":t.length<=3?JSON.stringify(e):`{${t.length} keys: ${t.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,t){if(!t)return e;try{let s=typeof t=="string"?JSON.parse(t):t;if(e==="Bash"&&s.command){let r=s.command.length>50?s.command.substring(0,50)+"...":s.command;return`${e}(${r})`}if(e==="Read"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}if(e==="Edit"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}if(e==="Write"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}return e}catch{return e}}formatTimestamp(e){let t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),n=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0"),i=String(e.getSeconds()).padStart(2,"0"),u=String(e.getMilliseconds()).padStart(3,"0");return`${t}-${s}-${r} ${n}:${l}:${i}.${u}`}log(e,t,s,r,n){if(e0&&(m=` {${Object.entries(v).map(([O,x])=>`${O}=${x}`).join(", ")}}`)}let E=`[${l}] [${i}] [${u}] ${f}${s}${m}${p}`;e===3?console.error(E):console.log(E)}debug(e,t,s,r){this.log(0,e,t,s,r)}info(e,t,s,r){this.log(1,e,t,s,r)}warn(e,t,s,r){this.log(2,e,t,s,r)}error(e,t,s,r){this.log(3,e,t,s,r)}dataIn(e,t,s,r){this.info(e,`\u2192 ${t}`,s,r)}dataOut(e,t,s,r){this.info(e,`\u2190 ${t}`,s,r)}success(e,t,s,r){this.info(e,`\u2713 ${t}`,s,r)}failure(e,t,s,r){this.error(e,`\u2717 ${t}`,s,r)}timing(e,t,s,r){this.info(e,`\u23F1 ${t}`,r,{duration:`${s}ms`})}},$t=new Rs;var Ts={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function ul(a){return process.platform==="win32"?Math.round(a*Ts.WINDOWS_MULTIPLIER):a}var xa=require("path");var pl=require("os");var ke=require("path"),dl=require("os");var fl=require("url");var Vf={};function qf(){return typeof __dirname<"u"?__dirname:(0,ke.dirname)((0,fl.fileURLToPath)(Vf.url))}var Fg=qf(),cr=rr.get("CLAUDE_MEM_DATA_DIR"),Os=process.env.CLAUDE_CONFIG_DIR||(0,ke.join)((0,dl.homedir)(),".claude"),Ug=(0,ke.join)(cr,"archives"),qg=(0,ke.join)(cr,"logs"),Vg=(0,ke.join)(cr,"trash"),zg=(0,ke.join)(cr,"backups"),Hg=(0,ke.join)(cr,"settings.json"),Zg=(0,ke.join)(cr,"claude-mem.db"),Bg=(0,ke.join)(cr,"vector-db"),Wg=(0,ke.join)(Os,"settings.json"),Kg=(0,ke.join)(Os,"commands"),Qg=(0,ke.join)(Os,"CLAUDE.md");var ty=(0,xa.join)(cr,"worker.pid"),ay=(0,xa.join)(cr,"logs"),sy=(0,xa.join)((0,pl.homedir)(),".claude","plugins","marketplaces","thedotmack");var hy=wa.default.join((0,As.homedir)(),".claude","plugins","marketplaces","thedotmack"),my=ul(Ts.HEALTH_CHECK),ht=null;function hl(){if(ht!==null)return ht;try{let a=wa.default.join(rr.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=rr.loadFromFile(a);return ht=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),ht}catch(a){return $t.debug("SYSTEM","Failed to load port from settings, using default",{error:a}),ht=parseInt(rr.get("CLAUDE_MEM_WORKER_PORT"),10),ht}}function ml(){let a=wa.default.join((0,As.homedir)(),".claude-mem","settings.json");return rr.loadFromFile(a).CLAUDE_MEM_WORKER_HOST}var zf=hl(),Hf=ml(),mt=`http://${Hf}:${zf}`,kt={search:"/api/search",timeline:"/api/timeline",get_recent_context:"/api/context/recent",get_context_timeline:"/api/context/timeline",progressive_ix:"/api/instructions"};async function Ct(a,e){we("[mcp-server] \u2192 Worker API",{endpoint:a,params:e});try{let t=new URLSearchParams;for(let[l,i]of Object.entries(e))i!=null&&t.append(l,String(i));let s=`${mt}${a}?${t}`,r=await fetch(s);if(!r.ok){let l=await r.text();throw new Error(`Worker API error (${r.status}): ${l}`)}let n=await r.json();return we("[mcp-server] \u2190 Worker API success",{endpoint:a}),n}catch(t){return we("[mcp-server] \u2190 Worker API error",{endpoint:a,error:t.message}),{content:[{type:"text",text:`Error calling Worker API: ${t.message}`}],isError:!0}}}async function Ds(a,e){we("[mcp-server] \u2192 Worker API (path)",{endpoint:a,id:e});try{let t=`${mt}${a}/${e}`,s=await fetch(t);if(!s.ok){let n=await s.text();throw new Error(`Worker API error (${s.status}): ${n}`)}let r=await s.json();return we("[mcp-server] \u2190 Worker API success (path)",{endpoint:a,id:e}),{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}catch(t){return we("[mcp-server] \u2190 Worker API error (path)",{endpoint:a,id:e,error:t.message}),{content:[{type:"text",text:`Error calling Worker API: ${t.message}`}],isError:!0}}}async function Zf(a,e){we("[mcp-server] \u2192 Worker API (POST)",{endpoint:a,body:e});try{let t=`${mt}${a}`,s=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok){let n=await s.text();throw new Error(`Worker API error (${s.status}): ${n}`)}let r=await s.json();return we("[mcp-server] \u2190 Worker API success (POST)",{endpoint:a}),{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}catch(t){return we("[mcp-server] \u2190 Worker API error (POST)",{endpoint:a,error:t.message}),{content:[{type:"text",text:`Error calling Worker API: ${t.message}`}],isError:!0}}}async function Bf(){try{return(await fetch(`${mt}/api/health`)).ok}catch{return!1}}var vl=[{name:"search",description:"Search observations, sessions, and prompts",inputSchema:o.object({query:o.string().optional(),format:o.enum(["index","full"]).default("index"),type:o.enum(["observations","sessions","prompts"]).optional(),obs_type:o.string().optional(),concepts:o.string().optional(),files:o.string().optional(),project:o.string().optional(),dateStart:o.union([o.string(),o.number()]).optional(),dateEnd:o.union([o.string(),o.number()]).optional(),limit:o.number().min(1).max(100).default(20),offset:o.number().min(0).default(0),orderBy:o.enum(["relevance","date_desc","date_asc"]).default("date_desc")}),handler:async a=>{let e=kt.search;return await Ct(e,a)}},{name:"timeline",description:"Get timeline around observation ID or query",inputSchema:o.object({query:o.string().optional(),anchor:o.number().optional(),depth_before:o.number().min(0).max(100).default(10),depth_after:o.number().min(0).max(100).default(10),format:o.enum(["index","full"]).default("index"),type:o.string().optional(),concepts:o.string().optional(),files:o.string().optional(),project:o.string().optional()}),handler:async a=>{let e=kt.timeline;return await Ct(e,a)}},{name:"get_recent_context",description:"Get recent timeline items",inputSchema:o.object({limit:o.number().min(1).max(100).default(30),format:o.enum(["index","full"]).default("index"),type:o.string().optional(),concepts:o.string().optional(),files:o.string().optional(),project:o.string().optional(),dateStart:o.union([o.string(),o.number()]).optional(),dateEnd:o.union([o.string(),o.number()]).optional()}),handler:async a=>{let e=kt.get_recent_context;return await Ct(e,a)}},{name:"get_context_timeline",description:"Get timeline around specific observation",inputSchema:o.object({anchor:o.number(),depth_before:o.number().min(0).max(100).default(10),depth_after:o.number().min(0).max(100).default(10),format:o.enum(["index","full"]).default("index"),type:o.string().optional(),concepts:o.string().optional(),files:o.string().optional(),project:o.string().optional()}),handler:async a=>{let e=kt.get_context_timeline;return await Ct(e,a)}},{name:"progressive_ix",description:"Load parameter docs and usage instructions",inputSchema:o.object({topic:o.enum(["workflow","search_params","examples","all"]).default("all")}),handler:async a=>{let e=kt.progressive_ix;return await Ct(e,a)}},{name:"get_observation",description:"Get observation by ID",inputSchema:o.object({id:o.number()}),handler:async a=>await Ds("/api/observation",a.id)},{name:"get_batch_observations",description:"Get multiple observations by IDs",inputSchema:o.object({ids:o.array(o.number()),orderBy:o.enum(["date_desc","date_asc"]).optional(),limit:o.number().optional(),project:o.string().optional()}),handler:async a=>await Zf("/api/observations/batch",a)},{name:"get_session",description:"Get session summary by ID",inputSchema:o.object({id:o.number()}),handler:async a=>await Ds("/api/session",a.id)},{name:"get_prompt",description:"Get user prompt by ID",inputSchema:o.object({id:o.number()}),handler:async a=>await Ds("/api/prompt",a.id)}],Is=new ga({name:"claude-mem-search-server",version:"1.0.0"},{capabilities:{tools:{}}});Is.setRequestHandler(za,async()=>({tools:vl.map(a=>({name:a.name,description:a.description,inputSchema:xs(a.inputSchema)}))}));Is.setRequestHandler(Ha,async a=>{let e=vl.find(t=>t.name===a.params.name);if(!e)throw new Error(`Unknown tool: ${a.params.name}`);try{return await e.handler(a.params.arguments||{})}catch(t){return{content:[{type:"text",text:`Tool execution failed: ${t.message}`}],isError:!0}}});async function gl(){we("[mcp-server] Shutting down..."),process.exit(0)}process.on("SIGTERM",gl);process.on("SIGINT",gl);async function Wf(){let a=new _a;await Is.connect(a),we("[mcp-server] Claude-mem search server started"),setTimeout(async()=>{await Bf()?we("[mcp-server] Worker available at",mt):(we("[mcp-server] WARNING: Worker not available at",mt),we("[mcp-server] Tools will fail until Worker is started"),we("[mcp-server] Start Worker with: npm run worker:restart"))},0)}Wf().catch(a=>{we("[mcp-server] Fatal error:",a),process.exit(1)}); /*! Bundled license information: uri-js/dist/es5/uri.all.js: diff --git a/plugin/scripts/worker-service.cjs b/plugin/scripts/worker-service.cjs index 7182eafe..7628c6b6 100755 --- a/plugin/scripts/worker-service.cjs +++ b/plugin/scripts/worker-service.cjs @@ -961,16 +961,16 @@ MEMORY PROCESSING CONTINUED `,n=[];t&&(i+=" WHERE s.project = ?",n.push(t)),i+=" ORDER BY up.created_at_epoch DESC LIMIT ? OFFSET ?",n.push(r+1,e);let l=s.prepare(i).all(...n);return{items:l.slice(0,r),hasMore:l.length>r,offset:e,limit:r}}paginate(e,r,t,s,i){let n=this.dbManager.getSessionStore().db,o=`SELECT ${r} FROM ${e}`,l=[];i&&(o+=" WHERE project = ?",l.push(i)),o+=" ORDER BY created_at_epoch DESC LIMIT ? OFFSET ?",l.push(s+1,t);let u=n.prepare(o).all(...l);return{items:u.slice(0,s),hasMore:u.length>s,offset:t,limit:s}}};ft();var kl=class{dbManager;defaultSettings={sidebarOpen:!0,selectedProject:null,theme:"system"};constructor(e){this.dbManager=e}getSettings(){let e=this.dbManager.getSessionStore().db;try{let t=e.prepare("SELECT key, value FROM viewer_settings").all(),s={...this.defaultSettings};for(let i of t){let n=i.key;n in s&&(s[n]=JSON.parse(i.value))}return s}catch(r){return M.debug("WORKER","Failed to load settings, using defaults",{},r),{...this.defaultSettings}}}updateSettings(e){let t=this.dbManager.getSessionStore().db.prepare(` INSERT OR REPLACE INTO viewer_settings (key, value) VALUES (?, ?) - `);for(let[s,i]of Object.entries(e))t.run(s,JSON.stringify(i));return this.getSettings()}};var Gw=require("path");ft();var Al=class{constructor(e,r,t,s,i){this.sessionSearch=e;this.sessionStore=r;this.chromaSync=t;this.formatter=s;this.timelineService=i}async queryChroma(e,r,t){return await this.chromaSync.queryChroma(e,r,t)}normalizeParams(e){let r={...e};return r.concepts&&typeof r.concepts=="string"&&(r.concepts=r.concepts.split(",").map(t=>t.trim()).filter(Boolean)),r.files&&typeof r.files=="string"&&(r.files=r.files.split(",").map(t=>t.trim()).filter(Boolean)),r.obs_type&&typeof r.obs_type=="string"&&(r.obs_type=r.obs_type.split(",").map(t=>t.trim()).filter(Boolean)),r.type&&typeof r.type=="string"&&r.type.includes(",")&&(r.type=r.type.split(",").map(t=>t.trim()).filter(Boolean)),(r.dateStart||r.dateEnd)&&(r.dateRange={start:r.dateStart,end:r.dateEnd},delete r.dateStart,delete r.dateEnd),r}async search(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",type:i,obs_type:n,concepts:o,files:l,...c}=r,u=[],p=[],m=[],d=!i||i==="observations",v=!i||i==="sessions",h=!i||i==="prompts";if(t)if(this.chromaSync){let w=!1;try{M.debug("SEARCH","Using ChromaDB semantic search",{typeFilter:i||"all"});let P;i==="observations"?P={doc_type:"observation"}:i==="sessions"?P={doc_type:"session_summary"}:i==="prompts"&&(P={doc_type:"user_prompt"});let T=await this.queryChroma(t,100,P);if(w=!0,M.debug("SEARCH","ChromaDB returned semantic matches",{matchCount:T.ids.length}),T.ids.length>0){let k=Date.now()-7776e6,N=T.metadatas.map((C,O)=>({id:T.ids[O],meta:C,isRecent:C&&C.created_at_epoch>k})).filter(C=>C.isRecent);M.debug("SEARCH","Results within 90-day window",{count:N.length});let A=[],$=[],D=[];for(let C of N){let O=C.meta?.doc_type;O==="observation"&&d?A.push(C.id):O==="session_summary"&&v?$.push(C.id):O==="user_prompt"&&h&&D.push(C.id)}if(M.debug("SEARCH","Categorized results by type",{observations:A.length,sessions:$.length,prompts:D.length}),A.length>0){let C={...c,type:n,concepts:o,files:l};u=this.sessionStore.getObservationsByIds(A,C)}$.length>0&&(p=this.sessionStore.getSessionSummariesByIds($,{orderBy:"date_desc",limit:c.limit,project:c.project})),D.length>0&&(m=this.sessionStore.getUserPromptsByIds(D,{orderBy:"date_desc",limit:c.limit,project:c.project})),M.debug("SEARCH","Hydrated results from SQLite",{observations:u.length,sessions:p.length,prompts:m.length})}else M.debug("SEARCH","ChromaDB found no matches (final result, no FTS5 fallback)",{})}catch(P){M.debug("SEARCH","ChromaDB failed - returning empty results (FTS5 fallback removed)",{error:P.message}),M.debug("SEARCH","Install UVX/Python to enable vector search",{url:"https://docs.astral.sh/uv/getting-started/installation/"}),u=[],p=[],m=[]}}else M.debug("SEARCH","ChromaDB not initialized - returning empty results (FTS5 fallback removed)",{}),M.debug("SEARCH","Install UVX/Python to enable vector search",{url:"https://docs.astral.sh/uv/getting-started/installation/"}),u=[],p=[],m=[];else{M.debug("SEARCH","Filter-only query (no query text), using direct SQLite filtering",{enablesDateFilters:!0});let w={...c,type:n,concepts:o,files:l};d&&(u=this.sessionSearch.searchObservations(void 0,w)),v&&(p=this.sessionSearch.searchSessions(void 0,c)),h&&(m=this.sessionSearch.searchUserPrompts(void 0,c))}let f=u.length+p.length+m.length;if(f===0)return s==="json"?{observations:[],sessions:[],prompts:[]}:{content:[{type:"text",text:`No results found matching "${t}"`}]};let y=[...u.map(w=>({type:"observation",data:w,epoch:w.created_at_epoch})),...p.map(w=>({type:"session",data:w,epoch:w.created_at_epoch})),...m.map(w=>({type:"prompt",data:w,epoch:w.created_at_epoch}))];c.orderBy==="date_desc"?y.sort((w,P)=>P.epoch-w.epoch):c.orderBy==="date_asc"&&y.sort((w,P)=>w.epoch-P.epoch);let g=y.slice(0,c.limit||20);if(s==="json")return{observations:u,sessions:p,prompts:m};let b;if(s==="index"){let w=`Found ${f} result(s) matching "${t}" (${u.length} obs, ${p.length} sessions, ${m.length} prompts): + `);for(let[s,i]of Object.entries(e))t.run(s,JSON.stringify(i));return this.getSettings()}};var Gw=require("path");ft();var Al=class{constructor(e,r,t,s,i){this.sessionSearch=e;this.sessionStore=r;this.chromaSync=t;this.formatter=s;this.timelineService=i}async queryChroma(e,r,t){return await this.chromaSync.queryChroma(e,r,t)}normalizeParams(e){let r={...e};return r.concepts&&typeof r.concepts=="string"&&(r.concepts=r.concepts.split(",").map(t=>t.trim()).filter(Boolean)),r.files&&typeof r.files=="string"&&(r.files=r.files.split(",").map(t=>t.trim()).filter(Boolean)),r.obs_type&&typeof r.obs_type=="string"&&(r.obs_type=r.obs_type.split(",").map(t=>t.trim()).filter(Boolean)),r.type&&typeof r.type=="string"&&r.type.includes(",")&&(r.type=r.type.split(",").map(t=>t.trim()).filter(Boolean)),(r.dateStart||r.dateEnd)&&(r.dateRange={start:r.dateStart,end:r.dateEnd},delete r.dateStart,delete r.dateEnd),r}async search(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",type:i,obs_type:n,concepts:o,files:l,...c}=r,u=[],p=[],m=[],d=!i||i==="observations",v=!i||i==="sessions",h=!i||i==="prompts";if(t)if(this.chromaSync){let w=!1;try{M.debug("SEARCH","Using ChromaDB semantic search",{typeFilter:i||"all"});let P;i==="observations"?P={doc_type:"observation"}:i==="sessions"?P={doc_type:"session_summary"}:i==="prompts"&&(P={doc_type:"user_prompt"});let T=await this.queryChroma(t,100,P);if(w=!0,M.debug("SEARCH","ChromaDB returned semantic matches",{matchCount:T.ids.length}),T.ids.length>0){let k=Date.now()-7776e6,N=T.metadatas.map((C,O)=>({id:T.ids[O],meta:C,isRecent:C&&C.created_at_epoch>k})).filter(C=>C.isRecent);M.debug("SEARCH","Results within 90-day window",{count:N.length});let A=[],$=[],D=[];for(let C of N){let O=C.meta?.doc_type;O==="observation"&&d?A.push(C.id):O==="session_summary"&&v?$.push(C.id):O==="user_prompt"&&h&&D.push(C.id)}if(M.debug("SEARCH","Categorized results by type",{observations:A.length,sessions:$.length,prompts:D.length}),A.length>0){let C={...c,type:n,concepts:o,files:l};u=this.sessionStore.getObservationsByIds(A,C)}$.length>0&&(p=this.sessionStore.getSessionSummariesByIds($,{orderBy:"date_desc",limit:c.limit,project:c.project})),D.length>0&&(m=this.sessionStore.getUserPromptsByIds(D,{orderBy:"date_desc",limit:c.limit,project:c.project})),M.debug("SEARCH","Hydrated results from SQLite",{observations:u.length,sessions:p.length,prompts:m.length})}else M.debug("SEARCH","ChromaDB found no matches (final result, no FTS5 fallback)",{})}catch(P){M.debug("SEARCH","ChromaDB failed - returning empty results (FTS5 fallback removed)",{error:P.message}),M.debug("SEARCH","Install UVX/Python to enable vector search",{url:"https://docs.astral.sh/uv/getting-started/installation/"}),u=[],p=[],m=[]}}else M.debug("SEARCH","ChromaDB not initialized - returning empty results (FTS5 fallback removed)",{}),M.debug("SEARCH","Install UVX/Python to enable vector search",{url:"https://docs.astral.sh/uv/getting-started/installation/"}),u=[],p=[],m=[];else{M.debug("SEARCH","Filter-only query (no query text), using direct SQLite filtering",{enablesDateFilters:!0});let w={...c,type:n,concepts:o,files:l};d&&(u=this.sessionSearch.searchObservations(void 0,w)),v&&(p=this.sessionSearch.searchSessions(void 0,c)),h&&(m=this.sessionSearch.searchUserPrompts(void 0,c))}let f=u.length+p.length+m.length;if(f===0)return s==="json"?{observations:[],sessions:[],prompts:[]}:{content:[{type:"text",text:`No results found matching "${t}"`}]};let y=[...u.map(w=>({type:"observation",data:w,epoch:w.created_at_epoch})),...p.map(w=>({type:"session",data:w,epoch:w.created_at_epoch})),...m.map(w=>({type:"prompt",data:w,epoch:w.created_at_epoch}))];c.orderBy==="date_desc"?y.sort((w,P)=>P.epoch-w.epoch):c.orderBy==="date_asc"&&y.sort((w,P)=>w.epoch-P.epoch);let g=y.slice(0,c.limit||20);if(s==="json")return{observations:u,sessions:p,prompts:m};let b;if(s==="index"){let w=` \u23BF Found ${f} result(s) matching "${t}" (${u.length} obs, ${p.length} sessions, ${m.length} prompts): `,P=g.map((T,k)=>T.type==="observation"?this.formatter.formatObservationIndex(T.data,k):T.type==="session"?this.formatter.formatSessionIndex(T.data,k):this.formatter.formatUserPromptIndex(T.data,k));b=w+P.join(` -`)+this.formatter.formatSearchTips()}else b=g.map(P=>P.type==="observation"?this.formatter.formatObservationResult(P.data):P.type==="session"?this.formatter.formatSessionResult(P.data):this.formatter.formatUserPromptResult(P.data)).join(` +`)}else b=g.map(P=>P.type==="observation"?this.formatter.formatObservationResult(P.data):P.type==="session"?this.formatter.formatSessionResult(P.data):this.formatter.formatUserPromptResult(P.data)).join(` --- `);return{content:[{type:"text",text:b}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async timeline(e){try{let{anchor:r,query:t,depth_before:s=10,depth_after:i=10,project:n}=e;if(!r&&!t)return{content:[{type:"text",text:'Error: Must provide either "anchor" or "query" parameter'}],isError:!0};if(r&&t)return{content:[{type:"text",text:'Error: Cannot provide both "anchor" and "query" parameters. Use one or the other.'}],isError:!0};let o,l,c;if(t){let b=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid semantic search for timeline query",{});let P=await this.queryChroma(t,100);if(M.debug("SEARCH","Chroma returned semantic matches for timeline",{matchCount:P?.ids?.length??0}),P?.ids&&P.ids.length>0){let T=Date.now()-7776e6,k=P.ids.filter((N,A)=>{let $=P.metadatas[A];return $&&$.created_at_epoch>T});k.length>0&&(b=this.sessionStore.getObservationsByIds(k,{orderBy:"date_desc",limit:1}))}}catch(P){M.debug("SEARCH","Chroma query failed - no results (FTS5 fallback removed)",{error:P.message})}if(b.length===0)return{content:[{type:"text",text:`No observations found matching "${t}". Try a different search query.`}]};let w=b[0];o=w.id,l=w.created_at_epoch,M.debug("SEARCH","Query mode: Using observation as timeline anchor",{observationId:w.id}),c=this.sessionStore.getTimelineAroundObservation(w.id,w.created_at_epoch,s,i,n)}else if(typeof r=="number"){let b=this.sessionStore.getObservationById(r);if(!b)return{content:[{type:"text",text:`Observation #${r} not found`}],isError:!0};o=r,l=b.created_at_epoch,c=this.sessionStore.getTimelineAroundObservation(r,l,s,i,n)}else if(typeof r=="string")if(r.startsWith("S")||r.startsWith("#S")){let b=r.replace(/^#?S/,""),w=parseInt(b,10),P=this.sessionStore.getSessionSummariesByIds([w]);if(P.length===0)return{content:[{type:"text",text:`Session #${w} not found`}],isError:!0};l=P[0].created_at_epoch,o=`S${w}`,c=this.sessionStore.getTimelineAroundTimestamp(l,s,i,n)}else{let b=new Date(r);if(isNaN(b.getTime()))return{content:[{type:"text",text:`Invalid timestamp: ${r}`}],isError:!0};l=b.getTime(),o=r,c=this.sessionStore.getTimelineAroundTimestamp(l,s,i,n)}else return{content:[{type:"text",text:'Invalid anchor: must be observation ID (number), session ID (e.g., "S123"), or ISO timestamp'}],isError:!0};let u=[...(c.observations||[]).map(b=>({type:"observation",data:b,epoch:b.created_at_epoch})),...(c.sessions||[]).map(b=>({type:"session",data:b,epoch:b.created_at_epoch})),...(c.prompts||[]).map(b=>({type:"prompt",data:b,epoch:b.created_at_epoch}))];u.sort((b,w)=>b.epoch-w.epoch);let p=this.timelineService.filterByDepth(u,o,l,s,i);if(!p||p.length===0)return{content:[{type:"text",text:t?`Found observation matching "${t}", but no timeline context available (${s} records before, ${i} records after).`:`No context found around anchor (${s} records before, ${i} records after)`}]};let m=b=>new Date(b).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"}),d=b=>new Date(b).toLocaleString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}),v=b=>new Date(b).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),h=b=>b?Math.ceil(b.length/4):0,f=[];if(t){let b=p.find(P=>P.type==="observation"&&P.data.id===o),w=b&&b.type==="observation"?b.data.title||"Untitled":"Unknown";f.push(`# Timeline for query: "${t}"`),f.push(`**Anchor:** Observation #${o} - ${w}`)}else f.push(`# Timeline around anchor: ${o}`);f.push(`**Window:** ${s} records before \u2192 ${i} records after | **Items:** ${p?.length??0}`),f.push(""),f.push("**Legend:** \u{1F3AF} session-request | \u{1F534} bugfix | \u{1F7E3} feature | \u{1F504} refactor | \u2705 change | \u{1F535} discovery | \u{1F9E0} decision"),f.push("");let y=new Map;for(let b of p){let w=m(b.epoch);y.has(w)||y.set(w,[]),y.get(w).push(b)}let g=Array.from(y.entries()).sort((b,w)=>{let P=new Date(b[0]).getTime(),T=new Date(w[0]).getTime();return P-T});for(let[b,w]of g){f.push(`### ${b}`),f.push("");let P=null,T="",k=!1;for(let N of w){let A=typeof o=="number"&&N.type==="observation"&&N.data.id===o||typeof o=="string"&&o.startsWith("S")&&N.type==="session"&&`S${N.data.id}`===o;if(N.type==="session"){k&&(f.push(""),k=!1,P=null,T="");let $=N.data,D=$.request||"Session summary",C=`claude-mem://session-summary/${$.id}`,O=A?" \u2190 **ANCHOR**":"";f.push(`**\u{1F3AF} #S${$.id}** ${D} (${v(N.epoch)}) [\u2192](${C})${O}`),f.push("")}else if(N.type==="prompt"){k&&(f.push(""),k=!1,P=null,T="");let $=N.data,D=$.prompt_text.length>100?$.prompt_text.substring(0,100)+"...":$.prompt_text;f.push(`**\u{1F4AC} User Prompt #${$.prompt_number}** (${v(N.epoch)})`),f.push(`> ${D}`),f.push("")}else if(N.type==="observation"){let $=N.data,D="General";D!==P&&(k&&f.push(""),f.push(`**${D}**`),f.push("| ID | Time | T | Title | Tokens |"),f.push("|----|------|---|-------|--------|"),P=D,k=!0,T="");let C="\u2022";switch($.type){case"bugfix":C="\u{1F534}";break;case"feature":C="\u{1F7E3}";break;case"refactor":C="\u{1F504}";break;case"change":C="\u2705";break;case"discovery":C="\u{1F535}";break;case"decision":C="\u{1F9E0}";break}let O=d(N.epoch),j=$.title||"Untitled",q=h($.narrative),V=O!==T?O:"\u2033";T=O;let X=A?" \u2190 **ANCHOR**":"";f.push(`| #${$.id} | ${V} | ${C} | ${j}${X} | ~${q} |`)}}k&&f.push("")}return{content:[{type:"text",text:f.join(` -`)}]}}catch(r){return{content:[{type:"text",text:`Timeline query failed: ${r.message}`}],isError:!0}}}async decisions(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{if(t){M.debug("SEARCH","Using Chroma semantic search with type=decision filter",{});let c=(await this.queryChroma(t,Math.min((i.limit||20)*2,100),{type:"decision"})).ids;c.length>0&&(n=this.sessionStore.getObservationsByIds(c,{...i,type:"decision"}),n.sort((u,p)=>c.indexOf(u.id)-c.indexOf(p.id)))}else{M.debug("SEARCH","Using metadata-first + semantic ranking for decisions",{});let l=this.sessionSearch.findByType("decision",i);if(l.length>0){let c=l.map(m=>m.id),u=await this.queryChroma("decision",Math.min(c.length,100)),p=[];for(let m of u.ids)c.includes(m)&&!p.includes(m)&&p.push(m);p.length>0&&(n=this.sessionStore.getObservationsByIds(p,{limit:i.limit||20}),n.sort((m,d)=>p.indexOf(m.id)-p.indexOf(d.id)))}}}catch(l){M.debug("SEARCH","Chroma search failed, using SQLite fallback",{error:l.message})}if(n.length===0&&(n=this.sessionSearch.findByType("decision",i)),n.length===0)return{content:[{type:"text",text:"No decision observations found"}]};let o;if(s==="index"){let l=`Found ${n.length} decision(s): +`)}]}}catch(r){return{content:[{type:"text",text:`Timeline query failed: ${r.message}`}],isError:!0}}}async decisions(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{if(t){M.debug("SEARCH","Using Chroma semantic search with type=decision filter",{});let c=(await this.queryChroma(t,Math.min((i.limit||20)*2,100),{type:"decision"})).ids;c.length>0&&(n=this.sessionStore.getObservationsByIds(c,{...i,type:"decision"}),n.sort((u,p)=>c.indexOf(u.id)-c.indexOf(p.id)))}else{M.debug("SEARCH","Using metadata-first + semantic ranking for decisions",{});let l=this.sessionSearch.findByType("decision",i);if(l.length>0){let c=l.map(m=>m.id),u=await this.queryChroma("decision",Math.min(c.length,100)),p=[];for(let m of u.ids)c.includes(m)&&!p.includes(m)&&p.push(m);p.length>0&&(n=this.sessionStore.getObservationsByIds(p,{limit:i.limit||20}),n.sort((m,d)=>p.indexOf(m.id)-p.indexOf(d.id)))}}}catch(l){M.debug("SEARCH","Chroma search failed, using SQLite fallback",{error:l.message})}if(n.length===0&&(n=this.sessionSearch.findByType("decision",i)),n.length===0)return{content:[{type:"text",text:"No decision observations found"}]};let o;if(s==="index"){let l=` \u23BF Found ${n.length} decision(s): `,c=n.map((u,p)=>this.formatter.formatObservationIndex(u,p));o=l+c.join(` @@ -978,7 +978,7 @@ MEMORY PROCESSING CONTINUED --- -`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async changes(e){try{let r=this.normalizeParams(e),{format:t="index",...s}=r,i=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid search for change-related observations",{});let o=this.sessionSearch.findByType("change",s),l=this.sessionSearch.findByConcept("change",s),c=this.sessionSearch.findByConcept("what-changed",s),u=new Set;if([...o,...l,...c].forEach(p=>u.add(p.id)),u.size>0){let p=Array.from(u),m=await this.queryChroma("what changed",Math.min(p.length,100)),d=[];for(let v of m.ids)p.includes(v)&&!d.includes(v)&&d.push(v);d.length>0&&(i=this.sessionStore.getObservationsByIds(d,{limit:s.limit||20}),i.sort((v,h)=>d.indexOf(v.id)-d.indexOf(h.id)))}}catch(o){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:o.message})}if(i.length===0){let o=this.sessionSearch.findByType("change",s),l=this.sessionSearch.findByConcept("change",s),c=this.sessionSearch.findByConcept("what-changed",s),u=new Set;[...o,...l,...c].forEach(p=>u.add(p.id)),i=Array.from(u).map(p=>o.find(m=>m.id===p)||l.find(m=>m.id===p)||c.find(m=>m.id===p)).filter(Boolean),i.sort((p,m)=>m.created_at_epoch-p.created_at_epoch),i=i.slice(0,s.limit||20)}if(i.length===0)return{content:[{type:"text",text:"No change-related observations found"}]};let n;if(t==="index"){let o=`Found ${i.length} change-related observation(s): +`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async changes(e){try{let r=this.normalizeParams(e),{format:t="index",...s}=r,i=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid search for change-related observations",{});let o=this.sessionSearch.findByType("change",s),l=this.sessionSearch.findByConcept("change",s),c=this.sessionSearch.findByConcept("what-changed",s),u=new Set;if([...o,...l,...c].forEach(p=>u.add(p.id)),u.size>0){let p=Array.from(u),m=await this.queryChroma("what changed",Math.min(p.length,100)),d=[];for(let v of m.ids)p.includes(v)&&!d.includes(v)&&d.push(v);d.length>0&&(i=this.sessionStore.getObservationsByIds(d,{limit:s.limit||20}),i.sort((v,h)=>d.indexOf(v.id)-d.indexOf(h.id)))}}catch(o){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:o.message})}if(i.length===0){let o=this.sessionSearch.findByType("change",s),l=this.sessionSearch.findByConcept("change",s),c=this.sessionSearch.findByConcept("what-changed",s),u=new Set;[...o,...l,...c].forEach(p=>u.add(p.id)),i=Array.from(u).map(p=>o.find(m=>m.id===p)||l.find(m=>m.id===p)||c.find(m=>m.id===p)).filter(Boolean),i.sort((p,m)=>m.created_at_epoch-p.created_at_epoch),i=i.slice(0,s.limit||20)}if(i.length===0)return{content:[{type:"text",text:"No change-related observations found"}]};let n;if(t==="index"){let o=` \u23BF Found ${i.length} change-related observation(s): `,l=i.map((c,u)=>this.formatter.formatObservationIndex(c,u));n=o+l.join(` @@ -986,7 +986,7 @@ MEMORY PROCESSING CONTINUED --- -`);return{content:[{type:"text",text:n}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async howItWorks(e){try{let r=this.normalizeParams(e),{format:t="index",...s}=r,i=[];if(this.chromaSync)try{M.debug("SEARCH","Using metadata-first + semantic ranking for how-it-works",{});let o=this.sessionSearch.findByConcept("how-it-works",s);if(o.length>0){let l=o.map(p=>p.id),c=await this.queryChroma("how it works architecture",Math.min(l.length,100)),u=[];for(let p of c.ids)l.includes(p)&&!u.includes(p)&&u.push(p);u.length>0&&(i=this.sessionStore.getObservationsByIds(u,{limit:s.limit||20}),i.sort((p,m)=>u.indexOf(p.id)-u.indexOf(m.id)))}}catch(o){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:o.message})}if(i.length===0&&(i=this.sessionSearch.findByConcept("how-it-works",s)),i.length===0)return{content:[{type:"text",text:'No "how it works" observations found'}]};let n;if(t==="index"){let o=`Found ${i.length} "how it works" observation(s): +`);return{content:[{type:"text",text:n}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async howItWorks(e){try{let r=this.normalizeParams(e),{format:t="index",...s}=r,i=[];if(this.chromaSync)try{M.debug("SEARCH","Using metadata-first + semantic ranking for how-it-works",{});let o=this.sessionSearch.findByConcept("how-it-works",s);if(o.length>0){let l=o.map(p=>p.id),c=await this.queryChroma("how it works architecture",Math.min(l.length,100)),u=[];for(let p of c.ids)l.includes(p)&&!u.includes(p)&&u.push(p);u.length>0&&(i=this.sessionStore.getObservationsByIds(u,{limit:s.limit||20}),i.sort((p,m)=>u.indexOf(p.id)-u.indexOf(m.id)))}}catch(o){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:o.message})}if(i.length===0&&(i=this.sessionSearch.findByConcept("how-it-works",s)),i.length===0)return{content:[{type:"text",text:'No "how it works" observations found'}]};let n;if(t==="index"){let o=` \u23BF Found ${i.length} "how it works" observation(s): `,l=i.map((c,u)=>this.formatter.formatObservationIndex(c,u));n=o+l.join(` @@ -994,51 +994,51 @@ MEMORY PROCESSING CONTINUED --- -`);return{content:[{type:"text",text:n}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async searchObservations(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid semantic search (Chroma + SQLite)",{});let l=await this.queryChroma(t,100);if(M.debug("SEARCH","Chroma returned semantic matches",{matchCount:l.ids.length}),l.ids.length>0){let c=Date.now()-7776e6,u=l.ids.filter((p,m)=>{let d=l.metadatas[m];return d&&d.created_at_epoch>c});if(M.debug("SEARCH","Results within 90-day window",{count:u.length}),u.length>0){let p=i.limit||20;n=this.sessionStore.getObservationsByIds(u,{orderBy:"date_desc",limit:p}),M.debug("SEARCH","Hydrated observations from SQLite",{count:n.length})}}}catch(l){M.debug("SEARCH","Chroma query failed - no results (FTS5 fallback removed)",{error:l.message})}if(n.length===0)return{content:[{type:"text",text:`No observations found matching "${t}"`}]};let o;if(s==="index"){let l=`Found ${n.length} observation(s) matching "${t}": +`);return{content:[{type:"text",text:n}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async searchObservations(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid semantic search (Chroma + SQLite)",{});let l=await this.queryChroma(t,100);if(M.debug("SEARCH","Chroma returned semantic matches",{matchCount:l.ids.length}),l.ids.length>0){let c=Date.now()-7776e6,u=l.ids.filter((p,m)=>{let d=l.metadatas[m];return d&&d.created_at_epoch>c});if(M.debug("SEARCH","Results within 90-day window",{count:u.length}),u.length>0){let p=i.limit||20;n=this.sessionStore.getObservationsByIds(u,{orderBy:"date_desc",limit:p}),M.debug("SEARCH","Hydrated observations from SQLite",{count:n.length})}}}catch(l){M.debug("SEARCH","Chroma query failed - no results (FTS5 fallback removed)",{error:l.message})}if(n.length===0)return{content:[{type:"text",text:`No observations found matching "${t}"`}]};let o;if(s==="index"){let l=` \u23BF Found ${n.length} observation(s) matching "${t}": `,c=n.map((u,p)=>this.formatter.formatObservationIndex(u,p));o=l+c.join(` -`)+this.formatter.formatSearchTips()}else o=n.map(c=>this.formatter.formatObservationResult(c)).join(` +`)}else o=n.map(c=>this.formatter.formatObservationResult(c)).join(` --- -`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async searchSessions(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid semantic search for sessions",{});let l=await this.queryChroma(t,100,{doc_type:"session_summary"});if(M.debug("SEARCH","Chroma returned semantic matches for sessions",{matchCount:l.ids.length}),l.ids.length>0){let c=Date.now()-7776e6,u=l.ids.filter((p,m)=>{let d=l.metadatas[m];return d&&d.created_at_epoch>c});if(M.debug("SEARCH","Results within 90-day window",{count:u.length}),u.length>0){let p=i.limit||20;n=this.sessionStore.getSessionSummariesByIds(u,{orderBy:"date_desc",limit:p}),M.debug("SEARCH","Hydrated sessions from SQLite",{count:n.length})}}}catch(l){M.debug("SEARCH","Chroma query failed - no results (FTS5 fallback removed)",{error:l.message})}if(n.length===0)return{content:[{type:"text",text:`No sessions found matching "${t}"`}]};let o;if(s==="index"){let l=`Found ${n.length} session(s) matching "${t}": +`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async searchSessions(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid semantic search for sessions",{});let l=await this.queryChroma(t,100,{doc_type:"session_summary"});if(M.debug("SEARCH","Chroma returned semantic matches for sessions",{matchCount:l.ids.length}),l.ids.length>0){let c=Date.now()-7776e6,u=l.ids.filter((p,m)=>{let d=l.metadatas[m];return d&&d.created_at_epoch>c});if(M.debug("SEARCH","Results within 90-day window",{count:u.length}),u.length>0){let p=i.limit||20;n=this.sessionStore.getSessionSummariesByIds(u,{orderBy:"date_desc",limit:p}),M.debug("SEARCH","Hydrated sessions from SQLite",{count:n.length})}}}catch(l){M.debug("SEARCH","Chroma query failed - no results (FTS5 fallback removed)",{error:l.message})}if(n.length===0)return{content:[{type:"text",text:`No sessions found matching "${t}"`}]};let o;if(s==="index"){let l=` \u23BF Found ${n.length} session(s) matching "${t}": `,c=n.map((u,p)=>this.formatter.formatSessionIndex(u,p));o=l+c.join(` -`)+this.formatter.formatSearchTips()}else o=n.map(c=>this.formatter.formatSessionResult(c)).join(` +`)}else o=n.map(c=>this.formatter.formatSessionResult(c)).join(` --- -`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async searchUserPrompts(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid semantic search for user prompts",{});let l=await this.queryChroma(t,100,{doc_type:"user_prompt"});if(M.debug("SEARCH","Chroma returned semantic matches for prompts",{matchCount:l.ids.length}),l.ids.length>0){let c=Date.now()-7776e6,u=l.ids.filter((p,m)=>{let d=l.metadatas[m];return d&&d.created_at_epoch>c});if(M.debug("SEARCH","Results within 90-day window",{count:u.length}),u.length>0){let p=i.limit||20;n=this.sessionStore.getUserPromptsByIds(u,{orderBy:"date_desc",limit:p}),M.debug("SEARCH","Hydrated user prompts from SQLite",{count:n.length})}}}catch(l){M.debug("SEARCH","Chroma query failed - no results (FTS5 fallback removed)",{error:l.message})}if(n.length===0)return{content:[{type:"text",text:t?`No user prompts found matching "${t}"`:"No user prompts found"}]};let o;if(s==="index"){let l=`Found ${n.length} user prompt(s) matching "${t}": +`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async searchUserPrompts(e){try{let r=this.normalizeParams(e),{query:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{M.debug("SEARCH","Using hybrid semantic search for user prompts",{});let l=await this.queryChroma(t,100,{doc_type:"user_prompt"});if(M.debug("SEARCH","Chroma returned semantic matches for prompts",{matchCount:l.ids.length}),l.ids.length>0){let c=Date.now()-7776e6,u=l.ids.filter((p,m)=>{let d=l.metadatas[m];return d&&d.created_at_epoch>c});if(M.debug("SEARCH","Results within 90-day window",{count:u.length}),u.length>0){let p=i.limit||20;n=this.sessionStore.getUserPromptsByIds(u,{orderBy:"date_desc",limit:p}),M.debug("SEARCH","Hydrated user prompts from SQLite",{count:n.length})}}}catch(l){M.debug("SEARCH","Chroma query failed - no results (FTS5 fallback removed)",{error:l.message})}if(n.length===0)return{content:[{type:"text",text:t?`No user prompts found matching "${t}"`:"No user prompts found"}]};let o;if(s==="index"){let l=` \u23BF Found ${n.length} user prompt(s) matching "${t}": `,c=n.map((u,p)=>this.formatter.formatUserPromptIndex(u,p));o=l+c.join(` -`)+this.formatter.formatSearchTips()}else o=n.map(c=>this.formatter.formatUserPromptResult(c)).join(` +`)}else o=n.map(c=>this.formatter.formatUserPromptResult(c)).join(` --- -`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async findByConcept(e){try{let r=this.normalizeParams(e),{concepts:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{M.debug("SEARCH","Using metadata-first + semantic ranking for concept search",{});let l=this.sessionSearch.findByConcept(t,i);if(M.debug("SEARCH","Found observations with concept",{concept:t,count:l.length}),l.length>0){let c=l.map(m=>m.id),u=await this.queryChroma(t,Math.min(c.length,100)),p=[];for(let m of u.ids)c.includes(m)&&!p.includes(m)&&p.push(m);M.debug("SEARCH","Chroma ranked results by semantic relevance",{count:p.length}),p.length>0&&(n=this.sessionStore.getObservationsByIds(p,{limit:i.limit||20}),n.sort((m,d)=>p.indexOf(m.id)-p.indexOf(d.id)))}}catch(l){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:l.message})}if(n.length===0&&(M.debug("SEARCH","Using SQLite-only concept search",{}),n=this.sessionSearch.findByConcept(t,i)),n.length===0)return{content:[{type:"text",text:`No observations found with concept "${t}"`}]};let o;if(s==="index"){let l=`Found ${n.length} observation(s) with concept "${t}": +`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async findByConcept(e){try{let r=this.normalizeParams(e),{concepts:t,format:s="index",...i}=r,n=[];if(this.chromaSync)try{M.debug("SEARCH","Using metadata-first + semantic ranking for concept search",{});let l=this.sessionSearch.findByConcept(t,i);if(M.debug("SEARCH","Found observations with concept",{concept:t,count:l.length}),l.length>0){let c=l.map(m=>m.id),u=await this.queryChroma(t,Math.min(c.length,100)),p=[];for(let m of u.ids)c.includes(m)&&!p.includes(m)&&p.push(m);M.debug("SEARCH","Chroma ranked results by semantic relevance",{count:p.length}),p.length>0&&(n=this.sessionStore.getObservationsByIds(p,{limit:i.limit||20}),n.sort((m,d)=>p.indexOf(m.id)-p.indexOf(d.id)))}}catch(l){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:l.message})}if(n.length===0&&(M.debug("SEARCH","Using SQLite-only concept search",{}),n=this.sessionSearch.findByConcept(t,i)),n.length===0)return{content:[{type:"text",text:`No observations found with concept "${t}"`}]};let o;if(s==="index"){let l=` \u23BF Found ${n.length} observation(s) with concept "${t}": `,c=n.map((u,p)=>this.formatter.formatObservationIndex(u,p));o=l+c.join(` -`)+this.formatter.formatSearchTips()}else o=n.map(c=>this.formatter.formatObservationResult(c)).join(` +`)}else o=n.map(c=>this.formatter.formatObservationResult(c)).join(` --- -`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async findByFile(e){try{let r=this.normalizeParams(e),{files:t,format:s="index",...i}=r,n=[],o=[];if(this.chromaSync)try{M.debug("SEARCH","Using metadata-first + semantic ranking for file search",{});let u=this.sessionSearch.findByFile(t,i);if(M.debug("SEARCH","Found results for file",{file:t,observations:u.observations.length,sessions:u.sessions.length}),o=u.sessions,u.observations.length>0){let p=u.observations.map(v=>v.id),m=await this.queryChroma(t,Math.min(p.length,100)),d=[];for(let v of m.ids)p.includes(v)&&!d.includes(v)&&d.push(v);M.debug("SEARCH","Chroma ranked observations by semantic relevance",{count:d.length}),d.length>0&&(n=this.sessionStore.getObservationsByIds(d,{limit:i.limit||20}),n.sort((v,h)=>d.indexOf(v.id)-d.indexOf(h.id)))}}catch(u){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:u.message})}if(n.length===0&&o.length===0){M.debug("SEARCH","Using SQLite-only file search",{});let u=this.sessionSearch.findByFile(t,i);n=u.observations,o=u.sessions}let l=n.length+o.length;if(l===0)return{content:[{type:"text",text:`No results found for file "${t}"`}]};let c;if(s==="index"){let u=`Found ${l} result(s) for file "${t}": +`);return{content:[{type:"text",text:o}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async findByFile(e){try{let r=this.normalizeParams(e),{files:t,format:s="index",...i}=r,n=[],o=[];if(this.chromaSync)try{M.debug("SEARCH","Using metadata-first + semantic ranking for file search",{});let u=this.sessionSearch.findByFile(t,i);if(M.debug("SEARCH","Found results for file",{file:t,observations:u.observations.length,sessions:u.sessions.length}),o=u.sessions,u.observations.length>0){let p=u.observations.map(v=>v.id),m=await this.queryChroma(t,Math.min(p.length,100)),d=[];for(let v of m.ids)p.includes(v)&&!d.includes(v)&&d.push(v);M.debug("SEARCH","Chroma ranked observations by semantic relevance",{count:d.length}),d.length>0&&(n=this.sessionStore.getObservationsByIds(d,{limit:i.limit||20}),n.sort((v,h)=>d.indexOf(v.id)-d.indexOf(h.id)))}}catch(u){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:u.message})}if(n.length===0&&o.length===0){M.debug("SEARCH","Using SQLite-only file search",{});let u=this.sessionSearch.findByFile(t,i);n=u.observations,o=u.sessions}let l=n.length+o.length;if(l===0)return{content:[{type:"text",text:`No results found for file "${t}"`}]};let c;if(s==="index"){let u=` \u23BF Found ${l} result(s) for file "${t}": `,p=[];n.forEach((m,d)=>{p.push(this.formatter.formatObservationIndex(m,d))}),o.forEach((m,d)=>{p.push(this.formatter.formatSessionIndex(m,d+n.length))}),c=u+p.join(` -`)+this.formatter.formatSearchTips()}else{let u=[];n.forEach(p=>{u.push(this.formatter.formatObservationResult(p))}),o.forEach(p=>{u.push(this.formatter.formatSessionResult(p))}),c=u.join(` +`)}else{let u=[];n.forEach(p=>{u.push(this.formatter.formatObservationResult(p))}),o.forEach(p=>{u.push(this.formatter.formatSessionResult(p))}),c=u.join(` --- -`)}return{content:[{type:"text",text:c}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async findByType(e){try{let r=this.normalizeParams(e),{type:t,format:s="index",...i}=r,n=Array.isArray(t)?t.join(", "):t,o=[];if(this.chromaSync)try{M.debug("SEARCH","Using metadata-first + semantic ranking for type search",{});let c=this.sessionSearch.findByType(t,i);if(M.debug("SEARCH","Found observations with type",{type:n,count:c.length}),c.length>0){let u=c.map(d=>d.id),p=await this.queryChroma(n,Math.min(u.length,100)),m=[];for(let d of p.ids)u.includes(d)&&!m.includes(d)&&m.push(d);M.debug("SEARCH","Chroma ranked results by semantic relevance",{count:m.length}),m.length>0&&(o=this.sessionStore.getObservationsByIds(m,{limit:i.limit||20}),o.sort((d,v)=>m.indexOf(d.id)-m.indexOf(v.id)))}}catch(c){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:c.message})}if(o.length===0&&(M.debug("SEARCH","Using SQLite-only type search",{}),o=this.sessionSearch.findByType(t,i)),o.length===0)return{content:[{type:"text",text:`No observations found with type "${n}"`}]};let l;if(s==="index"){let c=`Found ${o.length} observation(s) with type "${n}": +`)}return{content:[{type:"text",text:c}]}}catch(r){return{content:[{type:"text",text:`Search failed: ${r.message}`}],isError:!0}}}async findByType(e){try{let r=this.normalizeParams(e),{type:t,format:s="index",...i}=r,n=Array.isArray(t)?t.join(", "):t,o=[];if(this.chromaSync)try{M.debug("SEARCH","Using metadata-first + semantic ranking for type search",{});let c=this.sessionSearch.findByType(t,i);if(M.debug("SEARCH","Found observations with type",{type:n,count:c.length}),c.length>0){let u=c.map(d=>d.id),p=await this.queryChroma(n,Math.min(u.length,100)),m=[];for(let d of p.ids)u.includes(d)&&!m.includes(d)&&m.push(d);M.debug("SEARCH","Chroma ranked results by semantic relevance",{count:m.length}),m.length>0&&(o=this.sessionStore.getObservationsByIds(m,{limit:i.limit||20}),o.sort((d,v)=>m.indexOf(d.id)-m.indexOf(v.id)))}}catch(c){M.debug("SEARCH","Chroma ranking failed, using SQLite order",{error:c.message})}if(o.length===0&&(M.debug("SEARCH","Using SQLite-only type search",{}),o=this.sessionSearch.findByType(t,i)),o.length===0)return{content:[{type:"text",text:`No observations found with type "${n}"`}]};let l;if(s==="index"){let c=` \u23BF Found ${o.length} observation(s) with type "${n}": `,u=o.map((p,m)=>this.formatter.formatObservationIndex(p,m));l=c+u.join(` -`)+this.formatter.formatSearchTips()}else l=o.map(u=>this.formatter.formatObservationResult(u)).join(` +`)}else l=o.map(u=>this.formatter.formatObservationResult(u)).join(` --- @@ -1063,13 +1063,13 @@ Search workflow: Other tips: \u2022 To search by concept: Use find_by_concept tool \u2022 To browse by type: Use find_by_type with ["decision", "feature", etc.] -\u2022 To sort by date: Use orderBy: "date_desc" or "date_asc"`}formatObservationIndex(e,r){let t=e.title||`Observation #${e.id}`,s=new Date(e.created_at_epoch).toLocaleString(),i=e.type?`[${e.type}]`:"";return`${r+1}. ${i} ${t} - Date: ${s} - Source: claude-mem://observation/${e.id}`}formatSessionIndex(e,r){let t=e.request||`Session ${e.sdk_session_id?.substring(0,8)||"unknown"}`,s=new Date(e.created_at_epoch).toLocaleString();return`${r+1}. ${t} - Date: ${s} - Source: claude-mem://session/${e.sdk_session_id}`}formatUserPromptIndex(e,r){let t=new Date(e.created_at_epoch).toLocaleString();return`${r+1}. "${e.prompt_text}" - Date: ${t} | Prompt #${e.prompt_number} - Source: claude-mem://user-prompt/${e.id}`}formatObservationResult(e){let r=e.title||`Observation #${e.id}`,t=[];t.push(`## ${r}`),t.push(`*Source: claude-mem://observation/${e.id}*`),t.push(""),e.subtitle&&(t.push(`**${e.subtitle}**`),t.push("")),e.narrative&&(t.push(e.narrative),t.push("")),e.text&&(t.push(e.text),t.push(""));let s=[];if(s.push(`Type: ${e.type}`),e.facts)try{let n=JSON.parse(e.facts);n.length>0&&s.push(`Facts: ${n.join("; ")}`)}catch{M.warn("FORMAT","Invalid JSON in facts field",{obsId:e.id})}if(e.concepts)try{let n=JSON.parse(e.concepts);n.length>0&&s.push(`Concepts: ${n.join(", ")}`)}catch{M.warn("FORMAT","Invalid JSON in concepts field",{obsId:e.id})}if(e.files_read||e.files_modified){let n=[];if(e.files_read)try{n.push(...JSON.parse(e.files_read))}catch{M.warn("FORMAT","Invalid JSON in files_read field",{obsId:e.id})}if(e.files_modified)try{n.push(...JSON.parse(e.files_modified))}catch{M.warn("FORMAT","Invalid JSON in files_modified field",{obsId:e.id})}n.length>0&&s.push(`Files: ${[...new Set(n)].join(", ")}`)}s.length>0&&(t.push("---"),t.push(s.join(" | ")));let i=new Date(e.created_at_epoch).toLocaleString();return t.push(""),t.push("---"),t.push(`Date: ${i}`),t.join(` +\u2022 To sort by date: Use orderBy: "date_desc" or "date_asc"`}formatObservationIndex(e,r){let t=e.title||`Observation #${e.id}`,s=new Date(e.created_at_epoch).toLocaleString(),i=e.type?`[${e.type}]`:"";return` ${r+1}. ${i} ${t} + Date: ${s} + Source: claude-mem://observation/${e.id}`}formatSessionIndex(e,r){let t=e.request||`Session ${e.sdk_session_id?.substring(0,8)||"unknown"}`,s=new Date(e.created_at_epoch).toLocaleString();return` ${r+1}. ${t} + Date: ${s} + Source: claude-mem://session/${e.sdk_session_id}`}formatUserPromptIndex(e,r){let t=new Date(e.created_at_epoch).toLocaleString();return` ${r+1}. "${e.prompt_text}" + Date: ${t} | Prompt #${e.prompt_number} + Source: claude-mem://user-prompt/${e.id}`}formatObservationResult(e){let r=e.title||`Observation #${e.id}`,t=[];t.push(`## ${r}`),t.push(`*Source: claude-mem://observation/${e.id}*`),t.push(""),e.subtitle&&(t.push(`**${e.subtitle}**`),t.push("")),e.narrative&&(t.push(e.narrative),t.push("")),e.text&&(t.push(e.text),t.push(""));let s=[];if(s.push(`Type: ${e.type}`),e.facts)try{let n=JSON.parse(e.facts);n.length>0&&s.push(`Facts: ${n.join("; ")}`)}catch{M.warn("FORMAT","Invalid JSON in facts field",{obsId:e.id})}if(e.concepts)try{let n=JSON.parse(e.concepts);n.length>0&&s.push(`Concepts: ${n.join(", ")}`)}catch{M.warn("FORMAT","Invalid JSON in concepts field",{obsId:e.id})}if(e.files_read||e.files_modified){let n=[];if(e.files_read)try{n.push(...JSON.parse(e.files_read))}catch{M.warn("FORMAT","Invalid JSON in files_read field",{obsId:e.id})}if(e.files_modified)try{n.push(...JSON.parse(e.files_modified))}catch{M.warn("FORMAT","Invalid JSON in files_modified field",{obsId:e.id})}n.length>0&&s.push(`Files: ${[...new Set(n)].join(", ")}`)}s.length>0&&(t.push("---"),t.push(s.join(" | ")));let i=new Date(e.created_at_epoch).toLocaleString();return t.push(""),t.push("---"),t.push(`Date: ${i}`),t.join(` `)}formatSessionResult(e){let r=e.request||`Session ${e.sdk_session_id?.substring(0,8)||"unknown"}`,t=[];t.push(`## ${r}`),t.push(`*Source: claude-mem://session/${e.sdk_session_id}*`),t.push(""),e.completed&&(t.push(`**Completed:** ${e.completed}`),t.push("")),e.learned&&(t.push(`**Learned:** ${e.learned}`),t.push("")),e.investigated&&(t.push(`**Investigated:** ${e.investigated}`),t.push("")),e.next_steps&&(t.push(`**Next Steps:** ${e.next_steps}`),t.push("")),e.notes&&(t.push(`**Notes:** ${e.notes}`),t.push(""));let s=[];if(e.files_read||e.files_edited){let n=[];if(e.files_read)try{n.push(...JSON.parse(e.files_read))}catch{M.warn("FORMAT","Invalid JSON in session files_read field",{sessionId:e.sdk_session_id})}if(e.files_edited)try{n.push(...JSON.parse(e.files_edited))}catch{M.warn("FORMAT","Invalid JSON in session files_edited field",{sessionId:e.sdk_session_id})}n.length>0&&s.push(`Files: ${[...new Set(n)].join(", ")}`)}let i=new Date(e.created_at_epoch).toLocaleDateString();return s.push(`Date: ${i}`),s.length>0&&(t.push("---"),t.push(s.join(" | "))),t.join(` `)}formatUserPromptResult(e){let r=[];r.push(`## User Prompt #${e.prompt_number}`),r.push(`*Source: claude-mem://user-prompt/${e.id}*`),r.push(""),r.push(e.prompt_text),r.push(""),r.push("---");let t=new Date(e.created_at_epoch).toLocaleString();return r.push(`Date: ${t}`),r.join(` `)}};var Dl=class{buildTimeline(e){let r=[...e.observations.map(t=>({type:"observation",data:t,epoch:t.created_at_epoch})),...e.sessions.map(t=>({type:"session",data:t,epoch:t.created_at_epoch})),...e.prompts.map(t=>({type:"prompt",data:t,epoch:t.created_at_epoch}))];return r.sort((t,s)=>t.epoch-s.epoch),r}filterByDepth(e,r,t,s,i){if(e.length===0)return e;let n=-1;if(typeof r=="number")n=e.findIndex(c=>c.type==="observation"&&c.data.id===r);else if(typeof r=="string"&&r.startsWith("S")){let c=parseInt(r.slice(1),10);n=e.findIndex(u=>u.type==="session"&&u.data.id===c)}else n=e.findIndex(c=>c.epoch>=t),n===-1&&(n=e.length-1);if(n===-1)return e;let o=Math.max(0,n-s),l=Math.min(e.length,n+i+1);return e.slice(o,l)}formatTimeline(e,r,t,s,i){if(e.length===0)return t?`Found observation matching "${t}", but no timeline context available.`:"No timeline items found";let n=[];if(t&&r){let c=e.find(p=>p.type==="observation"&&p.data.id===r),u=c?c.data.title||"Untitled":"Unknown";n.push(`# Timeline for query: "${t}"`),n.push(`**Anchor:** Observation #${r} - ${u}`)}else r?n.push(`# Timeline around anchor: ${r}`):n.push("# Timeline");s!==void 0&&i!==void 0?n.push(`**Window:** ${s} records before \u2192 ${i} records after | **Items:** ${e.length}`):n.push(`**Items:** ${e.length}`),n.push(""),n.push("**Legend:** \u{1F3AF} session-request | \u{1F534} bugfix | \u{1F7E3} feature | \u{1F504} refactor | \u2705 change | \u{1F535} discovery | \u{1F9E0} decision"),n.push("");let o=new Map;for(let c of e){let u=this.formatDate(c.epoch);o.has(u)||o.set(u,[]),o.get(u).push(c)}let l=Array.from(o.entries()).sort((c,u)=>{let p=new Date(c[0]).getTime(),m=new Date(u[0]).getTime();return p-m});for(let[c,u]of l){n.push(`### ${c}`),n.push("");let p=null,m="",d=!1;for(let v of u){let h=typeof r=="number"&&v.type==="observation"&&v.data.id===r||typeof r=="string"&&r.startsWith("S")&&v.type==="session"&&`S${v.data.id}`===r;if(v.type==="session"){d&&(n.push(""),d=!1,p=null,m="");let f=v.data,y=f.request||"Session summary",g=`claude-mem://session-summary/${f.id}`,b=h?" \u2190 **ANCHOR**":"";n.push(`**\u{1F3AF} #S${f.id}** ${y} (${this.formatDateTime(v.epoch)}) [\u2192](${g})${b}`),n.push("")}else if(v.type==="prompt"){d&&(n.push(""),d=!1,p=null,m="");let f=v.data,y=f.prompt_text.length>100?f.prompt_text.substring(0,100)+"...":f.prompt_text;n.push(`**\u{1F4AC} User Prompt #${f.prompt_number}** (${this.formatDateTime(v.epoch)})`),n.push(`> ${y}`),n.push("")}else if(v.type==="observation"){let f=v.data,y="General";y!==p&&(d&&n.push(""),n.push(`**${y}**`),n.push("| ID | Time | T | Title | Tokens |"),n.push("|----|------|---|-------|--------|"),p=y,d=!0,m="");let g=this.getTypeIcon(f.type),b=this.formatTime(v.epoch),w=f.title||"Untitled",P=this.estimateTokens(f.narrative),k=b!==m?b:"\u2033";m=b;let N=h?" \u2190 **ANCHOR**":"";n.push(`| #${f.id} | ${k} | ${g} | ${w}${N} | ~${P} |`)}}d&&n.push("")}return n.join(` diff --git a/plugin/skills/mem-search/SKILL.md b/plugin/skills/mem-search/SKILL.md index bee8e01c..5eebd3e1 100644 --- a/plugin/skills/mem-search/SKILL.md +++ b/plugin/skills/mem-search/SKILL.md @@ -87,13 +87,7 @@ Review the index results (and timeline if used). Identify which IDs are actually For each relevant ID, fetch full details using MCP tools: -**Fetch single observation:** - -``` -get_observation(id=11131) -``` - -**Fetch multiple observations (recommended for 2+ IDs):** +**Fetch multiple observations (ALWAYS use for 2+ IDs):** ``` get_batch_observations(ids=[11131, 10942, 10855]) @@ -105,10 +99,17 @@ get_batch_observations(ids=[11131, 10942, 10855]) get_batch_observations( ids=[11131, 10942, 10855], orderBy="date_desc", - limit=10 + limit=10, + project="my-project" ) ``` +**Fetch single observation (only when fetching exactly 1):** + +``` +get_observation(id=11131) +``` + **Fetch session:** ``` @@ -127,18 +128,20 @@ get_prompt(id=5421) - Sessions: Just the number (2005) from "S2005" - Prompts: Just the number (5421) -**When to use batch:** +**Batch optimization:** -- Always use `get_batch_observations` when fetching 2+ observations -- More efficient: one request vs multiple -- Returns all observations in a single response +- **ALWAYS use `get_batch_observations` for 2+ observations** +- 10-100x more efficient than individual fetches +- Single HTTP request vs N requests +- Returns all results in one response +- Supports ordering and filtering ## Search Parameters **Basic:** - `query` - What to search for (required) -- `format` - "index" or "full" (always use "index" first) +- `format` - "index" (NEVER USE FULL) - `limit` - How many results (default 30) - `project` - Filter by project name (required) @@ -188,18 +191,30 @@ progressive_ix(topic="all") # Get complete guide ## Why This Workflow? -**Token efficiency:** +**Massive performance gains:** -- Index format: ~50-100 tokens per result -- Full format: ~500-1000 tokens per result -- **10x difference** - only fetch full when you know it's relevant +- **Index format:** ~50-100 tokens per result +- **Full format:** ~500-1000 tokens per result +- **10x token savings** - only fetch full when you know it's relevant + +**Batch fetching optimization:** + +- **Fetching 10 observations individually:** 10 HTTP requests, ~5-10s latency +- **Batch fetch:** 1 HTTP request, ~0.5-1s latency +- **10-100x faster** for multi-observation queries **Clarity:** -- See everything first -- Pick what matters -- Get details only for what you need +- See everything first (index) +- Get timeline context around interesting results +- Pick what matters based on context +- Fetch details only for what you need (batch when possible) --- -**Remember:** ALWAYS search with format=index first. ALWAYS get timeline context for observations you're interested in. ALWAYS fetch by ID for details. The IDs are there for a reason - use them. +**Remember:** + +- ALWAYS search with `format="index"` first for token efficiency +- ALWAYS get timeline context to understand what was happening +- ALWAYS use `get_batch_observations` when fetching 2+ observations +- The workflow is optimized: index → timeline → batch fetch = 10-100x faster diff --git a/src/servers/mcp-server.ts b/src/servers/mcp-server.ts index 67657147..13b8c1cf 100644 --- a/src/servers/mcp-server.ts +++ b/src/servers/mcp-server.ts @@ -30,18 +30,8 @@ const WORKER_BASE_URL = `http://${WORKER_HOST}:${WORKER_PORT}`; const TOOL_ENDPOINT_MAP: Record = { 'search': '/api/search', 'timeline': '/api/timeline', - 'decisions': '/api/decisions', - 'changes': '/api/changes', - 'how_it_works': '/api/how-it-works', - 'search_observations': '/api/search/observations', - 'search_sessions': '/api/search/sessions', - 'search_user_prompts': '/api/search/prompts', - 'find_by_concept': '/api/search/by-concept', - 'find_by_file': '/api/search/by-file', - 'find_by_type': '/api/search/by-type', 'get_recent_context': '/api/context/recent', 'get_context_timeline': '/api/context/timeline', - 'get_timeline_by_query': '/api/timeline/by-query', 'progressive_ix': '/api/instructions' }; @@ -192,24 +182,25 @@ async function verifyWorkerConnection(): Promise { /** * Tool definitions with HTTP-based handlers + * Descriptions removed - use progressive_ix tool for parameter documentation */ const tools = [ { name: 'search', description: 'Search observations, sessions, and prompts', inputSchema: z.object({ - query: z.string().optional().describe('Natural language search query for semantic ranking via ChromaDB vector search. Optional - omit for date-filtered queries only (Chroma cannot filter by date, requires direct SQLite).'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED for initial search), "full" for complete details (use only after reviewing index results)'), - type: z.enum(['observations', 'sessions', 'prompts']).optional().describe('Filter by document type (observations, sessions, or prompts). Omit to search all types.'), - obs_type: z.string().optional().describe('Filter observations by type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change). Only applies when type="observations"'), - concepts: z.string().optional().describe('Filter by concept tags (single value or comma-separated list). Only applies when type="observations"'), - files: z.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match). Only applies when type="observations"'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - offset: z.number().min(0).default(0).describe('Number of results to skip'), - orderBy: z.enum(['relevance', 'date_desc', 'date_asc']).default('date_desc').describe('Sort order') + query: z.string().optional(), + format: z.enum(['index', 'full']).default('index'), + type: z.enum(['observations', 'sessions', 'prompts']).optional(), + obs_type: z.string().optional(), + concepts: z.string().optional(), + files: z.string().optional(), + project: z.string().optional(), + dateStart: z.union([z.string(), z.number()]).optional(), + dateEnd: z.union([z.string(), z.number()]).optional(), + limit: z.number().min(1).max(100).default(20), + offset: z.number().min(0).default(0), + orderBy: z.enum(['relevance', 'date_desc', 'date_asc']).default('date_desc') }), handler: async (args: any) => { const endpoint = TOOL_ENDPOINT_MAP['search']; @@ -220,195 +211,33 @@ const tools = [ name: 'timeline', description: 'Get timeline around observation ID or query', inputSchema: z.object({ - query: z.string().optional().describe('Natural language query to find anchor observation (query-based mode). Mutually exclusive with anchor.'), - anchor: z.number().optional().describe('Observation ID to use as anchor (anchor-based mode). Mutually exclusive with query.'), - depth_before: z.number().min(0).max(100).default(10).describe('Number of observations to fetch before anchor'), - depth_after: z.number().min(0).max(100).default(10).describe('Number of observations to fetch after anchor'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - type: z.string().optional().describe('Filter observations by type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)'), - concepts: z.string().optional().describe('Filter by concept tags (single value or comma-separated list)'), - files: z.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match)'), - project: z.string().optional().describe('Filter by project name') + query: z.string().optional(), + anchor: z.number().optional(), + depth_before: z.number().min(0).max(100).default(10), + depth_after: z.number().min(0).max(100).default(10), + format: z.enum(['index', 'full']).default('index'), + type: z.string().optional(), + concepts: z.string().optional(), + files: z.string().optional(), + project: z.string().optional() }), handler: async (args: any) => { const endpoint = TOOL_ENDPOINT_MAP['timeline']; return await callWorkerAPI(endpoint, args); } }, - { - name: 'decisions', - description: 'Find architectural and design decisions', - inputSchema: z.object({ - query: z.string().describe('Natural language query for finding decisions'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['decisions']; - return await callWorkerAPI(endpoint, args); - } - }, - { - name: 'changes', - description: 'Find code changes and refactorings', - inputSchema: z.object({ - query: z.string().describe('Natural language query for finding changes'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['changes']; - return await callWorkerAPI(endpoint, args); - } - }, - { - name: 'how_it_works', - description: 'Understand system architecture', - inputSchema: z.object({ - query: z.string().describe('Natural language query for understanding how something works'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['how_it_works']; - return await callWorkerAPI(endpoint, args); - } - }, - { - name: 'search_observations', - description: '[DEPRECATED] Search observations only', - inputSchema: z.object({ - query: z.string().optional().describe('Full-text search query (FTS5)'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - type: z.string().optional().describe('Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)'), - concepts: z.string().optional().describe('Filter by concept tags (single value or comma-separated list)'), - files: z.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match)'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - offset: z.number().min(0).default(0).describe('Number of results to skip'), - orderBy: z.enum(['relevance', 'date_desc', 'date_asc']).default('relevance').describe('Sort order (relevance only when query provided)') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['search_observations']; - return await callWorkerAPI(endpoint, args); - } - }, - { - name: 'search_sessions', - description: '[DEPRECATED] Search sessions only', - inputSchema: z.object({ - query: z.string().optional().describe('Full-text search query (FTS5)'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - offset: z.number().min(0).default(0).describe('Number of results to skip'), - orderBy: z.enum(['relevance', 'date_desc', 'date_asc']).default('relevance').describe('Sort order (relevance only when query provided)') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['search_sessions']; - return await callWorkerAPI(endpoint, args); - } - }, - { - name: 'search_user_prompts', - description: '[DEPRECATED] Search prompts only', - inputSchema: z.object({ - query: z.string().optional().describe('Full-text search query (FTS5)'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - offset: z.number().min(0).default(0).describe('Number of results to skip'), - orderBy: z.enum(['relevance', 'date_desc', 'date_asc']).default('relevance').describe('Sort order (relevance only when query provided)') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['search_user_prompts']; - return await callWorkerAPI(endpoint, args); - } - }, - { - name: 'find_by_concept', - description: 'Find observations by concept tags', - inputSchema: z.object({ - concepts: z.string().describe('Concept tag(s) to filter by (single value or comma-separated list)'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - type: z.string().optional().describe('Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)'), - files: z.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match)'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - offset: z.number().min(0).default(0).describe('Number of results to skip'), - orderBy: z.enum(['date_desc', 'date_asc']).default('date_desc').describe('Sort order') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['find_by_concept']; - return await callWorkerAPI(endpoint, args); - } - }, - { - name: 'find_by_file', - description: 'Find observations by file paths', - inputSchema: z.object({ - files: z.string().describe('File path(s) to filter by (single value or comma-separated list for partial match)'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - type: z.string().optional().describe('Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)'), - concepts: z.string().optional().describe('Filter by concept tags (single value or comma-separated list)'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - offset: z.number().min(0).default(0).describe('Number of results to skip'), - orderBy: z.enum(['date_desc', 'date_asc']).default('date_desc').describe('Sort order') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['find_by_file']; - return await callWorkerAPI(endpoint, args); - } - }, - { - name: 'find_by_type', - description: 'Find observations by type', - inputSchema: z.object({ - type: z.string().describe('Observation type(s) to filter by (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - concepts: z.string().optional().describe('Filter by concept tags (single value or comma-separated list)'), - files: z.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match)'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)'), - limit: z.number().min(1).max(100).default(20).describe('Maximum number of results'), - offset: z.number().min(0).default(0).describe('Number of results to skip'), - orderBy: z.enum(['date_desc', 'date_asc']).default('date_desc').describe('Sort order') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['find_by_type']; - return await callWorkerAPI(endpoint, args); - } - }, { name: 'get_recent_context', description: 'Get recent timeline items', inputSchema: z.object({ - limit: z.number().min(1).max(100).default(30).describe('Maximum number of timeline items to return'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - type: z.string().optional().describe('Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)'), - concepts: z.string().optional().describe('Filter by concept tags (single value or comma-separated list)'), - files: z.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match)'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)') + limit: z.number().min(1).max(100).default(30), + format: z.enum(['index', 'full']).default('index'), + type: z.string().optional(), + concepts: z.string().optional(), + files: z.string().optional(), + project: z.string().optional(), + dateStart: z.union([z.string(), z.number()]).optional(), + dateEnd: z.union([z.string(), z.number()]).optional() }), handler: async (args: any) => { const endpoint = TOOL_ENDPOINT_MAP['get_recent_context']; @@ -419,47 +248,25 @@ const tools = [ name: 'get_context_timeline', description: 'Get timeline around specific observation', inputSchema: z.object({ - anchor: z.number().describe('Observation ID to use as anchor point'), - depth_before: z.number().min(0).max(100).default(10).describe('Number of observations to fetch before anchor'), - depth_after: z.number().min(0).max(100).default(10).describe('Number of observations to fetch after anchor'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - type: z.string().optional().describe('Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)'), - concepts: z.string().optional().describe('Filter by concept tags (single value or comma-separated list)'), - files: z.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match)'), - project: z.string().optional().describe('Filter by project name') + anchor: z.number(), + depth_before: z.number().min(0).max(100).default(10), + depth_after: z.number().min(0).max(100).default(10), + format: z.enum(['index', 'full']).default('index'), + type: z.string().optional(), + concepts: z.string().optional(), + files: z.string().optional(), + project: z.string().optional() }), handler: async (args: any) => { const endpoint = TOOL_ENDPOINT_MAP['get_context_timeline']; return await callWorkerAPI(endpoint, args); } }, - { - name: 'get_timeline_by_query', - description: 'Search and get timeline in one call', - inputSchema: z.object({ - query: z.string().describe('Natural language query to find anchor observation'), - depth_before: z.number().min(0).max(100).default(10).describe('Number of observations to fetch before anchor'), - depth_after: z.number().min(0).max(100).default(10).describe('Number of observations to fetch after anchor'), - format: z.enum(['index', 'full']).default('index').describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'), - type: z.string().optional().describe('Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)'), - concepts: z.string().optional().describe('Filter by concept tags (single value or comma-separated list)'), - files: z.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match)'), - project: z.string().optional().describe('Filter by project name'), - dateStart: z.union([z.string(), z.number()]).optional().describe('Start date for filtering (ISO string or epoch timestamp)'), - dateEnd: z.union([z.string(), z.number()]).optional().describe('End date for filtering (ISO string or epoch timestamp)') - }), - handler: async (args: any) => { - const endpoint = TOOL_ENDPOINT_MAP['get_timeline_by_query']; - return await callWorkerAPI(endpoint, args); - } - }, { name: 'progressive_ix', - description: 'Load detailed instructions for mem-search tools', + description: 'Load parameter docs and usage instructions', inputSchema: z.object({ - topic: z.enum(['workflow', 'search_params', 'examples', 'all']) - .default('all') - .describe('Which instruction section to load: workflow (4-step process), search_params (parameters reference), examples (usage examples), all (complete guide)') + topic: z.enum(['workflow', 'search_params', 'examples', 'all']).default('all') }), handler: async (args: any) => { const endpoint = TOOL_ENDPOINT_MAP['progressive_ix']; @@ -468,9 +275,9 @@ const tools = [ }, { name: 'get_observation', - description: 'Get full details for a single observation by ID', + description: 'Get observation by ID', inputSchema: z.object({ - id: z.number().describe('Observation ID from search/timeline results') + id: z.number() }), handler: async (args: any) => { return await callWorkerAPIWithPath('/api/observation', args.id); @@ -478,12 +285,12 @@ const tools = [ }, { name: 'get_batch_observations', - description: 'Get full details for multiple observations by IDs in one request', + description: 'Get multiple observations by IDs', inputSchema: z.object({ - ids: z.array(z.number()).describe('Array of observation IDs to fetch'), - orderBy: z.enum(['date_desc', 'date_asc']).optional().describe('Sort order for results'), - limit: z.number().optional().describe('Maximum number of results to return'), - project: z.string().optional().describe('Filter by project name') + ids: z.array(z.number()), + orderBy: z.enum(['date_desc', 'date_asc']).optional(), + limit: z.number().optional(), + project: z.string().optional() }), handler: async (args: any) => { return await callWorkerAPIPost('/api/observations/batch', args); @@ -491,9 +298,9 @@ const tools = [ }, { name: 'get_session', - description: 'Get full session summary by ID', + description: 'Get session summary by ID', inputSchema: z.object({ - id: z.number().describe('Session ID (just the number from S1234)') + id: z.number() }), handler: async (args: any) => { return await callWorkerAPIWithPath('/api/session', args.id); @@ -503,7 +310,7 @@ const tools = [ name: 'get_prompt', description: 'Get user prompt by ID', inputSchema: z.object({ - id: z.number().describe('Prompt ID from search results') + id: z.number() }), handler: async (args: any) => { return await callWorkerAPIWithPath('/api/prompt', args.id); diff --git a/src/services/worker/FormattingService.ts b/src/services/worker/FormattingService.ts index 8a7e5975..dd20b514 100644 --- a/src/services/worker/FormattingService.ts +++ b/src/services/worker/FormattingService.ts @@ -38,9 +38,7 @@ Other tips: const date = new Date(obs.created_at_epoch).toLocaleString(); const type = obs.type ? `[${obs.type}]` : ''; - return `${index + 1}. ${type} ${title} - Date: ${date} - Source: claude-mem://observation/${obs.id}`; + return ` ${index + 1}. ${type} ${title}\n Date: ${date}\n Source: claude-mem://observation/${obs.id}`; } /** @@ -50,9 +48,7 @@ Other tips: const title = session.request || `Session ${session.sdk_session_id?.substring(0, 8) || 'unknown'}`; const date = new Date(session.created_at_epoch).toLocaleString(); - return `${index + 1}. ${title} - Date: ${date} - Source: claude-mem://session/${session.sdk_session_id}`; + return ` ${index + 1}. ${title}\n Date: ${date}\n Source: claude-mem://session/${session.sdk_session_id}`; } /** @@ -61,9 +57,7 @@ Other tips: formatUserPromptIndex(prompt: UserPromptSearchResult, index: number): string { const date = new Date(prompt.created_at_epoch).toLocaleString(); - return `${index + 1}. "${prompt.prompt_text}" - Date: ${date} | Prompt #${prompt.prompt_number} - Source: claude-mem://user-prompt/${prompt.id}`; + return ` ${index + 1}. "${prompt.prompt_text}"\n Date: ${date} | Prompt #${prompt.prompt_number}\n Source: claude-mem://user-prompt/${prompt.id}`; } /** diff --git a/src/services/worker/SearchManager.ts b/src/services/worker/SearchManager.ts index 3a516b35..88a57176 100644 --- a/src/services/worker/SearchManager.ts +++ b/src/services/worker/SearchManager.ts @@ -248,7 +248,7 @@ export class SearchManager { let combinedText: string; if (format === 'index') { - const header = `Found ${totalResults} result(s) matching "${query}" (${observations.length} obs, ${sessions.length} sessions, ${prompts.length} prompts):\n\n`; + const header = ` ⎿ Found ${totalResults} result(s) matching "${query}" (${observations.length} obs, ${sessions.length} sessions, ${prompts.length} prompts):\n\n`; const formattedResults = limitedResults.map((item, i) => { if (item.type === 'observation') { return this.formatter.formatObservationIndex(item.data, i); @@ -258,7 +258,7 @@ export class SearchManager { return this.formatter.formatUserPromptIndex(item.data, i); } }); - combinedText = header + formattedResults.join('\n\n') + this.formatter.formatSearchTips(); + combinedText = header + formattedResults.join('\n\n'); } else { const formattedResults = limitedResults.map(item => { if (item.type === 'observation') { @@ -688,7 +688,7 @@ export class SearchManager { let combinedText: string; if (format === 'index') { - const header = `Found ${results.length} decision(s):\n\n`; + const header = ` ⎿ Found ${results.length} decision(s):\n\n`; const formattedResults = results.map((obs, i) => this.formatter.formatObservationIndex(obs, i)); combinedText = header + formattedResults.join('\n\n'); } else { @@ -786,7 +786,7 @@ export class SearchManager { let combinedText: string; if (format === 'index') { - const header = `Found ${results.length} change-related observation(s):\n\n`; + const header = ` ⎿ Found ${results.length} change-related observation(s):\n\n`; const formattedResults = results.map((obs, i) => this.formatter.formatObservationIndex(obs, i)); combinedText = header + formattedResults.join('\n\n'); } else { @@ -862,7 +862,7 @@ export class SearchManager { let combinedText: string; if (format === 'index') { - const header = `Found ${results.length} "how it works" observation(s):\n\n`; + const header = ` ⎿ Found ${results.length} "how it works" observation(s):\n\n`; const formattedResults = results.map((obs, i) => this.formatter.formatObservationIndex(obs, i)); combinedText = header + formattedResults.join('\n\n'); } else { @@ -939,9 +939,9 @@ export class SearchManager { // Format based on requested format let combinedText: string; if (format === 'index') { - const header = `Found ${results.length} observation(s) matching "${query}":\n\n`; + const header = ` ⎿ Found ${results.length} observation(s) matching "${query}":\n\n`; const formattedResults = results.map((obs, i) => this.formatter.formatObservationIndex(obs, i)); - combinedText = header + formattedResults.join('\n\n') + this.formatter.formatSearchTips(); + combinedText = header + formattedResults.join('\n\n'); } else { const formattedResults = results.map((obs) => this.formatter.formatObservationResult(obs)); combinedText = formattedResults.join('\n\n---\n\n'); @@ -1016,9 +1016,9 @@ export class SearchManager { // Format based on requested format let combinedText: string; if (format === 'index') { - const header = `Found ${results.length} session(s) matching "${query}":\n\n`; + const header = ` ⎿ Found ${results.length} session(s) matching "${query}":\n\n`; const formattedResults = results.map((session, i) => this.formatter.formatSessionIndex(session, i)); - combinedText = header + formattedResults.join('\n\n') + this.formatter.formatSearchTips(); + combinedText = header + formattedResults.join('\n\n'); } else { const formattedResults = results.map((session) => this.formatter.formatSessionResult(session)); combinedText = formattedResults.join('\n\n---\n\n'); @@ -1093,9 +1093,9 @@ export class SearchManager { // Format based on requested format let combinedText: string; if (format === 'index') { - const header = `Found ${results.length} user prompt(s) matching "${query}":\n\n`; + const header = ` ⎿ Found ${results.length} user prompt(s) matching "${query}":\n\n`; const formattedResults = results.map((prompt, i) => this.formatter.formatUserPromptIndex(prompt, i)); - combinedText = header + formattedResults.join('\n\n') + this.formatter.formatSearchTips(); + combinedText = header + formattedResults.join('\n\n'); } else { const formattedResults = results.map((prompt) => this.formatter.formatUserPromptResult(prompt)); combinedText = formattedResults.join('\n\n---\n\n'); @@ -1182,9 +1182,9 @@ export class SearchManager { // Format based on requested format let combinedText: string; if (format === 'index') { - const header = `Found ${results.length} observation(s) with concept "${concept}":\n\n`; + const header = ` ⎿ Found ${results.length} observation(s) with concept "${concept}":\n\n`; const formattedResults = results.map((obs, i) => this.formatter.formatObservationIndex(obs, i)); - combinedText = header + formattedResults.join('\n\n') + this.formatter.formatSearchTips(); + combinedText = header + formattedResults.join('\n\n'); } else { const formattedResults = results.map((obs) => this.formatter.formatObservationResult(obs)); combinedText = formattedResults.join('\n\n---\n\n'); @@ -1279,7 +1279,7 @@ export class SearchManager { let combinedText: string; if (format === 'index') { - const header = `Found ${totalResults} result(s) for file "${filePath}":\n\n`; + const header = ` ⎿ Found ${totalResults} result(s) for file "${filePath}":\n\n`; const formattedResults: string[] = []; // Add observations @@ -1292,7 +1292,7 @@ export class SearchManager { formattedResults.push(this.formatter.formatSessionIndex(session, i + observations.length)); }); - combinedText = header + formattedResults.join('\n\n') + this.formatter.formatSearchTips(); + combinedText = header + formattedResults.join('\n\n'); } else { const formattedResults: string[] = []; @@ -1391,9 +1391,9 @@ export class SearchManager { // Format based on requested format let combinedText: string; if (format === 'index') { - const header = `Found ${results.length} observation(s) with type "${typeStr}":\n\n`; + const header = ` ⎿ Found ${results.length} observation(s) with type "${typeStr}":\n\n`; const formattedResults = results.map((obs, i) => this.formatter.formatObservationIndex(obs, i)); - combinedText = header + formattedResults.join('\n\n') + this.formatter.formatSearchTips(); + combinedText = header + formattedResults.join('\n\n'); } else { const formattedResults = results.map((obs) => this.formatter.formatObservationResult(obs)); combinedText = formattedResults.join('\n\n---\n\n');