532 lines
273 KiB
JavaScript
Executable File
532 lines
273 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
var Sl=Object.create;var Ia=Object.defineProperty;var xl=Object.getOwnPropertyDescriptor;var Rl=Object.getOwnPropertyNames;var Tl=Object.getPrototypeOf,Pl=Object.prototype.hasOwnProperty;var X=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),Ol=(a,e)=>{for(var t in e)Ia(a,t,{get:e[t],enumerable:!0})},wl=(a,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Rl(e))!Pl.call(a,r)&&r!==t&&Ia(a,r,{get:()=>e[r],enumerable:!(s=xl(e,r))||s.enumerable});return a};var Il=(a,e,t)=>(t=a!=null?Sl(Tl(a)):{},wl(e||!a||!a.__esModule?Ia(t,"default",{value:a,enumerable:!0}):t,a));var vn=X((Xt,mn)=>{(function(a,e){typeof Xt=="object"&&typeof mn<"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,f=Array(h),y=0;y<h;y++)f[y]=arguments[y];if(f.length>1){f[0]=f[0].slice(0,-1);for(var S=f.length-1,x=1;x<S;++x)f[x]=f[x].slice(1,-1);return f[S]=f[S].slice(1),f.join("")}else return f[0]}function t(h){return"(?:"+h+")"}function s(h){return h===void 0?"undefined":h===null?"null":Object.prototype.toString.call(h).split(" ").pop().split("]").shift().toLowerCase()}function r(h){return h.toUpperCase()}function n(h){return h!=null?h instanceof Array?h:typeof h.length!="number"||h.split||h.setInterval||h.call?[h]:Array.prototype.slice.call(h):[]}function i(h,f){var y=h;if(f)for(var S in f)y[S]=f[S];return y}function o(h){var f="[A-Za-z]",y="[\\x0D]",S="[0-9]",x="[\\x22]",L=e(S,"[A-Fa-f]"),Q="[\\x0A]",ae="[\\x20]",oe=t(t("%[EFef]"+L+"%"+L+L+"%"+L+L)+"|"+t("%[89A-Fa-f]"+L+"%"+L+L)+"|"+t("%"+L+L)),Ee="[\\:\\/\\?\\#\\[\\]\\@]",te="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",pe=e(Ee,te),be=h?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",de=h?"[\\uE000-\\uF8FF]":"[]",ne=e(f,S,"[\\-\\.\\_\\~]",be),he=t(f+e(f,S,"[\\+\\-\\.]")+"*"),ce=t(t(oe+"|"+e(ne,te,"[\\:]"))+"*"),Ir=t(t("25[0-5]")+"|"+t("2[0-4]"+S)+"|"+t("1"+S+S)+"|"+t("[1-9]"+S)+"|"+S),je=t(t("25[0-5]")+"|"+t("2[0-4]"+S)+"|"+t("1"+S+S)+"|"+t("0?[1-9]"+S)+"|0?0?"+S),Ue=t(je+"\\."+je+"\\."+je+"\\."+je),ue=t(L+"{1,4}"),Fe=t(t(ue+"\\:"+ue)+"|"+Ue),qe=t(t(ue+"\\:")+"{6}"+Fe),tr=t("\\:\\:"+t(ue+"\\:")+"{5}"+Fe),Nr=t(t(ue)+"?\\:\\:"+t(ue+"\\:")+"{4}"+Fe),ur=t(t(t(ue+"\\:")+"{0,1}"+ue)+"?\\:\\:"+t(ue+"\\:")+"{3}"+Fe),mt=t(t(t(ue+"\\:")+"{0,2}"+ue)+"?\\:\\:"+t(ue+"\\:")+"{2}"+Fe),Nt=t(t(t(ue+"\\:")+"{0,3}"+ue)+"?\\:\\:"+ue+"\\:"+Fe),At=t(t(t(ue+"\\:")+"{0,4}"+ue)+"?\\:\\:"+Fe),Jr=t(t(t(ue+"\\:")+"{0,5}"+ue)+"?\\:\\:"+ue),Yr=t(t(t(ue+"\\:")+"{0,6}"+ue)+"?\\:\\:"),dr=t([qe,tr,Nr,ur,mt,Nt,At,Jr,Yr].join("|")),et=t(t(ne+"|"+oe)+"+"),Oa=t(dr+"\\%25"+et),Ar=t(dr+t("\\%25|\\%(?!"+L+"{2})")+et),ml=t("[vV]"+L+"+\\."+e(ne,te,"[\\:]")+"+"),vl=t("\\["+t(Ar+"|"+dr+"|"+ml)+"\\]"),$s=t(t(oe+"|"+e(ne,te))+"*"),vt=t(vl+"|"+Ue+"(?!"+$s+")|"+$s),gt=t(S+"*"),ks=t(t(ce+"@")+"?"+vt+t("\\:"+gt)+"?"),_t=t(oe+"|"+e(ne,te,"[\\:\\@]")),gl=t(_t+"*"),Ls=t(_t+"+"),_l=t(t(oe+"|"+e(ne,te,"[\\@]"))+"+"),fr=t(t("\\/"+gl)+"*"),rt=t("\\/"+t(Ls+fr)+"?"),wa=t(_l+fr),Dt=t(Ls+fr),tt="(?!"+_t+")",kf=t(fr+"|"+rt+"|"+wa+"|"+Dt+"|"+tt),at=t(t(_t+"|"+e("[\\/\\?]",de))+"*"),yt=t(t(_t+"|[\\/\\?]")+"*"),js=t(t("\\/\\/"+ks+fr)+"|"+rt+"|"+Dt+"|"+tt),yl=t(he+"\\:"+js+t("\\?"+at)+"?"+t("\\#"+yt)+"?"),El=t(t("\\/\\/"+ks+fr)+"|"+rt+"|"+wa+"|"+tt),bl=t(El+t("\\?"+at)+"?"+t("\\#"+yt)+"?"),Lf=t(yl+"|"+bl),jf=t(he+"\\:"+js+t("\\?"+at)+"?"),Ff="^("+he+")\\:"+t(t("\\/\\/("+t("("+ce+")@")+"?("+vt+")"+t("\\:("+gt+")")+"?)")+"?("+fr+"|"+rt+"|"+Dt+"|"+tt+")")+t("\\?("+at+")")+"?"+t("\\#("+yt+")")+"?$",Mf="^(){0}"+t(t("\\/\\/("+t("("+ce+")@")+"?("+vt+")"+t("\\:("+gt+")")+"?)")+"?("+fr+"|"+rt+"|"+wa+"|"+tt+")")+t("\\?("+at+")")+"?"+t("\\#("+yt+")")+"?$",Uf="^("+he+")\\:"+t(t("\\/\\/("+t("("+ce+")@")+"?("+vt+")"+t("\\:("+gt+")")+"?)")+"?("+fr+"|"+rt+"|"+Dt+"|"+tt+")")+t("\\?("+at+")")+"?$",qf="^"+t("\\#("+yt+")")+"?$",Vf="^"+t("("+ce+")@")+"?("+vt+")"+t("\\:("+gt+")")+"?$";return{NOT_SCHEME:new RegExp(e("[^]",f,S,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(e("[^\\%\\:]",ne,te),"g"),NOT_HOST:new RegExp(e("[^\\%\\[\\]\\:]",ne,te),"g"),NOT_PATH:new RegExp(e("[^\\%\\/\\:\\@]",ne,te),"g"),NOT_PATH_NOSCHEME:new RegExp(e("[^\\%\\/\\@]",ne,te),"g"),NOT_QUERY:new RegExp(e("[^\\%]",ne,te,"[\\:\\@\\/\\?]",de),"g"),NOT_FRAGMENT:new RegExp(e("[^\\%]",ne,te,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(e("[^]",ne,te),"g"),UNRESERVED:new RegExp(ne,"g"),OTHER_CHARS:new RegExp(e("[^\\%]",ne,pe),"g"),PCT_ENCODED:new RegExp(oe,"g"),IPV4ADDRESS:new RegExp("^("+Ue+")$"),IPV6ADDRESS:new RegExp("^\\[?("+dr+")"+t(t("\\%25|\\%(?!"+L+"{2})")+"("+et+")")+"?\\]?$")}}var c=o(!1),u=o(!0),p=function(){function h(f,y){var S=[],x=!0,L=!1,Q=void 0;try{for(var ae=f[Symbol.iterator](),oe;!(x=(oe=ae.next()).done)&&(S.push(oe.value),!(y&&S.length===y));x=!0);}catch(Ee){L=!0,Q=Ee}finally{try{!x&&ae.return&&ae.return()}finally{if(L)throw Q}}return S}return function(f,y){if(Array.isArray(f))return f;if(Symbol.iterator in Object(f))return h(f,y);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),m=function(h){if(Array.isArray(h)){for(var f=0,y=Array(h.length);f<h.length;f++)y[f]=h[f];return y}else return Array.from(h)},E=2147483647,d=36,g=1,_=26,v=38,b=700,T=72,R=128,P="-",N=/^xn--/,A=/[^\0-\x7E]/,z=/[\x2E\u3002\uFF0E\uFF61]/g,U={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=d-g,q=Math.floor,M=String.fromCharCode;function j(h){throw new RangeError(U[h])}function I(h,f){for(var y=[],S=h.length;S--;)y[S]=f(h[S]);return y}function C(h,f){var y=h.split("@"),S="";y.length>1&&(S=y[0]+"@",h=y[1]),h=h.replace(z,".");var x=h.split("."),L=I(x,f).join(".");return S+L}function F(h){for(var f=[],y=0,S=h.length;y<S;){var x=h.charCodeAt(y++);if(x>=55296&&x<=56319&&y<S){var L=h.charCodeAt(y++);(L&64512)==56320?f.push(((x&1023)<<10)+(L&1023)+65536):(f.push(x),y--)}else f.push(x)}return f}var le=function(f){return String.fromCodePoint.apply(String,m(f))},J=function(f){return f-48<10?f-22:f-65<26?f-65:f-97<26?f-97:d},re=function(f,y){return f+22+75*(f<26)-((y!=0)<<5)},K=function(f,y,S){var x=0;for(f=S?q(f/b):f>>1,f+=q(f/y);f>D*_>>1;x+=d)f=q(f/D);return q(x+(D+1)*f/(f+v))},H=function(f){var y=[],S=f.length,x=0,L=R,Q=T,ae=f.lastIndexOf(P);ae<0&&(ae=0);for(var oe=0;oe<ae;++oe)f.charCodeAt(oe)>=128&&j("not-basic"),y.push(f.charCodeAt(oe));for(var Ee=ae>0?ae+1:0;Ee<S;){for(var te=x,pe=1,be=d;;be+=d){Ee>=S&&j("invalid-input");var de=J(f.charCodeAt(Ee++));(de>=d||de>q((E-x)/pe))&&j("overflow"),x+=de*pe;var ne=be<=Q?g:be>=Q+_?_:be-Q;if(de<ne)break;var he=d-ne;pe>q(E/he)&&j("overflow"),pe*=he}var ce=y.length+1;Q=K(x-te,ce,te==0),q(x/ce)>E-L&&j("overflow"),L+=q(x/ce),x%=ce,y.splice(x++,0,L)}return String.fromCodePoint.apply(String,y)},me=function(f){var y=[];f=F(f);var S=f.length,x=R,L=0,Q=T,ae=!0,oe=!1,Ee=void 0;try{for(var te=f[Symbol.iterator](),pe;!(ae=(pe=te.next()).done);ae=!0){var be=pe.value;be<128&&y.push(M(be))}}catch(Ar){oe=!0,Ee=Ar}finally{try{!ae&&te.return&&te.return()}finally{if(oe)throw Ee}}var de=y.length,ne=de;for(de&&y.push(P);ne<S;){var he=E,ce=!0,Ir=!1,je=void 0;try{for(var Ue=f[Symbol.iterator](),ue;!(ce=(ue=Ue.next()).done);ce=!0){var Fe=ue.value;Fe>=x&&Fe<he&&(he=Fe)}}catch(Ar){Ir=!0,je=Ar}finally{try{!ce&&Ue.return&&Ue.return()}finally{if(Ir)throw je}}var qe=ne+1;he-x>q((E-L)/qe)&&j("overflow"),L+=(he-x)*qe,x=he;var tr=!0,Nr=!1,ur=void 0;try{for(var mt=f[Symbol.iterator](),Nt;!(tr=(Nt=mt.next()).done);tr=!0){var At=Nt.value;if(At<x&&++L>E&&j("overflow"),At==x){for(var Jr=L,Yr=d;;Yr+=d){var dr=Yr<=Q?g:Yr>=Q+_?_:Yr-Q;if(Jr<dr)break;var et=Jr-dr,Oa=d-dr;y.push(M(re(dr+et%Oa,0))),Jr=q(et/Oa)}y.push(M(re(Jr,0))),Q=K(L,qe,ne==de),L=0,++ne}}}catch(Ar){Nr=!0,ur=Ar}finally{try{!tr&&mt.return&&mt.return()}finally{if(Nr)throw ur}}++L,++x}return y.join("")},Te=function(f){return C(f,function(y){return N.test(y)?H(y.slice(4).toLowerCase()):y})},we=function(f){return C(f,function(y){return A.test(y)?"xn--"+me(y):y})},se={version:"2.1.0",ucs2:{decode:F,encode:le},decode:H,encode:me,toASCII:we,toUnicode:Te},_e={};function Se(h){var f=h.charCodeAt(0),y=void 0;return f<16?y="%0"+f.toString(16).toUpperCase():f<128?y="%"+f.toString(16).toUpperCase():f<2048?y="%"+(f>>6|192).toString(16).toUpperCase()+"%"+(f&63|128).toString(16).toUpperCase():y="%"+(f>>12|224).toString(16).toUpperCase()+"%"+(f>>6&63|128).toString(16).toUpperCase()+"%"+(f&63|128).toString(16).toUpperCase(),y}function Ie(h){for(var f="",y=0,S=h.length;y<S;){var x=parseInt(h.substr(y+1,2),16);if(x<128)f+=String.fromCharCode(x),y+=3;else if(x>=194&&x<224){if(S-y>=6){var L=parseInt(h.substr(y+4,2),16);f+=String.fromCharCode((x&31)<<6|L&63)}else f+=h.substr(y,6);y+=6}else if(x>=224){if(S-y>=9){var Q=parseInt(h.substr(y+4,2),16),ae=parseInt(h.substr(y+7,2),16);f+=String.fromCharCode((x&15)<<12|(Q&63)<<6|ae&63)}else f+=h.substr(y,9);y+=9}else f+=h.substr(y,3),y+=3}return f}function gr(h,f){function y(S){var x=Ie(S);return x.match(f.UNRESERVED)?x:S}return h.scheme&&(h.scheme=String(h.scheme).replace(f.PCT_ENCODED,y).toLowerCase().replace(f.NOT_SCHEME,"")),h.userinfo!==void 0&&(h.userinfo=String(h.userinfo).replace(f.PCT_ENCODED,y).replace(f.NOT_USERINFO,Se).replace(f.PCT_ENCODED,r)),h.host!==void 0&&(h.host=String(h.host).replace(f.PCT_ENCODED,y).toLowerCase().replace(f.NOT_HOST,Se).replace(f.PCT_ENCODED,r)),h.path!==void 0&&(h.path=String(h.path).replace(f.PCT_ENCODED,y).replace(h.scheme?f.NOT_PATH:f.NOT_PATH_NOSCHEME,Se).replace(f.PCT_ENCODED,r)),h.query!==void 0&&(h.query=String(h.query).replace(f.PCT_ENCODED,y).replace(f.NOT_QUERY,Se).replace(f.PCT_ENCODED,r)),h.fragment!==void 0&&(h.fragment=String(h.fragment).replace(f.PCT_ENCODED,y).replace(f.NOT_FRAGMENT,Se).replace(f.PCT_ENCODED,r)),h}function lr(h){return h.replace(/^0*(.*)/,"$1")||"0"}function ye(h,f){var y=h.match(f.IPV4ADDRESS)||[],S=p(y,2),x=S[1];return x?x.split(".").map(lr).join("."):h}function ve(h,f){var y=h.match(f.IPV6ADDRESS)||[],S=p(y,3),x=S[1],L=S[2];if(x){for(var Q=x.toLowerCase().split("::").reverse(),ae=p(Q,2),oe=ae[0],Ee=ae[1],te=Ee?Ee.split(":").map(lr):[],pe=oe.split(":").map(lr),be=f.IPV4ADDRESS.test(pe[pe.length-1]),de=be?7:8,ne=pe.length-de,he=Array(de),ce=0;ce<de;++ce)he[ce]=te[ce]||pe[ne+ce]||"";be&&(he[de-1]=ye(he[de-1],f));var Ir=he.reduce(function(qe,tr,Nr){if(!tr||tr==="0"){var ur=qe[qe.length-1];ur&&ur.index+ur.length===Nr?ur.length++:qe.push({index:Nr,length:1})}return qe},[]),je=Ir.sort(function(qe,tr){return tr.length-qe.length})[0],Ue=void 0;if(je&&je.length>1){var ue=he.slice(0,je.index),Fe=he.slice(je.index+je.length);Ue=ue.join(":")+"::"+Fe.join(":")}else Ue=he.join(":");return L&&(Ue+="%"+L),Ue}else return h}var Pr=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,Pe="".match(/(){0}/)[1]===void 0;function ie(h){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y={},S=f.iri!==!1?u:c;f.reference==="suffix"&&(h=(f.scheme?f.scheme+":":"")+"//"+h);var x=h.match(Pr);if(x){Pe?(y.scheme=x[1],y.userinfo=x[3],y.host=x[4],y.port=parseInt(x[5],10),y.path=x[6]||"",y.query=x[7],y.fragment=x[8],isNaN(y.port)&&(y.port=x[5])):(y.scheme=x[1]||void 0,y.userinfo=h.indexOf("@")!==-1?x[3]:void 0,y.host=h.indexOf("//")!==-1?x[4]:void 0,y.port=parseInt(x[5],10),y.path=x[6]||"",y.query=h.indexOf("?")!==-1?x[7]:void 0,y.fragment=h.indexOf("#")!==-1?x[8]:void 0,isNaN(y.port)&&(y.port=h.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?x[4]:void 0)),y.host&&(y.host=ve(ye(y.host,S),S)),y.scheme===void 0&&y.userinfo===void 0&&y.host===void 0&&y.port===void 0&&!y.path&&y.query===void 0?y.reference="same-document":y.scheme===void 0?y.reference="relative":y.fragment===void 0?y.reference="absolute":y.reference="uri",f.reference&&f.reference!=="suffix"&&f.reference!==y.reference&&(y.error=y.error||"URI is not a "+f.reference+" reference.");var L=_e[(f.scheme||y.scheme||"").toLowerCase()];if(!f.unicodeSupport&&(!L||!L.unicodeSupport)){if(y.host&&(f.domainHost||L&&L.domainHost))try{y.host=se.toASCII(y.host.replace(S.PCT_ENCODED,Ie).toLowerCase())}catch(Q){y.error=y.error||"Host's domain name can not be converted to ASCII via punycode: "+Q}gr(y,c)}else gr(y,S);L&&L.parse&&L.parse(y,f)}else y.error=y.error||"URI can not be parsed.";return y}function _r(h,f){var y=f.iri!==!1?u:c,S=[];return h.userinfo!==void 0&&(S.push(h.userinfo),S.push("@")),h.host!==void 0&&S.push(ve(ye(String(h.host),y),y).replace(y.IPV6ADDRESS,function(x,L,Q){return"["+L+(Q?"%25"+Q:"")+"]"})),(typeof h.port=="number"||typeof h.port=="string")&&(S.push(":"),S.push(String(h.port))),S.length?S.join(""):void 0}var cr=/^\.\.?\//,Or=/^\/\.(\/|$)/,wr=/^\/\.\.(\/|$)/,xe=/^\/?(?:.|\n)*?(?=\/|$)/;function Me(h){for(var f=[];h.length;)if(h.match(cr))h=h.replace(cr,"");else if(h.match(Or))h=h.replace(Or,"/");else if(h.match(wr))h=h.replace(wr,"/"),f.pop();else if(h==="."||h==="..")h="";else{var y=h.match(xe);if(y){var S=y[0];h=h.slice(S.length),f.push(S)}else throw new Error("Unexpected dot segment condition")}return f.join("")}function De(h){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=f.iri?u:c,S=[],x=_e[(f.scheme||h.scheme||"").toLowerCase()];if(x&&x.serialize&&x.serialize(h,f),h.host&&!y.IPV6ADDRESS.test(h.host)){if(f.domainHost||x&&x.domainHost)try{h.host=f.iri?se.toUnicode(h.host):se.toASCII(h.host.replace(y.PCT_ENCODED,Ie).toLowerCase())}catch(ae){h.error=h.error||"Host's domain name can not be converted to "+(f.iri?"Unicode":"ASCII")+" via punycode: "+ae}}gr(h,y),f.reference!=="suffix"&&h.scheme&&(S.push(h.scheme),S.push(":"));var L=_r(h,f);if(L!==void 0&&(f.reference!=="suffix"&&S.push("//"),S.push(L),h.path&&h.path.charAt(0)!=="/"&&S.push("/")),h.path!==void 0){var Q=h.path;!f.absolutePath&&(!x||!x.absolutePath)&&(Q=Me(Q)),L===void 0&&(Q=Q.replace(/^\/\//,"/%2F")),S.push(Q)}return h.query!==void 0&&(S.push("?"),S.push(h.query)),h.fragment!==void 0&&(S.push("#"),S.push(h.fragment)),S.join("")}function Ne(h,f){var y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},S=arguments[3],x={};return S||(h=ie(De(h,y),y),f=ie(De(f,y),y)),y=y||{},!y.tolerant&&f.scheme?(x.scheme=f.scheme,x.userinfo=f.userinfo,x.host=f.host,x.port=f.port,x.path=Me(f.path||""),x.query=f.query):(f.userinfo!==void 0||f.host!==void 0||f.port!==void 0?(x.userinfo=f.userinfo,x.host=f.host,x.port=f.port,x.path=Me(f.path||""),x.query=f.query):(f.path?(f.path.charAt(0)==="/"?x.path=Me(f.path):((h.userinfo!==void 0||h.host!==void 0||h.port!==void 0)&&!h.path?x.path="/"+f.path:h.path?x.path=h.path.slice(0,h.path.lastIndexOf("/")+1)+f.path:x.path=f.path,x.path=Me(x.path)),x.query=f.query):(x.path=h.path,f.query!==void 0?x.query=f.query:x.query=h.query),x.userinfo=h.userinfo,x.host=h.host,x.port=h.port),x.scheme=h.scheme),x.fragment=f.fragment,x}function er(h,f,y){var S=i({scheme:"null"},y);return De(Ne(ie(h,S),ie(f,S),S,!0),S)}function Le(h,f){return typeof h=="string"?h=De(ie(h,f),f):s(h)==="object"&&(h=ie(De(h,f),f)),h}function It(h,f,y){return typeof h=="string"?h=De(ie(h,y),y):s(h)==="object"&&(h=De(h,y)),typeof f=="string"?f=De(ie(f,y),y):s(f)==="object"&&(f=De(f,y)),h===f}function Ta(h,f){return h&&h.toString().replace(!f||!f.iri?c.ESCAPE:u.ESCAPE,Se)}function Xe(h,f){return h&&h.toString().replace(!f||!f.iri?c.PCT_ENCODED:u.PCT_ENCODED,Ie)}var pt={scheme:"http",domainHost:!0,parse:function(f,y){return f.host||(f.error=f.error||"HTTP URIs must have a host."),f},serialize:function(f,y){var S=String(f.scheme).toLowerCase()==="https";return(f.port===(S?443:80)||f.port==="")&&(f.port=void 0),f.path||(f.path="/"),f}},Ps={scheme:"https",domainHost:pt.domainHost,parse:pt.parse,serialize:pt.serialize};function Os(h){return typeof h.secure=="boolean"?h.secure:String(h.scheme).toLowerCase()==="wss"}var ht={scheme:"ws",domainHost:!0,parse:function(f,y){var S=f;return S.secure=Os(S),S.resourceName=(S.path||"/")+(S.query?"?"+S.query:""),S.path=void 0,S.query=void 0,S},serialize:function(f,y){if((f.port===(Os(f)?443:80)||f.port==="")&&(f.port=void 0),typeof f.secure=="boolean"&&(f.scheme=f.secure?"wss":"ws",f.secure=void 0),f.resourceName){var S=f.resourceName.split("?"),x=p(S,2),L=x[0],Q=x[1];f.path=L&&L!=="/"?L:void 0,f.query=Q,f.resourceName=void 0}return f.fragment=void 0,f}},ws={scheme:"wss",domainHost:ht.domainHost,parse:ht.parse,serialize:ht.serialize},al={},sl=!0,Is="[A-Za-z0-9\\-\\.\\_\\~"+(sl?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",rr="[0-9A-Fa-f]",nl=t(t("%[EFef]"+rr+"%"+rr+rr+"%"+rr+rr)+"|"+t("%[89A-Fa-f]"+rr+"%"+rr+rr)+"|"+t("%"+rr+rr)),il="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",ol="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",ll=e(ol,'[\\"\\\\]'),cl="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",ul=new RegExp(Is,"g"),Kr=new RegExp(nl,"g"),dl=new RegExp(e("[^]",il,"[\\.]",'[\\"]',ll),"g"),Ns=new RegExp(e("[^]",Is,cl),"g"),fl=Ns;function Pa(h){var f=Ie(h);return f.match(ul)?f:h}var As={scheme:"mailto",parse:function(f,y){var S=f,x=S.to=S.path?S.path.split(","):[];if(S.path=void 0,S.query){for(var L=!1,Q={},ae=S.query.split("&"),oe=0,Ee=ae.length;oe<Ee;++oe){var te=ae[oe].split("=");switch(te[0]){case"to":for(var pe=te[1].split(","),be=0,de=pe.length;be<de;++be)x.push(pe[be]);break;case"subject":S.subject=Xe(te[1],y);break;case"body":S.body=Xe(te[1],y);break;default:L=!0,Q[Xe(te[0],y)]=Xe(te[1],y);break}}L&&(S.headers=Q)}S.query=void 0;for(var ne=0,he=x.length;ne<he;++ne){var ce=x[ne].split("@");if(ce[0]=Xe(ce[0]),y.unicodeSupport)ce[1]=Xe(ce[1],y).toLowerCase();else try{ce[1]=se.toASCII(Xe(ce[1],y).toLowerCase())}catch(Ir){S.error=S.error||"Email address's domain name can not be converted to ASCII via punycode: "+Ir}x[ne]=ce.join("@")}return S},serialize:function(f,y){var S=f,x=n(f.to);if(x){for(var L=0,Q=x.length;L<Q;++L){var ae=String(x[L]),oe=ae.lastIndexOf("@"),Ee=ae.slice(0,oe).replace(Kr,Pa).replace(Kr,r).replace(dl,Se),te=ae.slice(oe+1);try{te=y.iri?se.toUnicode(te):se.toASCII(Xe(te,y).toLowerCase())}catch(ne){S.error=S.error||"Email address's domain name can not be converted to "+(y.iri?"Unicode":"ASCII")+" via punycode: "+ne}x[L]=Ee+"@"+te}S.path=x.join(",")}var pe=f.headers=f.headers||{};f.subject&&(pe.subject=f.subject),f.body&&(pe.body=f.body);var be=[];for(var de in pe)pe[de]!==al[de]&&be.push(de.replace(Kr,Pa).replace(Kr,r).replace(Ns,Se)+"="+pe[de].replace(Kr,Pa).replace(Kr,r).replace(fl,Se));return be.length&&(S.query=be.join("&")),S}},pl=/^([^\:]+)\:(.*)/,Ds={scheme:"urn",parse:function(f,y){var S=f.path&&f.path.match(pl),x=f;if(S){var L=y.scheme||x.scheme||"urn",Q=S[1].toLowerCase(),ae=S[2],oe=L+":"+(y.nid||Q),Ee=_e[oe];x.nid=Q,x.nss=ae,x.path=void 0,Ee&&(x=Ee.parse(x,y))}else x.error=x.error||"URN can not be parsed.";return x},serialize:function(f,y){var S=y.scheme||f.scheme||"urn",x=f.nid,L=S+":"+(y.nid||x),Q=_e[L];Q&&(f=Q.serialize(f,y));var ae=f,oe=f.nss;return ae.path=(x||y.nid)+":"+oe,ae}},hl=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Cs={scheme:"urn:uuid",parse:function(f,y){var S=f;return S.uuid=S.nss,S.nss=void 0,!y.tolerant&&(!S.uuid||!S.uuid.match(hl))&&(S.error=S.error||"UUID is not valid."),S},serialize:function(f,y){var S=f;return S.nss=(f.uuid||"").toLowerCase(),S}};_e[pt.scheme]=pt,_e[Ps.scheme]=Ps,_e[ht.scheme]=ht,_e[ws.scheme]=ws,_e[As.scheme]=As,_e[Ds.scheme]=Ds,_e[Cs.scheme]=Cs,a.SCHEMES=_e,a.pctEncChar=Se,a.pctDecChars=Ie,a.parse=ie,a.removeDotSegments=Me,a.serialize=De,a.resolveComponents=Ne,a.resolve=er,a.normalize=Le,a.equal=It,a.escapeComponent=Ta,a.unescapeComponent=Xe,Object.defineProperty(a,"__esModule",{value:!0})})});var Gt=X((Op,gn)=>{"use strict";gn.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 i=n[r];if(!a(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}});var yn=X((wp,_n)=>{"use strict";_n.exports=function(e){for(var t=0,s=e.length,r=0,n;r<s;)t++,n=e.charCodeAt(r++),n>=55296&&n<=56319&&r<s&&(n=e.charCodeAt(r),(n&64512)==56320&&r++);return t}});var Gr=X((Ip,Sn)=>{"use strict";Sn.exports={copy:Lu,checkDataType:Xa,checkDataTypes:ju,coerceToTypes:Fu,toHash:Qa,getProperty:Wa,escapeQuotes:Ka,equal:Gt(),ucs2length:yn(),varOccurences:qu,varReplace:Vu,schemaHasRules:zu,schemaHasRulesExcept:Hu,schemaUnknownRules:Bu,toQuotedString:Ga,getPathExpr:Zu,getPath:Xu,getData:Wu,unescapeFragment:Ku,unescapeJsonPointer:Ya,escapeFragment:Ju,escapeJsonPointer:Ja};function Lu(a,e){e=e||{};for(var t in a)e[t]=a[t];return e}function Xa(a,e,t,s){var r=s?" !== ":" === ",n=s?" || ":" && ",i=s?"!":"",o=s?"":"!";switch(a){case"null":return e+r+"null";case"array":return i+"Array.isArray("+e+")";case"object":return"("+i+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+i+"isFinite("+e+")":"")+")";case"number":return"(typeof "+e+r+'"'+a+'"'+(t?n+i+"isFinite("+e+")":"")+")";default:return"typeof "+e+r+'"'+a+'"'}}function ju(a,e,t){switch(a.length){case 1:return Xa(a[0],e,t,!0);default:var s="",r=Qa(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?" && ":"")+Xa(n,e,t,!0);return s}}var En=Qa(["string","number","integer","boolean","null"]);function Fu(a,e){if(Array.isArray(e)){for(var t=[],s=0;s<e.length;s++){var r=e[s];(En[r]||a==="array"&&r==="array")&&(t[t.length]=r)}if(t.length)return t}else{if(En[e])return[e];if(a==="array"&&e==="array")return["array"]}}function Qa(a){for(var e={},t=0;t<a.length;t++)e[a[t]]=!0;return e}var Mu=/^[a-z$_][a-z$_0-9]*$/i,Uu=/'|\\/g;function Wa(a){return typeof a=="number"?"["+a+"]":Mu.test(a)?"."+a:"['"+Ka(a)+"']"}function Ka(a){return a.replace(Uu,"\\$&").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\f/g,"\\f").replace(/\t/g,"\\t")}function qu(a,e){e+="[^0-9]";var t=a.match(new RegExp(e,"g"));return t?t.length:0}function Vu(a,e,t){return e+="([^0-9])",t=t.replace(/\$/g,"$$$$"),a.replace(new RegExp(e,"g"),t+"$1")}function zu(a,e){if(typeof a=="boolean")return!a;for(var t in a)if(e[t])return!0}function Hu(a,e,t){if(typeof a=="boolean")return!a&&t!="not";for(var s in a)if(s!=t&&e[s])return!0}function Bu(a,e){if(typeof a!="boolean"){for(var t in a)if(!e[t])return t}}function Ga(a){return"'"+Ka(a)+"'"}function Zu(a,e,t,s){var r=t?"'/' + "+e+(s?"":".replace(/~/g, '~0').replace(/\\//g, '~1')"):s?"'[' + "+e+" + ']'":"'[\\'' + "+e+" + '\\']'";return bn(a,r)}function Xu(a,e,t){var s=Ga(t?"/"+Ja(e):Wa(e));return bn(a,s)}var Gu=/^\/(?:[^~]|~0|~1)*$/,Qu=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Wu(a,e,t){var s,r,n,i;if(a==="")return"rootData";if(a[0]=="/"){if(!Gu.test(a))throw new Error("Invalid JSON-pointer: "+a);r=a,n="rootData"}else{if(i=a.match(Qu),!i)throw new Error("Invalid JSON-pointer: "+a);if(s=+i[1],r=i[2],r=="#"){if(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,c=r.split("/"),u=0;u<c.length;u++){var p=c[u];p&&(n+=Wa(Ya(p)),o+=" && "+n)}return o}function bn(a,e){return a=='""'?e:(a+" + "+e).replace(/([^\\])' \+ '/g,"$1")}function Ku(a){return Ya(decodeURIComponent(a))}function Ju(a){return encodeURIComponent(Ja(a))}function Ja(a){return a.replace(/~/g,"~0").replace(/\//g,"~1")}function Ya(a){return a.replace(/~1/g,"/").replace(/~0/g,"~")}});var es=X((Np,xn)=>{"use strict";var Yu=Gr();xn.exports=ed;function ed(a){Yu.copy(a,this)}});var Tn=X((Ap,Rn)=>{"use strict";var xr=Rn.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(){};Qt(e,s,r,a,"",a)};xr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0};xr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};xr.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};xr.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 Qt(a,e,t,s,r,n,i,o,c,u){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,r,n,i,o,c,u);for(var p in s){var m=s[p];if(Array.isArray(m)){if(p in xr.arrayKeywords)for(var E=0;E<m.length;E++)Qt(a,e,t,m[E],r+"/"+p+"/"+E,n,r,p,s,E)}else if(p in xr.propsKeywords){if(m&&typeof m=="object")for(var d in m)Qt(a,e,t,m[d],r+"/"+p+"/"+rd(d),n,r,p,s,d)}else(p in xr.keywords||a.allKeys&&!(p in xr.skipKeywords))&&Qt(a,e,t,m,r+"/"+p,n,r,p,s)}t(s,r,n,i,o,c,u)}}function rd(a){return a.replace(/~/g,"~0").replace(/\//g,"~1")}});var ra=X((Dp,In)=>{"use strict";var Ot=vn(),Pn=Gt(),Yt=Gr(),Wt=es(),td=Tn();In.exports=Tr;Tr.normalizeId=Rr;Tr.fullPath=Kt;Tr.url=Jt;Tr.ids=od;Tr.inlineRef=rs;Tr.schema=ea;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 Wt)return rs(s.schema,this._opts.inlineRefs)?s.schema:s.validate||this._compile(s);var r=ea.call(this,e,t),n,i,o;return r&&(n=r.schema,e=r.root,o=r.baseId),n instanceof Wt?i=n.validate||a.call(this,n.schema,e,void 0,o):n!==void 0&&(i=rs(n,this._opts.inlineRefs)?n:a.call(this,n,e,void 0,o)),i}function ea(a,e){var t=Ot.parse(e),s=wn(t),r=Kt(this._getId(a.schema));if(Object.keys(a.schema).length===0||s!==r){var n=Rr(s),i=this._refs[n];if(typeof i=="string")return ad.call(this,a,i,t);if(i instanceof Wt)i.validate||this._compile(i),a=i;else if(i=this._schemas[n],i instanceof Wt){if(i.validate||this._compile(i),n==Rr(e))return{schema:i,root:a,baseId:r};a=i}else return;if(!a.schema)return;r=Kt(this._getId(a.schema))}return On.call(this,t,r,a.schema,a)}function ad(a,e,t){var s=ea.call(this,a,e);if(s){var r=s.schema,n=s.baseId;a=s.root;var i=this._getId(r);return i&&(n=Jt(n,i)),On.call(this,t,n,r,a)}}var sd=Yt.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function On(a,e,t,s){if(a.fragment=a.fragment||"",a.fragment.slice(0,1)=="/"){for(var r=a.fragment.split("/"),n=1;n<r.length;n++){var i=r[n];if(i){if(i=Yt.unescapeFragment(i),t=t[i],t===void 0)break;var o;if(!sd[i]&&(o=this._getId(t),o&&(e=Jt(e,o)),t.$ref)){var c=Jt(e,t.$ref),u=ea.call(this,s,c);u&&(t=u.schema,s=u.root,e=u.baseId)}}}if(t!==void 0&&t!==s.schema)return{schema:t,root:s,baseId:e}}}var nd=Yt.toHash(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum"]);function rs(a,e){if(e===!1)return!1;if(e===void 0||e===!0)return ts(a);if(e)return as(a)<=e}function ts(a){var e;if(Array.isArray(a)){for(var t=0;t<a.length;t++)if(e=a[t],typeof e=="object"&&!ts(e))return!1}else for(var s in a)if(s=="$ref"||(e=a[s],typeof e=="object"&&!ts(e)))return!1;return!0}function as(a){var e=0,t;if(Array.isArray(a)){for(var s=0;s<a.length;s++)if(t=a[s],typeof t=="object"&&(e+=as(t)),e==1/0)return 1/0}else for(var r in a){if(r=="$ref")return 1/0;if(nd[r])e++;else if(t=a[r],typeof t=="object"&&(e+=as(t)+1),e==1/0)return 1/0}return e}function Kt(a,e){e!==!1&&(a=Rr(a));var t=Ot.parse(a);return wn(t)}function wn(a){return Ot.serialize(a).split("#")[0]+"#"}var id=/#\/?$/;function Rr(a){return a?a.replace(id,""):""}function Jt(a,e){return e=Rr(e),Ot.resolve(a,e)}function od(a){var e=Rr(this._getId(a)),t={"":e},s={"":Kt(e,!1)},r={},n=this;return td(a,{allKeys:!0},function(i,o,c,u,p,m,E){if(o!==""){var d=n._getId(i),g=t[u],_=s[u]+"/"+p;if(E!==void 0&&(_+="/"+(typeof E=="number"?E:Yt.escapeFragment(E))),typeof d=="string"){d=g=Rr(g?Ot.resolve(g,d):d);var v=n._refs[d];if(typeof v=="string"&&(v=n._refs[v]),v&&v.schema){if(!Pn(i,v.schema))throw new Error('id "'+d+'" resolves to more than one schema')}else if(d!=Rr(_))if(d[0]=="#"){if(r[d]&&!Pn(i,r[d]))throw new Error('id "'+d+'" resolves to more than one schema');r[d]=i}else n._refs[d]=_}t[o]=g,s[o]=_}}),r}});var ta=X((Cp,An)=>{"use strict";var ss=ra();An.exports={Validation:Nn(ld),MissingRef:Nn(ns)};function ld(a){this.message="validation failed",this.errors=a,this.ajv=this.validation=!0}ns.message=function(a,e){return"can't resolve reference "+e+" from id "+a};function ns(a,e,t){this.message=t||ns.message(a,e),this.missingRef=ss.url(a,e),this.missingSchema=ss.normalizeId(ss.fullPath(this.missingRef))}function Nn(a){return a.prototype=Object.create(Error.prototype),a.prototype.constructor=a,a}});var is=X(($p,Dn)=>{"use strict";Dn.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(i){return function(o,c){var u={key:o,value:i[o]},p={key:c,value:i[c]};return n(u,p)}}}(e.cmp),r=[];return function n(i){if(i&&i.toJSON&&typeof i.toJSON=="function"&&(i=i.toJSON()),i!==void 0){if(typeof i=="number")return isFinite(i)?""+i:"null";if(typeof i!="object")return JSON.stringify(i);var o,c;if(Array.isArray(i)){for(c="[",o=0;o<i.length;o++)o&&(c+=","),c+=n(i[o])||"null";return c+"]"}if(i===null)return"null";if(r.indexOf(i)!==-1){if(t)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var u=r.push(i)-1,p=Object.keys(i).sort(s&&s(i));for(c="",o=0;o<p.length;o++){var m=p[o],E=n(i[m]);E&&(c&&(c+=","),c+=JSON.stringify(m)+":"+E)}return r.splice(u,1),"{"+c+"}"}}(a)}});var os=X((kp,Cn)=>{"use strict";Cn.exports=function(e,t,s){var r="",n=e.schema.$async===!0,i=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),o=e.self._getId(e.schema);if(e.opts.strictKeywords){var c=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(c){var u="unknown keyword: "+c;if(e.opts.strictKeywords==="log")e.logger.warn(u);else throw new Error(u)}}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"||!(i||e.schema.$ref)){var t="false schema",p=e.level,m=e.dataLevel,E=e.schema[t],d=e.schemaPath+e.util.getProperty(t),g=e.errSchemaPath+"/"+t,N=!e.opts.allErrors,U,_="data"+(m||""),P="valid"+p;if(e.schema===!1){e.isTop?N=!0:r+=" var "+P+" = false; ";var v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(U||"false schema")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(g)+" , 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 b=r;r=v.pop(),!e.compositeRule&&N?e.async?r+=" throw new ValidationError(["+b+"]); ":r+=" validate.errors = ["+b+"]; return false; ":r+=" var err = "+b+"; 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 "+P+" = 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 R="default is ignored in the schema root";if(e.opts.strictDefaults==="log")e.logger.warn(R);else throw new Error(R)}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 P="valid"+p,N=!e.opts.allErrors,A="",z="",U,D=e.schema.type,q=Array.isArray(D);if(D&&e.opts.nullable&&e.schema.nullable===!0&&(q?D.indexOf("null")==-1&&(D=D.concat("null")):D!="null"&&(D=[D,"null"],q=!0)),q&&D.length==1&&(D=D[0],q=!1),e.schema.$ref&&i){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&&(i=!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")),D){if(e.opts.coerceTypes)var M=e.util.coerceToTypes(e.opts.coerceTypes,D);var j=e.RULES.types[D];if(M||q||j===!0||j&&!xe(j)){var d=e.schemaPath+".type",g=e.errSchemaPath+"/type",d=e.schemaPath+".type",g=e.errSchemaPath+"/type",I=q?"checkDataTypes":"checkDataType";if(r+=" if ("+e.util[I](D,_,e.opts.strictNumbers,!0)+") { ",M){var C="dataType"+p,F="coerced"+p;r+=" var "+C+" = typeof "+_+"; var "+F+" = undefined; ",e.opts.coerceTypes=="array"&&(r+=" if ("+C+" == 'object' && Array.isArray("+_+") && "+_+".length == 1) { "+_+" = "+_+"[0]; "+C+" = typeof "+_+"; if ("+e.util.checkDataType(e.schema.type,_,e.opts.strictNumbers)+") "+F+" = "+_+"; } "),r+=" if ("+F+" !== undefined) ; ";var le=M;if(le)for(var J,re=-1,K=le.length-1;re<K;)J=le[re+=1],J=="string"?r+=" else if ("+C+" == 'number' || "+C+" == 'boolean') "+F+" = '' + "+_+"; else if ("+_+" === null) "+F+" = ''; ":J=="number"||J=="integer"?(r+=" else if ("+C+" == 'boolean' || "+_+" === null || ("+C+" == 'string' && "+_+" && "+_+" == +"+_+" ",J=="integer"&&(r+=" && !("+_+" % 1)"),r+=")) "+F+" = +"+_+"; "):J=="boolean"?r+=" else if ("+_+" === 'false' || "+_+" === 0 || "+_+" === null) "+F+" = false; else if ("+_+" === 'true' || "+_+" === 1) "+F+" = true; ":J=="null"?r+=" else if ("+_+" === '' || "+_+" === 0 || "+_+" === false) "+F+" = null; ":e.opts.coerceTypes=="array"&&J=="array"&&(r+=" else if ("+C+" == 'string' || "+C+" == 'number' || "+C+" == 'boolean' || "+_+" == null) "+F+" = ["+_+"]; ");r+=" else { ";var v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(U||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(g)+" , params: { type: '",q?r+=""+D.join(","):r+=""+D,r+="' } ",e.opts.messages!==!1&&(r+=" , message: 'should be ",q?r+=""+D.join(","):r+=""+D,r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+d+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+_+" "),r+=" } "):r+=" {} ";var b=r;r=v.pop(),!e.compositeRule&&N?e.async?r+=" throw new ValidationError(["+b+"]); ":r+=" validate.errors = ["+b+"]; return false; ":r+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } if ("+F+" !== undefined) { ";var H=m?"data"+(m-1||""):"parentData",me=m?e.dataPathArr[m]:"parentDataProperty";r+=" "+_+" = "+F+"; ",m||(r+="if ("+H+" !== undefined)"),r+=" "+H+"["+me+"] = "+F+"; } "}else{var v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(U||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(g)+" , params: { type: '",q?r+=""+D.join(","):r+=""+D,r+="' } ",e.opts.messages!==!1&&(r+=" , message: 'should be ",q?r+=""+D.join(","):r+=""+D,r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+d+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+_+" "),r+=" } "):r+=" {} ";var b=r;r=v.pop(),!e.compositeRule&&N?e.async?r+=" throw new ValidationError(["+b+"]); ":r+=" validate.errors = ["+b+"]; return false; ":r+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}r+=" } "}}if(e.schema.$ref&&!i)r+=" "+e.RULES.all.$ref.code(e,"$ref")+" ",N&&(r+=" } if (errors === ",T?r+="0":r+="errs_"+p,r+=") { ",z+="}");else{var Te=e.RULES;if(Te){for(var j,we=-1,se=Te.length-1;we<se;)if(j=Te[we+=1],xe(j)){if(j.type&&(r+=" if ("+e.util.checkDataType(j.type,_,e.opts.strictNumbers)+") { "),e.opts.useDefaults){if(j.type=="object"&&e.schema.properties){var E=e.schema.properties,_e=Object.keys(E),Se=_e;if(Se)for(var Ie,gr=-1,lr=Se.length-1;gr<lr;){Ie=Se[gr+=1];var ye=E[Ie];if(ye.default!==void 0){var ve=_+e.util.getProperty(Ie);if(e.compositeRule){if(e.opts.strictDefaults){var R="default is ignored for: "+ve;if(e.opts.strictDefaults==="log")e.logger.warn(R);else throw new Error(R)}}else r+=" if ("+ve+" === undefined ",e.opts.useDefaults=="empty"&&(r+=" || "+ve+" === null || "+ve+" === '' "),r+=" ) "+ve+" = ",e.opts.useDefaults=="shared"?r+=" "+e.useDefault(ye.default)+" ":r+=" "+JSON.stringify(ye.default)+" ",r+="; "}}}else if(j.type=="array"&&Array.isArray(e.schema.items)){var Pr=e.schema.items;if(Pr){for(var ye,re=-1,Pe=Pr.length-1;re<Pe;)if(ye=Pr[re+=1],ye.default!==void 0){var ve=_+"["+re+"]";if(e.compositeRule){if(e.opts.strictDefaults){var R="default is ignored for: "+ve;if(e.opts.strictDefaults==="log")e.logger.warn(R);else throw new Error(R)}}else r+=" if ("+ve+" === undefined ",e.opts.useDefaults=="empty"&&(r+=" || "+ve+" === null || "+ve+" === '' "),r+=" ) "+ve+" = ",e.opts.useDefaults=="shared"?r+=" "+e.useDefault(ye.default)+" ":r+=" "+JSON.stringify(ye.default)+" ",r+="; "}}}}var ie=j.rules;if(ie){for(var _r,cr=-1,Or=ie.length-1;cr<Or;)if(_r=ie[cr+=1],Me(_r)){var wr=_r.code(e,_r.keyword,j.type);wr&&(r+=" "+wr+" ",N&&(A+="}"))}}if(N&&(r+=" "+A+" ",A=""),j.type&&(r+=" } ",D&&D===j.type&&!M)){r+=" else { ";var d=e.schemaPath+".type",g=e.errSchemaPath+"/type",v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(U||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(g)+" , params: { type: '",q?r+=""+D.join(","):r+=""+D,r+="' } ",e.opts.messages!==!1&&(r+=" , message: 'should be ",q?r+=""+D.join(","):r+=""+D,r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+d+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+_+" "),r+=" } "):r+=" {} ";var b=r;r=v.pop(),!e.compositeRule&&N?e.async?r+=" throw new ValidationError(["+b+"]); ":r+=" validate.errors = ["+b+"]; return false; ":r+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } "}N&&(r+=" if (errors === ",T?r+="0":r+="errs_"+p,r+=") { ",z+="}")}}}N&&(r+=" "+z+" "),T?(n?(r+=" if (errors === 0) return data; ",r+=" else throw new ValidationError(vErrors); "):(r+=" validate.errors = vErrors; ",r+=" return errors === 0; "),r+=" }; return validate;"):r+=" var "+P+" = errors === errs_"+p+";";function xe(Ne){for(var er=Ne.rules,Le=0;Le<er.length;Le++)if(Me(er[Le]))return!0}function Me(Ne){return e.schema[Ne.keyword]!==void 0||Ne.implements&&De(Ne)}function De(Ne){for(var er=Ne.implements,Le=0;Le<er.length;Le++)if(e.schema[er[Le]]!==void 0)return!0}return r}});var Fn=X((Lp,jn)=>{"use strict";var aa=ra(),na=Gr(),kn=ta(),cd=is(),$n=os(),ud=na.ucs2length,dd=Gt(),fd=kn.Validation;jn.exports=ls;function ls(a,e,t,s){var r=this,n=this._opts,i=[void 0],o={},c=[],u={},p=[],m={},E=[];e=e||{schema:a,refVal:i,refs:o};var d=pd.call(this,a,e,s),g=this._compilations[d.index];if(d.compiling)return g.callValidate=R;var _=this._formats,v=this.RULES;try{var b=P(a,e,t,s);g.validate=b;var T=g.callValidate;return T&&(T.schema=b.schema,T.errors=null,T.refs=b.refs,T.refVal=b.refVal,T.root=b.root,T.$async=b.$async,n.sourceCode&&(T.source=b.source)),b}finally{hd.call(this,a,e,s)}function R(){var I=g.validate,C=I.apply(this,arguments);return R.errors=I.errors,C}function P(I,C,F,le){var J=!C||C&&C.schema==I;if(C.schema!=e.schema)return ls.call(r,I,C,F,le);var re=I.$async===!0,K=$n({isTop:!0,schema:I,isRoot:J,baseId:le,root:C,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:kn.MissingRef,RULES:v,validate:$n,util:na,resolve:aa,resolveRef:N,usePattern:q,useDefault:M,useCustomRule:j,opts:n,formats:_,logger:r.logger,self:r});K=sa(i,gd)+sa(c,md)+sa(p,vd)+sa(E,_d)+K,n.processCode&&(K=n.processCode(K,I));var H;try{var me=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",K);H=me(r,v,_,e,i,p,E,dd,ud,fd),i[0]=H}catch(Te){throw r.logger.error("Error compiling schema, function code:",K),Te}return H.schema=I,H.errors=null,H.refs=o,H.refVal=i,H.root=J?H:C,re&&(H.$async=!0),n.sourceCode===!0&&(H.source={code:K,patterns:c,defaults:p}),H}function N(I,C,F){C=aa.url(I,C);var le=o[C],J,re;if(le!==void 0)return J=i[le],re="refVal["+le+"]",D(J,re);if(!F&&e.refs){var K=e.refs[C];if(K!==void 0)return J=e.refVal[K],re=A(C,J),D(J,re)}re=A(C);var H=aa.call(r,P,e,C);if(H===void 0){var me=t&&t[C];me&&(H=aa.inlineRef(me,n.inlineRefs)?me:ls.call(r,me,e,t,I))}if(H===void 0)z(C);else return U(C,H),D(H,re)}function A(I,C){var F=i.length;return i[F]=C,o[I]=F,"refVal"+F}function z(I){delete o[I]}function U(I,C){var F=o[I];i[F]=C}function D(I,C){return typeof I=="object"||typeof I=="boolean"?{code:C,schema:I,inline:!0}:{code:C,$async:I&&!!I.$async}}function q(I){var C=u[I];return C===void 0&&(C=u[I]=c.length,c[C]=I),"pattern"+C}function M(I){switch(typeof I){case"boolean":case"number":return""+I;case"string":return na.toQuotedString(I);case"object":if(I===null)return"null";var C=cd(I),F=m[C];return F===void 0&&(F=m[C]=p.length,p[F]=I),"default"+F}}function j(I,C,F,le){if(r._opts.validateSchema!==!1){var J=I.definition.dependencies;if(J&&!J.every(function(Se){return Object.prototype.hasOwnProperty.call(F,Se)}))throw new Error("parent schema must have all required keywords: "+J.join(","));var re=I.definition.validateSchema;if(re){var K=re(C);if(!K){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=I.definition.compile,Te=I.definition.inline,we=I.definition.macro,se;if(me)se=me.call(r,C,F,le);else if(we)se=we.call(r,C,F,le),n.validateSchema!==!1&&r.validateSchema(se,!0);else if(Te)se=Te.call(r,le,I.keyword,C,F);else if(se=I.definition.validate,!se)return;if(se===void 0)throw new Error('custom keyword "'+I.keyword+'"failed to compile');var _e=E.length;return E[_e]=se,{code:"customRule"+_e,validate:se}}}function pd(a,e,t){var s=Ln.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 hd(a,e,t){var s=Ln.call(this,a,e,t);s>=0&&this._compilations.splice(s,1)}function Ln(a,e,t){for(var s=0;s<this._compilations.length;s++){var r=this._compilations[s];if(r.schema==a&&r.root==e&&r.baseId==t)return s}return-1}function md(a,e){return"var pattern"+a+" = new RegExp("+na.toQuotedString(e[a])+");"}function vd(a){return"var default"+a+" = defaults["+a+"];"}function gd(a,e){return e[a]===void 0?"":"var refVal"+a+" = refVal["+a+"];"}function _d(a){return"var customRule"+a+" = customRules["+a+"];"}function sa(a,e){if(!a.length)return"";for(var t="",s=0;s<a.length;s++)t+=e(s,a);return t}});var Un=X((jp,Mn)=>{"use strict";var ia=Mn.exports=function(){this._cache={}};ia.prototype.put=function(e,t){this._cache[e]=t};ia.prototype.get=function(e){return this._cache[e]};ia.prototype.del=function(e){delete this._cache[e]};ia.prototype.clear=function(){this._cache={}}});var Jn=X((Fp,Kn)=>{"use strict";var yd=Gr(),Ed=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,bd=[0,31,28,31,30,31,30,31,31,30,31,30,31],Sd=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,qn=/^(?=.{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,xd=/^(?:[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,Rd=/^(?:[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,Vn=/^(?:(?:[^\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,zn=/^(?:(?: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,Hn=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Bn=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Zn=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Xn=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;Kn.exports=oa;function oa(a){return a=a=="full"?"full":"fast",yd.copy(oa[a])}oa.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":Vn,url:zn,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:qn,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:Wn,uuid:Hn,"json-pointer":Bn,"json-pointer-uri-fragment":Zn,"relative-json-pointer":Xn};oa.full={date:Gn,time:Qn,"date-time":Od,uri:Id,"uri-reference":Rd,"uri-template":Vn,url:zn,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:qn,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:Wn,uuid:Hn,"json-pointer":Bn,"json-pointer-uri-fragment":Zn,"relative-json-pointer":Xn};function Td(a){return a%4===0&&(a%100!==0||a%400===0)}function Gn(a){var e=a.match(Ed);if(!e)return!1;var t=+e[1],s=+e[2],r=+e[3];return s>=1&&s<=12&&r>=1&&r<=(s==2&&Td(t)?29:bd[s])}function Qn(a,e){var t=a.match(Sd);if(!t)return!1;var s=t[1],r=t[2],n=t[3],i=t[5];return(s<=23&&r<=59&&n<=59||s==23&&r==59&&n==60)&&(!e||i)}var Pd=/t|\s/i;function Od(a){var e=a.split(Pd);return e.length==2&&Gn(e[0])&&Qn(e[1],!0)}var wd=/\/|:/;function Id(a){return wd.test(a)&&xd.test(a)}var Nd=/[^\\]\\Z/;function Wn(a){if(Nd.test(a))return!1;try{return new RegExp(a),!0}catch{return!1}}});var ei=X((Mp,Yn)=>{"use strict";Yn.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,p="data"+(i||""),m="valid"+n,E,d;if(o=="#"||o=="#/")e.isRoot?(E=e.async,d="validate"):(E=e.root.schema.$async===!0,d="root.refVal[0]");else{var g=e.resolveRef(e.baseId,o,e.isRoot);if(g===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(c)+" , 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 b=r;r=v.pop(),!e.compositeRule&&u?e.async?r+=" throw new ValidationError(["+b+"]); ":r+=" validate.errors = ["+b+"]; return false; ":r+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",u&&(r+=" if (false) { ")}else if(e.opts.missingRefs=="ignore")e.logger.warn(_),u&&(r+=" if (true) { ");else throw new e.MissingRefError(e.baseId,o,_)}else if(g.inline){var T=e.util.copy(e);T.level++;var R="valid"+T.level;T.schema=g.schema,T.schemaPath="",T.errSchemaPath=o;var P=e.validate(T).replace(/validate\.schema/g,g.code);r+=" "+P+" ",u&&(r+=" if ("+R+") { ")}else E=g.$async===!0||e.async&&g.$async!==!1,d=g.code}if(d){var v=v||[];v.push(r),r="",e.opts.passContext?r+=" "+d+".call(this, ":r+=" "+d+"( ",r+=" "+p+", (dataPath || '')",e.errorPath!='""'&&(r+=" + "+e.errorPath);var N=i?"data"+(i-1||""):"parentData",A=i?e.dataPathArr[i]:"parentDataProperty";r+=" , "+N+" , "+A+", rootData) ";var z=r;if(r=v.pop(),E){if(!e.async)throw new Error("async schema referenced by sync schema");u&&(r+=" var "+m+"; "),r+=" try { await "+z+"; ",u&&(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; ",u&&(r+=" "+m+" = false; "),r+=" } ",u&&(r+=" if ("+m+") { ")}else r+=" if (!"+z+") { if (vErrors === null) vErrors = "+d+".errors; else vErrors = vErrors.concat("+d+".errors); errors = vErrors.length; } ",u&&(r+=" else { ")}return r}});var ti=X((Up,ri)=>{"use strict";ri.exports=function(e,t,s){var r=" ",n=e.schema[t],i=e.schemaPath+e.util.getProperty(t),o=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,u=e.util.copy(e),p="";u.level++;var m="valid"+u.level,E=u.baseId,d=!0,g=n;if(g)for(var _,v=-1,b=g.length-1;v<b;)_=g[v+=1],(e.opts.strictKeywords?typeof _=="object"&&Object.keys(_).length>0||_===!1:e.util.schemaHasRules(_,e.RULES.all))&&(d=!1,u.schema=_,u.schemaPath=i+"["+v+"]",u.errSchemaPath=o+"/"+v,r+=" "+e.validate(u)+" ",u.baseId=E,c&&(r+=" if ("+m+") { ",p+="}"));return c&&(d?r+=" if (true) { ":r+=" "+p.slice(0,-1)+" "),r}});var si=X((qp,ai)=>{"use strict";ai.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d="errs__"+n,g=e.util.copy(e),_="";g.level++;var v="valid"+g.level,b=o.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(b){var T=g.baseId;r+=" var "+d+" = errors; var "+E+" = false; ";var R=e.compositeRule;e.compositeRule=g.compositeRule=!0;var P=o;if(P)for(var N,A=-1,z=P.length-1;A<z;)N=P[A+=1],g.schema=N,g.schemaPath=c+"["+A+"]",g.errSchemaPath=u+"/"+A,r+=" "+e.validate(g)+" ",g.baseId=T,r+=" "+E+" = "+E+" || "+v+"; if (!"+E+") { ",_+="}";e.compositeRule=g.compositeRule=R,r+=" "+_+" if (!"+E+") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , 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 = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; } ",e.opts.allErrors&&(r+=" } ")}else p&&(r+=" if (true) { ");return r}});var ii=X((Vp,ni)=>{"use strict";ni.exports=function(e,t,s){var r=" ",n=e.schema[t],i=e.errSchemaPath+"/"+t,o=!e.opts.allErrors,c=e.util.toQuotedString(n);return e.opts.$comment===!0?r+=" console.log("+c+");":typeof e.opts.$comment=="function"&&(r+=" self._opts.$comment("+c+", "+e.util.toQuotedString(i)+", validate.root.schema);"),r}});var li=X((zp,oi)=>{"use strict";oi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d=e.opts.$data&&o&&o.$data,g;d?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",g="schema"+n):g=o,d||(r+=" var schema"+n+" = validate.schema"+c+";"),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(u)+" , params: { allowedValue: schema"+n+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be equal to constant' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , 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 ui=X((Hp,ci)=>{"use strict";ci.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d="errs__"+n,g=e.util.copy(e),_="";g.level++;var v="valid"+g.level,b="i"+n,T=g.dataLevel=e.dataLevel+1,R="data"+T,P=e.baseId,N=e.opts.strictKeywords?typeof o=="object"&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all);if(r+="var "+d+" = errors;var "+E+";",N){var A=e.compositeRule;e.compositeRule=g.compositeRule=!0,g.schema=o,g.schemaPath=c,g.errSchemaPath=u,r+=" var "+v+" = false; for (var "+b+" = 0; "+b+" < "+m+".length; "+b+"++) { ",g.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers,!0);var z=m+"["+b+"]";g.dataPathArr[T]=b;var U=e.validate(g);g.baseId=P,e.util.varOccurences(U,R)<2?r+=" "+e.util.varReplace(U,R,z)+" ":r+=" var "+R+" = "+z+"; "+U+" ",r+=" if ("+v+") break; } ",e.compositeRule=g.compositeRule=A,r+=" "+_+" if (!"+v+") {"}else r+=" if ("+m+".length == 0) {";var D=D||[];D.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should contain a valid item' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var q=r;return r=D.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 { ",N&&(r+=" errors = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; } "),e.opts.allErrors&&(r+=" } "),r}});var fi=X((Bp,di)=>{"use strict";di.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="errs__"+n,d=e.util.copy(e),g="";d.level++;var _="valid"+d.level,v={},b={},T=e.opts.ownProperties;for(A in o)if(A!="__proto__"){var R=o[A],P=Array.isArray(R)?b:v;P[A]=R}r+="var "+E+" = errors;";var N=e.errorPath;r+="var missing"+n+";";for(var A in b)if(P=b[A],P.length){if(r+=" if ( "+m+e.util.getProperty(A)+" !== undefined ",T&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(A)+"') "),p){r+=" && ( ";var z=P;if(z)for(var U,D=-1,q=z.length-1;D<q;){U=z[D+=1],D&&(r+=" || ");var M=e.util.getProperty(U),j=m+M;r+=" ( ( "+j+" === undefined ",T&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(U)+"') "),r+=") && (missing"+n+" = "+e.util.toQuotedString(e.opts.jsonPointers?U:M)+") ) "}r+=")) { ";var I="missing"+n,C="' + "+I+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(N,I,!0):N+" + "+I);var F=F||[];F.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { property: '"+e.util.escapeQuotes(A)+"', missingProperty: '"+C+"', depsCount: "+P.length+", deps: '"+e.util.escapeQuotes(P.length==1?P[0]:P.join(", "))+"' } ",e.opts.messages!==!1&&(r+=" , message: 'should have ",P.length==1?r+="property "+e.util.escapeQuotes(P[0]):r+="properties "+e.util.escapeQuotes(P.join(", ")),r+=" when property "+e.util.escapeQuotes(A)+" is present' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var le=r;r=F.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+le+"]); ":r+=" validate.errors = ["+le+"]; return false; ":r+=" var err = "+le+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{r+=" ) { ";var J=P;if(J)for(var U,re=-1,K=J.length-1;re<K;){U=J[re+=1];var M=e.util.getProperty(U),C=e.util.escapeQuotes(U),j=m+M;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(N,U,e.opts.jsonPointers)),r+=" if ( "+j+" === undefined ",T&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(U)+"') "),r+=") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { property: '"+e.util.escapeQuotes(A)+"', missingProperty: '"+C+"', depsCount: "+P.length+", deps: '"+e.util.escapeQuotes(P.length==1?P[0]:P.join(", "))+"' } ",e.opts.messages!==!1&&(r+=" , message: 'should have ",P.length==1?r+="property "+e.util.escapeQuotes(P[0]):r+="properties "+e.util.escapeQuotes(P.join(", ")),r+=" when property "+e.util.escapeQuotes(A)+" is present' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}r+=" } ",p&&(g+="}",r+=" else { ")}e.errorPath=N;var H=d.baseId;for(var A in v){var R=v[A];(e.opts.strictKeywords?typeof R=="object"&&Object.keys(R).length>0||R===!1:e.util.schemaHasRules(R,e.RULES.all))&&(r+=" "+_+" = true; if ( "+m+e.util.getProperty(A)+" !== undefined ",T&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(A)+"') "),r+=") { ",d.schema=R,d.schemaPath=c+e.util.getProperty(A),d.errSchemaPath=u+"/"+e.util.escapeFragment(A),r+=" "+e.validate(d)+" ",d.baseId=H,r+=" } ",p&&(r+=" if ("+_+") { ",g+="}"))}return p&&(r+=" "+g+" if ("+E+" == errors) {"),r}});var hi=X((Zp,pi)=>{"use strict";pi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d=e.opts.$data&&o&&o.$data,g;d?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",g="schema"+n):g=o;var _="i"+n,v="schema"+n;d||(r+=" var "+v+" = validate.schema"+c+";"),r+="var "+E+";",d&&(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; }",d&&(r+=" } "),r+=" if (!"+E+") { ";var b=b||[];b.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , 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"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var T=r;return r=b.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 vi=X((Xp,mi)=>{"use strict";mi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||"");if(e.opts.format===!1)return p&&(r+=" if (true) { "),r;var E=e.opts.$data&&o&&o.$data,d;E?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",d="schema"+n):d=o;var g=e.opts.unknownFormats,_=Array.isArray(g);if(E){var v="format"+n,b="isObject"+n,T="formatType"+n;r+=" var "+v+" = formats["+d+"]; var "+b+" = typeof "+v+" == 'object' && !("+v+" instanceof RegExp) && "+v+".validate; var "+T+" = "+b+" && "+v+".type || 'string'; if ("+b+") { ",e.async&&(r+=" var async"+n+" = "+v+".async; "),r+=" "+v+" = "+v+".validate; } if ( ",E&&(r+=" ("+d+" !== undefined && typeof "+d+" != 'string') || "),r+=" (",g!="ignore"&&(r+=" ("+d+" && !"+v+" ",_&&(r+=" && self._opts.unknownFormats.indexOf("+d+") == -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(g=="ignore")return e.logger.warn('unknown format "'+o+'" ignored in schema at path "'+e.errSchemaPath+'"'),p&&(r+=" if (true) { "),r;if(_&&g.indexOf(o)>=0)return p&&(r+=" if (true) { "),r;throw new Error('unknown format "'+o+'" is used in schema at path "'+e.errSchemaPath+'"')}var b=typeof v=="object"&&!(v instanceof RegExp)&&v.validate,T=b&&v.type||"string";if(b){var R=v.async===!0;v=v.validate}if(T!=s)return p&&(r+=" if (true) { "),r;if(R){if(!e.async)throw new Error("async format in sync schema");var P="formats"+e.util.getProperty(o)+".validate";r+=" if (!(await "+P+"("+m+"))) { "}else{r+=" if (! ";var P="formats"+e.util.getProperty(o);b&&(P+=".validate"),typeof v=="function"?r+=" "+P+"("+m+") ":r+=" "+P+".test("+m+") ",r+=") { "}}var N=N||[];N.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { format: ",E?r+=""+d:r+=""+e.util.toQuotedString(o),r+=" } ",e.opts.messages!==!1&&(r+=` , message: 'should match format "`,E?r+="' + "+d+" + '":r+=""+e.util.escapeQuotes(o),r+=`"' `),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+c:r+=""+e.util.toQuotedString(o),r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var A=r;return r=N.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+=" } ",p&&(r+=" else { "),r}});var _i=X((Gp,gi)=>{"use strict";gi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d="errs__"+n,g=e.util.copy(e);g.level++;var _="valid"+g.level,v=e.schema.then,b=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)),R=b!==void 0&&(e.opts.strictKeywords?typeof b=="object"&&Object.keys(b).length>0||b===!1:e.util.schemaHasRules(b,e.RULES.all)),P=g.baseId;if(T||R){var N;g.createErrors=!1,g.schema=o,g.schemaPath=c,g.errSchemaPath=u,r+=" var "+d+" = errors; var "+E+" = true; ";var A=e.compositeRule;e.compositeRule=g.compositeRule=!0,r+=" "+e.validate(g)+" ",g.baseId=P,g.createErrors=!0,r+=" errors = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; } ",e.compositeRule=g.compositeRule=A,T?(r+=" if ("+_+") { ",g.schema=e.schema.then,g.schemaPath=e.schemaPath+".then",g.errSchemaPath=e.errSchemaPath+"/then",r+=" "+e.validate(g)+" ",g.baseId=P,r+=" "+E+" = "+_+"; ",T&&R?(N="ifClause"+n,r+=" var "+N+" = 'then'; "):N="'then'",r+=" } ",R&&(r+=" else { ")):r+=" if (!"+_+") { ",R&&(g.schema=e.schema.else,g.schemaPath=e.schemaPath+".else",g.errSchemaPath=e.errSchemaPath+"/else",r+=" "+e.validate(g)+" ",g.baseId=P,r+=" "+E+" = "+_+"; ",T&&R?(N="ifClause"+n,r+=" var "+N+" = 'else'; "):N="'else'",r+=" } "),r+=" if (!"+E+") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { failingKeyword: "+N+" } ",e.opts.messages!==!1&&(r+=` , message: 'should match "' + `+N+` + '" schema' `),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , 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 Ei=X((Qp,yi)=>{"use strict";yi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d="errs__"+n,g=e.util.copy(e),_="";g.level++;var v="valid"+g.level,b="i"+n,T=g.dataLevel=e.dataLevel+1,R="data"+T,P=e.baseId;if(r+="var "+d+" = errors;var "+E+";",Array.isArray(o)){var N=e.schema.additionalItems;if(N===!1){r+=" "+E+" = "+m+".length <= "+o.length+"; ";var A=u;u=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(u)+" , 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 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+=" } ",u=A,p&&(_+="}",r+=" else { ")}var D=o;if(D){for(var q,M=-1,j=D.length-1;M<j;)if(q=D[M+=1],e.opts.strictKeywords?typeof q=="object"&&Object.keys(q).length>0||q===!1:e.util.schemaHasRules(q,e.RULES.all)){r+=" "+v+" = true; if ("+m+".length > "+M+") { ";var I=m+"["+M+"]";g.schema=q,g.schemaPath=c+"["+M+"]",g.errSchemaPath=u+"/"+M,g.errorPath=e.util.getPathExpr(e.errorPath,M,e.opts.jsonPointers,!0),g.dataPathArr[T]=M;var C=e.validate(g);g.baseId=P,e.util.varOccurences(C,R)<2?r+=" "+e.util.varReplace(C,R,I)+" ":r+=" var "+R+" = "+I+"; "+C+" ",r+=" } ",p&&(r+=" if ("+v+") { ",_+="}")}}if(typeof N=="object"&&(e.opts.strictKeywords?typeof N=="object"&&Object.keys(N).length>0||N===!1:e.util.schemaHasRules(N,e.RULES.all))){g.schema=N,g.schemaPath=e.schemaPath+".additionalItems",g.errSchemaPath=e.errSchemaPath+"/additionalItems",r+=" "+v+" = true; if ("+m+".length > "+o.length+") { for (var "+b+" = "+o.length+"; "+b+" < "+m+".length; "+b+"++) { ",g.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers,!0);var I=m+"["+b+"]";g.dataPathArr[T]=b;var C=e.validate(g);g.baseId=P,e.util.varOccurences(C,R)<2?r+=" "+e.util.varReplace(C,R,I)+" ":r+=" var "+R+" = "+I+"; "+C+" ",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)){g.schema=o,g.schemaPath=c,g.errSchemaPath=u,r+=" for (var "+b+" = 0; "+b+" < "+m+".length; "+b+"++) { ",g.errorPath=e.util.getPathExpr(e.errorPath,b,e.opts.jsonPointers,!0);var I=m+"["+b+"]";g.dataPathArr[T]=b;var C=e.validate(g);g.baseId=P,e.util.varOccurences(C,R)<2?r+=" "+e.util.varReplace(C,R,I)+" ":r+=" var "+R+" = "+I+"; "+C+" ",p&&(r+=" if (!"+v+") break; "),r+=" }"}return p&&(r+=" "+_+" if ("+d+" == errors) {"),r}});var cs=X((Wp,bi)=>{"use strict";bi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,P,m="data"+(i||""),E=e.opts.$data&&o&&o.$data,d;E?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",d="schema"+n):d=o;var g=t=="maximum",_=g?"exclusiveMaximum":"exclusiveMinimum",v=e.schema[_],b=e.opts.$data&&v&&v.$data,T=g?"<":">",R=g?">":"<",P=void 0;if(!(E||typeof o=="number"||o===void 0))throw new Error(t+" must be number");if(!(b||v===void 0||typeof v=="number"||typeof v=="boolean"))throw new Error(_+" must be number or boolean");if(b){var N=e.util.getData(v.$data,i,e.dataPathArr),A="exclusive"+n,z="exclType"+n,U="exclIsNumber"+n,D="op"+n,q="' + "+D+" + '";r+=" var schemaExcl"+n+" = "+N+"; ",N="schemaExcl"+n,r+=" var "+A+"; var "+z+" = typeof "+N+"; if ("+z+" != 'boolean' && "+z+" != 'undefined' && "+z+" != 'number') { ";var P=_,M=M||[];M.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(P||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: '"+_+" should be boolean' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var j=r;r=M.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+j+"]); ":r+=" validate.errors = ["+j+"]; return false; ":r+=" var err = "+j+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } else if ( ",E&&(r+=" ("+d+" !== undefined && typeof "+d+" != 'number') || "),r+=" "+z+" == 'number' ? ( ("+A+" = "+d+" === undefined || "+N+" "+T+"= "+d+") ? "+m+" "+R+"= "+N+" : "+m+" "+R+" "+d+" ) : ( ("+A+" = "+N+" === true) ? "+m+" "+R+"= "+d+" : "+m+" "+R+" "+d+" ) || "+m+" !== "+m+") { var op"+n+" = "+A+" ? '"+T+"' : '"+T+"='; ",o===void 0&&(P=_,u=e.errSchemaPath+"/"+_,d=N,E=b)}else{var U=typeof v=="number",q=T;if(U&&E){var D="'"+q+"'";r+=" if ( ",E&&(r+=" ("+d+" !== undefined && typeof "+d+" != 'number') || "),r+=" ( "+d+" === undefined || "+v+" "+T+"= "+d+" ? "+m+" "+R+"= "+v+" : "+m+" "+R+" "+d+" ) || "+m+" !== "+m+") { "}else{U&&o===void 0?(A=!0,P=_,u=e.errSchemaPath+"/"+_,d=v,R+="="):(U&&(d=Math[g?"min":"max"](v,o)),v===(U?d:!0)?(A=!0,P=_,u=e.errSchemaPath+"/"+_,R+="="):(A=!1,q+="="));var D="'"+q+"'";r+=" if ( ",E&&(r+=" ("+d+" !== undefined && typeof "+d+" != 'number') || "),r+=" "+m+" "+R+" "+d+" || "+m+" !== "+m+") { "}}P=P||t;var M=M||[];M.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(P||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { comparison: "+D+", limit: "+d+", exclusive: "+A+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be "+q+" ",E?r+="' + "+d:r+=""+d+"'"),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+c:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var j=r;return r=M.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+j+"]); ":r+=" validate.errors = ["+j+"]; return false; ":r+=" var err = "+j+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",p&&(r+=" else { "),r}});var us=X((Kp,Si)=>{"use strict";Si.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(i||""),E=e.opts.$data&&o&&o.$data,d;if(E?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",d="schema"+n):d=o,!(E||typeof o=="number"))throw new Error(t+" must be number");var g=t=="maxItems"?">":"<";r+="if ( ",E&&(r+=" ("+d+" !== undefined && typeof "+d+" != 'number') || "),r+=" "+m+".length "+g+" "+d+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+d+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have ",t=="maxItems"?r+="more":r+="fewer",r+=" than ",E?r+="' + "+d+" + '":r+=""+o,r+=" items' "),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+c:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var b=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+b+"]); ":r+=" validate.errors = ["+b+"]; return false; ":r+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var ds=X((Jp,xi)=>{"use strict";xi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(i||""),E=e.opts.$data&&o&&o.$data,d;if(E?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",d="schema"+n):d=o,!(E||typeof o=="number"))throw new Error(t+" must be number");var g=t=="maxLength"?">":"<";r+="if ( ",E&&(r+=" ("+d+" !== undefined && typeof "+d+" != 'number') || "),e.opts.unicode===!1?r+=" "+m+".length ":r+=" ucs2length("+m+") ",r+=" "+g+" "+d+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+d+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be ",t=="maxLength"?r+="longer":r+="shorter",r+=" than ",E?r+="' + "+d+" + '":r+=""+o,r+=" characters' "),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+c:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var b=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+b+"]); ":r+=" validate.errors = ["+b+"]; return false; ":r+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var fs=X((Yp,Ri)=>{"use strict";Ri.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,_,m="data"+(i||""),E=e.opts.$data&&o&&o.$data,d;if(E?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",d="schema"+n):d=o,!(E||typeof o=="number"))throw new Error(t+" must be number");var g=t=="maxProperties"?">":"<";r+="if ( ",E&&(r+=" ("+d+" !== undefined && typeof "+d+" != 'number') || "),r+=" Object.keys("+m+").length "+g+" "+d+") { ";var _=t,v=v||[];v.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(_||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+d+" } ",e.opts.messages!==!1&&(r+=" , message: 'should NOT have ",t=="maxProperties"?r+="more":r+="fewer",r+=" than ",E?r+="' + "+d+" + '":r+=""+o,r+=" properties' "),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+c:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var b=r;return r=v.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+b+"]); ":r+=" validate.errors = ["+b+"]; return false; ":r+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+="} ",p&&(r+=" else { "),r}});var Pi=X((eh,Ti)=>{"use strict";Ti.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E=e.opts.$data&&o&&o.$data,d;if(E?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",d="schema"+n):d=o,!(E||typeof o=="number"))throw new Error(t+" must be number");r+="var division"+n+";if (",E&&(r+=" "+d+" !== undefined && ( typeof "+d+" != 'number' || "),r+=" (division"+n+" = "+m+" / "+d+", ",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 g=g||[];g.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { multipleOf: "+d+" } ",e.opts.messages!==!1&&(r+=" , message: 'should be multiple of ",E?r+="' + "+d:r+=""+d+"'"),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+c:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var _=r;return r=g.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 wi=X((rh,Oi)=>{"use strict";Oi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="errs__"+n,d=e.util.copy(e);d.level++;var g="valid"+d.level;if(e.opts.strictKeywords?typeof o=="object"&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all)){d.schema=o,d.schemaPath=c,d.errSchemaPath=u,r+=" var "+E+" = errors; ";var _=e.compositeRule;e.compositeRule=d.compositeRule=!0,d.createErrors=!1;var v;d.opts.allErrors&&(v=d.opts.allErrors,d.opts.allErrors=!1),r+=" "+e.validate(d)+" ",d.createErrors=!0,v&&(d.opts.allErrors=v),e.compositeRule=d.compositeRule=_,r+=" if ("+g+") { ";var b=b||[];b.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be valid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var T=r;r=b.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 = "+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(u)+" , params: {} ",e.opts.messages!==!1&&(r+=" , message: 'should NOT be valid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , 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 Ni=X((th,Ii)=>{"use strict";Ii.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d="errs__"+n,g=e.util.copy(e),_="";g.level++;var v="valid"+g.level,b=g.baseId,T="prevValid"+n,R="passingSchemas"+n;r+="var "+d+" = errors , "+T+" = false , "+E+" = false , "+R+" = null; ";var P=e.compositeRule;e.compositeRule=g.compositeRule=!0;var N=o;if(N)for(var A,z=-1,U=N.length-1;z<U;)A=N[z+=1],(e.opts.strictKeywords?typeof A=="object"&&Object.keys(A).length>0||A===!1:e.util.schemaHasRules(A,e.RULES.all))?(g.schema=A,g.schemaPath=c+"["+z+"]",g.errSchemaPath=u+"/"+z,r+=" "+e.validate(g)+" ",g.baseId=b):r+=" var "+v+" = true; ",z&&(r+=" if ("+v+" && "+T+") { "+E+" = false; "+R+" = ["+R+", "+z+"]; } else { ",_+="}"),r+=" if ("+v+") { "+E+" = "+T+" = true; "+R+" = "+z+"; }";return e.compositeRule=g.compositeRule=P,r+=""+_+"if (!"+E+") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { passingSchemas: "+R+" } ",e.opts.messages!==!1&&(r+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , 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 = "+d+"; if (vErrors !== null) { if ("+d+") vErrors.length = "+d+"; else vErrors = null; }",e.opts.allErrors&&(r+=" } "),r}});var Di=X((ah,Ai)=>{"use strict";Ai.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E=e.opts.$data&&o&&o.$data,d;E?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",d="schema"+n):d=o;var g=E?"(new RegExp("+d+"))":e.usePattern(o);r+="if ( ",E&&(r+=" ("+d+" !== undefined && typeof "+d+" != 'string') || "),r+=" !"+g+".test("+m+") ) { ";var _=_||[];_.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { pattern: ",E?r+=""+d:r+=""+e.util.toQuotedString(o),r+=" } ",e.opts.messages!==!1&&(r+=` , message: 'should match pattern "`,E?r+="' + "+d+" + '":r+=""+e.util.escapeQuotes(o),r+=`"' `),e.opts.verbose&&(r+=" , schema: ",E?r+="validate.schema"+c: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 $i=X((sh,Ci)=>{"use strict";Ci.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="errs__"+n,d=e.util.copy(e),g="";d.level++;var _="valid"+d.level,v="key"+n,b="idx"+n,T=d.dataLevel=e.dataLevel+1,R="data"+T,P="dataProperties"+n,N=Object.keys(o||{}).filter(re),A=e.schema.patternProperties||{},z=Object.keys(A).filter(re),U=e.schema.additionalProperties,D=N.length||z.length,q=U===!1,M=typeof U=="object"&&Object.keys(U).length,j=e.opts.removeAdditional,I=q||M||j,C=e.opts.ownProperties,F=e.baseId,le=e.schema.required;if(le&&!(e.opts.$data&&le.$data)&&le.length<e.opts.loopRequired)var J=e.util.toHash(le);function re(Xe){return Xe!=="__proto__"}if(r+="var "+E+" = errors;var "+_+" = true;",C&&(r+=" var "+P+" = undefined;"),I){if(C?r+=" "+P+" = "+P+" || Object.keys("+m+"); for (var "+b+"=0; "+b+"<"+P+".length; "+b+"++) { var "+v+" = "+P+"["+b+"]; ":r+=" for (var "+v+" in "+m+") { ",D){if(r+=" var isAdditional"+n+" = !(false ",N.length)if(N.length>8)r+=" || validate.schema"+c+".hasOwnProperty("+v+") ";else{var K=N;if(K)for(var H,me=-1,Te=K.length-1;me<Te;)H=K[me+=1],r+=" || "+v+" == "+e.util.toQuotedString(H)+" "}if(z.length){var we=z;if(we)for(var se,_e=-1,Se=we.length-1;_e<Se;)se=we[_e+=1],r+=" || "+e.usePattern(se)+".test("+v+") "}r+=" ); if (isAdditional"+n+") { "}if(j=="all")r+=" delete "+m+"["+v+"]; ";else{var Ie=e.errorPath,gr="' + "+v+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers)),q)if(j)r+=" delete "+m+"["+v+"]; ";else{r+=" "+_+" = false; ";var lr=u;u=e.errSchemaPath+"/additionalProperties";var ye=ye||[];ye.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { additionalProperty: '"+gr+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is an invalid additional property":r+="should NOT have additional properties",r+="' "),e.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var ve=r;r=ye.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++; ",u=lr,p&&(r+=" break; ")}else if(M)if(j=="failing"){r+=" var "+E+" = errors; ";var Pr=e.compositeRule;e.compositeRule=d.compositeRule=!0,d.schema=U,d.schemaPath=e.schemaPath+".additionalProperties",d.errSchemaPath=e.errSchemaPath+"/additionalProperties",d.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers);var Pe=m+"["+v+"]";d.dataPathArr[T]=v;var ie=e.validate(d);d.baseId=F,e.util.varOccurences(ie,R)<2?r+=" "+e.util.varReplace(ie,R,Pe)+" ":r+=" var "+R+" = "+Pe+"; "+ie+" ",r+=" if (!"+_+") { errors = "+E+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+m+"["+v+"]; } ",e.compositeRule=d.compositeRule=Pr}else{d.schema=U,d.schemaPath=e.schemaPath+".additionalProperties",d.errSchemaPath=e.errSchemaPath+"/additionalProperties",d.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers);var Pe=m+"["+v+"]";d.dataPathArr[T]=v;var ie=e.validate(d);d.baseId=F,e.util.varOccurences(ie,R)<2?r+=" "+e.util.varReplace(ie,R,Pe)+" ":r+=" var "+R+" = "+Pe+"; "+ie+" ",p&&(r+=" if (!"+_+") break; ")}e.errorPath=Ie}D&&(r+=" } "),r+=" } ",p&&(r+=" if ("+_+") { ",g+="}")}var _r=e.opts.useDefaults&&!e.compositeRule;if(N.length){var cr=N;if(cr)for(var H,Or=-1,wr=cr.length-1;Or<wr;){H=cr[Or+=1];var xe=o[H];if(e.opts.strictKeywords?typeof xe=="object"&&Object.keys(xe).length>0||xe===!1:e.util.schemaHasRules(xe,e.RULES.all)){var Me=e.util.getProperty(H),Pe=m+Me,De=_r&&xe.default!==void 0;d.schema=xe,d.schemaPath=c+Me,d.errSchemaPath=u+"/"+e.util.escapeFragment(H),d.errorPath=e.util.getPath(e.errorPath,H,e.opts.jsonPointers),d.dataPathArr[T]=e.util.toQuotedString(H);var ie=e.validate(d);if(d.baseId=F,e.util.varOccurences(ie,R)<2){ie=e.util.varReplace(ie,R,Pe);var Ne=Pe}else{var Ne=R;r+=" var "+R+" = "+Pe+"; "}if(De)r+=" "+ie+" ";else{if(J&&J[H]){r+=" if ( "+Ne+" === undefined ",C&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=") { "+_+" = false; ";var Ie=e.errorPath,lr=u,er=e.util.escapeQuotes(H);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(Ie,H,e.opts.jsonPointers)),u=e.errSchemaPath+"/required";var ye=ye||[];ye.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+er+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+er+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var ve=r;r=ye.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++; ",u=lr,e.errorPath=Ie,r+=" } else { "}else p?(r+=" if ( "+Ne+" === undefined ",C&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=") { "+_+" = true; } else { "):(r+=" if ("+Ne+" !== undefined ",C&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(H)+"') "),r+=" ) { ");r+=" "+ie+" } "}}p&&(r+=" if ("+_+") { ",g+="}")}}if(z.length){var Le=z;if(Le)for(var se,It=-1,Ta=Le.length-1;It<Ta;){se=Le[It+=1];var xe=A[se];if(e.opts.strictKeywords?typeof xe=="object"&&Object.keys(xe).length>0||xe===!1:e.util.schemaHasRules(xe,e.RULES.all)){d.schema=xe,d.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(se),d.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(se),C?r+=" "+P+" = "+P+" || Object.keys("+m+"); for (var "+b+"=0; "+b+"<"+P+".length; "+b+"++) { var "+v+" = "+P+"["+b+"]; ":r+=" for (var "+v+" in "+m+") { ",r+=" if ("+e.usePattern(se)+".test("+v+")) { ",d.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers);var Pe=m+"["+v+"]";d.dataPathArr[T]=v;var ie=e.validate(d);d.baseId=F,e.util.varOccurences(ie,R)<2?r+=" "+e.util.varReplace(ie,R,Pe)+" ":r+=" var "+R+" = "+Pe+"; "+ie+" ",p&&(r+=" if (!"+_+") break; "),r+=" } ",p&&(r+=" else "+_+" = true; "),r+=" } ",p&&(r+=" if ("+_+") { ",g+="}")}}}return p&&(r+=" "+g+" if ("+E+" == errors) {"),r}});var Li=X((nh,ki)=>{"use strict";ki.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="errs__"+n,d=e.util.copy(e),g="";d.level++;var _="valid"+d.level;if(r+="var "+E+" = errors;",e.opts.strictKeywords?typeof o=="object"&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all)){d.schema=o,d.schemaPath=c,d.errSchemaPath=u;var v="key"+n,b="idx"+n,T="i"+n,R="' + "+v+" + '",P=d.dataLevel=e.dataLevel+1,N="data"+P,A="dataProperties"+n,z=e.opts.ownProperties,U=e.baseId;z&&(r+=" var "+A+" = undefined; "),z?r+=" "+A+" = "+A+" || Object.keys("+m+"); for (var "+b+"=0; "+b+"<"+A+".length; "+b+"++) { var "+v+" = "+A+"["+b+"]; ":r+=" for (var "+v+" in "+m+") { ",r+=" var startErrs"+n+" = errors; ";var D=v,q=e.compositeRule;e.compositeRule=d.compositeRule=!0;var M=e.validate(d);d.baseId=U,e.util.varOccurences(M,N)<2?r+=" "+e.util.varReplace(M,N,D)+" ":r+=" var "+N+" = "+D+"; "+M+" ",e.compositeRule=d.compositeRule=q,r+=" if (!"+_+") { for (var "+T+"=startErrs"+n+"; "+T+"<errors; "+T+"++) { vErrors["+T+"].propertyName = "+v+"; } var err = ",e.createErrors!==!1?(r+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { propertyName: '"+R+"' } ",e.opts.messages!==!1&&(r+=" , message: 'property name \\'"+R+"\\' is invalid' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , 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; "),p&&(r+=" break; "),r+=" } }"}return p&&(r+=" "+g+" if ("+E+" == errors) {"),r}});var Fi=X((ih,ji)=>{"use strict";ji.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d=e.opts.$data&&o&&o.$data,g;d?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",g="schema"+n):g=o;var _="schema"+n;if(!d)if(o.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var v=[],b=o;if(b)for(var T,R=-1,P=b.length-1;R<P;){T=b[R+=1];var N=e.schema.properties[T];N&&(e.opts.strictKeywords?typeof N=="object"&&Object.keys(N).length>0||N===!1:e.util.schemaHasRules(N,e.RULES.all))||(v[v.length]=T)}}else var v=o;if(d||v.length){var A=e.errorPath,z=d||v.length>=e.opts.loopRequired,U=e.opts.ownProperties;if(p)if(r+=" var missing"+n+"; ",z){d||(r+=" var "+_+" = validate.schema"+c+"; ");var D="i"+n,q="schema"+n+"["+D+"]",M="' + "+q+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(A,q,e.opts.jsonPointers)),r+=" var "+E+" = true; ",d&&(r+=" if (schema"+n+" === undefined) "+E+" = true; else if (!Array.isArray(schema"+n+")) "+E+" = false; else {"),r+=" for (var "+D+" = 0; "+D+" < "+_+".length; "+D+"++) { "+E+" = "+m+"["+_+"["+D+"]] !== undefined ",U&&(r+=" && Object.prototype.hasOwnProperty.call("+m+", "+_+"["+D+"]) "),r+="; if (!"+E+") break; } ",d&&(r+=" } "),r+=" if (!"+E+") { ";var j=j||[];j.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+M+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+M+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var I=r;r=j.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+=" } else { "}else{r+=" if ( ";var C=v;if(C)for(var F,D=-1,le=C.length-1;D<le;){F=C[D+=1],D&&(r+=" || ");var J=e.util.getProperty(F),re=m+J;r+=" ( ( "+re+" === undefined ",U&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(F)+"') "),r+=") && (missing"+n+" = "+e.util.toQuotedString(e.opts.jsonPointers?F:J)+") ) "}r+=") { ";var q="missing"+n,M="' + "+q+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(A,q,!0):A+" + "+q);var j=j||[];j.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+M+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+M+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var I=r;r=j.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+=" } else { "}else if(z){d||(r+=" var "+_+" = validate.schema"+c+"; ");var D="i"+n,q="schema"+n+"["+D+"]",M="' + "+q+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(A,q,e.opts.jsonPointers)),d&&(r+=" if ("+_+" && !Array.isArray("+_+")) { var err = ",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+M+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+M+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+_+" !== undefined) { "),r+=" for (var "+D+" = 0; "+D+" < "+_+".length; "+D+"++) { if ("+m+"["+_+"["+D+"]] === undefined ",U&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", "+_+"["+D+"]) "),r+=") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+M+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+M+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",d&&(r+=" } ")}else{var K=v;if(K)for(var F,H=-1,me=K.length-1;H<me;){F=K[H+=1];var J=e.util.getProperty(F),M=e.util.escapeQuotes(F),re=m+J;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(A,F,e.opts.jsonPointers)),r+=" if ( "+re+" === undefined ",U&&(r+=" || ! Object.prototype.hasOwnProperty.call("+m+", '"+e.util.escapeQuotes(F)+"') "),r+=") { var err = ",e.createErrors!==!1?(r+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+M+"' } ",e.opts.messages!==!1&&(r+=" , message: '",e.opts._errorDataPathProperty?r+="is a required property":r+="should have required property \\'"+M+"\\'",r+="' "),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ",r+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=A}else p&&(r+=" if (true) {");return r}});var Ui=X((oh,Mi)=>{"use strict";Mi.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m="data"+(i||""),E="valid"+n,d=e.opts.$data&&o&&o.$data,g;if(d?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",g="schema"+n):g=o,(o||d)&&e.opts.uniqueItems!==!1){d&&(r+=" var "+E+"; if ("+g+" === false || "+g+" === undefined) "+E+" = true; else if (typeof "+g+" != '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 b="checkDataType"+(v?"s":"");r+=" if ("+e.util[b](_,"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+=" } ",d&&(r+=" } "),r+=" if (!"+E+") { ";var T=T||[];T.push(r),r="",e.createErrors!==!1?(r+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , 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: ",d?r+="validate.schema"+c:r+=""+o,r+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+m+" "),r+=" } "):r+=" {} ";var R=r;r=T.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+R+"]); ":r+=" validate.errors = ["+R+"]; return false; ":r+=" var err = "+R+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",r+=" } ",p&&(r+=" else { ")}else p&&(r+=" if (true) { ");return r}});var Vi=X((lh,qi)=>{"use strict";qi.exports={$ref:ei(),allOf:ti(),anyOf:si(),$comment:ii(),const:li(),contains:ui(),dependencies:fi(),enum:hi(),format:vi(),if:_i(),items:Ei(),maximum:cs(),minimum:cs(),maxItems:us(),minItems:us(),maxLength:ds(),minLength:ds(),maxProperties:fs(),minProperties:fs(),multipleOf:Pi(),not:wi(),oneOf:Ni(),pattern:Di(),properties:$i(),propertyNames:Li(),required:Fi(),uniqueItems:Ui(),validate:os()}});var Bi=X((ch,Hi)=>{"use strict";var zi=Vi(),ps=Gr().toHash;Hi.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=ps(t),e.types=ps(r),e.forEach(function(n){n.rules=n.rules.map(function(i){var o;if(typeof i=="object"){var c=Object.keys(i)[0];o=i[c],i=c,o.forEach(function(p){t.push(p),e.all[p]=!0})}t.push(i);var u=e.all[i]={keyword:i,code:zi[i],implements:o};return u}),e.all.$comment={keyword:"$comment",code:zi.$comment},n.type&&(e.types[n.type]=n)}),e.keywords=ps(t.concat(s)),e.custom={},e}});var Gi=X((uh,Xi)=>{"use strict";var Zi=["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<e.length;t++){a=JSON.parse(JSON.stringify(a));var s=e[t].split("/"),r=a,n;for(n=1;n<s.length;n++)r=r[s[n]];for(n=0;n<Zi.length;n++){var i=Zi[n],o=r[i];o&&(r[i]={anyOf:[o,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return a}});var Ki=X((dh,Wi)=>{"use strict";var Ad=ta().MissingRef;Wi.exports=Qi;function Qi(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||i(o)});return t&&r.then(function(o){t(null,o)},t),r;function n(o){var c=o.$schema;return c&&!s.getSchema(c)?Qi.call(s,{$ref:c},!0):Promise.resolve()}function i(o){try{return s._compile(o)}catch(u){if(u instanceof Ad)return c(u);throw u}function c(u){var p=u.missingSchema;if(d(p))throw new Error("Schema "+p+" is loaded but "+u.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(g){if(!d(p))return n(g).then(function(){d(p)||s.addSchema(g,p,void 0,e)})}).then(function(){return i(o)});function E(){delete s._loadingSchemas[p]}function d(g){return s._refs[g]||s._schemas[g]}}}}});var Yi=X((fh,Ji)=>{"use strict";Ji.exports=function(e,t,s){var r=" ",n=e.level,i=e.dataLevel,o=e.schema[t],c=e.schemaPath+e.util.getProperty(t),u=e.errSchemaPath+"/"+t,p=!e.opts.allErrors,m,E="data"+(i||""),d="valid"+n,g="errs__"+n,_=e.opts.$data&&o&&o.$data,v;_?(r+=" var schema"+n+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",v="schema"+n):v=o;var b=this,T="definition"+n,R=b.definition,P="",N,A,z,U,D;if(_&&R.$data){D="keywordValidate"+n;var q=R.validateSchema;r+=" var "+T+" = RULES.custom['"+t+"'].definition; var "+D+" = "+T+".validate;"}else{if(U=e.useCustomRule(b,o,e.schema,e),!U)return;v="validate.schema"+c,D=U.code,N=R.compile,A=R.inline,z=R.macro}var M=D+".errors",j="i"+n,I="ruleErr"+n,C=R.async;if(C&&!e.async)throw new Error("async keyword in sync schema");if(A||z||(r+=""+M+" = null;"),r+="var "+g+" = errors;var "+d+";",_&&R.$data&&(P+="}",r+=" if ("+v+" === undefined) { "+d+" = true; } else { ",q&&(P+="}",r+=" "+d+" = "+T+".validateSchema("+v+"); if ("+d+") { ")),A)R.statements?r+=" "+U.validate+" ":r+=" "+d+" = "+U.validate+"; ";else if(z){var F=e.util.copy(e),P="";F.level++;var le="valid"+F.level;F.schema=U.validate,F.schemaPath="";var J=e.compositeRule;e.compositeRule=F.compositeRule=!0;var re=e.validate(F).replace(/validate\.schema/g,D);e.compositeRule=F.compositeRule=J,r+=" "+re}else{var K=K||[];K.push(r),r="",r+=" "+D+".call( ",e.opts.passContext?r+="this":r+="self",N||R.schema===!1?r+=" , "+E+" ":r+=" , "+v+" , "+E+" , validate.schema"+e.schemaPath+" ",r+=" , (dataPath || '')",e.errorPath!='""'&&(r+=" + "+e.errorPath);var H=i?"data"+(i-1||""):"parentData",me=i?e.dataPathArr[i]:"parentDataProperty";r+=" , "+H+" , "+me+" , rootData ) ";var Te=r;r=K.pop(),R.errors===!1?(r+=" "+d+" = ",C&&(r+="await "),r+=""+Te+"; "):C?(M="customErrors"+n,r+=" var "+M+" = null; try { "+d+" = await "+Te+"; } catch (e) { "+d+" = false; if (e instanceof ValidationError) "+M+" = e.errors; else throw e; } "):r+=" "+M+" = null; "+d+" = "+Te+"; "}if(R.modifying&&(r+=" if ("+H+") "+E+" = "+H+"["+me+"];"),r+=""+P,R.valid)p&&(r+=" if (true) { ");else{r+=" if ( ",R.valid===void 0?(r+=" !",z?r+=""+le:r+=""+d):r+=" "+!R.valid+" ",r+=") { ",m=b.keyword;var K=K||[];K.push(r),r="";var K=K||[];K.push(r),r="",e.createErrors!==!1?(r+=" { keyword: '"+(m||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { keyword: '"+b.keyword+"' } ",e.opts.messages!==!1&&(r+=` , message: 'should pass "`+b.keyword+`" keyword validation' `),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+E+" "),r+=" } "):r+=" {} ";var we=r;r=K.pop(),!e.compositeRule&&p?e.async?r+=" throw new ValidationError(["+we+"]); ":r+=" validate.errors = ["+we+"]; return false; ":r+=" var err = "+we+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var se=r;r=K.pop(),A?R.errors?R.errors!="full"&&(r+=" for (var "+j+"="+g+"; "+j+"<errors; "+j+"++) { var "+I+" = vErrors["+j+"]; if ("+I+".dataPath === undefined) "+I+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+I+".schemaPath === undefined) { "+I+'.schemaPath = "'+u+'"; } ',e.opts.verbose&&(r+=" "+I+".schema = "+v+"; "+I+".data = "+E+"; "),r+=" } "):R.errors===!1?r+=" "+se+" ":(r+=" if ("+g+" == errors) { "+se+" } else { for (var "+j+"="+g+"; "+j+"<errors; "+j+"++) { var "+I+" = vErrors["+j+"]; if ("+I+".dataPath === undefined) "+I+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+I+".schemaPath === undefined) { "+I+'.schemaPath = "'+u+'"; } ',e.opts.verbose&&(r+=" "+I+".schema = "+v+"; "+I+".data = "+E+"; "),r+=" } } "):z?(r+=" var err = ",e.createErrors!==!1?(r+=" { keyword: '"+(m||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { keyword: '"+b.keyword+"' } ",e.opts.messages!==!1&&(r+=` , message: 'should pass "`+b.keyword+`" keyword validation' `),e.opts.verbose&&(r+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+E+" "),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.errors===!1?r+=" "+se+" ":(r+=" if (Array.isArray("+M+")) { if (vErrors === null) vErrors = "+M+"; else vErrors = vErrors.concat("+M+"); errors = vErrors.length; for (var "+j+"="+g+"; "+j+"<errors; "+j+"++) { var "+I+" = vErrors["+j+"]; if ("+I+".dataPath === undefined) "+I+".dataPath = (dataPath || '') + "+e.errorPath+"; "+I+'.schemaPath = "'+u+'"; ',e.opts.verbose&&(r+=" "+I+".schema = "+v+"; "+I+".data = "+E+"; "),r+=" } } else { "+se+" } "),r+=" } ",p&&(r+=" else { ")}return r}});var hs=X((ph,Dd)=>{Dd.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 to=X((hh,ro)=>{"use strict";var eo=hs();ro.exports={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:eo.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:eo.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 so=X((mh,ao)=>{"use strict";var Cd=/^[a-z_$][a-z0-9_$-]*$/i,$d=Yi(),kd=to();ao.exports={add:Ld,get:jd,remove:Fd,validate:ms};function Ld(a,e){var t=this.RULES;if(t.keywords[a])throw new Error("Keyword "+a+" is already defined");if(!Cd.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<s.length;r++)i(a,s[r],e);else i(a,s,e);var n=e.metaSchema;n&&(e.$data&&this._opts.$data&&(n={anyOf:[n,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),e.validateSchema=this.compile(n,!0))}t.keywords[a]=t.all[a]=!0;function i(o,c,u){for(var p,m=0;m<t.length;m++){var E=t[m];if(E.type==c){p=E;break}}p||(p={type:c,rules:[]},t.push(p));var d={keyword:o,definition:u,custom:!0,code:$d,implements:u.implements};p.rules.push(d),t.custom[o]=d}return this}function jd(a){var e=this.RULES.custom[a];return e?e.definition:this.RULES.keywords[a]||!1}function Fd(a){var e=this.RULES;delete e.keywords[a],delete e.all[a],delete e.custom[a];for(var t=0;t<e.length;t++)for(var s=e[t].rules,r=0;r<s.length;r++)if(s[r].keyword==a){s.splice(r,1);break}return this}function ms(a,e){ms.errors=null;var t=this._validateKeyword=this._validateKeyword||this.compile(kd,!0);if(t(a))return!0;if(ms.errors=t.errors,e)throw new Error("custom keyword definition is invalid: "+this.errorsText(t.errors));return!1}});var no=X((vh,Md)=>{Md.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 vo=X((gh,mo)=>{"use strict";var oo=Fn(),Qr=ra(),Ud=Un(),lo=es(),qd=is(),Vd=Jn(),zd=Bi(),co=Gi(),uo=Gr();mo.exports=ge;ge.prototype.validate=Bd;ge.prototype.compile=Zd;ge.prototype.addSchema=Xd;ge.prototype.addMetaSchema=Gd;ge.prototype.validateSchema=Qd;ge.prototype.getSchema=Kd;ge.prototype.removeSchema=Yd;ge.prototype.addFormat=lf;ge.prototype.errorsText=of;ge.prototype._addSchema=ef;ge.prototype._compile=rf;ge.prototype.compileAsync=Ki();var ua=so();ge.prototype.addKeyword=ua.add;ge.prototype.getKeyword=ua.get;ge.prototype.removeKeyword=ua.remove;ge.prototype.validateKeyword=ua.validate;var fo=ta();ge.ValidationError=fo.Validation;ge.MissingRefError=fo.MissingRef;ge.$dataMetaSchema=co;var ca="http://json-schema.org/draft-07/schema",io=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],Hd=["/properties"];function ge(a){if(!(this instanceof ge))return new ge(a);a=this._opts=uo.copy(a)||{},hf(this),this._schemas={},this._refs={},this._fragments={},this._formats=Vd(a.format),this._cache=a.cache||new Ud,this._loadingSchemas={},this._compilations=[],this.RULES=zd(),this._getId=tf(a),a.loopRequired=a.loopRequired||1/0,a.errorDataPath=="property"&&(a._errorDataPathProperty=!0),a.serialize===void 0&&(a.serialize=qd),this._metaOpts=pf(this),a.formats&&df(this),a.keywords&&ff(this),cf(this),typeof a.meta=="object"&&this.addMetaSchema(a.meta),a.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),uf(this)}function Bd(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 Zd(a,e){var t=this._addSchema(a,void 0,e);return t.validate||this._compile(t)}function Xd(a,e,t,s){if(Array.isArray(a)){for(var r=0;r<a.length;r++)this.addSchema(a[r],void 0,t,s);return this}var n=this._getId(a);if(n!==void 0&&typeof n!="string")throw new Error("schema id must be string");return e=Qr.normalizeId(e||n),ho(this,e),this._schemas[e]=this._addSchema(a,t,s,!0),this}function Gd(a,e,t){return this.addSchema(a,e,t,!0),this}function Qd(a,e){var t=a.$schema;if(t!==void 0&&typeof t!="string")throw new Error("$schema must be a string");if(t=t||this._opts.defaultMeta||Wd(this),!t)return this.logger.warn("meta-schema not available"),this.errors=null,!0;var s=this.validate(t,a);if(!s&&e){var r="schema is invalid: "+this.errorsText();if(this._opts.validateSchema=="log")this.logger.error(r);else throw new Error(r)}return s}function Wd(a){var e=a._opts.meta;return a._opts.defaultMeta=typeof e=="object"?a._getId(e)||e:a.getSchema(ca)?ca:void 0,a._opts.defaultMeta}function Kd(a){var e=po(this,a);switch(typeof e){case"object":return e.validate||this._compile(e);case"string":return this.getSchema(e);case"undefined":return Jd(this,a)}}function Jd(a,e){var t=Qr.schema.call(a,{schema:{}},e);if(t){var s=t.schema,r=t.root,n=t.baseId,i=oo.call(a,s,r,void 0,n);return a._fragments[e]=new lo({ref:e,fragment:!0,schema:s,root:r,baseId:n,validate:i}),i}}function po(a,e){return e=Qr.normalizeId(e),a._schemas[e]||a._refs[e]||a._fragments[e]}function Yd(a){if(a instanceof RegExp)return la(this,this._schemas,a),la(this,this._refs,a),this;switch(typeof a){case"undefined":return la(this,this._schemas),la(this,this._refs),this._cache.clear(),this;case"string":var e=po(this,a);return e&&this._cache.del(e.cacheKey),delete this._schemas[a],delete this._refs[a],this;case"object":var t=this._opts.serialize,s=t?t(a):a;this._cache.del(s);var r=this._getId(a);r&&(r=Qr.normalizeId(r),delete this._schemas[r],delete this._refs[r])}return this}function la(a,e,t){for(var s in e){var r=e[s];!r.meta&&(!t||t.test(s))&&(a._cache.del(r.cacheKey),delete e[s])}}function ef(a,e,t,s){if(typeof a!="object"&&typeof a!="boolean")throw new Error("schema should be object or boolean");var r=this._opts.serialize,n=r?r(a):a,i=this._cache.get(n);if(i)return i;s=s||this._opts.addUsedSchema!==!1;var o=Qr.normalizeId(this._getId(a));o&&s&&ho(this,o);var c=this._opts.validateSchema!==!1&&!e,u;c&&!(u=o&&o==Qr.normalizeId(a.$schema))&&this.validateSchema(a,!0);var p=Qr.ids.call(this,a),m=new lo({id:o,schema:a,localRefs:p,cacheKey:n,meta:t});return o[0]!="#"&&s&&(this._refs[o]=m),this._cache.put(n,m),c&&u&&this.validateSchema(a,!0),m}function rf(a,e){if(a.compiling)return a.validate=r,r.schema=a.schema,r.errors=null,r.root=e||r,a.schema.$async===!0&&(r.$async=!0),r;a.compiling=!0;var t;a.meta&&(t=this._opts,this._opts=this._metaOpts);var s;try{s=oo.call(this,a.schema,e,a.localRefs)}catch(n){throw delete a.validate,n}finally{a.compiling=!1,a.meta&&(this._opts=t)}return a.validate=s,a.refs=s.refs,a.refVal=s.refVal,a.root=s.root,s;function r(){var n=a.validate,i=n.apply(this,arguments);return r.errors=n.errors,i}}function tf(a){switch(a.schemaId){case"auto":return nf;case"id":return af;default:return sf}}function af(a){return a.$id&&this.logger.warn("schema $id ignored",a.$id),a.id}function sf(a){return a.id&&this.logger.warn("schema id ignored",a.id),a.$id}function nf(a){if(a.$id&&a.id&&a.$id!=a.id)throw new Error("schema $id is different from id");return a.$id||a.id}function of(a,e){if(a=a||this.errors,!a)return"No errors";e=e||{};for(var t=e.separator===void 0?", ":e.separator,s=e.dataVar===void 0?"data":e.dataVar,r="",n=0;n<a.length;n++){var i=a[n];i&&(r+=s+i.dataPath+" "+i.message+t)}return r.slice(0,-t.length)}function lf(a,e){return typeof e=="string"&&(e=new RegExp(e)),this._formats[a]=e,this}function cf(a){var e;if(a._opts.$data&&(e=no(),a.addMetaSchema(e,e.$id,!0)),a._opts.meta!==!1){var t=hs();a._opts.$data&&(t=co(t,Hd)),a.addMetaSchema(t,ca,!0),a._refs["http://json-schema.org/schema"]=ca}}function uf(a){var e=a._opts.schemas;if(e)if(Array.isArray(e))a.addSchema(e);else for(var t in e)a.addSchema(e[t],t)}function df(a){for(var e in a._opts.formats){var t=a._opts.formats[e];a.addFormat(e,t)}}function ff(a){for(var e in a._opts.keywords){var t=a._opts.keywords[e];a.addKeyword(e,t)}}function ho(a,e){if(a._schemas[e]||a._refs[e])throw new Error('schema with key or id "'+e+'" already exists')}function pf(a){for(var e=uo.copy(a._opts),t=0;t<io.length;t++)delete e[io[t]];return e}function hf(a){var e=a._opts.logger;if(e===!1)a.logger={log:vs,warn:vs,error:vs};else{if(e===void 0&&(e=console),!(typeof e=="object"&&e.log&&e.warn&&e.error))throw new Error("logger must implement log, warn and error methods");a.logger=e}}function vs(){}});var l={};Ol(l,{BRAND:()=>rc,DIRTY:()=>Dr,EMPTY_PATH:()=>Cl,INVALID:()=>B,NEVER:()=>Mc,OK:()=>Oe,ParseStatus:()=>Re,Schema:()=>W,ZodAny:()=>br,ZodArray:()=>vr,ZodBigInt:()=>$r,ZodBoolean:()=>kr,ZodBranded:()=>bt,ZodCatch:()=>Zr,ZodDate:()=>Lr,ZodDefault:()=>Br,ZodDiscriminatedUnion:()=>kt,ZodEffects:()=>He,ZodEnum:()=>zr,ZodError:()=>Ce,ZodFirstPartyTypeKind:()=>w,ZodFunction:()=>jt,ZodIntersection:()=>Ur,ZodIssueCode:()=>O,ZodLazy:()=>qr,ZodLiteral:()=>Vr,ZodMap:()=>ct,ZodNaN:()=>dt,ZodNativeEnum:()=>Hr,ZodNever:()=>Ge,ZodNull:()=>Fr,ZodNullable:()=>nr,ZodNumber:()=>Cr,ZodObject:()=>$e,ZodOptional:()=>Ve,ZodParsedType:()=>k,ZodPipeline:()=>St,ZodPromise:()=>Sr,ZodReadonly:()=>Xr,ZodRecord:()=>Lt,ZodSchema:()=>W,ZodSet:()=>ut,ZodString:()=>Er,ZodSymbol:()=>ot,ZodTransformer:()=>He,ZodTuple:()=>sr,ZodType:()=>W,ZodUndefined:()=>jr,ZodUnion:()=>Mr,ZodUnknown:()=>mr,ZodVoid:()=>lt,addIssueToContext:()=>$,any:()=>uc,array:()=>hc,bigint:()=>nc,boolean:()=>Gs,coerce:()=>Fc,custom:()=>Bs,date:()=>ic,datetimeRegex:()=>zs,defaultErrorMap:()=>pr,discriminatedUnion:()=>_c,effect:()=>Nc,enum:()=>Oc,function:()=>Rc,getErrorMap:()=>st,getParsedType:()=>ar,instanceof:()=>ac,intersection:()=>yc,isAborted:()=>Ct,isAsync:()=>nt,isDirty:()=>$t,isValid:()=>yr,late:()=>tc,lazy:()=>Tc,literal:()=>Pc,makeIssue:()=>Et,map:()=>Sc,nan:()=>sc,nativeEnum:()=>wc,never:()=>fc,null:()=>cc,nullable:()=>Dc,number:()=>Xs,object:()=>mc,objectUtil:()=>Na,oboolean:()=>jc,onumber:()=>Lc,optional:()=>Ac,ostring:()=>kc,pipeline:()=>$c,preprocess:()=>Cc,promise:()=>Ic,quotelessJson:()=>Nl,record:()=>bc,set:()=>xc,setErrorMap:()=>Dl,strictObject:()=>vc,string:()=>Zs,symbol:()=>oc,transformer:()=>Nc,tuple:()=>Ec,undefined:()=>lc,union:()=>gc,unknown:()=>dc,util:()=>Y,void:()=>pc});var Y;(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 i of r)n[i]=i;return n},a.getValidEnumValues=r=>{let n=a.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(let o of n)i[o]=r[o];return a.objectValues(i)},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 i in r)Object.prototype.hasOwnProperty.call(r,i)&&n.push(i);return n},a.find=(r,n)=>{for(let i of r)if(n(i))return i},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(i=>typeof i=="string"?`'${i}'`:i).join(n)}a.joinValues=s,a.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(Y||(Y={}));var Na;(function(a){a.mergeShapes=(e,t)=>({...e,...t})})(Na||(Na={}));var k=Y.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ar=a=>{switch(typeof a){case"undefined":return k.undefined;case"string":return k.string;case"number":return Number.isNaN(a)?k.nan:k.number;case"boolean":return k.boolean;case"function":return k.function;case"bigint":return k.bigint;case"symbol":return k.symbol;case"object":return Array.isArray(a)?k.array:a===null?k.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?k.promise:typeof Map<"u"&&a instanceof Map?k.map:typeof Set<"u"&&a instanceof Set?k.set:typeof Date<"u"&&a instanceof Date?k.date:k.object;default:return k.unknown}};var O=Y.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"]),Nl=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:"),Ce=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 i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return r(this),s}static assert(e){if(!(e instanceof a))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Y.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.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()}};Ce.create=a=>new Ce(a);var Al=(a,e)=>{let t;switch(a.code){case O.invalid_type:a.received===k.undefined?t="Required":t=`Expected ${a.expected}, received ${a.received}`;break;case O.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(a.expected,Y.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:t=`Unrecognized key(s) in object: ${Y.joinValues(a.keys,", ")}`;break;case O.invalid_union:t="Invalid input";break;case O.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Y.joinValues(a.options)}`;break;case O.invalid_enum_value:t=`Invalid enum value. Expected ${Y.joinValues(a.options)}, received '${a.received}'`;break;case O.invalid_arguments:t="Invalid function arguments";break;case O.invalid_return_type:t="Invalid function return type";break;case O.invalid_date:t="Invalid date";break;case O.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}"`:Y.assertNever(a.validation):a.validation!=="regex"?t=`Invalid ${a.validation}`:t="Invalid";break;case O.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 O.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 O.custom:t="Invalid input";break;case O.invalid_intersection_types:t="Intersection results could not be merged";break;case O.not_multiple_of:t=`Number must be a multiple of ${a.multipleOf}`;break;case O.not_finite:t="Number must be finite";break;default:t=e.defaultError,Y.assertNever(a)}return{message:t}},pr=Al;var Fs=pr;function Dl(a){Fs=a}function st(){return Fs}var Et=a=>{let{data:e,path:t,errorMaps:s,issueData:r}=a,n=[...t,...r.path||[]],i={...r,path:n};if(r.message!==void 0)return{...r,path:n,message:r.message};let o="",c=s.filter(u=>!!u).slice().reverse();for(let u of c)o=u(i,{data:e,defaultError:o}).message;return{...r,path:n,message:o}},Cl=[];function $(a,e){let t=st(),s=Et({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,t,t===pr?void 0:pr].filter(r=>!!r)});a.common.issues.push(s)}var Re=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 B;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,i=await r.value;s.push({key:n,value:i})}return a.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let r of t){let{key:n,value:i}=r;if(n.status==="aborted"||i.status==="aborted")return B;n.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(s[n.value]=i.value)}return{status:e.value,value:s}}},B=Object.freeze({status:"aborted"}),Dr=a=>({status:"dirty",value:a}),Oe=a=>({status:"valid",value:a}),Ct=a=>a.status==="aborted",$t=a=>a.status==="dirty",yr=a=>a.status==="valid",nt=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}},Ms=(a,e)=>{if(yr(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 Ce(a.common.issues);return this._error=t,this._error}}};function G(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:(i,o)=>{let{message:c}=a;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:r}}var W=class{get description(){return this._def.description}_getType(e){return ar(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ar(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Re,ctx:{common:e.parent.common,data:e.data,parsedType:ar(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(nt(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:ar(e)},r=this._parseSync({data:e,path:s.path,parent:s});return Ms(s,r)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ar(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return yr(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=>yr(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:ar(e)},r=this._parse({data:e,path:s.path,parent:s}),n=await(nt(r)?r:Promise.resolve(r));return Ms(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 i=e(r),o=()=>n.addIssue({code:O.custom,...s(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!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 He({schema:this,typeName:w.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 Ve.create(this,this._def)}nullable(){return nr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return vr.create(this)}promise(){return Sr.create(this,this._def)}or(e){return Mr.create([this,e],this._def)}and(e){return Ur.create(this,e,this._def)}transform(e){return new He({...G(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Br({...G(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new bt({typeName:w.ZodBranded,type:this,...G(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Zr({...G(this._def),innerType:this,catchValue:t,typeName:w.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return St.create(this,e)}readonly(){return Xr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},$l=/^c[^\s-]{8,}$/i,kl=/^[0-9a-z]+$/,Ll=/^[0-9A-HJKMNP-TV-Z]{26}$/i,jl=/^[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,Fl=/^[a-z0-9_-]{21}$/i,Ml=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ul=/^[-+]?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)?)??$/,ql=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Vl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Aa,zl=/^(?:(?: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])$/,Hl=/^(?:(?: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])$/,Bl=/^(([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]))$/,Zl=/^(([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])$/,Xl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Gl=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,qs="((\\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])))",Ql=new RegExp(`^${qs}$`);function Vs(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 Wl(a){return new RegExp(`^${Vs(a)}$`)}function zs(a){let e=`${qs}T${Vs(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 Kl(a,e){return!!((e==="v4"||!e)&&zl.test(a)||(e==="v6"||!e)&&Bl.test(a))}function Jl(a,e){if(!Ml.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 Yl(a,e){return!!((e==="v4"||!e)&&Hl.test(a)||(e==="v6"||!e)&&Zl.test(a))}var Er=class a extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==k.string){let n=this._getOrReturnCtx(e);return $(n,{code:O.invalid_type,expected:k.string,received:n.parsedType}),B}let s=new Re,r;for(let n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:O.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="max")e.data.length>n.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:O.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),s.dirty());else if(n.kind==="length"){let i=e.data.length>n.value,o=e.data.length<n.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?$(r,{code:O.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&$(r,{code:O.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),s.dirty())}else if(n.kind==="email")ql.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"email",code:O.invalid_string,message:n.message}),s.dirty());else if(n.kind==="emoji")Aa||(Aa=new RegExp(Vl,"u")),Aa.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"emoji",code:O.invalid_string,message:n.message}),s.dirty());else if(n.kind==="uuid")jl.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"uuid",code:O.invalid_string,message:n.message}),s.dirty());else if(n.kind==="nanoid")Fl.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"nanoid",code:O.invalid_string,message:n.message}),s.dirty());else if(n.kind==="cuid")$l.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid",code:O.invalid_string,message:n.message}),s.dirty());else if(n.kind==="cuid2")kl.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid2",code:O.invalid_string,message:n.message}),s.dirty());else if(n.kind==="ulid")Ll.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ulid",code:O.invalid_string,message:n.message}),s.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),$(r,{validation:"url",code:O.invalid_string,message:n.message}),s.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"regex",code:O.invalid_string,message:n.message}),s.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(r=this._getOrReturnCtx(e,r),$(r,{code:O.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),s.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(r=this._getOrReturnCtx(e,r),$(r,{code:O.invalid_string,validation:{startsWith:n.value},message:n.message}),s.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),$(r,{code:O.invalid_string,validation:{endsWith:n.value},message:n.message}),s.dirty()):n.kind==="datetime"?zs(n).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:O.invalid_string,validation:"datetime",message:n.message}),s.dirty()):n.kind==="date"?Ql.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:O.invalid_string,validation:"date",message:n.message}),s.dirty()):n.kind==="time"?Wl(n).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:O.invalid_string,validation:"time",message:n.message}),s.dirty()):n.kind==="duration"?Ul.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"duration",code:O.invalid_string,message:n.message}),s.dirty()):n.kind==="ip"?Kl(e.data,n.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ip",code:O.invalid_string,message:n.message}),s.dirty()):n.kind==="jwt"?Jl(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"jwt",code:O.invalid_string,message:n.message}),s.dirty()):n.kind==="cidr"?Yl(e.data,n.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cidr",code:O.invalid_string,message:n.message}),s.dirty()):n.kind==="base64"?Xl.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64",code:O.invalid_string,message:n.message}),s.dirty()):n.kind==="base64url"?Gl.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64url",code:O.invalid_string,message:n.message}),s.dirty()):Y.assertNever(n);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),{validation:t,code:O.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.value<e)&&(e=t.value);return e}};Er.create=a=>new Er({checks:[],typeName:w.ZodString,coerce:a?.coerce??!1,...G(a)});function ec(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(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return n%i/10**r}var Cr=class a extends W{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)!==k.number){let n=this._getOrReturnCtx(e);return $(n,{code:O.invalid_type,expected:k.number,received:n.parsedType}),B}let s,r=new Re;for(let n of this._def.checks)n.kind==="int"?Y.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),$(s,{code:O.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(s=this._getOrReturnCtx(e,s),$(s,{code:O.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),$(s,{code:O.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):n.kind==="multipleOf"?ec(e.data,n.value)!==0&&(s=this._getOrReturnCtx(e,s),$(s,{code:O.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),$(s,{code:O.not_finite,message:n.message}),r.dirty()):Y.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.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Y.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.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Cr.create=a=>new Cr({checks:[],typeName:w.ZodNumber,coerce:a?.coerce||!1,...G(a)});var $r=class a extends W{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)!==k.bigint)return this._getInvalidInput(e);let s,r=new Re;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(s=this._getOrReturnCtx(e,s),$(s,{code:O.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(s=this._getOrReturnCtx(e,s),$(s,{code:O.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),$(s,{code:O.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):Y.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return $(t,{code:O.invalid_type,expected:k.bigint,received:t.parsedType}),B}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.value<e)&&(e=t.value);return e}};$r.create=a=>new $r({checks:[],typeName:w.ZodBigInt,coerce:a?.coerce??!1,...G(a)});var kr=class extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==k.boolean){let s=this._getOrReturnCtx(e);return $(s,{code:O.invalid_type,expected:k.boolean,received:s.parsedType}),B}return Oe(e.data)}};kr.create=a=>new kr({typeName:w.ZodBoolean,coerce:a?.coerce||!1,...G(a)});var Lr=class a extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==k.date){let n=this._getOrReturnCtx(e);return $(n,{code:O.invalid_type,expected:k.date,received:n.parsedType}),B}if(Number.isNaN(e.data.getTime())){let n=this._getOrReturnCtx(e);return $(n,{code:O.invalid_date}),B}let s=new Re,r;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:O.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),s.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:O.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),s.dirty()):Y.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.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Lr.create=a=>new Lr({checks:[],coerce:a?.coerce||!1,typeName:w.ZodDate,...G(a)});var ot=class extends W{_parse(e){if(this._getType(e)!==k.symbol){let s=this._getOrReturnCtx(e);return $(s,{code:O.invalid_type,expected:k.symbol,received:s.parsedType}),B}return Oe(e.data)}};ot.create=a=>new ot({typeName:w.ZodSymbol,...G(a)});var jr=class extends W{_parse(e){if(this._getType(e)!==k.undefined){let s=this._getOrReturnCtx(e);return $(s,{code:O.invalid_type,expected:k.undefined,received:s.parsedType}),B}return Oe(e.data)}};jr.create=a=>new jr({typeName:w.ZodUndefined,...G(a)});var Fr=class extends W{_parse(e){if(this._getType(e)!==k.null){let s=this._getOrReturnCtx(e);return $(s,{code:O.invalid_type,expected:k.null,received:s.parsedType}),B}return Oe(e.data)}};Fr.create=a=>new Fr({typeName:w.ZodNull,...G(a)});var br=class extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return Oe(e.data)}};br.create=a=>new br({typeName:w.ZodAny,...G(a)});var mr=class extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Oe(e.data)}};mr.create=a=>new mr({typeName:w.ZodUnknown,...G(a)});var Ge=class extends W{_parse(e){let t=this._getOrReturnCtx(e);return $(t,{code:O.invalid_type,expected:k.never,received:t.parsedType}),B}};Ge.create=a=>new Ge({typeName:w.ZodNever,...G(a)});var lt=class extends W{_parse(e){if(this._getType(e)!==k.undefined){let s=this._getOrReturnCtx(e);return $(s,{code:O.invalid_type,expected:k.void,received:s.parsedType}),B}return Oe(e.data)}};lt.create=a=>new lt({typeName:w.ZodVoid,...G(a)});var vr=class a extends W{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==k.array)return $(t,{code:O.invalid_type,expected:k.array,received:t.parsedType}),B;if(r.exactLength!==null){let i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&($(t,{code:i?O.too_big:O.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&($(t,{code:O.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&($(t,{code:O.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((i,o)=>r.type._parseAsync(new ze(t,i,t.path,o)))).then(i=>Re.mergeArray(s,i));let n=[...t.data].map((i,o)=>r.type._parseSync(new ze(t,i,t.path,o)));return Re.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)}};vr.create=(a,e)=>new vr({type:a,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...G(e)});function it(a){if(a instanceof $e){let e={};for(let t in a.shape){let s=a.shape[t];e[t]=Ve.create(it(s))}return new $e({...a._def,shape:()=>e})}else return a instanceof vr?new vr({...a._def,type:it(a.element)}):a instanceof Ve?Ve.create(it(a.unwrap())):a instanceof nr?nr.create(it(a.unwrap())):a instanceof sr?sr.create(a.items.map(e=>it(e))):a}var $e=class a extends W{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=Y.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==k.object){let u=this._getOrReturnCtx(e);return $(u,{code:O.invalid_type,expected:k.object,received:u.parsedType}),B}let{status:s,ctx:r}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Ge&&this._def.unknownKeys==="strip"))for(let u in r.data)i.includes(u)||o.push(u);let c=[];for(let u of i){let p=n[u],m=r.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new ze(r,m,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof Ge){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:r.data[p]}});else if(u==="strict")o.length>0&&($(r,{code:O.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let p of o){let m=r.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new ze(r,m,r.path,p)),alwaysSet:p in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of c){let m=await p.key,E=await p.value;u.push({key:m,value:E,alwaysSet:p.alwaysSet})}return u}).then(u=>Re.mergeObjectSync(s,u)):Re.mergeObjectSync(s,c)}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:w.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 Y.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 Y.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 Y.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 Y.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Ve;)n=n._def.innerType;t[s]=n}return new a({...this._def,shape:()=>t})}keyof(){return Hs(Y.objectKeys(this.shape))}};$e.create=(a,e)=>new $e({shape:()=>a,unknownKeys:"strip",catchall:Ge.create(),typeName:w.ZodObject,...G(e)});$e.strictCreate=(a,e)=>new $e({shape:()=>a,unknownKeys:"strict",catchall:Ge.create(),typeName:w.ZodObject,...G(e)});$e.lazycreate=(a,e)=>new $e({shape:a,unknownKeys:"strip",catchall:Ge.create(),typeName:w.ZodObject,...G(e)});var Mr=class extends W{_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 i=n.map(o=>new Ce(o.ctx.common.issues));return $(t,{code:O.invalid_union,unionErrors:i}),B}if(t.common.async)return Promise.all(s.map(async n=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(r);{let n,i=[];for(let c of s){let u={...t,common:{...t.common,issues:[]},parent:null},p=c._parseSync({data:t.data,path:t.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!n&&(n={result:p,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;let o=i.map(c=>new Ce(c));return $(t,{code:O.invalid_union,unionErrors:o}),B}}get options(){return this._def.options}};Mr.create=(a,e)=>new Mr({options:a,typeName:w.ZodUnion,...G(e)});var hr=a=>a instanceof qr?hr(a.schema):a instanceof He?hr(a.innerType()):a instanceof Vr?[a.value]:a instanceof zr?a.options:a instanceof Hr?Y.objectValues(a.enum):a instanceof Br?hr(a._def.innerType):a instanceof jr?[void 0]:a instanceof Fr?[null]:a instanceof Ve?[void 0,...hr(a.unwrap())]:a instanceof nr?[null,...hr(a.unwrap())]:a instanceof bt||a instanceof Xr?hr(a.unwrap()):a instanceof Zr?hr(a._def.innerType):[],kt=class a extends W{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.object)return $(t,{code:O.invalid_type,expected:k.object,received:t.parsedType}),B;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}):($(t,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),B)}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 i=hr(n.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,n)}}return new a({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...G(s)})}};function Da(a,e){let t=ar(a),s=ar(e);if(a===e)return{valid:!0,data:a};if(t===k.object&&s===k.object){let r=Y.objectKeys(e),n=Y.objectKeys(a).filter(o=>r.indexOf(o)!==-1),i={...a,...e};for(let o of n){let c=Da(a[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===k.array&&s===k.array){if(a.length!==e.length)return{valid:!1};let r=[];for(let n=0;n<a.length;n++){let i=a[n],o=e[n],c=Da(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===k.date&&s===k.date&&+a==+e?{valid:!0,data:a}:{valid:!1}}var Ur=class extends W{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),r=(n,i)=>{if(Ct(n)||Ct(i))return B;let o=Da(n.value,i.value);return o.valid?(($t(n)||$t(i))&&t.dirty(),{status:t.value,value:o.data}):($(s,{code:O.invalid_intersection_types}),B)};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,i])=>r(n,i)):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}))}};Ur.create=(a,e,t)=>new Ur({left:a,right:e,typeName:w.ZodIntersection,...G(t)});var sr=class a extends W{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.array)return $(s,{code:O.invalid_type,expected:k.array,received:s.parsedType}),B;if(s.data.length<this._def.items.length)return $(s,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),B;!this._def.rest&&s.data.length>this._def.items.length&&($(s,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...s.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new ze(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(n).then(i=>Re.mergeArray(t,i)):Re.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new a({...this._def,rest:e})}};sr.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new sr({items:a,typeName:w.ZodTuple,rest:null,...G(e)})};var Lt=class a extends W{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!==k.object)return $(s,{code:O.invalid_type,expected:k.object,received:s.parsedType}),B;let r=[],n=this._def.keyType,i=this._def.valueType;for(let o in s.data)r.push({key:n._parse(new ze(s,o,s.path,o)),value:i._parse(new ze(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?Re.mergeObjectAsync(t,r):Re.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof W?new a({keyType:e,valueType:t,typeName:w.ZodRecord,...G(s)}):new a({keyType:Er.create(),valueType:e,typeName:w.ZodRecord,...G(t)})}},ct=class extends W{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!==k.map)return $(s,{code:O.invalid_type,expected:k.map,received:s.parsedType}),B;let r=this._def.keyType,n=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:r._parse(new ze(s,o,s.path,[u,"key"])),value:n._parse(new ze(s,c,s.path,[u,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return B;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(u.value,p.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let c of i){let u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return B;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(u.value,p.value)}return{status:t.value,value:o}}}};ct.create=(a,e,t)=>new ct({valueType:e,keyType:a,typeName:w.ZodMap,...G(t)});var ut=class a extends W{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.set)return $(s,{code:O.invalid_type,expected:k.set,received:s.parsedType}),B;let r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&($(s,{code:O.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&($(s,{code:O.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let n=this._def.valueType;function i(c){let u=new Set;for(let p of c){if(p.status==="aborted")return B;p.status==="dirty"&&t.dirty(),u.add(p.value)}return{status:t.value,value:u}}let o=[...s.data.values()].map((c,u)=>n._parse(new ze(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(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)}};ut.create=(a,e)=>new ut({valueType:a,minSize:null,maxSize:null,typeName:w.ZodSet,...G(e)});var jt=class a extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.function)return $(t,{code:O.invalid_type,expected:k.function,received:t.parsedType}),B;function s(o,c){return Et({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,st(),pr].filter(u=>!!u),issueData:{code:O.invalid_arguments,argumentsError:c}})}function r(o,c){return Et({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,st(),pr].filter(u=>!!u),issueData:{code:O.invalid_return_type,returnTypeError:c}})}let n={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Sr){let o=this;return Oe(async function(...c){let u=new Ce([]),p=await o._def.args.parseAsync(c,n).catch(d=>{throw u.addIssue(s(c,d)),u}),m=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(m,n).catch(d=>{throw u.addIssue(r(m,d)),u})})}else{let o=this;return Oe(function(...c){let u=o._def.args.safeParse(c,n);if(!u.success)throw new Ce([s(c,u.error)]);let p=Reflect.apply(i,this,u.data),m=o._def.returns.safeParse(p,n);if(!m.success)throw new Ce([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:sr.create(e).rest(mr.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||sr.create([]).rest(mr.create()),returns:t||mr.create(),typeName:w.ZodFunction,...G(s)})}},qr=class extends W{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})}};qr.create=(a,e)=>new qr({getter:a,typeName:w.ZodLazy,...G(e)});var Vr=class extends W{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return $(t,{received:t.data,code:O.invalid_literal,expected:this._def.value}),B}return{status:"valid",value:e.data}}get value(){return this._def.value}};Vr.create=(a,e)=>new Vr({value:a,typeName:w.ZodLiteral,...G(e)});function Hs(a,e){return new zr({values:a,typeName:w.ZodEnum,...G(e)})}var zr=class a extends W{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return $(t,{expected:Y.joinValues(s),received:t.parsedType,code:O.invalid_type}),B}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 $(t,{received:t.data,code:O.invalid_enum_value,options:s}),B}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=Hs;var Hr=class extends W{_parse(e){let t=Y.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==k.string&&s.parsedType!==k.number){let r=Y.objectValues(t);return $(s,{expected:Y.joinValues(r),received:s.parsedType,code:O.invalid_type}),B}if(this._cache||(this._cache=new Set(Y.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let r=Y.objectValues(t);return $(s,{received:s.data,code:O.invalid_enum_value,options:r}),B}return Oe(e.data)}get enum(){return this._def.values}};Hr.create=(a,e)=>new Hr({values:a,typeName:w.ZodNativeEnum,...G(e)});var Sr=class extends W{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.promise&&t.common.async===!1)return $(t,{code:O.invalid_type,expected:k.promise,received:t.parsedType}),B;let s=t.parsedType===k.promise?t.data:Promise.resolve(t.data);return Oe(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Sr.create=(a,e)=>new Sr({type:a,typeName:w.ZodPromise,...G(e)});var He=class extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.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:i=>{$(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),r.type==="preprocess"){let i=r.transform(s.data,n);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return B;let c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?B:c.status==="dirty"?Dr(c.value):t.value==="dirty"?Dr(c.value):c});{if(t.value==="aborted")return B;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?B:o.status==="dirty"?Dr(o.value):t.value==="dirty"?Dr(o.value):o}}if(r.type==="refinement"){let i=o=>{let c=r.refinement(o,n);if(s.common.async)return Promise.resolve(c);if(c 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"?B:(o.status==="dirty"&&t.dirty(),i(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"?B:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!yr(i))return B;let o=r.transform(i.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(i=>yr(i)?Promise.resolve(r.transform(i.value,n)).then(o=>({status:t.value,value:o})):B);Y.assertNever(r)}};He.create=(a,e,t)=>new He({schema:a,typeName:w.ZodEffects,effect:e,...G(t)});He.createWithPreprocess=(a,e,t)=>new He({schema:e,effect:{type:"preprocess",transform:a},typeName:w.ZodEffects,...G(t)});var Ve=class extends W{_parse(e){return this._getType(e)===k.undefined?Oe(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ve.create=(a,e)=>new Ve({innerType:a,typeName:w.ZodOptional,...G(e)});var nr=class extends W{_parse(e){return this._getType(e)===k.null?Oe(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};nr.create=(a,e)=>new nr({innerType:a,typeName:w.ZodNullable,...G(e)});var Br=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===k.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Br.create=(a,e)=>new Br({innerType:a,typeName:w.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});var Zr=class extends W{_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 nt(r)?r.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ce(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ce(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Zr.create=(a,e)=>new Zr({innerType:a,typeName:w.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});var dt=class extends W{_parse(e){if(this._getType(e)!==k.nan){let s=this._getOrReturnCtx(e);return $(s,{code:O.invalid_type,expected:k.nan,received:s.parsedType}),B}return{status:"valid",value:e.data}}};dt.create=a=>new dt({typeName:w.ZodNaN,...G(a)});var rc=Symbol("zod_brand"),bt=class extends W{_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}},St=class a extends W{_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"?B:n.status==="dirty"?(t.dirty(),Dr(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"?B: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:w.ZodPipeline})}},Xr=class extends W{_parse(e){let t=this._def.innerType._parse(e),s=r=>(yr(r)&&(r.value=Object.freeze(r.value)),r);return nt(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}};Xr.create=(a,e)=>new Xr({innerType:a,typeName:w.ZodReadonly,...G(e)});function Us(a,e){let t=typeof a=="function"?a(e):typeof a=="string"?{message:a}:a;return typeof t=="string"?{message:t}:t}function Bs(a,e={},t){return a?br.create().superRefine((s,r)=>{let n=a(s);if(n instanceof Promise)return n.then(i=>{if(!i){let o=Us(e,s),c=o.fatal??t??!0;r.addIssue({code:"custom",...o,fatal:c})}});if(!n){let i=Us(e,s),o=i.fatal??t??!0;r.addIssue({code:"custom",...i,fatal:o})}}):br.create()}var tc={object:$e.lazycreate},w;(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"})(w||(w={}));var ac=(a,e={message:`Input not instance of ${a.name}`})=>Bs(t=>t instanceof a,e),Zs=Er.create,Xs=Cr.create,sc=dt.create,nc=$r.create,Gs=kr.create,ic=Lr.create,oc=ot.create,lc=jr.create,cc=Fr.create,uc=br.create,dc=mr.create,fc=Ge.create,pc=lt.create,hc=vr.create,mc=$e.create,vc=$e.strictCreate,gc=Mr.create,_c=kt.create,yc=Ur.create,Ec=sr.create,bc=Lt.create,Sc=ct.create,xc=ut.create,Rc=jt.create,Tc=qr.create,Pc=Vr.create,Oc=zr.create,wc=Hr.create,Ic=Sr.create,Nc=He.create,Ac=Ve.create,Dc=nr.create,Cc=He.createWithPreprocess,$c=St.create,kc=()=>Zs().optional(),Lc=()=>Xs().optional(),jc=()=>Gs().optional(),Fc={string:a=>Er.create({...a,coerce:!0}),number:a=>Cr.create({...a,coerce:!0}),boolean:a=>kr.create({...a,coerce:!0}),bigint:a=>$r.create({...a,coerce:!0}),date:a=>Lr.create({...a,coerce:!0})};var Mc=B;var Ca="2025-06-18";var Qs=[Ca,"2025-03-26","2024-11-05","2024-10-07"],Ft="2.0",Ws=l.union([l.string(),l.number().int()]),Ks=l.string(),Uc=l.object({progressToken:l.optional(Ws)}).passthrough(),Be=l.object({_meta:l.optional(Uc)}).passthrough(),ke=l.object({method:l.string(),params:l.optional(Be)}),xt=l.object({_meta:l.optional(l.object({}).passthrough())}).passthrough(),ir=l.object({method:l.string(),params:l.optional(xt)}),Ze=l.object({_meta:l.optional(l.object({}).passthrough())}).passthrough(),Mt=l.union([l.string(),l.number().int()]),Js=l.object({jsonrpc:l.literal(Ft),id:Mt}).merge(ke).strict(),Ys=a=>Js.safeParse(a).success,en=l.object({jsonrpc:l.literal(Ft)}).merge(ir).strict(),rn=a=>en.safeParse(a).success,tn=l.object({jsonrpc:l.literal(Ft),id:Mt,result:Ze}).strict(),$a=a=>tn.safeParse(a).success,Qe;(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"})(Qe||(Qe={}));var an=l.object({jsonrpc:l.literal(Ft),id:Mt,error:l.object({code:l.number().int(),message:l.string(),data:l.optional(l.unknown())})}).strict(),sn=a=>an.safeParse(a).success,nn=l.union([Js,en,tn,an]),Ut=Ze.strict(),qt=ir.extend({method:l.literal("notifications/cancelled"),params:xt.extend({requestId:Mt,reason:l.string().optional()})}),qc=l.object({src:l.string(),mimeType:l.optional(l.string()),sizes:l.optional(l.array(l.string()))}).passthrough(),Rt=l.object({icons:l.array(qc).optional()}).passthrough(),Tt=l.object({name:l.string(),title:l.optional(l.string())}).passthrough(),on=Tt.extend({version:l.string(),websiteUrl:l.optional(l.string())}).merge(Rt),Vc=l.object({experimental:l.optional(l.object({}).passthrough()),sampling:l.optional(l.object({}).passthrough()),elicitation:l.optional(l.object({}).passthrough()),roots:l.optional(l.object({listChanged:l.optional(l.boolean())}).passthrough())}).passthrough(),ka=ke.extend({method:l.literal("initialize"),params:Be.extend({protocolVersion:l.string(),capabilities:Vc,clientInfo:on})});var zc=l.object({experimental:l.optional(l.object({}).passthrough()),logging:l.optional(l.object({}).passthrough()),completions:l.optional(l.object({}).passthrough()),prompts:l.optional(l.object({listChanged:l.optional(l.boolean())}).passthrough()),resources:l.optional(l.object({subscribe:l.optional(l.boolean()),listChanged:l.optional(l.boolean())}).passthrough()),tools:l.optional(l.object({listChanged:l.optional(l.boolean())}).passthrough())}).passthrough(),Hc=Ze.extend({protocolVersion:l.string(),capabilities:zc,serverInfo:on,instructions:l.optional(l.string())}),La=ir.extend({method:l.literal("notifications/initialized")});var Vt=ke.extend({method:l.literal("ping")}),Bc=l.object({progress:l.number(),total:l.optional(l.number()),message:l.optional(l.string())}).passthrough(),zt=ir.extend({method:l.literal("notifications/progress"),params:xt.merge(Bc).extend({progressToken:Ws})}),Ht=ke.extend({params:Be.extend({cursor:l.optional(Ks)}).optional()}),Bt=Ze.extend({nextCursor:l.optional(Ks)}),ln=l.object({uri:l.string(),mimeType:l.optional(l.string()),_meta:l.optional(l.object({}).passthrough())}).passthrough(),cn=ln.extend({text:l.string()}),ja=l.string().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),un=ln.extend({blob:ja}),dn=Tt.extend({uri:l.string(),description:l.optional(l.string()),mimeType:l.optional(l.string()),_meta:l.optional(l.object({}).passthrough())}).merge(Rt),Zc=Tt.extend({uriTemplate:l.string(),description:l.optional(l.string()),mimeType:l.optional(l.string()),_meta:l.optional(l.object({}).passthrough())}).merge(Rt),Xc=Ht.extend({method:l.literal("resources/list")}),Gc=Bt.extend({resources:l.array(dn)}),Qc=Ht.extend({method:l.literal("resources/templates/list")}),Wc=Bt.extend({resourceTemplates:l.array(Zc)}),Kc=ke.extend({method:l.literal("resources/read"),params:Be.extend({uri:l.string()})}),Jc=Ze.extend({contents:l.array(l.union([cn,un]))}),Yc=ir.extend({method:l.literal("notifications/resources/list_changed")}),eu=ke.extend({method:l.literal("resources/subscribe"),params:Be.extend({uri:l.string()})}),ru=ke.extend({method:l.literal("resources/unsubscribe"),params:Be.extend({uri:l.string()})}),tu=ir.extend({method:l.literal("notifications/resources/updated"),params:xt.extend({uri:l.string()})}),au=l.object({name:l.string(),description:l.optional(l.string()),required:l.optional(l.boolean())}).passthrough(),su=Tt.extend({description:l.optional(l.string()),arguments:l.optional(l.array(au)),_meta:l.optional(l.object({}).passthrough())}).merge(Rt),nu=Ht.extend({method:l.literal("prompts/list")}),iu=Bt.extend({prompts:l.array(su)}),ou=ke.extend({method:l.literal("prompts/get"),params:Be.extend({name:l.string(),arguments:l.optional(l.record(l.string()))})}),Fa=l.object({type:l.literal("text"),text:l.string(),_meta:l.optional(l.object({}).passthrough())}).passthrough(),Ma=l.object({type:l.literal("image"),data:ja,mimeType:l.string(),_meta:l.optional(l.object({}).passthrough())}).passthrough(),Ua=l.object({type:l.literal("audio"),data:ja,mimeType:l.string(),_meta:l.optional(l.object({}).passthrough())}).passthrough(),lu=l.object({type:l.literal("resource"),resource:l.union([cn,un]),_meta:l.optional(l.object({}).passthrough())}).passthrough(),cu=dn.extend({type:l.literal("resource_link")}),fn=l.union([Fa,Ma,Ua,cu,lu]),uu=l.object({role:l.enum(["user","assistant"]),content:fn}).passthrough(),du=Ze.extend({description:l.optional(l.string()),messages:l.array(uu)}),fu=ir.extend({method:l.literal("notifications/prompts/list_changed")}),pu=l.object({title:l.optional(l.string()),readOnlyHint:l.optional(l.boolean()),destructiveHint:l.optional(l.boolean()),idempotentHint:l.optional(l.boolean()),openWorldHint:l.optional(l.boolean())}).passthrough(),hu=Tt.extend({description:l.optional(l.string()),inputSchema:l.object({type:l.literal("object"),properties:l.optional(l.object({}).passthrough()),required:l.optional(l.array(l.string()))}).passthrough(),outputSchema:l.optional(l.object({type:l.literal("object"),properties:l.optional(l.object({}).passthrough()),required:l.optional(l.array(l.string()))}).passthrough()),annotations:l.optional(pu),_meta:l.optional(l.object({}).passthrough())}).merge(Rt),qa=Ht.extend({method:l.literal("tools/list")}),mu=Bt.extend({tools:l.array(hu)}),pn=Ze.extend({content:l.array(fn).default([]),structuredContent:l.object({}).passthrough().optional(),isError:l.optional(l.boolean())}),gp=pn.or(Ze.extend({toolResult:l.unknown()})),Va=ke.extend({method:l.literal("tools/call"),params:Be.extend({name:l.string(),arguments:l.optional(l.record(l.unknown()))})}),vu=ir.extend({method:l.literal("notifications/tools/list_changed")}),Pt=l.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),za=ke.extend({method:l.literal("logging/setLevel"),params:Be.extend({level:Pt})}),gu=ir.extend({method:l.literal("notifications/message"),params:xt.extend({level:Pt,logger:l.optional(l.string()),data:l.unknown()})}),_u=l.object({name:l.string().optional()}).passthrough(),yu=l.object({hints:l.optional(l.array(_u)),costPriority:l.optional(l.number().min(0).max(1)),speedPriority:l.optional(l.number().min(0).max(1)),intelligencePriority:l.optional(l.number().min(0).max(1))}).passthrough(),Eu=l.object({role:l.enum(["user","assistant"]),content:l.union([Fa,Ma,Ua])}).passthrough(),bu=ke.extend({method:l.literal("sampling/createMessage"),params:Be.extend({messages:l.array(Eu),systemPrompt:l.optional(l.string()),includeContext:l.optional(l.enum(["none","thisServer","allServers"])),temperature:l.optional(l.number()),maxTokens:l.number().int(),stopSequences:l.optional(l.array(l.string())),metadata:l.optional(l.object({}).passthrough()),modelPreferences:l.optional(yu)})}),Ha=Ze.extend({model:l.string(),stopReason:l.optional(l.enum(["endTurn","stopSequence","maxTokens"]).or(l.string())),role:l.enum(["user","assistant"]),content:l.discriminatedUnion("type",[Fa,Ma,Ua])}),Su=l.object({type:l.literal("boolean"),title:l.optional(l.string()),description:l.optional(l.string()),default:l.optional(l.boolean())}).passthrough(),xu=l.object({type:l.literal("string"),title:l.optional(l.string()),description:l.optional(l.string()),minLength:l.optional(l.number()),maxLength:l.optional(l.number()),format:l.optional(l.enum(["email","uri","date","date-time"]))}).passthrough(),Ru=l.object({type:l.enum(["number","integer"]),title:l.optional(l.string()),description:l.optional(l.string()),minimum:l.optional(l.number()),maximum:l.optional(l.number())}).passthrough(),Tu=l.object({type:l.literal("string"),title:l.optional(l.string()),description:l.optional(l.string()),enum:l.array(l.string()),enumNames:l.optional(l.array(l.string()))}).passthrough(),Pu=l.union([Su,xu,Ru,Tu]),Ou=ke.extend({method:l.literal("elicitation/create"),params:Be.extend({message:l.string(),requestedSchema:l.object({type:l.literal("object"),properties:l.record(l.string(),Pu),required:l.optional(l.array(l.string()))}).passthrough()})}),Ba=Ze.extend({action:l.enum(["accept","decline","cancel"]),content:l.optional(l.record(l.string(),l.unknown()))}),wu=l.object({type:l.literal("ref/resource"),uri:l.string()}).passthrough();var Iu=l.object({type:l.literal("ref/prompt"),name:l.string()}).passthrough(),Nu=ke.extend({method:l.literal("completion/complete"),params:Be.extend({ref:l.union([Iu,wu]),argument:l.object({name:l.string(),value:l.string()}).passthrough(),context:l.optional(l.object({arguments:l.optional(l.record(l.string(),l.string()))}))})}),Au=Ze.extend({completion:l.object({values:l.array(l.string()).max(100),total:l.optional(l.number().int()),hasMore:l.optional(l.boolean())}).passthrough()}),Du=l.object({uri:l.string().startsWith("file://"),name:l.optional(l.string()),_meta:l.optional(l.object({}).passthrough())}).passthrough(),Cu=ke.extend({method:l.literal("roots/list")}),Za=Ze.extend({roots:l.array(Du)}),$u=ir.extend({method:l.literal("notifications/roots/list_changed")}),_p=l.union([Vt,ka,Nu,za,ou,nu,Xc,Qc,Kc,eu,ru,Va,qa]),yp=l.union([qt,zt,La,$u]),Ep=l.union([Ut,Ha,Ba,Za]),bp=l.union([Vt,bu,Ou,Cu]),Sp=l.union([qt,zt,gu,tu,Yc,vu,fu]),xp=l.union([Ut,Hc,Au,du,iu,Gc,Wc,Jc,pn,mu]),We=class extends Error{constructor(e,t,s){super(`MCP error ${e}: ${t}`),this.code=e,this.data=s,this.name="McpError"}};var ku=6e4,Zt=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(qt,t=>{let s=this._requestHandlerAbortControllers.get(t.params.requestId);s?.abort(t.params.reason)}),this.setNotificationHandler(zt,t=>{this._onprogress(t)}),this.setRequestHandler(Vt,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 We(Qe.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 i=(s=this.transport)===null||s===void 0?void 0:s.onerror;this._transport.onerror=c=>{i?.(c),this._onerror(c)};let o=(r=this._transport)===null||r===void 0?void 0:r.onmessage;this._transport.onmessage=(c,u)=>{o?.(c,u),$a(c)||sn(c)?this._onresponse(c):Ys(c)?this._onrequest(c,u):rn(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},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 We(Qe.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,i=this._transport;if(n===void 0){i?.send({jsonrpc:"2.0",id:e.id,error:{code:Qe.MethodNotFound,message:"Method not found"}}).catch(u=>this._onerror(new Error(`Failed to send an error response: ${u}`)));return}let o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);let c={signal:o.signal,sessionId:i?.sessionId,_meta:(r=e.params)===null||r===void 0?void 0:r._meta,sendNotification:u=>this.notification(u,{relatedRequestId:e.id}),sendRequest:(u,p,m)=>this.request(u,p,{...m,relatedRequestId:e.id}),authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo};Promise.resolve().then(()=>n(e,c)).then(u=>{if(!o.signal.aborted)return i?.send({result:u,jsonrpc:"2.0",id:e.id})},u=>{var p;if(!o.signal.aborted)return i?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(u.code)?u.code:Qe.InternalError,message:(p=u.message)!==null&&p!==void 0?p:"Internal error"}})}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).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 i=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(c){i(c);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),$a(e))s(e);else{let r=new We(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:i}=s??{};return new Promise((o,c)=>{var u,p,m,E,d,g;if(!this._transport){c(new Error("Not connected"));return}((u=this._options)===null||u===void 0?void 0:u.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 b=P=>{var N;this._responseHandlers.delete(_),this._progressHandlers.delete(_),this._cleanupTimeout(_),(N=this._transport)===null||N===void 0||N.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:_,reason:String(P)}},{relatedRequestId:r,resumptionToken:n,onresumptiontoken:i}).catch(A=>this._onerror(new Error(`Failed to send cancellation: ${A}`))),c(P)};this._responseHandlers.set(_,P=>{var N;if(!(!((N=s?.signal)===null||N===void 0)&&N.aborted)){if(P instanceof Error)return c(P);try{let A=t.parse(P.result);o(A)}catch(A){c(A)}}}),(E=s?.signal)===null||E===void 0||E.addEventListener("abort",()=>{var P;b((P=s?.signal)===null||P===void 0?void 0:P.reason)});let T=(d=s?.timeout)!==null&&d!==void 0?d:ku,R=()=>b(new We(Qe.RequestTimeout,"Request timed out",{timeout:T}));this._setupTimeout(_,T,s?.maxTotalTimeout,R,(g=s?.resetTimeoutOnProgress)!==null&&g!==void 0?g:!1),this._transport.send(v,{relatedRequestId:r,resumptionToken:n,onresumptiontoken:i}).catch(P=>{this._cleanupTimeout(_),c(P)})})}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 c;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let u={...e,jsonrpc:"2.0"};(c=this._transport)===null||c===void 0||c.send(u,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 hn(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 go=Il(vo(),1),da=class extends Zt{constructor(e,t){var s;super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Pt.options.map((r,n)=>[r,n])),this.isMessageIgnored=(r,n)=>{let i=this._loggingLevels.get(n);return i?this.LOG_LEVEL_SEVERITY.get(r)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=(s=t?.capabilities)!==null&&s!==void 0?s:{},this._instructions=t?.instructions,this.setRequestHandler(ka,r=>this._oninitialize(r)),this.setNotificationHandler(La,()=>{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 i;let o=n.sessionId||((i=n.requestInfo)===null||i===void 0?void 0:i.headers["mcp-session-id"])||void 0,{level:c}=r.params,u=Pt.safeParse(c);return u.success&&this._loggingLevels.set(o,u.data),{}})}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=hn(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:Qs.includes(t)?t:Ca,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"},Ut)}async createMessage(e,t){return this.request({method:"sampling/createMessage",params:e},Ha,t)}async elicitInput(e,t){let s=await this.request({method:"elicitation/create",params:e},Ba,t);if(s.action==="accept"&&s.content)try{let r=new go.default,n=r.compile(e.requestedSchema);if(!n(s.content))throw new We(Qe.InvalidParams,`Elicitation response content does not match requested schema: ${r.errorsText(n.errors)}`)}catch(r){throw r instanceof We?r:new We(Qe.InternalError,`Error validating elicitation response: ${r}`)}return s}async listRoots(e,t){return this.request({method:"roots/list",params:e},Za,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"})}};import yo from"node:process";var fa=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),mf(t)}clear(){this._buffer=void 0}};function mf(a){return nn.parse(JSON.parse(a))}function _o(a){return JSON.stringify(a)+`
|
|
`}var pa=class{constructor(e=yo.stdin,t=yo.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new fa,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=_o(e);this._stdout.write(s)?t():this._stdout.once("drain",t)})}};var bo=Symbol("Let zodToJsonSchema decide on which parser to use");var Eo={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"},So=a=>typeof a=="string"?{...Eo,name:a}:{...Eo,...a};var xo=a=>{let e=So(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 gs(a,e,t,s){s?.errorMessages&&t&&(a.errorMessage={...a.errorMessage,[e]:t})}function ee(a,e,t,s,r){a[e]=t,gs(a,e,s,r)}var ha=(a,e)=>{let t=0;for(;t<a.length&&t<e.length&&a[t]===e[t];t++);return[(a.length-t).toString(),...e.slice(t)].join("/")};function fe(a){if(a.target!=="openAi")return{};let e=[...a.basePath,a.definitionPath,a.openAiAnyTypeName];return a.flags.hasReferencedOpenAiAnyType=!0,{$ref:a.$refStrategy==="relative"?ha(e,a.currentPath):e.join("/")}}function Ro(a,e){let t={type:"array"};return a.type?._def&&a.type?._def?.typeName!==w.ZodAny&&(t.items=Z(a.type._def,{...e,currentPath:[...e.currentPath,"items"]})),a.minLength&&ee(t,"minItems",a.minLength.value,a.minLength.message,e),a.maxLength&&ee(t,"maxItems",a.maxLength.value,a.maxLength.message,e),a.exactLength&&(ee(t,"minItems",a.exactLength.value,a.exactLength.message,e),ee(t,"maxItems",a.exactLength.value,a.exactLength.message,e)),t}function To(a,e){let t={type:"integer",format:"int64"};if(!a.checks)return t;for(let s of a.checks)switch(s.kind){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 Po(){return{type:"boolean"}}function ma(a,e){return Z(a.type._def,e)}var Oo=(a,e)=>Z(a.innerType._def,e);function _s(a,e,t){let s=t??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,n)=>_s(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 vf(a,e)}}var vf=(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 wo(a,e){return{...Z(a.innerType._def,e),default:a.defaultValue()}}function Io(a,e){return e.effectStrategy==="input"?Z(a.schema._def,e):fe(e)}function No(a){return{type:"string",enum:Array.from(a.values)}}var gf=a=>"type"in a&&a.type==="string"?!1:"allOf"in a;function Ao(a,e){let t=[Z(a.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),Z(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(gf(n))r.push(...n.allOf),n.unevaluatedProperties===void 0&&(s=void 0);else{let i=n;if("additionalProperties"in n&&n.additionalProperties===!1){let{additionalProperties:o,...c}=n;i=c}else s=void 0;r.push(i)}}),r.length?{allOf:r,...s}:void 0}function Do(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 ys,Ke={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:()=>(ys===void 0&&(ys=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ys),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 va(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":Je(t,"email",s.message,e);break;case"format:idn-email":Je(t,"idn-email",s.message,e);break;case"pattern:zod":Ae(t,Ke.email,s.message,e);break}break;case"url":Je(t,"uri",s.message,e);break;case"uuid":Je(t,"uuid",s.message,e);break;case"regex":Ae(t,s.regex,s.message,e);break;case"cuid":Ae(t,Ke.cuid,s.message,e);break;case"cuid2":Ae(t,Ke.cuid2,s.message,e);break;case"startsWith":Ae(t,RegExp(`^${Es(s.value,e)}`),s.message,e);break;case"endsWith":Ae(t,RegExp(`${Es(s.value,e)}$`),s.message,e);break;case"datetime":Je(t,"date-time",s.message,e);break;case"date":Je(t,"date",s.message,e);break;case"time":Je(t,"time",s.message,e);break;case"duration":Je(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":{Ae(t,RegExp(Es(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&Je(t,"ipv4",s.message,e),s.version!=="v4"&&Je(t,"ipv6",s.message,e);break}case"base64url":Ae(t,Ke.base64url,s.message,e);break;case"jwt":Ae(t,Ke.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&Ae(t,Ke.ipv4Cidr,s.message,e),s.version!=="v4"&&Ae(t,Ke.ipv6Cidr,s.message,e);break}case"emoji":Ae(t,Ke.emoji(),s.message,e);break;case"ulid":{Ae(t,Ke.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Je(t,"binary",s.message,e);break}case"contentEncoding:base64":{ee(t,"contentEncoding","base64",s.message,e);break}case"pattern:zod":{Ae(t,Ke.base64,s.message,e);break}}break}case"nanoid":Ae(t,Ke.nanoid,s.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return t}function Es(a,e){return e.patternStrategy==="escape"?yf(a):a}var _f=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function yf(a){let e="";for(let t=0;t<a.length;t++)_f.has(a[t])||(e+="\\"),e+=a[t];return e}function Je(a,e,t,s){a.format||a.anyOf?.some(r=>r.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 Ae(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:Co(e,s),...t&&s.errorMessages&&{errorMessage:{pattern:t}}})):ee(a,"pattern",Co(e,s),t,s)}function Co(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,i=!1,o=!1;for(let c=0;c<s.length;c++){if(n){r+=s[c],n=!1;continue}if(t.i){if(i){if(s[c].match(/[a-z]/)){o?(r+=s[c],r+=`${s[c-2]}-${s[c]}`.toUpperCase(),o=!1):s[c+1]==="-"&&s[c+2]?.match(/[a-z]/)?(r+=s[c],o=!0):r+=`${s[c]}${s[c].toUpperCase()}`;continue}}else if(s[c].match(/[a-z]/)){r+=`[${s[c]}${s[c].toUpperCase()}]`;continue}}if(t.m){if(s[c]==="^"){r+=`(^|(?<=[\r
|
|
]))`;continue}else if(s[c]==="$"){r+=`($|(?=[\r
|
|
]))`;continue}}if(t.s&&s[c]==="."){r+=i?`${s[c]}\r
|
|
`:`[${s[c]}\r
|
|
]`;continue}r+=s[c],s[c]==="\\"?n=!0:i&&s[c]==="]"?i=!1:!i&&s[c]==="["&&(i=!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 ga(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===w.ZodEnum)return{type:"object",required:a.keyType._def.values,properties:a.keyType._def.values.reduce((s,r)=>({...s,[r]:Z(a.valueType._def,{...e,currentPath:[...e.currentPath,"properties",r]})??fe(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let t={type:"object",additionalProperties:Z(a.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return t;if(a.keyType?._def.typeName===w.ZodString&&a.keyType._def.checks?.length){let{type:s,...r}=va(a.keyType._def,e);return{...t,propertyNames:r}}else{if(a.keyType?._def.typeName===w.ZodEnum)return{...t,propertyNames:{enum:a.keyType._def.values}};if(a.keyType?._def.typeName===w.ZodBranded&&a.keyType._def.type._def.typeName===w.ZodString&&a.keyType._def.type._def.checks?.length){let{type:s,...r}=ma(a.keyType._def,e);return{...t,propertyNames:r}}}return t}function $o(a,e){if(e.mapStrategy==="record")return ga(a,e);let t=Z(a.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||fe(e),s=Z(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 ko(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 Lo(a){return a.target==="openAi"?void 0:{not:fe({...a,currentPath:[...a.currentPath,"not"]})}}function jo(a){return a.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var wt={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Mo(a,e){if(e.target==="openApi3")return Fo(a,e);let t=a.options instanceof Map?Array.from(a.options.values()):a.options;if(t.every(s=>s._def.typeName in wt&&(!s._def.checks||!s._def.checks.length))){let s=t.reduce((r,n)=>{let i=wt[n._def.typeName];return i&&!r.includes(i)?[...r,i]: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 i=typeof n._def.value;switch(i){case"string":case"number":case"boolean":return[...r,i];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,i,o)=>o.indexOf(n)===i);return{type:r.length>1?r:r[0],enum:t.reduce((n,i)=>n.includes(i._def.value)?n:[...n,i._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 Fo(a,e)}var Fo=(a,e)=>{let t=(a.options instanceof Map?Array.from(a.options.values()):a.options).map((s,r)=>Z(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 Uo(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:wt[a.innerType._def.typeName],nullable:!0}:{type:[wt[a.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let s=Z(a.innerType._def,{...e,currentPath:[...e.currentPath]});return s&&"$ref"in s?{allOf:[s],nullable:!0}:s&&{...s,nullable:!0}}let t=Z(a.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}function qo(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",gs(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 Vo(a,e){let t=e.target==="openAi",s={type:"object",properties:{}},r=[],n=a.shape();for(let o in n){let c=n[o];if(c===void 0||c._def===void 0)continue;let u=bf(c);u&&t&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let p=Z(c._def,{...e,currentPath:[...e.currentPath,"properties",o],propertyPath:[...e.currentPath,"properties",o]});p!==void 0&&(s.properties[o]=p,u||r.push(o))}r.length&&(s.required=r);let i=Ef(a,e);return i!==void 0&&(s.additionalProperties=i),s}function Ef(a,e){if(a.catchall._def.typeName!=="ZodNever")return Z(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 bf(a){try{return a.isOptional()}catch{return!0}}var zo=(a,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return Z(a.innerType._def,e);let t=Z(a.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:fe(e)},t]}:fe(e)};var Ho=(a,e)=>{if(e.pipeStrategy==="input")return Z(a.in._def,e);if(e.pipeStrategy==="output")return Z(a.out._def,e);let t=Z(a.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=Z(a.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return{allOf:[t,s].filter(r=>r!==void 0)}};function Bo(a,e){return Z(a.type._def,e)}function Zo(a,e){let s={type:"array",uniqueItems:!0,items:Z(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 Xo(a,e){return a.rest?{type:"array",minItems:a.items.length,items:a.items.map((t,s)=>Z(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[]),additionalItems:Z(a.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:a.items.length,maxItems:a.items.length,items:a.items.map((t,s)=>Z(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[])}}function Go(a){return{not:fe(a)}}function Qo(a){return fe(a)}var Wo=(a,e)=>Z(a.innerType._def,e);var Ko=(a,e,t)=>{switch(e){case w.ZodString:return va(a,t);case w.ZodNumber:return qo(a,t);case w.ZodObject:return Vo(a,t);case w.ZodBigInt:return To(a,t);case w.ZodBoolean:return Po();case w.ZodDate:return _s(a,t);case w.ZodUndefined:return Go(t);case w.ZodNull:return jo(t);case w.ZodArray:return Ro(a,t);case w.ZodUnion:case w.ZodDiscriminatedUnion:return Mo(a,t);case w.ZodIntersection:return Ao(a,t);case w.ZodTuple:return Xo(a,t);case w.ZodRecord:return ga(a,t);case w.ZodLiteral:return Do(a,t);case w.ZodEnum:return No(a);case w.ZodNativeEnum:return ko(a);case w.ZodNullable:return Uo(a,t);case w.ZodOptional:return zo(a,t);case w.ZodMap:return $o(a,t);case w.ZodSet:return Zo(a,t);case w.ZodLazy:return()=>a.getter()._def;case w.ZodPromise:return Bo(a,t);case w.ZodNaN:case w.ZodNever:return Lo(t);case w.ZodEffects:return Io(a,t);case w.ZodAny:return fe(t);case w.ZodUnknown:return Qo(t);case w.ZodDefault:return wo(a,t);case w.ZodBranded:return ma(a,t);case w.ZodReadonly:return Wo(a,t);case w.ZodCatch:return Oo(a,t);case w.ZodPipeline:return Ho(a,t);case w.ZodFunction:case w.ZodVoid:case w.ZodSymbol:return;default:return(s=>{})(e)}};function Z(a,e,t=!1){let s=e.seen.get(a);if(e.override){let o=e.override?.(a,e,s,t);if(o!==bo)return o}if(s&&!t){let o=Sf(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=Ko(a,a.typeName,e),i=typeof n=="function"?Z(n(),e):n;if(i&&xf(a,e,i),e.postProcess){let o=e.postProcess(i,a,e);return r.jsonSchema=i,o}return r.jsonSchema=i,i}var Sf=(a,e)=>{switch(e.$refStrategy){case"root":return{$ref:a.path.join("/")};case"relative":return{$ref:ha(e.currentPath,a.path)};case"none":case"seen":return a.path.length<e.currentPath.length&&a.path.every((t,s)=>e.currentPath[s]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),fe(e)):e.$refStrategy==="seen"?fe(e):void 0}},xf=(a,e,t)=>(a.description&&(t.description=a.description,e.markdownDescription&&(t.markdownDescription=a.description)),t);var bs=(a,e)=>{let t=xo(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,p])=>({...c,[u]:Z(p._def,{...t,currentPath:[...t.basePath,t.definitionPath,u]},!0)??fe(t)}),{}):void 0,r=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,n=Z(a._def,r===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,r]},!1)??fe(t),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(n.title=i),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};import{basename as Nf}from"path";import wf from"better-sqlite3";import{join as Ye,dirname as Rf,basename as _g}from"path";import{homedir as Jo}from"os";import{existsSync as Sg,mkdirSync as Tf}from"fs";import{fileURLToPath as Pf}from"url";function Of(){return typeof __dirname<"u"?__dirname:Rf(Pf(import.meta.url))}var Rg=Of(),or=process.env.CLAUDE_MEM_DATA_DIR||Ye(Jo(),".claude-mem"),Ss=process.env.CLAUDE_CONFIG_DIR||Ye(Jo(),".claude"),Tg=Ye(or,"archives"),Pg=Ye(or,"logs"),Og=Ye(or,"trash"),wg=Ye(or,"backups"),Ig=Ye(or,"settings.json"),_a=Ye(or,"claude-mem.db"),Ng=Ye(Ss,"settings.json"),Ag=Ye(Ss,"commands"),Dg=Ye(Ss,"CLAUDE.md");function ya(a){Tf(a,{recursive:!0})}var Ea=class{db;constructor(e){e||(ya(or),e=_a),this.db=new wf(e),this.db.pragma("journal_mode = WAL"),this.ensureFTSTables()}ensureFTSTables(){try{if(this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%_fts'").all().some(s=>s.name==="observations_fts"||s.name==="session_summaries_fts"))return;console.error("[SessionSearch] Creating FTS5 tables..."),this.db.exec(`
|
|
CREATE VIRTUAL TABLE IF NOT EXISTS observations_fts USING fts5(
|
|
title,
|
|
subtitle,
|
|
narrative,
|
|
text,
|
|
facts,
|
|
concepts,
|
|
content='observations',
|
|
content_rowid='id'
|
|
);
|
|
`),this.db.exec(`
|
|
INSERT INTO observations_fts(rowid, title, subtitle, narrative, text, facts, concepts)
|
|
SELECT id, title, subtitle, narrative, text, facts, concepts
|
|
FROM observations;
|
|
`),this.db.exec(`
|
|
CREATE TRIGGER IF NOT EXISTS observations_ai AFTER INSERT ON observations BEGIN
|
|
INSERT INTO observations_fts(rowid, title, subtitle, narrative, text, facts, concepts)
|
|
VALUES (new.id, new.title, new.subtitle, new.narrative, new.text, new.facts, new.concepts);
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS observations_ad AFTER DELETE ON observations BEGIN
|
|
INSERT INTO observations_fts(observations_fts, rowid, title, subtitle, narrative, text, facts, concepts)
|
|
VALUES('delete', old.id, old.title, old.subtitle, old.narrative, old.text, old.facts, old.concepts);
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS observations_au AFTER UPDATE ON observations BEGIN
|
|
INSERT INTO observations_fts(observations_fts, rowid, title, subtitle, narrative, text, facts, concepts)
|
|
VALUES('delete', old.id, old.title, old.subtitle, old.narrative, old.text, old.facts, old.concepts);
|
|
INSERT INTO observations_fts(rowid, title, subtitle, narrative, text, facts, concepts)
|
|
VALUES (new.id, new.title, new.subtitle, new.narrative, new.text, new.facts, new.concepts);
|
|
END;
|
|
`),this.db.exec(`
|
|
CREATE VIRTUAL TABLE IF NOT EXISTS session_summaries_fts USING fts5(
|
|
request,
|
|
investigated,
|
|
learned,
|
|
completed,
|
|
next_steps,
|
|
notes,
|
|
content='session_summaries',
|
|
content_rowid='id'
|
|
);
|
|
`),this.db.exec(`
|
|
INSERT INTO session_summaries_fts(rowid, request, investigated, learned, completed, next_steps, notes)
|
|
SELECT id, request, investigated, learned, completed, next_steps, notes
|
|
FROM session_summaries;
|
|
`),this.db.exec(`
|
|
CREATE TRIGGER IF NOT EXISTS session_summaries_ai AFTER INSERT ON session_summaries BEGIN
|
|
INSERT INTO session_summaries_fts(rowid, request, investigated, learned, completed, next_steps, notes)
|
|
VALUES (new.id, new.request, new.investigated, new.learned, new.completed, new.next_steps, new.notes);
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS session_summaries_ad AFTER DELETE ON session_summaries BEGIN
|
|
INSERT INTO session_summaries_fts(session_summaries_fts, rowid, request, investigated, learned, completed, next_steps, notes)
|
|
VALUES('delete', old.id, old.request, old.investigated, old.learned, old.completed, old.next_steps, old.notes);
|
|
END;
|
|
|
|
CREATE TRIGGER IF NOT EXISTS session_summaries_au AFTER UPDATE ON session_summaries BEGIN
|
|
INSERT INTO session_summaries_fts(session_summaries_fts, rowid, request, investigated, learned, completed, next_steps, notes)
|
|
VALUES('delete', old.id, old.request, old.investigated, old.learned, old.completed, old.next_steps, old.notes);
|
|
INSERT INTO session_summaries_fts(rowid, request, investigated, learned, completed, next_steps, notes)
|
|
VALUES (new.id, new.request, new.investigated, new.learned, new.completed, new.next_steps, new.notes);
|
|
END;
|
|
`),console.error("[SessionSearch] FTS5 tables created successfully")}catch(e){console.error("[SessionSearch] FTS migration error:",e.message)}}escapeFTS5(e){return`"${e.replace(/"/g,'""')}"`}buildFilterClause(e,t,s="o"){let r=[];if(e.project&&(r.push(`${s}.project = ?`),t.push(e.project)),e.type)if(Array.isArray(e.type)){let n=e.type.map(()=>"?").join(",");r.push(`${s}.type IN (${n})`),t.push(...e.type)}else r.push(`${s}.type = ?`),t.push(e.type);if(e.dateRange){let{start:n,end:i}=e.dateRange;if(n){let o=typeof n=="number"?n:new Date(n).getTime();r.push(`${s}.created_at_epoch >= ?`),t.push(o)}if(i){let o=typeof i=="number"?i:new Date(i).getTime();r.push(`${s}.created_at_epoch <= ?`),t.push(o)}}if(e.concepts){let n=Array.isArray(e.concepts)?e.concepts:[e.concepts],i=n.map(()=>`EXISTS (SELECT 1 FROM json_each(${s}.concepts) WHERE value = ?)`);i.length>0&&(r.push(`(${i.join(" OR ")})`),t.push(...n))}if(e.files){let n=Array.isArray(e.files)?e.files:[e.files],i=n.map(()=>`(
|
|
EXISTS (SELECT 1 FROM json_each(${s}.files_read) WHERE value LIKE ?)
|
|
OR EXISTS (SELECT 1 FROM json_each(${s}.files_modified) WHERE value LIKE ?)
|
|
)`);i.length>0&&(r.push(`(${i.join(" OR ")})`),n.forEach(o=>{t.push(`%${o}%`,`%${o}%`)}))}return r.length>0?r.join(" AND "):""}buildOrderClause(e="relevance",t=!0,s="observations_fts"){switch(e){case"relevance":return t?`ORDER BY ${s}.rank ASC`:"ORDER BY o.created_at_epoch DESC";case"date_desc":return"ORDER BY o.created_at_epoch DESC";case"date_asc":return"ORDER BY o.created_at_epoch ASC";default:return"ORDER BY o.created_at_epoch DESC"}}searchObservations(e,t={}){let s=[],{limit:r=50,offset:n=0,orderBy:i="relevance",...o}=t,c=this.escapeFTS5(e);s.push(c);let u=this.buildFilterClause(o,s,"o"),p=u?`AND ${u}`:"",m=this.buildOrderClause(i,!0),E=`
|
|
SELECT
|
|
o.*,
|
|
observations_fts.rank as rank
|
|
FROM observations o
|
|
JOIN observations_fts ON o.id = observations_fts.rowid
|
|
WHERE observations_fts MATCH ?
|
|
${p}
|
|
${m}
|
|
LIMIT ? OFFSET ?
|
|
`;s.push(r,n);let d=this.db.prepare(E).all(...s);if(d.length>0){let g=Math.min(...d.map(b=>b.rank||0)),v=Math.max(...d.map(b=>b.rank||0))-g||1;d.forEach(b=>{b.rank!==void 0&&(b.score=1-(b.rank-g)/v)})}return d}searchSessions(e,t={}){let s=[],{limit:r=50,offset:n=0,orderBy:i="relevance",...o}=t,c=this.escapeFTS5(e);s.push(c);let u={...o};delete u.type;let p=this.buildFilterClause(u,s,"s"),g=`
|
|
SELECT
|
|
s.*,
|
|
session_summaries_fts.rank as rank
|
|
FROM session_summaries s
|
|
JOIN session_summaries_fts ON s.id = session_summaries_fts.rowid
|
|
WHERE session_summaries_fts MATCH ?
|
|
${(p?`AND ${p}`:"").replace(/files_read/g,"files_read").replace(/files_modified/g,"files_edited")}
|
|
${i==="relevance"?"ORDER BY session_summaries_fts.rank ASC":i==="date_asc"?"ORDER BY s.created_at_epoch ASC":"ORDER BY s.created_at_epoch DESC"}
|
|
LIMIT ? OFFSET ?
|
|
`;s.push(r,n);let _=this.db.prepare(g).all(...s);if(_.length>0){let v=Math.min(..._.map(R=>R.rank||0)),T=Math.max(..._.map(R=>R.rank||0))-v||1;_.forEach(R=>{R.rank!==void 0&&(R.score=1-(R.rank-v)/T)})}return _}findByConcept(e,t={}){let s=[],{limit:r=50,offset:n=0,orderBy:i="date_desc",...o}=t,c={...o,concepts:e},u=this.buildFilterClause(c,s,"o"),p=this.buildOrderClause(i,!1),m=`
|
|
SELECT o.*
|
|
FROM observations o
|
|
WHERE ${u}
|
|
${p}
|
|
LIMIT ? OFFSET ?
|
|
`;return s.push(r,n),this.db.prepare(m).all(...s)}findByFile(e,t={}){let s=[],{limit:r=50,offset:n=0,orderBy:i="date_desc",...o}=t,c={...o,files:e},u=this.buildFilterClause(c,s,"o"),p=this.buildOrderClause(i,!1),m=`
|
|
SELECT o.*
|
|
FROM observations o
|
|
WHERE ${u}
|
|
${p}
|
|
LIMIT ? OFFSET ?
|
|
`;s.push(r,n);let E=this.db.prepare(m).all(...s),d=[],g={...o};delete g.type;let _=[];if(g.project&&(_.push("s.project = ?"),d.push(g.project)),g.dateRange){let{start:T,end:R}=g.dateRange;if(T){let P=typeof T=="number"?T:new Date(T).getTime();_.push("s.created_at_epoch >= ?"),d.push(P)}if(R){let P=typeof R=="number"?R:new Date(R).getTime();_.push("s.created_at_epoch <= ?"),d.push(P)}}_.push(`(
|
|
EXISTS (SELECT 1 FROM json_each(s.files_read) WHERE value LIKE ?)
|
|
OR EXISTS (SELECT 1 FROM json_each(s.files_edited) WHERE value LIKE ?)
|
|
)`),d.push(`%${e}%`,`%${e}%`);let v=`
|
|
SELECT s.*
|
|
FROM session_summaries s
|
|
WHERE ${_.join(" AND ")}
|
|
ORDER BY s.created_at_epoch DESC
|
|
LIMIT ? OFFSET ?
|
|
`;d.push(r,n);let b=this.db.prepare(v).all(...d);return{observations:E,sessions:b}}findByType(e,t={}){let s=[],{limit:r=50,offset:n=0,orderBy:i="date_desc",...o}=t,c={...o,type:e},u=this.buildFilterClause(c,s,"o"),p=this.buildOrderClause(i,!1),m=`
|
|
SELECT o.*
|
|
FROM observations o
|
|
WHERE ${u}
|
|
${p}
|
|
LIMIT ? OFFSET ?
|
|
`;return s.push(r,n),this.db.prepare(m).all(...s)}searchUserPrompts(e,t={}){let s=[],{limit:r=20,offset:n=0,orderBy:i="relevance",...o}=t,c=this.escapeFTS5(e);s.push(c);let u=[];if(o.project&&(u.push("s.project = ?"),s.push(o.project)),o.dateRange){let{start:g,end:_}=o.dateRange;if(g){let v=typeof g=="number"?g:new Date(g).getTime();u.push("up.created_at_epoch >= ?"),s.push(v)}if(_){let v=typeof _=="number"?_:new Date(_).getTime();u.push("up.created_at_epoch <= ?"),s.push(v)}}let E=`
|
|
SELECT
|
|
up.*,
|
|
user_prompts_fts.rank as rank
|
|
FROM user_prompts up
|
|
JOIN user_prompts_fts ON up.id = user_prompts_fts.rowid
|
|
JOIN sdk_sessions s ON up.claude_session_id = s.claude_session_id
|
|
WHERE user_prompts_fts MATCH ?
|
|
${u.length>0?`AND ${u.join(" AND ")}`:""}
|
|
${i==="relevance"?"ORDER BY user_prompts_fts.rank ASC":i==="date_asc"?"ORDER BY up.created_at_epoch ASC":"ORDER BY up.created_at_epoch DESC"}
|
|
LIMIT ? OFFSET ?
|
|
`;s.push(r,n);let d=this.db.prepare(E).all(...s);if(d.length>0){let g=Math.min(...d.map(b=>b.rank||0)),v=Math.max(...d.map(b=>b.rank||0))-g||1;d.forEach(b=>{b.rank!==void 0&&(b.score=1-(b.rank-g)/v)})}return d}getUserPromptsBySession(e){return this.db.prepare(`
|
|
SELECT
|
|
id,
|
|
claude_session_id,
|
|
prompt_number,
|
|
prompt_text,
|
|
created_at,
|
|
created_at_epoch
|
|
FROM user_prompts
|
|
WHERE claude_session_id = ?
|
|
ORDER BY prompt_number ASC
|
|
`).all(e)}close(){this.db.close()}};import If from"better-sqlite3";var xs=(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))(xs||{}),Rs=class{level;useColor;constructor(){let e=process.env.CLAUDE_MEM_LOG_LEVEL?.toUpperCase()||"INFO";this.level=xs[e]??1,this.useColor=process.stdout.isTTY??!1}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.level===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}}log(e,t,s,r,n){if(e<this.level)return;let i=new Date().toISOString().replace("T"," ").substring(0,23),o=xs[e].padEnd(5),c=t.padEnd(6),u="";r?.correlationId?u=`[${r.correlationId}] `:r?.sessionId&&(u=`[session-${r.sessionId}] `);let p="";n!=null&&(this.level===0&&typeof n=="object"?p=`
|
|
`+JSON.stringify(n,null,2):p=" "+this.formatData(n));let m="";if(r){let{sessionId:d,sdkSessionId:g,correlationId:_,...v}=r;Object.keys(v).length>0&&(m=` {${Object.entries(v).map(([T,R])=>`${T}=${R}`).join(", ")}}`)}let E=`[${i}] [${o}] [${c}] ${u}${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`})}},Yo=new Rs;var ba=class{db;constructor(){ya(or),this.db=new If(_a),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),this.initializeSchema(),this.ensureWorkerPortColumn(),this.ensurePromptTrackingColumns(),this.removeSessionSummariesUniqueConstraint(),this.addObservationHierarchicalFields(),this.makeObservationsTextNullable(),this.createUserPromptsTable()}initializeSchema(){try{this.db.exec(`
|
|
CREATE TABLE IF NOT EXISTS schema_versions (
|
|
id INTEGER PRIMARY KEY,
|
|
version INTEGER UNIQUE NOT NULL,
|
|
applied_at TEXT NOT NULL
|
|
)
|
|
`);let e=this.db.prepare("SELECT version FROM schema_versions ORDER BY version").all();(e.length>0?Math.max(...e.map(s=>s.version)):0)===0&&(console.error("[SessionStore] Initializing fresh database with migration004..."),this.db.exec(`
|
|
CREATE TABLE IF NOT EXISTS sdk_sessions (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
claude_session_id TEXT UNIQUE NOT NULL,
|
|
sdk_session_id TEXT UNIQUE,
|
|
project TEXT NOT NULL,
|
|
user_prompt TEXT,
|
|
started_at TEXT NOT NULL,
|
|
started_at_epoch INTEGER NOT NULL,
|
|
completed_at TEXT,
|
|
completed_at_epoch INTEGER,
|
|
status TEXT CHECK(status IN ('active', 'completed', 'failed')) NOT NULL DEFAULT 'active'
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_sdk_sessions_claude_id ON sdk_sessions(claude_session_id);
|
|
CREATE INDEX IF NOT EXISTS idx_sdk_sessions_sdk_id ON sdk_sessions(sdk_session_id);
|
|
CREATE INDEX IF NOT EXISTS idx_sdk_sessions_project ON sdk_sessions(project);
|
|
CREATE INDEX IF NOT EXISTS idx_sdk_sessions_status ON sdk_sessions(status);
|
|
CREATE INDEX IF NOT EXISTS idx_sdk_sessions_started ON sdk_sessions(started_at_epoch DESC);
|
|
|
|
CREATE TABLE IF NOT EXISTS observations (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
sdk_session_id TEXT NOT NULL,
|
|
project TEXT NOT NULL,
|
|
text TEXT NOT NULL,
|
|
type TEXT NOT NULL CHECK(type IN ('decision', 'bugfix', 'feature', 'refactor', 'discovery')),
|
|
created_at TEXT NOT NULL,
|
|
created_at_epoch INTEGER NOT NULL,
|
|
FOREIGN KEY(sdk_session_id) REFERENCES sdk_sessions(sdk_session_id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_observations_sdk_session ON observations(sdk_session_id);
|
|
CREATE INDEX IF NOT EXISTS idx_observations_project ON observations(project);
|
|
CREATE INDEX IF NOT EXISTS idx_observations_type ON observations(type);
|
|
CREATE INDEX IF NOT EXISTS idx_observations_created ON observations(created_at_epoch DESC);
|
|
|
|
CREATE TABLE IF NOT EXISTS session_summaries (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
sdk_session_id TEXT UNIQUE NOT NULL,
|
|
project TEXT NOT NULL,
|
|
request TEXT,
|
|
investigated TEXT,
|
|
learned TEXT,
|
|
completed TEXT,
|
|
next_steps TEXT,
|
|
files_read TEXT,
|
|
files_edited TEXT,
|
|
notes TEXT,
|
|
created_at TEXT NOT NULL,
|
|
created_at_epoch INTEGER NOT NULL,
|
|
FOREIGN KEY(sdk_session_id) REFERENCES sdk_sessions(sdk_session_id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_session_summaries_sdk_session ON session_summaries(sdk_session_id);
|
|
CREATE INDEX IF NOT EXISTS idx_session_summaries_project ON session_summaries(project);
|
|
CREATE INDEX IF NOT EXISTS idx_session_summaries_created ON session_summaries(created_at_epoch DESC);
|
|
`),this.db.prepare("INSERT INTO schema_versions (version, applied_at) VALUES (?, ?)").run(4,new Date().toISOString()),console.error("[SessionStore] Migration004 applied successfully"))}catch(e){throw console.error("[SessionStore] Schema initialization error:",e.message),e}}ensureWorkerPortColumn(){try{if(this.db.prepare("SELECT version FROM schema_versions WHERE version = ?").get(5))return;this.db.pragma("table_info(sdk_sessions)").some(r=>r.name==="worker_port")||(this.db.exec("ALTER TABLE sdk_sessions ADD COLUMN worker_port INTEGER"),console.error("[SessionStore] Added worker_port column to sdk_sessions table")),this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(5,new Date().toISOString())}catch(e){console.error("[SessionStore] Migration error:",e.message)}}ensurePromptTrackingColumns(){try{if(this.db.prepare("SELECT version FROM schema_versions WHERE version = ?").get(6))return;this.db.pragma("table_info(sdk_sessions)").some(c=>c.name==="prompt_counter")||(this.db.exec("ALTER TABLE sdk_sessions ADD COLUMN prompt_counter INTEGER DEFAULT 0"),console.error("[SessionStore] Added prompt_counter column to sdk_sessions table")),this.db.pragma("table_info(observations)").some(c=>c.name==="prompt_number")||(this.db.exec("ALTER TABLE observations ADD COLUMN prompt_number INTEGER"),console.error("[SessionStore] Added prompt_number column to observations table")),this.db.pragma("table_info(session_summaries)").some(c=>c.name==="prompt_number")||(this.db.exec("ALTER TABLE session_summaries ADD COLUMN prompt_number INTEGER"),console.error("[SessionStore] Added prompt_number column to session_summaries table")),this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(6,new Date().toISOString())}catch(e){console.error("[SessionStore] Prompt tracking migration error:",e.message)}}removeSessionSummariesUniqueConstraint(){try{if(this.db.prepare("SELECT version FROM schema_versions WHERE version = ?").get(7))return;if(!this.db.pragma("index_list(session_summaries)").some(r=>r.unique===1)){this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(7,new Date().toISOString());return}console.error("[SessionStore] Removing UNIQUE constraint from session_summaries.sdk_session_id..."),this.db.exec("BEGIN TRANSACTION");try{this.db.exec(`
|
|
CREATE TABLE session_summaries_new (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
sdk_session_id TEXT NOT NULL,
|
|
project TEXT NOT NULL,
|
|
request TEXT,
|
|
investigated TEXT,
|
|
learned TEXT,
|
|
completed TEXT,
|
|
next_steps TEXT,
|
|
files_read TEXT,
|
|
files_edited TEXT,
|
|
notes TEXT,
|
|
prompt_number INTEGER,
|
|
created_at TEXT NOT NULL,
|
|
created_at_epoch INTEGER NOT NULL,
|
|
FOREIGN KEY(sdk_session_id) REFERENCES sdk_sessions(sdk_session_id) ON DELETE CASCADE
|
|
)
|
|
`),this.db.exec(`
|
|
INSERT INTO session_summaries_new
|
|
SELECT id, sdk_session_id, project, request, investigated, learned,
|
|
completed, next_steps, files_read, files_edited, notes,
|
|
prompt_number, created_at, created_at_epoch
|
|
FROM session_summaries
|
|
`),this.db.exec("DROP TABLE session_summaries"),this.db.exec("ALTER TABLE session_summaries_new RENAME TO session_summaries"),this.db.exec(`
|
|
CREATE INDEX idx_session_summaries_sdk_session ON session_summaries(sdk_session_id);
|
|
CREATE INDEX idx_session_summaries_project ON session_summaries(project);
|
|
CREATE INDEX idx_session_summaries_created ON session_summaries(created_at_epoch DESC);
|
|
`),this.db.exec("COMMIT"),this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(7,new Date().toISOString()),console.error("[SessionStore] Successfully removed UNIQUE constraint from session_summaries.sdk_session_id")}catch(r){throw this.db.exec("ROLLBACK"),r}}catch(e){console.error("[SessionStore] Migration error (remove UNIQUE constraint):",e.message)}}addObservationHierarchicalFields(){try{if(this.db.prepare("SELECT version FROM schema_versions WHERE version = ?").get(8))return;if(this.db.pragma("table_info(observations)").some(r=>r.name==="title")){this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(8,new Date().toISOString());return}console.error("[SessionStore] Adding hierarchical fields to observations table..."),this.db.exec(`
|
|
ALTER TABLE observations ADD COLUMN title TEXT;
|
|
ALTER TABLE observations ADD COLUMN subtitle TEXT;
|
|
ALTER TABLE observations ADD COLUMN facts TEXT;
|
|
ALTER TABLE observations ADD COLUMN narrative TEXT;
|
|
ALTER TABLE observations ADD COLUMN concepts TEXT;
|
|
ALTER TABLE observations ADD COLUMN files_read TEXT;
|
|
ALTER TABLE observations ADD COLUMN files_modified TEXT;
|
|
`),this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(8,new Date().toISOString()),console.error("[SessionStore] Successfully added hierarchical fields to observations table")}catch(e){console.error("[SessionStore] Migration error (add hierarchical fields):",e.message)}}makeObservationsTextNullable(){try{if(this.db.prepare("SELECT version FROM schema_versions WHERE version = ?").get(9))return;let s=this.db.pragma("table_info(observations)").find(r=>r.name==="text");if(!s||s.notnull===0){this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(9,new Date().toISOString());return}console.error("[SessionStore] Making observations.text nullable..."),this.db.exec("BEGIN TRANSACTION");try{this.db.exec(`
|
|
CREATE TABLE observations_new (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
sdk_session_id TEXT NOT NULL,
|
|
project TEXT NOT NULL,
|
|
text TEXT,
|
|
type TEXT NOT NULL CHECK(type IN ('decision', 'bugfix', 'feature', 'refactor', 'discovery', 'change')),
|
|
title TEXT,
|
|
subtitle TEXT,
|
|
facts TEXT,
|
|
narrative TEXT,
|
|
concepts TEXT,
|
|
files_read TEXT,
|
|
files_modified TEXT,
|
|
prompt_number INTEGER,
|
|
created_at TEXT NOT NULL,
|
|
created_at_epoch INTEGER NOT NULL,
|
|
FOREIGN KEY(sdk_session_id) REFERENCES sdk_sessions(sdk_session_id) ON DELETE CASCADE
|
|
)
|
|
`),this.db.exec(`
|
|
INSERT INTO observations_new
|
|
SELECT id, sdk_session_id, project, text, type, title, subtitle, facts,
|
|
narrative, concepts, files_read, files_modified, prompt_number,
|
|
created_at, created_at_epoch
|
|
FROM observations
|
|
`),this.db.exec("DROP TABLE observations"),this.db.exec("ALTER TABLE observations_new RENAME TO observations"),this.db.exec(`
|
|
CREATE INDEX idx_observations_sdk_session ON observations(sdk_session_id);
|
|
CREATE INDEX idx_observations_project ON observations(project);
|
|
CREATE INDEX idx_observations_type ON observations(type);
|
|
CREATE INDEX idx_observations_created ON observations(created_at_epoch DESC);
|
|
`),this.db.exec("COMMIT"),this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(9,new Date().toISOString()),console.error("[SessionStore] Successfully made observations.text nullable")}catch(r){throw this.db.exec("ROLLBACK"),r}}catch(e){console.error("[SessionStore] Migration error (make text nullable):",e.message)}}createUserPromptsTable(){try{if(this.db.prepare("SELECT version FROM schema_versions WHERE version = ?").get(10))return;if(this.db.pragma("table_info(user_prompts)").length>0){this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(10,new Date().toISOString());return}console.error("[SessionStore] Creating user_prompts table with FTS5 support..."),this.db.exec("BEGIN TRANSACTION");try{this.db.exec(`
|
|
CREATE TABLE user_prompts (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
claude_session_id TEXT NOT NULL,
|
|
prompt_number INTEGER NOT NULL,
|
|
prompt_text TEXT NOT NULL,
|
|
created_at TEXT NOT NULL,
|
|
created_at_epoch INTEGER NOT NULL,
|
|
FOREIGN KEY(claude_session_id) REFERENCES sdk_sessions(claude_session_id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE INDEX idx_user_prompts_claude_session ON user_prompts(claude_session_id);
|
|
CREATE INDEX idx_user_prompts_created ON user_prompts(created_at_epoch DESC);
|
|
CREATE INDEX idx_user_prompts_prompt_number ON user_prompts(prompt_number);
|
|
`),this.db.exec(`
|
|
CREATE VIRTUAL TABLE user_prompts_fts USING fts5(
|
|
prompt_text,
|
|
content='user_prompts',
|
|
content_rowid='id'
|
|
);
|
|
`),this.db.exec(`
|
|
CREATE TRIGGER user_prompts_ai AFTER INSERT ON user_prompts BEGIN
|
|
INSERT INTO user_prompts_fts(rowid, prompt_text)
|
|
VALUES (new.id, new.prompt_text);
|
|
END;
|
|
|
|
CREATE TRIGGER user_prompts_ad AFTER DELETE ON user_prompts BEGIN
|
|
INSERT INTO user_prompts_fts(user_prompts_fts, rowid, prompt_text)
|
|
VALUES('delete', old.id, old.prompt_text);
|
|
END;
|
|
|
|
CREATE TRIGGER user_prompts_au AFTER UPDATE ON user_prompts BEGIN
|
|
INSERT INTO user_prompts_fts(user_prompts_fts, rowid, prompt_text)
|
|
VALUES('delete', old.id, old.prompt_text);
|
|
INSERT INTO user_prompts_fts(rowid, prompt_text)
|
|
VALUES (new.id, new.prompt_text);
|
|
END;
|
|
`),this.db.exec("COMMIT"),this.db.prepare("INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)").run(10,new Date().toISOString()),console.error("[SessionStore] Successfully created user_prompts table with FTS5 support")}catch(s){throw this.db.exec("ROLLBACK"),s}}catch(e){console.error("[SessionStore] Migration error (create user_prompts table):",e.message)}}getRecentSummaries(e,t=10){return this.db.prepare(`
|
|
SELECT
|
|
request, investigated, learned, completed, next_steps,
|
|
files_read, files_edited, notes, prompt_number, created_at
|
|
FROM session_summaries
|
|
WHERE project = ?
|
|
ORDER BY created_at_epoch DESC
|
|
LIMIT ?
|
|
`).all(e,t)}getRecentSummariesWithSessionInfo(e,t=3){return this.db.prepare(`
|
|
SELECT
|
|
sdk_session_id, request, learned, completed, next_steps,
|
|
prompt_number, created_at
|
|
FROM session_summaries
|
|
WHERE project = ?
|
|
ORDER BY created_at_epoch DESC
|
|
LIMIT ?
|
|
`).all(e,t)}getRecentObservations(e,t=20){return this.db.prepare(`
|
|
SELECT type, text, prompt_number, created_at
|
|
FROM observations
|
|
WHERE project = ?
|
|
ORDER BY created_at_epoch DESC
|
|
LIMIT ?
|
|
`).all(e,t)}getRecentSessionsWithStatus(e,t=3){return this.db.prepare(`
|
|
SELECT * FROM (
|
|
SELECT
|
|
s.sdk_session_id,
|
|
s.status,
|
|
s.started_at,
|
|
s.started_at_epoch,
|
|
s.user_prompt,
|
|
CASE WHEN sum.sdk_session_id IS NOT NULL THEN 1 ELSE 0 END as has_summary
|
|
FROM sdk_sessions s
|
|
LEFT JOIN session_summaries sum ON s.sdk_session_id = sum.sdk_session_id
|
|
WHERE s.project = ? AND s.sdk_session_id IS NOT NULL
|
|
GROUP BY s.sdk_session_id
|
|
ORDER BY s.started_at_epoch DESC
|
|
LIMIT ?
|
|
)
|
|
ORDER BY started_at_epoch ASC
|
|
`).all(e,t)}getObservationsForSession(e){return this.db.prepare(`
|
|
SELECT title, subtitle, type, prompt_number
|
|
FROM observations
|
|
WHERE sdk_session_id = ?
|
|
ORDER BY created_at_epoch ASC
|
|
`).all(e)}getSummaryForSession(e){return this.db.prepare(`
|
|
SELECT
|
|
request, investigated, learned, completed, next_steps,
|
|
files_read, files_edited, notes, prompt_number, created_at
|
|
FROM session_summaries
|
|
WHERE sdk_session_id = ?
|
|
ORDER BY created_at_epoch DESC
|
|
LIMIT 1
|
|
`).get(e)||null}getFilesForSession(e){let s=this.db.prepare(`
|
|
SELECT files_read, files_modified
|
|
FROM observations
|
|
WHERE sdk_session_id = ?
|
|
`).all(e),r=new Set,n=new Set;for(let i of s){if(i.files_read)try{let o=JSON.parse(i.files_read);Array.isArray(o)&&o.forEach(c=>r.add(c))}catch{}if(i.files_modified)try{let o=JSON.parse(i.files_modified);Array.isArray(o)&&o.forEach(c=>n.add(c))}catch{}}return{filesRead:Array.from(r),filesModified:Array.from(n)}}getSessionById(e){return this.db.prepare(`
|
|
SELECT id, sdk_session_id, project, user_prompt
|
|
FROM sdk_sessions
|
|
WHERE id = ?
|
|
LIMIT 1
|
|
`).get(e)||null}findActiveSDKSession(e){return this.db.prepare(`
|
|
SELECT id, sdk_session_id, project, worker_port
|
|
FROM sdk_sessions
|
|
WHERE claude_session_id = ? AND status = 'active'
|
|
LIMIT 1
|
|
`).get(e)||null}findAnySDKSession(e){return this.db.prepare(`
|
|
SELECT id
|
|
FROM sdk_sessions
|
|
WHERE claude_session_id = ?
|
|
LIMIT 1
|
|
`).get(e)||null}reactivateSession(e,t){this.db.prepare(`
|
|
UPDATE sdk_sessions
|
|
SET status = 'active', user_prompt = ?, worker_port = NULL
|
|
WHERE id = ?
|
|
`).run(t,e)}incrementPromptCounter(e){return this.db.prepare(`
|
|
UPDATE sdk_sessions
|
|
SET prompt_counter = COALESCE(prompt_counter, 0) + 1
|
|
WHERE id = ?
|
|
`).run(e),this.db.prepare(`
|
|
SELECT prompt_counter FROM sdk_sessions WHERE id = ?
|
|
`).get(e)?.prompt_counter||1}getPromptCounter(e){return this.db.prepare(`
|
|
SELECT prompt_counter FROM sdk_sessions WHERE id = ?
|
|
`).get(e)?.prompt_counter||0}createSDKSession(e,t,s){let r=new Date,n=r.getTime(),o=this.db.prepare(`
|
|
INSERT OR IGNORE INTO sdk_sessions
|
|
(claude_session_id, sdk_session_id, project, user_prompt, started_at, started_at_epoch, status)
|
|
VALUES (?, ?, ?, ?, ?, ?, 'active')
|
|
`).run(e,e,t,s,r.toISOString(),n);return o.lastInsertRowid===0||o.changes===0?this.db.prepare(`
|
|
SELECT id FROM sdk_sessions WHERE claude_session_id = ? LIMIT 1
|
|
`).get(e).id:o.lastInsertRowid}updateSDKSessionId(e,t){return this.db.prepare(`
|
|
UPDATE sdk_sessions
|
|
SET sdk_session_id = ?
|
|
WHERE id = ? AND sdk_session_id IS NULL
|
|
`).run(t,e).changes===0?(Yo.debug("DB","sdk_session_id already set, skipping update",{sessionId:e,sdkSessionId:t}),!1):!0}setWorkerPort(e,t){this.db.prepare(`
|
|
UPDATE sdk_sessions
|
|
SET worker_port = ?
|
|
WHERE id = ?
|
|
`).run(t,e)}getWorkerPort(e){return this.db.prepare(`
|
|
SELECT worker_port
|
|
FROM sdk_sessions
|
|
WHERE id = ?
|
|
LIMIT 1
|
|
`).get(e)?.worker_port||null}saveUserPrompt(e,t,s){let r=new Date,n=r.getTime();return this.db.prepare(`
|
|
INSERT INTO user_prompts
|
|
(claude_session_id, prompt_number, prompt_text, created_at, created_at_epoch)
|
|
VALUES (?, ?, ?, ?, ?)
|
|
`).run(e,t,s,r.toISOString(),n).lastInsertRowid}storeObservation(e,t,s,r){let n=new Date,i=n.getTime();this.db.prepare(`
|
|
SELECT id FROM sdk_sessions WHERE sdk_session_id = ?
|
|
`).get(e)||(this.db.prepare(`
|
|
INSERT INTO sdk_sessions
|
|
(claude_session_id, sdk_session_id, project, started_at, started_at_epoch, status)
|
|
VALUES (?, ?, ?, ?, ?, 'active')
|
|
`).run(e,e,t,n.toISOString(),i),console.error(`[SessionStore] Auto-created session record for session_id: ${e}`)),this.db.prepare(`
|
|
INSERT INTO observations
|
|
(sdk_session_id, project, type, title, subtitle, facts, narrative, concepts,
|
|
files_read, files_modified, prompt_number, created_at, created_at_epoch)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
`).run(e,t,s.type,s.title,s.subtitle,JSON.stringify(s.facts),s.narrative,JSON.stringify(s.concepts),JSON.stringify(s.files_read),JSON.stringify(s.files_modified),r||null,n.toISOString(),i)}storeSummary(e,t,s,r){let n=new Date,i=n.getTime();this.db.prepare(`
|
|
SELECT id FROM sdk_sessions WHERE sdk_session_id = ?
|
|
`).get(e)||(this.db.prepare(`
|
|
INSERT INTO sdk_sessions
|
|
(claude_session_id, sdk_session_id, project, started_at, started_at_epoch, status)
|
|
VALUES (?, ?, ?, ?, ?, 'active')
|
|
`).run(e,e,t,n.toISOString(),i),console.error(`[SessionStore] Auto-created session record for session_id: ${e}`)),this.db.prepare(`
|
|
INSERT INTO session_summaries
|
|
(sdk_session_id, project, request, investigated, learned, completed,
|
|
next_steps, notes, prompt_number, created_at, created_at_epoch)
|
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
`).run(e,t,s.request,s.investigated,s.learned,s.completed,s.next_steps,s.notes,r||null,n.toISOString(),i)}markSessionCompleted(e){let t=new Date,s=t.getTime();this.db.prepare(`
|
|
UPDATE sdk_sessions
|
|
SET status = 'completed', completed_at = ?, completed_at_epoch = ?
|
|
WHERE id = ?
|
|
`).run(t.toISOString(),s,e)}markSessionFailed(e){let t=new Date,s=t.getTime();this.db.prepare(`
|
|
UPDATE sdk_sessions
|
|
SET status = 'failed', completed_at = ?, completed_at_epoch = ?
|
|
WHERE id = ?
|
|
`).run(t.toISOString(),s,e)}cleanupOrphanedSessions(){let e=new Date,t=e.getTime();return this.db.prepare(`
|
|
UPDATE sdk_sessions
|
|
SET status = 'failed', completed_at = ?, completed_at_epoch = ?
|
|
WHERE status = 'active'
|
|
`).run(e.toISOString(),t).changes}close(){this.db.close()}};var Wr,Ra;try{Wr=new Ea,Ra=new ba}catch(a){console.error("[search-server] Failed to initialize search:",a.message),process.exit(1)}function ft(){return`
|
|
---
|
|
\u{1F4A1} Search Strategy:
|
|
ALWAYS search with index format FIRST to get an overview and identify relevant results.
|
|
This is critical for token efficiency - index format uses ~10x fewer tokens than full format.
|
|
|
|
Search workflow:
|
|
1. Initial search: Use default (index) format to see titles, dates, and sources
|
|
2. Review results: Identify which items are most relevant to your needs
|
|
3. Deep dive: Only then use format: "full" on specific items of interest
|
|
4. Narrow down: Use filters (type, dateRange, concepts, files) to refine results
|
|
|
|
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"`}function Sa(a,e){let t=a.title||`Observation #${a.id}`,s=new Date(a.created_at_epoch).toLocaleString(),r=a.type?`[${a.type}]`:"";return`${e+1}. ${r} ${t}
|
|
Date: ${s}
|
|
Source: claude-mem://observation/${a.id}`}function el(a,e){let t=a.request||`Session ${a.sdk_session_id.substring(0,8)}`,s=new Date(a.created_at_epoch).toLocaleString();return`${e+1}. ${t}
|
|
Date: ${s}
|
|
Source: claude-mem://session/${a.sdk_session_id}`}function xa(a,e){let t=a.title||`Observation #${a.id}`,s=[];s.push(`## ${t}`),s.push(`*Source: claude-mem://observation/${a.id}*`),s.push(""),a.subtitle&&(s.push(`**${a.subtitle}**`),s.push("")),a.narrative&&(s.push(a.narrative),s.push("")),a.text&&(s.push(a.text),s.push(""));let r=[];if(r.push(`Type: ${a.type}`),a.facts)try{let i=JSON.parse(a.facts);i.length>0&&r.push(`Facts: ${i.join("; ")}`)}catch{}if(a.concepts)try{let i=JSON.parse(a.concepts);i.length>0&&r.push(`Concepts: ${i.join(", ")}`)}catch{}if(a.files_read||a.files_modified){let i=[];if(a.files_read)try{i.push(...JSON.parse(a.files_read))}catch{}if(a.files_modified)try{i.push(...JSON.parse(a.files_modified))}catch{}i.length>0&&r.push(`Files: ${[...new Set(i)].join(", ")}`)}r.length>0&&(s.push("---"),s.push(r.join(" | ")));let n=new Date(a.created_at_epoch).toLocaleString();return s.push(""),s.push("---"),s.push(`Date: ${n}`),s.join(`
|
|
`)}function rl(a,e){let t=a.request||`Session ${a.sdk_session_id.substring(0,8)}`,s=[];s.push(`## ${t}`),s.push(`*Source: claude-mem://session/${a.sdk_session_id}*`),s.push(""),a.completed&&(s.push(`**Completed:** ${a.completed}`),s.push("")),a.learned&&(s.push(`**Learned:** ${a.learned}`),s.push("")),a.investigated&&(s.push(`**Investigated:** ${a.investigated}`),s.push("")),a.next_steps&&(s.push(`**Next Steps:** ${a.next_steps}`),s.push("")),a.notes&&(s.push(`**Notes:** ${a.notes}`),s.push(""));let r=[];if(a.files_read||a.files_edited){let i=[];if(a.files_read)try{i.push(...JSON.parse(a.files_read))}catch{}if(a.files_edited)try{i.push(...JSON.parse(a.files_edited))}catch{}i.length>0&&r.push(`Files: ${[...new Set(i)].join(", ")}`)}let n=new Date(a.created_at_epoch).toLocaleDateString();return r.push(`Date: ${n}`),r.length>0&&(s.push("---"),s.push(r.join(" | "))),s.join(`
|
|
`)}function Af(a,e){let t=a.prompt_text.length>100?a.prompt_text.substring(0,100)+"...":a.prompt_text,s=new Date(a.created_at_epoch).toLocaleString();return`${e+1}. "${t}"
|
|
Date: ${s} | Prompt #${a.prompt_number}
|
|
Source: claude-mem://user-prompt/${a.id}`}function Df(a,e){let t=[];t.push(`## User Prompt #${a.prompt_number}`),t.push(`*Source: claude-mem://user-prompt/${a.id}*`),t.push(""),t.push(a.prompt_text),t.push(""),t.push("---");let s=new Date(a.created_at_epoch).toLocaleString();return t.push(`Date: ${s}`),t.join(`
|
|
`)}var Cf=l.object({project:l.string().optional().describe("Filter by project name"),type:l.union([l.enum(["decision","bugfix","feature","refactor","discovery","change"]),l.array(l.enum(["decision","bugfix","feature","refactor","discovery","change"]))]).optional().describe("Filter by observation type"),concepts:l.union([l.string(),l.array(l.string())]).optional().describe("Filter by concept tags"),files:l.union([l.string(),l.array(l.string())]).optional().describe("Filter by file paths (partial match)"),dateRange:l.object({start:l.union([l.string(),l.number()]).optional().describe("Start date (ISO string or epoch)"),end:l.union([l.string(),l.number()]).optional().describe("End date (ISO string or epoch)")}).optional().describe("Filter by date range"),limit:l.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:l.number().min(0).default(0).describe("Number of results to skip"),orderBy:l.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order")}),tl=[{name:"search_observations",description:'Search observations using full-text search across titles, narratives, facts, and concepts. IMPORTANT: Always use index format first (default) to get an overview with minimal token usage, then use format: "full" only for specific items of interest.',inputSchema:l.object({query:l.string().describe("Search query for FTS5 full-text search"),format:l.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)'),...Cf.shape}),handler:async a=>{try{let{query:e,format:t="index",...s}=a,r=Wr.searchObservations(e,s);if(r.length===0)return{content:[{type:"text",text:`No observations found matching "${e}"`}]};let n;if(t==="index"){let i=`Found ${r.length} observation(s) matching "${e}":
|
|
|
|
`,o=r.map((c,u)=>Sa(c,u));n=i+o.join(`
|
|
|
|
`)+ft()}else n=r.map((o,c)=>xa(o,c)).join(`
|
|
|
|
---
|
|
|
|
`);return{content:[{type:"text",text:n}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e.message}`}],isError:!0}}}},{name:"search_sessions",description:'Search session summaries using full-text search across requests, completions, learnings, and notes. IMPORTANT: Always use index format first (default) to get an overview with minimal token usage, then use format: "full" only for specific items of interest.',inputSchema:l.object({query:l.string().describe("Search query for FTS5 full-text search"),format:l.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)'),project:l.string().optional().describe("Filter by project name"),dateRange:l.object({start:l.union([l.string(),l.number()]).optional(),end:l.union([l.string(),l.number()]).optional()}).optional().describe("Filter by date range"),limit:l.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:l.number().min(0).default(0).describe("Number of results to skip"),orderBy:l.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order")}),handler:async a=>{try{let{query:e,format:t="index",...s}=a,r=Wr.searchSessions(e,s);if(r.length===0)return{content:[{type:"text",text:`No sessions found matching "${e}"`}]};let n;if(t==="index"){let i=`Found ${r.length} session(s) matching "${e}":
|
|
|
|
`,o=r.map((c,u)=>el(c,u));n=i+o.join(`
|
|
|
|
`)+ft()}else n=r.map((o,c)=>rl(o,c)).join(`
|
|
|
|
---
|
|
|
|
`);return{content:[{type:"text",text:n}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e.message}`}],isError:!0}}}},{name:"find_by_concept",description:'Find observations tagged with a specific concept. IMPORTANT: Always use index format first (default) to get an overview with minimal token usage, then use format: "full" only for specific items of interest.',inputSchema:l.object({concept:l.string().describe("Concept tag to search for"),format:l.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)'),project:l.string().optional().describe("Filter by project name"),dateRange:l.object({start:l.union([l.string(),l.number()]).optional(),end:l.union([l.string(),l.number()]).optional()}).optional().describe("Filter by date range"),limit:l.number().min(1).max(100).default(20).describe("Maximum results. IMPORTANT: Start with 3-5 to avoid exceeding MCP token limits, even in index mode."),offset:l.number().min(0).default(0).describe("Number of results to skip"),orderBy:l.enum(["relevance","date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{try{let{concept:e,format:t="index",...s}=a,r=Wr.findByConcept(e,s);if(r.length===0)return{content:[{type:"text",text:`No observations found with concept "${e}"`}]};let n;if(t==="index"){let i=`Found ${r.length} observation(s) with concept "${e}":
|
|
|
|
`,o=r.map((c,u)=>Sa(c,u));n=i+o.join(`
|
|
|
|
`)+ft()}else n=r.map((o,c)=>xa(o,c)).join(`
|
|
|
|
---
|
|
|
|
`);return{content:[{type:"text",text:n}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e.message}`}],isError:!0}}}},{name:"find_by_file",description:'Find observations and sessions that reference a specific file path. IMPORTANT: Always use index format first (default) to get an overview with minimal token usage, then use format: "full" only for specific items of interest.',inputSchema:l.object({filePath:l.string().describe("File path to search for (supports partial matching)"),format:l.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)'),project:l.string().optional().describe("Filter by project name"),dateRange:l.object({start:l.union([l.string(),l.number()]).optional(),end:l.union([l.string(),l.number()]).optional()}).optional().describe("Filter by date range"),limit:l.number().min(1).max(100).default(20).describe("Maximum results. IMPORTANT: Start with 3-5 to avoid exceeding MCP token limits, even in index mode."),offset:l.number().min(0).default(0).describe("Number of results to skip"),orderBy:l.enum(["relevance","date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{try{let{filePath:e,format:t="index",...s}=a,r=Wr.findByFile(e,s),n=r.observations.length+r.sessions.length;if(n===0)return{content:[{type:"text",text:`No results found for file "${e}"`}]};let i;if(t==="index"){let o=`Found ${n} result(s) for file "${e}":
|
|
|
|
`,c=[];r.observations.forEach((u,p)=>{c.push(Sa(u,p))}),r.sessions.forEach((u,p)=>{c.push(el(u,p+r.observations.length))}),i=o+c.join(`
|
|
|
|
`)+ft()}else{let o=[];r.observations.forEach((c,u)=>{o.push(xa(c,u))}),r.sessions.forEach((c,u)=>{o.push(rl(c,u+r.observations.length))}),i=o.join(`
|
|
|
|
---
|
|
|
|
`)}return{content:[{type:"text",text:i}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e.message}`}],isError:!0}}}},{name:"find_by_type",description:'Find observations of a specific type (decision, bugfix, feature, refactor, discovery, change). IMPORTANT: Always use index format first (default) to get an overview with minimal token usage, then use format: "full" only for specific items of interest.',inputSchema:l.object({type:l.union([l.enum(["decision","bugfix","feature","refactor","discovery","change"]),l.array(l.enum(["decision","bugfix","feature","refactor","discovery","change"]))]).describe("Observation type(s) to filter by"),format:l.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)'),project:l.string().optional().describe("Filter by project name"),dateRange:l.object({start:l.union([l.string(),l.number()]).optional(),end:l.union([l.string(),l.number()]).optional()}).optional().describe("Filter by date range"),limit:l.number().min(1).max(100).default(20).describe("Maximum results. IMPORTANT: Start with 3-5 to avoid exceeding MCP token limits, even in index mode."),offset:l.number().min(0).default(0).describe("Number of results to skip"),orderBy:l.enum(["relevance","date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{try{let{type:e,format:t="index",...s}=a,r=Wr.findByType(e,s);if(r.length===0)return{content:[{type:"text",text:`No observations found with type "${Array.isArray(e)?e.join(", "):e}"`}]};let n=Array.isArray(e)?e.join(", "):e,i;if(t==="index"){let o=`Found ${r.length} observation(s) with type "${n}":
|
|
|
|
`,c=r.map((u,p)=>Sa(u,p));i=o+c.join(`
|
|
|
|
`)+ft()}else i=r.map((c,u)=>xa(c,u)).join(`
|
|
|
|
---
|
|
|
|
`);return{content:[{type:"text",text:i}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e.message}`}],isError:!0}}}},{name:"get_recent_context",description:"Get recent session context including summaries and observations for a project",inputSchema:l.object({project:l.string().optional().describe("Project name (defaults to current working directory basename)"),limit:l.number().min(1).max(10).default(3).describe("Number of recent sessions to retrieve")}),handler:async a=>{try{let e=a.project||Nf(process.cwd()),t=a.limit||3,s=Ra.getRecentSessionsWithStatus(e,t);if(s.length===0)return{content:[{type:"text",text:`# Recent Session Context
|
|
|
|
No previous sessions found for project "${e}".`}]};let r=[];r.push("# Recent Session Context"),r.push(""),r.push(`Showing last ${s.length} session(s) for **${e}**:`),r.push("");for(let n of s)if(n.sdk_session_id){if(r.push("---"),r.push(""),n.has_summary){let i=Ra.getSummaryForSession(n.sdk_session_id);if(i){let o=i.prompt_number?` (Prompt #${i.prompt_number})`:"";if(r.push(`**Summary${o}**`),r.push(""),i.request&&r.push(`**Request:** ${i.request}`),i.completed&&r.push(`**Completed:** ${i.completed}`),i.learned&&r.push(`**Learned:** ${i.learned}`),i.next_steps&&r.push(`**Next Steps:** ${i.next_steps}`),i.files_read)try{let u=JSON.parse(i.files_read);Array.isArray(u)&&u.length>0&&r.push(`**Files Read:** ${u.join(", ")}`)}catch{i.files_read.trim()&&r.push(`**Files Read:** ${i.files_read}`)}if(i.files_edited)try{let u=JSON.parse(i.files_edited);Array.isArray(u)&&u.length>0&&r.push(`**Files Edited:** ${u.join(", ")}`)}catch{i.files_edited.trim()&&r.push(`**Files Edited:** ${i.files_edited}`)}let c=new Date(i.created_at).toLocaleString();r.push(`**Date:** ${c}`)}}else if(n.status==="active"){r.push("**In Progress**"),r.push(""),n.user_prompt&&r.push(`**Request:** ${n.user_prompt}`);let i=Ra.getObservationsForSession(n.sdk_session_id);if(i.length>0){r.push(""),r.push(`**Observations (${i.length}):**`);for(let c of i)r.push(`- ${c.title}`)}else r.push(""),r.push("*No observations yet*");r.push(""),r.push("**Status:** Active - summary pending");let o=new Date(n.started_at).toLocaleString();r.push(`**Date:** ${o}`)}else{r.push(`**${n.status.charAt(0).toUpperCase()+n.status.slice(1)}**`),r.push(""),n.user_prompt&&r.push(`**Request:** ${n.user_prompt}`),r.push(""),r.push(`**Status:** ${n.status} - no summary available`);let i=new Date(n.started_at).toLocaleString();r.push(`**Date:** ${i}`)}r.push("")}return{content:[{type:"text",text:r.join(`
|
|
`)}]}}catch(e){return{content:[{type:"text",text:`Failed to get recent context: ${e.message}`}],isError:!0}}}},{name:"search_user_prompts",description:'Search raw user prompts with full-text search. Use this to find what the user actually said/requested across all sessions. IMPORTANT: Always use index format first (default) to get an overview with minimal token usage, then use format: "full" only for specific items of interest.',inputSchema:l.object({query:l.string().describe("Search query for FTS5 full-text search"),format:l.enum(["index","full"]).default("index").describe('Output format: "index" for truncated prompts/dates (default, RECOMMENDED for initial search), "full" for complete prompt text (use only after reviewing index results)'),project:l.string().optional().describe("Filter by project name"),dateRange:l.object({start:l.union([l.string(),l.number()]).optional(),end:l.union([l.string(),l.number()]).optional()}).optional().describe("Filter by date range"),limit:l.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:l.number().min(0).default(0).describe("Number of results to skip"),orderBy:l.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order")}),handler:async a=>{try{let{query:e,format:t="index",...s}=a,r=Wr.searchUserPrompts(e,s);if(r.length===0)return{content:[{type:"text",text:`No user prompts found matching "${e}"`}]};let n;if(t==="index"){let i=`Found ${r.length} user prompt(s) matching "${e}":
|
|
|
|
`,o=r.map((c,u)=>Af(c,u));n=i+o.join(`
|
|
|
|
`)+ft()}else n=r.map((o,c)=>Df(o,c)).join(`
|
|
|
|
---
|
|
|
|
`);return{content:[{type:"text",text:n}]}}catch(e){return{content:[{type:"text",text:`Search failed: ${e.message}`}],isError:!0}}}}],Ts=new da({name:"claude-mem-search",version:"1.0.0"},{capabilities:{tools:{}}});Ts.setRequestHandler(qa,async()=>({tools:tl.map(a=>({name:a.name,description:a.description,inputSchema:bs(a.inputSchema)}))}));Ts.setRequestHandler(Va,async a=>{let e=tl.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 $f(){let a=new pa;await Ts.connect(a),console.error("[search-server] Claude-mem search server started")}$f().catch(a=>{console.error("[search-server] Fatal error:",a),process.exit(1)});
|
|
/*! Bundled license information:
|
|
|
|
uri-js/dist/es5/uri.all.js:
|
|
(** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js *)
|
|
*/
|