@graffiti-garden/implementation-local 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
- var rp=Object.create;var ds=Object.defineProperty;var np=Object.getOwnPropertyDescriptor;var ip=Object.getOwnPropertyNames;var sp=Object.getPrototypeOf,op=Object.prototype.hasOwnProperty;var Ar=(t,e)=>()=>(t&&(e=t(t=0)),e);var Y=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),hs=(t,e)=>{for(var r in e)ds(t,r,{get:e[r],enumerable:!0})},ap=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ip(e))!op.call(t,i)&&i!==r&&ds(t,i,{get:()=>e[i],enumerable:!(n=np(e,i))||n.enumerable});return t};var en=(t,e,r)=>(r=t!=null?rp(sp(t)):{},ap(e||!t||!t.__esModule?ds(r,"default",{value:t,enumerable:!0}):r,t));var I=Ar(()=>{});var z={};hs(z,{_debugEnd:()=>rc,_debugProcess:()=>tc,_events:()=>gc,_eventsCount:()=>_c,_exiting:()=>Nu,_fatalExceptions:()=>Yu,_getActiveHandles:()=>Mu,_getActiveRequests:()=>Lu,_kill:()=>Gu,_linkedBinding:()=>xu,_maxListeners:()=>yc,_preload_modules:()=>pc,_rawDebug:()=>ku,_startProfilerIdleNotifier:()=>nc,_stopProfilerIdleNotifier:()=>ic,_tickCallback:()=>ec,abort:()=>uc,addListener:()=>wc,allowedNodeEnvironmentFlags:()=>Hu,arch:()=>gu,argv:()=>bu,argv0:()=>hc,assert:()=>Wu,binding:()=>Ou,browser:()=>qu,chdir:()=>Tu,config:()=>Du,cpuUsage:()=>Jn,cwd:()=>Iu,debugPort:()=>dc,default:()=>Tc,dlopen:()=>Bu,domain:()=>ju,emit:()=>Pc,emitWarning:()=>Pu,env:()=>wu,execArgv:()=>Eu,execPath:()=>lc,exit:()=>Vu,features:()=>Qu,hasUncaughtExceptionCaptureCallback:()=>Zu,hrtime:()=>Vn,kill:()=>Ku,listeners:()=>Ic,memoryUsage:()=>zu,moduleLoadList:()=>Cu,nextTick:()=>mu,off:()=>Ec,on:()=>jt,once:()=>bc,openStdin:()=>Ju,pid:()=>cc,platform:()=>_u,ppid:()=>fc,prependListener:()=>Oc,prependOnceListener:()=>Ac,reallyExit:()=>Uu,release:()=>Ru,removeAllListeners:()=>Sc,removeListener:()=>$c,resourceUsage:()=>Fu,setSourceMapsEnabled:()=>mc,setUncaughtExceptionCaptureCallback:()=>Xu,stderr:()=>oc,stdin:()=>ac,stdout:()=>sc,title:()=>yu,umask:()=>Au,uptime:()=>vc,version:()=>$u,versions:()=>Su});function vs(t){throw new Error("Node.js process "+t+" is not supported by JSPM core outside of Node.js")}function up(){!Ir||!rr||(Ir=!1,rr.length?xt=rr.concat(xt):Kn=-1,xt.length&&pu())}function pu(){if(!Ir){var t=setTimeout(up,0);Ir=!0;for(var e=xt.length;e;){for(rr=xt,xt=[];++Kn<e;)rr&&rr[Kn].run();Kn=-1,e=xt.length}rr=null,Ir=!1,clearTimeout(t)}}function mu(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];xt.push(new vu(t,e)),xt.length===1&&!Ir&&setTimeout(pu,0)}function vu(t,e){this.fun=t,this.array=e}function Qe(){}function xu(t){vs("_linkedBinding")}function Bu(t){vs("dlopen")}function Lu(){return[]}function Mu(){return[]}function Wu(t,e){if(!t)throw new Error(e||"assertion error")}function Zu(){return!1}function vc(){return Ft.now()/1e3}function Vn(t){var e=Math.floor((Date.now()-Ft.now())*.001),r=Ft.now()*.001,n=Math.floor(r)+e,i=Math.floor(r%1*1e9);return t&&(n=n-t[0],i=i-t[1],i<0&&(n--,i+=ms)),[n,i]}function jt(){return Tc}function Ic(t){return[]}var xt,Ir,rr,Kn,yu,gu,_u,wu,bu,Eu,$u,Su,Pu,Ou,Au,Iu,Tu,Ru,qu,ku,Cu,ju,Nu,Du,Uu,Gu,Jn,Fu,zu,Ku,Vu,Ju,Hu,Qu,Yu,Xu,ec,tc,rc,nc,ic,sc,oc,ac,uc,cc,fc,lc,dc,hc,pc,mc,Ft,ps,ms,yc,gc,_c,wc,bc,Ec,$c,Sc,Pc,Oc,Ac,Tc,Rc=Ar(()=>{I();R();T();xt=[],Ir=!1,Kn=-1;vu.prototype.run=function(){this.fun.apply(null,this.array)};yu="browser",gu="x64",_u="browser",wu={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},bu=["/usr/bin/node"],Eu=[],$u="v16.8.0",Su={},Pu=function(t,e){console.warn((e?e+": ":"")+t)},Ou=function(t){vs("binding")},Au=function(t){return 0},Iu=function(){return"/"},Tu=function(t){},Ru={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};qu=!0,ku=Qe,Cu=[];ju={},Nu=!1,Du={};Uu=Qe,Gu=Qe,Jn=function(){return{}},Fu=Jn,zu=Jn,Ku=Qe,Vu=Qe,Ju=Qe,Hu={};Qu={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Yu=Qe,Xu=Qe;ec=Qe,tc=Qe,rc=Qe,nc=Qe,ic=Qe,sc=void 0,oc=void 0,ac=void 0,uc=Qe,cc=2,fc=1,lc="/bin/usr/node",dc=9229,hc="node",pc=[],mc=Qe,Ft={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};Ft.now===void 0&&(ps=Date.now(),Ft.timing&&Ft.timing.navigationStart&&(ps=Ft.timing.navigationStart),Ft.now=()=>Date.now()-ps);ms=1e9;Vn.bigint=function(t){var e=Vn(t);return typeof BigInt>"u"?e[0]*ms+e[1]:BigInt(e[0]*ms)+BigInt(e[1])};yc=10,gc={},_c=0;wc=jt,bc=jt,Ec=jt,$c=jt,Sc=jt,Pc=Qe,Oc=jt,Ac=jt;Tc={version:$u,versions:Su,arch:gu,platform:_u,browser:qu,release:Ru,_rawDebug:ku,moduleLoadList:Cu,binding:Ou,_linkedBinding:xu,_events:gc,_eventsCount:_c,_maxListeners:yc,on:jt,addListener:wc,once:bc,off:Ec,removeListener:$c,removeAllListeners:Sc,emit:Pc,prependListener:Oc,prependOnceListener:Ac,listeners:Ic,domain:ju,_exiting:Nu,config:Du,dlopen:Bu,uptime:vc,_getActiveRequests:Lu,_getActiveHandles:Mu,reallyExit:Uu,_kill:Gu,cpuUsage:Jn,resourceUsage:Fu,memoryUsage:zu,kill:Ku,exit:Vu,openStdin:Ju,allowedNodeEnvironmentFlags:Hu,assert:Wu,features:Qu,_fatalExceptions:Yu,setUncaughtExceptionCaptureCallback:Xu,hasUncaughtExceptionCaptureCallback:Zu,emitWarning:Pu,nextTick:mu,_tickCallback:ec,_debugProcess:tc,_debugEnd:rc,_startProfilerIdleNotifier:nc,_stopProfilerIdleNotifier:ic,stdout:sc,stdin:ac,stderr:oc,abort:uc,umask:Au,chdir:Tu,cwd:Iu,env:wu,title:yu,argv:bu,execArgv:Eu,pid:cc,ppid:fc,execPath:lc,debugPort:dc,hrtime:Vn,argv0:hc,_preload_modules:pc,setSourceMapsEnabled:mc}});var T=Ar(()=>{Rc()});function cp(){if(qc)return tn;qc=!0,tn.byteLength=a,tn.toByteArray=d,tn.fromByteArray=g;for(var t=[],e=[],r=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,s=n.length;i<s;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;e[45]=62,e[95]=63;function o(_){var b=_.length;if(b%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var P=_.indexOf("=");P===-1&&(P=b);var S=P===b?0:4-P%4;return[P,S]}function a(_){var b=o(_),P=b[0],S=b[1];return(P+S)*3/4-S}function c(_,b,P){return(b+P)*3/4-P}function d(_){var b,P=o(_),S=P[0],y=P[1],w=new r(c(_,S,y)),p=0,h=y>0?S-4:S,v;for(v=0;v<h;v+=4)b=e[_.charCodeAt(v)]<<18|e[_.charCodeAt(v+1)]<<12|e[_.charCodeAt(v+2)]<<6|e[_.charCodeAt(v+3)],w[p++]=b>>16&255,w[p++]=b>>8&255,w[p++]=b&255;return y===2&&(b=e[_.charCodeAt(v)]<<2|e[_.charCodeAt(v+1)]>>4,w[p++]=b&255),y===1&&(b=e[_.charCodeAt(v)]<<10|e[_.charCodeAt(v+1)]<<4|e[_.charCodeAt(v+2)]>>2,w[p++]=b>>8&255,w[p++]=b&255),w}function m(_){return t[_>>18&63]+t[_>>12&63]+t[_>>6&63]+t[_&63]}function f(_,b,P){for(var S,y=[],w=b;w<P;w+=3)S=(_[w]<<16&16711680)+(_[w+1]<<8&65280)+(_[w+2]&255),y.push(m(S));return y.join("")}function g(_){for(var b,P=_.length,S=P%3,y=[],w=16383,p=0,h=P-S;p<h;p+=w)y.push(f(_,p,p+w>h?h:p+w));return S===1?(b=_[P-1],y.push(t[b>>2]+t[b<<4&63]+"==")):S===2&&(b=(_[P-2]<<8)+_[P-1],y.push(t[b>>10]+t[b>>4&63]+t[b<<2&63]+"=")),y.join("")}return tn}function fp(){if(kc)return Hn;kc=!0;return Hn.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,d=c>>1,m=-7,f=r?i-1:0,g=r?-1:1,_=t[e+f];for(f+=g,s=_&(1<<-m)-1,_>>=-m,m+=a;m>0;s=s*256+t[e+f],f+=g,m-=8);for(o=s&(1<<-m)-1,s>>=-m,m+=n;m>0;o=o*256+t[e+f],f+=g,m-=8);if(s===0)s=1-d;else{if(s===c)return o?NaN:(_?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-d}return(_?-1:1)*o*Math.pow(2,s-n)},Hn.write=function(t,e,r,n,i,s){var o,a,c,d=s*8-i-1,m=(1<<d)-1,f=m>>1,g=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=n?0:s-1,b=n?1:-1,P=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=m):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+f>=1?e+=g/c:e+=g*Math.pow(2,1-f),e*c>=2&&(o++,c/=2),o+f>=m?(a=0,o=m):o+f>=1?(a=(e*c-1)*Math.pow(2,i),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+_]=a&255,_+=b,a/=256,i-=8);for(o=o<<i|a,d+=i;d>0;t[r+_]=o&255,_+=b,o/=256,d-=8);t[r+_-b]|=P*128},Hn}function xc(){if(Cc)return nr;Cc=!0;let t=cp(),e=fp(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;nr.Buffer=o,nr.SlowBuffer=y,nr.INSPECT_MAX_BYTES=50;let n=2147483647;nr.kMaxLength=n,o.TYPED_ARRAY_SUPPORT=i(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{let $=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf($,u),$.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function s($){if($>n)throw new RangeError('The value "'+$+'" is invalid for option "size"');let u=new Uint8Array($);return Object.setPrototypeOf(u,o.prototype),u}function o($,u,l){if(typeof $=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m($)}return a($,u,l)}o.poolSize=8192;function a($,u,l){if(typeof $=="string")return f($,u);if(ArrayBuffer.isView($))return _($);if($==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof $);if(Pe($,ArrayBuffer)||$&&Pe($.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Pe($,SharedArrayBuffer)||$&&Pe($.buffer,SharedArrayBuffer)))return b($,u,l);if(typeof $=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let O=$.valueOf&&$.valueOf();if(O!=null&&O!==$)return o.from(O,u,l);let A=P($);if(A)return A;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof $[Symbol.toPrimitive]=="function")return o.from($[Symbol.toPrimitive]("string"),u,l);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof $)}o.from=function($,u,l){return a($,u,l)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function c($){if(typeof $!="number")throw new TypeError('"size" argument must be of type number');if($<0)throw new RangeError('The value "'+$+'" is invalid for option "size"')}function d($,u,l){return c($),$<=0?s($):u!==void 0?typeof l=="string"?s($).fill(u,l):s($).fill(u):s($)}o.alloc=function($,u,l){return d($,u,l)};function m($){return c($),s($<0?0:S($)|0)}o.allocUnsafe=function($){return m($)},o.allocUnsafeSlow=function($){return m($)};function f($,u){if((typeof u!="string"||u==="")&&(u="utf8"),!o.isEncoding(u))throw new TypeError("Unknown encoding: "+u);let l=w($,u)|0,O=s(l),A=O.write($,u);return A!==l&&(O=O.slice(0,A)),O}function g($){let u=$.length<0?0:S($.length)|0,l=s(u);for(let O=0;O<u;O+=1)l[O]=$[O]&255;return l}function _($){if(Pe($,Uint8Array)){let u=new Uint8Array($);return b(u.buffer,u.byteOffset,u.byteLength)}return g($)}function b($,u,l){if(u<0||$.byteLength<u)throw new RangeError('"offset" is outside of buffer bounds');if($.byteLength<u+(l||0))throw new RangeError('"length" is outside of buffer bounds');let O;return u===void 0&&l===void 0?O=new Uint8Array($):l===void 0?O=new Uint8Array($,u):O=new Uint8Array($,u,l),Object.setPrototypeOf(O,o.prototype),O}function P($){if(o.isBuffer($)){let u=S($.length)|0,l=s(u);return l.length===0||$.copy(l,0,0,u),l}if($.length!==void 0)return typeof $.length!="number"||er($.length)?s(0):g($);if($.type==="Buffer"&&Array.isArray($.data))return g($.data)}function S($){if($>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return $|0}function y($){return+$!=$&&($=0),o.alloc(+$)}o.isBuffer=function(u){return u!=null&&u._isBuffer===!0&&u!==o.prototype},o.compare=function(u,l){if(Pe(u,Uint8Array)&&(u=o.from(u,u.offset,u.byteLength)),Pe(l,Uint8Array)&&(l=o.from(l,l.offset,l.byteLength)),!o.isBuffer(u)||!o.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(u===l)return 0;let O=u.length,A=l.length;for(let j=0,U=Math.min(O,A);j<U;++j)if(u[j]!==l[j]){O=u[j],A=l[j];break}return O<A?-1:A<O?1:0},o.isEncoding=function(u){switch(String(u).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(u,l){if(!Array.isArray(u))throw new TypeError('"list" argument must be an Array of Buffers');if(u.length===0)return o.alloc(0);let O;if(l===void 0)for(l=0,O=0;O<u.length;++O)l+=u[O].length;let A=o.allocUnsafe(l),j=0;for(O=0;O<u.length;++O){let U=u[O];if(Pe(U,Uint8Array))j+U.length>A.length?(o.isBuffer(U)||(U=o.from(U)),U.copy(A,j)):Uint8Array.prototype.set.call(A,U,j);else if(o.isBuffer(U))U.copy(A,j);else throw new TypeError('"list" argument must be an Array of Buffers');j+=U.length}return A};function w($,u){if(o.isBuffer($))return $.length;if(ArrayBuffer.isView($)||Pe($,ArrayBuffer))return $.byteLength;if(typeof $!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof $);let l=$.length,O=arguments.length>2&&arguments[2]===!0;if(!O&&l===0)return 0;let A=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return l;case"utf8":case"utf-8":return ve($).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return l*2;case"hex":return l>>>1;case"base64":return nt($).length;default:if(A)return O?-1:ve($).length;u=(""+u).toLowerCase(),A=!0}}o.byteLength=w;function p($,u,l){let O=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((l===void 0||l>this.length)&&(l=this.length),l<=0)||(l>>>=0,u>>>=0,l<=u))return"";for($||($="utf8");;)switch($){case"hex":return q(this,u,l);case"utf8":case"utf-8":return Q(this,u,l);case"ascii":return fe(this,u,l);case"latin1":case"binary":return me(this,u,l);case"base64":return re(this,u,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,u,l);default:if(O)throw new TypeError("Unknown encoding: "+$);$=($+"").toLowerCase(),O=!0}}o.prototype._isBuffer=!0;function h($,u,l){let O=$[u];$[u]=$[l],$[l]=O}o.prototype.swap16=function(){let u=this.length;if(u%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<u;l+=2)h(this,l,l+1);return this},o.prototype.swap32=function(){let u=this.length;if(u%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<u;l+=4)h(this,l,l+3),h(this,l+1,l+2);return this},o.prototype.swap64=function(){let u=this.length;if(u%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<u;l+=8)h(this,l,l+7),h(this,l+1,l+6),h(this,l+2,l+5),h(this,l+3,l+4);return this},o.prototype.toString=function(){let u=this.length;return u===0?"":arguments.length===0?Q(this,0,u):p.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(u){if(!o.isBuffer(u))throw new TypeError("Argument must be a Buffer");return this===u?!0:o.compare(this,u)===0},o.prototype.inspect=function(){let u="",l=nr.INSPECT_MAX_BYTES;return u=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(u+=" ... "),"<Buffer "+u+">"},r&&(o.prototype[r]=o.prototype.inspect),o.prototype.compare=function(u,l,O,A,j){if(Pe(u,Uint8Array)&&(u=o.from(u,u.offset,u.byteLength)),!o.isBuffer(u))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof u);if(l===void 0&&(l=0),O===void 0&&(O=u?u.length:0),A===void 0&&(A=0),j===void 0&&(j=this.length),l<0||O>u.length||A<0||j>this.length)throw new RangeError("out of range index");if(A>=j&&l>=O)return 0;if(A>=j)return-1;if(l>=O)return 1;if(l>>>=0,O>>>=0,A>>>=0,j>>>=0,this===u)return 0;let U=j-A,he=O-l,Ce=Math.min(U,he),ke=this.slice(A,j),xe=u.slice(l,O);for(let Ae=0;Ae<Ce;++Ae)if(ke[Ae]!==xe[Ae]){U=ke[Ae],he=xe[Ae];break}return U<he?-1:he<U?1:0};function v($,u,l,O,A){if($.length===0)return-1;if(typeof l=="string"?(O=l,l=0):l>2147483647?l=2147483647:l<-2147483648&&(l=-2147483648),l=+l,er(l)&&(l=A?0:$.length-1),l<0&&(l=$.length+l),l>=$.length){if(A)return-1;l=$.length-1}else if(l<0)if(A)l=0;else return-1;if(typeof u=="string"&&(u=o.from(u,O)),o.isBuffer(u))return u.length===0?-1:E($,u,l,O,A);if(typeof u=="number")return u=u&255,typeof Uint8Array.prototype.indexOf=="function"?A?Uint8Array.prototype.indexOf.call($,u,l):Uint8Array.prototype.lastIndexOf.call($,u,l):E($,[u],l,O,A);throw new TypeError("val must be string, number or Buffer")}function E($,u,l,O,A){let j=1,U=$.length,he=u.length;if(O!==void 0&&(O=String(O).toLowerCase(),O==="ucs2"||O==="ucs-2"||O==="utf16le"||O==="utf-16le")){if($.length<2||u.length<2)return-1;j=2,U/=2,he/=2,l/=2}function Ce(xe,Ae){return j===1?xe[Ae]:xe.readUInt16BE(Ae*j)}let ke;if(A){let xe=-1;for(ke=l;ke<U;ke++)if(Ce($,ke)===Ce(u,xe===-1?0:ke-xe)){if(xe===-1&&(xe=ke),ke-xe+1===he)return xe*j}else xe!==-1&&(ke-=ke-xe),xe=-1}else for(l+he>U&&(l=U-he),ke=l;ke>=0;ke--){let xe=!0;for(let Ae=0;Ae<he;Ae++)if(Ce($,ke+Ae)!==Ce(u,Ae)){xe=!1;break}if(xe)return ke}return-1}o.prototype.includes=function(u,l,O){return this.indexOf(u,l,O)!==-1},o.prototype.indexOf=function(u,l,O){return v(this,u,l,O,!0)},o.prototype.lastIndexOf=function(u,l,O){return v(this,u,l,O,!1)};function k($,u,l,O){l=Number(l)||0;let A=$.length-l;O?(O=Number(O),O>A&&(O=A)):O=A;let j=u.length;O>j/2&&(O=j/2);let U;for(U=0;U<O;++U){let he=parseInt(u.substr(U*2,2),16);if(er(he))return U;$[l+U]=he}return U}function x($,u,l,O){return Fe(ve(u,$.length-l),$,l,O)}function N($,u,l,O){return Fe(ge(u),$,l,O)}function G($,u,l,O){return Fe(nt(u),$,l,O)}function H($,u,l,O){return Fe(Se(u,$.length-l),$,l,O)}o.prototype.write=function(u,l,O,A){if(l===void 0)A="utf8",O=this.length,l=0;else if(O===void 0&&typeof l=="string")A=l,O=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(O)?(O=O>>>0,A===void 0&&(A="utf8")):(A=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let j=this.length-l;if((O===void 0||O>j)&&(O=j),u.length>0&&(O<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");A||(A="utf8");let U=!1;for(;;)switch(A){case"hex":return k(this,u,l,O);case"utf8":case"utf-8":return x(this,u,l,O);case"ascii":case"latin1":case"binary":return N(this,u,l,O);case"base64":return G(this,u,l,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,u,l,O);default:if(U)throw new TypeError("Unknown encoding: "+A);A=(""+A).toLowerCase(),U=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function re($,u,l){return u===0&&l===$.length?t.fromByteArray($):t.fromByteArray($.slice(u,l))}function Q($,u,l){l=Math.min($.length,l);let O=[],A=u;for(;A<l;){let j=$[A],U=null,he=j>239?4:j>223?3:j>191?2:1;if(A+he<=l){let Ce,ke,xe,Ae;switch(he){case 1:j<128&&(U=j);break;case 2:Ce=$[A+1],(Ce&192)===128&&(Ae=(j&31)<<6|Ce&63,Ae>127&&(U=Ae));break;case 3:Ce=$[A+1],ke=$[A+2],(Ce&192)===128&&(ke&192)===128&&(Ae=(j&15)<<12|(Ce&63)<<6|ke&63,Ae>2047&&(Ae<55296||Ae>57343)&&(U=Ae));break;case 4:Ce=$[A+1],ke=$[A+2],xe=$[A+3],(Ce&192)===128&&(ke&192)===128&&(xe&192)===128&&(Ae=(j&15)<<18|(Ce&63)<<12|(ke&63)<<6|xe&63,Ae>65535&&Ae<1114112&&(U=Ae))}}U===null?(U=65533,he=1):U>65535&&(U-=65536,O.push(U>>>10&1023|55296),U=56320|U&1023),O.push(U),A+=he}return ce(O)}let Z=4096;function ce($){let u=$.length;if(u<=Z)return String.fromCharCode.apply(String,$);let l="",O=0;for(;O<u;)l+=String.fromCharCode.apply(String,$.slice(O,O+=Z));return l}function fe($,u,l){let O="";l=Math.min($.length,l);for(let A=u;A<l;++A)O+=String.fromCharCode($[A]&127);return O}function me($,u,l){let O="";l=Math.min($.length,l);for(let A=u;A<l;++A)O+=String.fromCharCode($[A]);return O}function q($,u,l){let O=$.length;(!u||u<0)&&(u=0),(!l||l<0||l>O)&&(l=O);let A="";for(let j=u;j<l;++j)A+=tr[$[j]];return A}function C($,u,l){let O=$.slice(u,l),A="";for(let j=0;j<O.length-1;j+=2)A+=String.fromCharCode(O[j]+O[j+1]*256);return A}o.prototype.slice=function(u,l){let O=this.length;u=~~u,l=l===void 0?O:~~l,u<0?(u+=O,u<0&&(u=0)):u>O&&(u=O),l<0?(l+=O,l<0&&(l=0)):l>O&&(l=O),l<u&&(l=u);let A=this.subarray(u,l);return Object.setPrototypeOf(A,o.prototype),A};function L($,u,l){if($%1!==0||$<0)throw new RangeError("offset is not uint");if($+u>l)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(u,l,O){u=u>>>0,l=l>>>0,O||L(u,l,this.length);let A=this[u],j=1,U=0;for(;++U<l&&(j*=256);)A+=this[u+U]*j;return A},o.prototype.readUintBE=o.prototype.readUIntBE=function(u,l,O){u=u>>>0,l=l>>>0,O||L(u,l,this.length);let A=this[u+--l],j=1;for(;l>0&&(j*=256);)A+=this[u+--l]*j;return A},o.prototype.readUint8=o.prototype.readUInt8=function(u,l){return u=u>>>0,l||L(u,1,this.length),this[u]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(u,l){return u=u>>>0,l||L(u,2,this.length),this[u]|this[u+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(u,l){return u=u>>>0,l||L(u,2,this.length),this[u]<<8|this[u+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(u,l){return u=u>>>0,l||L(u,4,this.length),(this[u]|this[u+1]<<8|this[u+2]<<16)+this[u+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(u,l){return u=u>>>0,l||L(u,4,this.length),this[u]*16777216+(this[u+1]<<16|this[u+2]<<8|this[u+3])},o.prototype.readBigUInt64LE=Gt(function(u){u=u>>>0,$e(u,"offset");let l=this[u],O=this[u+7];(l===void 0||O===void 0)&&Re(u,this.length-8);let A=l+this[++u]*2**8+this[++u]*2**16+this[++u]*2**24,j=this[++u]+this[++u]*2**8+this[++u]*2**16+O*2**24;return BigInt(A)+(BigInt(j)<<BigInt(32))}),o.prototype.readBigUInt64BE=Gt(function(u){u=u>>>0,$e(u,"offset");let l=this[u],O=this[u+7];(l===void 0||O===void 0)&&Re(u,this.length-8);let A=l*2**24+this[++u]*2**16+this[++u]*2**8+this[++u],j=this[++u]*2**24+this[++u]*2**16+this[++u]*2**8+O;return(BigInt(A)<<BigInt(32))+BigInt(j)}),o.prototype.readIntLE=function(u,l,O){u=u>>>0,l=l>>>0,O||L(u,l,this.length);let A=this[u],j=1,U=0;for(;++U<l&&(j*=256);)A+=this[u+U]*j;return j*=128,A>=j&&(A-=Math.pow(2,8*l)),A},o.prototype.readIntBE=function(u,l,O){u=u>>>0,l=l>>>0,O||L(u,l,this.length);let A=l,j=1,U=this[u+--A];for(;A>0&&(j*=256);)U+=this[u+--A]*j;return j*=128,U>=j&&(U-=Math.pow(2,8*l)),U},o.prototype.readInt8=function(u,l){return u=u>>>0,l||L(u,1,this.length),this[u]&128?(255-this[u]+1)*-1:this[u]},o.prototype.readInt16LE=function(u,l){u=u>>>0,l||L(u,2,this.length);let O=this[u]|this[u+1]<<8;return O&32768?O|4294901760:O},o.prototype.readInt16BE=function(u,l){u=u>>>0,l||L(u,2,this.length);let O=this[u+1]|this[u]<<8;return O&32768?O|4294901760:O},o.prototype.readInt32LE=function(u,l){return u=u>>>0,l||L(u,4,this.length),this[u]|this[u+1]<<8|this[u+2]<<16|this[u+3]<<24},o.prototype.readInt32BE=function(u,l){return u=u>>>0,l||L(u,4,this.length),this[u]<<24|this[u+1]<<16|this[u+2]<<8|this[u+3]},o.prototype.readBigInt64LE=Gt(function(u){u=u>>>0,$e(u,"offset");let l=this[u],O=this[u+7];(l===void 0||O===void 0)&&Re(u,this.length-8);let A=this[u+4]+this[u+5]*2**8+this[u+6]*2**16+(O<<24);return(BigInt(A)<<BigInt(32))+BigInt(l+this[++u]*2**8+this[++u]*2**16+this[++u]*2**24)}),o.prototype.readBigInt64BE=Gt(function(u){u=u>>>0,$e(u,"offset");let l=this[u],O=this[u+7];(l===void 0||O===void 0)&&Re(u,this.length-8);let A=(l<<24)+this[++u]*2**16+this[++u]*2**8+this[++u];return(BigInt(A)<<BigInt(32))+BigInt(this[++u]*2**24+this[++u]*2**16+this[++u]*2**8+O)}),o.prototype.readFloatLE=function(u,l){return u=u>>>0,l||L(u,4,this.length),e.read(this,u,!0,23,4)},o.prototype.readFloatBE=function(u,l){return u=u>>>0,l||L(u,4,this.length),e.read(this,u,!1,23,4)},o.prototype.readDoubleLE=function(u,l){return u=u>>>0,l||L(u,8,this.length),e.read(this,u,!0,52,8)},o.prototype.readDoubleBE=function(u,l){return u=u>>>0,l||L(u,8,this.length),e.read(this,u,!1,52,8)};function B($,u,l,O,A,j){if(!o.isBuffer($))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>A||u<j)throw new RangeError('"value" argument is out of bounds');if(l+O>$.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(u,l,O,A){if(u=+u,l=l>>>0,O=O>>>0,!A){let he=Math.pow(2,8*O)-1;B(this,u,l,O,he,0)}let j=1,U=0;for(this[l]=u&255;++U<O&&(j*=256);)this[l+U]=u/j&255;return l+O},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(u,l,O,A){if(u=+u,l=l>>>0,O=O>>>0,!A){let he=Math.pow(2,8*O)-1;B(this,u,l,O,he,0)}let j=O-1,U=1;for(this[l+j]=u&255;--j>=0&&(U*=256);)this[l+j]=u/U&255;return l+O},o.prototype.writeUint8=o.prototype.writeUInt8=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,1,255,0),this[l]=u&255,l+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,2,65535,0),this[l]=u&255,this[l+1]=u>>>8,l+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,2,65535,0),this[l]=u>>>8,this[l+1]=u&255,l+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,4,4294967295,0),this[l+3]=u>>>24,this[l+2]=u>>>16,this[l+1]=u>>>8,this[l]=u&255,l+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,4,4294967295,0),this[l]=u>>>24,this[l+1]=u>>>16,this[l+2]=u>>>8,this[l+3]=u&255,l+4};function F($,u,l,O,A){Ee(u,O,A,$,l,7);let j=Number(u&BigInt(4294967295));$[l++]=j,j=j>>8,$[l++]=j,j=j>>8,$[l++]=j,j=j>>8,$[l++]=j;let U=Number(u>>BigInt(32)&BigInt(4294967295));return $[l++]=U,U=U>>8,$[l++]=U,U=U>>8,$[l++]=U,U=U>>8,$[l++]=U,l}function X($,u,l,O,A){Ee(u,O,A,$,l,7);let j=Number(u&BigInt(4294967295));$[l+7]=j,j=j>>8,$[l+6]=j,j=j>>8,$[l+5]=j,j=j>>8,$[l+4]=j;let U=Number(u>>BigInt(32)&BigInt(4294967295));return $[l+3]=U,U=U>>8,$[l+2]=U,U=U>>8,$[l+1]=U,U=U>>8,$[l]=U,l+8}o.prototype.writeBigUInt64LE=Gt(function(u,l=0){return F(this,u,l,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Gt(function(u,l=0){return X(this,u,l,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(u,l,O,A){if(u=+u,l=l>>>0,!A){let Ce=Math.pow(2,8*O-1);B(this,u,l,O,Ce-1,-Ce)}let j=0,U=1,he=0;for(this[l]=u&255;++j<O&&(U*=256);)u<0&&he===0&&this[l+j-1]!==0&&(he=1),this[l+j]=(u/U>>0)-he&255;return l+O},o.prototype.writeIntBE=function(u,l,O,A){if(u=+u,l=l>>>0,!A){let Ce=Math.pow(2,8*O-1);B(this,u,l,O,Ce-1,-Ce)}let j=O-1,U=1,he=0;for(this[l+j]=u&255;--j>=0&&(U*=256);)u<0&&he===0&&this[l+j+1]!==0&&(he=1),this[l+j]=(u/U>>0)-he&255;return l+O},o.prototype.writeInt8=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,1,127,-128),u<0&&(u=255+u+1),this[l]=u&255,l+1},o.prototype.writeInt16LE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,2,32767,-32768),this[l]=u&255,this[l+1]=u>>>8,l+2},o.prototype.writeInt16BE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,2,32767,-32768),this[l]=u>>>8,this[l+1]=u&255,l+2},o.prototype.writeInt32LE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,4,2147483647,-2147483648),this[l]=u&255,this[l+1]=u>>>8,this[l+2]=u>>>16,this[l+3]=u>>>24,l+4},o.prototype.writeInt32BE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,4,2147483647,-2147483648),u<0&&(u=4294967295+u+1),this[l]=u>>>24,this[l+1]=u>>>16,this[l+2]=u>>>8,this[l+3]=u&255,l+4},o.prototype.writeBigInt64LE=Gt(function(u,l=0){return F(this,u,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Gt(function(u,l=0){return X(this,u,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ie($,u,l,O,A,j){if(l+O>$.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("Index out of range")}function J($,u,l,O,A){return u=+u,l=l>>>0,A||ie($,u,l,4),e.write($,u,l,O,23,4),l+4}o.prototype.writeFloatLE=function(u,l,O){return J(this,u,l,!0,O)},o.prototype.writeFloatBE=function(u,l,O){return J(this,u,l,!1,O)};function D($,u,l,O,A){return u=+u,l=l>>>0,A||ie($,u,l,8),e.write($,u,l,O,52,8),l+8}o.prototype.writeDoubleLE=function(u,l,O){return D(this,u,l,!0,O)},o.prototype.writeDoubleBE=function(u,l,O){return D(this,u,l,!1,O)},o.prototype.copy=function(u,l,O,A){if(!o.isBuffer(u))throw new TypeError("argument should be a Buffer");if(O||(O=0),!A&&A!==0&&(A=this.length),l>=u.length&&(l=u.length),l||(l=0),A>0&&A<O&&(A=O),A===O||u.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("sourceEnd out of bounds");A>this.length&&(A=this.length),u.length-l<A-O&&(A=u.length-l+O);let j=A-O;return this===u&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,O,A):Uint8Array.prototype.set.call(u,this.subarray(O,A),l),j},o.prototype.fill=function(u,l,O,A){if(typeof u=="string"){if(typeof l=="string"?(A=l,l=0,O=this.length):typeof O=="string"&&(A=O,O=this.length),A!==void 0&&typeof A!="string")throw new TypeError("encoding must be a string");if(typeof A=="string"&&!o.isEncoding(A))throw new TypeError("Unknown encoding: "+A);if(u.length===1){let U=u.charCodeAt(0);(A==="utf8"&&U<128||A==="latin1")&&(u=U)}}else typeof u=="number"?u=u&255:typeof u=="boolean"&&(u=Number(u));if(l<0||this.length<l||this.length<O)throw new RangeError("Out of range index");if(O<=l)return this;l=l>>>0,O=O===void 0?this.length:O>>>0,u||(u=0);let j;if(typeof u=="number")for(j=l;j<O;++j)this[j]=u;else{let U=o.isBuffer(u)?u:o.from(u,A),he=U.length;if(he===0)throw new TypeError('The value "'+u+'" is invalid for argument "value"');for(j=0;j<O-l;++j)this[j+l]=U[j%he]}return this};let M={};function W($,u,l){M[$]=class extends l{constructor(){super(),Object.defineProperty(this,"message",{value:u.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${$}]`,this.stack,delete this.name}get code(){return $}set code(A){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:A,writable:!0})}toString(){return`${this.name} [${$}]: ${this.message}`}}}W("ERR_BUFFER_OUT_OF_BOUNDS",function($){return $?`${$} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),W("ERR_INVALID_ARG_TYPE",function($,u){return`The "${$}" argument must be of type number. Received type ${typeof u}`},TypeError),W("ERR_OUT_OF_RANGE",function($,u,l){let O=`The value of "${$}" is out of range.`,A=l;return Number.isInteger(l)&&Math.abs(l)>2**32?A=ee(String(l)):typeof l=="bigint"&&(A=String(l),(l>BigInt(2)**BigInt(32)||l<-(BigInt(2)**BigInt(32)))&&(A=ee(A)),A+="n"),O+=` It must be ${u}. Received ${A}`,O},RangeError);function ee($){let u="",l=$.length,O=$[0]==="-"?1:0;for(;l>=O+4;l-=3)u=`_${$.slice(l-3,l)}${u}`;return`${$.slice(0,l)}${u}`}function ne($,u,l){$e(u,"offset"),($[u]===void 0||$[u+l]===void 0)&&Re(u,$.length-(l+1))}function Ee($,u,l,O,A,j){if($>l||$<u){let U=typeof u=="bigint"?"n":"",he;throw u===0||u===BigInt(0)?he=`>= 0${U} and < 2${U} ** ${(j+1)*8}${U}`:he=`>= -(2${U} ** ${(j+1)*8-1}${U}) and < 2 ** ${(j+1)*8-1}${U}`,new M.ERR_OUT_OF_RANGE("value",he,$)}ne(O,A,j)}function $e($,u){if(typeof $!="number")throw new M.ERR_INVALID_ARG_TYPE(u,"number",$)}function Re($,u,l){throw Math.floor($)!==$?($e($,l),new M.ERR_OUT_OF_RANGE("offset","an integer",$)):u<0?new M.ERR_BUFFER_OUT_OF_BOUNDS:new M.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${u}`,$)}let We=/[^+/0-9A-Za-z-_]/g;function ct($){if($=$.split("=")[0],$=$.trim().replace(We,""),$.length<2)return"";for(;$.length%4!==0;)$=$+"=";return $}function ve($,u){u=u||1/0;let l,O=$.length,A=null,j=[];for(let U=0;U<O;++U){if(l=$.charCodeAt(U),l>55295&&l<57344){if(!A){if(l>56319){(u-=3)>-1&&j.push(239,191,189);continue}else if(U+1===O){(u-=3)>-1&&j.push(239,191,189);continue}A=l;continue}if(l<56320){(u-=3)>-1&&j.push(239,191,189),A=l;continue}l=(A-55296<<10|l-56320)+65536}else A&&(u-=3)>-1&&j.push(239,191,189);if(A=null,l<128){if((u-=1)<0)break;j.push(l)}else if(l<2048){if((u-=2)<0)break;j.push(l>>6|192,l&63|128)}else if(l<65536){if((u-=3)<0)break;j.push(l>>12|224,l>>6&63|128,l&63|128)}else if(l<1114112){if((u-=4)<0)break;j.push(l>>18|240,l>>12&63|128,l>>6&63|128,l&63|128)}else throw new Error("Invalid code point")}return j}function ge($){let u=[];for(let l=0;l<$.length;++l)u.push($.charCodeAt(l)&255);return u}function Se($,u){let l,O,A,j=[];for(let U=0;U<$.length&&!((u-=2)<0);++U)l=$.charCodeAt(U),O=l>>8,A=l%256,j.push(A),j.push(O);return j}function nt($){return t.toByteArray(ct($))}function Fe($,u,l,O){let A;for(A=0;A<O&&!(A+l>=u.length||A>=$.length);++A)u[A+l]=$[A];return A}function Pe($,u){return $ instanceof u||$!=null&&$.constructor!=null&&$.constructor.name!=null&&$.constructor.name===u.name}function er($){return $!==$}let tr=function(){let $="0123456789abcdef",u=new Array(256);for(let l=0;l<16;++l){let O=l*16;for(let A=0;A<16;++A)u[O+A]=$[l]+$[A]}return u}();function Gt($){return typeof BigInt>"u"?tp:$}function tp(){throw new Error("BigInt not supported")}return nr}var tn,qc,Hn,kc,nr,Cc,jc=Ar(()=>{I();R();T();tn={},qc=!1;Hn={},kc=!1;nr={},Cc=!1});var ir,K,ab,ub,Nc=Ar(()=>{I();R();T();jc();ir=xc();ir.Buffer;ir.SlowBuffer;ir.INSPECT_MAX_BYTES;ir.kMaxLength;K=ir.Buffer,ab=ir.INSPECT_MAX_BYTES,ub=ir.kMaxLength});var R=Ar(()=>{Nc()});var on=Y(we=>{"use strict";I();R();T();Object.defineProperty(we,"__esModule",{value:!0});we.regexpCode=we.getEsmExportName=we.getProperty=we.safeStringify=we.stringify=we.strConcat=we.addCodeArg=we.str=we._=we.nil=we._Code=we.Name=we.IDENTIFIER=we._CodeOrName=void 0;var nn=class{};we._CodeOrName=nn;we.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var sr=class extends nn{constructor(e){if(super(),!we.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};we.Name=sr;var ft=class extends nn{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof sr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};we._Code=ft;we.nil=new ft("");function Wc(t,...e){let r=[t[0]],n=0;for(;n<e.length;)gs(r,e[n]),r.push(t[++n]);return new ft(r)}we._=Wc;var ys=new ft("+");function Qc(t,...e){let r=[sn(t[0])],n=0;for(;n<e.length;)r.push(ys),gs(r,e[n]),r.push(ys,sn(t[++n]));return lp(r),new ft(r)}we.str=Qc;function gs(t,e){e instanceof ft?t.push(...e._items):e instanceof sr?t.push(e):t.push(pp(e))}we.addCodeArg=gs;function lp(t){let e=1;for(;e<t.length-1;){if(t[e]===ys){let r=dp(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function dp(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof sr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof sr))return`"${t}${e.slice(1)}`}function hp(t,e){return e.emptyStr()?t:t.emptyStr()?e:Qc`${t}${e}`}we.strConcat=hp;function pp(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:sn(Array.isArray(t)?t.join(","):t)}function mp(t){return new ft(sn(t))}we.stringify=mp;function sn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}we.safeStringify=sn;function vp(t){return typeof t=="string"&&we.IDENTIFIER.test(t)?new ft(`.${t}`):Wc`[${t}]`}we.getProperty=vp;function yp(t){if(typeof t=="string"&&we.IDENTIFIER.test(t))return new ft(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}we.getEsmExportName=yp;function gp(t){return new ft(t.toString())}we.regexpCode=gp});var bs=Y(st=>{"use strict";I();R();T();Object.defineProperty(st,"__esModule",{value:!0});st.ValueScope=st.ValueScopeName=st.Scope=st.varKinds=st.UsedValueState=void 0;var it=on(),_s=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Qn;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Qn||(st.UsedValueState=Qn={}));st.varKinds={const:new it.Name("const"),let:new it.Name("let"),var:new it.Name("var")};var Yn=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof it.Name?e:this.name(e)}name(e){return new it.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};st.Scope=Yn;var Xn=class extends it.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,it._)`.${new it.Name(r)}[${n}]`}};st.ValueScopeName=Xn;var _p=(0,it._)`\n`,ws=class extends Yn{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?_p:it.nil}}get(){return this._scope}name(e){return new Xn(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:s}=i,o=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let m=a.get(o);if(m)return m}else a=this._values[s]=new Map;a.set(o,i);let c=this._scope[s]||(this._scope[s]=[]),d=c.length;return c[d]=r.ref,i.setValue(r,{property:s,itemIndex:d}),i}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,it._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(e,r,n={},i){let s=it.nil;for(let o in e){let a=e[o];if(!a)continue;let c=n[o]=n[o]||new Map;a.forEach(d=>{if(c.has(d))return;c.set(d,Qn.Started);let m=r(d);if(m){let f=this.opts.es5?st.varKinds.var:st.varKinds.const;s=(0,it._)`${s}${f} ${d} = ${m};${this.opts._n}`}else if(m=i?.(d))s=(0,it._)`${s}${m}${this.opts._n}`;else throw new _s(d);c.set(d,Qn.Completed)})}return s}};st.ValueScope=ws});var pe=Y(le=>{"use strict";I();R();T();Object.defineProperty(le,"__esModule",{value:!0});le.or=le.and=le.not=le.CodeGen=le.operators=le.varKinds=le.ValueScopeName=le.ValueScope=le.Scope=le.Name=le.regexpCode=le.stringify=le.getProperty=le.nil=le.strConcat=le.str=le._=void 0;var ye=on(),yt=bs(),zt=on();Object.defineProperty(le,"_",{enumerable:!0,get:function(){return zt._}});Object.defineProperty(le,"str",{enumerable:!0,get:function(){return zt.str}});Object.defineProperty(le,"strConcat",{enumerable:!0,get:function(){return zt.strConcat}});Object.defineProperty(le,"nil",{enumerable:!0,get:function(){return zt.nil}});Object.defineProperty(le,"getProperty",{enumerable:!0,get:function(){return zt.getProperty}});Object.defineProperty(le,"stringify",{enumerable:!0,get:function(){return zt.stringify}});Object.defineProperty(le,"regexpCode",{enumerable:!0,get:function(){return zt.regexpCode}});Object.defineProperty(le,"Name",{enumerable:!0,get:function(){return zt.Name}});var ri=bs();Object.defineProperty(le,"Scope",{enumerable:!0,get:function(){return ri.Scope}});Object.defineProperty(le,"ValueScope",{enumerable:!0,get:function(){return ri.ValueScope}});Object.defineProperty(le,"ValueScopeName",{enumerable:!0,get:function(){return ri.ValueScopeName}});Object.defineProperty(le,"varKinds",{enumerable:!0,get:function(){return ri.varKinds}});le.operators={GT:new ye._Code(">"),GTE:new ye._Code(">="),LT:new ye._Code("<"),LTE:new ye._Code("<="),EQ:new ye._Code("==="),NEQ:new ye._Code("!=="),NOT:new ye._Code("!"),OR:new ye._Code("||"),AND:new ye._Code("&&"),ADD:new ye._Code("+")};var Nt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Es=class extends Nt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?yt.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=qr(this.rhs,e,r)),this}get names(){return this.rhs instanceof ye._CodeOrName?this.rhs.names:{}}},Zn=class extends Nt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ye.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=qr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ye.Name?{}:{...this.lhs.names};return ti(e,this.rhs)}},$s=class extends Zn{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Ss=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Ps=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Os=class extends Nt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},As=class extends Nt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=qr(this.code,e,r),this}get names(){return this.code instanceof ye._CodeOrName?this.code.names:{}}},an=class extends Nt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,i=n.length;for(;i--;){let s=n[i];s.optimizeNames(e,r)||(wp(e,s.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>ur(e,r.names),{})}},Dt=class extends an{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Is=class extends an{},Rr=class extends Dt{};Rr.kind="else";var or=class t extends Dt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Rr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Yc(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=qr(this.condition,e,r),this}get names(){let e=super.names;return ti(e,this.condition),this.else&&ur(e,this.else.names),e}};or.kind="if";var ar=class extends Dt{};ar.kind="for";var Ts=class extends ar{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=qr(this.iteration,e,r),this}get names(){return ur(super.names,this.iteration.names)}},Rs=class extends ar{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?yt.varKinds.var:this.varKind,{name:n,from:i,to:s}=this;return`for(${r} ${n}=${i}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=ti(super.names,this.from);return ti(e,this.to)}},ei=class extends ar{constructor(e,r,n,i){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=qr(this.iterable,e,r),this}get names(){return ur(super.names,this.iterable.names)}},un=class extends Dt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};un.kind="func";var cn=class extends an{render(e){return"return "+super.render(e)}};cn.kind="return";var qs=class extends Dt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,i;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(i=this.finally)===null||i===void 0||i.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&ur(e,this.catch.names),this.finally&&ur(e,this.finally.names),e}},fn=class extends Dt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};fn.kind="catch";var ln=class extends Dt{render(e){return"finally"+super.render(e)}};ln.kind="finally";var ks=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
- `:""},this._extScope=e,this._scope=new yt.Scope({parent:e}),this._nodes=[new Is]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,i){let s=this._scope.toName(r);return n!==void 0&&i&&(this._constants[s.str]=n),this._leafNode(new Es(e,s,n)),s}const(e,r,n){return this._def(yt.varKinds.const,e,r,n)}let(e,r,n){return this._def(yt.varKinds.let,e,r,n)}var(e,r,n){return this._def(yt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Zn(e,r,n))}add(e,r){return this._leafNode(new $s(e,le.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ye.nil&&this._leafNode(new As(e)),this}object(...e){let r=["{"];for(let[n,i]of e)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,ye.addCodeArg)(r,i));return r.push("}"),new ye._Code(r)}if(e,r,n){if(this._blockNode(new or(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new or(e))}else(){return this._elseNode(new Rr)}endIf(){return this._endBlockNode(or,Rr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ts(e),r)}forRange(e,r,n,i,s=this.opts.es5?yt.varKinds.var:yt.varKinds.let){let o=this._scope.toName(e);return this._for(new Rs(s,o,r,n),()=>i(o))}forOf(e,r,n,i=yt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let o=r instanceof ye.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ye._)`${o}.length`,a=>{this.var(s,(0,ye._)`${o}[${a}]`),n(s)})}return this._for(new ei("of",i,s,r),()=>n(s))}forIn(e,r,n,i=this.opts.es5?yt.varKinds.var:yt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ye._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new ei("in",i,s,r),()=>n(s))}endFor(){return this._endBlockNode(ar)}label(e){return this._leafNode(new Ss(e))}break(e){return this._leafNode(new Ps(e))}return(e){let r=new cn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(cn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new qs;if(this._blockNode(i),this.code(e),r){let s=this.name("e");this._currNode=i.catch=new fn(s),r(s)}return n&&(this._currNode=i.finally=new ln,this.code(n)),this._endBlockNode(fn,ln)}throw(e){return this._leafNode(new Os(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ye.nil,n,i){return this._blockNode(new un(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(un)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof or))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};le.CodeGen=ks;function ur(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function ti(t,e){return e instanceof ye._CodeOrName?ur(t,e.names):t}function qr(t,e,r){if(t instanceof ye.Name)return n(t);if(!i(t))return t;return new ye._Code(t._items.reduce((s,o)=>(o instanceof ye.Name&&(o=n(o)),o instanceof ye._Code?s.push(...o._items):s.push(o),s),[]));function n(s){let o=r[s.str];return o===void 0||e[s.str]!==1?s:(delete e[s.str],o)}function i(s){return s instanceof ye._Code&&s._items.some(o=>o instanceof ye.Name&&e[o.str]===1&&r[o.str]!==void 0)}}function wp(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Yc(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ye._)`!${Cs(t)}`}le.not=Yc;var bp=Xc(le.operators.AND);function Ep(...t){return t.reduce(bp)}le.and=Ep;var $p=Xc(le.operators.OR);function Sp(...t){return t.reduce($p)}le.or=Sp;function Xc(t){return(e,r)=>e===ye.nil?r:r===ye.nil?e:(0,ye._)`${Cs(e)} ${t} ${Cs(r)}`}function Cs(t){return t instanceof ye.Name?t:(0,ye._)`(${t})`}});var be=Y(de=>{"use strict";I();R();T();Object.defineProperty(de,"__esModule",{value:!0});de.checkStrictMode=de.getErrorPath=de.Type=de.useFunc=de.setEvaluated=de.evaluatedPropsToName=de.mergeEvaluated=de.eachItem=de.unescapeJsonPointer=de.escapeJsonPointer=de.escapeFragment=de.unescapeFragment=de.schemaRefOrVal=de.schemaHasRulesButRef=de.schemaHasRules=de.checkUnknownRules=de.alwaysValidSchema=de.toHash=void 0;var Ie=pe(),Pp=on();function Op(t){let e={};for(let r of t)e[r]=!0;return e}de.toHash=Op;function Ap(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(tf(t,e),!rf(e,t.self.RULES.all))}de.alwaysValidSchema=Ap;function tf(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let i=n.RULES.keywords;for(let s in e)i[s]||of(t,`unknown keyword: "${s}"`)}de.checkUnknownRules=tf;function rf(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}de.schemaHasRules=rf;function Ip(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}de.schemaHasRulesButRef=Ip;function Tp({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Ie._)`${r}`}return(0,Ie._)`${t}${e}${(0,Ie.getProperty)(n)}`}de.schemaRefOrVal=Tp;function Rp(t){return nf(decodeURIComponent(t))}de.unescapeFragment=Rp;function qp(t){return encodeURIComponent(js(t))}de.escapeFragment=qp;function js(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}de.escapeJsonPointer=js;function nf(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}de.unescapeJsonPointer=nf;function kp(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}de.eachItem=kp;function Zc({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,s,o,a)=>{let c=o===void 0?s:o instanceof Ie.Name?(s instanceof Ie.Name?t(i,s,o):e(i,s,o),o):s instanceof Ie.Name?(e(i,o,s),s):r(s,o);return a===Ie.Name&&!(c instanceof Ie.Name)?n(i,c):c}}de.mergeEvaluated={props:Zc({mergeNames:(t,e,r)=>t.if((0,Ie._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Ie._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Ie._)`${r} || {}`).code((0,Ie._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Ie._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Ie._)`${r} || {}`),Ns(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:sf}),items:Zc({mergeNames:(t,e,r)=>t.if((0,Ie._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Ie._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Ie._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Ie._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function sf(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Ie._)`{}`);return e!==void 0&&Ns(t,r,e),r}de.evaluatedPropsToName=sf;function Ns(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Ie._)`${e}${(0,Ie.getProperty)(n)}`,!0))}de.setEvaluated=Ns;var ef={};function Cp(t,e){return t.scopeValue("func",{ref:e,code:ef[e.code]||(ef[e.code]=new Pp._Code(e.code))})}de.useFunc=Cp;var xs;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(xs||(de.Type=xs={}));function xp(t,e,r){if(t instanceof Ie.Name){let n=e===xs.Num;return r?n?(0,Ie._)`"[" + ${t} + "]"`:(0,Ie._)`"['" + ${t} + "']"`:n?(0,Ie._)`"/" + ${t}`:(0,Ie._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Ie.getProperty)(t).toString():"/"+js(t)}de.getErrorPath=xp;function of(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}de.checkStrictMode=of});var Bt=Y(Ds=>{"use strict";I();R();T();Object.defineProperty(Ds,"__esModule",{value:!0});var Ye=pe(),jp={data:new Ye.Name("data"),valCxt:new Ye.Name("valCxt"),instancePath:new Ye.Name("instancePath"),parentData:new Ye.Name("parentData"),parentDataProperty:new Ye.Name("parentDataProperty"),rootData:new Ye.Name("rootData"),dynamicAnchors:new Ye.Name("dynamicAnchors"),vErrors:new Ye.Name("vErrors"),errors:new Ye.Name("errors"),this:new Ye.Name("this"),self:new Ye.Name("self"),scope:new Ye.Name("scope"),json:new Ye.Name("json"),jsonPos:new Ye.Name("jsonPos"),jsonLen:new Ye.Name("jsonLen"),jsonPart:new Ye.Name("jsonPart")};Ds.default=jp});var dn=Y(Xe=>{"use strict";I();R();T();Object.defineProperty(Xe,"__esModule",{value:!0});Xe.extendErrors=Xe.resetErrorsCount=Xe.reportExtraError=Xe.reportError=Xe.keyword$DataError=Xe.keywordError=void 0;var _e=pe(),ni=be(),et=Bt();Xe.keywordError={message:({keyword:t})=>(0,_e.str)`must pass "${t}" keyword validation`};Xe.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,_e.str)`"${t}" keyword must be ${e} ($data)`:(0,_e.str)`"${t}" keyword is invalid ($data)`};function Np(t,e=Xe.keywordError,r,n){let{it:i}=t,{gen:s,compositeRule:o,allErrors:a}=i,c=cf(t,e,r);n??(o||a)?af(s,c):uf(i,(0,_e._)`[${c}]`)}Xe.reportError=Np;function Dp(t,e=Xe.keywordError,r){let{it:n}=t,{gen:i,compositeRule:s,allErrors:o}=n,a=cf(t,e,r);af(i,a),s||o||uf(n,et.default.vErrors)}Xe.reportExtraError=Dp;function Bp(t,e){t.assign(et.default.errors,e),t.if((0,_e._)`${et.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,_e._)`${et.default.vErrors}.length`,e),()=>t.assign(et.default.vErrors,null)))}Xe.resetErrorsCount=Bp;function Lp({gen:t,keyword:e,schemaValue:r,data:n,errsCount:i,it:s}){if(i===void 0)throw new Error("ajv implementation error");let o=t.name("err");t.forRange("i",i,et.default.errors,a=>{t.const(o,(0,_e._)`${et.default.vErrors}[${a}]`),t.if((0,_e._)`${o}.instancePath === undefined`,()=>t.assign((0,_e._)`${o}.instancePath`,(0,_e.strConcat)(et.default.instancePath,s.errorPath))),t.assign((0,_e._)`${o}.schemaPath`,(0,_e.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,_e._)`${o}.schema`,r),t.assign((0,_e._)`${o}.data`,n))})}Xe.extendErrors=Lp;function af(t,e){let r=t.const("err",e);t.if((0,_e._)`${et.default.vErrors} === null`,()=>t.assign(et.default.vErrors,(0,_e._)`[${r}]`),(0,_e._)`${et.default.vErrors}.push(${r})`),t.code((0,_e._)`${et.default.errors}++`)}function uf(t,e){let{gen:r,validateName:n,schemaEnv:i}=t;i.$async?r.throw((0,_e._)`new ${t.ValidationError}(${e})`):(r.assign((0,_e._)`${n}.errors`,e),r.return(!1))}var cr={keyword:new _e.Name("keyword"),schemaPath:new _e.Name("schemaPath"),params:new _e.Name("params"),propertyName:new _e.Name("propertyName"),message:new _e.Name("message"),schema:new _e.Name("schema"),parentSchema:new _e.Name("parentSchema")};function cf(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,_e._)`{}`:Mp(t,e,r)}function Mp(t,e,r={}){let{gen:n,it:i}=t,s=[Up(i,r),Gp(t,r)];return Fp(t,e,s),n.object(...s)}function Up({errorPath:t},{instancePath:e}){let r=e?(0,_e.str)`${t}${(0,ni.getErrorPath)(e,ni.Type.Str)}`:t;return[et.default.instancePath,(0,_e.strConcat)(et.default.instancePath,r)]}function Gp({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let i=n?e:(0,_e.str)`${e}/${t}`;return r&&(i=(0,_e.str)`${i}${(0,ni.getErrorPath)(r,ni.Type.Str)}`),[cr.schemaPath,i]}function Fp(t,{params:e,message:r},n){let{keyword:i,data:s,schemaValue:o,it:a}=t,{opts:c,propertyName:d,topSchemaRef:m,schemaPath:f}=a;n.push([cr.keyword,i],[cr.params,typeof e=="function"?e(t):e||(0,_e._)`{}`]),c.messages&&n.push([cr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([cr.schema,o],[cr.parentSchema,(0,_e._)`${m}${f}`],[et.default.data,s]),d&&n.push([cr.propertyName,d])}});var lf=Y(kr=>{"use strict";I();R();T();Object.defineProperty(kr,"__esModule",{value:!0});kr.boolOrEmptySchema=kr.topBoolOrEmptySchema=void 0;var zp=dn(),Kp=pe(),Vp=Bt(),Jp={message:"boolean schema is false"};function Hp(t){let{gen:e,schema:r,validateName:n}=t;r===!1?ff(t,!1):typeof r=="object"&&r.$async===!0?e.return(Vp.default.data):(e.assign((0,Kp._)`${n}.errors`,null),e.return(!0))}kr.topBoolOrEmptySchema=Hp;function Wp(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),ff(t)):r.var(e,!0)}kr.boolOrEmptySchema=Wp;function ff(t,e){let{gen:r,data:n}=t,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,zp.reportError)(i,Jp,void 0,e)}});var Bs=Y(Cr=>{"use strict";I();R();T();Object.defineProperty(Cr,"__esModule",{value:!0});Cr.getRules=Cr.isJSONType=void 0;var Qp=["string","number","integer","boolean","null","object","array"],Yp=new Set(Qp);function Xp(t){return typeof t=="string"&&Yp.has(t)}Cr.isJSONType=Xp;function Zp(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Cr.getRules=Zp});var Ls=Y(Kt=>{"use strict";I();R();T();Object.defineProperty(Kt,"__esModule",{value:!0});Kt.shouldUseRule=Kt.shouldUseGroup=Kt.schemaHasRulesForType=void 0;function em({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&df(t,n)}Kt.schemaHasRulesForType=em;function df(t,e){return e.rules.some(r=>hf(t,r))}Kt.shouldUseGroup=df;function hf(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Kt.shouldUseRule=hf});var hn=Y(Ze=>{"use strict";I();R();T();Object.defineProperty(Ze,"__esModule",{value:!0});Ze.reportTypeError=Ze.checkDataTypes=Ze.checkDataType=Ze.coerceAndCheckDataType=Ze.getJSONTypes=Ze.getSchemaTypes=Ze.DataType=void 0;var tm=Bs(),rm=Ls(),nm=dn(),ue=pe(),pf=be(),xr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(xr||(Ze.DataType=xr={}));function im(t){let e=mf(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ze.getSchemaTypes=im;function mf(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(tm.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ze.getJSONTypes=mf;function sm(t,e){let{gen:r,data:n,opts:i}=t,s=om(e,i.coerceTypes),o=e.length>0&&!(s.length===0&&e.length===1&&(0,rm.schemaHasRulesForType)(t,e[0]));if(o){let a=Us(e,n,i.strictNumbers,xr.Wrong);r.if(a,()=>{s.length?am(t,e,s):Gs(t)})}return o}Ze.coerceAndCheckDataType=sm;var vf=new Set(["string","number","integer","boolean","null"]);function om(t,e){return e?t.filter(r=>vf.has(r)||e==="array"&&r==="array"):[]}function am(t,e,r){let{gen:n,data:i,opts:s}=t,o=n.let("dataType",(0,ue._)`typeof ${i}`),a=n.let("coerced",(0,ue._)`undefined`);s.coerceTypes==="array"&&n.if((0,ue._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,ue._)`${i}[0]`).assign(o,(0,ue._)`typeof ${i}`).if(Us(e,i,s.strictNumbers),()=>n.assign(a,i))),n.if((0,ue._)`${a} !== undefined`);for(let d of r)(vf.has(d)||d==="array"&&s.coerceTypes==="array")&&c(d);n.else(),Gs(t),n.endIf(),n.if((0,ue._)`${a} !== undefined`,()=>{n.assign(i,a),um(t,a)});function c(d){switch(d){case"string":n.elseIf((0,ue._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,ue._)`"" + ${i}`).elseIf((0,ue._)`${i} === null`).assign(a,(0,ue._)`""`);return;case"number":n.elseIf((0,ue._)`${o} == "boolean" || ${i} === null
1
+ var rp=Object.create;var ds=Object.defineProperty;var np=Object.getOwnPropertyDescriptor;var ip=Object.getOwnPropertyNames;var sp=Object.getPrototypeOf,op=Object.prototype.hasOwnProperty;var Ar=(t,e)=>()=>(t&&(e=t(t=0)),e);var Y=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),hs=(t,e)=>{for(var r in e)ds(t,r,{get:e[r],enumerable:!0})},ap=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ip(e))!op.call(t,i)&&i!==r&&ds(t,i,{get:()=>e[i],enumerable:!(n=np(e,i))||n.enumerable});return t};var en=(t,e,r)=>(r=t!=null?rp(sp(t)):{},ap(e||!t||!t.__esModule?ds(r,"default",{value:t,enumerable:!0}):r,t));var I=Ar(()=>{});var z={};hs(z,{_debugEnd:()=>rc,_debugProcess:()=>tc,_events:()=>gc,_eventsCount:()=>_c,_exiting:()=>ju,_fatalExceptions:()=>Yu,_getActiveHandles:()=>Mu,_getActiveRequests:()=>Lu,_kill:()=>Gu,_linkedBinding:()=>xu,_maxListeners:()=>yc,_preload_modules:()=>pc,_rawDebug:()=>ku,_startProfilerIdleNotifier:()=>nc,_stopProfilerIdleNotifier:()=>ic,_tickCallback:()=>ec,abort:()=>uc,addListener:()=>wc,allowedNodeEnvironmentFlags:()=>Hu,arch:()=>gu,argv:()=>bu,argv0:()=>hc,assert:()=>Wu,binding:()=>Ou,browser:()=>qu,chdir:()=>Tu,config:()=>Du,cpuUsage:()=>Jn,cwd:()=>Iu,debugPort:()=>dc,default:()=>Tc,dlopen:()=>Bu,domain:()=>Nu,emit:()=>Pc,emitWarning:()=>Pu,env:()=>wu,execArgv:()=>Eu,execPath:()=>lc,exit:()=>Vu,features:()=>Qu,hasUncaughtExceptionCaptureCallback:()=>Zu,hrtime:()=>Vn,kill:()=>Ku,listeners:()=>Ic,memoryUsage:()=>zu,moduleLoadList:()=>Cu,nextTick:()=>mu,off:()=>Ec,on:()=>Nt,once:()=>bc,openStdin:()=>Ju,pid:()=>cc,platform:()=>_u,ppid:()=>fc,prependListener:()=>Oc,prependOnceListener:()=>Ac,reallyExit:()=>Uu,release:()=>Ru,removeAllListeners:()=>Sc,removeListener:()=>$c,resourceUsage:()=>Fu,setSourceMapsEnabled:()=>mc,setUncaughtExceptionCaptureCallback:()=>Xu,stderr:()=>oc,stdin:()=>ac,stdout:()=>sc,title:()=>yu,umask:()=>Au,uptime:()=>vc,version:()=>$u,versions:()=>Su});function vs(t){throw new Error("Node.js process "+t+" is not supported by JSPM core outside of Node.js")}function up(){!Ir||!rr||(Ir=!1,rr.length?xt=rr.concat(xt):Kn=-1,xt.length&&pu())}function pu(){if(!Ir){var t=setTimeout(up,0);Ir=!0;for(var e=xt.length;e;){for(rr=xt,xt=[];++Kn<e;)rr&&rr[Kn].run();Kn=-1,e=xt.length}rr=null,Ir=!1,clearTimeout(t)}}function mu(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];xt.push(new vu(t,e)),xt.length===1&&!Ir&&setTimeout(pu,0)}function vu(t,e){this.fun=t,this.array=e}function Qe(){}function xu(t){vs("_linkedBinding")}function Bu(t){vs("dlopen")}function Lu(){return[]}function Mu(){return[]}function Wu(t,e){if(!t)throw new Error(e||"assertion error")}function Zu(){return!1}function vc(){return Ft.now()/1e3}function Vn(t){var e=Math.floor((Date.now()-Ft.now())*.001),r=Ft.now()*.001,n=Math.floor(r)+e,i=Math.floor(r%1*1e9);return t&&(n=n-t[0],i=i-t[1],i<0&&(n--,i+=ms)),[n,i]}function Nt(){return Tc}function Ic(t){return[]}var xt,Ir,rr,Kn,yu,gu,_u,wu,bu,Eu,$u,Su,Pu,Ou,Au,Iu,Tu,Ru,qu,ku,Cu,Nu,ju,Du,Uu,Gu,Jn,Fu,zu,Ku,Vu,Ju,Hu,Qu,Yu,Xu,ec,tc,rc,nc,ic,sc,oc,ac,uc,cc,fc,lc,dc,hc,pc,mc,Ft,ps,ms,yc,gc,_c,wc,bc,Ec,$c,Sc,Pc,Oc,Ac,Tc,Rc=Ar(()=>{I();R();T();xt=[],Ir=!1,Kn=-1;vu.prototype.run=function(){this.fun.apply(null,this.array)};yu="browser",gu="x64",_u="browser",wu={PATH:"/usr/bin",LANG:typeof navigator<"u"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},bu=["/usr/bin/node"],Eu=[],$u="v16.8.0",Su={},Pu=function(t,e){console.warn((e?e+": ":"")+t)},Ou=function(t){vs("binding")},Au=function(t){return 0},Iu=function(){return"/"},Tu=function(t){},Ru={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};qu=!0,ku=Qe,Cu=[];Nu={},ju=!1,Du={};Uu=Qe,Gu=Qe,Jn=function(){return{}},Fu=Jn,zu=Jn,Ku=Qe,Vu=Qe,Ju=Qe,Hu={};Qu={inspector:!1,debug:!1,uv:!1,ipv6:!1,tls_alpn:!1,tls_sni:!1,tls_ocsp:!1,tls:!1,cached_builtins:!0},Yu=Qe,Xu=Qe;ec=Qe,tc=Qe,rc=Qe,nc=Qe,ic=Qe,sc=void 0,oc=void 0,ac=void 0,uc=Qe,cc=2,fc=1,lc="/bin/usr/node",dc=9229,hc="node",pc=[],mc=Qe,Ft={now:typeof performance<"u"?performance.now.bind(performance):void 0,timing:typeof performance<"u"?performance.timing:void 0};Ft.now===void 0&&(ps=Date.now(),Ft.timing&&Ft.timing.navigationStart&&(ps=Ft.timing.navigationStart),Ft.now=()=>Date.now()-ps);ms=1e9;Vn.bigint=function(t){var e=Vn(t);return typeof BigInt>"u"?e[0]*ms+e[1]:BigInt(e[0]*ms)+BigInt(e[1])};yc=10,gc={},_c=0;wc=Nt,bc=Nt,Ec=Nt,$c=Nt,Sc=Nt,Pc=Qe,Oc=Nt,Ac=Nt;Tc={version:$u,versions:Su,arch:gu,platform:_u,browser:qu,release:Ru,_rawDebug:ku,moduleLoadList:Cu,binding:Ou,_linkedBinding:xu,_events:gc,_eventsCount:_c,_maxListeners:yc,on:Nt,addListener:wc,once:bc,off:Ec,removeListener:$c,removeAllListeners:Sc,emit:Pc,prependListener:Oc,prependOnceListener:Ac,listeners:Ic,domain:Nu,_exiting:ju,config:Du,dlopen:Bu,uptime:vc,_getActiveRequests:Lu,_getActiveHandles:Mu,reallyExit:Uu,_kill:Gu,cpuUsage:Jn,resourceUsage:Fu,memoryUsage:zu,kill:Ku,exit:Vu,openStdin:Ju,allowedNodeEnvironmentFlags:Hu,assert:Wu,features:Qu,_fatalExceptions:Yu,setUncaughtExceptionCaptureCallback:Xu,hasUncaughtExceptionCaptureCallback:Zu,emitWarning:Pu,nextTick:mu,_tickCallback:ec,_debugProcess:tc,_debugEnd:rc,_startProfilerIdleNotifier:nc,_stopProfilerIdleNotifier:ic,stdout:sc,stdin:ac,stderr:oc,abort:uc,umask:Au,chdir:Tu,cwd:Iu,env:wu,title:yu,argv:bu,execArgv:Eu,pid:cc,ppid:fc,execPath:lc,debugPort:dc,hrtime:Vn,argv0:hc,_preload_modules:pc,setSourceMapsEnabled:mc}});var T=Ar(()=>{Rc()});function cp(){if(qc)return tn;qc=!0,tn.byteLength=a,tn.toByteArray=d,tn.fromByteArray=y;for(var t=[],e=[],r=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,s=n.length;i<s;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;e[45]=62,e[95]=63;function o(_){var b=_.length;if(b%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var P=_.indexOf("=");P===-1&&(P=b);var S=P===b?0:4-P%4;return[P,S]}function a(_){var b=o(_),P=b[0],S=b[1];return(P+S)*3/4-S}function c(_,b,P){return(b+P)*3/4-P}function d(_){var b,P=o(_),S=P[0],g=P[1],w=new r(c(_,S,g)),p=0,h=g>0?S-4:S,v;for(v=0;v<h;v+=4)b=e[_.charCodeAt(v)]<<18|e[_.charCodeAt(v+1)]<<12|e[_.charCodeAt(v+2)]<<6|e[_.charCodeAt(v+3)],w[p++]=b>>16&255,w[p++]=b>>8&255,w[p++]=b&255;return g===2&&(b=e[_.charCodeAt(v)]<<2|e[_.charCodeAt(v+1)]>>4,w[p++]=b&255),g===1&&(b=e[_.charCodeAt(v)]<<10|e[_.charCodeAt(v+1)]<<4|e[_.charCodeAt(v+2)]>>2,w[p++]=b>>8&255,w[p++]=b&255),w}function m(_){return t[_>>18&63]+t[_>>12&63]+t[_>>6&63]+t[_&63]}function f(_,b,P){for(var S,g=[],w=b;w<P;w+=3)S=(_[w]<<16&16711680)+(_[w+1]<<8&65280)+(_[w+2]&255),g.push(m(S));return g.join("")}function y(_){for(var b,P=_.length,S=P%3,g=[],w=16383,p=0,h=P-S;p<h;p+=w)g.push(f(_,p,p+w>h?h:p+w));return S===1?(b=_[P-1],g.push(t[b>>2]+t[b<<4&63]+"==")):S===2&&(b=(_[P-2]<<8)+_[P-1],g.push(t[b>>10]+t[b>>4&63]+t[b<<2&63]+"=")),g.join("")}return tn}function fp(){if(kc)return Hn;kc=!0;return Hn.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,d=c>>1,m=-7,f=r?i-1:0,y=r?-1:1,_=t[e+f];for(f+=y,s=_&(1<<-m)-1,_>>=-m,m+=a;m>0;s=s*256+t[e+f],f+=y,m-=8);for(o=s&(1<<-m)-1,s>>=-m,m+=n;m>0;o=o*256+t[e+f],f+=y,m-=8);if(s===0)s=1-d;else{if(s===c)return o?NaN:(_?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-d}return(_?-1:1)*o*Math.pow(2,s-n)},Hn.write=function(t,e,r,n,i,s){var o,a,c,d=s*8-i-1,m=(1<<d)-1,f=m>>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,_=n?0:s-1,b=n?1:-1,P=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=m):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+f>=1?e+=y/c:e+=y*Math.pow(2,1-f),e*c>=2&&(o++,c/=2),o+f>=m?(a=0,o=m):o+f>=1?(a=(e*c-1)*Math.pow(2,i),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+_]=a&255,_+=b,a/=256,i-=8);for(o=o<<i|a,d+=i;d>0;t[r+_]=o&255,_+=b,o/=256,d-=8);t[r+_-b]|=P*128},Hn}function xc(){if(Cc)return nr;Cc=!0;let t=cp(),e=fp(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;nr.Buffer=o,nr.SlowBuffer=g,nr.INSPECT_MAX_BYTES=50;let n=2147483647;nr.kMaxLength=n,o.TYPED_ARRAY_SUPPORT=i(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{let $=new Uint8Array(1),u={foo:function(){return 42}};return Object.setPrototypeOf(u,Uint8Array.prototype),Object.setPrototypeOf($,u),$.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function s($){if($>n)throw new RangeError('The value "'+$+'" is invalid for option "size"');let u=new Uint8Array($);return Object.setPrototypeOf(u,o.prototype),u}function o($,u,l){if(typeof $=="number"){if(typeof u=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m($)}return a($,u,l)}o.poolSize=8192;function a($,u,l){if(typeof $=="string")return f($,u);if(ArrayBuffer.isView($))return _($);if($==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof $);if(Pe($,ArrayBuffer)||$&&Pe($.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Pe($,SharedArrayBuffer)||$&&Pe($.buffer,SharedArrayBuffer)))return b($,u,l);if(typeof $=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let O=$.valueOf&&$.valueOf();if(O!=null&&O!==$)return o.from(O,u,l);let A=P($);if(A)return A;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof $[Symbol.toPrimitive]=="function")return o.from($[Symbol.toPrimitive]("string"),u,l);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof $)}o.from=function($,u,l){return a($,u,l)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function c($){if(typeof $!="number")throw new TypeError('"size" argument must be of type number');if($<0)throw new RangeError('The value "'+$+'" is invalid for option "size"')}function d($,u,l){return c($),$<=0?s($):u!==void 0?typeof l=="string"?s($).fill(u,l):s($).fill(u):s($)}o.alloc=function($,u,l){return d($,u,l)};function m($){return c($),s($<0?0:S($)|0)}o.allocUnsafe=function($){return m($)},o.allocUnsafeSlow=function($){return m($)};function f($,u){if((typeof u!="string"||u==="")&&(u="utf8"),!o.isEncoding(u))throw new TypeError("Unknown encoding: "+u);let l=w($,u)|0,O=s(l),A=O.write($,u);return A!==l&&(O=O.slice(0,A)),O}function y($){let u=$.length<0?0:S($.length)|0,l=s(u);for(let O=0;O<u;O+=1)l[O]=$[O]&255;return l}function _($){if(Pe($,Uint8Array)){let u=new Uint8Array($);return b(u.buffer,u.byteOffset,u.byteLength)}return y($)}function b($,u,l){if(u<0||$.byteLength<u)throw new RangeError('"offset" is outside of buffer bounds');if($.byteLength<u+(l||0))throw new RangeError('"length" is outside of buffer bounds');let O;return u===void 0&&l===void 0?O=new Uint8Array($):l===void 0?O=new Uint8Array($,u):O=new Uint8Array($,u,l),Object.setPrototypeOf(O,o.prototype),O}function P($){if(o.isBuffer($)){let u=S($.length)|0,l=s(u);return l.length===0||$.copy(l,0,0,u),l}if($.length!==void 0)return typeof $.length!="number"||er($.length)?s(0):y($);if($.type==="Buffer"&&Array.isArray($.data))return y($.data)}function S($){if($>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return $|0}function g($){return+$!=$&&($=0),o.alloc(+$)}o.isBuffer=function(u){return u!=null&&u._isBuffer===!0&&u!==o.prototype},o.compare=function(u,l){if(Pe(u,Uint8Array)&&(u=o.from(u,u.offset,u.byteLength)),Pe(l,Uint8Array)&&(l=o.from(l,l.offset,l.byteLength)),!o.isBuffer(u)||!o.isBuffer(l))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(u===l)return 0;let O=u.length,A=l.length;for(let N=0,U=Math.min(O,A);N<U;++N)if(u[N]!==l[N]){O=u[N],A=l[N];break}return O<A?-1:A<O?1:0},o.isEncoding=function(u){switch(String(u).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(u,l){if(!Array.isArray(u))throw new TypeError('"list" argument must be an Array of Buffers');if(u.length===0)return o.alloc(0);let O;if(l===void 0)for(l=0,O=0;O<u.length;++O)l+=u[O].length;let A=o.allocUnsafe(l),N=0;for(O=0;O<u.length;++O){let U=u[O];if(Pe(U,Uint8Array))N+U.length>A.length?(o.isBuffer(U)||(U=o.from(U)),U.copy(A,N)):Uint8Array.prototype.set.call(A,U,N);else if(o.isBuffer(U))U.copy(A,N);else throw new TypeError('"list" argument must be an Array of Buffers');N+=U.length}return A};function w($,u){if(o.isBuffer($))return $.length;if(ArrayBuffer.isView($)||Pe($,ArrayBuffer))return $.byteLength;if(typeof $!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof $);let l=$.length,O=arguments.length>2&&arguments[2]===!0;if(!O&&l===0)return 0;let A=!1;for(;;)switch(u){case"ascii":case"latin1":case"binary":return l;case"utf8":case"utf-8":return ve($).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return l*2;case"hex":return l>>>1;case"base64":return nt($).length;default:if(A)return O?-1:ve($).length;u=(""+u).toLowerCase(),A=!0}}o.byteLength=w;function p($,u,l){let O=!1;if((u===void 0||u<0)&&(u=0),u>this.length||((l===void 0||l>this.length)&&(l=this.length),l<=0)||(l>>>=0,u>>>=0,l<=u))return"";for($||($="utf8");;)switch($){case"hex":return q(this,u,l);case"utf8":case"utf-8":return Q(this,u,l);case"ascii":return fe(this,u,l);case"latin1":case"binary":return me(this,u,l);case"base64":return re(this,u,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,u,l);default:if(O)throw new TypeError("Unknown encoding: "+$);$=($+"").toLowerCase(),O=!0}}o.prototype._isBuffer=!0;function h($,u,l){let O=$[u];$[u]=$[l],$[l]=O}o.prototype.swap16=function(){let u=this.length;if(u%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let l=0;l<u;l+=2)h(this,l,l+1);return this},o.prototype.swap32=function(){let u=this.length;if(u%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let l=0;l<u;l+=4)h(this,l,l+3),h(this,l+1,l+2);return this},o.prototype.swap64=function(){let u=this.length;if(u%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let l=0;l<u;l+=8)h(this,l,l+7),h(this,l+1,l+6),h(this,l+2,l+5),h(this,l+3,l+4);return this},o.prototype.toString=function(){let u=this.length;return u===0?"":arguments.length===0?Q(this,0,u):p.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(u){if(!o.isBuffer(u))throw new TypeError("Argument must be a Buffer");return this===u?!0:o.compare(this,u)===0},o.prototype.inspect=function(){let u="",l=nr.INSPECT_MAX_BYTES;return u=this.toString("hex",0,l).replace(/(.{2})/g,"$1 ").trim(),this.length>l&&(u+=" ... "),"<Buffer "+u+">"},r&&(o.prototype[r]=o.prototype.inspect),o.prototype.compare=function(u,l,O,A,N){if(Pe(u,Uint8Array)&&(u=o.from(u,u.offset,u.byteLength)),!o.isBuffer(u))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof u);if(l===void 0&&(l=0),O===void 0&&(O=u?u.length:0),A===void 0&&(A=0),N===void 0&&(N=this.length),l<0||O>u.length||A<0||N>this.length)throw new RangeError("out of range index");if(A>=N&&l>=O)return 0;if(A>=N)return-1;if(l>=O)return 1;if(l>>>=0,O>>>=0,A>>>=0,N>>>=0,this===u)return 0;let U=N-A,he=O-l,Ce=Math.min(U,he),ke=this.slice(A,N),xe=u.slice(l,O);for(let Ae=0;Ae<Ce;++Ae)if(ke[Ae]!==xe[Ae]){U=ke[Ae],he=xe[Ae];break}return U<he?-1:he<U?1:0};function v($,u,l,O,A){if($.length===0)return-1;if(typeof l=="string"?(O=l,l=0):l>2147483647?l=2147483647:l<-2147483648&&(l=-2147483648),l=+l,er(l)&&(l=A?0:$.length-1),l<0&&(l=$.length+l),l>=$.length){if(A)return-1;l=$.length-1}else if(l<0)if(A)l=0;else return-1;if(typeof u=="string"&&(u=o.from(u,O)),o.isBuffer(u))return u.length===0?-1:E($,u,l,O,A);if(typeof u=="number")return u=u&255,typeof Uint8Array.prototype.indexOf=="function"?A?Uint8Array.prototype.indexOf.call($,u,l):Uint8Array.prototype.lastIndexOf.call($,u,l):E($,[u],l,O,A);throw new TypeError("val must be string, number or Buffer")}function E($,u,l,O,A){let N=1,U=$.length,he=u.length;if(O!==void 0&&(O=String(O).toLowerCase(),O==="ucs2"||O==="ucs-2"||O==="utf16le"||O==="utf-16le")){if($.length<2||u.length<2)return-1;N=2,U/=2,he/=2,l/=2}function Ce(xe,Ae){return N===1?xe[Ae]:xe.readUInt16BE(Ae*N)}let ke;if(A){let xe=-1;for(ke=l;ke<U;ke++)if(Ce($,ke)===Ce(u,xe===-1?0:ke-xe)){if(xe===-1&&(xe=ke),ke-xe+1===he)return xe*N}else xe!==-1&&(ke-=ke-xe),xe=-1}else for(l+he>U&&(l=U-he),ke=l;ke>=0;ke--){let xe=!0;for(let Ae=0;Ae<he;Ae++)if(Ce($,ke+Ae)!==Ce(u,Ae)){xe=!1;break}if(xe)return ke}return-1}o.prototype.includes=function(u,l,O){return this.indexOf(u,l,O)!==-1},o.prototype.indexOf=function(u,l,O){return v(this,u,l,O,!0)},o.prototype.lastIndexOf=function(u,l,O){return v(this,u,l,O,!1)};function k($,u,l,O){l=Number(l)||0;let A=$.length-l;O?(O=Number(O),O>A&&(O=A)):O=A;let N=u.length;O>N/2&&(O=N/2);let U;for(U=0;U<O;++U){let he=parseInt(u.substr(U*2,2),16);if(er(he))return U;$[l+U]=he}return U}function x($,u,l,O){return Fe(ve(u,$.length-l),$,l,O)}function j($,u,l,O){return Fe(ge(u),$,l,O)}function G($,u,l,O){return Fe(nt(u),$,l,O)}function H($,u,l,O){return Fe(Se(u,$.length-l),$,l,O)}o.prototype.write=function(u,l,O,A){if(l===void 0)A="utf8",O=this.length,l=0;else if(O===void 0&&typeof l=="string")A=l,O=this.length,l=0;else if(isFinite(l))l=l>>>0,isFinite(O)?(O=O>>>0,A===void 0&&(A="utf8")):(A=O,O=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let N=this.length-l;if((O===void 0||O>N)&&(O=N),u.length>0&&(O<0||l<0)||l>this.length)throw new RangeError("Attempt to write outside buffer bounds");A||(A="utf8");let U=!1;for(;;)switch(A){case"hex":return k(this,u,l,O);case"utf8":case"utf-8":return x(this,u,l,O);case"ascii":case"latin1":case"binary":return j(this,u,l,O);case"base64":return G(this,u,l,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,u,l,O);default:if(U)throw new TypeError("Unknown encoding: "+A);A=(""+A).toLowerCase(),U=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function re($,u,l){return u===0&&l===$.length?t.fromByteArray($):t.fromByteArray($.slice(u,l))}function Q($,u,l){l=Math.min($.length,l);let O=[],A=u;for(;A<l;){let N=$[A],U=null,he=N>239?4:N>223?3:N>191?2:1;if(A+he<=l){let Ce,ke,xe,Ae;switch(he){case 1:N<128&&(U=N);break;case 2:Ce=$[A+1],(Ce&192)===128&&(Ae=(N&31)<<6|Ce&63,Ae>127&&(U=Ae));break;case 3:Ce=$[A+1],ke=$[A+2],(Ce&192)===128&&(ke&192)===128&&(Ae=(N&15)<<12|(Ce&63)<<6|ke&63,Ae>2047&&(Ae<55296||Ae>57343)&&(U=Ae));break;case 4:Ce=$[A+1],ke=$[A+2],xe=$[A+3],(Ce&192)===128&&(ke&192)===128&&(xe&192)===128&&(Ae=(N&15)<<18|(Ce&63)<<12|(ke&63)<<6|xe&63,Ae>65535&&Ae<1114112&&(U=Ae))}}U===null?(U=65533,he=1):U>65535&&(U-=65536,O.push(U>>>10&1023|55296),U=56320|U&1023),O.push(U),A+=he}return ce(O)}let Z=4096;function ce($){let u=$.length;if(u<=Z)return String.fromCharCode.apply(String,$);let l="",O=0;for(;O<u;)l+=String.fromCharCode.apply(String,$.slice(O,O+=Z));return l}function fe($,u,l){let O="";l=Math.min($.length,l);for(let A=u;A<l;++A)O+=String.fromCharCode($[A]&127);return O}function me($,u,l){let O="";l=Math.min($.length,l);for(let A=u;A<l;++A)O+=String.fromCharCode($[A]);return O}function q($,u,l){let O=$.length;(!u||u<0)&&(u=0),(!l||l<0||l>O)&&(l=O);let A="";for(let N=u;N<l;++N)A+=tr[$[N]];return A}function C($,u,l){let O=$.slice(u,l),A="";for(let N=0;N<O.length-1;N+=2)A+=String.fromCharCode(O[N]+O[N+1]*256);return A}o.prototype.slice=function(u,l){let O=this.length;u=~~u,l=l===void 0?O:~~l,u<0?(u+=O,u<0&&(u=0)):u>O&&(u=O),l<0?(l+=O,l<0&&(l=0)):l>O&&(l=O),l<u&&(l=u);let A=this.subarray(u,l);return Object.setPrototypeOf(A,o.prototype),A};function L($,u,l){if($%1!==0||$<0)throw new RangeError("offset is not uint");if($+u>l)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(u,l,O){u=u>>>0,l=l>>>0,O||L(u,l,this.length);let A=this[u],N=1,U=0;for(;++U<l&&(N*=256);)A+=this[u+U]*N;return A},o.prototype.readUintBE=o.prototype.readUIntBE=function(u,l,O){u=u>>>0,l=l>>>0,O||L(u,l,this.length);let A=this[u+--l],N=1;for(;l>0&&(N*=256);)A+=this[u+--l]*N;return A},o.prototype.readUint8=o.prototype.readUInt8=function(u,l){return u=u>>>0,l||L(u,1,this.length),this[u]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(u,l){return u=u>>>0,l||L(u,2,this.length),this[u]|this[u+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(u,l){return u=u>>>0,l||L(u,2,this.length),this[u]<<8|this[u+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(u,l){return u=u>>>0,l||L(u,4,this.length),(this[u]|this[u+1]<<8|this[u+2]<<16)+this[u+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(u,l){return u=u>>>0,l||L(u,4,this.length),this[u]*16777216+(this[u+1]<<16|this[u+2]<<8|this[u+3])},o.prototype.readBigUInt64LE=Gt(function(u){u=u>>>0,$e(u,"offset");let l=this[u],O=this[u+7];(l===void 0||O===void 0)&&Re(u,this.length-8);let A=l+this[++u]*2**8+this[++u]*2**16+this[++u]*2**24,N=this[++u]+this[++u]*2**8+this[++u]*2**16+O*2**24;return BigInt(A)+(BigInt(N)<<BigInt(32))}),o.prototype.readBigUInt64BE=Gt(function(u){u=u>>>0,$e(u,"offset");let l=this[u],O=this[u+7];(l===void 0||O===void 0)&&Re(u,this.length-8);let A=l*2**24+this[++u]*2**16+this[++u]*2**8+this[++u],N=this[++u]*2**24+this[++u]*2**16+this[++u]*2**8+O;return(BigInt(A)<<BigInt(32))+BigInt(N)}),o.prototype.readIntLE=function(u,l,O){u=u>>>0,l=l>>>0,O||L(u,l,this.length);let A=this[u],N=1,U=0;for(;++U<l&&(N*=256);)A+=this[u+U]*N;return N*=128,A>=N&&(A-=Math.pow(2,8*l)),A},o.prototype.readIntBE=function(u,l,O){u=u>>>0,l=l>>>0,O||L(u,l,this.length);let A=l,N=1,U=this[u+--A];for(;A>0&&(N*=256);)U+=this[u+--A]*N;return N*=128,U>=N&&(U-=Math.pow(2,8*l)),U},o.prototype.readInt8=function(u,l){return u=u>>>0,l||L(u,1,this.length),this[u]&128?(255-this[u]+1)*-1:this[u]},o.prototype.readInt16LE=function(u,l){u=u>>>0,l||L(u,2,this.length);let O=this[u]|this[u+1]<<8;return O&32768?O|4294901760:O},o.prototype.readInt16BE=function(u,l){u=u>>>0,l||L(u,2,this.length);let O=this[u+1]|this[u]<<8;return O&32768?O|4294901760:O},o.prototype.readInt32LE=function(u,l){return u=u>>>0,l||L(u,4,this.length),this[u]|this[u+1]<<8|this[u+2]<<16|this[u+3]<<24},o.prototype.readInt32BE=function(u,l){return u=u>>>0,l||L(u,4,this.length),this[u]<<24|this[u+1]<<16|this[u+2]<<8|this[u+3]},o.prototype.readBigInt64LE=Gt(function(u){u=u>>>0,$e(u,"offset");let l=this[u],O=this[u+7];(l===void 0||O===void 0)&&Re(u,this.length-8);let A=this[u+4]+this[u+5]*2**8+this[u+6]*2**16+(O<<24);return(BigInt(A)<<BigInt(32))+BigInt(l+this[++u]*2**8+this[++u]*2**16+this[++u]*2**24)}),o.prototype.readBigInt64BE=Gt(function(u){u=u>>>0,$e(u,"offset");let l=this[u],O=this[u+7];(l===void 0||O===void 0)&&Re(u,this.length-8);let A=(l<<24)+this[++u]*2**16+this[++u]*2**8+this[++u];return(BigInt(A)<<BigInt(32))+BigInt(this[++u]*2**24+this[++u]*2**16+this[++u]*2**8+O)}),o.prototype.readFloatLE=function(u,l){return u=u>>>0,l||L(u,4,this.length),e.read(this,u,!0,23,4)},o.prototype.readFloatBE=function(u,l){return u=u>>>0,l||L(u,4,this.length),e.read(this,u,!1,23,4)},o.prototype.readDoubleLE=function(u,l){return u=u>>>0,l||L(u,8,this.length),e.read(this,u,!0,52,8)},o.prototype.readDoubleBE=function(u,l){return u=u>>>0,l||L(u,8,this.length),e.read(this,u,!1,52,8)};function B($,u,l,O,A,N){if(!o.isBuffer($))throw new TypeError('"buffer" argument must be a Buffer instance');if(u>A||u<N)throw new RangeError('"value" argument is out of bounds');if(l+O>$.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(u,l,O,A){if(u=+u,l=l>>>0,O=O>>>0,!A){let he=Math.pow(2,8*O)-1;B(this,u,l,O,he,0)}let N=1,U=0;for(this[l]=u&255;++U<O&&(N*=256);)this[l+U]=u/N&255;return l+O},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(u,l,O,A){if(u=+u,l=l>>>0,O=O>>>0,!A){let he=Math.pow(2,8*O)-1;B(this,u,l,O,he,0)}let N=O-1,U=1;for(this[l+N]=u&255;--N>=0&&(U*=256);)this[l+N]=u/U&255;return l+O},o.prototype.writeUint8=o.prototype.writeUInt8=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,1,255,0),this[l]=u&255,l+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,2,65535,0),this[l]=u&255,this[l+1]=u>>>8,l+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,2,65535,0),this[l]=u>>>8,this[l+1]=u&255,l+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,4,4294967295,0),this[l+3]=u>>>24,this[l+2]=u>>>16,this[l+1]=u>>>8,this[l]=u&255,l+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,4,4294967295,0),this[l]=u>>>24,this[l+1]=u>>>16,this[l+2]=u>>>8,this[l+3]=u&255,l+4};function F($,u,l,O,A){Ee(u,O,A,$,l,7);let N=Number(u&BigInt(4294967295));$[l++]=N,N=N>>8,$[l++]=N,N=N>>8,$[l++]=N,N=N>>8,$[l++]=N;let U=Number(u>>BigInt(32)&BigInt(4294967295));return $[l++]=U,U=U>>8,$[l++]=U,U=U>>8,$[l++]=U,U=U>>8,$[l++]=U,l}function X($,u,l,O,A){Ee(u,O,A,$,l,7);let N=Number(u&BigInt(4294967295));$[l+7]=N,N=N>>8,$[l+6]=N,N=N>>8,$[l+5]=N,N=N>>8,$[l+4]=N;let U=Number(u>>BigInt(32)&BigInt(4294967295));return $[l+3]=U,U=U>>8,$[l+2]=U,U=U>>8,$[l+1]=U,U=U>>8,$[l]=U,l+8}o.prototype.writeBigUInt64LE=Gt(function(u,l=0){return F(this,u,l,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeBigUInt64BE=Gt(function(u,l=0){return X(this,u,l,BigInt(0),BigInt("0xffffffffffffffff"))}),o.prototype.writeIntLE=function(u,l,O,A){if(u=+u,l=l>>>0,!A){let Ce=Math.pow(2,8*O-1);B(this,u,l,O,Ce-1,-Ce)}let N=0,U=1,he=0;for(this[l]=u&255;++N<O&&(U*=256);)u<0&&he===0&&this[l+N-1]!==0&&(he=1),this[l+N]=(u/U>>0)-he&255;return l+O},o.prototype.writeIntBE=function(u,l,O,A){if(u=+u,l=l>>>0,!A){let Ce=Math.pow(2,8*O-1);B(this,u,l,O,Ce-1,-Ce)}let N=O-1,U=1,he=0;for(this[l+N]=u&255;--N>=0&&(U*=256);)u<0&&he===0&&this[l+N+1]!==0&&(he=1),this[l+N]=(u/U>>0)-he&255;return l+O},o.prototype.writeInt8=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,1,127,-128),u<0&&(u=255+u+1),this[l]=u&255,l+1},o.prototype.writeInt16LE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,2,32767,-32768),this[l]=u&255,this[l+1]=u>>>8,l+2},o.prototype.writeInt16BE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,2,32767,-32768),this[l]=u>>>8,this[l+1]=u&255,l+2},o.prototype.writeInt32LE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,4,2147483647,-2147483648),this[l]=u&255,this[l+1]=u>>>8,this[l+2]=u>>>16,this[l+3]=u>>>24,l+4},o.prototype.writeInt32BE=function(u,l,O){return u=+u,l=l>>>0,O||B(this,u,l,4,2147483647,-2147483648),u<0&&(u=4294967295+u+1),this[l]=u>>>24,this[l+1]=u>>>16,this[l+2]=u>>>8,this[l+3]=u&255,l+4},o.prototype.writeBigInt64LE=Gt(function(u,l=0){return F(this,u,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),o.prototype.writeBigInt64BE=Gt(function(u,l=0){return X(this,u,l,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ie($,u,l,O,A,N){if(l+O>$.length)throw new RangeError("Index out of range");if(l<0)throw new RangeError("Index out of range")}function J($,u,l,O,A){return u=+u,l=l>>>0,A||ie($,u,l,4),e.write($,u,l,O,23,4),l+4}o.prototype.writeFloatLE=function(u,l,O){return J(this,u,l,!0,O)},o.prototype.writeFloatBE=function(u,l,O){return J(this,u,l,!1,O)};function D($,u,l,O,A){return u=+u,l=l>>>0,A||ie($,u,l,8),e.write($,u,l,O,52,8),l+8}o.prototype.writeDoubleLE=function(u,l,O){return D(this,u,l,!0,O)},o.prototype.writeDoubleBE=function(u,l,O){return D(this,u,l,!1,O)},o.prototype.copy=function(u,l,O,A){if(!o.isBuffer(u))throw new TypeError("argument should be a Buffer");if(O||(O=0),!A&&A!==0&&(A=this.length),l>=u.length&&(l=u.length),l||(l=0),A>0&&A<O&&(A=O),A===O||u.length===0||this.length===0)return 0;if(l<0)throw new RangeError("targetStart out of bounds");if(O<0||O>=this.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("sourceEnd out of bounds");A>this.length&&(A=this.length),u.length-l<A-O&&(A=u.length-l+O);let N=A-O;return this===u&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(l,O,A):Uint8Array.prototype.set.call(u,this.subarray(O,A),l),N},o.prototype.fill=function(u,l,O,A){if(typeof u=="string"){if(typeof l=="string"?(A=l,l=0,O=this.length):typeof O=="string"&&(A=O,O=this.length),A!==void 0&&typeof A!="string")throw new TypeError("encoding must be a string");if(typeof A=="string"&&!o.isEncoding(A))throw new TypeError("Unknown encoding: "+A);if(u.length===1){let U=u.charCodeAt(0);(A==="utf8"&&U<128||A==="latin1")&&(u=U)}}else typeof u=="number"?u=u&255:typeof u=="boolean"&&(u=Number(u));if(l<0||this.length<l||this.length<O)throw new RangeError("Out of range index");if(O<=l)return this;l=l>>>0,O=O===void 0?this.length:O>>>0,u||(u=0);let N;if(typeof u=="number")for(N=l;N<O;++N)this[N]=u;else{let U=o.isBuffer(u)?u:o.from(u,A),he=U.length;if(he===0)throw new TypeError('The value "'+u+'" is invalid for argument "value"');for(N=0;N<O-l;++N)this[N+l]=U[N%he]}return this};let M={};function W($,u,l){M[$]=class extends l{constructor(){super(),Object.defineProperty(this,"message",{value:u.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${$}]`,this.stack,delete this.name}get code(){return $}set code(A){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:A,writable:!0})}toString(){return`${this.name} [${$}]: ${this.message}`}}}W("ERR_BUFFER_OUT_OF_BOUNDS",function($){return $?`${$} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),W("ERR_INVALID_ARG_TYPE",function($,u){return`The "${$}" argument must be of type number. Received type ${typeof u}`},TypeError),W("ERR_OUT_OF_RANGE",function($,u,l){let O=`The value of "${$}" is out of range.`,A=l;return Number.isInteger(l)&&Math.abs(l)>2**32?A=ee(String(l)):typeof l=="bigint"&&(A=String(l),(l>BigInt(2)**BigInt(32)||l<-(BigInt(2)**BigInt(32)))&&(A=ee(A)),A+="n"),O+=` It must be ${u}. Received ${A}`,O},RangeError);function ee($){let u="",l=$.length,O=$[0]==="-"?1:0;for(;l>=O+4;l-=3)u=`_${$.slice(l-3,l)}${u}`;return`${$.slice(0,l)}${u}`}function ne($,u,l){$e(u,"offset"),($[u]===void 0||$[u+l]===void 0)&&Re(u,$.length-(l+1))}function Ee($,u,l,O,A,N){if($>l||$<u){let U=typeof u=="bigint"?"n":"",he;throw u===0||u===BigInt(0)?he=`>= 0${U} and < 2${U} ** ${(N+1)*8}${U}`:he=`>= -(2${U} ** ${(N+1)*8-1}${U}) and < 2 ** ${(N+1)*8-1}${U}`,new M.ERR_OUT_OF_RANGE("value",he,$)}ne(O,A,N)}function $e($,u){if(typeof $!="number")throw new M.ERR_INVALID_ARG_TYPE(u,"number",$)}function Re($,u,l){throw Math.floor($)!==$?($e($,l),new M.ERR_OUT_OF_RANGE("offset","an integer",$)):u<0?new M.ERR_BUFFER_OUT_OF_BOUNDS:new M.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${u}`,$)}let We=/[^+/0-9A-Za-z-_]/g;function ct($){if($=$.split("=")[0],$=$.trim().replace(We,""),$.length<2)return"";for(;$.length%4!==0;)$=$+"=";return $}function ve($,u){u=u||1/0;let l,O=$.length,A=null,N=[];for(let U=0;U<O;++U){if(l=$.charCodeAt(U),l>55295&&l<57344){if(!A){if(l>56319){(u-=3)>-1&&N.push(239,191,189);continue}else if(U+1===O){(u-=3)>-1&&N.push(239,191,189);continue}A=l;continue}if(l<56320){(u-=3)>-1&&N.push(239,191,189),A=l;continue}l=(A-55296<<10|l-56320)+65536}else A&&(u-=3)>-1&&N.push(239,191,189);if(A=null,l<128){if((u-=1)<0)break;N.push(l)}else if(l<2048){if((u-=2)<0)break;N.push(l>>6|192,l&63|128)}else if(l<65536){if((u-=3)<0)break;N.push(l>>12|224,l>>6&63|128,l&63|128)}else if(l<1114112){if((u-=4)<0)break;N.push(l>>18|240,l>>12&63|128,l>>6&63|128,l&63|128)}else throw new Error("Invalid code point")}return N}function ge($){let u=[];for(let l=0;l<$.length;++l)u.push($.charCodeAt(l)&255);return u}function Se($,u){let l,O,A,N=[];for(let U=0;U<$.length&&!((u-=2)<0);++U)l=$.charCodeAt(U),O=l>>8,A=l%256,N.push(A),N.push(O);return N}function nt($){return t.toByteArray(ct($))}function Fe($,u,l,O){let A;for(A=0;A<O&&!(A+l>=u.length||A>=$.length);++A)u[A+l]=$[A];return A}function Pe($,u){return $ instanceof u||$!=null&&$.constructor!=null&&$.constructor.name!=null&&$.constructor.name===u.name}function er($){return $!==$}let tr=function(){let $="0123456789abcdef",u=new Array(256);for(let l=0;l<16;++l){let O=l*16;for(let A=0;A<16;++A)u[O+A]=$[l]+$[A]}return u}();function Gt($){return typeof BigInt>"u"?tp:$}function tp(){throw new Error("BigInt not supported")}return nr}var tn,qc,Hn,kc,nr,Cc,Nc=Ar(()=>{I();R();T();tn={},qc=!1;Hn={},kc=!1;nr={},Cc=!1});var ir,K,ab,ub,jc=Ar(()=>{I();R();T();Nc();ir=xc();ir.Buffer;ir.SlowBuffer;ir.INSPECT_MAX_BYTES;ir.kMaxLength;K=ir.Buffer,ab=ir.INSPECT_MAX_BYTES,ub=ir.kMaxLength});var R=Ar(()=>{jc()});var on=Y(we=>{"use strict";I();R();T();Object.defineProperty(we,"__esModule",{value:!0});we.regexpCode=we.getEsmExportName=we.getProperty=we.safeStringify=we.stringify=we.strConcat=we.addCodeArg=we.str=we._=we.nil=we._Code=we.Name=we.IDENTIFIER=we._CodeOrName=void 0;var nn=class{};we._CodeOrName=nn;we.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var sr=class extends nn{constructor(e){if(super(),!we.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};we.Name=sr;var ft=class extends nn{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof sr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};we._Code=ft;we.nil=new ft("");function Wc(t,...e){let r=[t[0]],n=0;for(;n<e.length;)gs(r,e[n]),r.push(t[++n]);return new ft(r)}we._=Wc;var ys=new ft("+");function Qc(t,...e){let r=[sn(t[0])],n=0;for(;n<e.length;)r.push(ys),gs(r,e[n]),r.push(ys,sn(t[++n]));return lp(r),new ft(r)}we.str=Qc;function gs(t,e){e instanceof ft?t.push(...e._items):e instanceof sr?t.push(e):t.push(pp(e))}we.addCodeArg=gs;function lp(t){let e=1;for(;e<t.length-1;){if(t[e]===ys){let r=dp(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function dp(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof sr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof sr))return`"${t}${e.slice(1)}`}function hp(t,e){return e.emptyStr()?t:t.emptyStr()?e:Qc`${t}${e}`}we.strConcat=hp;function pp(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:sn(Array.isArray(t)?t.join(","):t)}function mp(t){return new ft(sn(t))}we.stringify=mp;function sn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}we.safeStringify=sn;function vp(t){return typeof t=="string"&&we.IDENTIFIER.test(t)?new ft(`.${t}`):Wc`[${t}]`}we.getProperty=vp;function yp(t){if(typeof t=="string"&&we.IDENTIFIER.test(t))return new ft(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}we.getEsmExportName=yp;function gp(t){return new ft(t.toString())}we.regexpCode=gp});var bs=Y(st=>{"use strict";I();R();T();Object.defineProperty(st,"__esModule",{value:!0});st.ValueScope=st.ValueScopeName=st.Scope=st.varKinds=st.UsedValueState=void 0;var it=on(),_s=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Qn;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Qn||(st.UsedValueState=Qn={}));st.varKinds={const:new it.Name("const"),let:new it.Name("let"),var:new it.Name("var")};var Yn=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof it.Name?e:this.name(e)}name(e){return new it.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};st.Scope=Yn;var Xn=class extends it.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,it._)`.${new it.Name(r)}[${n}]`}};st.ValueScopeName=Xn;var _p=(0,it._)`\n`,ws=class extends Yn{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?_p:it.nil}}get(){return this._scope}name(e){return new Xn(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let i=this.toName(e),{prefix:s}=i,o=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let m=a.get(o);if(m)return m}else a=this._values[s]=new Map;a.set(o,i);let c=this._scope[s]||(this._scope[s]=[]),d=c.length;return c[d]=r.ref,i.setValue(r,{property:s,itemIndex:d}),i}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,it._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,i=>{if(i.value===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return i.value.code},r,n)}_reduceValues(e,r,n={},i){let s=it.nil;for(let o in e){let a=e[o];if(!a)continue;let c=n[o]=n[o]||new Map;a.forEach(d=>{if(c.has(d))return;c.set(d,Qn.Started);let m=r(d);if(m){let f=this.opts.es5?st.varKinds.var:st.varKinds.const;s=(0,it._)`${s}${f} ${d} = ${m};${this.opts._n}`}else if(m=i?.(d))s=(0,it._)`${s}${m}${this.opts._n}`;else throw new _s(d);c.set(d,Qn.Completed)})}return s}};st.ValueScope=ws});var pe=Y(le=>{"use strict";I();R();T();Object.defineProperty(le,"__esModule",{value:!0});le.or=le.and=le.not=le.CodeGen=le.operators=le.varKinds=le.ValueScopeName=le.ValueScope=le.Scope=le.Name=le.regexpCode=le.stringify=le.getProperty=le.nil=le.strConcat=le.str=le._=void 0;var ye=on(),yt=bs(),zt=on();Object.defineProperty(le,"_",{enumerable:!0,get:function(){return zt._}});Object.defineProperty(le,"str",{enumerable:!0,get:function(){return zt.str}});Object.defineProperty(le,"strConcat",{enumerable:!0,get:function(){return zt.strConcat}});Object.defineProperty(le,"nil",{enumerable:!0,get:function(){return zt.nil}});Object.defineProperty(le,"getProperty",{enumerable:!0,get:function(){return zt.getProperty}});Object.defineProperty(le,"stringify",{enumerable:!0,get:function(){return zt.stringify}});Object.defineProperty(le,"regexpCode",{enumerable:!0,get:function(){return zt.regexpCode}});Object.defineProperty(le,"Name",{enumerable:!0,get:function(){return zt.Name}});var ri=bs();Object.defineProperty(le,"Scope",{enumerable:!0,get:function(){return ri.Scope}});Object.defineProperty(le,"ValueScope",{enumerable:!0,get:function(){return ri.ValueScope}});Object.defineProperty(le,"ValueScopeName",{enumerable:!0,get:function(){return ri.ValueScopeName}});Object.defineProperty(le,"varKinds",{enumerable:!0,get:function(){return ri.varKinds}});le.operators={GT:new ye._Code(">"),GTE:new ye._Code(">="),LT:new ye._Code("<"),LTE:new ye._Code("<="),EQ:new ye._Code("==="),NEQ:new ye._Code("!=="),NOT:new ye._Code("!"),OR:new ye._Code("||"),AND:new ye._Code("&&"),ADD:new ye._Code("+")};var jt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Es=class extends jt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?yt.varKinds.var:this.varKind,i=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${i};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=qr(this.rhs,e,r)),this}get names(){return this.rhs instanceof ye._CodeOrName?this.rhs.names:{}}},Zn=class extends jt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof ye.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=qr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ye.Name?{}:{...this.lhs.names};return ti(e,this.rhs)}},$s=class extends Zn{constructor(e,r,n,i){super(e,n,i),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Ss=class extends jt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Ps=class extends jt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Os=class extends jt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},As=class extends jt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=qr(this.code,e,r),this}get names(){return this.code instanceof ye._CodeOrName?this.code.names:{}}},an=class extends jt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,i=n.length;for(;i--;){let s=n[i];s.optimizeNames(e,r)||(wp(e,s.names),n.splice(i,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>ur(e,r.names),{})}},Dt=class extends an{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Is=class extends an{},Rr=class extends Dt{};Rr.kind="else";var or=class t extends Dt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Rr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Yc(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=qr(this.condition,e,r),this}get names(){let e=super.names;return ti(e,this.condition),this.else&&ur(e,this.else.names),e}};or.kind="if";var ar=class extends Dt{};ar.kind="for";var Ts=class extends ar{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=qr(this.iteration,e,r),this}get names(){return ur(super.names,this.iteration.names)}},Rs=class extends ar{constructor(e,r,n,i){super(),this.varKind=e,this.name=r,this.from=n,this.to=i}render(e){let r=e.es5?yt.varKinds.var:this.varKind,{name:n,from:i,to:s}=this;return`for(${r} ${n}=${i}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=ti(super.names,this.from);return ti(e,this.to)}},ei=class extends ar{constructor(e,r,n,i){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=i}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=qr(this.iterable,e,r),this}get names(){return ur(super.names,this.iterable.names)}},un=class extends Dt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};un.kind="func";var cn=class extends an{render(e){return"return "+super.render(e)}};cn.kind="return";var qs=class extends Dt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,i;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(i=this.finally)===null||i===void 0||i.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&ur(e,this.catch.names),this.finally&&ur(e,this.finally.names),e}},fn=class extends Dt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};fn.kind="catch";var ln=class extends Dt{render(e){return"finally"+super.render(e)}};ln.kind="finally";var ks=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
+ `:""},this._extScope=e,this._scope=new yt.Scope({parent:e}),this._nodes=[new Is]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,i){let s=this._scope.toName(r);return n!==void 0&&i&&(this._constants[s.str]=n),this._leafNode(new Es(e,s,n)),s}const(e,r,n){return this._def(yt.varKinds.const,e,r,n)}let(e,r,n){return this._def(yt.varKinds.let,e,r,n)}var(e,r,n){return this._def(yt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Zn(e,r,n))}add(e,r){return this._leafNode(new $s(e,le.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ye.nil&&this._leafNode(new As(e)),this}object(...e){let r=["{"];for(let[n,i]of e)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,ye.addCodeArg)(r,i));return r.push("}"),new ye._Code(r)}if(e,r,n){if(this._blockNode(new or(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new or(e))}else(){return this._elseNode(new Rr)}endIf(){return this._endBlockNode(or,Rr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ts(e),r)}forRange(e,r,n,i,s=this.opts.es5?yt.varKinds.var:yt.varKinds.let){let o=this._scope.toName(e);return this._for(new Rs(s,o,r,n),()=>i(o))}forOf(e,r,n,i=yt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let o=r instanceof ye.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ye._)`${o}.length`,a=>{this.var(s,(0,ye._)`${o}[${a}]`),n(s)})}return this._for(new ei("of",i,s,r),()=>n(s))}forIn(e,r,n,i=this.opts.es5?yt.varKinds.var:yt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ye._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new ei("in",i,s,r),()=>n(s))}endFor(){return this._endBlockNode(ar)}label(e){return this._leafNode(new Ss(e))}break(e){return this._leafNode(new Ps(e))}return(e){let r=new cn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(cn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new qs;if(this._blockNode(i),this.code(e),r){let s=this.name("e");this._currNode=i.catch=new fn(s),r(s)}return n&&(this._currNode=i.finally=new ln,this.code(n)),this._endBlockNode(fn,ln)}throw(e){return this._leafNode(new Os(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=ye.nil,n,i){return this._blockNode(new un(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(un)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof or))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};le.CodeGen=ks;function ur(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function ti(t,e){return e instanceof ye._CodeOrName?ur(t,e.names):t}function qr(t,e,r){if(t instanceof ye.Name)return n(t);if(!i(t))return t;return new ye._Code(t._items.reduce((s,o)=>(o instanceof ye.Name&&(o=n(o)),o instanceof ye._Code?s.push(...o._items):s.push(o),s),[]));function n(s){let o=r[s.str];return o===void 0||e[s.str]!==1?s:(delete e[s.str],o)}function i(s){return s instanceof ye._Code&&s._items.some(o=>o instanceof ye.Name&&e[o.str]===1&&r[o.str]!==void 0)}}function wp(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Yc(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ye._)`!${Cs(t)}`}le.not=Yc;var bp=Xc(le.operators.AND);function Ep(...t){return t.reduce(bp)}le.and=Ep;var $p=Xc(le.operators.OR);function Sp(...t){return t.reduce($p)}le.or=Sp;function Xc(t){return(e,r)=>e===ye.nil?r:r===ye.nil?e:(0,ye._)`${Cs(e)} ${t} ${Cs(r)}`}function Cs(t){return t instanceof ye.Name?t:(0,ye._)`(${t})`}});var be=Y(de=>{"use strict";I();R();T();Object.defineProperty(de,"__esModule",{value:!0});de.checkStrictMode=de.getErrorPath=de.Type=de.useFunc=de.setEvaluated=de.evaluatedPropsToName=de.mergeEvaluated=de.eachItem=de.unescapeJsonPointer=de.escapeJsonPointer=de.escapeFragment=de.unescapeFragment=de.schemaRefOrVal=de.schemaHasRulesButRef=de.schemaHasRules=de.checkUnknownRules=de.alwaysValidSchema=de.toHash=void 0;var Ie=pe(),Pp=on();function Op(t){let e={};for(let r of t)e[r]=!0;return e}de.toHash=Op;function Ap(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(tf(t,e),!rf(e,t.self.RULES.all))}de.alwaysValidSchema=Ap;function tf(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let i=n.RULES.keywords;for(let s in e)i[s]||of(t,`unknown keyword: "${s}"`)}de.checkUnknownRules=tf;function rf(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}de.schemaHasRules=rf;function Ip(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}de.schemaHasRulesButRef=Ip;function Tp({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Ie._)`${r}`}return(0,Ie._)`${t}${e}${(0,Ie.getProperty)(n)}`}de.schemaRefOrVal=Tp;function Rp(t){return nf(decodeURIComponent(t))}de.unescapeFragment=Rp;function qp(t){return encodeURIComponent(Ns(t))}de.escapeFragment=qp;function Ns(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}de.escapeJsonPointer=Ns;function nf(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}de.unescapeJsonPointer=nf;function kp(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}de.eachItem=kp;function Zc({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,s,o,a)=>{let c=o===void 0?s:o instanceof Ie.Name?(s instanceof Ie.Name?t(i,s,o):e(i,s,o),o):s instanceof Ie.Name?(e(i,o,s),s):r(s,o);return a===Ie.Name&&!(c instanceof Ie.Name)?n(i,c):c}}de.mergeEvaluated={props:Zc({mergeNames:(t,e,r)=>t.if((0,Ie._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Ie._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Ie._)`${r} || {}`).code((0,Ie._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Ie._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Ie._)`${r} || {}`),js(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:sf}),items:Zc({mergeNames:(t,e,r)=>t.if((0,Ie._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Ie._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Ie._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Ie._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function sf(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Ie._)`{}`);return e!==void 0&&js(t,r,e),r}de.evaluatedPropsToName=sf;function js(t,e,r){Object.keys(r).forEach(n=>t.assign((0,Ie._)`${e}${(0,Ie.getProperty)(n)}`,!0))}de.setEvaluated=js;var ef={};function Cp(t,e){return t.scopeValue("func",{ref:e,code:ef[e.code]||(ef[e.code]=new Pp._Code(e.code))})}de.useFunc=Cp;var xs;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(xs||(de.Type=xs={}));function xp(t,e,r){if(t instanceof Ie.Name){let n=e===xs.Num;return r?n?(0,Ie._)`"[" + ${t} + "]"`:(0,Ie._)`"['" + ${t} + "']"`:n?(0,Ie._)`"/" + ${t}`:(0,Ie._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Ie.getProperty)(t).toString():"/"+Ns(t)}de.getErrorPath=xp;function of(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}de.checkStrictMode=of});var Bt=Y(Ds=>{"use strict";I();R();T();Object.defineProperty(Ds,"__esModule",{value:!0});var Ye=pe(),Np={data:new Ye.Name("data"),valCxt:new Ye.Name("valCxt"),instancePath:new Ye.Name("instancePath"),parentData:new Ye.Name("parentData"),parentDataProperty:new Ye.Name("parentDataProperty"),rootData:new Ye.Name("rootData"),dynamicAnchors:new Ye.Name("dynamicAnchors"),vErrors:new Ye.Name("vErrors"),errors:new Ye.Name("errors"),this:new Ye.Name("this"),self:new Ye.Name("self"),scope:new Ye.Name("scope"),json:new Ye.Name("json"),jsonPos:new Ye.Name("jsonPos"),jsonLen:new Ye.Name("jsonLen"),jsonPart:new Ye.Name("jsonPart")};Ds.default=Np});var dn=Y(Xe=>{"use strict";I();R();T();Object.defineProperty(Xe,"__esModule",{value:!0});Xe.extendErrors=Xe.resetErrorsCount=Xe.reportExtraError=Xe.reportError=Xe.keyword$DataError=Xe.keywordError=void 0;var _e=pe(),ni=be(),et=Bt();Xe.keywordError={message:({keyword:t})=>(0,_e.str)`must pass "${t}" keyword validation`};Xe.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,_e.str)`"${t}" keyword must be ${e} ($data)`:(0,_e.str)`"${t}" keyword is invalid ($data)`};function jp(t,e=Xe.keywordError,r,n){let{it:i}=t,{gen:s,compositeRule:o,allErrors:a}=i,c=cf(t,e,r);n??(o||a)?af(s,c):uf(i,(0,_e._)`[${c}]`)}Xe.reportError=jp;function Dp(t,e=Xe.keywordError,r){let{it:n}=t,{gen:i,compositeRule:s,allErrors:o}=n,a=cf(t,e,r);af(i,a),s||o||uf(n,et.default.vErrors)}Xe.reportExtraError=Dp;function Bp(t,e){t.assign(et.default.errors,e),t.if((0,_e._)`${et.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,_e._)`${et.default.vErrors}.length`,e),()=>t.assign(et.default.vErrors,null)))}Xe.resetErrorsCount=Bp;function Lp({gen:t,keyword:e,schemaValue:r,data:n,errsCount:i,it:s}){if(i===void 0)throw new Error("ajv implementation error");let o=t.name("err");t.forRange("i",i,et.default.errors,a=>{t.const(o,(0,_e._)`${et.default.vErrors}[${a}]`),t.if((0,_e._)`${o}.instancePath === undefined`,()=>t.assign((0,_e._)`${o}.instancePath`,(0,_e.strConcat)(et.default.instancePath,s.errorPath))),t.assign((0,_e._)`${o}.schemaPath`,(0,_e.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,_e._)`${o}.schema`,r),t.assign((0,_e._)`${o}.data`,n))})}Xe.extendErrors=Lp;function af(t,e){let r=t.const("err",e);t.if((0,_e._)`${et.default.vErrors} === null`,()=>t.assign(et.default.vErrors,(0,_e._)`[${r}]`),(0,_e._)`${et.default.vErrors}.push(${r})`),t.code((0,_e._)`${et.default.errors}++`)}function uf(t,e){let{gen:r,validateName:n,schemaEnv:i}=t;i.$async?r.throw((0,_e._)`new ${t.ValidationError}(${e})`):(r.assign((0,_e._)`${n}.errors`,e),r.return(!1))}var cr={keyword:new _e.Name("keyword"),schemaPath:new _e.Name("schemaPath"),params:new _e.Name("params"),propertyName:new _e.Name("propertyName"),message:new _e.Name("message"),schema:new _e.Name("schema"),parentSchema:new _e.Name("parentSchema")};function cf(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,_e._)`{}`:Mp(t,e,r)}function Mp(t,e,r={}){let{gen:n,it:i}=t,s=[Up(i,r),Gp(t,r)];return Fp(t,e,s),n.object(...s)}function Up({errorPath:t},{instancePath:e}){let r=e?(0,_e.str)`${t}${(0,ni.getErrorPath)(e,ni.Type.Str)}`:t;return[et.default.instancePath,(0,_e.strConcat)(et.default.instancePath,r)]}function Gp({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let i=n?e:(0,_e.str)`${e}/${t}`;return r&&(i=(0,_e.str)`${i}${(0,ni.getErrorPath)(r,ni.Type.Str)}`),[cr.schemaPath,i]}function Fp(t,{params:e,message:r},n){let{keyword:i,data:s,schemaValue:o,it:a}=t,{opts:c,propertyName:d,topSchemaRef:m,schemaPath:f}=a;n.push([cr.keyword,i],[cr.params,typeof e=="function"?e(t):e||(0,_e._)`{}`]),c.messages&&n.push([cr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([cr.schema,o],[cr.parentSchema,(0,_e._)`${m}${f}`],[et.default.data,s]),d&&n.push([cr.propertyName,d])}});var lf=Y(kr=>{"use strict";I();R();T();Object.defineProperty(kr,"__esModule",{value:!0});kr.boolOrEmptySchema=kr.topBoolOrEmptySchema=void 0;var zp=dn(),Kp=pe(),Vp=Bt(),Jp={message:"boolean schema is false"};function Hp(t){let{gen:e,schema:r,validateName:n}=t;r===!1?ff(t,!1):typeof r=="object"&&r.$async===!0?e.return(Vp.default.data):(e.assign((0,Kp._)`${n}.errors`,null),e.return(!0))}kr.topBoolOrEmptySchema=Hp;function Wp(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),ff(t)):r.var(e,!0)}kr.boolOrEmptySchema=Wp;function ff(t,e){let{gen:r,data:n}=t,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,zp.reportError)(i,Jp,void 0,e)}});var Bs=Y(Cr=>{"use strict";I();R();T();Object.defineProperty(Cr,"__esModule",{value:!0});Cr.getRules=Cr.isJSONType=void 0;var Qp=["string","number","integer","boolean","null","object","array"],Yp=new Set(Qp);function Xp(t){return typeof t=="string"&&Yp.has(t)}Cr.isJSONType=Xp;function Zp(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Cr.getRules=Zp});var Ls=Y(Kt=>{"use strict";I();R();T();Object.defineProperty(Kt,"__esModule",{value:!0});Kt.shouldUseRule=Kt.shouldUseGroup=Kt.schemaHasRulesForType=void 0;function em({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&df(t,n)}Kt.schemaHasRulesForType=em;function df(t,e){return e.rules.some(r=>hf(t,r))}Kt.shouldUseGroup=df;function hf(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Kt.shouldUseRule=hf});var hn=Y(Ze=>{"use strict";I();R();T();Object.defineProperty(Ze,"__esModule",{value:!0});Ze.reportTypeError=Ze.checkDataTypes=Ze.checkDataType=Ze.coerceAndCheckDataType=Ze.getJSONTypes=Ze.getSchemaTypes=Ze.DataType=void 0;var tm=Bs(),rm=Ls(),nm=dn(),ue=pe(),pf=be(),xr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(xr||(Ze.DataType=xr={}));function im(t){let e=mf(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ze.getSchemaTypes=im;function mf(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(tm.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ze.getJSONTypes=mf;function sm(t,e){let{gen:r,data:n,opts:i}=t,s=om(e,i.coerceTypes),o=e.length>0&&!(s.length===0&&e.length===1&&(0,rm.schemaHasRulesForType)(t,e[0]));if(o){let a=Us(e,n,i.strictNumbers,xr.Wrong);r.if(a,()=>{s.length?am(t,e,s):Gs(t)})}return o}Ze.coerceAndCheckDataType=sm;var vf=new Set(["string","number","integer","boolean","null"]);function om(t,e){return e?t.filter(r=>vf.has(r)||e==="array"&&r==="array"):[]}function am(t,e,r){let{gen:n,data:i,opts:s}=t,o=n.let("dataType",(0,ue._)`typeof ${i}`),a=n.let("coerced",(0,ue._)`undefined`);s.coerceTypes==="array"&&n.if((0,ue._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,ue._)`${i}[0]`).assign(o,(0,ue._)`typeof ${i}`).if(Us(e,i,s.strictNumbers),()=>n.assign(a,i))),n.if((0,ue._)`${a} !== undefined`);for(let d of r)(vf.has(d)||d==="array"&&s.coerceTypes==="array")&&c(d);n.else(),Gs(t),n.endIf(),n.if((0,ue._)`${a} !== undefined`,()=>{n.assign(i,a),um(t,a)});function c(d){switch(d){case"string":n.elseIf((0,ue._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,ue._)`"" + ${i}`).elseIf((0,ue._)`${i} === null`).assign(a,(0,ue._)`""`);return;case"number":n.elseIf((0,ue._)`${o} == "boolean" || ${i} === null
3
3
  || (${o} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,ue._)`+${i}`);return;case"integer":n.elseIf((0,ue._)`${o} === "boolean" || ${i} === null
4
4
  || (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,ue._)`+${i}`);return;case"boolean":n.elseIf((0,ue._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,ue._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,ue._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,ue._)`${o} === "string" || ${o} === "number"
5
- || ${o} === "boolean" || ${i} === null`).assign(a,(0,ue._)`[${i}]`)}}}function um({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,ue._)`${e} !== undefined`,()=>t.assign((0,ue._)`${e}[${r}]`,n))}function Ms(t,e,r,n=xr.Correct){let i=n===xr.Correct?ue.operators.EQ:ue.operators.NEQ,s;switch(t){case"null":return(0,ue._)`${e} ${i} null`;case"array":s=(0,ue._)`Array.isArray(${e})`;break;case"object":s=(0,ue._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=o((0,ue._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=o();break;default:return(0,ue._)`typeof ${e} ${i} ${t}`}return n===xr.Correct?s:(0,ue.not)(s);function o(a=ue.nil){return(0,ue.and)((0,ue._)`typeof ${e} == "number"`,a,r?(0,ue._)`isFinite(${e})`:ue.nil)}}Ze.checkDataType=Ms;function Us(t,e,r,n){if(t.length===1)return Ms(t[0],e,r,n);let i,s=(0,pf.toHash)(t);if(s.array&&s.object){let o=(0,ue._)`typeof ${e} != "object"`;i=s.null?o:(0,ue._)`!${e} || ${o}`,delete s.null,delete s.array,delete s.object}else i=ue.nil;s.number&&delete s.integer;for(let o in s)i=(0,ue.and)(i,Ms(o,e,r,n));return i}Ze.checkDataTypes=Us;var cm={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,ue._)`{type: ${t}}`:(0,ue._)`{type: ${e}}`};function Gs(t){let e=fm(t);(0,nm.reportError)(e,cm)}Ze.reportTypeError=Gs;function fm(t){let{gen:e,data:r,schema:n}=t,i=(0,pf.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var gf=Y(ii=>{"use strict";I();R();T();Object.defineProperty(ii,"__esModule",{value:!0});ii.assignDefaults=void 0;var jr=pe(),lm=be();function dm(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)yf(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,s)=>yf(t,s,i.default))}ii.assignDefaults=dm;function yf(t,e,r){let{gen:n,compositeRule:i,data:s,opts:o}=t;if(r===void 0)return;let a=(0,jr._)`${s}${(0,jr.getProperty)(e)}`;if(i){(0,lm.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,jr._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,jr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,jr._)`${a} = ${(0,jr.stringify)(r)}`)}});var lt=Y(Oe=>{"use strict";I();R();T();Object.defineProperty(Oe,"__esModule",{value:!0});Oe.validateUnion=Oe.validateArray=Oe.usePattern=Oe.callValidateCode=Oe.schemaProperties=Oe.allSchemaProperties=Oe.noPropertyInData=Oe.propertyInData=Oe.isOwnProperty=Oe.hasPropFunc=Oe.reportMissingProp=Oe.checkMissingProp=Oe.checkReportMissingProp=void 0;var qe=pe(),Fs=be(),Vt=Bt(),hm=be();function pm(t,e){let{gen:r,data:n,it:i}=t;r.if(Ks(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,qe._)`${e}`},!0),t.error()})}Oe.checkReportMissingProp=pm;function mm({gen:t,data:e,it:{opts:r}},n,i){return(0,qe.or)(...n.map(s=>(0,qe.and)(Ks(t,e,s,r.ownProperties),(0,qe._)`${i} = ${s}`)))}Oe.checkMissingProp=mm;function vm(t,e){t.setParams({missingProperty:e},!0),t.error()}Oe.reportMissingProp=vm;function _f(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,qe._)`Object.prototype.hasOwnProperty`})}Oe.hasPropFunc=_f;function zs(t,e,r){return(0,qe._)`${_f(t)}.call(${e}, ${r})`}Oe.isOwnProperty=zs;function ym(t,e,r,n){let i=(0,qe._)`${e}${(0,qe.getProperty)(r)} !== undefined`;return n?(0,qe._)`${i} && ${zs(t,e,r)}`:i}Oe.propertyInData=ym;function Ks(t,e,r,n){let i=(0,qe._)`${e}${(0,qe.getProperty)(r)} === undefined`;return n?(0,qe.or)(i,(0,qe.not)(zs(t,e,r))):i}Oe.noPropertyInData=Ks;function wf(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}Oe.allSchemaProperties=wf;function gm(t,e){return wf(e).filter(r=>!(0,Fs.alwaysValidSchema)(t,e[r]))}Oe.schemaProperties=gm;function _m({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:s},it:o},a,c,d){let m=d?(0,qe._)`${t}, ${e}, ${n}${i}`:e,f=[[Vt.default.instancePath,(0,qe.strConcat)(Vt.default.instancePath,s)],[Vt.default.parentData,o.parentData],[Vt.default.parentDataProperty,o.parentDataProperty],[Vt.default.rootData,Vt.default.rootData]];o.opts.dynamicRef&&f.push([Vt.default.dynamicAnchors,Vt.default.dynamicAnchors]);let g=(0,qe._)`${m}, ${r.object(...f)}`;return c!==qe.nil?(0,qe._)`${a}.call(${c}, ${g})`:(0,qe._)`${a}(${g})`}Oe.callValidateCode=_m;var wm=(0,qe._)`new RegExp`;function bm({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:i}=e.code,s=i(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,qe._)`${i.code==="new RegExp"?wm:(0,hm.useFunc)(t,i)}(${r}, ${n})`})}Oe.usePattern=bm;function Em(t){let{gen:e,data:r,keyword:n,it:i}=t,s=e.name("valid");if(i.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(s,!0),o(()=>e.break()),s;function o(a){let c=e.const("len",(0,qe._)`${r}.length`);e.forRange("i",0,c,d=>{t.subschema({keyword:n,dataProp:d,dataPropType:Fs.Type.Num},s),e.if((0,qe.not)(s),a)})}}Oe.validateArray=Em;function $m(t){let{gen:e,schema:r,keyword:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Fs.alwaysValidSchema)(i,c))&&!i.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,d)=>{let m=t.subschema({keyword:n,schemaProp:d,compositeRule:!0},a);e.assign(o,(0,qe._)`${o} || ${a}`),t.mergeValidEvaluated(m,a)||e.if((0,qe.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}Oe.validateUnion=$m});var $f=Y(St=>{"use strict";I();R();T();Object.defineProperty(St,"__esModule",{value:!0});St.validateKeywordUsage=St.validSchemaType=St.funcKeywordCode=St.macroKeywordCode=void 0;var tt=pe(),fr=Bt(),Sm=lt(),Pm=dn();function Om(t,e){let{gen:r,keyword:n,schema:i,parentSchema:s,it:o}=t,a=e.macro.call(o.self,i,s,o),c=Ef(r,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let d=r.name("valid");t.subschema({schema:a,schemaPath:tt.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},d),t.pass(d,()=>t.error(!0))}St.macroKeywordCode=Om;function Am(t,e){var r;let{gen:n,keyword:i,schema:s,parentSchema:o,$data:a,it:c}=t;Tm(c,e);let d=!a&&e.compile?e.compile.call(c.self,s,o,c):e.validate,m=Ef(n,i,d),f=n.let("valid");t.block$data(f,g),t.ok((r=e.valid)!==null&&r!==void 0?r:f);function g(){if(e.errors===!1)P(),e.modifying&&bf(t),S(()=>t.error());else{let y=e.async?_():b();e.modifying&&bf(t),S(()=>Im(t,y))}}function _(){let y=n.let("ruleErrs",null);return n.try(()=>P((0,tt._)`await `),w=>n.assign(f,!1).if((0,tt._)`${w} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,tt._)`${w}.errors`),()=>n.throw(w))),y}function b(){let y=(0,tt._)`${m}.errors`;return n.assign(y,null),P(tt.nil),y}function P(y=e.async?(0,tt._)`await `:tt.nil){let w=c.opts.passContext?fr.default.this:fr.default.self,p=!("compile"in e&&!a||e.schema===!1);n.assign(f,(0,tt._)`${y}${(0,Sm.callValidateCode)(t,m,w,p)}`,e.modifying)}function S(y){var w;n.if((0,tt.not)((w=e.valid)!==null&&w!==void 0?w:f),y)}}St.funcKeywordCode=Am;function bf(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,tt._)`${n.parentData}[${n.parentDataProperty}]`))}function Im(t,e){let{gen:r}=t;r.if((0,tt._)`Array.isArray(${e})`,()=>{r.assign(fr.default.vErrors,(0,tt._)`${fr.default.vErrors} === null ? ${e} : ${fr.default.vErrors}.concat(${e})`).assign(fr.default.errors,(0,tt._)`${fr.default.vErrors}.length`),(0,Pm.extendErrors)(t)},()=>t.error())}function Tm({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Ef(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,tt.stringify)(r)})}function Rm(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}St.validSchemaType=Rm;function qm({schema:t,opts:e,self:r,errSchemaPath:n},i,s){if(Array.isArray(i.keyword)?!i.keyword.includes(s):i.keyword!==s)throw new Error("ajv implementation error");let o=i.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}St.validateKeywordUsage=qm});var Pf=Y(Jt=>{"use strict";I();R();T();Object.defineProperty(Jt,"__esModule",{value:!0});Jt.extendSubschemaMode=Jt.extendSubschemaData=Jt.getSubschema=void 0;var Pt=pe(),Sf=be();function km(t,{keyword:e,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:s,topSchemaRef:o}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Pt._)`${t.schemaPath}${(0,Pt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Pt._)`${t.schemaPath}${(0,Pt.getProperty)(e)}${(0,Pt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Sf.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||s===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:o,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Jt.getSubschema=km;function Cm(t,e,{dataProp:r,dataPropType:n,data:i,dataTypes:s,propertyName:o}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:d,dataPathArr:m,opts:f}=e,g=a.let("data",(0,Pt._)`${e.data}${(0,Pt.getProperty)(r)}`,!0);c(g),t.errorPath=(0,Pt.str)`${d}${(0,Sf.getErrorPath)(r,n,f.jsPropertySyntax)}`,t.parentDataProperty=(0,Pt._)`${r}`,t.dataPathArr=[...m,t.parentDataProperty]}if(i!==void 0){let d=i instanceof Pt.Name?i:a.let("data",i,!0);c(d),o!==void 0&&(t.propertyName=o)}s&&(t.dataTypes=s);function c(d){t.data=d,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,d]}}Jt.extendSubschemaData=Cm;function xm(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:s}){n!==void 0&&(t.compositeRule=n),i!==void 0&&(t.createErrors=i),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Jt.extendSubschemaMode=xm});var Vs=Y((EE,Of)=>{"use strict";I();R();T();Of.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[i]))return!1;for(i=n;i--!==0;){var o=s[i];if(!t(e[o],r[o]))return!1}return!0}return e!==e&&r!==r}});var If=Y((OE,Af)=>{"use strict";I();R();T();var Ht=Af.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};si(e,n,i,t,"",t)};Ht.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ht.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ht.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ht.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 si(t,e,r,n,i,s,o,a,c,d){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,i,s,o,a,c,d);for(var m in n){var f=n[m];if(Array.isArray(f)){if(m in Ht.arrayKeywords)for(var g=0;g<f.length;g++)si(t,e,r,f[g],i+"/"+m+"/"+g,s,i,m,n,g)}else if(m in Ht.propsKeywords){if(f&&typeof f=="object")for(var _ in f)si(t,e,r,f[_],i+"/"+m+"/"+jm(_),s,i,m,n,_)}else(m in Ht.keywords||t.allKeys&&!(m in Ht.skipKeywords))&&si(t,e,r,f,i+"/"+m,s,i,m,n)}r(n,i,s,o,a,c,d)}}function jm(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var pn=Y(ot=>{"use strict";I();R();T();Object.defineProperty(ot,"__esModule",{value:!0});ot.getSchemaRefs=ot.resolveUrl=ot.normalizeId=ot._getFullPath=ot.getFullPath=ot.inlineRef=void 0;var Nm=be(),Dm=Vs(),Bm=If(),Lm=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Mm(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Js(t):e?Tf(t)<=e:!1}ot.inlineRef=Mm;var Um=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Js(t){for(let e in t){if(Um.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Js)||typeof r=="object"&&Js(r))return!0}return!1}function Tf(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Lm.has(r)&&(typeof t[r]=="object"&&(0,Nm.eachItem)(t[r],n=>e+=Tf(n)),e===1/0))return 1/0}return e}function Rf(t,e="",r){r!==!1&&(e=Nr(e));let n=t.parse(e);return qf(t,n)}ot.getFullPath=Rf;function qf(t,e){return t.serialize(e).split("#")[0]+"#"}ot._getFullPath=qf;var Gm=/#\/?$/;function Nr(t){return t?t.replace(Gm,""):""}ot.normalizeId=Nr;function Fm(t,e,r){return r=Nr(r),t.resolve(e,r)}ot.resolveUrl=Fm;var zm=/^[a-z_][-a-z0-9._]*$/i;function Km(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=Nr(t[r]||e),s={"":i},o=Rf(n,i,!1),a={},c=new Set;return Bm(t,{allKeys:!0},(f,g,_,b)=>{if(b===void 0)return;let P=o+g,S=s[b];typeof f[r]=="string"&&(S=y.call(this,f[r])),w.call(this,f.$anchor),w.call(this,f.$dynamicAnchor),s[g]=S;function y(p){let h=this.opts.uriResolver.resolve;if(p=Nr(S?h(S,p):p),c.has(p))throw m(p);c.add(p);let v=this.refs[p];return typeof v=="string"&&(v=this.refs[v]),typeof v=="object"?d(f,v.schema,p):p!==Nr(P)&&(p[0]==="#"?(d(f,a[p],p),a[p]=f):this.refs[p]=P),p}function w(p){if(typeof p=="string"){if(!zm.test(p))throw new Error(`invalid anchor "${p}"`);y.call(this,`#${p}`)}}}),a;function d(f,g,_){if(g!==void 0&&!Dm(f,g))throw m(_)}function m(f){return new Error(`reference "${f}" resolves to more than one schema`)}}ot.getSchemaRefs=Km});var ui=Y(Wt=>{"use strict";I();R();T();Object.defineProperty(Wt,"__esModule",{value:!0});Wt.getData=Wt.KeywordCxt=Wt.validateFunctionCode=void 0;var Nf=lf(),kf=hn(),Ws=Ls(),oi=hn(),Vm=gf(),vn=$f(),Hs=Pf(),te=pe(),se=Bt(),Jm=pn(),Lt=be(),mn=dn();function Hm(t){if(Lf(t)&&(Mf(t),Bf(t))){Ym(t);return}Df(t,()=>(0,Nf.topBoolOrEmptySchema)(t))}Wt.validateFunctionCode=Hm;function Df({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},s){i.code.es5?t.func(e,(0,te._)`${se.default.data}, ${se.default.valCxt}`,n.$async,()=>{t.code((0,te._)`"use strict"; ${Cf(r,i)}`),Qm(t,i),t.code(s)}):t.func(e,(0,te._)`${se.default.data}, ${Wm(i)}`,n.$async,()=>t.code(Cf(r,i)).code(s))}function Wm(t){return(0,te._)`{${se.default.instancePath}="", ${se.default.parentData}, ${se.default.parentDataProperty}, ${se.default.rootData}=${se.default.data}${t.dynamicRef?(0,te._)`, ${se.default.dynamicAnchors}={}`:te.nil}}={}`}function Qm(t,e){t.if(se.default.valCxt,()=>{t.var(se.default.instancePath,(0,te._)`${se.default.valCxt}.${se.default.instancePath}`),t.var(se.default.parentData,(0,te._)`${se.default.valCxt}.${se.default.parentData}`),t.var(se.default.parentDataProperty,(0,te._)`${se.default.valCxt}.${se.default.parentDataProperty}`),t.var(se.default.rootData,(0,te._)`${se.default.valCxt}.${se.default.rootData}`),e.dynamicRef&&t.var(se.default.dynamicAnchors,(0,te._)`${se.default.valCxt}.${se.default.dynamicAnchors}`)},()=>{t.var(se.default.instancePath,(0,te._)`""`),t.var(se.default.parentData,(0,te._)`undefined`),t.var(se.default.parentDataProperty,(0,te._)`undefined`),t.var(se.default.rootData,se.default.data),e.dynamicRef&&t.var(se.default.dynamicAnchors,(0,te._)`{}`)})}function Ym(t){let{schema:e,opts:r,gen:n}=t;Df(t,()=>{r.$comment&&e.$comment&&Gf(t),rv(t),n.let(se.default.vErrors,null),n.let(se.default.errors,0),r.unevaluated&&Xm(t),Uf(t),sv(t)})}function Xm(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,te._)`${r}.evaluated`),e.if((0,te._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,te._)`${t.evaluated}.props`,(0,te._)`undefined`)),e.if((0,te._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,te._)`${t.evaluated}.items`,(0,te._)`undefined`))}function Cf(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,te._)`/*# sourceURL=${r} */`:te.nil}function Zm(t,e){if(Lf(t)&&(Mf(t),Bf(t))){ev(t,e);return}(0,Nf.boolOrEmptySchema)(t,e)}function Bf({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Lf(t){return typeof t.schema!="boolean"}function ev(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&Gf(t),nv(t),iv(t);let s=n.const("_errs",se.default.errors);Uf(t,s),n.var(e,(0,te._)`${s} === ${se.default.errors}`)}function Mf(t){(0,Lt.checkUnknownRules)(t),tv(t)}function Uf(t,e){if(t.opts.jtd)return xf(t,[],!1,e);let r=(0,kf.getSchemaTypes)(t.schema),n=(0,kf.coerceAndCheckDataType)(t,r);xf(t,r,!n,e)}function tv(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Lt.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function rv(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Lt.checkStrictMode)(t,"default is ignored in the schema root")}function nv(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Jm.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function iv(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Gf({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let s=r.$comment;if(i.$comment===!0)t.code((0,te._)`${se.default.self}.logger.log(${s})`);else if(typeof i.$comment=="function"){let o=(0,te.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,te._)`${se.default.self}.opts.$comment(${s}, ${o}, ${a}.schema)`)}}function sv(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:s}=t;r.$async?e.if((0,te._)`${se.default.errors} === 0`,()=>e.return(se.default.data),()=>e.throw((0,te._)`new ${i}(${se.default.vErrors})`)):(e.assign((0,te._)`${n}.errors`,se.default.vErrors),s.unevaluated&&ov(t),e.return((0,te._)`${se.default.errors} === 0`))}function ov({gen:t,evaluated:e,props:r,items:n}){r instanceof te.Name&&t.assign((0,te._)`${e}.props`,r),n instanceof te.Name&&t.assign((0,te._)`${e}.items`,n)}function xf(t,e,r,n){let{gen:i,schema:s,data:o,allErrors:a,opts:c,self:d}=t,{RULES:m}=d;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Lt.schemaHasRulesButRef)(s,m))){i.block(()=>zf(t,"$ref",m.all.$ref.definition));return}c.jtd||av(t,e),i.block(()=>{for(let g of m.rules)f(g);f(m.post)});function f(g){(0,Ws.shouldUseGroup)(s,g)&&(g.type?(i.if((0,oi.checkDataType)(g.type,o,c.strictNumbers)),jf(t,g),e.length===1&&e[0]===g.type&&r&&(i.else(),(0,oi.reportTypeError)(t)),i.endIf()):jf(t,g),a||i.if((0,te._)`${se.default.errors} === ${n||0}`))}}function jf(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,Vm.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Ws.shouldUseRule)(n,s)&&zf(t,s.keyword,s.definition,e.type)})}function av(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(uv(t,e),t.opts.allowUnionTypes||cv(t,e),fv(t,t.dataTypes))}function uv(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Ff(t.dataTypes,r)||Qs(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),dv(t,e)}}function cv(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Qs(t,"use allowUnionTypes to allow union type keyword")}function fv(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,Ws.shouldUseRule)(t.schema,i)){let{type:s}=i.definition;s.length&&!s.some(o=>lv(e,o))&&Qs(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function lv(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Ff(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function dv(t,e){let r=[];for(let n of t.dataTypes)Ff(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Qs(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Lt.checkStrictMode)(t,e,t.opts.strictTypes)}var ai=class{constructor(e,r,n){if((0,vn.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Lt.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Kf(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,vn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",se.default.errors))}result(e,r,n){this.failResult((0,te.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,te.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,te._)`${r} !== undefined && (${(0,te.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?mn.reportExtraError:mn.reportError)(this,this.def.error,r)}$dataError(){(0,mn.reportError)(this,this.def.$dataError||mn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,mn.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=te.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=te.nil,r=te.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:s,def:o}=this;n.if((0,te.or)((0,te._)`${i} === undefined`,r)),e!==te.nil&&n.assign(e,!0),(s.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==te.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:s}=this;return(0,te.or)(o(),a());function o(){if(n.length){if(!(r instanceof te.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,te._)`${(0,oi.checkDataTypes)(c,r,s.opts.strictNumbers,oi.DataType.Wrong)}`}return te.nil}function a(){if(i.validateSchema){let c=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,te._)`!${c}(${r})`}return te.nil}}subschema(e,r){let n=(0,Hs.getSubschema)(this.it,e);(0,Hs.extendSubschemaData)(n,this.it,e),(0,Hs.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return Zm(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Lt.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Lt.mergeEvaluated.items(i,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(e,te.Name)),!0}};Wt.KeywordCxt=ai;function zf(t,e,r,n){let i=new ai(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,vn.funcKeywordCode)(i,r):"macro"in r?(0,vn.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,vn.funcKeywordCode)(i,r)}var hv=/^\/(?:[^~]|~0|~1)*$/,pv=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Kf(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,s;if(t==="")return se.default.rootData;if(t[0]==="/"){if(!hv.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,s=se.default.rootData}else{let d=pv.exec(t);if(!d)throw new Error(`Invalid JSON-pointer: ${t}`);let m=+d[1];if(i=d[2],i==="#"){if(m>=e)throw new Error(c("property/index",m));return n[e-m]}if(m>e)throw new Error(c("data",m));if(s=r[e-m],!i)return s}let o=s,a=i.split("/");for(let d of a)d&&(s=(0,te._)`${s}${(0,te.getProperty)((0,Lt.unescapeJsonPointer)(d))}`,o=(0,te._)`${o} && ${s}`);return o;function c(d,m){return`Cannot access ${d} ${m} levels up, current level is ${e}`}}Wt.getData=Kf});var Zs=Y(Xs=>{"use strict";I();R();T();Object.defineProperty(Xs,"__esModule",{value:!0});var Ys=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Xs.default=Ys});var ci=Y(ro=>{"use strict";I();R();T();Object.defineProperty(ro,"__esModule",{value:!0});var eo=pn(),to=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,eo.resolveUrl)(e,r,n),this.missingSchema=(0,eo.normalizeId)((0,eo.getFullPath)(e,this.missingRef))}};ro.default=to});var li=Y(dt=>{"use strict";I();R();T();Object.defineProperty(dt,"__esModule",{value:!0});dt.resolveSchema=dt.getCompilingSchema=dt.resolveRef=dt.compileSchema=dt.SchemaEnv=void 0;var gt=pe(),mv=Zs(),lr=Bt(),_t=pn(),Vf=be(),vv=ui(),Dr=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,_t.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};dt.SchemaEnv=Dr;function io(t){let e=Jf.call(this,t);if(e)return e;let r=(0,_t.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:s}=this.opts,o=new gt.CodeGen(this.scope,{es5:n,lines:i,ownProperties:s}),a;t.$async&&(a=o.scopeValue("Error",{ref:mv.default,code:(0,gt._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");t.validateName=c;let d={gen:o,allErrors:this.opts.allErrors,data:lr.default.data,parentData:lr.default.parentData,parentDataProperty:lr.default.parentDataProperty,dataNames:[lr.default.data],dataPathArr:[gt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,gt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:gt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,gt._)`""`,opts:this.opts,self:this},m;try{this._compilations.add(t),(0,vv.validateFunctionCode)(d),o.optimize(this.opts.code.optimize);let f=o.toString();m=`${o.scopeRefs(lr.default.scope)}return ${f}`,this.opts.code.process&&(m=this.opts.code.process(m,t));let _=new Function(`${lr.default.self}`,`${lr.default.scope}`,m)(this,this.scope.get());if(this.scope.value(c,{ref:_}),_.errors=null,_.schema=t.schema,_.schemaEnv=t,t.$async&&(_.$async=!0),this.opts.code.source===!0&&(_.source={validateName:c,validateCode:f,scopeValues:o._values}),this.opts.unevaluated){let{props:b,items:P}=d;_.evaluated={props:b instanceof gt.Name?void 0:b,items:P instanceof gt.Name?void 0:P,dynamicProps:b instanceof gt.Name,dynamicItems:P instanceof gt.Name},_.source&&(_.source.evaluated=(0,gt.stringify)(_.evaluated))}return t.validate=_,t}catch(f){throw delete t.validate,delete t.validateName,m&&this.logger.error("Error compiling schema, function code:",m),f}finally{this._compilations.delete(t)}}dt.compileSchema=io;function yv(t,e,r){var n;r=(0,_t.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let s=wv.call(this,t,r);if(s===void 0){let o=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;o&&(s=new Dr({schema:o,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=gv.call(this,s)}dt.resolveRef=yv;function gv(t){return(0,_t.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:io.call(this,t)}function Jf(t){for(let e of this._compilations)if(_v(e,t))return e}dt.getCompilingSchema=Jf;function _v(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function wv(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||fi.call(this,t,e)}function fi(t,e){let r=this.opts.uriResolver.parse(e),n=(0,_t._getFullPath)(this.opts.uriResolver,r),i=(0,_t.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return no.call(this,r,t);let s=(0,_t.normalizeId)(n),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=fi.call(this,t,o);return typeof a?.schema!="object"?void 0:no.call(this,r,a)}if(typeof o?.schema=="object"){if(o.validate||io.call(this,o),s===(0,_t.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,d=a[c];return d&&(i=(0,_t.resolveUrl)(this.opts.uriResolver,i,d)),new Dr({schema:a,schemaId:c,root:t,baseId:i})}return no.call(this,r,o)}}dt.resolveSchema=fi;var bv=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function no(t,{baseId:e,schema:r,root:n}){var i;if(((i=t.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Vf.unescapeFragment)(a)];if(c===void 0)return;r=c;let d=typeof r=="object"&&r[this.opts.schemaId];!bv.has(a)&&d&&(e=(0,_t.resolveUrl)(this.opts.uriResolver,e,d))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Vf.schemaHasRulesButRef)(r,this.RULES)){let a=(0,_t.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=fi.call(this,n,a)}let{schemaId:o}=this.opts;if(s=s||new Dr({schema:r,schemaId:o,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var Hf=Y((QE,Ev)=>{Ev.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Qf=Y((YE,Wf)=>{"use strict";I();R();T();var $v={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};Wf.exports={HEX:$v}});var il=Y((t$,nl)=>{"use strict";I();R();T();var{HEX:Sv}=Qf(),Pv=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function el(t){if(rl(t,".")<3)return{host:t,isIPV4:!1};let e=t.match(Pv)||[],[r]=e;return r?{host:Av(r,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function so(t,e=!1){let r="",n=!0;for(let i of t){if(Sv[i]===void 0)return;i!=="0"&&n===!0&&(n=!1),n||(r+=i)}return e&&r.length===0&&(r="0"),r}function Ov(t){let e=0,r={error:!1,address:"",zone:""},n=[],i=[],s=!1,o=!1,a=!1;function c(){if(i.length){if(s===!1){let d=so(i);if(d!==void 0)n.push(d);else return r.error=!0,!1}i.length=0}return!0}for(let d=0;d<t.length;d++){let m=t[d];if(!(m==="["||m==="]"))if(m===":"){if(o===!0&&(a=!0),!c())break;if(e++,n.push(":"),e>7){r.error=!0;break}d-1>=0&&t[d-1]===":"&&(o=!0);continue}else if(m==="%"){if(!c())break;s=!0}else{i.push(m);continue}}return i.length&&(s?r.zone=i.join(""):a?n.push(i.join("")):n.push(so(i))),r.address=n.join(""),r}function tl(t){if(rl(t,":")<2)return{host:t,isIPV6:!1};let e=Ov(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,escapedHost:n,isIPV6:!0}}}function Av(t,e){let r="",n=!0,i=t.length;for(let s=0;s<i;s++){let o=t[s];o==="0"&&n?(s+1<=i&&t[s+1]===e||s+1===i)&&(r+=o,n=!1):(o===e?n=!0:n=!1,r+=o)}return r}function rl(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}var Yf=/^\.\.?\//u,Xf=/^\/\.(?:\/|$)/u,Zf=/^\/\.\.(?:\/|$)/u,Iv=/^\/?(?:.|\n)*?(?=\/|$)/u;function Tv(t){let e=[];for(;t.length;)if(t.match(Yf))t=t.replace(Yf,"");else if(t.match(Xf))t=t.replace(Xf,"/");else if(t.match(Zf))t=t.replace(Zf,"/"),e.pop();else if(t==="."||t==="..")t="";else{let r=t.match(Iv);if(r){let n=r[0];t=t.slice(n.length),e.push(n)}else throw new Error("Unexpected dot segment condition")}return e.join("")}function Rv(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function qv(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host),n=el(r);if(n.isIPV4)r=n.host;else{let i=tl(n.host);i.isIPV6===!0?r=`[${i.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}nl.exports={recomposeAuthority:qv,normalizeComponentEncoding:Rv,removeDotSegments:Tv,normalizeIPv4:el,normalizeIPv6:tl,stringArrayToHexStripped:so}});var fl=Y((s$,cl)=>{"use strict";I();R();T();var kv=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,Cv=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function sl(t){return typeof t.secure=="boolean"?t.secure:String(t.scheme).toLowerCase()==="wss"}function ol(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function al(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function xv(t){return t.secure=sl(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function jv(t){if((t.port===(sl(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function Nv(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Cv);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let i=`${n}:${e.nid||t.nid}`,s=oo[i];t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Dv(t,e){let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),i=`${r}:${e.nid||n}`,s=oo[i];s&&(t=s.serialize(t,e));let o=t,a=t.nss;return o.path=`${n||e.nid}:${a}`,e.skipEscape=!0,o}function Bv(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!kv.test(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Lv(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var ul={scheme:"http",domainHost:!0,parse:ol,serialize:al},Mv={scheme:"https",domainHost:ul.domainHost,parse:ol,serialize:al},di={scheme:"ws",domainHost:!0,parse:xv,serialize:jv},Uv={scheme:"wss",domainHost:di.domainHost,parse:di.parse,serialize:di.serialize},Gv={scheme:"urn",parse:Nv,serialize:Dv,skipNormalize:!0},Fv={scheme:"urn:uuid",parse:Bv,serialize:Lv,skipNormalize:!0},oo={http:ul,https:Mv,ws:di,wss:Uv,urn:Gv,"urn:uuid":Fv};cl.exports=oo});var dl=Y((c$,pi)=>{"use strict";I();R();T();var{normalizeIPv6:zv,normalizeIPv4:Kv,removeDotSegments:yn,recomposeAuthority:Vv,normalizeComponentEncoding:hi}=il(),ao=fl();function Jv(t,e){return typeof t=="string"?t=Ot(Mt(t,e),e):typeof t=="object"&&(t=Mt(Ot(t,e),e)),t}function Hv(t,e,r){let n=Object.assign({scheme:"null"},r),i=ll(Mt(t,n),Mt(e,n),n,!0);return Ot(i,{...n,skipEscape:!0})}function ll(t,e,r,n){let i={};return n||(t=Mt(Ot(t,r),r),e=Mt(Ot(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=yn(e.path||""),i.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=yn(e.path||""),i.query=e.query):(e.path?(e.path.charAt(0)==="/"?i.path=yn(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?i.path="/"+e.path:t.path?i.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:i.path=e.path,i.path=yn(i.path)),i.query=e.query):(i.path=t.path,e.query!==void 0?i.query=e.query:i.query=t.query),i.userinfo=t.userinfo,i.host=t.host,i.port=t.port),i.scheme=t.scheme),i.fragment=e.fragment,i}function Wv(t,e,r){return typeof t=="string"?(t=unescape(t),t=Ot(hi(Mt(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=Ot(hi(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=Ot(hi(Mt(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=Ot(hi(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function Ot(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),i=[],s=ao[(n.scheme||r.scheme||"").toLowerCase()];s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let o=Vv(r);if(o!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(o),r.path&&r.path.charAt(0)!=="/"&&i.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=yn(a)),o===void 0&&(a=a.replace(/^\/\//u,"/%2F")),i.push(a)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var Qv=Array.from({length:127},(t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)));function Yv(t){let e=0;for(let r=0,n=t.length;r<n;++r)if(e=t.charCodeAt(r),e>126||Qv[e])return!0;return!1}var Xv=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Mt(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=t.indexOf("%")!==-1,s=!1;r.reference==="suffix"&&(t=(r.scheme?r.scheme+":":"")+"//"+t);let o=t.match(Xv);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host){let c=Kv(n.host);if(c.isIPV4===!1){let d=zv(c.host);n.host=d.host.toLowerCase(),s=d.isIPV6}else n.host=c.host,s=!0}n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=ao[(r.scheme||n.scheme||"").toLowerCase()];if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===!1&&Yv(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(c){n.error=n.error||"Host's domain name can not be converted to ASCII: "+c}(!a||a&&!a.skipNormalize)&&(i&&n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),i&&n.host!==void 0&&(n.host=unescape(n.host)),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var uo={SCHEMES:ao,normalize:Jv,resolve:Hv,resolveComponents:ll,equal:Wv,serialize:Ot,parse:Mt};pi.exports=uo;pi.exports.default=uo;pi.exports.fastUri=uo});var pl=Y(co=>{"use strict";I();R();T();Object.defineProperty(co,"__esModule",{value:!0});var hl=dl();hl.code='require("ajv/dist/runtime/uri").default';co.default=hl});var bn=Y(ze=>{"use strict";I();R();T();Object.defineProperty(ze,"__esModule",{value:!0});ze.CodeGen=ze.Name=ze.nil=ze.stringify=ze.str=ze._=ze.KeywordCxt=void 0;var Zv=ui();Object.defineProperty(ze,"KeywordCxt",{enumerable:!0,get:function(){return Zv.KeywordCxt}});var Br=pe();Object.defineProperty(ze,"_",{enumerable:!0,get:function(){return Br._}});Object.defineProperty(ze,"str",{enumerable:!0,get:function(){return Br.str}});Object.defineProperty(ze,"stringify",{enumerable:!0,get:function(){return Br.stringify}});Object.defineProperty(ze,"nil",{enumerable:!0,get:function(){return Br.nil}});Object.defineProperty(ze,"Name",{enumerable:!0,get:function(){return Br.Name}});Object.defineProperty(ze,"CodeGen",{enumerable:!0,get:function(){return Br.CodeGen}});var ey=Zs(),_l=ci(),ty=Bs(),gn=li(),ry=pe(),_n=pn(),mi=hn(),lo=be(),ml=Hf(),ny=pl(),wl=(t,e)=>new RegExp(t,e);wl.code="new RegExp";var iy=["removeAdditional","useDefaults","coerceTypes"],sy=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),oy={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},ay={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},vl=200;function uy(t){var e,r,n,i,s,o,a,c,d,m,f,g,_,b,P,S,y,w,p,h,v,E,k,x,N;let G=t.strict,H=(e=t.code)===null||e===void 0?void 0:e.optimize,re=H===!0||H===void 0?1:H||0,Q=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:wl,Z=(i=t.uriResolver)!==null&&i!==void 0?i:ny.default;return{strictSchema:(o=(s=t.strictSchema)!==null&&s!==void 0?s:G)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:G)!==null&&c!==void 0?c:!0,strictTypes:(m=(d=t.strictTypes)!==null&&d!==void 0?d:G)!==null&&m!==void 0?m:"log",strictTuples:(g=(f=t.strictTuples)!==null&&f!==void 0?f:G)!==null&&g!==void 0?g:"log",strictRequired:(b=(_=t.strictRequired)!==null&&_!==void 0?_:G)!==null&&b!==void 0?b:!1,code:t.code?{...t.code,optimize:re,regExp:Q}:{optimize:re,regExp:Q},loopRequired:(P=t.loopRequired)!==null&&P!==void 0?P:vl,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:vl,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(w=t.messages)!==null&&w!==void 0?w:!0,inlineRefs:(p=t.inlineRefs)!==null&&p!==void 0?p:!0,schemaId:(h=t.schemaId)!==null&&h!==void 0?h:"$id",addUsedSchema:(v=t.addUsedSchema)!==null&&v!==void 0?v:!0,validateSchema:(E=t.validateSchema)!==null&&E!==void 0?E:!0,validateFormats:(k=t.validateFormats)!==null&&k!==void 0?k:!0,unicodeRegExp:(x=t.unicodeRegExp)!==null&&x!==void 0?x:!0,int32range:(N=t.int32range)!==null&&N!==void 0?N:!0,uriResolver:Z}}var wn=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...uy(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new ry.ValueScope({scope:{},prefixes:sy,es5:r,lines:n}),this.logger=py(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,ty.getRules)(),yl.call(this,oy,e,"NOT SUPPORTED"),yl.call(this,ay,e,"DEPRECATED","warn"),this._metaOpts=dy.call(this),e.formats&&fy.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&ly.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),cy.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=ml;n==="id"&&(i={...ml},i.id=i.$id,delete i.$id),r&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,e,r);async function i(m,f){await s.call(this,m.$schema);let g=this._addSchema(m,f);return g.validate||o.call(this,g)}async function s(m){m&&!this.getSchema(m)&&await i.call(this,{$ref:m},!0)}async function o(m){try{return this._compileSchemaEnv(m)}catch(f){if(!(f instanceof _l.default))throw f;return a.call(this,f),await c.call(this,f.missingSchema),o.call(this,m)}}function a({missingSchema:m,missingRef:f}){if(this.refs[m])throw new Error(`AnySchema ${m} is loaded but ${f} cannot be resolved`)}async function c(m){let f=await d.call(this,m);this.refs[m]||await s.call(this,f.$schema),this.refs[m]||this.addSchema(f,m,r)}async function d(m){let f=this._loading[m];if(f)return f;try{return await(this._loading[m]=n(m))}finally{delete this._loading[m]}}}addSchema(e,r,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,i);return this}let s;if(typeof e=="object"){let{schemaId:o}=this.opts;if(s=e[o],s!==void 0&&typeof s!="string")throw new Error(`schema ${o} must be string`)}return r=(0,_n.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,i,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let i=this.validate(n,e);if(!i&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return i}getSchema(e){let r;for(;typeof(r=gl.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new gn.SchemaEnv({schema:{},schemaId:n});if(r=gn.resolveSchema.call(this,i,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=gl.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,_n.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(vy.call(this,n,r),!r)return(0,lo.eachItem)(n,s=>fo.call(this,s)),this;gy.call(this,r);let i={...r,type:(0,mi.getJSONTypes)(r.type),schemaType:(0,mi.getJSONTypes)(r.schemaType)};return(0,lo.eachItem)(n,i.type.length===0?s=>fo.call(this,s,i):s=>i.type.forEach(o=>fo.call(this,s,i,o))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let i=n.rules.findIndex(s=>s.keyword===e);i>=0&&n.rules.splice(i,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,s)=>i+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of r){let s=i.split("/").slice(1),o=e;for(let a of s)o=o[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:d}=c.definition,m=o[a];d&&m&&(o[a]=bl(m))}}return e}_removeAllSchemas(e,r){for(let n in e){let i=e[n];(!r||r.test(n))&&(typeof i=="string"?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,r,n,i=this.opts.validateSchema,s=this.opts.addUsedSchema){let o,{schemaId:a}=this.opts;if(typeof e=="object")o=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,_n.normalizeId)(o||n);let d=_n.getSchemaRefs.call(this,e,n);return c=new gn.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:d}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),i&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):gn.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{gn.compileSchema.call(this,e)}finally{this.opts=r}}};wn.ValidationError=ey.default;wn.MissingRefError=_l.default;ze.default=wn;function yl(t,e,r,n="error"){for(let i in t){let s=i;s in e&&this.logger[n](`${r}: option ${i}. ${t[s]}`)}}function gl(t){return t=(0,_n.normalizeId)(t),this.schemas[t]||this.refs[t]}function cy(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function fy(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function ly(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function dy(){let t={...this.opts};for(let e of iy)delete t[e];return t}var hy={log(){},warn(){},error(){}};function py(t){if(t===!1)return hy;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var my=/^[a-z_$][a-z0-9_$:-]*$/i;function vy(t,e){let{RULES:r}=this;if((0,lo.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!my.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function fo(t,e,r){var n;let i=e?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,o=i?s.post:s.rules.find(({type:c})=>c===r);if(o||(o={type:r,rules:[]},s.rules.push(o)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,mi.getJSONTypes)(e.type),schemaType:(0,mi.getJSONTypes)(e.schemaType)}};e.before?yy.call(this,o,a,e.before):o.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function yy(t,e,r){let n=t.rules.findIndex(i=>i.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function gy(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=bl(e)),t.validateSchema=this.compile(e,!0))}var _y={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function bl(t){return{anyOf:[t,_y]}}});var Pl=Y(dr=>{"use strict";I();R();T();Object.defineProperty(dr,"__esModule",{value:!0});dr.callRef=dr.getValidate=void 0;var wy=ci(),El=lt(),at=pe(),Lr=Bt(),$l=li(),vi=be(),by={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:i,schemaEnv:s,validateName:o,opts:a,self:c}=n,{root:d}=s;if((r==="#"||r==="#/")&&i===d.baseId)return f();let m=$l.resolveRef.call(c,d,i,r);if(m===void 0)throw new wy.default(n.opts.uriResolver,i,r);if(m instanceof $l.SchemaEnv)return g(m);return _(m);function f(){if(s===d)return yi(t,o,s,s.$async);let b=e.scopeValue("root",{ref:d});return yi(t,(0,at._)`${b}.validate`,d,d.$async)}function g(b){let P=Sl(t,b);yi(t,P,b,b.$async)}function _(b){let P=e.scopeValue("schema",a.code.source===!0?{ref:b,code:(0,at.stringify)(b)}:{ref:b}),S=e.name("valid"),y=t.subschema({schema:b,dataTypes:[],schemaPath:at.nil,topSchemaRef:P,errSchemaPath:r},S);t.mergeEvaluated(y),t.ok(S)}}};function Sl(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,at._)`${r.scopeValue("wrapper",{ref:e})}.validate`}dr.getValidate=Sl;function yi(t,e,r,n){let{gen:i,it:s}=t,{allErrors:o,schemaEnv:a,opts:c}=s,d=c.passContext?Lr.default.this:at.nil;n?m():f();function m(){if(!a.$async)throw new Error("async schema referenced by sync schema");let b=i.let("valid");i.try(()=>{i.code((0,at._)`await ${(0,El.callValidateCode)(t,e,d)}`),_(e),o||i.assign(b,!0)},P=>{i.if((0,at._)`!(${P} instanceof ${s.ValidationError})`,()=>i.throw(P)),g(P),o||i.assign(b,!1)}),t.ok(b)}function f(){t.result((0,El.callValidateCode)(t,e,d),()=>_(e),()=>g(e))}function g(b){let P=(0,at._)`${b}.errors`;i.assign(Lr.default.vErrors,(0,at._)`${Lr.default.vErrors} === null ? ${P} : ${Lr.default.vErrors}.concat(${P})`),i.assign(Lr.default.errors,(0,at._)`${Lr.default.vErrors}.length`)}function _(b){var P;if(!s.opts.unevaluated)return;let S=(P=r?.validate)===null||P===void 0?void 0:P.evaluated;if(s.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(s.props=vi.mergeEvaluated.props(i,S.props,s.props));else{let y=i.var("props",(0,at._)`${b}.evaluated.props`);s.props=vi.mergeEvaluated.props(i,y,s.props,at.Name)}if(s.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(s.items=vi.mergeEvaluated.items(i,S.items,s.items));else{let y=i.var("items",(0,at._)`${b}.evaluated.items`);s.items=vi.mergeEvaluated.items(i,y,s.items,at.Name)}}}dr.callRef=yi;dr.default=by});var Ol=Y(ho=>{"use strict";I();R();T();Object.defineProperty(ho,"__esModule",{value:!0});var Ey=Pl(),$y=["$schema","id","$defs",{keyword:"$comment"},"definitions",Ey.default];ho.default=$y});var Al=Y(yo=>{"use strict";I();R();T();Object.defineProperty(yo,"__esModule",{value:!0});var po=bn(),Sy=pe(),Qt=Sy.operators,mo={maximum:{exclusive:"exclusiveMaximum",ops:[{okStr:"<=",ok:Qt.LTE,fail:Qt.GT},{okStr:"<",ok:Qt.LT,fail:Qt.GTE}]},minimum:{exclusive:"exclusiveMinimum",ops:[{okStr:">=",ok:Qt.GTE,fail:Qt.LT},{okStr:">",ok:Qt.GT,fail:Qt.LTE}]}},Py={message:t=>po.str`must be ${vo(t).okStr} ${t.schemaCode}`,params:t=>po._`{comparison: ${vo(t).okStr}, limit: ${t.schemaCode}}`},Oy={keyword:Object.keys(mo),type:"number",schemaType:"number",$data:!0,error:Py,code(t){let{data:e,schemaCode:r}=t;t.fail$data(po._`${e} ${vo(t).fail} ${r} || isNaN(${e})`)}};function vo(t){var e;let r=t.keyword,n=!((e=t.parentSchema)===null||e===void 0)&&e[mo[r].exclusive]?1:0;return mo[r].ops[n]}yo.default=Oy});var Tl=Y(go=>{"use strict";I();R();T();Object.defineProperty(go,"__esModule",{value:!0});var Il={exclusiveMaximum:"maximum",exclusiveMinimum:"minimum"},Ay={keyword:Object.keys(Il),type:"number",schemaType:"boolean",code({keyword:t,parentSchema:e}){let r=Il[t];if(e[r]===void 0)throw new Error(`${t} can only be used with ${r}`)}};go.default=Ay});var Rl=Y(_o=>{"use strict";I();R();T();Object.defineProperty(_o,"__esModule",{value:!0});var En=pe(),Iy={message:({schemaCode:t})=>(0,En.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,En._)`{multipleOf: ${t}}`},Ty={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Iy,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,s=i.opts.multipleOfPrecision,o=e.let("res"),a=s?(0,En._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${s}`:(0,En._)`${o} !== parseInt(${o})`;t.fail$data((0,En._)`(${n} === 0 || (${o} = ${r}/${n}, ${a}))`)}};_o.default=Ty});var kl=Y(wo=>{"use strict";I();R();T();Object.defineProperty(wo,"__esModule",{value:!0});function ql(t){let e=t.length,r=0,n=0,i;for(;n<e;)r++,i=t.charCodeAt(n++),i>=55296&&i<=56319&&n<e&&(i=t.charCodeAt(n),(i&64512)===56320&&n++);return r}wo.default=ql;ql.code='require("ajv/dist/runtime/ucs2length").default'});var Cl=Y(bo=>{"use strict";I();R();T();Object.defineProperty(bo,"__esModule",{value:!0});var hr=pe(),Ry=be(),qy=kl(),ky={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,hr.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,hr._)`{limit: ${t}}`},Cy={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:ky,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,s=e==="maxLength"?hr.operators.GT:hr.operators.LT,o=i.opts.unicode===!1?(0,hr._)`${r}.length`:(0,hr._)`${(0,Ry.useFunc)(t.gen,qy.default)}(${r})`;t.fail$data((0,hr._)`${o} ${s} ${n}`)}};bo.default=Cy});var xl=Y(Eo=>{"use strict";I();R();T();Object.defineProperty(Eo,"__esModule",{value:!0});var xy=lt(),gi=pe(),jy={message:({schemaCode:t})=>(0,gi.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,gi._)`{pattern: ${t}}`},Ny={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:jy,code(t){let{data:e,$data:r,schema:n,schemaCode:i,it:s}=t,o=s.opts.unicodeRegExp?"u":"",a=r?(0,gi._)`(new RegExp(${i}, ${o}))`:(0,xy.usePattern)(t,n);t.fail$data((0,gi._)`!${a}.test(${e})`)}};Eo.default=Ny});var jl=Y($o=>{"use strict";I();R();T();Object.defineProperty($o,"__esModule",{value:!0});var $n=pe(),Dy={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,$n.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,$n._)`{limit: ${t}}`},By={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Dy,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?$n.operators.GT:$n.operators.LT;t.fail$data((0,$n._)`Object.keys(${r}).length ${i} ${n}`)}};$o.default=By});var Nl=Y(So=>{"use strict";I();R();T();Object.defineProperty(So,"__esModule",{value:!0});var Sn=lt(),Pn=pe(),Ly=be(),My={message:({params:{missingProperty:t}})=>(0,Pn.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Pn._)`{missingProperty: ${t}}`},Uy={keyword:"required",type:"object",schemaType:"array",$data:!0,error:My,code(t){let{gen:e,schema:r,schemaCode:n,data:i,$data:s,it:o}=t,{opts:a}=o;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(o.allErrors?d():m(),a.strictRequired){let _=t.parentSchema.properties,{definedProperties:b}=t.it;for(let P of r)if(_?.[P]===void 0&&!b.has(P)){let S=o.schemaEnv.baseId+o.errSchemaPath,y=`required property "${P}" is not defined at "${S}" (strictRequired)`;(0,Ly.checkStrictMode)(o,y,o.opts.strictRequired)}}function d(){if(c||s)t.block$data(Pn.nil,f);else for(let _ of r)(0,Sn.checkReportMissingProp)(t,_)}function m(){let _=e.let("missing");if(c||s){let b=e.let("valid",!0);t.block$data(b,()=>g(_,b)),t.ok(b)}else e.if((0,Sn.checkMissingProp)(t,r,_)),(0,Sn.reportMissingProp)(t,_),e.else()}function f(){e.forOf("prop",n,_=>{t.setParams({missingProperty:_}),e.if((0,Sn.noPropertyInData)(e,i,_,a.ownProperties),()=>t.error())})}function g(_,b){t.setParams({missingProperty:_}),e.forOf(_,n,()=>{e.assign(b,(0,Sn.propertyInData)(e,i,_,a.ownProperties)),e.if((0,Pn.not)(b),()=>{t.error(),e.break()})},Pn.nil)}}};So.default=Uy});var Dl=Y(Po=>{"use strict";I();R();T();Object.defineProperty(Po,"__esModule",{value:!0});var On=pe(),Gy={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,On.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,On._)`{limit: ${t}}`},Fy={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Gy,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?On.operators.GT:On.operators.LT;t.fail$data((0,On._)`${r}.length ${i} ${n}`)}};Po.default=Fy});var _i=Y(Oo=>{"use strict";I();R();T();Object.defineProperty(Oo,"__esModule",{value:!0});var Bl=Vs();Bl.code='require("ajv/dist/runtime/equal").default';Oo.default=Bl});var Ll=Y(Io=>{"use strict";I();R();T();Object.defineProperty(Io,"__esModule",{value:!0});var Ao=hn(),Ke=pe(),zy=be(),Ky=_i(),Vy={message:({params:{i:t,j:e}})=>(0,Ke.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Ke._)`{i: ${t}, j: ${e}}`},Jy={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Vy,code(t){let{gen:e,data:r,$data:n,schema:i,parentSchema:s,schemaCode:o,it:a}=t;if(!n&&!i)return;let c=e.let("valid"),d=s.items?(0,Ao.getSchemaTypes)(s.items):[];t.block$data(c,m,(0,Ke._)`${o} === false`),t.ok(c);function m(){let b=e.let("i",(0,Ke._)`${r}.length`),P=e.let("j");t.setParams({i:b,j:P}),e.assign(c,!0),e.if((0,Ke._)`${b} > 1`,()=>(f()?g:_)(b,P))}function f(){return d.length>0&&!d.some(b=>b==="object"||b==="array")}function g(b,P){let S=e.name("item"),y=(0,Ao.checkDataTypes)(d,S,a.opts.strictNumbers,Ao.DataType.Wrong),w=e.const("indices",(0,Ke._)`{}`);e.for((0,Ke._)`;${b}--;`,()=>{e.let(S,(0,Ke._)`${r}[${b}]`),e.if(y,(0,Ke._)`continue`),d.length>1&&e.if((0,Ke._)`typeof ${S} == "string"`,(0,Ke._)`${S} += "_"`),e.if((0,Ke._)`typeof ${w}[${S}] == "number"`,()=>{e.assign(P,(0,Ke._)`${w}[${S}]`),t.error(),e.assign(c,!1).break()}).code((0,Ke._)`${w}[${S}] = ${b}`)})}function _(b,P){let S=(0,zy.useFunc)(e,Ky.default),y=e.name("outer");e.label(y).for((0,Ke._)`;${b}--;`,()=>e.for((0,Ke._)`${P} = ${b}; ${P}--;`,()=>e.if((0,Ke._)`${S}(${r}[${b}], ${r}[${P}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Io.default=Jy});var Ml=Y(Ro=>{"use strict";I();R();T();Object.defineProperty(Ro,"__esModule",{value:!0});var To=pe(),Hy=be(),Wy=_i(),Qy={message:"must be equal to constant",params:({schemaCode:t})=>(0,To._)`{allowedValue: ${t}}`},Yy={keyword:"const",$data:!0,error:Qy,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,To._)`!${(0,Hy.useFunc)(e,Wy.default)}(${r}, ${i})`):t.fail((0,To._)`${s} !== ${r}`)}};Ro.default=Yy});var Ul=Y(qo=>{"use strict";I();R();T();Object.defineProperty(qo,"__esModule",{value:!0});var An=pe(),Xy=be(),Zy=_i(),eg={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,An._)`{allowedValues: ${t}}`},tg={keyword:"enum",schemaType:"array",$data:!0,error:eg,code(t){let{gen:e,data:r,$data:n,schema:i,schemaCode:s,it:o}=t;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=o.opts.loopEnum,c,d=()=>c??(c=(0,Xy.useFunc)(e,Zy.default)),m;if(a||n)m=e.let("valid"),t.block$data(m,f);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let _=e.const("vSchema",s);m=(0,An.or)(...i.map((b,P)=>g(_,P)))}t.pass(m);function f(){e.assign(m,!1),e.forOf("v",s,_=>e.if((0,An._)`${d()}(${r}, ${_})`,()=>e.assign(m,!0).break()))}function g(_,b){let P=i[b];return typeof P=="object"&&P!==null?(0,An._)`${d()}(${r}, ${_}[${b}])`:(0,An._)`${r} === ${P}`}}};qo.default=tg});var Gl=Y(ko=>{"use strict";I();R();T();Object.defineProperty(ko,"__esModule",{value:!0});var rg=Al(),ng=Tl(),ig=Rl(),sg=Cl(),og=xl(),ag=jl(),ug=Nl(),cg=Dl(),fg=Ll(),lg=Ml(),dg=Ul(),hg=[rg.default,ng.default,ig.default,sg.default,og.default,ag.default,ug.default,cg.default,fg.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},lg.default,dg.default];ko.default=hg});var xo=Y(In=>{"use strict";I();R();T();Object.defineProperty(In,"__esModule",{value:!0});In.validateAdditionalItems=void 0;var pr=pe(),Co=be(),pg={message:({params:{len:t}})=>(0,pr.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,pr._)`{limit: ${t}}`},mg={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:pg,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Co.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Fl(t,n)}};function Fl(t,e){let{gen:r,schema:n,data:i,keyword:s,it:o}=t;o.items=!0;let a=r.const("len",(0,pr._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,pr._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Co.alwaysValidSchema)(o,n)){let d=r.var("valid",(0,pr._)`${a} <= ${e.length}`);r.if((0,pr.not)(d),()=>c(d)),t.ok(d)}function c(d){r.forRange("i",e.length,a,m=>{t.subschema({keyword:s,dataProp:m,dataPropType:Co.Type.Num},d),o.allErrors||r.if((0,pr.not)(d),()=>r.break())})}}In.validateAdditionalItems=Fl;In.default=mg});var jo=Y(Tn=>{"use strict";I();R();T();Object.defineProperty(Tn,"__esModule",{value:!0});Tn.validateTuple=void 0;var zl=pe(),wi=be(),vg=lt(),yg={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Kl(t,"additionalItems",e);r.items=!0,!(0,wi.alwaysValidSchema)(r,e)&&t.ok((0,vg.validateArray)(t))}};function Kl(t,e,r=t.schema){let{gen:n,parentSchema:i,data:s,keyword:o,it:a}=t;m(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=wi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),d=n.const("len",(0,zl._)`${s}.length`);r.forEach((f,g)=>{(0,wi.alwaysValidSchema)(a,f)||(n.if((0,zl._)`${d} > ${g}`,()=>t.subschema({keyword:o,schemaProp:g,dataProp:g},c)),t.ok(c))});function m(f){let{opts:g,errSchemaPath:_}=a,b=r.length,P=b===f.minItems&&(b===f.maxItems||f[e]===!1);if(g.strictTuples&&!P){let S=`"${o}" is ${b}-tuple, but minItems or maxItems/${e} are not specified or different at path "${_}"`;(0,wi.checkStrictMode)(a,S,g.strictTuples)}}}Tn.validateTuple=Kl;Tn.default=yg});var Vl=Y(No=>{"use strict";I();R();T();Object.defineProperty(No,"__esModule",{value:!0});var gg=jo(),_g={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,gg.validateTuple)(t,"items")};No.default=_g});var Hl=Y(Do=>{"use strict";I();R();T();Object.defineProperty(Do,"__esModule",{value:!0});var Jl=pe(),wg=be(),bg=lt(),Eg=xo(),$g={message:({params:{len:t}})=>(0,Jl.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Jl._)`{limit: ${t}}`},Sg={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:$g,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,wg.alwaysValidSchema)(n,e)&&(i?(0,Eg.validateAdditionalItems)(t,i):t.ok((0,bg.validateArray)(t)))}};Do.default=Sg});var Wl=Y(Bo=>{"use strict";I();R();T();Object.defineProperty(Bo,"__esModule",{value:!0});var ht=pe(),bi=be(),Pg={message:({params:{min:t,max:e}})=>e===void 0?(0,ht.str)`must contain at least ${t} valid item(s)`:(0,ht.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,ht._)`{minContains: ${t}}`:(0,ht._)`{minContains: ${t}, maxContains: ${e}}`},Og={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Pg,code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:s}=t,o,a,{minContains:c,maxContains:d}=n;s.opts.next?(o=c===void 0?1:c,a=d):o=1;let m=e.const("len",(0,ht._)`${i}.length`);if(t.setParams({min:o,max:a}),a===void 0&&o===0){(0,bi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,bi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,bi.alwaysValidSchema)(s,r)){let P=(0,ht._)`${m} >= ${o}`;a!==void 0&&(P=(0,ht._)`${P} && ${m} <= ${a}`),t.pass(P);return}s.items=!0;let f=e.name("valid");a===void 0&&o===1?_(f,()=>e.if(f,()=>e.break())):o===0?(e.let(f,!0),a!==void 0&&e.if((0,ht._)`${i}.length > 0`,g)):(e.let(f,!1),g()),t.result(f,()=>t.reset());function g(){let P=e.name("_valid"),S=e.let("count",0);_(P,()=>e.if(P,()=>b(S)))}function _(P,S){e.forRange("i",0,m,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:bi.Type.Num,compositeRule:!0},P),S()})}function b(P){e.code((0,ht._)`${P}++`),a===void 0?e.if((0,ht._)`${P} >= ${o}`,()=>e.assign(f,!0).break()):(e.if((0,ht._)`${P} > ${a}`,()=>e.assign(f,!1).break()),o===1?e.assign(f,!0):e.if((0,ht._)`${P} >= ${o}`,()=>e.assign(f,!0)))}}};Bo.default=Og});var Xl=Y(At=>{"use strict";I();R();T();Object.defineProperty(At,"__esModule",{value:!0});At.validateSchemaDeps=At.validatePropertyDeps=At.error=void 0;var Lo=pe(),Ag=be(),Rn=lt();At.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Lo.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Lo._)`{property: ${t},
5
+ || ${o} === "boolean" || ${i} === null`).assign(a,(0,ue._)`[${i}]`)}}}function um({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,ue._)`${e} !== undefined`,()=>t.assign((0,ue._)`${e}[${r}]`,n))}function Ms(t,e,r,n=xr.Correct){let i=n===xr.Correct?ue.operators.EQ:ue.operators.NEQ,s;switch(t){case"null":return(0,ue._)`${e} ${i} null`;case"array":s=(0,ue._)`Array.isArray(${e})`;break;case"object":s=(0,ue._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=o((0,ue._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=o();break;default:return(0,ue._)`typeof ${e} ${i} ${t}`}return n===xr.Correct?s:(0,ue.not)(s);function o(a=ue.nil){return(0,ue.and)((0,ue._)`typeof ${e} == "number"`,a,r?(0,ue._)`isFinite(${e})`:ue.nil)}}Ze.checkDataType=Ms;function Us(t,e,r,n){if(t.length===1)return Ms(t[0],e,r,n);let i,s=(0,pf.toHash)(t);if(s.array&&s.object){let o=(0,ue._)`typeof ${e} != "object"`;i=s.null?o:(0,ue._)`!${e} || ${o}`,delete s.null,delete s.array,delete s.object}else i=ue.nil;s.number&&delete s.integer;for(let o in s)i=(0,ue.and)(i,Ms(o,e,r,n));return i}Ze.checkDataTypes=Us;var cm={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,ue._)`{type: ${t}}`:(0,ue._)`{type: ${e}}`};function Gs(t){let e=fm(t);(0,nm.reportError)(e,cm)}Ze.reportTypeError=Gs;function fm(t){let{gen:e,data:r,schema:n}=t,i=(0,pf.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var gf=Y(ii=>{"use strict";I();R();T();Object.defineProperty(ii,"__esModule",{value:!0});ii.assignDefaults=void 0;var Nr=pe(),lm=be();function dm(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)yf(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,s)=>yf(t,s,i.default))}ii.assignDefaults=dm;function yf(t,e,r){let{gen:n,compositeRule:i,data:s,opts:o}=t;if(r===void 0)return;let a=(0,Nr._)`${s}${(0,Nr.getProperty)(e)}`;if(i){(0,lm.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Nr._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,Nr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Nr._)`${a} = ${(0,Nr.stringify)(r)}`)}});var lt=Y(Oe=>{"use strict";I();R();T();Object.defineProperty(Oe,"__esModule",{value:!0});Oe.validateUnion=Oe.validateArray=Oe.usePattern=Oe.callValidateCode=Oe.schemaProperties=Oe.allSchemaProperties=Oe.noPropertyInData=Oe.propertyInData=Oe.isOwnProperty=Oe.hasPropFunc=Oe.reportMissingProp=Oe.checkMissingProp=Oe.checkReportMissingProp=void 0;var qe=pe(),Fs=be(),Vt=Bt(),hm=be();function pm(t,e){let{gen:r,data:n,it:i}=t;r.if(Ks(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,qe._)`${e}`},!0),t.error()})}Oe.checkReportMissingProp=pm;function mm({gen:t,data:e,it:{opts:r}},n,i){return(0,qe.or)(...n.map(s=>(0,qe.and)(Ks(t,e,s,r.ownProperties),(0,qe._)`${i} = ${s}`)))}Oe.checkMissingProp=mm;function vm(t,e){t.setParams({missingProperty:e},!0),t.error()}Oe.reportMissingProp=vm;function _f(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,qe._)`Object.prototype.hasOwnProperty`})}Oe.hasPropFunc=_f;function zs(t,e,r){return(0,qe._)`${_f(t)}.call(${e}, ${r})`}Oe.isOwnProperty=zs;function ym(t,e,r,n){let i=(0,qe._)`${e}${(0,qe.getProperty)(r)} !== undefined`;return n?(0,qe._)`${i} && ${zs(t,e,r)}`:i}Oe.propertyInData=ym;function Ks(t,e,r,n){let i=(0,qe._)`${e}${(0,qe.getProperty)(r)} === undefined`;return n?(0,qe.or)(i,(0,qe.not)(zs(t,e,r))):i}Oe.noPropertyInData=Ks;function wf(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}Oe.allSchemaProperties=wf;function gm(t,e){return wf(e).filter(r=>!(0,Fs.alwaysValidSchema)(t,e[r]))}Oe.schemaProperties=gm;function _m({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:s},it:o},a,c,d){let m=d?(0,qe._)`${t}, ${e}, ${n}${i}`:e,f=[[Vt.default.instancePath,(0,qe.strConcat)(Vt.default.instancePath,s)],[Vt.default.parentData,o.parentData],[Vt.default.parentDataProperty,o.parentDataProperty],[Vt.default.rootData,Vt.default.rootData]];o.opts.dynamicRef&&f.push([Vt.default.dynamicAnchors,Vt.default.dynamicAnchors]);let y=(0,qe._)`${m}, ${r.object(...f)}`;return c!==qe.nil?(0,qe._)`${a}.call(${c}, ${y})`:(0,qe._)`${a}(${y})`}Oe.callValidateCode=_m;var wm=(0,qe._)`new RegExp`;function bm({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:i}=e.code,s=i(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,qe._)`${i.code==="new RegExp"?wm:(0,hm.useFunc)(t,i)}(${r}, ${n})`})}Oe.usePattern=bm;function Em(t){let{gen:e,data:r,keyword:n,it:i}=t,s=e.name("valid");if(i.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(s,!0),o(()=>e.break()),s;function o(a){let c=e.const("len",(0,qe._)`${r}.length`);e.forRange("i",0,c,d=>{t.subschema({keyword:n,dataProp:d,dataPropType:Fs.Type.Num},s),e.if((0,qe.not)(s),a)})}}Oe.validateArray=Em;function $m(t){let{gen:e,schema:r,keyword:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Fs.alwaysValidSchema)(i,c))&&!i.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,d)=>{let m=t.subschema({keyword:n,schemaProp:d,compositeRule:!0},a);e.assign(o,(0,qe._)`${o} || ${a}`),t.mergeValidEvaluated(m,a)||e.if((0,qe.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}Oe.validateUnion=$m});var $f=Y(St=>{"use strict";I();R();T();Object.defineProperty(St,"__esModule",{value:!0});St.validateKeywordUsage=St.validSchemaType=St.funcKeywordCode=St.macroKeywordCode=void 0;var tt=pe(),fr=Bt(),Sm=lt(),Pm=dn();function Om(t,e){let{gen:r,keyword:n,schema:i,parentSchema:s,it:o}=t,a=e.macro.call(o.self,i,s,o),c=Ef(r,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let d=r.name("valid");t.subschema({schema:a,schemaPath:tt.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},d),t.pass(d,()=>t.error(!0))}St.macroKeywordCode=Om;function Am(t,e){var r;let{gen:n,keyword:i,schema:s,parentSchema:o,$data:a,it:c}=t;Tm(c,e);let d=!a&&e.compile?e.compile.call(c.self,s,o,c):e.validate,m=Ef(n,i,d),f=n.let("valid");t.block$data(f,y),t.ok((r=e.valid)!==null&&r!==void 0?r:f);function y(){if(e.errors===!1)P(),e.modifying&&bf(t),S(()=>t.error());else{let g=e.async?_():b();e.modifying&&bf(t),S(()=>Im(t,g))}}function _(){let g=n.let("ruleErrs",null);return n.try(()=>P((0,tt._)`await `),w=>n.assign(f,!1).if((0,tt._)`${w} instanceof ${c.ValidationError}`,()=>n.assign(g,(0,tt._)`${w}.errors`),()=>n.throw(w))),g}function b(){let g=(0,tt._)`${m}.errors`;return n.assign(g,null),P(tt.nil),g}function P(g=e.async?(0,tt._)`await `:tt.nil){let w=c.opts.passContext?fr.default.this:fr.default.self,p=!("compile"in e&&!a||e.schema===!1);n.assign(f,(0,tt._)`${g}${(0,Sm.callValidateCode)(t,m,w,p)}`,e.modifying)}function S(g){var w;n.if((0,tt.not)((w=e.valid)!==null&&w!==void 0?w:f),g)}}St.funcKeywordCode=Am;function bf(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,tt._)`${n.parentData}[${n.parentDataProperty}]`))}function Im(t,e){let{gen:r}=t;r.if((0,tt._)`Array.isArray(${e})`,()=>{r.assign(fr.default.vErrors,(0,tt._)`${fr.default.vErrors} === null ? ${e} : ${fr.default.vErrors}.concat(${e})`).assign(fr.default.errors,(0,tt._)`${fr.default.vErrors}.length`),(0,Pm.extendErrors)(t)},()=>t.error())}function Tm({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Ef(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,tt.stringify)(r)})}function Rm(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}St.validSchemaType=Rm;function qm({schema:t,opts:e,self:r,errSchemaPath:n},i,s){if(Array.isArray(i.keyword)?!i.keyword.includes(s):i.keyword!==s)throw new Error("ajv implementation error");let o=i.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}St.validateKeywordUsage=qm});var Pf=Y(Jt=>{"use strict";I();R();T();Object.defineProperty(Jt,"__esModule",{value:!0});Jt.extendSubschemaMode=Jt.extendSubschemaData=Jt.getSubschema=void 0;var Pt=pe(),Sf=be();function km(t,{keyword:e,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:s,topSchemaRef:o}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Pt._)`${t.schemaPath}${(0,Pt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Pt._)`${t.schemaPath}${(0,Pt.getProperty)(e)}${(0,Pt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Sf.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||s===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:o,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Jt.getSubschema=km;function Cm(t,e,{dataProp:r,dataPropType:n,data:i,dataTypes:s,propertyName:o}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:d,dataPathArr:m,opts:f}=e,y=a.let("data",(0,Pt._)`${e.data}${(0,Pt.getProperty)(r)}`,!0);c(y),t.errorPath=(0,Pt.str)`${d}${(0,Sf.getErrorPath)(r,n,f.jsPropertySyntax)}`,t.parentDataProperty=(0,Pt._)`${r}`,t.dataPathArr=[...m,t.parentDataProperty]}if(i!==void 0){let d=i instanceof Pt.Name?i:a.let("data",i,!0);c(d),o!==void 0&&(t.propertyName=o)}s&&(t.dataTypes=s);function c(d){t.data=d,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,d]}}Jt.extendSubschemaData=Cm;function xm(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:s}){n!==void 0&&(t.compositeRule=n),i!==void 0&&(t.createErrors=i),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Jt.extendSubschemaMode=xm});var Vs=Y((EE,Of)=>{"use strict";I();R();T();Of.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[i]))return!1;for(i=n;i--!==0;){var o=s[i];if(!t(e[o],r[o]))return!1}return!0}return e!==e&&r!==r}});var If=Y((OE,Af)=>{"use strict";I();R();T();var Ht=Af.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};si(e,n,i,t,"",t)};Ht.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ht.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ht.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ht.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 si(t,e,r,n,i,s,o,a,c,d){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,i,s,o,a,c,d);for(var m in n){var f=n[m];if(Array.isArray(f)){if(m in Ht.arrayKeywords)for(var y=0;y<f.length;y++)si(t,e,r,f[y],i+"/"+m+"/"+y,s,i,m,n,y)}else if(m in Ht.propsKeywords){if(f&&typeof f=="object")for(var _ in f)si(t,e,r,f[_],i+"/"+m+"/"+Nm(_),s,i,m,n,_)}else(m in Ht.keywords||t.allKeys&&!(m in Ht.skipKeywords))&&si(t,e,r,f,i+"/"+m,s,i,m,n)}r(n,i,s,o,a,c,d)}}function Nm(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var pn=Y(ot=>{"use strict";I();R();T();Object.defineProperty(ot,"__esModule",{value:!0});ot.getSchemaRefs=ot.resolveUrl=ot.normalizeId=ot._getFullPath=ot.getFullPath=ot.inlineRef=void 0;var jm=be(),Dm=Vs(),Bm=If(),Lm=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Mm(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Js(t):e?Tf(t)<=e:!1}ot.inlineRef=Mm;var Um=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Js(t){for(let e in t){if(Um.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Js)||typeof r=="object"&&Js(r))return!0}return!1}function Tf(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Lm.has(r)&&(typeof t[r]=="object"&&(0,jm.eachItem)(t[r],n=>e+=Tf(n)),e===1/0))return 1/0}return e}function Rf(t,e="",r){r!==!1&&(e=jr(e));let n=t.parse(e);return qf(t,n)}ot.getFullPath=Rf;function qf(t,e){return t.serialize(e).split("#")[0]+"#"}ot._getFullPath=qf;var Gm=/#\/?$/;function jr(t){return t?t.replace(Gm,""):""}ot.normalizeId=jr;function Fm(t,e,r){return r=jr(r),t.resolve(e,r)}ot.resolveUrl=Fm;var zm=/^[a-z_][-a-z0-9._]*$/i;function Km(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=jr(t[r]||e),s={"":i},o=Rf(n,i,!1),a={},c=new Set;return Bm(t,{allKeys:!0},(f,y,_,b)=>{if(b===void 0)return;let P=o+y,S=s[b];typeof f[r]=="string"&&(S=g.call(this,f[r])),w.call(this,f.$anchor),w.call(this,f.$dynamicAnchor),s[y]=S;function g(p){let h=this.opts.uriResolver.resolve;if(p=jr(S?h(S,p):p),c.has(p))throw m(p);c.add(p);let v=this.refs[p];return typeof v=="string"&&(v=this.refs[v]),typeof v=="object"?d(f,v.schema,p):p!==jr(P)&&(p[0]==="#"?(d(f,a[p],p),a[p]=f):this.refs[p]=P),p}function w(p){if(typeof p=="string"){if(!zm.test(p))throw new Error(`invalid anchor "${p}"`);g.call(this,`#${p}`)}}}),a;function d(f,y,_){if(y!==void 0&&!Dm(f,y))throw m(_)}function m(f){return new Error(`reference "${f}" resolves to more than one schema`)}}ot.getSchemaRefs=Km});var ui=Y(Wt=>{"use strict";I();R();T();Object.defineProperty(Wt,"__esModule",{value:!0});Wt.getData=Wt.KeywordCxt=Wt.validateFunctionCode=void 0;var jf=lf(),kf=hn(),Ws=Ls(),oi=hn(),Vm=gf(),vn=$f(),Hs=Pf(),te=pe(),se=Bt(),Jm=pn(),Lt=be(),mn=dn();function Hm(t){if(Lf(t)&&(Mf(t),Bf(t))){Ym(t);return}Df(t,()=>(0,jf.topBoolOrEmptySchema)(t))}Wt.validateFunctionCode=Hm;function Df({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},s){i.code.es5?t.func(e,(0,te._)`${se.default.data}, ${se.default.valCxt}`,n.$async,()=>{t.code((0,te._)`"use strict"; ${Cf(r,i)}`),Qm(t,i),t.code(s)}):t.func(e,(0,te._)`${se.default.data}, ${Wm(i)}`,n.$async,()=>t.code(Cf(r,i)).code(s))}function Wm(t){return(0,te._)`{${se.default.instancePath}="", ${se.default.parentData}, ${se.default.parentDataProperty}, ${se.default.rootData}=${se.default.data}${t.dynamicRef?(0,te._)`, ${se.default.dynamicAnchors}={}`:te.nil}}={}`}function Qm(t,e){t.if(se.default.valCxt,()=>{t.var(se.default.instancePath,(0,te._)`${se.default.valCxt}.${se.default.instancePath}`),t.var(se.default.parentData,(0,te._)`${se.default.valCxt}.${se.default.parentData}`),t.var(se.default.parentDataProperty,(0,te._)`${se.default.valCxt}.${se.default.parentDataProperty}`),t.var(se.default.rootData,(0,te._)`${se.default.valCxt}.${se.default.rootData}`),e.dynamicRef&&t.var(se.default.dynamicAnchors,(0,te._)`${se.default.valCxt}.${se.default.dynamicAnchors}`)},()=>{t.var(se.default.instancePath,(0,te._)`""`),t.var(se.default.parentData,(0,te._)`undefined`),t.var(se.default.parentDataProperty,(0,te._)`undefined`),t.var(se.default.rootData,se.default.data),e.dynamicRef&&t.var(se.default.dynamicAnchors,(0,te._)`{}`)})}function Ym(t){let{schema:e,opts:r,gen:n}=t;Df(t,()=>{r.$comment&&e.$comment&&Gf(t),rv(t),n.let(se.default.vErrors,null),n.let(se.default.errors,0),r.unevaluated&&Xm(t),Uf(t),sv(t)})}function Xm(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,te._)`${r}.evaluated`),e.if((0,te._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,te._)`${t.evaluated}.props`,(0,te._)`undefined`)),e.if((0,te._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,te._)`${t.evaluated}.items`,(0,te._)`undefined`))}function Cf(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,te._)`/*# sourceURL=${r} */`:te.nil}function Zm(t,e){if(Lf(t)&&(Mf(t),Bf(t))){ev(t,e);return}(0,jf.boolOrEmptySchema)(t,e)}function Bf({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Lf(t){return typeof t.schema!="boolean"}function ev(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&Gf(t),nv(t),iv(t);let s=n.const("_errs",se.default.errors);Uf(t,s),n.var(e,(0,te._)`${s} === ${se.default.errors}`)}function Mf(t){(0,Lt.checkUnknownRules)(t),tv(t)}function Uf(t,e){if(t.opts.jtd)return xf(t,[],!1,e);let r=(0,kf.getSchemaTypes)(t.schema),n=(0,kf.coerceAndCheckDataType)(t,r);xf(t,r,!n,e)}function tv(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Lt.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function rv(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Lt.checkStrictMode)(t,"default is ignored in the schema root")}function nv(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Jm.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function iv(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Gf({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let s=r.$comment;if(i.$comment===!0)t.code((0,te._)`${se.default.self}.logger.log(${s})`);else if(typeof i.$comment=="function"){let o=(0,te.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,te._)`${se.default.self}.opts.$comment(${s}, ${o}, ${a}.schema)`)}}function sv(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:s}=t;r.$async?e.if((0,te._)`${se.default.errors} === 0`,()=>e.return(se.default.data),()=>e.throw((0,te._)`new ${i}(${se.default.vErrors})`)):(e.assign((0,te._)`${n}.errors`,se.default.vErrors),s.unevaluated&&ov(t),e.return((0,te._)`${se.default.errors} === 0`))}function ov({gen:t,evaluated:e,props:r,items:n}){r instanceof te.Name&&t.assign((0,te._)`${e}.props`,r),n instanceof te.Name&&t.assign((0,te._)`${e}.items`,n)}function xf(t,e,r,n){let{gen:i,schema:s,data:o,allErrors:a,opts:c,self:d}=t,{RULES:m}=d;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Lt.schemaHasRulesButRef)(s,m))){i.block(()=>zf(t,"$ref",m.all.$ref.definition));return}c.jtd||av(t,e),i.block(()=>{for(let y of m.rules)f(y);f(m.post)});function f(y){(0,Ws.shouldUseGroup)(s,y)&&(y.type?(i.if((0,oi.checkDataType)(y.type,o,c.strictNumbers)),Nf(t,y),e.length===1&&e[0]===y.type&&r&&(i.else(),(0,oi.reportTypeError)(t)),i.endIf()):Nf(t,y),a||i.if((0,te._)`${se.default.errors} === ${n||0}`))}}function Nf(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,Vm.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Ws.shouldUseRule)(n,s)&&zf(t,s.keyword,s.definition,e.type)})}function av(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(uv(t,e),t.opts.allowUnionTypes||cv(t,e),fv(t,t.dataTypes))}function uv(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Ff(t.dataTypes,r)||Qs(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),dv(t,e)}}function cv(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Qs(t,"use allowUnionTypes to allow union type keyword")}function fv(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,Ws.shouldUseRule)(t.schema,i)){let{type:s}=i.definition;s.length&&!s.some(o=>lv(e,o))&&Qs(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function lv(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Ff(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function dv(t,e){let r=[];for(let n of t.dataTypes)Ff(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Qs(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Lt.checkStrictMode)(t,e,t.opts.strictTypes)}var ai=class{constructor(e,r,n){if((0,vn.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Lt.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Kf(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,vn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",se.default.errors))}result(e,r,n){this.failResult((0,te.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,te.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,te._)`${r} !== undefined && (${(0,te.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?mn.reportExtraError:mn.reportError)(this,this.def.error,r)}$dataError(){(0,mn.reportError)(this,this.def.$dataError||mn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,mn.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=te.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=te.nil,r=te.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:s,def:o}=this;n.if((0,te.or)((0,te._)`${i} === undefined`,r)),e!==te.nil&&n.assign(e,!0),(s.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==te.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:s}=this;return(0,te.or)(o(),a());function o(){if(n.length){if(!(r instanceof te.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,te._)`${(0,oi.checkDataTypes)(c,r,s.opts.strictNumbers,oi.DataType.Wrong)}`}return te.nil}function a(){if(i.validateSchema){let c=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,te._)`!${c}(${r})`}return te.nil}}subschema(e,r){let n=(0,Hs.getSubschema)(this.it,e);(0,Hs.extendSubschemaData)(n,this.it,e),(0,Hs.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return Zm(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Lt.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Lt.mergeEvaluated.items(i,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(e,te.Name)),!0}};Wt.KeywordCxt=ai;function zf(t,e,r,n){let i=new ai(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,vn.funcKeywordCode)(i,r):"macro"in r?(0,vn.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,vn.funcKeywordCode)(i,r)}var hv=/^\/(?:[^~]|~0|~1)*$/,pv=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Kf(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,s;if(t==="")return se.default.rootData;if(t[0]==="/"){if(!hv.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,s=se.default.rootData}else{let d=pv.exec(t);if(!d)throw new Error(`Invalid JSON-pointer: ${t}`);let m=+d[1];if(i=d[2],i==="#"){if(m>=e)throw new Error(c("property/index",m));return n[e-m]}if(m>e)throw new Error(c("data",m));if(s=r[e-m],!i)return s}let o=s,a=i.split("/");for(let d of a)d&&(s=(0,te._)`${s}${(0,te.getProperty)((0,Lt.unescapeJsonPointer)(d))}`,o=(0,te._)`${o} && ${s}`);return o;function c(d,m){return`Cannot access ${d} ${m} levels up, current level is ${e}`}}Wt.getData=Kf});var Zs=Y(Xs=>{"use strict";I();R();T();Object.defineProperty(Xs,"__esModule",{value:!0});var Ys=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Xs.default=Ys});var ci=Y(ro=>{"use strict";I();R();T();Object.defineProperty(ro,"__esModule",{value:!0});var eo=pn(),to=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,eo.resolveUrl)(e,r,n),this.missingSchema=(0,eo.normalizeId)((0,eo.getFullPath)(e,this.missingRef))}};ro.default=to});var li=Y(dt=>{"use strict";I();R();T();Object.defineProperty(dt,"__esModule",{value:!0});dt.resolveSchema=dt.getCompilingSchema=dt.resolveRef=dt.compileSchema=dt.SchemaEnv=void 0;var gt=pe(),mv=Zs(),lr=Bt(),_t=pn(),Vf=be(),vv=ui(),Dr=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,_t.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};dt.SchemaEnv=Dr;function io(t){let e=Jf.call(this,t);if(e)return e;let r=(0,_t.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:s}=this.opts,o=new gt.CodeGen(this.scope,{es5:n,lines:i,ownProperties:s}),a;t.$async&&(a=o.scopeValue("Error",{ref:mv.default,code:(0,gt._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");t.validateName=c;let d={gen:o,allErrors:this.opts.allErrors,data:lr.default.data,parentData:lr.default.parentData,parentDataProperty:lr.default.parentDataProperty,dataNames:[lr.default.data],dataPathArr:[gt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,gt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:gt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,gt._)`""`,opts:this.opts,self:this},m;try{this._compilations.add(t),(0,vv.validateFunctionCode)(d),o.optimize(this.opts.code.optimize);let f=o.toString();m=`${o.scopeRefs(lr.default.scope)}return ${f}`,this.opts.code.process&&(m=this.opts.code.process(m,t));let _=new Function(`${lr.default.self}`,`${lr.default.scope}`,m)(this,this.scope.get());if(this.scope.value(c,{ref:_}),_.errors=null,_.schema=t.schema,_.schemaEnv=t,t.$async&&(_.$async=!0),this.opts.code.source===!0&&(_.source={validateName:c,validateCode:f,scopeValues:o._values}),this.opts.unevaluated){let{props:b,items:P}=d;_.evaluated={props:b instanceof gt.Name?void 0:b,items:P instanceof gt.Name?void 0:P,dynamicProps:b instanceof gt.Name,dynamicItems:P instanceof gt.Name},_.source&&(_.source.evaluated=(0,gt.stringify)(_.evaluated))}return t.validate=_,t}catch(f){throw delete t.validate,delete t.validateName,m&&this.logger.error("Error compiling schema, function code:",m),f}finally{this._compilations.delete(t)}}dt.compileSchema=io;function yv(t,e,r){var n;r=(0,_t.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let s=wv.call(this,t,r);if(s===void 0){let o=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;o&&(s=new Dr({schema:o,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=gv.call(this,s)}dt.resolveRef=yv;function gv(t){return(0,_t.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:io.call(this,t)}function Jf(t){for(let e of this._compilations)if(_v(e,t))return e}dt.getCompilingSchema=Jf;function _v(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function wv(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||fi.call(this,t,e)}function fi(t,e){let r=this.opts.uriResolver.parse(e),n=(0,_t._getFullPath)(this.opts.uriResolver,r),i=(0,_t.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return no.call(this,r,t);let s=(0,_t.normalizeId)(n),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=fi.call(this,t,o);return typeof a?.schema!="object"?void 0:no.call(this,r,a)}if(typeof o?.schema=="object"){if(o.validate||io.call(this,o),s===(0,_t.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,d=a[c];return d&&(i=(0,_t.resolveUrl)(this.opts.uriResolver,i,d)),new Dr({schema:a,schemaId:c,root:t,baseId:i})}return no.call(this,r,o)}}dt.resolveSchema=fi;var bv=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function no(t,{baseId:e,schema:r,root:n}){var i;if(((i=t.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Vf.unescapeFragment)(a)];if(c===void 0)return;r=c;let d=typeof r=="object"&&r[this.opts.schemaId];!bv.has(a)&&d&&(e=(0,_t.resolveUrl)(this.opts.uriResolver,e,d))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Vf.schemaHasRulesButRef)(r,this.RULES)){let a=(0,_t.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=fi.call(this,n,a)}let{schemaId:o}=this.opts;if(s=s||new Dr({schema:r,schemaId:o,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var Hf=Y((QE,Ev)=>{Ev.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Qf=Y((YE,Wf)=>{"use strict";I();R();T();var $v={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};Wf.exports={HEX:$v}});var il=Y((t$,nl)=>{"use strict";I();R();T();var{HEX:Sv}=Qf(),Pv=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function el(t){if(rl(t,".")<3)return{host:t,isIPV4:!1};let e=t.match(Pv)||[],[r]=e;return r?{host:Av(r,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function so(t,e=!1){let r="",n=!0;for(let i of t){if(Sv[i]===void 0)return;i!=="0"&&n===!0&&(n=!1),n||(r+=i)}return e&&r.length===0&&(r="0"),r}function Ov(t){let e=0,r={error:!1,address:"",zone:""},n=[],i=[],s=!1,o=!1,a=!1;function c(){if(i.length){if(s===!1){let d=so(i);if(d!==void 0)n.push(d);else return r.error=!0,!1}i.length=0}return!0}for(let d=0;d<t.length;d++){let m=t[d];if(!(m==="["||m==="]"))if(m===":"){if(o===!0&&(a=!0),!c())break;if(e++,n.push(":"),e>7){r.error=!0;break}d-1>=0&&t[d-1]===":"&&(o=!0);continue}else if(m==="%"){if(!c())break;s=!0}else{i.push(m);continue}}return i.length&&(s?r.zone=i.join(""):a?n.push(i.join("")):n.push(so(i))),r.address=n.join(""),r}function tl(t){if(rl(t,":")<2)return{host:t,isIPV6:!1};let e=Ov(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,escapedHost:n,isIPV6:!0}}}function Av(t,e){let r="",n=!0,i=t.length;for(let s=0;s<i;s++){let o=t[s];o==="0"&&n?(s+1<=i&&t[s+1]===e||s+1===i)&&(r+=o,n=!1):(o===e?n=!0:n=!1,r+=o)}return r}function rl(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}var Yf=/^\.\.?\//u,Xf=/^\/\.(?:\/|$)/u,Zf=/^\/\.\.(?:\/|$)/u,Iv=/^\/?(?:.|\n)*?(?=\/|$)/u;function Tv(t){let e=[];for(;t.length;)if(t.match(Yf))t=t.replace(Yf,"");else if(t.match(Xf))t=t.replace(Xf,"/");else if(t.match(Zf))t=t.replace(Zf,"/"),e.pop();else if(t==="."||t==="..")t="";else{let r=t.match(Iv);if(r){let n=r[0];t=t.slice(n.length),e.push(n)}else throw new Error("Unexpected dot segment condition")}return e.join("")}function Rv(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function qv(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host),n=el(r);if(n.isIPV4)r=n.host;else{let i=tl(n.host);i.isIPV6===!0?r=`[${i.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}nl.exports={recomposeAuthority:qv,normalizeComponentEncoding:Rv,removeDotSegments:Tv,normalizeIPv4:el,normalizeIPv6:tl,stringArrayToHexStripped:so}});var fl=Y((s$,cl)=>{"use strict";I();R();T();var kv=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,Cv=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function sl(t){return typeof t.secure=="boolean"?t.secure:String(t.scheme).toLowerCase()==="wss"}function ol(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function al(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function xv(t){return t.secure=sl(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Nv(t){if((t.port===(sl(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function jv(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Cv);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let i=`${n}:${e.nid||t.nid}`,s=oo[i];t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Dv(t,e){let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),i=`${r}:${e.nid||n}`,s=oo[i];s&&(t=s.serialize(t,e));let o=t,a=t.nss;return o.path=`${n||e.nid}:${a}`,e.skipEscape=!0,o}function Bv(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!kv.test(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Lv(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var ul={scheme:"http",domainHost:!0,parse:ol,serialize:al},Mv={scheme:"https",domainHost:ul.domainHost,parse:ol,serialize:al},di={scheme:"ws",domainHost:!0,parse:xv,serialize:Nv},Uv={scheme:"wss",domainHost:di.domainHost,parse:di.parse,serialize:di.serialize},Gv={scheme:"urn",parse:jv,serialize:Dv,skipNormalize:!0},Fv={scheme:"urn:uuid",parse:Bv,serialize:Lv,skipNormalize:!0},oo={http:ul,https:Mv,ws:di,wss:Uv,urn:Gv,"urn:uuid":Fv};cl.exports=oo});var dl=Y((c$,pi)=>{"use strict";I();R();T();var{normalizeIPv6:zv,normalizeIPv4:Kv,removeDotSegments:yn,recomposeAuthority:Vv,normalizeComponentEncoding:hi}=il(),ao=fl();function Jv(t,e){return typeof t=="string"?t=Ot(Mt(t,e),e):typeof t=="object"&&(t=Mt(Ot(t,e),e)),t}function Hv(t,e,r){let n=Object.assign({scheme:"null"},r),i=ll(Mt(t,n),Mt(e,n),n,!0);return Ot(i,{...n,skipEscape:!0})}function ll(t,e,r,n){let i={};return n||(t=Mt(Ot(t,r),r),e=Mt(Ot(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=yn(e.path||""),i.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=yn(e.path||""),i.query=e.query):(e.path?(e.path.charAt(0)==="/"?i.path=yn(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?i.path="/"+e.path:t.path?i.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:i.path=e.path,i.path=yn(i.path)),i.query=e.query):(i.path=t.path,e.query!==void 0?i.query=e.query:i.query=t.query),i.userinfo=t.userinfo,i.host=t.host,i.port=t.port),i.scheme=t.scheme),i.fragment=e.fragment,i}function Wv(t,e,r){return typeof t=="string"?(t=unescape(t),t=Ot(hi(Mt(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=Ot(hi(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=Ot(hi(Mt(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=Ot(hi(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function Ot(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),i=[],s=ao[(n.scheme||r.scheme||"").toLowerCase()];s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let o=Vv(r);if(o!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(o),r.path&&r.path.charAt(0)!=="/"&&i.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=yn(a)),o===void 0&&(a=a.replace(/^\/\//u,"/%2F")),i.push(a)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var Qv=Array.from({length:127},(t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)));function Yv(t){let e=0;for(let r=0,n=t.length;r<n;++r)if(e=t.charCodeAt(r),e>126||Qv[e])return!0;return!1}var Xv=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Mt(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=t.indexOf("%")!==-1,s=!1;r.reference==="suffix"&&(t=(r.scheme?r.scheme+":":"")+"//"+t);let o=t.match(Xv);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host){let c=Kv(n.host);if(c.isIPV4===!1){let d=zv(c.host);n.host=d.host.toLowerCase(),s=d.isIPV6}else n.host=c.host,s=!0}n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=ao[(r.scheme||n.scheme||"").toLowerCase()];if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===!1&&Yv(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(c){n.error=n.error||"Host's domain name can not be converted to ASCII: "+c}(!a||a&&!a.skipNormalize)&&(i&&n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),i&&n.host!==void 0&&(n.host=unescape(n.host)),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var uo={SCHEMES:ao,normalize:Jv,resolve:Hv,resolveComponents:ll,equal:Wv,serialize:Ot,parse:Mt};pi.exports=uo;pi.exports.default=uo;pi.exports.fastUri=uo});var pl=Y(co=>{"use strict";I();R();T();Object.defineProperty(co,"__esModule",{value:!0});var hl=dl();hl.code='require("ajv/dist/runtime/uri").default';co.default=hl});var bn=Y(ze=>{"use strict";I();R();T();Object.defineProperty(ze,"__esModule",{value:!0});ze.CodeGen=ze.Name=ze.nil=ze.stringify=ze.str=ze._=ze.KeywordCxt=void 0;var Zv=ui();Object.defineProperty(ze,"KeywordCxt",{enumerable:!0,get:function(){return Zv.KeywordCxt}});var Br=pe();Object.defineProperty(ze,"_",{enumerable:!0,get:function(){return Br._}});Object.defineProperty(ze,"str",{enumerable:!0,get:function(){return Br.str}});Object.defineProperty(ze,"stringify",{enumerable:!0,get:function(){return Br.stringify}});Object.defineProperty(ze,"nil",{enumerable:!0,get:function(){return Br.nil}});Object.defineProperty(ze,"Name",{enumerable:!0,get:function(){return Br.Name}});Object.defineProperty(ze,"CodeGen",{enumerable:!0,get:function(){return Br.CodeGen}});var ey=Zs(),_l=ci(),ty=Bs(),gn=li(),ry=pe(),_n=pn(),mi=hn(),lo=be(),ml=Hf(),ny=pl(),wl=(t,e)=>new RegExp(t,e);wl.code="new RegExp";var iy=["removeAdditional","useDefaults","coerceTypes"],sy=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),oy={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},ay={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},vl=200;function uy(t){var e,r,n,i,s,o,a,c,d,m,f,y,_,b,P,S,g,w,p,h,v,E,k,x,j;let G=t.strict,H=(e=t.code)===null||e===void 0?void 0:e.optimize,re=H===!0||H===void 0?1:H||0,Q=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:wl,Z=(i=t.uriResolver)!==null&&i!==void 0?i:ny.default;return{strictSchema:(o=(s=t.strictSchema)!==null&&s!==void 0?s:G)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:G)!==null&&c!==void 0?c:!0,strictTypes:(m=(d=t.strictTypes)!==null&&d!==void 0?d:G)!==null&&m!==void 0?m:"log",strictTuples:(y=(f=t.strictTuples)!==null&&f!==void 0?f:G)!==null&&y!==void 0?y:"log",strictRequired:(b=(_=t.strictRequired)!==null&&_!==void 0?_:G)!==null&&b!==void 0?b:!1,code:t.code?{...t.code,optimize:re,regExp:Q}:{optimize:re,regExp:Q},loopRequired:(P=t.loopRequired)!==null&&P!==void 0?P:vl,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:vl,meta:(g=t.meta)!==null&&g!==void 0?g:!0,messages:(w=t.messages)!==null&&w!==void 0?w:!0,inlineRefs:(p=t.inlineRefs)!==null&&p!==void 0?p:!0,schemaId:(h=t.schemaId)!==null&&h!==void 0?h:"$id",addUsedSchema:(v=t.addUsedSchema)!==null&&v!==void 0?v:!0,validateSchema:(E=t.validateSchema)!==null&&E!==void 0?E:!0,validateFormats:(k=t.validateFormats)!==null&&k!==void 0?k:!0,unicodeRegExp:(x=t.unicodeRegExp)!==null&&x!==void 0?x:!0,int32range:(j=t.int32range)!==null&&j!==void 0?j:!0,uriResolver:Z}}var wn=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...uy(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new ry.ValueScope({scope:{},prefixes:sy,es5:r,lines:n}),this.logger=py(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,ty.getRules)(),yl.call(this,oy,e,"NOT SUPPORTED"),yl.call(this,ay,e,"DEPRECATED","warn"),this._metaOpts=dy.call(this),e.formats&&fy.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&ly.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),cy.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=ml;n==="id"&&(i={...ml},i.id=i.$id,delete i.$id),r&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,e,r);async function i(m,f){await s.call(this,m.$schema);let y=this._addSchema(m,f);return y.validate||o.call(this,y)}async function s(m){m&&!this.getSchema(m)&&await i.call(this,{$ref:m},!0)}async function o(m){try{return this._compileSchemaEnv(m)}catch(f){if(!(f instanceof _l.default))throw f;return a.call(this,f),await c.call(this,f.missingSchema),o.call(this,m)}}function a({missingSchema:m,missingRef:f}){if(this.refs[m])throw new Error(`AnySchema ${m} is loaded but ${f} cannot be resolved`)}async function c(m){let f=await d.call(this,m);this.refs[m]||await s.call(this,f.$schema),this.refs[m]||this.addSchema(f,m,r)}async function d(m){let f=this._loading[m];if(f)return f;try{return await(this._loading[m]=n(m))}finally{delete this._loading[m]}}}addSchema(e,r,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,i);return this}let s;if(typeof e=="object"){let{schemaId:o}=this.opts;if(s=e[o],s!==void 0&&typeof s!="string")throw new Error(`schema ${o} must be string`)}return r=(0,_n.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,i,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let i=this.validate(n,e);if(!i&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return i}getSchema(e){let r;for(;typeof(r=gl.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new gn.SchemaEnv({schema:{},schemaId:n});if(r=gn.resolveSchema.call(this,i,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=gl.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,_n.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(vy.call(this,n,r),!r)return(0,lo.eachItem)(n,s=>fo.call(this,s)),this;gy.call(this,r);let i={...r,type:(0,mi.getJSONTypes)(r.type),schemaType:(0,mi.getJSONTypes)(r.schemaType)};return(0,lo.eachItem)(n,i.type.length===0?s=>fo.call(this,s,i):s=>i.type.forEach(o=>fo.call(this,s,i,o))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let i=n.rules.findIndex(s=>s.keyword===e);i>=0&&n.rules.splice(i,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,s)=>i+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of r){let s=i.split("/").slice(1),o=e;for(let a of s)o=o[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:d}=c.definition,m=o[a];d&&m&&(o[a]=bl(m))}}return e}_removeAllSchemas(e,r){for(let n in e){let i=e[n];(!r||r.test(n))&&(typeof i=="string"?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,r,n,i=this.opts.validateSchema,s=this.opts.addUsedSchema){let o,{schemaId:a}=this.opts;if(typeof e=="object")o=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,_n.normalizeId)(o||n);let d=_n.getSchemaRefs.call(this,e,n);return c=new gn.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:d}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),i&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):gn.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{gn.compileSchema.call(this,e)}finally{this.opts=r}}};wn.ValidationError=ey.default;wn.MissingRefError=_l.default;ze.default=wn;function yl(t,e,r,n="error"){for(let i in t){let s=i;s in e&&this.logger[n](`${r}: option ${i}. ${t[s]}`)}}function gl(t){return t=(0,_n.normalizeId)(t),this.schemas[t]||this.refs[t]}function cy(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function fy(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function ly(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function dy(){let t={...this.opts};for(let e of iy)delete t[e];return t}var hy={log(){},warn(){},error(){}};function py(t){if(t===!1)return hy;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var my=/^[a-z_$][a-z0-9_$:-]*$/i;function vy(t,e){let{RULES:r}=this;if((0,lo.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!my.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function fo(t,e,r){var n;let i=e?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,o=i?s.post:s.rules.find(({type:c})=>c===r);if(o||(o={type:r,rules:[]},s.rules.push(o)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,mi.getJSONTypes)(e.type),schemaType:(0,mi.getJSONTypes)(e.schemaType)}};e.before?yy.call(this,o,a,e.before):o.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function yy(t,e,r){let n=t.rules.findIndex(i=>i.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function gy(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=bl(e)),t.validateSchema=this.compile(e,!0))}var _y={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function bl(t){return{anyOf:[t,_y]}}});var Pl=Y(dr=>{"use strict";I();R();T();Object.defineProperty(dr,"__esModule",{value:!0});dr.callRef=dr.getValidate=void 0;var wy=ci(),El=lt(),at=pe(),Lr=Bt(),$l=li(),vi=be(),by={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:i,schemaEnv:s,validateName:o,opts:a,self:c}=n,{root:d}=s;if((r==="#"||r==="#/")&&i===d.baseId)return f();let m=$l.resolveRef.call(c,d,i,r);if(m===void 0)throw new wy.default(n.opts.uriResolver,i,r);if(m instanceof $l.SchemaEnv)return y(m);return _(m);function f(){if(s===d)return yi(t,o,s,s.$async);let b=e.scopeValue("root",{ref:d});return yi(t,(0,at._)`${b}.validate`,d,d.$async)}function y(b){let P=Sl(t,b);yi(t,P,b,b.$async)}function _(b){let P=e.scopeValue("schema",a.code.source===!0?{ref:b,code:(0,at.stringify)(b)}:{ref:b}),S=e.name("valid"),g=t.subschema({schema:b,dataTypes:[],schemaPath:at.nil,topSchemaRef:P,errSchemaPath:r},S);t.mergeEvaluated(g),t.ok(S)}}};function Sl(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,at._)`${r.scopeValue("wrapper",{ref:e})}.validate`}dr.getValidate=Sl;function yi(t,e,r,n){let{gen:i,it:s}=t,{allErrors:o,schemaEnv:a,opts:c}=s,d=c.passContext?Lr.default.this:at.nil;n?m():f();function m(){if(!a.$async)throw new Error("async schema referenced by sync schema");let b=i.let("valid");i.try(()=>{i.code((0,at._)`await ${(0,El.callValidateCode)(t,e,d)}`),_(e),o||i.assign(b,!0)},P=>{i.if((0,at._)`!(${P} instanceof ${s.ValidationError})`,()=>i.throw(P)),y(P),o||i.assign(b,!1)}),t.ok(b)}function f(){t.result((0,El.callValidateCode)(t,e,d),()=>_(e),()=>y(e))}function y(b){let P=(0,at._)`${b}.errors`;i.assign(Lr.default.vErrors,(0,at._)`${Lr.default.vErrors} === null ? ${P} : ${Lr.default.vErrors}.concat(${P})`),i.assign(Lr.default.errors,(0,at._)`${Lr.default.vErrors}.length`)}function _(b){var P;if(!s.opts.unevaluated)return;let S=(P=r?.validate)===null||P===void 0?void 0:P.evaluated;if(s.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(s.props=vi.mergeEvaluated.props(i,S.props,s.props));else{let g=i.var("props",(0,at._)`${b}.evaluated.props`);s.props=vi.mergeEvaluated.props(i,g,s.props,at.Name)}if(s.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(s.items=vi.mergeEvaluated.items(i,S.items,s.items));else{let g=i.var("items",(0,at._)`${b}.evaluated.items`);s.items=vi.mergeEvaluated.items(i,g,s.items,at.Name)}}}dr.callRef=yi;dr.default=by});var Ol=Y(ho=>{"use strict";I();R();T();Object.defineProperty(ho,"__esModule",{value:!0});var Ey=Pl(),$y=["$schema","id","$defs",{keyword:"$comment"},"definitions",Ey.default];ho.default=$y});var Al=Y(yo=>{"use strict";I();R();T();Object.defineProperty(yo,"__esModule",{value:!0});var po=bn(),Sy=pe(),Qt=Sy.operators,mo={maximum:{exclusive:"exclusiveMaximum",ops:[{okStr:"<=",ok:Qt.LTE,fail:Qt.GT},{okStr:"<",ok:Qt.LT,fail:Qt.GTE}]},minimum:{exclusive:"exclusiveMinimum",ops:[{okStr:">=",ok:Qt.GTE,fail:Qt.LT},{okStr:">",ok:Qt.GT,fail:Qt.LTE}]}},Py={message:t=>po.str`must be ${vo(t).okStr} ${t.schemaCode}`,params:t=>po._`{comparison: ${vo(t).okStr}, limit: ${t.schemaCode}}`},Oy={keyword:Object.keys(mo),type:"number",schemaType:"number",$data:!0,error:Py,code(t){let{data:e,schemaCode:r}=t;t.fail$data(po._`${e} ${vo(t).fail} ${r} || isNaN(${e})`)}};function vo(t){var e;let r=t.keyword,n=!((e=t.parentSchema)===null||e===void 0)&&e[mo[r].exclusive]?1:0;return mo[r].ops[n]}yo.default=Oy});var Tl=Y(go=>{"use strict";I();R();T();Object.defineProperty(go,"__esModule",{value:!0});var Il={exclusiveMaximum:"maximum",exclusiveMinimum:"minimum"},Ay={keyword:Object.keys(Il),type:"number",schemaType:"boolean",code({keyword:t,parentSchema:e}){let r=Il[t];if(e[r]===void 0)throw new Error(`${t} can only be used with ${r}`)}};go.default=Ay});var Rl=Y(_o=>{"use strict";I();R();T();Object.defineProperty(_o,"__esModule",{value:!0});var En=pe(),Iy={message:({schemaCode:t})=>(0,En.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,En._)`{multipleOf: ${t}}`},Ty={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Iy,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,s=i.opts.multipleOfPrecision,o=e.let("res"),a=s?(0,En._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${s}`:(0,En._)`${o} !== parseInt(${o})`;t.fail$data((0,En._)`(${n} === 0 || (${o} = ${r}/${n}, ${a}))`)}};_o.default=Ty});var kl=Y(wo=>{"use strict";I();R();T();Object.defineProperty(wo,"__esModule",{value:!0});function ql(t){let e=t.length,r=0,n=0,i;for(;n<e;)r++,i=t.charCodeAt(n++),i>=55296&&i<=56319&&n<e&&(i=t.charCodeAt(n),(i&64512)===56320&&n++);return r}wo.default=ql;ql.code='require("ajv/dist/runtime/ucs2length").default'});var Cl=Y(bo=>{"use strict";I();R();T();Object.defineProperty(bo,"__esModule",{value:!0});var hr=pe(),Ry=be(),qy=kl(),ky={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,hr.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,hr._)`{limit: ${t}}`},Cy={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:ky,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,s=e==="maxLength"?hr.operators.GT:hr.operators.LT,o=i.opts.unicode===!1?(0,hr._)`${r}.length`:(0,hr._)`${(0,Ry.useFunc)(t.gen,qy.default)}(${r})`;t.fail$data((0,hr._)`${o} ${s} ${n}`)}};bo.default=Cy});var xl=Y(Eo=>{"use strict";I();R();T();Object.defineProperty(Eo,"__esModule",{value:!0});var xy=lt(),gi=pe(),Ny={message:({schemaCode:t})=>(0,gi.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,gi._)`{pattern: ${t}}`},jy={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Ny,code(t){let{data:e,$data:r,schema:n,schemaCode:i,it:s}=t,o=s.opts.unicodeRegExp?"u":"",a=r?(0,gi._)`(new RegExp(${i}, ${o}))`:(0,xy.usePattern)(t,n);t.fail$data((0,gi._)`!${a}.test(${e})`)}};Eo.default=jy});var Nl=Y($o=>{"use strict";I();R();T();Object.defineProperty($o,"__esModule",{value:!0});var $n=pe(),Dy={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,$n.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,$n._)`{limit: ${t}}`},By={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Dy,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?$n.operators.GT:$n.operators.LT;t.fail$data((0,$n._)`Object.keys(${r}).length ${i} ${n}`)}};$o.default=By});var jl=Y(So=>{"use strict";I();R();T();Object.defineProperty(So,"__esModule",{value:!0});var Sn=lt(),Pn=pe(),Ly=be(),My={message:({params:{missingProperty:t}})=>(0,Pn.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Pn._)`{missingProperty: ${t}}`},Uy={keyword:"required",type:"object",schemaType:"array",$data:!0,error:My,code(t){let{gen:e,schema:r,schemaCode:n,data:i,$data:s,it:o}=t,{opts:a}=o;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(o.allErrors?d():m(),a.strictRequired){let _=t.parentSchema.properties,{definedProperties:b}=t.it;for(let P of r)if(_?.[P]===void 0&&!b.has(P)){let S=o.schemaEnv.baseId+o.errSchemaPath,g=`required property "${P}" is not defined at "${S}" (strictRequired)`;(0,Ly.checkStrictMode)(o,g,o.opts.strictRequired)}}function d(){if(c||s)t.block$data(Pn.nil,f);else for(let _ of r)(0,Sn.checkReportMissingProp)(t,_)}function m(){let _=e.let("missing");if(c||s){let b=e.let("valid",!0);t.block$data(b,()=>y(_,b)),t.ok(b)}else e.if((0,Sn.checkMissingProp)(t,r,_)),(0,Sn.reportMissingProp)(t,_),e.else()}function f(){e.forOf("prop",n,_=>{t.setParams({missingProperty:_}),e.if((0,Sn.noPropertyInData)(e,i,_,a.ownProperties),()=>t.error())})}function y(_,b){t.setParams({missingProperty:_}),e.forOf(_,n,()=>{e.assign(b,(0,Sn.propertyInData)(e,i,_,a.ownProperties)),e.if((0,Pn.not)(b),()=>{t.error(),e.break()})},Pn.nil)}}};So.default=Uy});var Dl=Y(Po=>{"use strict";I();R();T();Object.defineProperty(Po,"__esModule",{value:!0});var On=pe(),Gy={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,On.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,On._)`{limit: ${t}}`},Fy={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Gy,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?On.operators.GT:On.operators.LT;t.fail$data((0,On._)`${r}.length ${i} ${n}`)}};Po.default=Fy});var _i=Y(Oo=>{"use strict";I();R();T();Object.defineProperty(Oo,"__esModule",{value:!0});var Bl=Vs();Bl.code='require("ajv/dist/runtime/equal").default';Oo.default=Bl});var Ll=Y(Io=>{"use strict";I();R();T();Object.defineProperty(Io,"__esModule",{value:!0});var Ao=hn(),Ke=pe(),zy=be(),Ky=_i(),Vy={message:({params:{i:t,j:e}})=>(0,Ke.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,Ke._)`{i: ${t}, j: ${e}}`},Jy={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Vy,code(t){let{gen:e,data:r,$data:n,schema:i,parentSchema:s,schemaCode:o,it:a}=t;if(!n&&!i)return;let c=e.let("valid"),d=s.items?(0,Ao.getSchemaTypes)(s.items):[];t.block$data(c,m,(0,Ke._)`${o} === false`),t.ok(c);function m(){let b=e.let("i",(0,Ke._)`${r}.length`),P=e.let("j");t.setParams({i:b,j:P}),e.assign(c,!0),e.if((0,Ke._)`${b} > 1`,()=>(f()?y:_)(b,P))}function f(){return d.length>0&&!d.some(b=>b==="object"||b==="array")}function y(b,P){let S=e.name("item"),g=(0,Ao.checkDataTypes)(d,S,a.opts.strictNumbers,Ao.DataType.Wrong),w=e.const("indices",(0,Ke._)`{}`);e.for((0,Ke._)`;${b}--;`,()=>{e.let(S,(0,Ke._)`${r}[${b}]`),e.if(g,(0,Ke._)`continue`),d.length>1&&e.if((0,Ke._)`typeof ${S} == "string"`,(0,Ke._)`${S} += "_"`),e.if((0,Ke._)`typeof ${w}[${S}] == "number"`,()=>{e.assign(P,(0,Ke._)`${w}[${S}]`),t.error(),e.assign(c,!1).break()}).code((0,Ke._)`${w}[${S}] = ${b}`)})}function _(b,P){let S=(0,zy.useFunc)(e,Ky.default),g=e.name("outer");e.label(g).for((0,Ke._)`;${b}--;`,()=>e.for((0,Ke._)`${P} = ${b}; ${P}--;`,()=>e.if((0,Ke._)`${S}(${r}[${b}], ${r}[${P}])`,()=>{t.error(),e.assign(c,!1).break(g)})))}}};Io.default=Jy});var Ml=Y(Ro=>{"use strict";I();R();T();Object.defineProperty(Ro,"__esModule",{value:!0});var To=pe(),Hy=be(),Wy=_i(),Qy={message:"must be equal to constant",params:({schemaCode:t})=>(0,To._)`{allowedValue: ${t}}`},Yy={keyword:"const",$data:!0,error:Qy,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,To._)`!${(0,Hy.useFunc)(e,Wy.default)}(${r}, ${i})`):t.fail((0,To._)`${s} !== ${r}`)}};Ro.default=Yy});var Ul=Y(qo=>{"use strict";I();R();T();Object.defineProperty(qo,"__esModule",{value:!0});var An=pe(),Xy=be(),Zy=_i(),eg={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,An._)`{allowedValues: ${t}}`},tg={keyword:"enum",schemaType:"array",$data:!0,error:eg,code(t){let{gen:e,data:r,$data:n,schema:i,schemaCode:s,it:o}=t;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=o.opts.loopEnum,c,d=()=>c??(c=(0,Xy.useFunc)(e,Zy.default)),m;if(a||n)m=e.let("valid"),t.block$data(m,f);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let _=e.const("vSchema",s);m=(0,An.or)(...i.map((b,P)=>y(_,P)))}t.pass(m);function f(){e.assign(m,!1),e.forOf("v",s,_=>e.if((0,An._)`${d()}(${r}, ${_})`,()=>e.assign(m,!0).break()))}function y(_,b){let P=i[b];return typeof P=="object"&&P!==null?(0,An._)`${d()}(${r}, ${_}[${b}])`:(0,An._)`${r} === ${P}`}}};qo.default=tg});var Gl=Y(ko=>{"use strict";I();R();T();Object.defineProperty(ko,"__esModule",{value:!0});var rg=Al(),ng=Tl(),ig=Rl(),sg=Cl(),og=xl(),ag=Nl(),ug=jl(),cg=Dl(),fg=Ll(),lg=Ml(),dg=Ul(),hg=[rg.default,ng.default,ig.default,sg.default,og.default,ag.default,ug.default,cg.default,fg.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},lg.default,dg.default];ko.default=hg});var xo=Y(In=>{"use strict";I();R();T();Object.defineProperty(In,"__esModule",{value:!0});In.validateAdditionalItems=void 0;var pr=pe(),Co=be(),pg={message:({params:{len:t}})=>(0,pr.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,pr._)`{limit: ${t}}`},mg={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:pg,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Co.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Fl(t,n)}};function Fl(t,e){let{gen:r,schema:n,data:i,keyword:s,it:o}=t;o.items=!0;let a=r.const("len",(0,pr._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,pr._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Co.alwaysValidSchema)(o,n)){let d=r.var("valid",(0,pr._)`${a} <= ${e.length}`);r.if((0,pr.not)(d),()=>c(d)),t.ok(d)}function c(d){r.forRange("i",e.length,a,m=>{t.subschema({keyword:s,dataProp:m,dataPropType:Co.Type.Num},d),o.allErrors||r.if((0,pr.not)(d),()=>r.break())})}}In.validateAdditionalItems=Fl;In.default=mg});var No=Y(Tn=>{"use strict";I();R();T();Object.defineProperty(Tn,"__esModule",{value:!0});Tn.validateTuple=void 0;var zl=pe(),wi=be(),vg=lt(),yg={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Kl(t,"additionalItems",e);r.items=!0,!(0,wi.alwaysValidSchema)(r,e)&&t.ok((0,vg.validateArray)(t))}};function Kl(t,e,r=t.schema){let{gen:n,parentSchema:i,data:s,keyword:o,it:a}=t;m(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=wi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),d=n.const("len",(0,zl._)`${s}.length`);r.forEach((f,y)=>{(0,wi.alwaysValidSchema)(a,f)||(n.if((0,zl._)`${d} > ${y}`,()=>t.subschema({keyword:o,schemaProp:y,dataProp:y},c)),t.ok(c))});function m(f){let{opts:y,errSchemaPath:_}=a,b=r.length,P=b===f.minItems&&(b===f.maxItems||f[e]===!1);if(y.strictTuples&&!P){let S=`"${o}" is ${b}-tuple, but minItems or maxItems/${e} are not specified or different at path "${_}"`;(0,wi.checkStrictMode)(a,S,y.strictTuples)}}}Tn.validateTuple=Kl;Tn.default=yg});var Vl=Y(jo=>{"use strict";I();R();T();Object.defineProperty(jo,"__esModule",{value:!0});var gg=No(),_g={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,gg.validateTuple)(t,"items")};jo.default=_g});var Hl=Y(Do=>{"use strict";I();R();T();Object.defineProperty(Do,"__esModule",{value:!0});var Jl=pe(),wg=be(),bg=lt(),Eg=xo(),$g={message:({params:{len:t}})=>(0,Jl.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Jl._)`{limit: ${t}}`},Sg={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:$g,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,wg.alwaysValidSchema)(n,e)&&(i?(0,Eg.validateAdditionalItems)(t,i):t.ok((0,bg.validateArray)(t)))}};Do.default=Sg});var Wl=Y(Bo=>{"use strict";I();R();T();Object.defineProperty(Bo,"__esModule",{value:!0});var ht=pe(),bi=be(),Pg={message:({params:{min:t,max:e}})=>e===void 0?(0,ht.str)`must contain at least ${t} valid item(s)`:(0,ht.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,ht._)`{minContains: ${t}}`:(0,ht._)`{minContains: ${t}, maxContains: ${e}}`},Og={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Pg,code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:s}=t,o,a,{minContains:c,maxContains:d}=n;s.opts.next?(o=c===void 0?1:c,a=d):o=1;let m=e.const("len",(0,ht._)`${i}.length`);if(t.setParams({min:o,max:a}),a===void 0&&o===0){(0,bi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,bi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,bi.alwaysValidSchema)(s,r)){let P=(0,ht._)`${m} >= ${o}`;a!==void 0&&(P=(0,ht._)`${P} && ${m} <= ${a}`),t.pass(P);return}s.items=!0;let f=e.name("valid");a===void 0&&o===1?_(f,()=>e.if(f,()=>e.break())):o===0?(e.let(f,!0),a!==void 0&&e.if((0,ht._)`${i}.length > 0`,y)):(e.let(f,!1),y()),t.result(f,()=>t.reset());function y(){let P=e.name("_valid"),S=e.let("count",0);_(P,()=>e.if(P,()=>b(S)))}function _(P,S){e.forRange("i",0,m,g=>{t.subschema({keyword:"contains",dataProp:g,dataPropType:bi.Type.Num,compositeRule:!0},P),S()})}function b(P){e.code((0,ht._)`${P}++`),a===void 0?e.if((0,ht._)`${P} >= ${o}`,()=>e.assign(f,!0).break()):(e.if((0,ht._)`${P} > ${a}`,()=>e.assign(f,!1).break()),o===1?e.assign(f,!0):e.if((0,ht._)`${P} >= ${o}`,()=>e.assign(f,!0)))}}};Bo.default=Og});var Xl=Y(At=>{"use strict";I();R();T();Object.defineProperty(At,"__esModule",{value:!0});At.validateSchemaDeps=At.validatePropertyDeps=At.error=void 0;var Lo=pe(),Ag=be(),Rn=lt();At.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Lo.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Lo._)`{property: ${t},
6
6
  missingProperty: ${n},
7
7
  depsCount: ${e},
8
- deps: ${r}}`};var Ig={keyword:"dependencies",type:"object",schemaType:"object",error:At.error,code(t){let[e,r]=Tg(t);Ql(t,e),Yl(t,r)}};function Tg({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let i=Array.isArray(t[n])?e:r;i[n]=t[n]}return[e,r]}function Ql(t,e=t.schema){let{gen:r,data:n,it:i}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,Rn.propertyInData)(r,n,o,i.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(c,()=>{for(let d of a)(0,Rn.checkReportMissingProp)(t,d)}):(r.if((0,Lo._)`${c} && (${(0,Rn.checkMissingProp)(t,a,s)})`),(0,Rn.reportMissingProp)(t,s),r.else())}}At.validatePropertyDeps=Ql;function Yl(t,e=t.schema){let{gen:r,data:n,keyword:i,it:s}=t,o=r.name("valid");for(let a in e)(0,Ag.alwaysValidSchema)(s,e[a])||(r.if((0,Rn.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:i,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>r.var(o,!0)),t.ok(o))}At.validateSchemaDeps=Yl;At.default=Ig});var ed=Y(Mo=>{"use strict";I();R();T();Object.defineProperty(Mo,"__esModule",{value:!0});var Zl=pe(),Rg=be(),qg={message:"property name must be valid",params:({params:t})=>(0,Zl._)`{propertyName: ${t.propertyName}}`},kg={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:qg,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,Rg.alwaysValidSchema)(i,r))return;let s=e.name("valid");e.forIn("key",n,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,Zl.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};Mo.default=kg});var Go=Y(Uo=>{"use strict";I();R();T();Object.defineProperty(Uo,"__esModule",{value:!0});var Ei=lt(),wt=pe(),Cg=Bt(),$i=be(),xg={message:"must NOT have additional properties",params:({params:t})=>(0,wt._)`{additionalProperty: ${t.additionalProperty}}`},jg={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:xg,code(t){let{gen:e,schema:r,parentSchema:n,data:i,errsCount:s,it:o}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,$i.alwaysValidSchema)(o,r))return;let d=(0,Ei.allSchemaProperties)(n.properties),m=(0,Ei.allSchemaProperties)(n.patternProperties);f(),t.ok((0,wt._)`${s} === ${Cg.default.errors}`);function f(){e.forIn("key",i,S=>{!d.length&&!m.length?b(S):e.if(g(S),()=>b(S))})}function g(S){let y;if(d.length>8){let w=(0,$i.schemaRefOrVal)(o,n.properties,"properties");y=(0,Ei.isOwnProperty)(e,w,S)}else d.length?y=(0,wt.or)(...d.map(w=>(0,wt._)`${S} === ${w}`)):y=wt.nil;return m.length&&(y=(0,wt.or)(y,...m.map(w=>(0,wt._)`${(0,Ei.usePattern)(t,w)}.test(${S})`))),(0,wt.not)(y)}function _(S){e.code((0,wt._)`delete ${i}[${S}]`)}function b(S){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){_(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,$i.alwaysValidSchema)(o,r)){let y=e.name("valid");c.removeAdditional==="failing"?(P(S,y,!1),e.if((0,wt.not)(y),()=>{t.reset(),_(S)})):(P(S,y),a||e.if((0,wt.not)(y),()=>e.break()))}}function P(S,y,w){let p={keyword:"additionalProperties",dataProp:S,dataPropType:$i.Type.Str};w===!1&&Object.assign(p,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(p,y)}}};Uo.default=jg});var nd=Y(zo=>{"use strict";I();R();T();Object.defineProperty(zo,"__esModule",{value:!0});var Ng=ui(),td=lt(),Fo=be(),rd=Go(),Dg={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&rd.default.code(new Ng.KeywordCxt(s,rd.default,"additionalProperties"));let o=(0,td.allSchemaProperties)(r);for(let f of o)s.definedProperties.add(f);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=Fo.mergeEvaluated.props(e,(0,Fo.toHash)(o),s.props));let a=o.filter(f=>!(0,Fo.alwaysValidSchema)(s,r[f]));if(a.length===0)return;let c=e.name("valid");for(let f of a)d(f)?m(f):(e.if((0,td.propertyInData)(e,i,f,s.opts.ownProperties)),m(f),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(f),t.ok(c);function d(f){return s.opts.useDefaults&&!s.compositeRule&&r[f].default!==void 0}function m(f){t.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};zo.default=Dg});var ad=Y(Ko=>{"use strict";I();R();T();Object.defineProperty(Ko,"__esModule",{value:!0});var id=lt(),Si=pe(),sd=be(),od=be(),Bg={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:i,it:s}=t,{opts:o}=s,a=(0,id.allSchemaProperties)(r),c=a.filter(P=>(0,sd.alwaysValidSchema)(s,r[P]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let d=o.strictSchema&&!o.allowMatchingProperties&&i.properties,m=e.name("valid");s.props!==!0&&!(s.props instanceof Si.Name)&&(s.props=(0,od.evaluatedPropsToName)(e,s.props));let{props:f}=s;g();function g(){for(let P of a)d&&_(P),s.allErrors?b(P):(e.var(m,!0),b(P),e.if(m))}function _(P){for(let S in d)new RegExp(P).test(S)&&(0,sd.checkStrictMode)(s,`property ${S} matches pattern ${P} (use allowMatchingProperties)`)}function b(P){e.forIn("key",n,S=>{e.if((0,Si._)`${(0,id.usePattern)(t,P)}.test(${S})`,()=>{let y=c.includes(P);y||t.subschema({keyword:"patternProperties",schemaProp:P,dataProp:S,dataPropType:od.Type.Str},m),s.opts.unevaluated&&f!==!0?e.assign((0,Si._)`${f}[${S}]`,!0):!y&&!s.allErrors&&e.if((0,Si.not)(m),()=>e.break())})})}}};Ko.default=Bg});var ud=Y(Vo=>{"use strict";I();R();T();Object.defineProperty(Vo,"__esModule",{value:!0});var Lg=be(),Mg={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,Lg.alwaysValidSchema)(n,r)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Vo.default=Mg});var cd=Y(Jo=>{"use strict";I();R();T();Object.defineProperty(Jo,"__esModule",{value:!0});var Ug=lt(),Gg={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Ug.validateUnion,error:{message:"must match a schema in anyOf"}};Jo.default=Gg});var fd=Y(Ho=>{"use strict";I();R();T();Object.defineProperty(Ho,"__esModule",{value:!0});var Pi=pe(),Fg=be(),zg={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Pi._)`{passingSchemas: ${t.passing}}`},Kg={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:zg,code(t){let{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let s=r,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(d),t.result(o,()=>t.reset(),()=>t.error(!0));function d(){s.forEach((m,f)=>{let g;(0,Fg.alwaysValidSchema)(i,m)?e.var(c,!0):g=t.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&e.if((0,Pi._)`${c} && ${o}`).assign(o,!1).assign(a,(0,Pi._)`[${a}, ${f}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,f),g&&t.mergeEvaluated(g,Pi.Name)})})}}};Ho.default=Kg});var ld=Y(Wo=>{"use strict";I();R();T();Object.defineProperty(Wo,"__esModule",{value:!0});var Vg=be(),Jg={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=e.name("valid");r.forEach((s,o)=>{if((0,Vg.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};Wo.default=Jg});var pd=Y(Qo=>{"use strict";I();R();T();Object.defineProperty(Qo,"__esModule",{value:!0});var Oi=pe(),hd=be(),Hg={message:({params:t})=>(0,Oi.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Oi._)`{failingKeyword: ${t.ifClause}}`},Wg={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Hg,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,hd.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=dd(n,"then"),s=dd(n,"else");if(!i&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),i&&s){let m=e.let("ifClause");t.setParams({ifClause:m}),e.if(a,d("then",m),d("else",m))}else i?e.if(a,d("then")):e.if((0,Oi.not)(a),d("else"));t.pass(o,()=>t.error(!0));function c(){let m=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(m)}function d(m,f){return()=>{let g=t.subschema({keyword:m},a);e.assign(o,a),t.mergeValidEvaluated(g,o),f?e.assign(f,(0,Oi._)`${m}`):t.setParams({ifClause:m})}}}};function dd(t,e){let r=t.schema[e];return r!==void 0&&!(0,hd.alwaysValidSchema)(t,r)}Qo.default=Wg});var md=Y(Yo=>{"use strict";I();R();T();Object.defineProperty(Yo,"__esModule",{value:!0});var Qg=be(),Yg={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Qg.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Yo.default=Yg});var vd=Y(Xo=>{"use strict";I();R();T();Object.defineProperty(Xo,"__esModule",{value:!0});var Xg=xo(),Zg=Vl(),e_=jo(),t_=Hl(),r_=Wl(),n_=Xl(),i_=ed(),s_=Go(),o_=nd(),a_=ad(),u_=ud(),c_=cd(),f_=fd(),l_=ld(),d_=pd(),h_=md();function p_(t=!1){let e=[u_.default,c_.default,f_.default,l_.default,d_.default,h_.default,i_.default,s_.default,n_.default,o_.default,a_.default];return t?e.push(Zg.default,t_.default):e.push(Xg.default,e_.default),e.push(r_.default),e}Xo.default=p_});var yd=Y(Zo=>{"use strict";I();R();T();Object.defineProperty(Zo,"__esModule",{value:!0});var Ne=pe(),m_={message:({schemaCode:t})=>(0,Ne.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ne._)`{format: ${t}}`},v_={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:m_,code(t,e){let{gen:r,data:n,$data:i,schema:s,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:d,schemaEnv:m,self:f}=a;if(!c.validateFormats)return;i?g():_();function g(){let b=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),P=r.const("fDef",(0,Ne._)`${b}[${o}]`),S=r.let("fType"),y=r.let("format");r.if((0,Ne._)`typeof ${P} == "object" && !(${P} instanceof RegExp)`,()=>r.assign(S,(0,Ne._)`${P}.type || "string"`).assign(y,(0,Ne._)`${P}.validate`),()=>r.assign(S,(0,Ne._)`"string"`).assign(y,P)),t.fail$data((0,Ne.or)(w(),p()));function w(){return c.strictSchema===!1?Ne.nil:(0,Ne._)`${o} && !${y}`}function p(){let h=m.$async?(0,Ne._)`(${P}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,Ne._)`${y}(${n})`,v=(0,Ne._)`(typeof ${y} == "function" ? ${h} : ${y}.test(${n}))`;return(0,Ne._)`${y} && ${y} !== true && ${S} === ${e} && !${v}`}}function _(){let b=f.formats[s];if(!b){w();return}if(b===!0)return;let[P,S,y]=p(b);P===e&&t.pass(h());function w(){if(c.strictSchema===!1){f.logger.warn(v());return}throw new Error(v());function v(){return`unknown format "${s}" ignored in schema at path "${d}"`}}function p(v){let E=v instanceof RegExp?(0,Ne.regexpCode)(v):c.code.formats?(0,Ne._)`${c.code.formats}${(0,Ne.getProperty)(s)}`:void 0,k=r.scopeValue("formats",{key:s,ref:v,code:E});return typeof v=="object"&&!(v instanceof RegExp)?[v.type||"string",v.validate,(0,Ne._)`${k}.validate`]:["string",v,k]}function h(){if(typeof b=="object"&&!(b instanceof RegExp)&&b.async){if(!m.$async)throw new Error("async format in sync schema");return(0,Ne._)`await ${y}(${n})`}return typeof S=="function"?(0,Ne._)`${y}(${n})`:(0,Ne._)`${y}.test(${n})`}}}};Zo.default=v_});var gd=Y(ea=>{"use strict";I();R();T();Object.defineProperty(ea,"__esModule",{value:!0});var y_=yd(),g_=[y_.default];ea.default=g_});var _d=Y(ta=>{"use strict";I();R();T();Object.defineProperty(ta,"__esModule",{value:!0});var __=Ol(),w_=Gl(),b_=vd(),E_=gd(),$_=["title","description","default"],S_=[__.default,w_.default,b_.default(),E_.default,$_];ta.default=S_});var bd=Y(Ai=>{"use strict";I();R();T();Object.defineProperty(Ai,"__esModule",{value:!0});Ai.DiscrError=void 0;var wd;(function(t){t.Tag="tag",t.Mapping="mapping"})(wd||(Ai.DiscrError=wd={}))});var $d=Y(na=>{"use strict";I();R();T();Object.defineProperty(na,"__esModule",{value:!0});var Mr=pe(),ra=bd(),Ed=li(),P_=ci(),O_=be(),A_={message:({params:{discrError:t,tagName:e}})=>t===ra.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Mr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},I_={keyword:"discriminator",type:"object",schemaType:"object",error:A_,code(t){let{gen:e,data:r,schema:n,parentSchema:i,it:s}=t,{oneOf:o}=i;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),d=e.const("tag",(0,Mr._)`${r}${(0,Mr.getProperty)(a)}`);e.if((0,Mr._)`typeof ${d} == "string"`,()=>m(),()=>t.error(!1,{discrError:ra.DiscrError.Tag,tag:d,tagName:a})),t.ok(c);function m(){let _=g();e.if(!1);for(let b in _)e.elseIf((0,Mr._)`${d} === ${b}`),e.assign(c,f(_[b]));e.else(),t.error(!1,{discrError:ra.DiscrError.Mapping,tag:d,tagName:a}),e.endIf()}function f(_){let b=e.name("valid"),P=t.subschema({keyword:"oneOf",schemaProp:_},b);return t.mergeEvaluated(P,Mr.Name),b}function g(){var _;let b={},P=y(i),S=!0;for(let h=0;h<o.length;h++){let v=o[h];if(v?.$ref&&!(0,O_.schemaHasRulesButRef)(v,s.self.RULES)){let k=v.$ref;if(v=Ed.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,k),v instanceof Ed.SchemaEnv&&(v=v.schema),v===void 0)throw new P_.default(s.opts.uriResolver,s.baseId,k)}let E=(_=v?.properties)===null||_===void 0?void 0:_[a];if(typeof E!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);S=S&&(P||y(v)),w(E,h)}if(!S)throw new Error(`discriminator: "${a}" must be required`);return b;function y({required:h}){return Array.isArray(h)&&h.includes(a)}function w(h,v){if(h.const)p(h.const,v);else if(h.enum)for(let E of h.enum)p(E,v);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function p(h,v){if(typeof h!="string"||h in b)throw new Error(`discriminator: "${a}" values must be unique strings`);b[h]=v}}}};na.default=I_});var Sd=Y((lO,T_)=>{T_.exports={id:"http://json-schema.org/draft-04/schema#",$schema:"http://json-schema.org/draft-04/schema#",description:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},positiveInteger:{type:"integer",minimum:0},positiveIntegerDefault0:{allOf:[{$ref:"#/definitions/positiveInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},minItems:1,uniqueItems:!0}},type:"object",properties:{id:{type:"string",format:"uri"},$schema:{type:"string",format:"uri"},title:{type:"string"},description:{type:"string"},default:{},multipleOf:{type:"number",minimum:0,exclusiveMinimum:!0},maximum:{type:"number"},exclusiveMaximum:{type:"boolean",default:!1},minimum:{type:"number"},exclusiveMinimum:{type:"boolean",default:!1},maxLength:{$ref:"#/definitions/positiveInteger"},minLength:{$ref:"#/definitions/positiveIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:{}},maxItems:{$ref:"#/definitions/positiveInteger"},minItems:{$ref:"#/definitions/positiveIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxProperties:{$ref:"#/definitions/positiveInteger"},minProperties:{$ref:"#/definitions/positiveIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},enum:{type:"array",minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},dependencies:{exclusiveMaximum:["maximum"],exclusiveMinimum:["minimum"]},default:{}}});var Ri=Y((Me,Od)=>{"use strict";I();R();T();Object.defineProperty(Me,"__esModule",{value:!0});Me.CodeGen=Me.Name=Me.nil=Me.stringify=Me.str=Me._=Me.KeywordCxt=void 0;var R_=bn(),q_=_d(),k_=$d(),Pd=Sd(),C_=["/properties"],Ii="http://json-schema.org/draft-04/schema",Ti=class extends R_.default{constructor(e={}){super({...e,schemaId:"id"})}_addVocabularies(){super._addVocabularies(),q_.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(k_.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Pd,C_):Pd;this.addMetaSchema(e,Ii,!1),this.refs["http://json-schema.org/schema"]=Ii}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ii)?Ii:void 0)}};Od.exports=Me=Ti;Object.defineProperty(Me,"__esModule",{value:!0});Me.default=Ti;var x_=bn();Object.defineProperty(Me,"KeywordCxt",{enumerable:!0,get:function(){return x_.KeywordCxt}});var Ur=bn();Object.defineProperty(Me,"_",{enumerable:!0,get:function(){return Ur._}});Object.defineProperty(Me,"str",{enumerable:!0,get:function(){return Ur.str}});Object.defineProperty(Me,"stringify",{enumerable:!0,get:function(){return Ur.stringify}});Object.defineProperty(Me,"nil",{enumerable:!0,get:function(){return Ur.nil}});Object.defineProperty(Me,"Name",{enumerable:!0,get:function(){return Ur.Name}});Object.defineProperty(Me,"CodeGen",{enumerable:!0,get:function(){return Ur.CodeGen}})});var Td=Y((Ad,Id)=>{I();R();T();(function(t){if(typeof Ad=="object")Id.exports=t();else if(typeof define=="function"&&define.amd)define(t);else{var e;try{e=window}catch{e=self}e.SparkMD5=t()}})(function(t){"use strict";var e=function(y,w){return y+w&4294967295},r=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(y,w,p,h,v,E){return w=e(e(w,y),e(h,E)),e(w<<v|w>>>32-v,p)}function i(y,w){var p=y[0],h=y[1],v=y[2],E=y[3];p+=(h&v|~h&E)+w[0]-680876936|0,p=(p<<7|p>>>25)+h|0,E+=(p&h|~p&v)+w[1]-389564586|0,E=(E<<12|E>>>20)+p|0,v+=(E&p|~E&h)+w[2]+606105819|0,v=(v<<17|v>>>15)+E|0,h+=(v&E|~v&p)+w[3]-1044525330|0,h=(h<<22|h>>>10)+v|0,p+=(h&v|~h&E)+w[4]-176418897|0,p=(p<<7|p>>>25)+h|0,E+=(p&h|~p&v)+w[5]+1200080426|0,E=(E<<12|E>>>20)+p|0,v+=(E&p|~E&h)+w[6]-1473231341|0,v=(v<<17|v>>>15)+E|0,h+=(v&E|~v&p)+w[7]-45705983|0,h=(h<<22|h>>>10)+v|0,p+=(h&v|~h&E)+w[8]+1770035416|0,p=(p<<7|p>>>25)+h|0,E+=(p&h|~p&v)+w[9]-1958414417|0,E=(E<<12|E>>>20)+p|0,v+=(E&p|~E&h)+w[10]-42063|0,v=(v<<17|v>>>15)+E|0,h+=(v&E|~v&p)+w[11]-1990404162|0,h=(h<<22|h>>>10)+v|0,p+=(h&v|~h&E)+w[12]+1804603682|0,p=(p<<7|p>>>25)+h|0,E+=(p&h|~p&v)+w[13]-40341101|0,E=(E<<12|E>>>20)+p|0,v+=(E&p|~E&h)+w[14]-1502002290|0,v=(v<<17|v>>>15)+E|0,h+=(v&E|~v&p)+w[15]+1236535329|0,h=(h<<22|h>>>10)+v|0,p+=(h&E|v&~E)+w[1]-165796510|0,p=(p<<5|p>>>27)+h|0,E+=(p&v|h&~v)+w[6]-1069501632|0,E=(E<<9|E>>>23)+p|0,v+=(E&h|p&~h)+w[11]+643717713|0,v=(v<<14|v>>>18)+E|0,h+=(v&p|E&~p)+w[0]-373897302|0,h=(h<<20|h>>>12)+v|0,p+=(h&E|v&~E)+w[5]-701558691|0,p=(p<<5|p>>>27)+h|0,E+=(p&v|h&~v)+w[10]+38016083|0,E=(E<<9|E>>>23)+p|0,v+=(E&h|p&~h)+w[15]-660478335|0,v=(v<<14|v>>>18)+E|0,h+=(v&p|E&~p)+w[4]-405537848|0,h=(h<<20|h>>>12)+v|0,p+=(h&E|v&~E)+w[9]+568446438|0,p=(p<<5|p>>>27)+h|0,E+=(p&v|h&~v)+w[14]-1019803690|0,E=(E<<9|E>>>23)+p|0,v+=(E&h|p&~h)+w[3]-187363961|0,v=(v<<14|v>>>18)+E|0,h+=(v&p|E&~p)+w[8]+1163531501|0,h=(h<<20|h>>>12)+v|0,p+=(h&E|v&~E)+w[13]-1444681467|0,p=(p<<5|p>>>27)+h|0,E+=(p&v|h&~v)+w[2]-51403784|0,E=(E<<9|E>>>23)+p|0,v+=(E&h|p&~h)+w[7]+1735328473|0,v=(v<<14|v>>>18)+E|0,h+=(v&p|E&~p)+w[12]-1926607734|0,h=(h<<20|h>>>12)+v|0,p+=(h^v^E)+w[5]-378558|0,p=(p<<4|p>>>28)+h|0,E+=(p^h^v)+w[8]-2022574463|0,E=(E<<11|E>>>21)+p|0,v+=(E^p^h)+w[11]+1839030562|0,v=(v<<16|v>>>16)+E|0,h+=(v^E^p)+w[14]-35309556|0,h=(h<<23|h>>>9)+v|0,p+=(h^v^E)+w[1]-1530992060|0,p=(p<<4|p>>>28)+h|0,E+=(p^h^v)+w[4]+1272893353|0,E=(E<<11|E>>>21)+p|0,v+=(E^p^h)+w[7]-155497632|0,v=(v<<16|v>>>16)+E|0,h+=(v^E^p)+w[10]-1094730640|0,h=(h<<23|h>>>9)+v|0,p+=(h^v^E)+w[13]+681279174|0,p=(p<<4|p>>>28)+h|0,E+=(p^h^v)+w[0]-358537222|0,E=(E<<11|E>>>21)+p|0,v+=(E^p^h)+w[3]-722521979|0,v=(v<<16|v>>>16)+E|0,h+=(v^E^p)+w[6]+76029189|0,h=(h<<23|h>>>9)+v|0,p+=(h^v^E)+w[9]-640364487|0,p=(p<<4|p>>>28)+h|0,E+=(p^h^v)+w[12]-421815835|0,E=(E<<11|E>>>21)+p|0,v+=(E^p^h)+w[15]+530742520|0,v=(v<<16|v>>>16)+E|0,h+=(v^E^p)+w[2]-995338651|0,h=(h<<23|h>>>9)+v|0,p+=(v^(h|~E))+w[0]-198630844|0,p=(p<<6|p>>>26)+h|0,E+=(h^(p|~v))+w[7]+1126891415|0,E=(E<<10|E>>>22)+p|0,v+=(p^(E|~h))+w[14]-1416354905|0,v=(v<<15|v>>>17)+E|0,h+=(E^(v|~p))+w[5]-57434055|0,h=(h<<21|h>>>11)+v|0,p+=(v^(h|~E))+w[12]+1700485571|0,p=(p<<6|p>>>26)+h|0,E+=(h^(p|~v))+w[3]-1894986606|0,E=(E<<10|E>>>22)+p|0,v+=(p^(E|~h))+w[10]-1051523|0,v=(v<<15|v>>>17)+E|0,h+=(E^(v|~p))+w[1]-2054922799|0,h=(h<<21|h>>>11)+v|0,p+=(v^(h|~E))+w[8]+1873313359|0,p=(p<<6|p>>>26)+h|0,E+=(h^(p|~v))+w[15]-30611744|0,E=(E<<10|E>>>22)+p|0,v+=(p^(E|~h))+w[6]-1560198380|0,v=(v<<15|v>>>17)+E|0,h+=(E^(v|~p))+w[13]+1309151649|0,h=(h<<21|h>>>11)+v|0,p+=(v^(h|~E))+w[4]-145523070|0,p=(p<<6|p>>>26)+h|0,E+=(h^(p|~v))+w[11]-1120210379|0,E=(E<<10|E>>>22)+p|0,v+=(p^(E|~h))+w[2]+718787259|0,v=(v<<15|v>>>17)+E|0,h+=(E^(v|~p))+w[9]-343485551|0,h=(h<<21|h>>>11)+v|0,y[0]=p+y[0]|0,y[1]=h+y[1]|0,y[2]=v+y[2]|0,y[3]=E+y[3]|0}function s(y){var w=[],p;for(p=0;p<64;p+=4)w[p>>2]=y.charCodeAt(p)+(y.charCodeAt(p+1)<<8)+(y.charCodeAt(p+2)<<16)+(y.charCodeAt(p+3)<<24);return w}function o(y){var w=[],p;for(p=0;p<64;p+=4)w[p>>2]=y[p]+(y[p+1]<<8)+(y[p+2]<<16)+(y[p+3]<<24);return w}function a(y){var w=y.length,p=[1732584193,-271733879,-1732584194,271733878],h,v,E,k,x,N;for(h=64;h<=w;h+=64)i(p,s(y.substring(h-64,h)));for(y=y.substring(h-64),v=y.length,E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=0;h<v;h+=1)E[h>>2]|=y.charCodeAt(h)<<(h%4<<3);if(E[h>>2]|=128<<(h%4<<3),h>55)for(i(p,E),h=0;h<16;h+=1)E[h]=0;return k=w*8,k=k.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(k[2],16),N=parseInt(k[1],16)||0,E[14]=x,E[15]=N,i(p,E),p}function c(y){var w=y.length,p=[1732584193,-271733879,-1732584194,271733878],h,v,E,k,x,N;for(h=64;h<=w;h+=64)i(p,o(y.subarray(h-64,h)));for(y=h-64<w?y.subarray(h-64):new Uint8Array(0),v=y.length,E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=0;h<v;h+=1)E[h>>2]|=y[h]<<(h%4<<3);if(E[h>>2]|=128<<(h%4<<3),h>55)for(i(p,E),h=0;h<16;h+=1)E[h]=0;return k=w*8,k=k.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(k[2],16),N=parseInt(k[1],16)||0,E[14]=x,E[15]=N,i(p,E),p}function d(y){var w="",p;for(p=0;p<4;p+=1)w+=r[y>>p*8+4&15]+r[y>>p*8&15];return w}function m(y){var w;for(w=0;w<y.length;w+=1)y[w]=d(y[w]);return y.join("")}m(a("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(e=function(y,w){var p=(y&65535)+(w&65535),h=(y>>16)+(w>>16)+(p>>16);return h<<16|p&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function y(w,p){return w=w|0||0,w<0?Math.max(w+p,0):Math.min(w,p)}ArrayBuffer.prototype.slice=function(w,p){var h=this.byteLength,v=y(w,h),E=h,k,x,N,G;return p!==t&&(E=y(p,h)),v>E?new ArrayBuffer(0):(k=E-v,x=new ArrayBuffer(k),N=new Uint8Array(x),G=new Uint8Array(this,v,k),N.set(G),x)}}();function f(y){return/[\u0080-\uFFFF]/.test(y)&&(y=unescape(encodeURIComponent(y))),y}function g(y,w){var p=y.length,h=new ArrayBuffer(p),v=new Uint8Array(h),E;for(E=0;E<p;E+=1)v[E]=y.charCodeAt(E);return w?v:h}function _(y){return String.fromCharCode.apply(null,new Uint8Array(y))}function b(y,w,p){var h=new Uint8Array(y.byteLength+w.byteLength);return h.set(new Uint8Array(y)),h.set(new Uint8Array(w),y.byteLength),p?h:h.buffer}function P(y){var w=[],p=y.length,h;for(h=0;h<p-1;h+=2)w.push(parseInt(y.substr(h,2),16));return String.fromCharCode.apply(String,w)}function S(){this.reset()}return S.prototype.append=function(y){return this.appendBinary(f(y)),this},S.prototype.appendBinary=function(y){this._buff+=y,this._length+=y.length;var w=this._buff.length,p;for(p=64;p<=w;p+=64)i(this._hash,s(this._buff.substring(p-64,p)));return this._buff=this._buff.substring(p-64),this},S.prototype.end=function(y){var w=this._buff,p=w.length,h,v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],E;for(h=0;h<p;h+=1)v[h>>2]|=w.charCodeAt(h)<<(h%4<<3);return this._finish(v,p),E=m(this._hash),y&&(E=P(E)),this.reset(),E},S.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},S.prototype.setState=function(y){return this._buff=y.buff,this._length=y.length,this._hash=y.hash,this},S.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},S.prototype._finish=function(y,w){var p=w,h,v,E;if(y[p>>2]|=128<<(p%4<<3),p>55)for(i(this._hash,y),p=0;p<16;p+=1)y[p]=0;h=this._length*8,h=h.toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(h[2],16),E=parseInt(h[1],16)||0,y[14]=v,y[15]=E,i(this._hash,y)},S.hash=function(y,w){return S.hashBinary(f(y),w)},S.hashBinary=function(y,w){var p=a(y),h=m(p);return w?P(h):h},S.ArrayBuffer=function(){this.reset()},S.ArrayBuffer.prototype.append=function(y){var w=b(this._buff.buffer,y,!0),p=w.length,h;for(this._length+=y.byteLength,h=64;h<=p;h+=64)i(this._hash,o(w.subarray(h-64,h)));return this._buff=h-64<p?new Uint8Array(w.buffer.slice(h-64)):new Uint8Array(0),this},S.ArrayBuffer.prototype.end=function(y){var w=this._buff,p=w.length,h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],v,E;for(v=0;v<p;v+=1)h[v>>2]|=w[v]<<(v%4<<3);return this._finish(h,p),E=m(this._hash),y&&(E=P(E)),this.reset(),E},S.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.ArrayBuffer.prototype.getState=function(){var y=S.prototype.getState.call(this);return y.buff=_(y.buff),y},S.ArrayBuffer.prototype.setState=function(y){return y.buff=g(y.buff,!0),S.prototype.setState.call(this,y)},S.ArrayBuffer.prototype.destroy=S.prototype.destroy,S.ArrayBuffer.prototype._finish=S.prototype._finish,S.ArrayBuffer.hash=function(y,w){var p=c(new Uint8Array(y)),h=m(p);return w?P(h):h},S})});var Cd=Y(sa=>{"use strict";I();R();T();sa.stringify=function(e){var r=[];r.push({obj:e});for(var n="",i,s,o,a,c,d,m,f,g,_,b;i=r.pop();)if(s=i.obj,o=i.prefix||"",a=i.val||"",n+=o,a)n+=a;else if(typeof s!="object")n+=typeof s>"u"?null:JSON.stringify(s);else if(s===null)n+="null";else if(Array.isArray(s)){for(r.push({val:"]"}),c=s.length-1;c>=0;c--)d=c===0?"":",",r.push({obj:s[c],prefix:d});r.push({val:"["})}else{m=[];for(f in s)s.hasOwnProperty(f)&&m.push(f);for(r.push({val:"}"}),c=m.length-1;c>=0;c--)g=m[c],_=s[g],b=c>0?",":"",b+=JSON.stringify(g)+":",r.push({obj:_,prefix:b});r.push({val:"{"})}return n};function Gr(t,e,r){var n=r[r.length-1];t===n.element&&(r.pop(),n=r[r.length-1]);var i=n.element,s=n.index;if(Array.isArray(i))i.push(t);else if(s===e.length-2){var o=e.pop();i[o]=t}else e.push(t)}sa.parse=function(t){for(var e=[],r=[],n=0,i,s,o,a,c,d,m,f,g;;){if(i=t[n++],i==="}"||i==="]"||typeof i>"u"){if(e.length===1)return e.pop();Gr(e.pop(),e,r);continue}switch(i){case" ":case" ":case`
9
- `:case":":case",":break;case"n":n+=3,Gr(null,e,r);break;case"t":n+=3,Gr(!0,e,r);break;case"f":n+=4,Gr(!1,e,r);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"-":for(s="",n--;;)if(o=t[n++],/[\d\.\-e\+]/.test(o))s+=o;else{n--;break}Gr(parseFloat(s),e,r);break;case'"':for(a="",c=void 0,d=0;m=t[n++],m!=='"'||c==="\\"&&d%2===1;)a+=m,c=m,c==="\\"?d++:d=0;Gr(JSON.parse('"'+a+'"'),e,r);break;case"[":f={element:[],index:e.length},e.push(f.element),r.push(f);break;case"{":g={element:{},index:e.length},e.push(g.element),r.push(g);break;default:throw new Error("unexpectedly reached end of input: "+i)}}}});I();R();T();I();R();T();var Dc=class{objectToUri(t){return this.locationToUri(t)}};var rn=class Bc extends Error{constructor(e){super(e),this.name="GraffitiErrorForbidden",Object.setPrototypeOf(this,Bc.prototype)}},Wn=class Lc extends Error{constructor(e){super(e),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,Lc.prototype)}},Mc=class Uc extends Error{constructor(e){super(e),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,Uc.prototype)}},Gc=class Fc extends Error{constructor(e){super(e),this.name="GraffitiErrorSchemaMismatch",Object.setPrototypeOf(this,Fc.prototype)}},zc=class Kc extends Error{constructor(e){super(e),this.name="GraffitiErrorPatchTestFailed",Object.setPrototypeOf(this,Kc.prototype)}},Tr=class Vc extends Error{constructor(e){super(e),this.name="GraffitiErrorPatchError",Object.setPrototypeOf(this,Vc.prototype)}},Jc=class Hc extends Error{constructor(e){super(e),this.name="GraffitiErrorInvalidUri",Object.setPrototypeOf(this,Hc.prototype)}};var ep=en(Ri());I();R();T();var qi=class{sessionEvents=new EventTarget;constructor(){(async()=>{await Promise.resolve();for(let n of this.getLoggedInActors()){let i=new CustomEvent("login",{detail:{session:{actor:n}}});this.sessionEvents.dispatchEvent(i)}let r=new CustomEvent("initialized",{detail:{}});this.sessionEvents.dispatchEvent(r)})()}loggedInActors=[];getLoggedInActors(){if(typeof window<"u"){let e=window.localStorage.getItem("graffiti-actor");return e?e.split(",").map(decodeURIComponent):[]}else return this.loggedInActors}setLoggedInActors(e){typeof window<"u"?window.localStorage.setItem("graffiti-actor",e.map(encodeURIComponent).join(",")):this.loggedInActors=e}login=async e=>{let r=e?.actor;if(!r&&typeof window<"u"){let s=window.prompt(`This is an insecure implementation of the Graffiti API for *demo purposes only*. Do not store any sensitive information here.
8
+ deps: ${r}}`};var Ig={keyword:"dependencies",type:"object",schemaType:"object",error:At.error,code(t){let[e,r]=Tg(t);Ql(t,e),Yl(t,r)}};function Tg({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let i=Array.isArray(t[n])?e:r;i[n]=t[n]}return[e,r]}function Ql(t,e=t.schema){let{gen:r,data:n,it:i}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,Rn.propertyInData)(r,n,o,i.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(c,()=>{for(let d of a)(0,Rn.checkReportMissingProp)(t,d)}):(r.if((0,Lo._)`${c} && (${(0,Rn.checkMissingProp)(t,a,s)})`),(0,Rn.reportMissingProp)(t,s),r.else())}}At.validatePropertyDeps=Ql;function Yl(t,e=t.schema){let{gen:r,data:n,keyword:i,it:s}=t,o=r.name("valid");for(let a in e)(0,Ag.alwaysValidSchema)(s,e[a])||(r.if((0,Rn.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:i,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>r.var(o,!0)),t.ok(o))}At.validateSchemaDeps=Yl;At.default=Ig});var ed=Y(Mo=>{"use strict";I();R();T();Object.defineProperty(Mo,"__esModule",{value:!0});var Zl=pe(),Rg=be(),qg={message:"property name must be valid",params:({params:t})=>(0,Zl._)`{propertyName: ${t.propertyName}}`},kg={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:qg,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,Rg.alwaysValidSchema)(i,r))return;let s=e.name("valid");e.forIn("key",n,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,Zl.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};Mo.default=kg});var Go=Y(Uo=>{"use strict";I();R();T();Object.defineProperty(Uo,"__esModule",{value:!0});var Ei=lt(),wt=pe(),Cg=Bt(),$i=be(),xg={message:"must NOT have additional properties",params:({params:t})=>(0,wt._)`{additionalProperty: ${t.additionalProperty}}`},Ng={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:xg,code(t){let{gen:e,schema:r,parentSchema:n,data:i,errsCount:s,it:o}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,$i.alwaysValidSchema)(o,r))return;let d=(0,Ei.allSchemaProperties)(n.properties),m=(0,Ei.allSchemaProperties)(n.patternProperties);f(),t.ok((0,wt._)`${s} === ${Cg.default.errors}`);function f(){e.forIn("key",i,S=>{!d.length&&!m.length?b(S):e.if(y(S),()=>b(S))})}function y(S){let g;if(d.length>8){let w=(0,$i.schemaRefOrVal)(o,n.properties,"properties");g=(0,Ei.isOwnProperty)(e,w,S)}else d.length?g=(0,wt.or)(...d.map(w=>(0,wt._)`${S} === ${w}`)):g=wt.nil;return m.length&&(g=(0,wt.or)(g,...m.map(w=>(0,wt._)`${(0,Ei.usePattern)(t,w)}.test(${S})`))),(0,wt.not)(g)}function _(S){e.code((0,wt._)`delete ${i}[${S}]`)}function b(S){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){_(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,$i.alwaysValidSchema)(o,r)){let g=e.name("valid");c.removeAdditional==="failing"?(P(S,g,!1),e.if((0,wt.not)(g),()=>{t.reset(),_(S)})):(P(S,g),a||e.if((0,wt.not)(g),()=>e.break()))}}function P(S,g,w){let p={keyword:"additionalProperties",dataProp:S,dataPropType:$i.Type.Str};w===!1&&Object.assign(p,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(p,g)}}};Uo.default=Ng});var nd=Y(zo=>{"use strict";I();R();T();Object.defineProperty(zo,"__esModule",{value:!0});var jg=ui(),td=lt(),Fo=be(),rd=Go(),Dg={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&rd.default.code(new jg.KeywordCxt(s,rd.default,"additionalProperties"));let o=(0,td.allSchemaProperties)(r);for(let f of o)s.definedProperties.add(f);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=Fo.mergeEvaluated.props(e,(0,Fo.toHash)(o),s.props));let a=o.filter(f=>!(0,Fo.alwaysValidSchema)(s,r[f]));if(a.length===0)return;let c=e.name("valid");for(let f of a)d(f)?m(f):(e.if((0,td.propertyInData)(e,i,f,s.opts.ownProperties)),m(f),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(f),t.ok(c);function d(f){return s.opts.useDefaults&&!s.compositeRule&&r[f].default!==void 0}function m(f){t.subschema({keyword:"properties",schemaProp:f,dataProp:f},c)}}};zo.default=Dg});var ad=Y(Ko=>{"use strict";I();R();T();Object.defineProperty(Ko,"__esModule",{value:!0});var id=lt(),Si=pe(),sd=be(),od=be(),Bg={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:i,it:s}=t,{opts:o}=s,a=(0,id.allSchemaProperties)(r),c=a.filter(P=>(0,sd.alwaysValidSchema)(s,r[P]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let d=o.strictSchema&&!o.allowMatchingProperties&&i.properties,m=e.name("valid");s.props!==!0&&!(s.props instanceof Si.Name)&&(s.props=(0,od.evaluatedPropsToName)(e,s.props));let{props:f}=s;y();function y(){for(let P of a)d&&_(P),s.allErrors?b(P):(e.var(m,!0),b(P),e.if(m))}function _(P){for(let S in d)new RegExp(P).test(S)&&(0,sd.checkStrictMode)(s,`property ${S} matches pattern ${P} (use allowMatchingProperties)`)}function b(P){e.forIn("key",n,S=>{e.if((0,Si._)`${(0,id.usePattern)(t,P)}.test(${S})`,()=>{let g=c.includes(P);g||t.subschema({keyword:"patternProperties",schemaProp:P,dataProp:S,dataPropType:od.Type.Str},m),s.opts.unevaluated&&f!==!0?e.assign((0,Si._)`${f}[${S}]`,!0):!g&&!s.allErrors&&e.if((0,Si.not)(m),()=>e.break())})})}}};Ko.default=Bg});var ud=Y(Vo=>{"use strict";I();R();T();Object.defineProperty(Vo,"__esModule",{value:!0});var Lg=be(),Mg={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,Lg.alwaysValidSchema)(n,r)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Vo.default=Mg});var cd=Y(Jo=>{"use strict";I();R();T();Object.defineProperty(Jo,"__esModule",{value:!0});var Ug=lt(),Gg={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Ug.validateUnion,error:{message:"must match a schema in anyOf"}};Jo.default=Gg});var fd=Y(Ho=>{"use strict";I();R();T();Object.defineProperty(Ho,"__esModule",{value:!0});var Pi=pe(),Fg=be(),zg={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Pi._)`{passingSchemas: ${t.passing}}`},Kg={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:zg,code(t){let{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let s=r,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(d),t.result(o,()=>t.reset(),()=>t.error(!0));function d(){s.forEach((m,f)=>{let y;(0,Fg.alwaysValidSchema)(i,m)?e.var(c,!0):y=t.subschema({keyword:"oneOf",schemaProp:f,compositeRule:!0},c),f>0&&e.if((0,Pi._)`${c} && ${o}`).assign(o,!1).assign(a,(0,Pi._)`[${a}, ${f}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,f),y&&t.mergeEvaluated(y,Pi.Name)})})}}};Ho.default=Kg});var ld=Y(Wo=>{"use strict";I();R();T();Object.defineProperty(Wo,"__esModule",{value:!0});var Vg=be(),Jg={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=e.name("valid");r.forEach((s,o)=>{if((0,Vg.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};Wo.default=Jg});var pd=Y(Qo=>{"use strict";I();R();T();Object.defineProperty(Qo,"__esModule",{value:!0});var Oi=pe(),hd=be(),Hg={message:({params:t})=>(0,Oi.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Oi._)`{failingKeyword: ${t.ifClause}}`},Wg={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Hg,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,hd.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=dd(n,"then"),s=dd(n,"else");if(!i&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),i&&s){let m=e.let("ifClause");t.setParams({ifClause:m}),e.if(a,d("then",m),d("else",m))}else i?e.if(a,d("then")):e.if((0,Oi.not)(a),d("else"));t.pass(o,()=>t.error(!0));function c(){let m=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(m)}function d(m,f){return()=>{let y=t.subschema({keyword:m},a);e.assign(o,a),t.mergeValidEvaluated(y,o),f?e.assign(f,(0,Oi._)`${m}`):t.setParams({ifClause:m})}}}};function dd(t,e){let r=t.schema[e];return r!==void 0&&!(0,hd.alwaysValidSchema)(t,r)}Qo.default=Wg});var md=Y(Yo=>{"use strict";I();R();T();Object.defineProperty(Yo,"__esModule",{value:!0});var Qg=be(),Yg={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,Qg.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Yo.default=Yg});var vd=Y(Xo=>{"use strict";I();R();T();Object.defineProperty(Xo,"__esModule",{value:!0});var Xg=xo(),Zg=Vl(),e_=No(),t_=Hl(),r_=Wl(),n_=Xl(),i_=ed(),s_=Go(),o_=nd(),a_=ad(),u_=ud(),c_=cd(),f_=fd(),l_=ld(),d_=pd(),h_=md();function p_(t=!1){let e=[u_.default,c_.default,f_.default,l_.default,d_.default,h_.default,i_.default,s_.default,n_.default,o_.default,a_.default];return t?e.push(Zg.default,t_.default):e.push(Xg.default,e_.default),e.push(r_.default),e}Xo.default=p_});var yd=Y(Zo=>{"use strict";I();R();T();Object.defineProperty(Zo,"__esModule",{value:!0});var je=pe(),m_={message:({schemaCode:t})=>(0,je.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,je._)`{format: ${t}}`},v_={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:m_,code(t,e){let{gen:r,data:n,$data:i,schema:s,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:d,schemaEnv:m,self:f}=a;if(!c.validateFormats)return;i?y():_();function y(){let b=r.scopeValue("formats",{ref:f.formats,code:c.code.formats}),P=r.const("fDef",(0,je._)`${b}[${o}]`),S=r.let("fType"),g=r.let("format");r.if((0,je._)`typeof ${P} == "object" && !(${P} instanceof RegExp)`,()=>r.assign(S,(0,je._)`${P}.type || "string"`).assign(g,(0,je._)`${P}.validate`),()=>r.assign(S,(0,je._)`"string"`).assign(g,P)),t.fail$data((0,je.or)(w(),p()));function w(){return c.strictSchema===!1?je.nil:(0,je._)`${o} && !${g}`}function p(){let h=m.$async?(0,je._)`(${P}.async ? await ${g}(${n}) : ${g}(${n}))`:(0,je._)`${g}(${n})`,v=(0,je._)`(typeof ${g} == "function" ? ${h} : ${g}.test(${n}))`;return(0,je._)`${g} && ${g} !== true && ${S} === ${e} && !${v}`}}function _(){let b=f.formats[s];if(!b){w();return}if(b===!0)return;let[P,S,g]=p(b);P===e&&t.pass(h());function w(){if(c.strictSchema===!1){f.logger.warn(v());return}throw new Error(v());function v(){return`unknown format "${s}" ignored in schema at path "${d}"`}}function p(v){let E=v instanceof RegExp?(0,je.regexpCode)(v):c.code.formats?(0,je._)`${c.code.formats}${(0,je.getProperty)(s)}`:void 0,k=r.scopeValue("formats",{key:s,ref:v,code:E});return typeof v=="object"&&!(v instanceof RegExp)?[v.type||"string",v.validate,(0,je._)`${k}.validate`]:["string",v,k]}function h(){if(typeof b=="object"&&!(b instanceof RegExp)&&b.async){if(!m.$async)throw new Error("async format in sync schema");return(0,je._)`await ${g}(${n})`}return typeof S=="function"?(0,je._)`${g}(${n})`:(0,je._)`${g}.test(${n})`}}}};Zo.default=v_});var gd=Y(ea=>{"use strict";I();R();T();Object.defineProperty(ea,"__esModule",{value:!0});var y_=yd(),g_=[y_.default];ea.default=g_});var _d=Y(ta=>{"use strict";I();R();T();Object.defineProperty(ta,"__esModule",{value:!0});var __=Ol(),w_=Gl(),b_=vd(),E_=gd(),$_=["title","description","default"],S_=[__.default,w_.default,b_.default(),E_.default,$_];ta.default=S_});var bd=Y(Ai=>{"use strict";I();R();T();Object.defineProperty(Ai,"__esModule",{value:!0});Ai.DiscrError=void 0;var wd;(function(t){t.Tag="tag",t.Mapping="mapping"})(wd||(Ai.DiscrError=wd={}))});var $d=Y(na=>{"use strict";I();R();T();Object.defineProperty(na,"__esModule",{value:!0});var Mr=pe(),ra=bd(),Ed=li(),P_=ci(),O_=be(),A_={message:({params:{discrError:t,tagName:e}})=>t===ra.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Mr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},I_={keyword:"discriminator",type:"object",schemaType:"object",error:A_,code(t){let{gen:e,data:r,schema:n,parentSchema:i,it:s}=t,{oneOf:o}=i;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),d=e.const("tag",(0,Mr._)`${r}${(0,Mr.getProperty)(a)}`);e.if((0,Mr._)`typeof ${d} == "string"`,()=>m(),()=>t.error(!1,{discrError:ra.DiscrError.Tag,tag:d,tagName:a})),t.ok(c);function m(){let _=y();e.if(!1);for(let b in _)e.elseIf((0,Mr._)`${d} === ${b}`),e.assign(c,f(_[b]));e.else(),t.error(!1,{discrError:ra.DiscrError.Mapping,tag:d,tagName:a}),e.endIf()}function f(_){let b=e.name("valid"),P=t.subschema({keyword:"oneOf",schemaProp:_},b);return t.mergeEvaluated(P,Mr.Name),b}function y(){var _;let b={},P=g(i),S=!0;for(let h=0;h<o.length;h++){let v=o[h];if(v?.$ref&&!(0,O_.schemaHasRulesButRef)(v,s.self.RULES)){let k=v.$ref;if(v=Ed.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,k),v instanceof Ed.SchemaEnv&&(v=v.schema),v===void 0)throw new P_.default(s.opts.uriResolver,s.baseId,k)}let E=(_=v?.properties)===null||_===void 0?void 0:_[a];if(typeof E!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);S=S&&(P||g(v)),w(E,h)}if(!S)throw new Error(`discriminator: "${a}" must be required`);return b;function g({required:h}){return Array.isArray(h)&&h.includes(a)}function w(h,v){if(h.const)p(h.const,v);else if(h.enum)for(let E of h.enum)p(E,v);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function p(h,v){if(typeof h!="string"||h in b)throw new Error(`discriminator: "${a}" values must be unique strings`);b[h]=v}}}};na.default=I_});var Sd=Y((lO,T_)=>{T_.exports={id:"http://json-schema.org/draft-04/schema#",$schema:"http://json-schema.org/draft-04/schema#",description:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},positiveInteger:{type:"integer",minimum:0},positiveIntegerDefault0:{allOf:[{$ref:"#/definitions/positiveInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},minItems:1,uniqueItems:!0}},type:"object",properties:{id:{type:"string",format:"uri"},$schema:{type:"string",format:"uri"},title:{type:"string"},description:{type:"string"},default:{},multipleOf:{type:"number",minimum:0,exclusiveMinimum:!0},maximum:{type:"number"},exclusiveMaximum:{type:"boolean",default:!1},minimum:{type:"number"},exclusiveMinimum:{type:"boolean",default:!1},maxLength:{$ref:"#/definitions/positiveInteger"},minLength:{$ref:"#/definitions/positiveIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:{}},maxItems:{$ref:"#/definitions/positiveInteger"},minItems:{$ref:"#/definitions/positiveIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxProperties:{$ref:"#/definitions/positiveInteger"},minProperties:{$ref:"#/definitions/positiveIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{anyOf:[{type:"boolean"},{$ref:"#"}],default:{}},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},enum:{type:"array",minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},dependencies:{exclusiveMaximum:["maximum"],exclusiveMinimum:["minimum"]},default:{}}});var Ri=Y((Me,Od)=>{"use strict";I();R();T();Object.defineProperty(Me,"__esModule",{value:!0});Me.CodeGen=Me.Name=Me.nil=Me.stringify=Me.str=Me._=Me.KeywordCxt=void 0;var R_=bn(),q_=_d(),k_=$d(),Pd=Sd(),C_=["/properties"],Ii="http://json-schema.org/draft-04/schema",Ti=class extends R_.default{constructor(e={}){super({...e,schemaId:"id"})}_addVocabularies(){super._addVocabularies(),q_.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(k_.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Pd,C_):Pd;this.addMetaSchema(e,Ii,!1),this.refs["http://json-schema.org/schema"]=Ii}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ii)?Ii:void 0)}};Od.exports=Me=Ti;Object.defineProperty(Me,"__esModule",{value:!0});Me.default=Ti;var x_=bn();Object.defineProperty(Me,"KeywordCxt",{enumerable:!0,get:function(){return x_.KeywordCxt}});var Ur=bn();Object.defineProperty(Me,"_",{enumerable:!0,get:function(){return Ur._}});Object.defineProperty(Me,"str",{enumerable:!0,get:function(){return Ur.str}});Object.defineProperty(Me,"stringify",{enumerable:!0,get:function(){return Ur.stringify}});Object.defineProperty(Me,"nil",{enumerable:!0,get:function(){return Ur.nil}});Object.defineProperty(Me,"Name",{enumerable:!0,get:function(){return Ur.Name}});Object.defineProperty(Me,"CodeGen",{enumerable:!0,get:function(){return Ur.CodeGen}})});var Td=Y((Ad,Id)=>{I();R();T();(function(t){if(typeof Ad=="object")Id.exports=t();else if(typeof define=="function"&&define.amd)define(t);else{var e;try{e=window}catch{e=self}e.SparkMD5=t()}})(function(t){"use strict";var e=function(g,w){return g+w&4294967295},r=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(g,w,p,h,v,E){return w=e(e(w,g),e(h,E)),e(w<<v|w>>>32-v,p)}function i(g,w){var p=g[0],h=g[1],v=g[2],E=g[3];p+=(h&v|~h&E)+w[0]-680876936|0,p=(p<<7|p>>>25)+h|0,E+=(p&h|~p&v)+w[1]-389564586|0,E=(E<<12|E>>>20)+p|0,v+=(E&p|~E&h)+w[2]+606105819|0,v=(v<<17|v>>>15)+E|0,h+=(v&E|~v&p)+w[3]-1044525330|0,h=(h<<22|h>>>10)+v|0,p+=(h&v|~h&E)+w[4]-176418897|0,p=(p<<7|p>>>25)+h|0,E+=(p&h|~p&v)+w[5]+1200080426|0,E=(E<<12|E>>>20)+p|0,v+=(E&p|~E&h)+w[6]-1473231341|0,v=(v<<17|v>>>15)+E|0,h+=(v&E|~v&p)+w[7]-45705983|0,h=(h<<22|h>>>10)+v|0,p+=(h&v|~h&E)+w[8]+1770035416|0,p=(p<<7|p>>>25)+h|0,E+=(p&h|~p&v)+w[9]-1958414417|0,E=(E<<12|E>>>20)+p|0,v+=(E&p|~E&h)+w[10]-42063|0,v=(v<<17|v>>>15)+E|0,h+=(v&E|~v&p)+w[11]-1990404162|0,h=(h<<22|h>>>10)+v|0,p+=(h&v|~h&E)+w[12]+1804603682|0,p=(p<<7|p>>>25)+h|0,E+=(p&h|~p&v)+w[13]-40341101|0,E=(E<<12|E>>>20)+p|0,v+=(E&p|~E&h)+w[14]-1502002290|0,v=(v<<17|v>>>15)+E|0,h+=(v&E|~v&p)+w[15]+1236535329|0,h=(h<<22|h>>>10)+v|0,p+=(h&E|v&~E)+w[1]-165796510|0,p=(p<<5|p>>>27)+h|0,E+=(p&v|h&~v)+w[6]-1069501632|0,E=(E<<9|E>>>23)+p|0,v+=(E&h|p&~h)+w[11]+643717713|0,v=(v<<14|v>>>18)+E|0,h+=(v&p|E&~p)+w[0]-373897302|0,h=(h<<20|h>>>12)+v|0,p+=(h&E|v&~E)+w[5]-701558691|0,p=(p<<5|p>>>27)+h|0,E+=(p&v|h&~v)+w[10]+38016083|0,E=(E<<9|E>>>23)+p|0,v+=(E&h|p&~h)+w[15]-660478335|0,v=(v<<14|v>>>18)+E|0,h+=(v&p|E&~p)+w[4]-405537848|0,h=(h<<20|h>>>12)+v|0,p+=(h&E|v&~E)+w[9]+568446438|0,p=(p<<5|p>>>27)+h|0,E+=(p&v|h&~v)+w[14]-1019803690|0,E=(E<<9|E>>>23)+p|0,v+=(E&h|p&~h)+w[3]-187363961|0,v=(v<<14|v>>>18)+E|0,h+=(v&p|E&~p)+w[8]+1163531501|0,h=(h<<20|h>>>12)+v|0,p+=(h&E|v&~E)+w[13]-1444681467|0,p=(p<<5|p>>>27)+h|0,E+=(p&v|h&~v)+w[2]-51403784|0,E=(E<<9|E>>>23)+p|0,v+=(E&h|p&~h)+w[7]+1735328473|0,v=(v<<14|v>>>18)+E|0,h+=(v&p|E&~p)+w[12]-1926607734|0,h=(h<<20|h>>>12)+v|0,p+=(h^v^E)+w[5]-378558|0,p=(p<<4|p>>>28)+h|0,E+=(p^h^v)+w[8]-2022574463|0,E=(E<<11|E>>>21)+p|0,v+=(E^p^h)+w[11]+1839030562|0,v=(v<<16|v>>>16)+E|0,h+=(v^E^p)+w[14]-35309556|0,h=(h<<23|h>>>9)+v|0,p+=(h^v^E)+w[1]-1530992060|0,p=(p<<4|p>>>28)+h|0,E+=(p^h^v)+w[4]+1272893353|0,E=(E<<11|E>>>21)+p|0,v+=(E^p^h)+w[7]-155497632|0,v=(v<<16|v>>>16)+E|0,h+=(v^E^p)+w[10]-1094730640|0,h=(h<<23|h>>>9)+v|0,p+=(h^v^E)+w[13]+681279174|0,p=(p<<4|p>>>28)+h|0,E+=(p^h^v)+w[0]-358537222|0,E=(E<<11|E>>>21)+p|0,v+=(E^p^h)+w[3]-722521979|0,v=(v<<16|v>>>16)+E|0,h+=(v^E^p)+w[6]+76029189|0,h=(h<<23|h>>>9)+v|0,p+=(h^v^E)+w[9]-640364487|0,p=(p<<4|p>>>28)+h|0,E+=(p^h^v)+w[12]-421815835|0,E=(E<<11|E>>>21)+p|0,v+=(E^p^h)+w[15]+530742520|0,v=(v<<16|v>>>16)+E|0,h+=(v^E^p)+w[2]-995338651|0,h=(h<<23|h>>>9)+v|0,p+=(v^(h|~E))+w[0]-198630844|0,p=(p<<6|p>>>26)+h|0,E+=(h^(p|~v))+w[7]+1126891415|0,E=(E<<10|E>>>22)+p|0,v+=(p^(E|~h))+w[14]-1416354905|0,v=(v<<15|v>>>17)+E|0,h+=(E^(v|~p))+w[5]-57434055|0,h=(h<<21|h>>>11)+v|0,p+=(v^(h|~E))+w[12]+1700485571|0,p=(p<<6|p>>>26)+h|0,E+=(h^(p|~v))+w[3]-1894986606|0,E=(E<<10|E>>>22)+p|0,v+=(p^(E|~h))+w[10]-1051523|0,v=(v<<15|v>>>17)+E|0,h+=(E^(v|~p))+w[1]-2054922799|0,h=(h<<21|h>>>11)+v|0,p+=(v^(h|~E))+w[8]+1873313359|0,p=(p<<6|p>>>26)+h|0,E+=(h^(p|~v))+w[15]-30611744|0,E=(E<<10|E>>>22)+p|0,v+=(p^(E|~h))+w[6]-1560198380|0,v=(v<<15|v>>>17)+E|0,h+=(E^(v|~p))+w[13]+1309151649|0,h=(h<<21|h>>>11)+v|0,p+=(v^(h|~E))+w[4]-145523070|0,p=(p<<6|p>>>26)+h|0,E+=(h^(p|~v))+w[11]-1120210379|0,E=(E<<10|E>>>22)+p|0,v+=(p^(E|~h))+w[2]+718787259|0,v=(v<<15|v>>>17)+E|0,h+=(E^(v|~p))+w[9]-343485551|0,h=(h<<21|h>>>11)+v|0,g[0]=p+g[0]|0,g[1]=h+g[1]|0,g[2]=v+g[2]|0,g[3]=E+g[3]|0}function s(g){var w=[],p;for(p=0;p<64;p+=4)w[p>>2]=g.charCodeAt(p)+(g.charCodeAt(p+1)<<8)+(g.charCodeAt(p+2)<<16)+(g.charCodeAt(p+3)<<24);return w}function o(g){var w=[],p;for(p=0;p<64;p+=4)w[p>>2]=g[p]+(g[p+1]<<8)+(g[p+2]<<16)+(g[p+3]<<24);return w}function a(g){var w=g.length,p=[1732584193,-271733879,-1732584194,271733878],h,v,E,k,x,j;for(h=64;h<=w;h+=64)i(p,s(g.substring(h-64,h)));for(g=g.substring(h-64),v=g.length,E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=0;h<v;h+=1)E[h>>2]|=g.charCodeAt(h)<<(h%4<<3);if(E[h>>2]|=128<<(h%4<<3),h>55)for(i(p,E),h=0;h<16;h+=1)E[h]=0;return k=w*8,k=k.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(k[2],16),j=parseInt(k[1],16)||0,E[14]=x,E[15]=j,i(p,E),p}function c(g){var w=g.length,p=[1732584193,-271733879,-1732584194,271733878],h,v,E,k,x,j;for(h=64;h<=w;h+=64)i(p,o(g.subarray(h-64,h)));for(g=h-64<w?g.subarray(h-64):new Uint8Array(0),v=g.length,E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=0;h<v;h+=1)E[h>>2]|=g[h]<<(h%4<<3);if(E[h>>2]|=128<<(h%4<<3),h>55)for(i(p,E),h=0;h<16;h+=1)E[h]=0;return k=w*8,k=k.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(k[2],16),j=parseInt(k[1],16)||0,E[14]=x,E[15]=j,i(p,E),p}function d(g){var w="",p;for(p=0;p<4;p+=1)w+=r[g>>p*8+4&15]+r[g>>p*8&15];return w}function m(g){var w;for(w=0;w<g.length;w+=1)g[w]=d(g[w]);return g.join("")}m(a("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(e=function(g,w){var p=(g&65535)+(w&65535),h=(g>>16)+(w>>16)+(p>>16);return h<<16|p&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function g(w,p){return w=w|0||0,w<0?Math.max(w+p,0):Math.min(w,p)}ArrayBuffer.prototype.slice=function(w,p){var h=this.byteLength,v=g(w,h),E=h,k,x,j,G;return p!==t&&(E=g(p,h)),v>E?new ArrayBuffer(0):(k=E-v,x=new ArrayBuffer(k),j=new Uint8Array(x),G=new Uint8Array(this,v,k),j.set(G),x)}}();function f(g){return/[\u0080-\uFFFF]/.test(g)&&(g=unescape(encodeURIComponent(g))),g}function y(g,w){var p=g.length,h=new ArrayBuffer(p),v=new Uint8Array(h),E;for(E=0;E<p;E+=1)v[E]=g.charCodeAt(E);return w?v:h}function _(g){return String.fromCharCode.apply(null,new Uint8Array(g))}function b(g,w,p){var h=new Uint8Array(g.byteLength+w.byteLength);return h.set(new Uint8Array(g)),h.set(new Uint8Array(w),g.byteLength),p?h:h.buffer}function P(g){var w=[],p=g.length,h;for(h=0;h<p-1;h+=2)w.push(parseInt(g.substr(h,2),16));return String.fromCharCode.apply(String,w)}function S(){this.reset()}return S.prototype.append=function(g){return this.appendBinary(f(g)),this},S.prototype.appendBinary=function(g){this._buff+=g,this._length+=g.length;var w=this._buff.length,p;for(p=64;p<=w;p+=64)i(this._hash,s(this._buff.substring(p-64,p)));return this._buff=this._buff.substring(p-64),this},S.prototype.end=function(g){var w=this._buff,p=w.length,h,v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],E;for(h=0;h<p;h+=1)v[h>>2]|=w.charCodeAt(h)<<(h%4<<3);return this._finish(v,p),E=m(this._hash),g&&(E=P(E)),this.reset(),E},S.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},S.prototype.setState=function(g){return this._buff=g.buff,this._length=g.length,this._hash=g.hash,this},S.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},S.prototype._finish=function(g,w){var p=w,h,v,E;if(g[p>>2]|=128<<(p%4<<3),p>55)for(i(this._hash,g),p=0;p<16;p+=1)g[p]=0;h=this._length*8,h=h.toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(h[2],16),E=parseInt(h[1],16)||0,g[14]=v,g[15]=E,i(this._hash,g)},S.hash=function(g,w){return S.hashBinary(f(g),w)},S.hashBinary=function(g,w){var p=a(g),h=m(p);return w?P(h):h},S.ArrayBuffer=function(){this.reset()},S.ArrayBuffer.prototype.append=function(g){var w=b(this._buff.buffer,g,!0),p=w.length,h;for(this._length+=g.byteLength,h=64;h<=p;h+=64)i(this._hash,o(w.subarray(h-64,h)));return this._buff=h-64<p?new Uint8Array(w.buffer.slice(h-64)):new Uint8Array(0),this},S.ArrayBuffer.prototype.end=function(g){var w=this._buff,p=w.length,h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],v,E;for(v=0;v<p;v+=1)h[v>>2]|=w[v]<<(v%4<<3);return this._finish(h,p),E=m(this._hash),g&&(E=P(E)),this.reset(),E},S.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.ArrayBuffer.prototype.getState=function(){var g=S.prototype.getState.call(this);return g.buff=_(g.buff),g},S.ArrayBuffer.prototype.setState=function(g){return g.buff=y(g.buff,!0),S.prototype.setState.call(this,g)},S.ArrayBuffer.prototype.destroy=S.prototype.destroy,S.ArrayBuffer.prototype._finish=S.prototype._finish,S.ArrayBuffer.hash=function(g,w){var p=c(new Uint8Array(g)),h=m(p);return w?P(h):h},S})});var Cd=Y(sa=>{"use strict";I();R();T();sa.stringify=function(e){var r=[];r.push({obj:e});for(var n="",i,s,o,a,c,d,m,f,y,_,b;i=r.pop();)if(s=i.obj,o=i.prefix||"",a=i.val||"",n+=o,a)n+=a;else if(typeof s!="object")n+=typeof s>"u"?null:JSON.stringify(s);else if(s===null)n+="null";else if(Array.isArray(s)){for(r.push({val:"]"}),c=s.length-1;c>=0;c--)d=c===0?"":",",r.push({obj:s[c],prefix:d});r.push({val:"["})}else{m=[];for(f in s)s.hasOwnProperty(f)&&m.push(f);for(r.push({val:"}"}),c=m.length-1;c>=0;c--)y=m[c],_=s[y],b=c>0?",":"",b+=JSON.stringify(y)+":",r.push({obj:_,prefix:b});r.push({val:"{"})}return n};function Gr(t,e,r){var n=r[r.length-1];t===n.element&&(r.pop(),n=r[r.length-1]);var i=n.element,s=n.index;if(Array.isArray(i))i.push(t);else if(s===e.length-2){var o=e.pop();i[o]=t}else e.push(t)}sa.parse=function(t){for(var e=[],r=[],n=0,i,s,o,a,c,d,m,f,y;;){if(i=t[n++],i==="}"||i==="]"||typeof i>"u"){if(e.length===1)return e.pop();Gr(e.pop(),e,r);continue}switch(i){case" ":case" ":case`
9
+ `:case":":case",":break;case"n":n+=3,Gr(null,e,r);break;case"t":n+=3,Gr(!0,e,r);break;case"f":n+=4,Gr(!1,e,r);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":case"-":for(s="",n--;;)if(o=t[n++],/[\d\.\-e\+]/.test(o))s+=o;else{n--;break}Gr(parseFloat(s),e,r);break;case'"':for(a="",c=void 0,d=0;m=t[n++],m!=='"'||c==="\\"&&d%2===1;)a+=m,c=m,c==="\\"?d++:d=0;Gr(JSON.parse('"'+a+'"'),e,r);break;case"[":f={element:[],index:e.length},e.push(f.element),r.push(f);break;case"{":y={element:{},index:e.length},e.push(y.element),r.push(y);break;default:throw new Error("unexpectedly reached end of input: "+i)}}}});I();R();T();I();R();T();var Dc=class{objectToUri(t){return this.locationToUri(t)}};var rn=class Bc extends Error{constructor(e){super(e),this.name="GraffitiErrorForbidden",Object.setPrototypeOf(this,Bc.prototype)}},Wn=class Lc extends Error{constructor(e){super(e),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,Lc.prototype)}},Mc=class Uc extends Error{constructor(e){super(e),this.name="GraffitiErrorInvalidSchema",Object.setPrototypeOf(this,Uc.prototype)}},Gc=class Fc extends Error{constructor(e){super(e),this.name="GraffitiErrorSchemaMismatch",Object.setPrototypeOf(this,Fc.prototype)}},zc=class Kc extends Error{constructor(e){super(e),this.name="GraffitiErrorPatchTestFailed",Object.setPrototypeOf(this,Kc.prototype)}},Tr=class Vc extends Error{constructor(e){super(e),this.name="GraffitiErrorPatchError",Object.setPrototypeOf(this,Vc.prototype)}},Jc=class Hc extends Error{constructor(e){super(e),this.name="GraffitiErrorInvalidUri",Object.setPrototypeOf(this,Hc.prototype)}};var ep=en(Ri());I();R();T();var qi=class{sessionEvents=new EventTarget;constructor(){(async()=>{await Promise.resolve();for(let n of this.getLoggedInActors()){let i=new CustomEvent("login",{detail:{session:{actor:n}}});this.sessionEvents.dispatchEvent(i)}let r=new CustomEvent("initialized",{detail:{}});this.sessionEvents.dispatchEvent(r)})()}loggedInActors=[];getLoggedInActors(){if(typeof window<"u"){let e=window.localStorage.getItem("graffiti-actor");return e?e.split(",").map(decodeURIComponent):[]}else return this.loggedInActors}setLoggedInActors(e){typeof window<"u"?window.localStorage.setItem("graffiti-actor",e.map(encodeURIComponent).join(",")):this.loggedInActors=e}login=async e=>{let r=e?.actor;if(!r&&typeof window<"u"){let s=window.prompt(`This is an insecure implementation of the Graffiti API for *demo purposes only*. Do not store any sensitive information here.
10
10
 
11
- Simply choose a username to log in.`);s&&(r=s)}let n;if(!r)n={error:new Error("No actor ID provided to login")};else{let s=this.getLoggedInActors();s.includes(r)||this.setLoggedInActors([...s,r]),n={session:{actor:r}}}let i=new CustomEvent("login",{detail:n});this.sessionEvents.dispatchEvent(i)};logout=async e=>{let r=this.getLoggedInActors(),n=r.includes(e.actor);n&&this.setLoggedInActors(r.filter(o=>o!==e.actor));let i=n?{actor:e.actor}:{actor:e.actor,error:new Error("Not logged in with that actor")},s=new CustomEvent("logout",{detail:i});this.sessionEvents.dispatchEvent(s)}};I();R();T();I();R();T();var Li=en(Td());I();R();T();I();R();T();var ki,j_=new Uint8Array(16);function ia(){if(!ki&&(ki=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ki))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ki(j_)}I();R();T();I();R();T();I();R();T();var Rd=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function N_(t){return typeof t=="string"&&Rd.test(t)}var qd=N_;var Ve=[];for(Ci=0;Ci<256;++Ci)Ve.push((Ci+256).toString(16).substr(1));var Ci;function D_(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(Ve[t[e+0]]+Ve[t[e+1]]+Ve[t[e+2]]+Ve[t[e+3]]+"-"+Ve[t[e+4]]+Ve[t[e+5]]+"-"+Ve[t[e+6]]+Ve[t[e+7]]+"-"+Ve[t[e+8]]+Ve[t[e+9]]+"-"+Ve[t[e+10]]+Ve[t[e+11]]+Ve[t[e+12]]+Ve[t[e+13]]+Ve[t[e+14]]+Ve[t[e+15]]).toLowerCase();if(!qd(r))throw TypeError("Stringified UUID is invalid");return r}var kd=D_;I();R();T();function B_(t,e,r){t=t||{};var n=t.random||(t.rng||ia)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(var i=0;i<16;++i)e[r+i]=n[i];return e}return kd(n)}var qn=B_;var Ua=en(Cd());I();R();T();var xi={},xd=!1;function L_(){if(xd)return xi;xd=!0;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(v,E,k){return Function.prototype.apply.call(v,E,k)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:r=function(v){return Object.getOwnPropertyNames(v)};function n(h){console&&console.warn&&console.warn(h)}var i=Number.isNaN||function(v){return v!==v};function s(){s.init.call(this)}xi=s,xi.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(h){if(typeof h!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof h)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(h){if(typeof h!="number"||h<0||i(h))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+h+".");o=h}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(v){if(typeof v!="number"||v<0||i(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function c(h){return h._maxListeners===void 0?s.defaultMaxListeners:h._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(v){for(var E=[],k=1;k<arguments.length;k++)E.push(arguments[k]);var x=v==="error",N=this._events;if(N!==void 0)x=x&&N.error===void 0;else if(!x)return!1;if(x){var G;if(E.length>0&&(G=E[0]),G instanceof Error)throw G;var H=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw H.context=G,H}var re=N[v];if(re===void 0)return!1;if(typeof re=="function")e(re,this,E);else for(var Q=re.length,Z=b(re,Q),k=0;k<Q;++k)e(Z[k],this,E);return!0};function d(h,v,E,k){var x,N,G;if(a(E),N=h._events,N===void 0?(N=h._events=Object.create(null),h._eventsCount=0):(N.newListener!==void 0&&(h.emit("newListener",v,E.listener?E.listener:E),N=h._events),G=N[v]),G===void 0)G=N[v]=E,++h._eventsCount;else if(typeof G=="function"?G=N[v]=k?[E,G]:[G,E]:k?G.unshift(E):G.push(E),x=c(h),x>0&&G.length>x&&!G.warned){G.warned=!0;var H=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");H.name="MaxListenersExceededWarning",H.emitter=h,H.type=v,H.count=G.length,n(H)}return h}s.prototype.addListener=function(v,E){return d(this,v,E,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(v,E){return d(this,v,E,!0)};function m(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(h,v,E){var k={fired:!1,wrapFn:void 0,target:h,type:v,listener:E},x=m.bind(k);return x.listener=E,k.wrapFn=x,x}s.prototype.once=function(v,E){return a(E),this.on(v,f(this,v,E)),this},s.prototype.prependOnceListener=function(v,E){return a(E),this.prependListener(v,f(this,v,E)),this},s.prototype.removeListener=function(v,E){var k,x,N,G,H;if(a(E),x=this._events,x===void 0)return this;if(k=x[v],k===void 0)return this;if(k===E||k.listener===E)--this._eventsCount===0?this._events=Object.create(null):(delete x[v],x.removeListener&&this.emit("removeListener",v,k.listener||E));else if(typeof k!="function"){for(N=-1,G=k.length-1;G>=0;G--)if(k[G]===E||k[G].listener===E){H=k[G].listener,N=G;break}if(N<0)return this;N===0?k.shift():P(k,N),k.length===1&&(x[v]=k[0]),x.removeListener!==void 0&&this.emit("removeListener",v,H||E)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(v){var E,k,x;if(k=this._events,k===void 0)return this;if(k.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):k[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete k[v]),this;if(arguments.length===0){var N=Object.keys(k),G;for(x=0;x<N.length;++x)G=N[x],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(E=k[v],typeof E=="function")this.removeListener(v,E);else if(E!==void 0)for(x=E.length-1;x>=0;x--)this.removeListener(v,E[x]);return this};function g(h,v,E){var k=h._events;if(k===void 0)return[];var x=k[v];return x===void 0?[]:typeof x=="function"?E?[x.listener||x]:[x]:E?S(x):b(x,x.length)}s.prototype.listeners=function(v){return g(this,v,!0)},s.prototype.rawListeners=function(v){return g(this,v,!1)},s.listenerCount=function(h,v){return typeof h.listenerCount=="function"?h.listenerCount(v):_.call(h,v)},s.prototype.listenerCount=_;function _(h){var v=this._events;if(v!==void 0){var E=v[h];if(typeof E=="function")return 1;if(E!==void 0)return E.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function b(h,v){for(var E=new Array(v),k=0;k<v;++k)E[k]=h[k];return E}function P(h,v){for(;v+1<h.length;v++)h[v]=h[v+1];h.pop()}function S(h){for(var v=new Array(h.length),E=0;E<v.length;++E)v[E]=h[E].listener||h[E];return v}function y(h,v){return new Promise(function(E,k){function x(G){h.removeListener(v,N),k(G)}function N(){typeof h.removeListener=="function"&&h.removeListener("error",x),E([].slice.call(arguments))}p(h,v,N,{once:!0}),v!=="error"&&w(h,x,{once:!0})})}function w(h,v,E){typeof h.on=="function"&&p(h,"error",v,E)}function p(h,v,E,k){if(typeof h.on=="function")k.once?h.once(v,E):h.on(v,E);else if(typeof h.addEventListener=="function")h.addEventListener(v,function x(N){k.once&&h.removeEventListener(v,x),E(N)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof h)}return xi}var ut=L_();ut.once;ut.once=function(t,e){return new Promise((r,n)=>{function i(...o){s!==void 0&&t.removeListener("error",s),r(o)}let s;e!=="error"&&(s=o=>{t.removeListener(name,i),n(o)},t.once("error",s)),t.once(e,i)})};ut.on=function(t,e){let r=[],n=[],i=null,s=!1,o={async next(){let d=r.shift();if(d)return createIterResult(d,!1);if(i){let m=Promise.reject(i);return i=null,m}return s?createIterResult(void 0,!0):new Promise((m,f)=>n.push({resolve:m,reject:f}))},async return(){t.removeListener(e,a),t.removeListener("error",c),s=!0;for(let d of n)d.resolve(createIterResult(void 0,!0));return createIterResult(void 0,!0)},throw(d){i=d,t.removeListener(e,a),t.removeListener("error",c)},[Symbol.asyncIterator](){return this}};return t.on(e,a),t.on("error",c),o;function a(...d){let m=n.shift();m?m.resolve(createIterResult(d,!1)):r.push(d)}function c(d){s=!0;let m=n.shift();m?m.reject(d):i=d,o.return()}};var{EventEmitter:tA,defaultMaxListeners:rA,init:nA,listenerCount:iA,on:sA,once:oA}=ut;function M_(t){return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer||typeof Blob<"u"&&t instanceof Blob}function U_(t){return t instanceof ArrayBuffer?t.slice(0):t.slice(0,t.size,t.type)}var uh=Function.prototype.toString,G_=uh.call(Object);function F_(t){var e=Object.getPrototypeOf(t);if(e===null)return!0;var r=e.constructor;return typeof r=="function"&&r instanceof r&&uh.call(r)==G_}function Ge(t){var e,r,n;if(!t||typeof t!="object")return t;if(Array.isArray(t)){for(e=[],r=0,n=t.length;r<n;r++)e[r]=Ge(t[r]);return e}if(t instanceof Date&&isFinite(t))return t.toISOString();if(M_(t))return U_(t);if(!F_(t))return t;e={};for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var i=Ge(t[r]);typeof i<"u"&&(e[r]=i)}return e}function ch(t){var e=!1;return function(...r){if(e)throw new Error("once called more than once");e=!0,t.apply(this,r)}}function fh(t){return function(...e){e=Ge(e);var r=this,n=typeof e[e.length-1]=="function"?e.pop():!1,i=new Promise(function(s,o){var a;try{var c=ch(function(d,m){d?o(d):s(m)});e.push(c),a=t.apply(r,e),a&&typeof a.then=="function"&&s(a)}catch(d){o(d)}});return n&&i.then(function(s){n(null,s)},n),i}}function z_(t,e,r){if(t.constructor.listeners("debug").length){for(var n=["api",t.name,e],i=0;i<r.length-1;i++)n.push(r[i]);t.constructor.emit("debug",n);var s=r[r.length-1];r[r.length-1]=function(o,a){var c=["api",t.name,e];c=c.concat(o?["error",o]:["success",a]),t.constructor.emit("debug",c),s(o,a)}}}function De(t,e){return fh(function(...r){if(this._closed)return Promise.reject(new Error("database is closed"));if(this._destroyed)return Promise.reject(new Error("database is destroyed"));var n=this;return z_(n,t,r),this.taskqueue.isReady?e.apply(this,r):new Promise(function(i,s){n.taskqueue.addTask(function(o){o?s(o):i(n[t].apply(n,r))})})})}function Nn(t,e){for(var r={},n=0,i=e.length;n<i;n++){var s=e[n];s in t&&(r[s]=t[s])}return r}var K_=6;function jd(t){return t}function V_(t){return[{ok:t}]}function lh(t,e,r){var n=e.docs,i=new Map;n.forEach(function(P){i.has(P.id)?i.get(P.id).push(P):i.set(P.id,[P])});var s=i.size,o=0,a=new Array(s);function c(){var P=[];a.forEach(function(S){S.docs.forEach(function(y){P.push({id:S.id,docs:[y]})})}),r(null,{results:P})}function d(){++o===s&&c()}function m(P,S,y){a[P]={id:S,docs:y},d()}var f=[];i.forEach(function(P,S){f.push(S)});var g=0;function _(){if(!(g>=f.length)){var P=Math.min(g+K_,f.length),S=f.slice(g,P);b(S,g),g+=S.length}}function b(P,S){P.forEach(function(y,w){var p=S+w,h=i.get(y),v=Nn(h[0],["atts_since","attachments"]);v.open_revs=h.map(function(k){return k.rev}),v.open_revs=v.open_revs.filter(jd);var E=jd;v.open_revs.length===0&&(delete v.open_revs,E=V_),["revs","attachments","binary","ajax","latest"].forEach(function(k){k in e&&(v[k]=e[k])}),t.get(y,v,function(k,x){var N;k?N=[{error:k}]:N=E(x),m(p,y,N),_()})})}_()}var _a;try{localStorage.setItem("_pouch_check_localstorage",1),_a=!!localStorage.getItem("_pouch_check_localstorage")}catch{_a=!1}function Mi(){return _a}var qt=typeof queueMicrotask=="function"?queueMicrotask:function(e){Promise.resolve().then(e)},wa=class extends ut{constructor(){super(),this._listeners={},Mi()&&addEventListener("storage",e=>{this.emit(e.key)})}addListener(e,r,n,i){if(this._listeners[r])return;var s=!1,o=this;function a(){if(!o._listeners[r])return;if(s){s="waiting";return}s=!0;var c=Nn(i,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary","return_docs"]);function d(){s=!1}n.changes(c).on("change",function(m){m.seq>i.since&&!i.cancelled&&(i.since=m.seq,i.onChange(m))}).on("complete",function(){s==="waiting"&&qt(a),s=!1}).on("error",d)}this._listeners[r]=a,this.on(e,a)}removeListener(e,r){r in this._listeners&&(super.removeListener(e,this._listeners[r]),delete this._listeners[r])}notifyLocalWindows(e){Mi()&&(localStorage[e]=localStorage[e]==="a"?"b":"a")}notify(e){this.emit(e),this.notifyLocalWindows(e)}};function vt(t){if(typeof console<"u"&&typeof console[t]=="function"){var e=Array.prototype.slice.call(arguments,1);console[t].apply(console,e)}}function J_(t,e){var r=6e5;t=parseInt(t,10)||0,e=parseInt(e,10),e!==e||e<=t?e=(t||1)<<1:e=e+1,e>r&&(t=r>>1,e=r);var n=Math.random(),i=e-t;return~~(i*n+t)}function H_(t){var e=0;return t||(e=2e3),J_(t,e)}function ba(t,e){vt("info","The above "+t+" is totally normal. "+e)}var Te=class extends Error{constructor(e,r,n){super(),this.status=e,this.name=r,this.message=n,this.error=!0}toString(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})}},hA=new Te(401,"unauthorized","Name or password is incorrect."),W_=new Te(400,"bad_request","Missing JSON list of 'docs'"),pt=new Te(404,"not_found","missing"),Vr=new Te(409,"conflict","Document update conflict"),dh=new Te(400,"bad_request","_id field must contain a string"),Q_=new Te(412,"missing_id","_id is required for puts"),Y_=new Te(400,"bad_request","Only reserved document ids may start with underscore."),pA=new Te(412,"precondition_failed","Database not open"),Ga=new Te(500,"unknown_error","Database encountered an unknown error"),hh=new Te(500,"badarg","Some query argument is invalid"),mA=new Te(400,"invalid_request","Request was invalid"),X_=new Te(400,"query_parse_error","Some query parameter is invalid"),Nd=new Te(500,"doc_validation","Bad special document member"),Qi=new Te(400,"bad_request","Something wrong with the request"),oa=new Te(400,"bad_request","Document must be a JSON object"),vA=new Te(404,"not_found","Database not found"),Fa=new Te(500,"indexed_db_went_bad","unknown"),yA=new Te(500,"web_sql_went_bad","unknown"),gA=new Te(500,"levelDB_went_went_bad","unknown"),_A=new Te(403,"forbidden","Forbidden by design doc validate_doc_update function"),Di=new Te(400,"bad_request","Invalid rev format"),wA=new Te(412,"file_exists","The database could not be created, the file already exists."),Z_=new Te(412,"missing_stub","A pre-existing attachment stub wasn't found"),bA=new Te(413,"invalid_url","Provided URL is invalid");function oe(t,e){function r(n){for(var i=Object.getOwnPropertyNames(t),s=0,o=i.length;s<o;s++)typeof t[i[s]]!="function"&&(this[i[s]]=t[i[s]]);this.stack===void 0&&(this.stack=new Error().stack),n!==void 0&&(this.reason=n)}return r.prototype=Te.prototype,new r(e)}function Jr(t){if(typeof t!="object"){var e=t;t=Ga,t.data=e}return"error"in t&&t.error==="conflict"&&(t.name="conflict",t.status=409),"name"in t||(t.name=t.error||"unknown"),"status"in t||(t.status=500),"message"in t||(t.message=t.message||t.reason),"stack"in t||(t.stack=new Error().stack),t}function e0(t,e,r){try{return!t(e,r)}catch(i){var n="Filter function threw: "+i.toString();return oe(Qi,n)}}function za(t){var e={},r=t.filter&&typeof t.filter=="function";return e.query=t.query_params,function(i){i.doc||(i.doc={});var s=r&&e0(t.filter,i.doc,e);if(typeof s=="object")return s;if(s)return!1;if(!t.include_docs)delete i.doc;else if(!t.attachments)for(var o in i.doc._attachments)Object.prototype.hasOwnProperty.call(i.doc._attachments,o)&&(i.doc._attachments[o].stub=!0);return!0}}function ph(t){var e;if(t?typeof t!="string"?e=oe(dh):/^_/.test(t)&&!/^_(design|local)/.test(t)&&(e=oe(Y_)):e=oe(Q_),e)throw e}function Rt(t){return typeof t._remote=="boolean"?t._remote:typeof t.type=="function"?(vt("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),t.type()==="http"):!1}function t0(t,e){return"listenerCount"in t?t.listenerCount(e):ut.listenerCount(t,e)}function Ea(t){if(!t)return null;var e=t.split("/");return e.length===2?e:e.length===1?[t,t]:null}function Dd(t){var e=Ea(t);return e?e.join("/"):null}var Bd=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Ld="queryKey",r0=/(?:^|&)([^&=]*)=?([^&]*)/g,n0=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;function mh(t){for(var e=n0.exec(t),r={},n=14;n--;){var i=Bd[n],s=e[n]||"",o=["user","password"].indexOf(i)!==-1;r[i]=o?decodeURIComponent(s):s}return r[Ld]={},r[Bd[12]].replace(r0,function(a,c,d){c&&(r[Ld][c]=d)}),r}function Ka(t,e){var r=[],n=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r.push(i),n.push(e[i]));return r.push(t),Function.apply(null,r).apply(null,n)}function Ui(t,e,r){return t.get(e).catch(function(n){if(n.status!==404)throw n;return{}}).then(function(n){var i=n._rev,s=r(n);return s?(s._id=e,s._rev=i,i0(t,s,r)):{updated:!1,rev:i}})}function i0(t,e,r){return t.put(e).then(function(n){return{updated:!0,rev:n.rev}},function(n){if(n.status!==409)throw n;return Ui(t,e._id,r)})}var Va=function(t){return atob(t)},Dn=function(t){return btoa(t)};function Ja(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(s){if(s.name!=="TypeError")throw s;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,n=new r,i=0;i<t.length;i+=1)n.append(t[i]);return n.getBlob(e.type)}}function s0(t){for(var e=t.length,r=new ArrayBuffer(e),n=new Uint8Array(r),i=0;i<e;i++)n[i]=t.charCodeAt(i);return r}function Ha(t,e){return Ja([s0(t)],{type:e})}function Wa(t,e){return Ha(Va(t),e)}function o0(t){for(var e="",r=new Uint8Array(t),n=r.byteLength,i=0;i<n;i++)e+=String.fromCharCode(r[i]);return e}function vh(t,e){var r=new FileReader,n=typeof r.readAsBinaryString=="function";r.onloadend=function(i){var s=i.target.result||"";if(n)return e(s);e(o0(s))},n?r.readAsBinaryString(t):r.readAsArrayBuffer(t)}function yh(t,e){vh(t,function(r){e(r)})}function Qa(t,e){yh(t,function(r){e(Dn(r))})}function a0(t,e){var r=new FileReader;r.onloadend=function(n){var i=n.target.result||new ArrayBuffer(0);e(i)},r.readAsArrayBuffer(t)}var u0=self.setImmediate||self.setTimeout,c0=32768;function f0(t){return Dn(t)}function l0(t,e,r,n,i){(r>0||n<e.size)&&(e=e.slice(r,n)),a0(e,function(s){t.append(s),i()})}function d0(t,e,r,n,i){(r>0||n<e.length)&&(e=e.substring(r,n)),t.appendBinary(e),i()}function Ya(t,e){var r=typeof t=="string",n=r?t.length:t.size,i=Math.min(c0,n),s=Math.ceil(n/i),o=0,a=r?new Li.default:new Li.default.ArrayBuffer,c=r?d0:l0;function d(){u0(f)}function m(){var g=a.end(!0),_=f0(g);e(_),a.destroy()}function f(){var g=o*i,_=g+i;o++,o<s?c(a,t,g,_,d):c(a,t,g,_,m)}f()}function gh(t){return Li.default.hash(t)}function _h(t,e){if(!e)return qn().replace(/-/g,"").toLowerCase();var r=Object.assign({},t);return delete r._rev_tree,gh(JSON.stringify(r))}var Yi=qn;function br(t){for(var e,r,n,i=t.rev_tree.slice(),s;s=i.pop();){var o=s.ids,a=o[2],c=s.pos;if(a.length){for(var d=0,m=a.length;d<m;d++)i.push({pos:c+1,ids:a[d]});continue}var f=!!o[1].deleted,g=o[0];(!e||(n!==f?n:r!==c?r<c:e<g))&&(e=g,r=c,n=f)}return r+"-"+e}function Er(t,e){for(var r=t.slice(),n;n=r.pop();)for(var i=n.pos,s=n.ids,o=s[2],a=e(o.length===0,i,s[0],n.ctx,s[1]),c=0,d=o.length;c<d;c++)r.push({pos:i+1,ids:o[c],ctx:a})}function h0(t,e){return t.pos-e.pos}function Xa(t){var e=[];Er(t,function(i,s,o,a,c){i&&e.push({rev:s+"-"+o,pos:s,opts:c})}),e.sort(h0).reverse();for(var r=0,n=e.length;r<n;r++)delete e[r].pos;return e}function Za(t){for(var e=br(t),r=Xa(t.rev_tree),n=[],i=0,s=r.length;i<s;i++){var o=r[i];o.rev!==e&&!o.opts.deleted&&n.push(o.rev)}return n}function p0(t){var e=[];return Er(t.rev_tree,function(r,n,i,s,o){o.status==="available"&&!r&&(e.push(n+"-"+i),o.status="missing")}),e}function m0(t,e){let r=[],n=t.slice(),i;for(;i=n.pop();){let{pos:s,ids:o}=i,a=`${s}-${o[0]}`,c=o[2];if(r.push(a),a===e){if(c.length!==0)throw new Error("The requested revision is not a leaf");return r.reverse()}(c.length===0||c.length>1)&&(r=[]);for(let d=0,m=c.length;d<m;d++)n.push({pos:s+1,ids:c[d]})}if(r.length===0)throw new Error("The requested revision does not exist");return r.reverse()}function wh(t){for(var e=[],r=t.slice(),n;n=r.pop();){var i=n.pos,s=n.ids,o=s[0],a=s[1],c=s[2],d=c.length===0,m=n.history?n.history.slice():[];m.push({id:o,opts:a}),d&&e.push({pos:i+1-m.length,ids:m});for(var f=0,g=c.length;f<g;f++)r.push({pos:i+1,ids:c[f],history:m})}return e.reverse()}function v0(t,e){return t.pos-e.pos}function y0(t,e,r){for(var n=0,i=t.length,s;n<i;)s=n+i>>>1,r(t[s],e)<0?n=s+1:i=s;return n}function g0(t,e,r){var n=y0(t,e,r);t.splice(n,0,e)}function Md(t,e){for(var r,n,i=e,s=t.length;i<s;i++){var o=t[i],a=[o.id,o.opts,[]];n?(n[2].push(a),n=a):r=n=a}return r}function _0(t,e){return t[0]<e[0]?-1:1}function Ud(t,e){for(var r=[{tree1:t,tree2:e}],n=!1;r.length>0;){var i=r.pop(),s=i.tree1,o=i.tree2;(s[1].status||o[1].status)&&(s[1].status=s[1].status==="available"||o[1].status==="available"?"available":"missing");for(var a=0;a<o[2].length;a++){if(!s[2][0]){n="new_leaf",s[2][0]=o[2][a];continue}for(var c=!1,d=0;d<s[2].length;d++)s[2][d][0]===o[2][a][0]&&(r.push({tree1:s[2][d],tree2:o[2][a]}),c=!0);c||(n="new_branch",g0(s[2],o[2][a],_0))}}return{conflicts:n,tree:t}}function bh(t,e,r){var n=[],i=!1,s=!1,o;if(!t.length)return{tree:[e],conflicts:"new_leaf"};for(var a=0,c=t.length;a<c;a++){var d=t[a];if(d.pos===e.pos&&d.ids[0]===e.ids[0])o=Ud(d.ids,e.ids),n.push({pos:d.pos,ids:o.tree}),i=i||o.conflicts,s=!0;else if(r!==!0){var m=d.pos<e.pos?d:e,f=d.pos<e.pos?e:d,g=f.pos-m.pos,_=[],b=[];for(b.push({ids:m.ids,diff:g,parent:null,parentIdx:null});b.length>0;){var P=b.pop();if(P.diff===0){P.ids[0]===f.ids[0]&&_.push(P);continue}for(var S=P.ids[2],y=0,w=S.length;y<w;y++)b.push({ids:S[y],diff:P.diff-1,parent:P.ids,parentIdx:y})}var p=_[0];p?(o=Ud(p.ids,f.ids),p.parent[2][p.parentIdx]=o.tree,n.push({pos:m.pos,ids:m.ids}),i=i||o.conflicts,s=!0):n.push(d)}else n.push(d)}return s||n.push(e),n.sort(v0),{tree:n,conflicts:i||"internal_node"}}function w0(t,e){for(var r=wh(t),n,i,s=0,o=r.length;s<o;s++){var a=r[s],c=a.ids,d;if(c.length>e){n||(n={});var m=c.length-e;d={pos:a.pos+m,ids:Md(c,m)};for(var f=0;f<m;f++){var g=a.pos+f+"-"+c[f].id;n[g]=!0}}else d={pos:a.pos,ids:Md(c,0)};i?i=bh(i,d,!0).tree:i=[d]}return n&&Er(i,function(_,b,P){delete n[b+"-"+P]}),{tree:i,revs:n?Object.keys(n):[]}}function Eh(t,e,r){var n=bh(t,e),i=w0(n.tree,r);return{tree:i.tree,stemmedRevs:i.revs,conflicts:n.conflicts}}function b0(t,e){for(var r=t.slice(),n=e.split("-"),i=parseInt(n[0],10),s=n[1],o;o=r.pop();){if(o.pos===i&&o.ids[0]===s)return!0;for(var a=o.ids[2],c=0,d=a.length;c<d;c++)r.push({pos:o.pos+1,ids:a[c]})}return!1}function E0(t){return t.ids}function Ut(t,e){e||(e=br(t));for(var r=e.substring(e.indexOf("-")+1),n=t.rev_tree.map(E0),i;i=n.pop();){if(i[0]===r)return!!i[1].deleted;n=n.concat(i[2])}}function wr(t){return typeof t=="string"&&t.startsWith("_local/")}function $0(t,e){for(var r=e.rev_tree.slice(),n;n=r.pop();){var i=n.pos,s=n.ids,o=s[0],a=s[1],c=s[2],d=c.length===0,m=n.history?n.history.slice():[];if(m.push({id:o,pos:i,opts:a}),d)for(var f=0,g=m.length;f<g;f++){var _=m[f],b=_.pos+"-"+_.id;if(b===t)return i+"-"+o}for(var P=0,S=c.length;P<S;P++)r.push({pos:i+1,ids:c[P],history:m})}throw new Error("Unable to resolve latest revision for id "+e.id+", rev "+t)}function S0(t,e,r,n){try{t.emit("change",e,r,n)}catch(i){vt("error",'Error in .on("change", function):',i)}}function P0(t,e,r){var n=[{rev:t._rev}];r.style==="all_docs"&&(n=Xa(e.rev_tree).map(function(s){return{rev:s.rev}}));var i={id:e.id,changes:n,doc:t};return Ut(e,t._rev)&&(i.deleted=!0),r.conflicts&&(i.doc._conflicts=Za(e),i.doc._conflicts.length||delete i.doc._conflicts),i}var $a=class extends ut{constructor(e,r,n){super(),this.db=e,r=r?Ge(r):{};var i=r.complete=ch((a,c)=>{a?t0(this,"error")>0&&this.emit("error",a):this.emit("complete",c),this.removeAllListeners(),e.removeListener("destroyed",s)});n&&(this.on("complete",function(a){n(null,a)}),this.on("error",n));let s=()=>{this.cancel()};e.once("destroyed",s),r.onChange=(a,c,d)=>{this.isCancelled||S0(this,a,c,d)};var o=new Promise(function(a,c){r.complete=function(d,m){d?c(d):a(m)}});this.once("cancel",function(){e.removeListener("destroyed",s),r.complete(null,{status:"cancelled"})}),this.then=o.then.bind(o),this.catch=o.catch.bind(o),this.then(function(a){i(null,a)},i),e.taskqueue.isReady?this.validateChanges(r):e.taskqueue.addTask(a=>{a?r.complete(a):this.isCancelled?this.emit("cancel"):this.validateChanges(r)})}cancel(){this.isCancelled=!0,this.db.taskqueue.isReady&&this.emit("cancel")}validateChanges(e){var r=e.complete;ae._changesFilterPlugin?ae._changesFilterPlugin.validate(e,n=>{if(n)return r(n);this.doChanges(e)}):this.doChanges(e)}doChanges(e){var r=e.complete;if(e=Ge(e),"live"in e&&!("continuous"in e)&&(e.continuous=e.live),e.processChange=P0,e.since==="latest"&&(e.since="now"),e.since||(e.since=0),e.since==="now"){this.db.info().then(i=>{if(this.isCancelled){r(null,{status:"cancelled"});return}e.since=i.update_seq,this.doChanges(e)},r);return}if(ae._changesFilterPlugin){if(ae._changesFilterPlugin.normalize(e),ae._changesFilterPlugin.shouldFilter(this,e))return ae._changesFilterPlugin.filter(this,e)}else["doc_ids","filter","selector","view"].forEach(function(i){i in e&&vt("warn",'The "'+i+'" option was passed in to changes/replicate, but pouchdb-changes-filter plugin is not installed, so it was ignored. Please install the plugin to enable filtering.')});"descending"in e||(e.descending=!1),e.limit=e.limit===0?1:e.limit,e.complete=r;var n=this.db._changes(e);if(n&&typeof n.cancel=="function"){let i=this.cancel;this.cancel=(...s)=>{n.cancel(),i.apply(this,s)}}}};function aa(t,e){return function(r,n){r||n[0]&&n[0].error?(r=r||n[0],r.docId=e,t(r)):t(null,n.length?n[0]:n)}}function O0(t){for(var e=0;e<t.length;e++){var r=t[e];if(r._deleted)delete r._attachments;else if(r._attachments)for(var n=Object.keys(r._attachments),i=0;i<n.length;i++){var s=n[i];r._attachments[s]=Nn(r._attachments[s],["data","digest","content_type","length","revpos","stub"])}}}function A0(t,e){if(t._id===e._id){let r=t._revisions?t._revisions.start:0,n=e._revisions?e._revisions.start:0;return r-n}return t._id<e._id?-1:1}function I0(t){var e={},r=[];return Er(t,function(n,i,s,o){var a=i+"-"+s;return n&&(e[a]=0),o!==void 0&&r.push({from:o,to:a}),a}),r.reverse(),r.forEach(function(n){e[n.from]===void 0?e[n.from]=1+e[n.to]:e[n.from]=Math.min(e[n.from],1+e[n.to])}),e}function T0(t){var e="limit"in t?t.keys.slice(t.skip,t.limit+t.skip):t.skip>0?t.keys.slice(t.skip):t.keys;t.keys=e,t.skip=0,delete t.limit,t.descending&&(e.reverse(),t.descending=!1)}function $h(t){var e=t._compactionQueue[0],r=e.opts,n=e.callback;t.get("_local/compaction").catch(function(){return!1}).then(function(i){i&&i.last_seq&&(r.last_seq=i.last_seq),t._compact(r,function(s,o){s?n(s):n(null,o),qt(function(){t._compactionQueue.shift(),t._compactionQueue.length&&$h(t)})})})}function R0(t,e,r){return t.get("_local/purges").then(function(n){let i=n.purgeSeq+1;return n.purges.push({docId:e,rev:r,purgeSeq:i}),n.purges.length>self.purged_infos_limit&&n.purges.splice(0,n.purges.length-self.purged_infos_limit),n.purgeSeq=i,n}).catch(function(n){if(n.status!==404)throw n;return{_id:"_local/purges",purges:[{docId:e,rev:r,purgeSeq:0}],purgeSeq:0}}).then(function(n){return t.put(n)})}function q0(t){return t.charAt(0)==="_"?t+" is not a valid attachment name, attachment names cannot start with '_'":!1}function ua(t){return t===null||typeof t!="object"||Array.isArray(t)}var k0=/^\d+-[^-]*$/;function ca(t){return typeof t=="string"&&k0.test(t)}var Gi=class extends ut{_setup(){this.post=De("post",function(e,r,n){if(typeof r=="function"&&(n=r,r={}),ua(e))return n(oe(oa));this.bulkDocs({docs:[e]},r,aa(n,e._id))}).bind(this),this.put=De("put",function(e,r,n){if(typeof r=="function"&&(n=r,r={}),ua(e))return n(oe(oa));if(ph(e._id),"_rev"in e&&!ca(e._rev))return n(oe(Di));if(wr(e._id)&&typeof this._putLocal=="function")return e._deleted?this._removeLocal(e,n):this._putLocal(e,n);let i=o=>{typeof this._put=="function"&&r.new_edits!==!1?this._put(e,r,o):this.bulkDocs({docs:[e]},r,aa(o,e._id))};r.force&&e._rev?(s(),i(function(o){var a=o?null:{ok:!0,id:e._id,rev:e._rev};n(o,a)})):i(n);function s(){var o=e._rev.split("-"),a=o[1],c=parseInt(o[0],10),d=c+1,m=_h();e._revisions={start:d,ids:[m,a]},e._rev=d+"-"+m,r.new_edits=!1}}).bind(this),this.putAttachment=De("putAttachment",function(e,r,n,i,s){var o=this;typeof s=="function"&&(s=i,i=n,n=null),typeof s>"u"&&(s=i,i=n,n=null),s||vt("warn","Attachment",r,"on document",e,"is missing content_type");function a(c){var d="_rev"in c?parseInt(c._rev,10):0;return c._attachments=c._attachments||{},c._attachments[r]={content_type:s,data:i,revpos:++d},o.put(c)}return o.get(e).then(function(c){if(c._rev!==n)throw oe(Vr);return a(c)},function(c){if(c.reason===pt.message)return a({_id:e});throw c})}).bind(this),this.removeAttachment=De("removeAttachment",function(e,r,n,i){this.get(e,(s,o)=>{if(s){i(s);return}if(o._rev!==n){i(oe(Vr));return}if(!o._attachments)return i();delete o._attachments[r],Object.keys(o._attachments).length===0&&delete o._attachments,this.put(o,i)})}).bind(this),this.remove=De("remove",function(e,r,n,i){var s;typeof r=="string"?(s={_id:e,_rev:r},typeof n=="function"&&(i=n,n={})):(s=e,typeof r=="function"?(i=r,n={}):(i=n,n=r)),n=n||{},n.was_delete=!0;var o={_id:s._id,_rev:s._rev||n.rev};if(o._deleted=!0,wr(o._id)&&typeof this._removeLocal=="function")return this._removeLocal(s,i);this.bulkDocs({docs:[o]},n,aa(i,o._id))}).bind(this),this.revsDiff=De("revsDiff",function(e,r,n){typeof r=="function"&&(n=r,r={});var i=Object.keys(e);if(!i.length)return n(null,{});var s=0,o=new Map;function a(d,m){o.has(d)||o.set(d,{missing:[]}),o.get(d).missing.push(m)}function c(d,m){var f=e[d].slice(0);Er(m,function(g,_,b,P,S){var y=_+"-"+b,w=f.indexOf(y);w!==-1&&(f.splice(w,1),S.status!=="available"&&a(d,y))}),f.forEach(function(g){a(d,g)})}i.forEach(function(d){this._getRevisionTree(d,function(m,f){if(m&&m.status===404&&m.message==="missing")o.set(d,{missing:e[d]});else{if(m)return n(m);c(d,f)}if(++s===i.length){var g={};return o.forEach(function(_,b){g[b]=_}),n(null,g)}})},this)}).bind(this),this.bulkGet=De("bulkGet",function(e,r){lh(this,e,r)}).bind(this),this.compactDocument=De("compactDocument",function(e,r,n){this._getRevisionTree(e,(i,s)=>{if(i)return n(i);var o=I0(s),a=[],c=[];Object.keys(o).forEach(function(d){o[d]>r&&a.push(d)}),Er(s,function(d,m,f,g,_){var b=m+"-"+f;_.status==="available"&&a.indexOf(b)!==-1&&c.push(b)}),this._doCompaction(e,c,n)})}).bind(this),this.compact=De("compact",function(e,r){typeof e=="function"&&(r=e,e={}),e=e||{},this._compactionQueue=this._compactionQueue||[],this._compactionQueue.push({opts:e,callback:r}),this._compactionQueue.length===1&&$h(this)}).bind(this),this.get=De("get",function(e,r,n){if(typeof r=="function"&&(n=r,r={}),r=r||{},typeof e!="string")return n(oe(dh));if(wr(e)&&typeof this._getLocal=="function")return this._getLocal(e,n);var i=[];let s=()=>{var c=[],d=i.length;if(!d)return n(null,c);i.forEach(m=>{this.get(e,{rev:m,revs:r.revs,latest:r.latest,attachments:r.attachments,binary:r.binary},function(f,g){if(f)c.push({missing:m});else{for(var _,b=0,P=c.length;b<P;b++)if(c[b].ok&&c[b].ok._rev===g._rev){_=!0;break}_||c.push({ok:g})}d--,d||n(null,c)})})};if(r.open_revs){if(r.open_revs==="all")this._getRevisionTree(e,function(c,d){if(c)return n(c);i=Xa(d).map(function(m){return m.rev}),s()});else if(Array.isArray(r.open_revs)){i=r.open_revs;for(var o=0;o<i.length;o++){var a=i[o];if(!ca(a))return n(oe(Di))}s()}else return n(oe(Ga,"function_clause"));return}return this._get(e,r,(c,d)=>{if(c)return c.docId=e,n(c);var m=d.doc,f=d.metadata,g=d.ctx;if(r.conflicts){var _=Za(f);_.length&&(m._conflicts=_)}if(Ut(f,m._rev)&&(m._deleted=!0),r.revs||r.revs_info){for(var b=m._rev.split("-"),P=parseInt(b[0],10),S=b[1],y=wh(f.rev_tree),w=null,p=0;p<y.length;p++){var h=y[p];let Q=h.ids.findIndex(Z=>Z.id===S);var v=Q===P-1;(v||!w&&Q!==-1)&&(w=h)}if(!w)return c=new Error("invalid rev tree"),c.docId=e,n(c);let H=m._rev.split("-")[1],re=w.ids.findIndex(Q=>Q.id===H)+1;var E=w.ids.length-re;if(w.ids.splice(re,E),w.ids.reverse(),r.revs&&(m._revisions={start:w.pos+w.ids.length-1,ids:w.ids.map(function(Q){return Q.id})}),r.revs_info){var k=w.pos+w.ids.length;m._revs_info=w.ids.map(function(Q){return k--,{rev:k+"-"+Q.id,status:Q.opts.status}})}}if(r.attachments&&m._attachments){var x=m._attachments,N=Object.keys(x).length;if(N===0)return n(null,m);Object.keys(x).forEach(H=>{this._getAttachment(m._id,H,x[H],{binary:r.binary,metadata:f,ctx:g},function(re,Q){var Z=m._attachments[H];Z.data=Q,delete Z.stub,delete Z.length,--N||n(null,m)})})}else{if(m._attachments)for(var G in m._attachments)Object.prototype.hasOwnProperty.call(m._attachments,G)&&(m._attachments[G].stub=!0);n(null,m)}})}).bind(this),this.getAttachment=De("getAttachment",function(e,r,n,i){n instanceof Function&&(i=n,n={}),this._get(e,n,(s,o)=>{if(s)return i(s);if(o.doc._attachments&&o.doc._attachments[r])n.ctx=o.ctx,n.binary=!0,n.metadata=o.metadata,this._getAttachment(e,r,o.doc._attachments[r],n,i);else return i(oe(pt))})}).bind(this),this.allDocs=De("allDocs",function(e,r){if(typeof e=="function"&&(r=e,e={}),e.skip=typeof e.skip<"u"?e.skip:0,e.start_key&&(e.startkey=e.start_key),e.end_key&&(e.endkey=e.end_key),"keys"in e){if(!Array.isArray(e.keys))return r(new TypeError("options.keys must be an array"));var n=["startkey","endkey","key"].filter(function(i){return i in e})[0];if(n){r(oe(X_,"Query parameter `"+n+"` is not compatible with multi-get"));return}if(!Rt(this)&&(T0(e),e.keys.length===0))return this._allDocs({limit:0},r)}return this._allDocs(e,r)}).bind(this),this.close=De("close",function(e){return this._closed=!0,this.emit("closed"),this._close(e)}).bind(this),this.info=De("info",function(e){this._info((r,n)=>{if(r)return e(r);n.db_name=n.db_name||this.name,n.auto_compaction=!!(this.auto_compaction&&!Rt(this)),n.adapter=this.adapter,e(null,n)})}).bind(this),this.id=De("id",function(e){return this._id(e)}).bind(this),this.bulkDocs=De("bulkDocs",function(e,r,n){if(typeof r=="function"&&(n=r,r={}),r=r||{},Array.isArray(e)&&(e={docs:e}),!e||!e.docs||!Array.isArray(e.docs))return n(oe(W_));for(var i=0;i<e.docs.length;++i){let c=e.docs[i];if(ua(c))return n(oe(oa));if("_rev"in c&&!ca(c._rev))return n(oe(Di))}var s;if(e.docs.forEach(function(c){c._attachments&&Object.keys(c._attachments).forEach(function(d){s=s||q0(d),c._attachments[d].content_type||vt("warn","Attachment",d,"on document",c._id,"is missing content_type")})}),s)return n(oe(Qi,s));"new_edits"in r||("new_edits"in e?r.new_edits=e.new_edits:r.new_edits=!0);var o=this;!r.new_edits&&!Rt(o)&&e.docs.sort(A0),O0(e.docs);var a=e.docs.map(function(c){return c._id});this._bulkDocs(e,r,function(c,d){if(c)return n(c);if(r.new_edits||(d=d.filter(function(g){return g.error})),!Rt(o))for(var m=0,f=d.length;m<f;m++)d[m].id=d[m].id||a[m];n(null,d)})}).bind(this),this.registerDependentDatabase=De("registerDependentDatabase",function(e,r){var n=Ge(this.__opts);this.__opts.view_adapter&&(n.adapter=this.__opts.view_adapter);var i=new this.constructor(e,n);function s(o){return o.dependentDbs=o.dependentDbs||{},o.dependentDbs[e]?!1:(o.dependentDbs[e]=!0,o)}Ui(this,"_local/_pouch_dependentDbs",s).then(function(){r(null,{db:i})}).catch(r)}).bind(this),this.destroy=De("destroy",function(e,r){typeof e=="function"&&(r=e,e={});var n="use_prefix"in this?this.use_prefix:!0;let i=()=>{this._destroy(e,(s,o)=>{if(s)return r(s);this._destroyed=!0,this.emit("destroyed"),r(null,o||{ok:!0})})};if(Rt(this))return i();this.get("_local/_pouch_dependentDbs",(s,o)=>{if(s)return s.status!==404?r(s):i();var a=o.dependentDbs,c=this.constructor,d=Object.keys(a).map(m=>{var f=n?m.replace(new RegExp("^"+c.prefix),""):m;return new c(f,this.__opts).destroy()});Promise.all(d).then(i,r)})}).bind(this)}_compact(e,r){var n={return_docs:!1,last_seq:e.last_seq||0,since:e.last_seq||0},i=[],s,o=0;let a=m=>{this.activeTasks.update(s,{completed_items:++o}),i.push(this.compactDocument(m.id,0))},c=m=>{this.activeTasks.remove(s,m),r(m)},d=m=>{var f=m.last_seq;Promise.all(i).then(()=>Ui(this,"_local/compaction",g=>!g.last_seq||g.last_seq<f?(g.last_seq=f,g):!1)).then(()=>{this.activeTasks.remove(s),r(null,{ok:!0})}).catch(c)};this.info().then(m=>{s=this.activeTasks.add({name:"database_compaction",total_items:m.update_seq-n.last_seq}),this.changes(n).on("change",a).on("complete",d).on("error",c)})}changes(e,r){return typeof e=="function"&&(r=e,e={}),e=e||{},e.return_docs="return_docs"in e?e.return_docs:!e.live,new $a(this,e,r)}type(){return typeof this._type=="function"?this._type():this.adapter}};Gi.prototype.purge=De("_purge",function(t,e,r){if(typeof this._purge>"u")return r(oe(Ga,"Purge is not implemented in the "+this.adapter+" adapter."));var n=this;n._getRevisionTree(t,(i,s)=>{if(i)return r(i);if(!s)return r(oe(pt));let o;try{o=m0(s,e)}catch(a){return r(a.message||a)}n._purge(t,o,(a,c)=>{if(a)return r(a);R0(n,t,e).then(function(){return r(null,c)})})})});var Sa=class{constructor(){this.isReady=!1,this.failed=!1,this.queue=[]}execute(){var e;if(this.failed)for(;e=this.queue.shift();)e(this.failed);else for(;e=this.queue.shift();)e()}fail(e){this.failed=e,this.execute()}ready(e){this.isReady=!0,this.db=e,this.execute()}addTask(e){this.queue.push(e),this.failed&&this.execute()}};function C0(t,e){var r=t.match(/([a-z-]*):\/\/(.*)/);if(r)return{name:/https?/.test(r[1])?r[1]+"://"+r[2]:r[2],adapter:r[1]};var n=ae.adapters,i=ae.preferredAdapters,s=ae.prefix,o=e.adapter;if(!o)for(var a=0;a<i.length;++a){if(o=i[a],o==="idb"&&"websql"in n&&Mi()&&localStorage["_pouch__websqldb_"+s+t]){vt("log",'PouchDB is downgrading "'+t+'" to WebSQL to avoid data loss, because it was already opened with WebSQL.');continue}break}var c=n[o],d=c&&"use_prefix"in c?c.use_prefix:!0;return{name:d?s+t:t,adapter:o}}function x0(t,e){t.prototype=Object.create(e.prototype,{constructor:{value:t}})}function Sh(t,e){let r=function(...n){if(!(this instanceof r))return new r(...n);e.apply(this,n)};return x0(r,t),r}function j0(t){function e(n){t.removeListener("closed",r),n||t.constructor.emit("destroyed",t.name)}function r(){t.removeListener("destroyed",e),t.constructor.emit("unref",t)}t.once("destroyed",e),t.once("closed",r),t.constructor.emit("ref",t)}var Fi=class extends Gi{constructor(e,r){super(),this._setup(e,r)}_setup(e,r){if(super._setup(),r=r||{},e&&typeof e=="object"&&(r=e,e=r.name,delete r.name),r.deterministic_revs===void 0&&(r.deterministic_revs=!0),this.__opts=r=Ge(r),this.auto_compaction=r.auto_compaction,this.purged_infos_limit=r.purged_infos_limit||1e3,this.prefix=ae.prefix,typeof e!="string")throw new Error("Missing/invalid DB name");var n=(r.prefix||"")+e,i=C0(n,r);if(r.name=i.name,r.adapter=r.adapter||i.adapter,this.name=e,this._adapter=r.adapter,ae.emit("debug",["adapter","Picked adapter: ",r.adapter]),!ae.adapters[r.adapter]||!ae.adapters[r.adapter].valid())throw new Error("Invalid Adapter: "+r.adapter);if(r.view_adapter&&(!ae.adapters[r.view_adapter]||!ae.adapters[r.view_adapter].valid()))throw new Error("Invalid View Adapter: "+r.view_adapter);this.taskqueue=new Sa,this.adapter=r.adapter,ae.adapters[r.adapter].call(this,r,s=>{if(s)return this.taskqueue.fail(s);j0(this),this.emit("created",this),ae.emit("created",this.name),this.taskqueue.ready(this)})}},ae=Sh(Fi,function(t,e){Fi.prototype._setup.call(this,t,e)}),Ph=fetch,zr=Headers,Pa=class{constructor(){this.tasks={}}list(){return Object.values(this.tasks)}add(e){let r=qn();return this.tasks[r]={id:r,name:e.name,total_items:e.total_items,created_at:new Date().toJSON()},r}get(e){return this.tasks[e]}remove(e,r){return delete this.tasks[e],this.tasks}update(e,r){let n=this.tasks[e];if(typeof n<"u"){let i={id:n.id,name:n.name,created_at:n.created_at,total_items:r.total_items||n.total_items,completed_items:r.completed_items||n.completed_items,updated_at:new Date().toJSON()};this.tasks[e]=i}return this.tasks}};ae.adapters={};ae.preferredAdapters=[];ae.prefix="_pouch_";var Gd=new ut;function N0(t){Object.keys(ut.prototype).forEach(function(r){typeof ut.prototype[r]=="function"&&(t[r]=Gd[r].bind(Gd))});var e=t._destructionListeners=new Map;t.on("ref",function(n){e.has(n.name)||e.set(n.name,[]),e.get(n.name).push(n)}),t.on("unref",function(n){if(e.has(n.name)){var i=e.get(n.name),s=i.indexOf(n);s<0||(i.splice(s,1),i.length>1?e.set(n.name,i):e.delete(n.name))}}),t.on("destroyed",function(n){if(e.has(n)){var i=e.get(n);e.delete(n),i.forEach(function(s){s.emit("destroyed",!0)})}})}N0(ae);ae.adapter=function(t,e,r){e.valid()&&(ae.adapters[t]=e,r&&ae.preferredAdapters.push(t))};ae.plugin=function(t){if(typeof t=="function")t(ae);else{if(typeof t!="object"||Object.keys(t).length===0)throw new Error('Invalid plugin: got "'+t+'", expected an object or a function');Object.keys(t).forEach(function(e){ae.prototype[e]=t[e]})}return this.__defaults&&(ae.__defaults=Object.assign({},this.__defaults)),ae};ae.defaults=function(t){let e=Sh(ae,function(r,n){n=n||{},r&&typeof r=="object"&&(n=r,r=n.name,delete n.name),n=Object.assign({},e.__defaults,n),ae.call(this,r,n)});return e.preferredAdapters=ae.preferredAdapters.slice(),Object.keys(ae).forEach(function(r){r in e||(e[r]=ae[r])}),e.__defaults=Object.assign({},this.__defaults,t),e};ae.fetch=function(t,e){return Ph(t,e)};ae.prototype.activeTasks=ae.activeTasks=new Pa;var D0="9.0.0";function eu(t,e){for(var r=t,n=0,i=e.length;n<i;n++){var s=e[n];if(r=r[s],!r)break}return r}function B0(t,e){return t<e?-1:t>e?1:0}function tu(t){for(var e=[],r="",n=0,i=t.length;n<i;n++){var s=t[n];n>0&&t[n-1]==="\\"&&(s==="$"||s===".")?r=r.substring(0,r.length-1)+s:s==="."?(e.push(r),r=""):r+=s}return e.push(r),e}var L0=["$or","$nor","$not"];function Oh(t){return L0.indexOf(t)>-1}function Ah(t){return Object.keys(t)[0]}function M0(t){return t[Ah(t)]}function xn(t){var e={},r={$or:!0,$nor:!0};return t.forEach(function(n){Object.keys(n).forEach(function(i){var s=n[i];if(typeof s!="object"&&(s={$eq:s}),Oh(i))if(s instanceof Array){if(r[i]){r[i]=!1,e[i]=s;return}var o=[];e[i].forEach(function(c){Object.keys(s).forEach(function(d){var m=s[d],f=Math.max(Object.keys(c).length,Object.keys(m).length),g=xn([c,m]);Object.keys(g).length<=f||o.push(g)})}),e[i]=o}else e[i]=xn([s]);else{var a=e[i]=e[i]||{};Object.keys(s).forEach(function(c){var d=s[c];if(c==="$gt"||c==="$gte")return U0(c,d,a);if(c==="$lt"||c==="$lte")return G0(c,d,a);if(c==="$ne")return F0(d,a);if(c==="$eq")return z0(d,a);if(c==="$regex")return K0(d,a);a[c]=d})}})}),e}function U0(t,e,r){typeof r.$eq<"u"||(typeof r.$gte<"u"?t==="$gte"?e>r.$gte&&(r.$gte=e):e>=r.$gte&&(delete r.$gte,r.$gt=e):typeof r.$gt<"u"?t==="$gte"?e>r.$gt&&(delete r.$gt,r.$gte=e):e>r.$gt&&(r.$gt=e):r[t]=e)}function G0(t,e,r){typeof r.$eq<"u"||(typeof r.$lte<"u"?t==="$lte"?e<r.$lte&&(r.$lte=e):e<=r.$lte&&(delete r.$lte,r.$lt=e):typeof r.$lt<"u"?t==="$lte"?e<r.$lt&&(delete r.$lt,r.$lte=e):e<r.$lt&&(r.$lt=e):r[t]=e)}function F0(t,e){"$ne"in e?e.$ne.push(t):e.$ne=[t]}function z0(t,e){delete e.$gt,delete e.$gte,delete e.$lt,delete e.$lte,delete e.$ne,e.$eq=t}function K0(t,e){"$regex"in e?e.$regex.push(t):e.$regex=[t]}function Ih(t){for(var e in t){if(Array.isArray(t))for(var r in t)t[r].$and&&(t[r]=xn(t[r].$and));var n=t[e];typeof n=="object"&&Ih(n)}return t}function Th(t,e){for(var r in t){r==="$and"&&(e=!0);var n=t[r];typeof n=="object"&&(e=Th(n,e))}return e}function V0(t){var e=Ge(t);Th(e,!1)&&(e=Ih(e),"$and"in e&&(e=xn(e.$and))),["$or","$nor"].forEach(function(o){o in e&&e[o].forEach(function(a){for(var c=Object.keys(a),d=0;d<c.length;d++){var m=c[d],f=a[m];(typeof f!="object"||f===null)&&(a[m]={$eq:f})}})}),"$not"in e&&(e.$not=xn([e.$not]));for(var r=Object.keys(e),n=0;n<r.length;n++){var i=r[n],s=e[i];(typeof s!="object"||s===null)&&(s={$eq:s}),e[i]=s}return Oa(e),e}function Oa(t){Object.keys(t).forEach(function(e){var r=t[e];Array.isArray(r)?r.forEach(function(n){n&&typeof n=="object"&&Oa(n)}):e==="$ne"?t.$ne=[r]:e==="$regex"?t.$regex=[r]:r&&typeof r=="object"&&Oa(r)})}function J0(t,e,r){for(var n="",i=r-t.length;n.length<i;)n+=e;return n}function H0(t,e,r){var n=J0(t,e,r);return n+t}var Rh=-324,Aa=3,Ia="";function Be(t,e){if(t===e)return 0;t=$r(t),e=$r(e);var r=Ta(t),n=Ta(e);if(r-n!==0)return r-n;switch(typeof t){case"number":return t-e;case"boolean":return t<e?-1:1;case"string":return ew(t,e)}return Array.isArray(t)?Z0(t,e):tw(t,e)}function $r(t){switch(typeof t){case"undefined":return null;case"number":return t===1/0||t===-1/0||isNaN(t)?null:t;case"object":var e=t;if(Array.isArray(t)){var r=t.length;t=new Array(r);for(var n=0;n<r;n++)t[n]=$r(e[n])}else{if(t instanceof Date)return t.toJSON();if(t!==null){t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var s=e[i];typeof s<"u"&&(t[i]=$r(s))}}}}return t}function W0(t){if(t!==null)switch(typeof t){case"boolean":return t?1:0;case"number":return rw(t);case"string":return t.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var e=Array.isArray(t),r=e?t:Object.keys(t),n=-1,i=r.length,s="";if(e)for(;++n<i;)s+=Et(r[n]);else for(;++n<i;){var o=r[n];s+=Et(o)+Et(t[o])}return s}return""}function Et(t){var e="\0";return t=$r(t),Ta(t)+Ia+W0(t)+e}function Q0(t,e){var r=e,n,i=t[e]==="1";if(i)n=0,e++;else{var s=t[e]==="0";e++;var o="",a=t.substring(e,e+Aa),c=parseInt(a,10)+Rh;for(s&&(c=-c),e+=Aa;;){var d=t[e];if(d==="\0")break;o+=d,e++}o=o.split("."),o.length===1?n=parseInt(o,10):n=parseFloat(o[0]+"."+o[1]),s&&(n=n-10),c!==0&&(n=parseFloat(n+"e"+c))}return{num:n,length:e-r}}function Y0(t,e){var r=t.pop();if(e.length){var n=e[e.length-1];r===n.element&&(e.pop(),n=e[e.length-1]);var i=n.element,s=n.index;if(Array.isArray(i))i.push(r);else if(s===t.length-2){var o=t.pop();i[o]=r}else t.push(r)}}function X0(t){for(var e=[],r=[],n=0;;){var i=t[n++];if(i==="\0"){if(e.length===1)return e.pop();Y0(e,r);continue}switch(i){case"1":e.push(null);break;case"2":e.push(t[n]==="1"),n++;break;case"3":var s=Q0(t,n);e.push(s.num),n+=s.length;break;case"4":for(var o="";;){var a=t[n];if(a==="\0")break;o+=a,n++}o=o.replace(/\u0001\u0001/g,"\0").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),e.push(o);break;case"5":var c={element:[],index:e.length};e.push(c.element),r.push(c);break;case"6":var d={element:{},index:e.length};e.push(d.element),r.push(d);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+i)}}}function Z0(t,e){for(var r=Math.min(t.length,e.length),n=0;n<r;n++){var i=Be(t[n],e[n]);if(i!==0)return i}return t.length===e.length?0:t.length>e.length?1:-1}function ew(t,e){return t===e?0:t>e?1:-1}function tw(t,e){for(var r=Object.keys(t),n=Object.keys(e),i=Math.min(r.length,n.length),s=0;s<i;s++){var o=Be(r[s],n[s]);if(o!==0||(o=Be(t[r[s]],e[n[s]]),o!==0))return o}return r.length===n.length?0:r.length>n.length?1:-1}function Ta(t){var e=["boolean","number","string","object"],r=e.indexOf(typeof t);if(~r)return t===null?1:Array.isArray(t)?5:r<3?r+2:r+3;if(Array.isArray(t))return 5}function rw(t){if(t===0)return"1";var e=t.toExponential().split(/e\+?/),r=parseInt(e[1],10),n=t<0,i=n?"0":"2",s=(n?-r:r)-Rh,o=H0(s.toString(),"0",Aa);i+=Ia+o;var a=Math.abs(parseFloat(e[0]));n&&(a=10-a);var c=a.toFixed(20);return c=c.replace(/\.?0+$/,""),i+=Ia+c,i}function nw(t){function e(r){return t.map(function(n){var i=Ah(n),s=tu(i),o=eu(r,s);return o})}return function(r,n){var i=e(r.doc),s=e(n.doc),o=Be(i,s);return o!==0?o:B0(r.doc._id,n.doc._id)}}function iw(t,e,r){if(t=t.filter(function(o){return Kr(o.doc,e.selector,r)}),e.sort){var n=nw(e.sort);t=t.sort(n),typeof e.sort[0]!="string"&&M0(e.sort[0])==="desc"&&(t=t.reverse())}if("limit"in e||"skip"in e){var i=e.skip||0,s=("limit"in e?e.limit:t.length)+i;t=t.slice(i,s)}return t}function Kr(t,e,r){return r.every(function(n){var i=e[n],s=tu(n),o=eu(t,s);return Oh(n)?sw(n,i,t):zi(i,t,s,o)})}function zi(t,e,r,n){return t?typeof t=="object"?Object.keys(t).every(function(i){var s=t[i];if(i.indexOf("$")===0)return Fd(i,e,s,r,n);var o=tu(i);if(n===void 0&&typeof s!="object"&&o.length>0)return!1;var a=eu(n,o);return typeof s=="object"?zi(s,e,r,a):Fd("$eq",e,s,o,a)}):t===n:!0}function sw(t,e,r){return t==="$or"?e.some(function(n){return Kr(r,n,Object.keys(n))}):t==="$not"?!Kr(r,e,Object.keys(e)):!e.find(function(n){return Kr(r,n,Object.keys(n))})}function Fd(t,e,r,n,i){if(!Kd[t])throw new Error('unknown operator "'+t+'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all');return Kd[t](e,r,n,i)}function kn(t){return typeof t<"u"&&t!==null}function mr(t){return typeof t<"u"}function ow(t,e){if(typeof t!="number"||parseInt(t,10)!==t)return!1;var r=e[0],n=e[1];return t%r===n}function zd(t,e){return e.some(function(r){return t instanceof Array?t.some(function(n){return Be(r,n)===0}):Be(r,t)===0})}function aw(t,e){return e.every(function(r){return t.some(function(n){return Be(r,n)===0})})}function uw(t,e){return t.length===e}function cw(t,e){var r=new RegExp(e);return r.test(t)}function fw(t,e){switch(e){case"null":return t===null;case"boolean":return typeof t=="boolean";case"number":return typeof t=="number";case"string":return typeof t=="string";case"array":return t instanceof Array;case"object":return{}.toString.call(t)==="[object Object]"}}var Kd={$elemMatch:function(t,e,r,n){return!Array.isArray(n)||n.length===0?!1:typeof n[0]=="object"&&n[0]!==null?n.some(function(i){return Kr(i,e,Object.keys(e))}):n.some(function(i){return zi(e,t,r,i)})},$allMatch:function(t,e,r,n){return!Array.isArray(n)||n.length===0?!1:typeof n[0]=="object"&&n[0]!==null?n.every(function(i){return Kr(i,e,Object.keys(e))}):n.every(function(i){return zi(e,t,r,i)})},$eq:function(t,e,r,n){return mr(n)&&Be(n,e)===0},$gte:function(t,e,r,n){return mr(n)&&Be(n,e)>=0},$gt:function(t,e,r,n){return mr(n)&&Be(n,e)>0},$lte:function(t,e,r,n){return mr(n)&&Be(n,e)<=0},$lt:function(t,e,r,n){return mr(n)&&Be(n,e)<0},$exists:function(t,e,r,n){return e?mr(n):!mr(n)},$mod:function(t,e,r,n){return kn(n)&&ow(n,e)},$ne:function(t,e,r,n){return e.every(function(i){return Be(n,i)!==0})},$in:function(t,e,r,n){return kn(n)&&zd(n,e)},$nin:function(t,e,r,n){return kn(n)&&!zd(n,e)},$size:function(t,e,r,n){return kn(n)&&Array.isArray(n)&&uw(n,e)},$all:function(t,e,r,n){return Array.isArray(n)&&aw(n,e)},$regex:function(t,e,r,n){return kn(n)&&typeof n=="string"&&e.every(function(i){return cw(n,i)})},$type:function(t,e,r,n){return fw(n,e)}};function lw(t,e){if(typeof e!="object")throw new Error("Selector error: expected a JSON object");e=V0(e);var r={doc:t},n=iw([r],{selector:e},Object.keys(e));return n&&n.length===1}function dw(t){return Ka(`"use strict";
11
+ Simply choose a username to log in.`);s&&(r=s)}let n;if(!r)n={error:new Error("No actor ID provided to login")};else{let s=this.getLoggedInActors();s.includes(r)||this.setLoggedInActors([...s,r]),n={session:{actor:r}}}let i=new CustomEvent("login",{detail:n});this.sessionEvents.dispatchEvent(i)};logout=async e=>{let r=this.getLoggedInActors(),n=r.includes(e.actor);n&&this.setLoggedInActors(r.filter(o=>o!==e.actor));let i=n?{actor:e.actor}:{actor:e.actor,error:new Error("Not logged in with that actor")},s=new CustomEvent("logout",{detail:i});this.sessionEvents.dispatchEvent(s)}};I();R();T();I();R();T();var Li=en(Td());I();R();T();I();R();T();var ki,N_=new Uint8Array(16);function ia(){if(!ki&&(ki=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ki))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ki(N_)}I();R();T();I();R();T();I();R();T();var Rd=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function j_(t){return typeof t=="string"&&Rd.test(t)}var qd=j_;var Ve=[];for(Ci=0;Ci<256;++Ci)Ve.push((Ci+256).toString(16).substr(1));var Ci;function D_(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=(Ve[t[e+0]]+Ve[t[e+1]]+Ve[t[e+2]]+Ve[t[e+3]]+"-"+Ve[t[e+4]]+Ve[t[e+5]]+"-"+Ve[t[e+6]]+Ve[t[e+7]]+"-"+Ve[t[e+8]]+Ve[t[e+9]]+"-"+Ve[t[e+10]]+Ve[t[e+11]]+Ve[t[e+12]]+Ve[t[e+13]]+Ve[t[e+14]]+Ve[t[e+15]]).toLowerCase();if(!qd(r))throw TypeError("Stringified UUID is invalid");return r}var kd=D_;I();R();T();function B_(t,e,r){t=t||{};var n=t.random||(t.rng||ia)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(var i=0;i<16;++i)e[r+i]=n[i];return e}return kd(n)}var qn=B_;var Ua=en(Cd());I();R();T();var xi={},xd=!1;function L_(){if(xd)return xi;xd=!0;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(v,E,k){return Function.prototype.apply.call(v,E,k)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:r=function(v){return Object.getOwnPropertyNames(v)};function n(h){console&&console.warn&&console.warn(h)}var i=Number.isNaN||function(v){return v!==v};function s(){s.init.call(this)}xi=s,xi.once=g,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(h){if(typeof h!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof h)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(h){if(typeof h!="number"||h<0||i(h))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+h+".");o=h}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(v){if(typeof v!="number"||v<0||i(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function c(h){return h._maxListeners===void 0?s.defaultMaxListeners:h._maxListeners}s.prototype.getMaxListeners=function(){return c(this)},s.prototype.emit=function(v){for(var E=[],k=1;k<arguments.length;k++)E.push(arguments[k]);var x=v==="error",j=this._events;if(j!==void 0)x=x&&j.error===void 0;else if(!x)return!1;if(x){var G;if(E.length>0&&(G=E[0]),G instanceof Error)throw G;var H=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw H.context=G,H}var re=j[v];if(re===void 0)return!1;if(typeof re=="function")e(re,this,E);else for(var Q=re.length,Z=b(re,Q),k=0;k<Q;++k)e(Z[k],this,E);return!0};function d(h,v,E,k){var x,j,G;if(a(E),j=h._events,j===void 0?(j=h._events=Object.create(null),h._eventsCount=0):(j.newListener!==void 0&&(h.emit("newListener",v,E.listener?E.listener:E),j=h._events),G=j[v]),G===void 0)G=j[v]=E,++h._eventsCount;else if(typeof G=="function"?G=j[v]=k?[E,G]:[G,E]:k?G.unshift(E):G.push(E),x=c(h),x>0&&G.length>x&&!G.warned){G.warned=!0;var H=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");H.name="MaxListenersExceededWarning",H.emitter=h,H.type=v,H.count=G.length,n(H)}return h}s.prototype.addListener=function(v,E){return d(this,v,E,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(v,E){return d(this,v,E,!0)};function m(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(h,v,E){var k={fired:!1,wrapFn:void 0,target:h,type:v,listener:E},x=m.bind(k);return x.listener=E,k.wrapFn=x,x}s.prototype.once=function(v,E){return a(E),this.on(v,f(this,v,E)),this},s.prototype.prependOnceListener=function(v,E){return a(E),this.prependListener(v,f(this,v,E)),this},s.prototype.removeListener=function(v,E){var k,x,j,G,H;if(a(E),x=this._events,x===void 0)return this;if(k=x[v],k===void 0)return this;if(k===E||k.listener===E)--this._eventsCount===0?this._events=Object.create(null):(delete x[v],x.removeListener&&this.emit("removeListener",v,k.listener||E));else if(typeof k!="function"){for(j=-1,G=k.length-1;G>=0;G--)if(k[G]===E||k[G].listener===E){H=k[G].listener,j=G;break}if(j<0)return this;j===0?k.shift():P(k,j),k.length===1&&(x[v]=k[0]),x.removeListener!==void 0&&this.emit("removeListener",v,H||E)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(v){var E,k,x;if(k=this._events,k===void 0)return this;if(k.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):k[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete k[v]),this;if(arguments.length===0){var j=Object.keys(k),G;for(x=0;x<j.length;++x)G=j[x],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(E=k[v],typeof E=="function")this.removeListener(v,E);else if(E!==void 0)for(x=E.length-1;x>=0;x--)this.removeListener(v,E[x]);return this};function y(h,v,E){var k=h._events;if(k===void 0)return[];var x=k[v];return x===void 0?[]:typeof x=="function"?E?[x.listener||x]:[x]:E?S(x):b(x,x.length)}s.prototype.listeners=function(v){return y(this,v,!0)},s.prototype.rawListeners=function(v){return y(this,v,!1)},s.listenerCount=function(h,v){return typeof h.listenerCount=="function"?h.listenerCount(v):_.call(h,v)},s.prototype.listenerCount=_;function _(h){var v=this._events;if(v!==void 0){var E=v[h];if(typeof E=="function")return 1;if(E!==void 0)return E.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function b(h,v){for(var E=new Array(v),k=0;k<v;++k)E[k]=h[k];return E}function P(h,v){for(;v+1<h.length;v++)h[v]=h[v+1];h.pop()}function S(h){for(var v=new Array(h.length),E=0;E<v.length;++E)v[E]=h[E].listener||h[E];return v}function g(h,v){return new Promise(function(E,k){function x(G){h.removeListener(v,j),k(G)}function j(){typeof h.removeListener=="function"&&h.removeListener("error",x),E([].slice.call(arguments))}p(h,v,j,{once:!0}),v!=="error"&&w(h,x,{once:!0})})}function w(h,v,E){typeof h.on=="function"&&p(h,"error",v,E)}function p(h,v,E,k){if(typeof h.on=="function")k.once?h.once(v,E):h.on(v,E);else if(typeof h.addEventListener=="function")h.addEventListener(v,function x(j){k.once&&h.removeEventListener(v,x),E(j)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof h)}return xi}var ut=L_();ut.once;ut.once=function(t,e){return new Promise((r,n)=>{function i(...o){s!==void 0&&t.removeListener("error",s),r(o)}let s;e!=="error"&&(s=o=>{t.removeListener(name,i),n(o)},t.once("error",s)),t.once(e,i)})};ut.on=function(t,e){let r=[],n=[],i=null,s=!1,o={async next(){let d=r.shift();if(d)return createIterResult(d,!1);if(i){let m=Promise.reject(i);return i=null,m}return s?createIterResult(void 0,!0):new Promise((m,f)=>n.push({resolve:m,reject:f}))},async return(){t.removeListener(e,a),t.removeListener("error",c),s=!0;for(let d of n)d.resolve(createIterResult(void 0,!0));return createIterResult(void 0,!0)},throw(d){i=d,t.removeListener(e,a),t.removeListener("error",c)},[Symbol.asyncIterator](){return this}};return t.on(e,a),t.on("error",c),o;function a(...d){let m=n.shift();m?m.resolve(createIterResult(d,!1)):r.push(d)}function c(d){s=!0;let m=n.shift();m?m.reject(d):i=d,o.return()}};var{EventEmitter:tA,defaultMaxListeners:rA,init:nA,listenerCount:iA,on:sA,once:oA}=ut;function M_(t){return typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer||typeof Blob<"u"&&t instanceof Blob}function U_(t){return t instanceof ArrayBuffer?t.slice(0):t.slice(0,t.size,t.type)}var uh=Function.prototype.toString,G_=uh.call(Object);function F_(t){var e=Object.getPrototypeOf(t);if(e===null)return!0;var r=e.constructor;return typeof r=="function"&&r instanceof r&&uh.call(r)==G_}function Ge(t){var e,r,n;if(!t||typeof t!="object")return t;if(Array.isArray(t)){for(e=[],r=0,n=t.length;r<n;r++)e[r]=Ge(t[r]);return e}if(t instanceof Date&&isFinite(t))return t.toISOString();if(M_(t))return U_(t);if(!F_(t))return t;e={};for(r in t)if(Object.prototype.hasOwnProperty.call(t,r)){var i=Ge(t[r]);typeof i<"u"&&(e[r]=i)}return e}function ch(t){var e=!1;return function(...r){if(e)throw new Error("once called more than once");e=!0,t.apply(this,r)}}function fh(t){return function(...e){e=Ge(e);var r=this,n=typeof e[e.length-1]=="function"?e.pop():!1,i=new Promise(function(s,o){var a;try{var c=ch(function(d,m){d?o(d):s(m)});e.push(c),a=t.apply(r,e),a&&typeof a.then=="function"&&s(a)}catch(d){o(d)}});return n&&i.then(function(s){n(null,s)},n),i}}function z_(t,e,r){if(t.constructor.listeners("debug").length){for(var n=["api",t.name,e],i=0;i<r.length-1;i++)n.push(r[i]);t.constructor.emit("debug",n);var s=r[r.length-1];r[r.length-1]=function(o,a){var c=["api",t.name,e];c=c.concat(o?["error",o]:["success",a]),t.constructor.emit("debug",c),s(o,a)}}}function De(t,e){return fh(function(...r){if(this._closed)return Promise.reject(new Error("database is closed"));if(this._destroyed)return Promise.reject(new Error("database is destroyed"));var n=this;return z_(n,t,r),this.taskqueue.isReady?e.apply(this,r):new Promise(function(i,s){n.taskqueue.addTask(function(o){o?s(o):i(n[t].apply(n,r))})})})}function jn(t,e){for(var r={},n=0,i=e.length;n<i;n++){var s=e[n];s in t&&(r[s]=t[s])}return r}var K_=6;function Nd(t){return t}function V_(t){return[{ok:t}]}function lh(t,e,r){var n=e.docs,i=new Map;n.forEach(function(P){i.has(P.id)?i.get(P.id).push(P):i.set(P.id,[P])});var s=i.size,o=0,a=new Array(s);function c(){var P=[];a.forEach(function(S){S.docs.forEach(function(g){P.push({id:S.id,docs:[g]})})}),r(null,{results:P})}function d(){++o===s&&c()}function m(P,S,g){a[P]={id:S,docs:g},d()}var f=[];i.forEach(function(P,S){f.push(S)});var y=0;function _(){if(!(y>=f.length)){var P=Math.min(y+K_,f.length),S=f.slice(y,P);b(S,y),y+=S.length}}function b(P,S){P.forEach(function(g,w){var p=S+w,h=i.get(g),v=jn(h[0],["atts_since","attachments"]);v.open_revs=h.map(function(k){return k.rev}),v.open_revs=v.open_revs.filter(Nd);var E=Nd;v.open_revs.length===0&&(delete v.open_revs,E=V_),["revs","attachments","binary","ajax","latest"].forEach(function(k){k in e&&(v[k]=e[k])}),t.get(g,v,function(k,x){var j;k?j=[{error:k}]:j=E(x),m(p,g,j),_()})})}_()}var _a;try{localStorage.setItem("_pouch_check_localstorage",1),_a=!!localStorage.getItem("_pouch_check_localstorage")}catch{_a=!1}function Mi(){return _a}var qt=typeof queueMicrotask=="function"?queueMicrotask:function(e){Promise.resolve().then(e)},wa=class extends ut{constructor(){super(),this._listeners={},Mi()&&addEventListener("storage",e=>{this.emit(e.key)})}addListener(e,r,n,i){if(this._listeners[r])return;var s=!1,o=this;function a(){if(!o._listeners[r])return;if(s){s="waiting";return}s=!0;var c=jn(i,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary","return_docs"]);function d(){s=!1}n.changes(c).on("change",function(m){m.seq>i.since&&!i.cancelled&&(i.since=m.seq,i.onChange(m))}).on("complete",function(){s==="waiting"&&qt(a),s=!1}).on("error",d)}this._listeners[r]=a,this.on(e,a)}removeListener(e,r){r in this._listeners&&(super.removeListener(e,this._listeners[r]),delete this._listeners[r])}notifyLocalWindows(e){Mi()&&(localStorage[e]=localStorage[e]==="a"?"b":"a")}notify(e){this.emit(e),this.notifyLocalWindows(e)}};function vt(t){if(typeof console<"u"&&typeof console[t]=="function"){var e=Array.prototype.slice.call(arguments,1);console[t].apply(console,e)}}function J_(t,e){var r=6e5;t=parseInt(t,10)||0,e=parseInt(e,10),e!==e||e<=t?e=(t||1)<<1:e=e+1,e>r&&(t=r>>1,e=r);var n=Math.random(),i=e-t;return~~(i*n+t)}function H_(t){var e=0;return t||(e=2e3),J_(t,e)}function ba(t,e){vt("info","The above "+t+" is totally normal. "+e)}var Te=class extends Error{constructor(e,r,n){super(),this.status=e,this.name=r,this.message=n,this.error=!0}toString(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})}},hA=new Te(401,"unauthorized","Name or password is incorrect."),W_=new Te(400,"bad_request","Missing JSON list of 'docs'"),pt=new Te(404,"not_found","missing"),Vr=new Te(409,"conflict","Document update conflict"),dh=new Te(400,"bad_request","_id field must contain a string"),Q_=new Te(412,"missing_id","_id is required for puts"),Y_=new Te(400,"bad_request","Only reserved document ids may start with underscore."),pA=new Te(412,"precondition_failed","Database not open"),Ga=new Te(500,"unknown_error","Database encountered an unknown error"),hh=new Te(500,"badarg","Some query argument is invalid"),mA=new Te(400,"invalid_request","Request was invalid"),X_=new Te(400,"query_parse_error","Some query parameter is invalid"),jd=new Te(500,"doc_validation","Bad special document member"),Qi=new Te(400,"bad_request","Something wrong with the request"),oa=new Te(400,"bad_request","Document must be a JSON object"),vA=new Te(404,"not_found","Database not found"),Fa=new Te(500,"indexed_db_went_bad","unknown"),yA=new Te(500,"web_sql_went_bad","unknown"),gA=new Te(500,"levelDB_went_went_bad","unknown"),_A=new Te(403,"forbidden","Forbidden by design doc validate_doc_update function"),Di=new Te(400,"bad_request","Invalid rev format"),wA=new Te(412,"file_exists","The database could not be created, the file already exists."),Z_=new Te(412,"missing_stub","A pre-existing attachment stub wasn't found"),bA=new Te(413,"invalid_url","Provided URL is invalid");function oe(t,e){function r(n){for(var i=Object.getOwnPropertyNames(t),s=0,o=i.length;s<o;s++)typeof t[i[s]]!="function"&&(this[i[s]]=t[i[s]]);this.stack===void 0&&(this.stack=new Error().stack),n!==void 0&&(this.reason=n)}return r.prototype=Te.prototype,new r(e)}function Jr(t){if(typeof t!="object"){var e=t;t=Ga,t.data=e}return"error"in t&&t.error==="conflict"&&(t.name="conflict",t.status=409),"name"in t||(t.name=t.error||"unknown"),"status"in t||(t.status=500),"message"in t||(t.message=t.message||t.reason),"stack"in t||(t.stack=new Error().stack),t}function e0(t,e,r){try{return!t(e,r)}catch(i){var n="Filter function threw: "+i.toString();return oe(Qi,n)}}function za(t){var e={},r=t.filter&&typeof t.filter=="function";return e.query=t.query_params,function(i){i.doc||(i.doc={});var s=r&&e0(t.filter,i.doc,e);if(typeof s=="object")return s;if(s)return!1;if(!t.include_docs)delete i.doc;else if(!t.attachments)for(var o in i.doc._attachments)Object.prototype.hasOwnProperty.call(i.doc._attachments,o)&&(i.doc._attachments[o].stub=!0);return!0}}function ph(t){var e;if(t?typeof t!="string"?e=oe(dh):/^_/.test(t)&&!/^_(design|local)/.test(t)&&(e=oe(Y_)):e=oe(Q_),e)throw e}function Rt(t){return typeof t._remote=="boolean"?t._remote:typeof t.type=="function"?(vt("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),t.type()==="http"):!1}function t0(t,e){return"listenerCount"in t?t.listenerCount(e):ut.listenerCount(t,e)}function Ea(t){if(!t)return null;var e=t.split("/");return e.length===2?e:e.length===1?[t,t]:null}function Dd(t){var e=Ea(t);return e?e.join("/"):null}var Bd=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],Ld="queryKey",r0=/(?:^|&)([^&=]*)=?([^&]*)/g,n0=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;function mh(t){for(var e=n0.exec(t),r={},n=14;n--;){var i=Bd[n],s=e[n]||"",o=["user","password"].indexOf(i)!==-1;r[i]=o?decodeURIComponent(s):s}return r[Ld]={},r[Bd[12]].replace(r0,function(a,c,d){c&&(r[Ld][c]=d)}),r}function Ka(t,e){var r=[],n=[];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r.push(i),n.push(e[i]));return r.push(t),Function.apply(null,r).apply(null,n)}function Ui(t,e,r){return t.get(e).catch(function(n){if(n.status!==404)throw n;return{}}).then(function(n){var i=n._rev,s=r(n);return s?(s._id=e,s._rev=i,i0(t,s,r)):{updated:!1,rev:i}})}function i0(t,e,r){return t.put(e).then(function(n){return{updated:!0,rev:n.rev}},function(n){if(n.status!==409)throw n;return Ui(t,e._id,r)})}var Va=function(t){return atob(t)},Dn=function(t){return btoa(t)};function Ja(t,e){t=t||[],e=e||{};try{return new Blob(t,e)}catch(s){if(s.name!=="TypeError")throw s;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,n=new r,i=0;i<t.length;i+=1)n.append(t[i]);return n.getBlob(e.type)}}function s0(t){for(var e=t.length,r=new ArrayBuffer(e),n=new Uint8Array(r),i=0;i<e;i++)n[i]=t.charCodeAt(i);return r}function Ha(t,e){return Ja([s0(t)],{type:e})}function Wa(t,e){return Ha(Va(t),e)}function o0(t){for(var e="",r=new Uint8Array(t),n=r.byteLength,i=0;i<n;i++)e+=String.fromCharCode(r[i]);return e}function vh(t,e){var r=new FileReader,n=typeof r.readAsBinaryString=="function";r.onloadend=function(i){var s=i.target.result||"";if(n)return e(s);e(o0(s))},n?r.readAsBinaryString(t):r.readAsArrayBuffer(t)}function yh(t,e){vh(t,function(r){e(r)})}function Qa(t,e){yh(t,function(r){e(Dn(r))})}function a0(t,e){var r=new FileReader;r.onloadend=function(n){var i=n.target.result||new ArrayBuffer(0);e(i)},r.readAsArrayBuffer(t)}var u0=self.setImmediate||self.setTimeout,c0=32768;function f0(t){return Dn(t)}function l0(t,e,r,n,i){(r>0||n<e.size)&&(e=e.slice(r,n)),a0(e,function(s){t.append(s),i()})}function d0(t,e,r,n,i){(r>0||n<e.length)&&(e=e.substring(r,n)),t.appendBinary(e),i()}function Ya(t,e){var r=typeof t=="string",n=r?t.length:t.size,i=Math.min(c0,n),s=Math.ceil(n/i),o=0,a=r?new Li.default:new Li.default.ArrayBuffer,c=r?d0:l0;function d(){u0(f)}function m(){var y=a.end(!0),_=f0(y);e(_),a.destroy()}function f(){var y=o*i,_=y+i;o++,o<s?c(a,t,y,_,d):c(a,t,y,_,m)}f()}function gh(t){return Li.default.hash(t)}function _h(t,e){if(!e)return qn().replace(/-/g,"").toLowerCase();var r=Object.assign({},t);return delete r._rev_tree,gh(JSON.stringify(r))}var Yi=qn;function br(t){for(var e,r,n,i=t.rev_tree.slice(),s;s=i.pop();){var o=s.ids,a=o[2],c=s.pos;if(a.length){for(var d=0,m=a.length;d<m;d++)i.push({pos:c+1,ids:a[d]});continue}var f=!!o[1].deleted,y=o[0];(!e||(n!==f?n:r!==c?r<c:e<y))&&(e=y,r=c,n=f)}return r+"-"+e}function Er(t,e){for(var r=t.slice(),n;n=r.pop();)for(var i=n.pos,s=n.ids,o=s[2],a=e(o.length===0,i,s[0],n.ctx,s[1]),c=0,d=o.length;c<d;c++)r.push({pos:i+1,ids:o[c],ctx:a})}function h0(t,e){return t.pos-e.pos}function Xa(t){var e=[];Er(t,function(i,s,o,a,c){i&&e.push({rev:s+"-"+o,pos:s,opts:c})}),e.sort(h0).reverse();for(var r=0,n=e.length;r<n;r++)delete e[r].pos;return e}function Za(t){for(var e=br(t),r=Xa(t.rev_tree),n=[],i=0,s=r.length;i<s;i++){var o=r[i];o.rev!==e&&!o.opts.deleted&&n.push(o.rev)}return n}function p0(t){var e=[];return Er(t.rev_tree,function(r,n,i,s,o){o.status==="available"&&!r&&(e.push(n+"-"+i),o.status="missing")}),e}function m0(t,e){let r=[],n=t.slice(),i;for(;i=n.pop();){let{pos:s,ids:o}=i,a=`${s}-${o[0]}`,c=o[2];if(r.push(a),a===e){if(c.length!==0)throw new Error("The requested revision is not a leaf");return r.reverse()}(c.length===0||c.length>1)&&(r=[]);for(let d=0,m=c.length;d<m;d++)n.push({pos:s+1,ids:c[d]})}if(r.length===0)throw new Error("The requested revision does not exist");return r.reverse()}function wh(t){for(var e=[],r=t.slice(),n;n=r.pop();){var i=n.pos,s=n.ids,o=s[0],a=s[1],c=s[2],d=c.length===0,m=n.history?n.history.slice():[];m.push({id:o,opts:a}),d&&e.push({pos:i+1-m.length,ids:m});for(var f=0,y=c.length;f<y;f++)r.push({pos:i+1,ids:c[f],history:m})}return e.reverse()}function v0(t,e){return t.pos-e.pos}function y0(t,e,r){for(var n=0,i=t.length,s;n<i;)s=n+i>>>1,r(t[s],e)<0?n=s+1:i=s;return n}function g0(t,e,r){var n=y0(t,e,r);t.splice(n,0,e)}function Md(t,e){for(var r,n,i=e,s=t.length;i<s;i++){var o=t[i],a=[o.id,o.opts,[]];n?(n[2].push(a),n=a):r=n=a}return r}function _0(t,e){return t[0]<e[0]?-1:1}function Ud(t,e){for(var r=[{tree1:t,tree2:e}],n=!1;r.length>0;){var i=r.pop(),s=i.tree1,o=i.tree2;(s[1].status||o[1].status)&&(s[1].status=s[1].status==="available"||o[1].status==="available"?"available":"missing");for(var a=0;a<o[2].length;a++){if(!s[2][0]){n="new_leaf",s[2][0]=o[2][a];continue}for(var c=!1,d=0;d<s[2].length;d++)s[2][d][0]===o[2][a][0]&&(r.push({tree1:s[2][d],tree2:o[2][a]}),c=!0);c||(n="new_branch",g0(s[2],o[2][a],_0))}}return{conflicts:n,tree:t}}function bh(t,e,r){var n=[],i=!1,s=!1,o;if(!t.length)return{tree:[e],conflicts:"new_leaf"};for(var a=0,c=t.length;a<c;a++){var d=t[a];if(d.pos===e.pos&&d.ids[0]===e.ids[0])o=Ud(d.ids,e.ids),n.push({pos:d.pos,ids:o.tree}),i=i||o.conflicts,s=!0;else if(r!==!0){var m=d.pos<e.pos?d:e,f=d.pos<e.pos?e:d,y=f.pos-m.pos,_=[],b=[];for(b.push({ids:m.ids,diff:y,parent:null,parentIdx:null});b.length>0;){var P=b.pop();if(P.diff===0){P.ids[0]===f.ids[0]&&_.push(P);continue}for(var S=P.ids[2],g=0,w=S.length;g<w;g++)b.push({ids:S[g],diff:P.diff-1,parent:P.ids,parentIdx:g})}var p=_[0];p?(o=Ud(p.ids,f.ids),p.parent[2][p.parentIdx]=o.tree,n.push({pos:m.pos,ids:m.ids}),i=i||o.conflicts,s=!0):n.push(d)}else n.push(d)}return s||n.push(e),n.sort(v0),{tree:n,conflicts:i||"internal_node"}}function w0(t,e){for(var r=wh(t),n,i,s=0,o=r.length;s<o;s++){var a=r[s],c=a.ids,d;if(c.length>e){n||(n={});var m=c.length-e;d={pos:a.pos+m,ids:Md(c,m)};for(var f=0;f<m;f++){var y=a.pos+f+"-"+c[f].id;n[y]=!0}}else d={pos:a.pos,ids:Md(c,0)};i?i=bh(i,d,!0).tree:i=[d]}return n&&Er(i,function(_,b,P){delete n[b+"-"+P]}),{tree:i,revs:n?Object.keys(n):[]}}function Eh(t,e,r){var n=bh(t,e),i=w0(n.tree,r);return{tree:i.tree,stemmedRevs:i.revs,conflicts:n.conflicts}}function b0(t,e){for(var r=t.slice(),n=e.split("-"),i=parseInt(n[0],10),s=n[1],o;o=r.pop();){if(o.pos===i&&o.ids[0]===s)return!0;for(var a=o.ids[2],c=0,d=a.length;c<d;c++)r.push({pos:o.pos+1,ids:a[c]})}return!1}function E0(t){return t.ids}function Ut(t,e){e||(e=br(t));for(var r=e.substring(e.indexOf("-")+1),n=t.rev_tree.map(E0),i;i=n.pop();){if(i[0]===r)return!!i[1].deleted;n=n.concat(i[2])}}function wr(t){return typeof t=="string"&&t.startsWith("_local/")}function $0(t,e){for(var r=e.rev_tree.slice(),n;n=r.pop();){var i=n.pos,s=n.ids,o=s[0],a=s[1],c=s[2],d=c.length===0,m=n.history?n.history.slice():[];if(m.push({id:o,pos:i,opts:a}),d)for(var f=0,y=m.length;f<y;f++){var _=m[f],b=_.pos+"-"+_.id;if(b===t)return i+"-"+o}for(var P=0,S=c.length;P<S;P++)r.push({pos:i+1,ids:c[P],history:m})}throw new Error("Unable to resolve latest revision for id "+e.id+", rev "+t)}function S0(t,e,r,n){try{t.emit("change",e,r,n)}catch(i){vt("error",'Error in .on("change", function):',i)}}function P0(t,e,r){var n=[{rev:t._rev}];r.style==="all_docs"&&(n=Xa(e.rev_tree).map(function(s){return{rev:s.rev}}));var i={id:e.id,changes:n,doc:t};return Ut(e,t._rev)&&(i.deleted=!0),r.conflicts&&(i.doc._conflicts=Za(e),i.doc._conflicts.length||delete i.doc._conflicts),i}var $a=class extends ut{constructor(e,r,n){super(),this.db=e,r=r?Ge(r):{};var i=r.complete=ch((a,c)=>{a?t0(this,"error")>0&&this.emit("error",a):this.emit("complete",c),this.removeAllListeners(),e.removeListener("destroyed",s)});n&&(this.on("complete",function(a){n(null,a)}),this.on("error",n));let s=()=>{this.cancel()};e.once("destroyed",s),r.onChange=(a,c,d)=>{this.isCancelled||S0(this,a,c,d)};var o=new Promise(function(a,c){r.complete=function(d,m){d?c(d):a(m)}});this.once("cancel",function(){e.removeListener("destroyed",s),r.complete(null,{status:"cancelled"})}),this.then=o.then.bind(o),this.catch=o.catch.bind(o),this.then(function(a){i(null,a)},i),e.taskqueue.isReady?this.validateChanges(r):e.taskqueue.addTask(a=>{a?r.complete(a):this.isCancelled?this.emit("cancel"):this.validateChanges(r)})}cancel(){this.isCancelled=!0,this.db.taskqueue.isReady&&this.emit("cancel")}validateChanges(e){var r=e.complete;ae._changesFilterPlugin?ae._changesFilterPlugin.validate(e,n=>{if(n)return r(n);this.doChanges(e)}):this.doChanges(e)}doChanges(e){var r=e.complete;if(e=Ge(e),"live"in e&&!("continuous"in e)&&(e.continuous=e.live),e.processChange=P0,e.since==="latest"&&(e.since="now"),e.since||(e.since=0),e.since==="now"){this.db.info().then(i=>{if(this.isCancelled){r(null,{status:"cancelled"});return}e.since=i.update_seq,this.doChanges(e)},r);return}if(ae._changesFilterPlugin){if(ae._changesFilterPlugin.normalize(e),ae._changesFilterPlugin.shouldFilter(this,e))return ae._changesFilterPlugin.filter(this,e)}else["doc_ids","filter","selector","view"].forEach(function(i){i in e&&vt("warn",'The "'+i+'" option was passed in to changes/replicate, but pouchdb-changes-filter plugin is not installed, so it was ignored. Please install the plugin to enable filtering.')});"descending"in e||(e.descending=!1),e.limit=e.limit===0?1:e.limit,e.complete=r;var n=this.db._changes(e);if(n&&typeof n.cancel=="function"){let i=this.cancel;this.cancel=(...s)=>{n.cancel(),i.apply(this,s)}}}};function aa(t,e){return function(r,n){r||n[0]&&n[0].error?(r=r||n[0],r.docId=e,t(r)):t(null,n.length?n[0]:n)}}function O0(t){for(var e=0;e<t.length;e++){var r=t[e];if(r._deleted)delete r._attachments;else if(r._attachments)for(var n=Object.keys(r._attachments),i=0;i<n.length;i++){var s=n[i];r._attachments[s]=jn(r._attachments[s],["data","digest","content_type","length","revpos","stub"])}}}function A0(t,e){if(t._id===e._id){let r=t._revisions?t._revisions.start:0,n=e._revisions?e._revisions.start:0;return r-n}return t._id<e._id?-1:1}function I0(t){var e={},r=[];return Er(t,function(n,i,s,o){var a=i+"-"+s;return n&&(e[a]=0),o!==void 0&&r.push({from:o,to:a}),a}),r.reverse(),r.forEach(function(n){e[n.from]===void 0?e[n.from]=1+e[n.to]:e[n.from]=Math.min(e[n.from],1+e[n.to])}),e}function T0(t){var e="limit"in t?t.keys.slice(t.skip,t.limit+t.skip):t.skip>0?t.keys.slice(t.skip):t.keys;t.keys=e,t.skip=0,delete t.limit,t.descending&&(e.reverse(),t.descending=!1)}function $h(t){var e=t._compactionQueue[0],r=e.opts,n=e.callback;t.get("_local/compaction").catch(function(){return!1}).then(function(i){i&&i.last_seq&&(r.last_seq=i.last_seq),t._compact(r,function(s,o){s?n(s):n(null,o),qt(function(){t._compactionQueue.shift(),t._compactionQueue.length&&$h(t)})})})}function R0(t,e,r){return t.get("_local/purges").then(function(n){let i=n.purgeSeq+1;return n.purges.push({docId:e,rev:r,purgeSeq:i}),n.purges.length>self.purged_infos_limit&&n.purges.splice(0,n.purges.length-self.purged_infos_limit),n.purgeSeq=i,n}).catch(function(n){if(n.status!==404)throw n;return{_id:"_local/purges",purges:[{docId:e,rev:r,purgeSeq:0}],purgeSeq:0}}).then(function(n){return t.put(n)})}function q0(t){return t.charAt(0)==="_"?t+" is not a valid attachment name, attachment names cannot start with '_'":!1}function ua(t){return t===null||typeof t!="object"||Array.isArray(t)}var k0=/^\d+-[^-]*$/;function ca(t){return typeof t=="string"&&k0.test(t)}var Gi=class extends ut{_setup(){this.post=De("post",function(e,r,n){if(typeof r=="function"&&(n=r,r={}),ua(e))return n(oe(oa));this.bulkDocs({docs:[e]},r,aa(n,e._id))}).bind(this),this.put=De("put",function(e,r,n){if(typeof r=="function"&&(n=r,r={}),ua(e))return n(oe(oa));if(ph(e._id),"_rev"in e&&!ca(e._rev))return n(oe(Di));if(wr(e._id)&&typeof this._putLocal=="function")return e._deleted?this._removeLocal(e,n):this._putLocal(e,n);let i=o=>{typeof this._put=="function"&&r.new_edits!==!1?this._put(e,r,o):this.bulkDocs({docs:[e]},r,aa(o,e._id))};r.force&&e._rev?(s(),i(function(o){var a=o?null:{ok:!0,id:e._id,rev:e._rev};n(o,a)})):i(n);function s(){var o=e._rev.split("-"),a=o[1],c=parseInt(o[0],10),d=c+1,m=_h();e._revisions={start:d,ids:[m,a]},e._rev=d+"-"+m,r.new_edits=!1}}).bind(this),this.putAttachment=De("putAttachment",function(e,r,n,i,s){var o=this;typeof s=="function"&&(s=i,i=n,n=null),typeof s>"u"&&(s=i,i=n,n=null),s||vt("warn","Attachment",r,"on document",e,"is missing content_type");function a(c){var d="_rev"in c?parseInt(c._rev,10):0;return c._attachments=c._attachments||{},c._attachments[r]={content_type:s,data:i,revpos:++d},o.put(c)}return o.get(e).then(function(c){if(c._rev!==n)throw oe(Vr);return a(c)},function(c){if(c.reason===pt.message)return a({_id:e});throw c})}).bind(this),this.removeAttachment=De("removeAttachment",function(e,r,n,i){this.get(e,(s,o)=>{if(s){i(s);return}if(o._rev!==n){i(oe(Vr));return}if(!o._attachments)return i();delete o._attachments[r],Object.keys(o._attachments).length===0&&delete o._attachments,this.put(o,i)})}).bind(this),this.remove=De("remove",function(e,r,n,i){var s;typeof r=="string"?(s={_id:e,_rev:r},typeof n=="function"&&(i=n,n={})):(s=e,typeof r=="function"?(i=r,n={}):(i=n,n=r)),n=n||{},n.was_delete=!0;var o={_id:s._id,_rev:s._rev||n.rev};if(o._deleted=!0,wr(o._id)&&typeof this._removeLocal=="function")return this._removeLocal(s,i);this.bulkDocs({docs:[o]},n,aa(i,o._id))}).bind(this),this.revsDiff=De("revsDiff",function(e,r,n){typeof r=="function"&&(n=r,r={});var i=Object.keys(e);if(!i.length)return n(null,{});var s=0,o=new Map;function a(d,m){o.has(d)||o.set(d,{missing:[]}),o.get(d).missing.push(m)}function c(d,m){var f=e[d].slice(0);Er(m,function(y,_,b,P,S){var g=_+"-"+b,w=f.indexOf(g);w!==-1&&(f.splice(w,1),S.status!=="available"&&a(d,g))}),f.forEach(function(y){a(d,y)})}i.forEach(function(d){this._getRevisionTree(d,function(m,f){if(m&&m.status===404&&m.message==="missing")o.set(d,{missing:e[d]});else{if(m)return n(m);c(d,f)}if(++s===i.length){var y={};return o.forEach(function(_,b){y[b]=_}),n(null,y)}})},this)}).bind(this),this.bulkGet=De("bulkGet",function(e,r){lh(this,e,r)}).bind(this),this.compactDocument=De("compactDocument",function(e,r,n){this._getRevisionTree(e,(i,s)=>{if(i)return n(i);var o=I0(s),a=[],c=[];Object.keys(o).forEach(function(d){o[d]>r&&a.push(d)}),Er(s,function(d,m,f,y,_){var b=m+"-"+f;_.status==="available"&&a.indexOf(b)!==-1&&c.push(b)}),this._doCompaction(e,c,n)})}).bind(this),this.compact=De("compact",function(e,r){typeof e=="function"&&(r=e,e={}),e=e||{},this._compactionQueue=this._compactionQueue||[],this._compactionQueue.push({opts:e,callback:r}),this._compactionQueue.length===1&&$h(this)}).bind(this),this.get=De("get",function(e,r,n){if(typeof r=="function"&&(n=r,r={}),r=r||{},typeof e!="string")return n(oe(dh));if(wr(e)&&typeof this._getLocal=="function")return this._getLocal(e,n);var i=[];let s=()=>{var c=[],d=i.length;if(!d)return n(null,c);i.forEach(m=>{this.get(e,{rev:m,revs:r.revs,latest:r.latest,attachments:r.attachments,binary:r.binary},function(f,y){if(f)c.push({missing:m});else{for(var _,b=0,P=c.length;b<P;b++)if(c[b].ok&&c[b].ok._rev===y._rev){_=!0;break}_||c.push({ok:y})}d--,d||n(null,c)})})};if(r.open_revs){if(r.open_revs==="all")this._getRevisionTree(e,function(c,d){if(c)return n(c);i=Xa(d).map(function(m){return m.rev}),s()});else if(Array.isArray(r.open_revs)){i=r.open_revs;for(var o=0;o<i.length;o++){var a=i[o];if(!ca(a))return n(oe(Di))}s()}else return n(oe(Ga,"function_clause"));return}return this._get(e,r,(c,d)=>{if(c)return c.docId=e,n(c);var m=d.doc,f=d.metadata,y=d.ctx;if(r.conflicts){var _=Za(f);_.length&&(m._conflicts=_)}if(Ut(f,m._rev)&&(m._deleted=!0),r.revs||r.revs_info){for(var b=m._rev.split("-"),P=parseInt(b[0],10),S=b[1],g=wh(f.rev_tree),w=null,p=0;p<g.length;p++){var h=g[p];let Q=h.ids.findIndex(Z=>Z.id===S);var v=Q===P-1;(v||!w&&Q!==-1)&&(w=h)}if(!w)return c=new Error("invalid rev tree"),c.docId=e,n(c);let H=m._rev.split("-")[1],re=w.ids.findIndex(Q=>Q.id===H)+1;var E=w.ids.length-re;if(w.ids.splice(re,E),w.ids.reverse(),r.revs&&(m._revisions={start:w.pos+w.ids.length-1,ids:w.ids.map(function(Q){return Q.id})}),r.revs_info){var k=w.pos+w.ids.length;m._revs_info=w.ids.map(function(Q){return k--,{rev:k+"-"+Q.id,status:Q.opts.status}})}}if(r.attachments&&m._attachments){var x=m._attachments,j=Object.keys(x).length;if(j===0)return n(null,m);Object.keys(x).forEach(H=>{this._getAttachment(m._id,H,x[H],{binary:r.binary,metadata:f,ctx:y},function(re,Q){var Z=m._attachments[H];Z.data=Q,delete Z.stub,delete Z.length,--j||n(null,m)})})}else{if(m._attachments)for(var G in m._attachments)Object.prototype.hasOwnProperty.call(m._attachments,G)&&(m._attachments[G].stub=!0);n(null,m)}})}).bind(this),this.getAttachment=De("getAttachment",function(e,r,n,i){n instanceof Function&&(i=n,n={}),this._get(e,n,(s,o)=>{if(s)return i(s);if(o.doc._attachments&&o.doc._attachments[r])n.ctx=o.ctx,n.binary=!0,n.metadata=o.metadata,this._getAttachment(e,r,o.doc._attachments[r],n,i);else return i(oe(pt))})}).bind(this),this.allDocs=De("allDocs",function(e,r){if(typeof e=="function"&&(r=e,e={}),e.skip=typeof e.skip<"u"?e.skip:0,e.start_key&&(e.startkey=e.start_key),e.end_key&&(e.endkey=e.end_key),"keys"in e){if(!Array.isArray(e.keys))return r(new TypeError("options.keys must be an array"));var n=["startkey","endkey","key"].filter(function(i){return i in e})[0];if(n){r(oe(X_,"Query parameter `"+n+"` is not compatible with multi-get"));return}if(!Rt(this)&&(T0(e),e.keys.length===0))return this._allDocs({limit:0},r)}return this._allDocs(e,r)}).bind(this),this.close=De("close",function(e){return this._closed=!0,this.emit("closed"),this._close(e)}).bind(this),this.info=De("info",function(e){this._info((r,n)=>{if(r)return e(r);n.db_name=n.db_name||this.name,n.auto_compaction=!!(this.auto_compaction&&!Rt(this)),n.adapter=this.adapter,e(null,n)})}).bind(this),this.id=De("id",function(e){return this._id(e)}).bind(this),this.bulkDocs=De("bulkDocs",function(e,r,n){if(typeof r=="function"&&(n=r,r={}),r=r||{},Array.isArray(e)&&(e={docs:e}),!e||!e.docs||!Array.isArray(e.docs))return n(oe(W_));for(var i=0;i<e.docs.length;++i){let c=e.docs[i];if(ua(c))return n(oe(oa));if("_rev"in c&&!ca(c._rev))return n(oe(Di))}var s;if(e.docs.forEach(function(c){c._attachments&&Object.keys(c._attachments).forEach(function(d){s=s||q0(d),c._attachments[d].content_type||vt("warn","Attachment",d,"on document",c._id,"is missing content_type")})}),s)return n(oe(Qi,s));"new_edits"in r||("new_edits"in e?r.new_edits=e.new_edits:r.new_edits=!0);var o=this;!r.new_edits&&!Rt(o)&&e.docs.sort(A0),O0(e.docs);var a=e.docs.map(function(c){return c._id});this._bulkDocs(e,r,function(c,d){if(c)return n(c);if(r.new_edits||(d=d.filter(function(y){return y.error})),!Rt(o))for(var m=0,f=d.length;m<f;m++)d[m].id=d[m].id||a[m];n(null,d)})}).bind(this),this.registerDependentDatabase=De("registerDependentDatabase",function(e,r){var n=Ge(this.__opts);this.__opts.view_adapter&&(n.adapter=this.__opts.view_adapter);var i=new this.constructor(e,n);function s(o){return o.dependentDbs=o.dependentDbs||{},o.dependentDbs[e]?!1:(o.dependentDbs[e]=!0,o)}Ui(this,"_local/_pouch_dependentDbs",s).then(function(){r(null,{db:i})}).catch(r)}).bind(this),this.destroy=De("destroy",function(e,r){typeof e=="function"&&(r=e,e={});var n="use_prefix"in this?this.use_prefix:!0;let i=()=>{this._destroy(e,(s,o)=>{if(s)return r(s);this._destroyed=!0,this.emit("destroyed"),r(null,o||{ok:!0})})};if(Rt(this))return i();this.get("_local/_pouch_dependentDbs",(s,o)=>{if(s)return s.status!==404?r(s):i();var a=o.dependentDbs,c=this.constructor,d=Object.keys(a).map(m=>{var f=n?m.replace(new RegExp("^"+c.prefix),""):m;return new c(f,this.__opts).destroy()});Promise.all(d).then(i,r)})}).bind(this)}_compact(e,r){var n={return_docs:!1,last_seq:e.last_seq||0,since:e.last_seq||0},i=[],s,o=0;let a=m=>{this.activeTasks.update(s,{completed_items:++o}),i.push(this.compactDocument(m.id,0))},c=m=>{this.activeTasks.remove(s,m),r(m)},d=m=>{var f=m.last_seq;Promise.all(i).then(()=>Ui(this,"_local/compaction",y=>!y.last_seq||y.last_seq<f?(y.last_seq=f,y):!1)).then(()=>{this.activeTasks.remove(s),r(null,{ok:!0})}).catch(c)};this.info().then(m=>{s=this.activeTasks.add({name:"database_compaction",total_items:m.update_seq-n.last_seq}),this.changes(n).on("change",a).on("complete",d).on("error",c)})}changes(e,r){return typeof e=="function"&&(r=e,e={}),e=e||{},e.return_docs="return_docs"in e?e.return_docs:!e.live,new $a(this,e,r)}type(){return typeof this._type=="function"?this._type():this.adapter}};Gi.prototype.purge=De("_purge",function(t,e,r){if(typeof this._purge>"u")return r(oe(Ga,"Purge is not implemented in the "+this.adapter+" adapter."));var n=this;n._getRevisionTree(t,(i,s)=>{if(i)return r(i);if(!s)return r(oe(pt));let o;try{o=m0(s,e)}catch(a){return r(a.message||a)}n._purge(t,o,(a,c)=>{if(a)return r(a);R0(n,t,e).then(function(){return r(null,c)})})})});var Sa=class{constructor(){this.isReady=!1,this.failed=!1,this.queue=[]}execute(){var e;if(this.failed)for(;e=this.queue.shift();)e(this.failed);else for(;e=this.queue.shift();)e()}fail(e){this.failed=e,this.execute()}ready(e){this.isReady=!0,this.db=e,this.execute()}addTask(e){this.queue.push(e),this.failed&&this.execute()}};function C0(t,e){var r=t.match(/([a-z-]*):\/\/(.*)/);if(r)return{name:/https?/.test(r[1])?r[1]+"://"+r[2]:r[2],adapter:r[1]};var n=ae.adapters,i=ae.preferredAdapters,s=ae.prefix,o=e.adapter;if(!o)for(var a=0;a<i.length;++a){if(o=i[a],o==="idb"&&"websql"in n&&Mi()&&localStorage["_pouch__websqldb_"+s+t]){vt("log",'PouchDB is downgrading "'+t+'" to WebSQL to avoid data loss, because it was already opened with WebSQL.');continue}break}var c=n[o],d=c&&"use_prefix"in c?c.use_prefix:!0;return{name:d?s+t:t,adapter:o}}function x0(t,e){t.prototype=Object.create(e.prototype,{constructor:{value:t}})}function Sh(t,e){let r=function(...n){if(!(this instanceof r))return new r(...n);e.apply(this,n)};return x0(r,t),r}function N0(t){function e(n){t.removeListener("closed",r),n||t.constructor.emit("destroyed",t.name)}function r(){t.removeListener("destroyed",e),t.constructor.emit("unref",t)}t.once("destroyed",e),t.once("closed",r),t.constructor.emit("ref",t)}var Fi=class extends Gi{constructor(e,r){super(),this._setup(e,r)}_setup(e,r){if(super._setup(),r=r||{},e&&typeof e=="object"&&(r=e,e=r.name,delete r.name),r.deterministic_revs===void 0&&(r.deterministic_revs=!0),this.__opts=r=Ge(r),this.auto_compaction=r.auto_compaction,this.purged_infos_limit=r.purged_infos_limit||1e3,this.prefix=ae.prefix,typeof e!="string")throw new Error("Missing/invalid DB name");var n=(r.prefix||"")+e,i=C0(n,r);if(r.name=i.name,r.adapter=r.adapter||i.adapter,this.name=e,this._adapter=r.adapter,ae.emit("debug",["adapter","Picked adapter: ",r.adapter]),!ae.adapters[r.adapter]||!ae.adapters[r.adapter].valid())throw new Error("Invalid Adapter: "+r.adapter);if(r.view_adapter&&(!ae.adapters[r.view_adapter]||!ae.adapters[r.view_adapter].valid()))throw new Error("Invalid View Adapter: "+r.view_adapter);this.taskqueue=new Sa,this.adapter=r.adapter,ae.adapters[r.adapter].call(this,r,s=>{if(s)return this.taskqueue.fail(s);N0(this),this.emit("created",this),ae.emit("created",this.name),this.taskqueue.ready(this)})}},ae=Sh(Fi,function(t,e){Fi.prototype._setup.call(this,t,e)}),Ph=fetch,zr=Headers,Pa=class{constructor(){this.tasks={}}list(){return Object.values(this.tasks)}add(e){let r=qn();return this.tasks[r]={id:r,name:e.name,total_items:e.total_items,created_at:new Date().toJSON()},r}get(e){return this.tasks[e]}remove(e,r){return delete this.tasks[e],this.tasks}update(e,r){let n=this.tasks[e];if(typeof n<"u"){let i={id:n.id,name:n.name,created_at:n.created_at,total_items:r.total_items||n.total_items,completed_items:r.completed_items||n.completed_items,updated_at:new Date().toJSON()};this.tasks[e]=i}return this.tasks}};ae.adapters={};ae.preferredAdapters=[];ae.prefix="_pouch_";var Gd=new ut;function j0(t){Object.keys(ut.prototype).forEach(function(r){typeof ut.prototype[r]=="function"&&(t[r]=Gd[r].bind(Gd))});var e=t._destructionListeners=new Map;t.on("ref",function(n){e.has(n.name)||e.set(n.name,[]),e.get(n.name).push(n)}),t.on("unref",function(n){if(e.has(n.name)){var i=e.get(n.name),s=i.indexOf(n);s<0||(i.splice(s,1),i.length>1?e.set(n.name,i):e.delete(n.name))}}),t.on("destroyed",function(n){if(e.has(n)){var i=e.get(n);e.delete(n),i.forEach(function(s){s.emit("destroyed",!0)})}})}j0(ae);ae.adapter=function(t,e,r){e.valid()&&(ae.adapters[t]=e,r&&ae.preferredAdapters.push(t))};ae.plugin=function(t){if(typeof t=="function")t(ae);else{if(typeof t!="object"||Object.keys(t).length===0)throw new Error('Invalid plugin: got "'+t+'", expected an object or a function');Object.keys(t).forEach(function(e){ae.prototype[e]=t[e]})}return this.__defaults&&(ae.__defaults=Object.assign({},this.__defaults)),ae};ae.defaults=function(t){let e=Sh(ae,function(r,n){n=n||{},r&&typeof r=="object"&&(n=r,r=n.name,delete n.name),n=Object.assign({},e.__defaults,n),ae.call(this,r,n)});return e.preferredAdapters=ae.preferredAdapters.slice(),Object.keys(ae).forEach(function(r){r in e||(e[r]=ae[r])}),e.__defaults=Object.assign({},this.__defaults,t),e};ae.fetch=function(t,e){return Ph(t,e)};ae.prototype.activeTasks=ae.activeTasks=new Pa;var D0="9.0.0";function eu(t,e){for(var r=t,n=0,i=e.length;n<i;n++){var s=e[n];if(r=r[s],!r)break}return r}function B0(t,e){return t<e?-1:t>e?1:0}function tu(t){for(var e=[],r="",n=0,i=t.length;n<i;n++){var s=t[n];n>0&&t[n-1]==="\\"&&(s==="$"||s===".")?r=r.substring(0,r.length-1)+s:s==="."?(e.push(r),r=""):r+=s}return e.push(r),e}var L0=["$or","$nor","$not"];function Oh(t){return L0.indexOf(t)>-1}function Ah(t){return Object.keys(t)[0]}function M0(t){return t[Ah(t)]}function xn(t){var e={},r={$or:!0,$nor:!0};return t.forEach(function(n){Object.keys(n).forEach(function(i){var s=n[i];if(typeof s!="object"&&(s={$eq:s}),Oh(i))if(s instanceof Array){if(r[i]){r[i]=!1,e[i]=s;return}var o=[];e[i].forEach(function(c){Object.keys(s).forEach(function(d){var m=s[d],f=Math.max(Object.keys(c).length,Object.keys(m).length),y=xn([c,m]);Object.keys(y).length<=f||o.push(y)})}),e[i]=o}else e[i]=xn([s]);else{var a=e[i]=e[i]||{};Object.keys(s).forEach(function(c){var d=s[c];if(c==="$gt"||c==="$gte")return U0(c,d,a);if(c==="$lt"||c==="$lte")return G0(c,d,a);if(c==="$ne")return F0(d,a);if(c==="$eq")return z0(d,a);if(c==="$regex")return K0(d,a);a[c]=d})}})}),e}function U0(t,e,r){typeof r.$eq<"u"||(typeof r.$gte<"u"?t==="$gte"?e>r.$gte&&(r.$gte=e):e>=r.$gte&&(delete r.$gte,r.$gt=e):typeof r.$gt<"u"?t==="$gte"?e>r.$gt&&(delete r.$gt,r.$gte=e):e>r.$gt&&(r.$gt=e):r[t]=e)}function G0(t,e,r){typeof r.$eq<"u"||(typeof r.$lte<"u"?t==="$lte"?e<r.$lte&&(r.$lte=e):e<=r.$lte&&(delete r.$lte,r.$lt=e):typeof r.$lt<"u"?t==="$lte"?e<r.$lt&&(delete r.$lt,r.$lte=e):e<r.$lt&&(r.$lt=e):r[t]=e)}function F0(t,e){"$ne"in e?e.$ne.push(t):e.$ne=[t]}function z0(t,e){delete e.$gt,delete e.$gte,delete e.$lt,delete e.$lte,delete e.$ne,e.$eq=t}function K0(t,e){"$regex"in e?e.$regex.push(t):e.$regex=[t]}function Ih(t){for(var e in t){if(Array.isArray(t))for(var r in t)t[r].$and&&(t[r]=xn(t[r].$and));var n=t[e];typeof n=="object"&&Ih(n)}return t}function Th(t,e){for(var r in t){r==="$and"&&(e=!0);var n=t[r];typeof n=="object"&&(e=Th(n,e))}return e}function V0(t){var e=Ge(t);Th(e,!1)&&(e=Ih(e),"$and"in e&&(e=xn(e.$and))),["$or","$nor"].forEach(function(o){o in e&&e[o].forEach(function(a){for(var c=Object.keys(a),d=0;d<c.length;d++){var m=c[d],f=a[m];(typeof f!="object"||f===null)&&(a[m]={$eq:f})}})}),"$not"in e&&(e.$not=xn([e.$not]));for(var r=Object.keys(e),n=0;n<r.length;n++){var i=r[n],s=e[i];(typeof s!="object"||s===null)&&(s={$eq:s}),e[i]=s}return Oa(e),e}function Oa(t){Object.keys(t).forEach(function(e){var r=t[e];Array.isArray(r)?r.forEach(function(n){n&&typeof n=="object"&&Oa(n)}):e==="$ne"?t.$ne=[r]:e==="$regex"?t.$regex=[r]:r&&typeof r=="object"&&Oa(r)})}function J0(t,e,r){for(var n="",i=r-t.length;n.length<i;)n+=e;return n}function H0(t,e,r){var n=J0(t,e,r);return n+t}var Rh=-324,Aa=3,Ia="";function Be(t,e){if(t===e)return 0;t=$r(t),e=$r(e);var r=Ta(t),n=Ta(e);if(r-n!==0)return r-n;switch(typeof t){case"number":return t-e;case"boolean":return t<e?-1:1;case"string":return ew(t,e)}return Array.isArray(t)?Z0(t,e):tw(t,e)}function $r(t){switch(typeof t){case"undefined":return null;case"number":return t===1/0||t===-1/0||isNaN(t)?null:t;case"object":var e=t;if(Array.isArray(t)){var r=t.length;t=new Array(r);for(var n=0;n<r;n++)t[n]=$r(e[n])}else{if(t instanceof Date)return t.toJSON();if(t!==null){t={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var s=e[i];typeof s<"u"&&(t[i]=$r(s))}}}}return t}function W0(t){if(t!==null)switch(typeof t){case"boolean":return t?1:0;case"number":return rw(t);case"string":return t.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var e=Array.isArray(t),r=e?t:Object.keys(t),n=-1,i=r.length,s="";if(e)for(;++n<i;)s+=Et(r[n]);else for(;++n<i;){var o=r[n];s+=Et(o)+Et(t[o])}return s}return""}function Et(t){var e="\0";return t=$r(t),Ta(t)+Ia+W0(t)+e}function Q0(t,e){var r=e,n,i=t[e]==="1";if(i)n=0,e++;else{var s=t[e]==="0";e++;var o="",a=t.substring(e,e+Aa),c=parseInt(a,10)+Rh;for(s&&(c=-c),e+=Aa;;){var d=t[e];if(d==="\0")break;o+=d,e++}o=o.split("."),o.length===1?n=parseInt(o,10):n=parseFloat(o[0]+"."+o[1]),s&&(n=n-10),c!==0&&(n=parseFloat(n+"e"+c))}return{num:n,length:e-r}}function Y0(t,e){var r=t.pop();if(e.length){var n=e[e.length-1];r===n.element&&(e.pop(),n=e[e.length-1]);var i=n.element,s=n.index;if(Array.isArray(i))i.push(r);else if(s===t.length-2){var o=t.pop();i[o]=r}else t.push(r)}}function X0(t){for(var e=[],r=[],n=0;;){var i=t[n++];if(i==="\0"){if(e.length===1)return e.pop();Y0(e,r);continue}switch(i){case"1":e.push(null);break;case"2":e.push(t[n]==="1"),n++;break;case"3":var s=Q0(t,n);e.push(s.num),n+=s.length;break;case"4":for(var o="";;){var a=t[n];if(a==="\0")break;o+=a,n++}o=o.replace(/\u0001\u0001/g,"\0").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),e.push(o);break;case"5":var c={element:[],index:e.length};e.push(c.element),r.push(c);break;case"6":var d={element:{},index:e.length};e.push(d.element),r.push(d);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+i)}}}function Z0(t,e){for(var r=Math.min(t.length,e.length),n=0;n<r;n++){var i=Be(t[n],e[n]);if(i!==0)return i}return t.length===e.length?0:t.length>e.length?1:-1}function ew(t,e){return t===e?0:t>e?1:-1}function tw(t,e){for(var r=Object.keys(t),n=Object.keys(e),i=Math.min(r.length,n.length),s=0;s<i;s++){var o=Be(r[s],n[s]);if(o!==0||(o=Be(t[r[s]],e[n[s]]),o!==0))return o}return r.length===n.length?0:r.length>n.length?1:-1}function Ta(t){var e=["boolean","number","string","object"],r=e.indexOf(typeof t);if(~r)return t===null?1:Array.isArray(t)?5:r<3?r+2:r+3;if(Array.isArray(t))return 5}function rw(t){if(t===0)return"1";var e=t.toExponential().split(/e\+?/),r=parseInt(e[1],10),n=t<0,i=n?"0":"2",s=(n?-r:r)-Rh,o=H0(s.toString(),"0",Aa);i+=Ia+o;var a=Math.abs(parseFloat(e[0]));n&&(a=10-a);var c=a.toFixed(20);return c=c.replace(/\.?0+$/,""),i+=Ia+c,i}function nw(t){function e(r){return t.map(function(n){var i=Ah(n),s=tu(i),o=eu(r,s);return o})}return function(r,n){var i=e(r.doc),s=e(n.doc),o=Be(i,s);return o!==0?o:B0(r.doc._id,n.doc._id)}}function iw(t,e,r){if(t=t.filter(function(o){return Kr(o.doc,e.selector,r)}),e.sort){var n=nw(e.sort);t=t.sort(n),typeof e.sort[0]!="string"&&M0(e.sort[0])==="desc"&&(t=t.reverse())}if("limit"in e||"skip"in e){var i=e.skip||0,s=("limit"in e?e.limit:t.length)+i;t=t.slice(i,s)}return t}function Kr(t,e,r){return r.every(function(n){var i=e[n],s=tu(n),o=eu(t,s);return Oh(n)?sw(n,i,t):zi(i,t,s,o)})}function zi(t,e,r,n){return t?typeof t=="object"?Object.keys(t).every(function(i){var s=t[i];if(i.indexOf("$")===0)return Fd(i,e,s,r,n);var o=tu(i);if(n===void 0&&typeof s!="object"&&o.length>0)return!1;var a=eu(n,o);return typeof s=="object"?zi(s,e,r,a):Fd("$eq",e,s,o,a)}):t===n:!0}function sw(t,e,r){return t==="$or"?e.some(function(n){return Kr(r,n,Object.keys(n))}):t==="$not"?!Kr(r,e,Object.keys(e)):!e.find(function(n){return Kr(r,n,Object.keys(n))})}function Fd(t,e,r,n,i){if(!Kd[t])throw new Error('unknown operator "'+t+'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all');return Kd[t](e,r,n,i)}function kn(t){return typeof t<"u"&&t!==null}function mr(t){return typeof t<"u"}function ow(t,e){if(typeof t!="number"||parseInt(t,10)!==t)return!1;var r=e[0],n=e[1];return t%r===n}function zd(t,e){return e.some(function(r){return t instanceof Array?t.some(function(n){return Be(r,n)===0}):Be(r,t)===0})}function aw(t,e){return e.every(function(r){return t.some(function(n){return Be(r,n)===0})})}function uw(t,e){return t.length===e}function cw(t,e){var r=new RegExp(e);return r.test(t)}function fw(t,e){switch(e){case"null":return t===null;case"boolean":return typeof t=="boolean";case"number":return typeof t=="number";case"string":return typeof t=="string";case"array":return t instanceof Array;case"object":return{}.toString.call(t)==="[object Object]"}}var Kd={$elemMatch:function(t,e,r,n){return!Array.isArray(n)||n.length===0?!1:typeof n[0]=="object"&&n[0]!==null?n.some(function(i){return Kr(i,e,Object.keys(e))}):n.some(function(i){return zi(e,t,r,i)})},$allMatch:function(t,e,r,n){return!Array.isArray(n)||n.length===0?!1:typeof n[0]=="object"&&n[0]!==null?n.every(function(i){return Kr(i,e,Object.keys(e))}):n.every(function(i){return zi(e,t,r,i)})},$eq:function(t,e,r,n){return mr(n)&&Be(n,e)===0},$gte:function(t,e,r,n){return mr(n)&&Be(n,e)>=0},$gt:function(t,e,r,n){return mr(n)&&Be(n,e)>0},$lte:function(t,e,r,n){return mr(n)&&Be(n,e)<=0},$lt:function(t,e,r,n){return mr(n)&&Be(n,e)<0},$exists:function(t,e,r,n){return e?mr(n):!mr(n)},$mod:function(t,e,r,n){return kn(n)&&ow(n,e)},$ne:function(t,e,r,n){return e.every(function(i){return Be(n,i)!==0})},$in:function(t,e,r,n){return kn(n)&&zd(n,e)},$nin:function(t,e,r,n){return kn(n)&&!zd(n,e)},$size:function(t,e,r,n){return kn(n)&&Array.isArray(n)&&uw(n,e)},$all:function(t,e,r,n){return Array.isArray(n)&&aw(n,e)},$regex:function(t,e,r,n){return kn(n)&&typeof n=="string"&&e.every(function(i){return cw(n,i)})},$type:function(t,e,r,n){return fw(n,e)}};function lw(t,e){if(typeof e!="object")throw new Error("Selector error: expected a JSON object");e=V0(e);var r={doc:t},n=iw([r],{selector:e},Object.keys(e));return n&&n.length===1}function dw(t){return Ka(`"use strict";
12
12
  return `+t+";",{})}function hw(t){var e=["return function(doc) {",' "use strict";'," var emitted = false;"," var emit = function (a, b) {"," emitted = true;"," };"," var view = "+t+";"," view(doc);"," if (emitted) {"," return true;"," }","};"].join(`
13
- `);return Ka(e,{})}function pw(t,e){if(t.selector&&t.filter&&t.filter!=="_selector"){var r=typeof t.filter=="string"?t.filter:"function";return e(new Error('selector invalid for filter "'+r+'"'))}e()}function mw(t){t.view&&!t.filter&&(t.filter="_view"),t.selector&&!t.filter&&(t.filter="_selector"),t.filter&&typeof t.filter=="string"&&(t.filter==="_view"?t.view=Dd(t.view):t.filter=Dd(t.filter))}function vw(t,e){return e.filter&&typeof e.filter=="string"&&!e.doc_ids&&!Rt(t.db)}function yw(t,e){var r=e.complete;if(e.filter==="_view"){if(!e.view||typeof e.view!="string"){var n=oe(Qi,"`view` filter parameter not found or invalid.");return r(n)}var i=Ea(e.view);t.db.get("_design/"+i[0],function(o,a){if(t.isCancelled)return r(null,{status:"cancelled"});if(o)return r(Jr(o));var c=a&&a.views&&a.views[i[1]]&&a.views[i[1]].map;if(!c)return r(oe(pt,a.views?"missing json key: "+i[1]:"missing json key: views"));e.filter=hw(c),t.doChanges(e)})}else if(e.selector)e.filter=function(o){return lw(o,e.selector)},t.doChanges(e);else{var s=Ea(e.filter);t.db.get("_design/"+s[0],function(o,a){if(t.isCancelled)return r(null,{status:"cancelled"});if(o)return r(Jr(o));var c=a&&a.filters&&a.filters[s[1]];if(!c)return r(oe(pt,a&&a.filters?"missing json key: "+s[1]:"missing json key: filters"));e.filter=dw(c),t.doChanges(e)})}}function gw(t){t._changesFilterPlugin={validate:pw,normalize:mw,shouldFilter:vw,filter:yw}}ae.plugin(gw);ae.version=D0;function _w(t,e,r){return new Promise(function(n){var i=Ja([""]);let s;if(typeof r=="function"){let a=r(i);s=t.objectStore(e).put(a)}else{let o=r;s=t.objectStore(e).put(i,o)}s.onsuccess=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);n(a||!o||parseInt(o[1],10)>=43)},s.onerror=t.onabort=function(o){o.preventDefault(),o.stopPropagation(),n(!1)}}).catch(function(){return!1})}function qh(t){return t.reduce(function(e,r){return e[r]=!0,e},{})}var ww=qh(["_id","_rev","_access","_attachments","_deleted","_revisions","_revs_info","_conflicts","_deleted_conflicts","_local_seq","_rev_tree","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats","_removed"]),bw=qh(["_access","_attachments","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats"]);function Vd(t){if(!/^\d+-/.test(t))return oe(Di);var e=t.indexOf("-"),r=t.substring(0,e),n=t.substring(e+1);return{prefix:parseInt(r,10),id:n}}function Ew(t,e){for(var r=t.start-t.ids.length+1,n=t.ids,i=[n[0],e,[]],s=1,o=n.length;s<o;s++)i=[n[s],{status:"missing"},[i]];return[{pos:r,ids:i}]}function kh(t,e,r){r||(r={deterministic_revs:!0});var n,i,s,o={status:"available"};if(t._deleted&&(o.deleted=!0),e)if(t._id||(t._id=Yi()),i=_h(t,r.deterministic_revs),t._rev){if(s=Vd(t._rev),s.error)return s;t._rev_tree=[{pos:s.prefix,ids:[s.id,{status:"missing"},[[i,o,[]]]]}],n=s.prefix+1}else t._rev_tree=[{pos:1,ids:[i,o,[]]}],n=1;else if(t._revisions&&(t._rev_tree=Ew(t._revisions,o),n=t._revisions.start,i=t._revisions.ids[0]),!t._rev_tree){if(s=Vd(t._rev),s.error)return s;n=s.prefix,i=s.id,t._rev_tree=[{pos:n,ids:[i,o,[]]}]}ph(t._id),t._rev=n+"-"+i;var a={metadata:{},data:{}};for(var c in t)if(Object.prototype.hasOwnProperty.call(t,c)){var d=c[0]==="_";if(d&&!ww[c]){var m=oe(Nd,c);throw m.message=Nd.message+": "+c,m}else d&&!bw[c]?a.metadata[c.slice(1)]=t[c]:a.data[c]=t[c]}return a}function $w(t){try{return Va(t)}catch{var e=oe(hh,"Attachment is not a valid base64 string");return{error:e}}}function Sw(t,e,r){var n=$w(t.data);if(n.error)return r(n.error);t.length=n.length,e==="blob"?t.data=Ha(n,t.content_type):e==="base64"?t.data=Dn(n):t.data=n,Ya(n,function(i){t.digest="md5-"+i,r()})}function Pw(t,e,r){Ya(t.data,function(n){t.digest="md5-"+n,t.length=t.data.size||t.data.length||0,e==="binary"?yh(t.data,function(i){t.data=i,r()}):e==="base64"?Qa(t.data,function(i){t.data=i,r()}):r()})}function Ow(t,e,r){if(t.stub)return r();typeof t.data=="string"?Sw(t,e,r):Pw(t,e,r)}function Aw(t,e,r){if(!t.length)return r();var n=0,i;t.forEach(function(o){var a=o.data&&o.data._attachments?Object.keys(o.data._attachments):[],c=0;if(!a.length)return s();function d(f){i=f,c++,c===a.length&&s()}for(var m in o.data._attachments)Object.prototype.hasOwnProperty.call(o.data._attachments,m)&&Ow(o.data._attachments[m],e,d)});function s(){n++,t.length===n&&(i?r(i):r())}}function Iw(t,e,r,n,i,s,o,a){if(b0(e.rev_tree,r.metadata.rev)&&!a)return n[i]=r,s();var c=e.winningRev||br(e),d="deleted"in e?e.deleted:Ut(e,c),m="deleted"in r.metadata?r.metadata.deleted:Ut(r.metadata),f=/^1-/.test(r.metadata.rev);if(d&&!m&&a&&f){var g=r.data;g._rev=c,g._id=r.metadata.id,r=kh(g,a)}var _=Eh(e.rev_tree,r.metadata.rev_tree[0],t),b=a&&(d&&m&&_.conflicts!=="new_leaf"||!d&&_.conflicts!=="new_leaf"||d&&!m&&_.conflicts==="new_branch");if(b){var P=oe(Vr);return n[i]=P,s()}var S=r.metadata.rev;r.metadata.rev_tree=_.tree,r.stemmedRevs=_.stemmedRevs||[],e.rev_map&&(r.metadata.rev_map=e.rev_map);var y=br(r.metadata),w=Ut(r.metadata,y),p=d===w?0:d<w?-1:1,h;S===y?h=w:h=Ut(r.metadata,S),o(r,y,w,h,!0,p,i,s)}function Tw(t){return t.metadata.rev_tree[0].ids[1].status==="missing"}function Rw(t,e,r,n,i,s,o,a,c){t=t||1e3;function d(P,S,y){var w=br(P.metadata),p=Ut(P.metadata,w);if("was_delete"in a&&p)return s[S]=oe(pt,"deleted"),y();var h=m&&Tw(P);if(h){var v=oe(Vr);return s[S]=v,y()}var E=p?0:1;o(P,w,p,p,!1,E,S,y)}var m=a.new_edits,f=new Map,g=0,_=e.length;function b(){++g===_&&c&&c()}e.forEach(function(P,S){if(P._id&&wr(P._id)){var y=P._deleted?"_removeLocal":"_putLocal";r[y](P,{ctx:i},function(p,h){s[S]=p||h,b()});return}var w=P.metadata.id;f.has(w)?(_--,f.get(w).push([P,S])):f.set(w,[[P,S]])}),f.forEach(function(P,S){var y=0;function w(){++y<P.length?p():b()}function p(){var h=P[y],v=h[0],E=h[1];if(n.has(S))Iw(t,n.get(S),v,s,E,w,o,m);else{var k=Eh([],v.metadata.rev_tree[0],t);v.metadata.rev_tree=k.tree,v.stemmedRevs=k.stemmedRevs||[],d(v,E,w)}}p()})}var qw=5,Le="document-store",Je="by-sequence",mt="attach-store",gr="attach-seq-store",rt="meta-store",It="local-store",fa="detect-blob-support";function kw(t){try{return JSON.parse(t)}catch{return Ua.default.parse(t)}}function Cw(t){try{return JSON.stringify(t)}catch{return Ua.default.stringify(t)}}function Tt(t){return function(e){var r="unknown_error";e.target&&e.target.error&&(r=e.target.error.name||e.target.error.message),t(oe(Fa,r,e.type))}}function Ra(t,e,r){return{data:Cw(t),winningRev:e,deletedOrLocal:r?"1":"0",seq:t.seq,id:t.id}}function _r(t){if(!t)return null;var e=kw(t.data);return e.winningRev=t.winningRev,e.deleted=t.deletedOrLocal==="1",e.seq=t.seq,e}function Ki(t){if(!t)return t;var e=t._doc_id_rev.lastIndexOf(":");return t._id=t._doc_id_rev.substring(0,e-1),t._rev=t._doc_id_rev.substring(e+1),delete t._doc_id_rev,t}function Ch(t,e,r,n){r?n(t?typeof t!="string"?t:Wa(t,e):Ja([""],{type:e})):t?typeof t!="string"?vh(t,function(i){n(Dn(i))}):n(t):n("")}function xh(t,e,r,n){var i=Object.keys(t._attachments||{});if(!i.length)return n&&n();var s=0;function o(){++s===i.length&&n&&n()}function a(c,d){var m=c._attachments[d],f=m.digest,g=r.objectStore(mt).get(f);g.onsuccess=function(_){m.body=_.target.result.body,o()}}i.forEach(function(c){e.attachments&&e.include_docs?a(t,c):(t._attachments[c].stub=!0,o())})}function qa(t,e){return Promise.all(t.map(function(r){if(r.doc&&r.doc._attachments){var n=Object.keys(r.doc._attachments);return Promise.all(n.map(function(i){var s=r.doc._attachments[i];if("body"in s){var o=s.body,a=s.content_type;return new Promise(function(c){Ch(o,a,e,function(d){r.doc._attachments[i]=Object.assign(Nn(s,["digest","content_type"]),{data:d}),c()})})}}))}}))}function jh(t,e,r){var n=[],i=r.objectStore(Je),s=r.objectStore(mt),o=r.objectStore(gr),a=t.length;function c(){a--,a||d()}function d(){n.length&&n.forEach(function(m){var f=o.index("digestSeq").count(IDBKeyRange.bound(m+"::",m+"::\uFFFF",!1,!1));f.onsuccess=function(g){var _=g.target.result;_||s.delete(m)}})}t.forEach(function(m){var f=i.index("_doc_id_rev"),g=e+"::"+m;f.getKey(g).onsuccess=function(_){var b=_.target.result;if(typeof b!="number")return c();i.delete(b);var P=o.index("seq").openCursor(IDBKeyRange.only(b));P.onsuccess=function(S){var y=S.target.result;if(y){var w=y.value.digestSeq.split("::")[0];n.push(w),o.delete(y.primaryKey),y.continue()}else c()}}})}function $t(t,e,r){try{return{txn:t.transaction(e,r)}}catch(n){return{error:n}}}var Cn=new wa;function xw(t,e,r,n,i,s){for(var o=e.docs,a,c,d,m,f,g,_,b,P=0,S=o.length;P<S;P++){var y=o[P];y._id&&wr(y._id)||(y=o[P]=kh(y,r.new_edits,t),y.error&&!_&&(_=y))}if(_)return s(_);var w=!1,p=0,h=new Array(o.length),v=new Map,E=!1,k=n._meta.blobSupport?"blob":"base64";Aw(o,k,function(B){if(B)return s(B);x()});function x(){var B=[Le,Je,mt,It,gr,rt],F=$t(i,B,"readwrite");if(F.error)return s(F.error);a=F.txn,a.onabort=Tt(s),a.ontimeout=Tt(s),a.oncomplete=Q,c=a.objectStore(Le),d=a.objectStore(Je),m=a.objectStore(mt),f=a.objectStore(gr),g=a.objectStore(rt),g.get(rt).onsuccess=function(X){b=X.target.result,H()},ce(function(X){if(X)return E=!0,s(X);re()})}function N(){w=!0,H()}function G(){Rw(t.revs_limit,o,n,v,a,h,fe,r,N)}function H(){!b||!w||(b.docCount+=p,g.put(b))}function re(){if(!o.length)return;var B=0;function F(){++B===o.length&&G()}function X(W){var ee=_r(W.target.result);ee&&v.set(ee.id,ee),F()}for(var ie=0,J=o.length;ie<J;ie++){var D=o[ie];if(D._id&&wr(D._id)){F();continue}var M=c.get(D.metadata.id);M.onsuccess=X}}function Q(){E||(Cn.notify(n._meta.name),s(null,h))}function Z(B,F){var X=m.get(B);X.onsuccess=function(ie){if(ie.target.result)F();else{var J=oe(Z_,"unknown stub attachment with digest "+B);J.status=412,F(J)}}}function ce(B){var F=[];if(o.forEach(function(D){D.data&&D.data._attachments&&Object.keys(D.data._attachments).forEach(function(M){var W=D.data._attachments[M];W.stub&&F.push(W.digest)})}),!F.length)return B();var X=0,ie;function J(){++X===F.length&&B(ie)}F.forEach(function(D){Z(D,function(M){M&&!ie&&(ie=M),J()})})}function fe(B,F,X,ie,J,D,M,W){B.metadata.winningRev=F,B.metadata.deleted=X;var ee=B.data;ee._id=B.metadata.id,ee._rev=B.metadata.rev,ie&&(ee._deleted=!0);var ne=ee._attachments&&Object.keys(ee._attachments).length;if(ne)return q(B,F,X,J,M,W);p+=D,H(),me(B,F,X,J,M,W)}function me(B,F,X,ie,J,D){var M=B.data,W=B.metadata;M._doc_id_rev=W.id+"::"+W.rev,delete M._id,delete M._rev;function ee(Re){var We=B.stemmedRevs||[];ie&&n.auto_compaction&&(We=We.concat(p0(B.metadata))),We&&We.length&&jh(We,B.metadata.id,a),W.seq=Re.target.result;var ct=Ra(W,F,X),ve=c.put(ct);ve.onsuccess=Ee}function ne(Re){Re.preventDefault(),Re.stopPropagation();var We=d.index("_doc_id_rev"),ct=We.getKey(M._doc_id_rev);ct.onsuccess=function(ve){var ge=d.put(M,ve.target.result);ge.onsuccess=ee}}function Ee(){h[J]={ok:!0,id:W.id,rev:W.rev},v.set(B.metadata.id,B.metadata),C(B,W.seq,D)}var $e=d.put(M);$e.onsuccess=ee,$e.onerror=ne}function q(B,F,X,ie,J,D){var M=B.data,W=0,ee=Object.keys(M._attachments);function ne(){W===ee.length&&me(B,F,X,ie,J,D)}function Ee(){W++,ne()}ee.forEach(function($e){var Re=B.data._attachments[$e];if(Re.stub)W++,ne();else{var We=Re.data;delete Re.data,Re.revpos=parseInt(F,10);var ct=Re.digest;L(ct,We,Ee)}})}function C(B,F,X){var ie=0,J=Object.keys(B.data._attachments||{});if(!J.length)return X();function D(){++ie===J.length&&X()}function M(ee){var ne=B.data._attachments[ee].digest,Ee=f.put({seq:F,digestSeq:ne+"::"+F});Ee.onsuccess=D,Ee.onerror=function($e){$e.preventDefault(),$e.stopPropagation(),D()}}for(var W=0;W<J.length;W++)M(J[W])}function L(B,F,X){var ie=m.count(B);ie.onsuccess=function(J){var D=J.target.result;if(D)return X();var M={digest:B,body:F},W=m.put(M);W.onsuccess=X}}}function Nh(t,e,r,n,i){n===-1&&(n=1e3);var s=typeof t.getAll=="function"&&typeof t.getAllKeys=="function"&&n>1&&!r,o,a,c;function d(_){a=_.target.result,o&&i(o,a,c)}function m(_){o=_.target.result,a&&i(o,a,c)}function f(){if(!o.length)return i();var _=o[o.length-1],b;if(e&&e.upper)try{b=IDBKeyRange.bound(_,e.upper,!0,e.upperOpen)}catch(P){if(P.name==="DataError"&&P.code===0)return i()}else b=IDBKeyRange.lowerBound(_,!0);e=b,o=null,a=null,t.getAll(e,n).onsuccess=d,t.getAllKeys(e,n).onsuccess=m}function g(_){var b=_.target.result;if(!b)return i();i([b.key],[b.value],b)}s?(c={continue:f},t.getAll(e,n).onsuccess=d,t.getAllKeys(e,n).onsuccess=m):r?t.openCursor(e,"prev").onsuccess=g:t.openCursor(e).onsuccess=g}function jw(t,e,r){if(typeof t.getAll=="function"){t.getAll(e).onsuccess=r;return}var n=[];function i(s){var o=s.target.result;o?(n.push(o.value),o.continue()):r({target:{result:n}})}t.openCursor(e).onsuccess=i}function Nw(t,e,r){var n=new Array(t.length),i=0;t.forEach(function(s,o){e.get(s).onsuccess=function(a){a.target.result?n[o]=a.target.result:n[o]={key:s,error:"not_found"},i++,i===t.length&&r(t,n,{})}})}function Dw(t,e,r,n,i){try{if(t&&e)return i?IDBKeyRange.bound(e,t,!r,!1):IDBKeyRange.bound(t,e,!1,!r);if(t)return i?IDBKeyRange.upperBound(t):IDBKeyRange.lowerBound(t);if(e)return i?IDBKeyRange.lowerBound(e,!r):IDBKeyRange.upperBound(e,!r);if(n)return IDBKeyRange.only(n)}catch(s){return{error:s}}return null}function Bw(t,e,r){var n="startkey"in t?t.startkey:!1,i="endkey"in t?t.endkey:!1,s="key"in t?t.key:!1,o="keys"in t?t.keys:!1,a=t.skip||0,c=typeof t.limit=="number"?t.limit:-1,d=t.inclusive_end!==!1,m,f;if(!o&&(m=Dw(n,i,d,s,t.descending),f=m&&m.error,f&&!(f.name==="DataError"&&f.code===0)))return r(oe(Fa,f.name,f.message));var g=[Le,Je,rt];t.attachments&&g.push(mt);var _=$t(e,g,"readonly");if(_.error)return r(_.error);var b=_.txn;b.oncomplete=re,b.onabort=Tt(r);var P=b.objectStore(Le),S=b.objectStore(Je),y=b.objectStore(rt),w=S.index("_doc_id_rev"),p=[],h,v;y.get(rt).onsuccess=function(Q){h=Q.target.result.docCount},t.update_seq&&(S.openKeyCursor(null,"prev").onsuccess=Q=>{var Z=Q.target.result;Z&&Z.key&&(v=Z.key)});function E(Q,Z,ce){var fe=Q.id+"::"+ce;w.get(fe).onsuccess=function(q){if(Z.doc=Ki(q.target.result)||{},t.conflicts){var C=Za(Q);C.length&&(Z.doc._conflicts=C)}xh(Z.doc,t,b)}}function k(Q,Z){var ce={id:Z.id,key:Z.id,value:{rev:Q}},fe=Z.deleted;fe?o&&(p.push(ce),ce.value.deleted=!0,ce.doc=null):a--<=0&&(p.push(ce),t.include_docs&&E(Z,ce,Q))}function x(Q){for(var Z=0,ce=Q.length;Z<ce&&p.length!==c;Z++){var fe=Q[Z];if(fe.error&&o){p.push(fe);continue}var me=_r(fe),q=me.winningRev;k(q,me)}}function N(Q,Z,ce){ce&&(x(Z),p.length<c&&ce.continue())}function G(Q){var Z=Q.target.result;t.descending&&(Z=Z.reverse()),x(Z)}function H(){var Q={total_rows:h,offset:t.skip,rows:p};t.update_seq&&v!==void 0&&(Q.update_seq=v),r(null,Q)}function re(){t.attachments?qa(p,t.binary).then(H):H()}if(!(f||c===0)){if(o)return Nw(o,P,N);if(c===-1)return jw(P,m,G);Nh(P,m,t.descending,c+a,N)}}function Lw(t,e){var r=t.objectStore(Le).index("deletedOrLocal");r.count(IDBKeyRange.only("0")).onsuccess=function(n){e(n.target.result)}}var ka=!1,Ca=[];function Mw(t,e,r,n){try{t(e,r)}catch(i){n.emit("error",i)}}function Jd(){ka||!Ca.length||(ka=!0,Ca.shift()())}function Uw(t,e,r){Ca.push(function(){t(function(s,o){Mw(e,s,o,r),ka=!1,qt(function(){Jd(r)})})}),Jd()}function Gw(t,e,r,n){if(t=Ge(t),t.continuous){var i=r+":"+Yi();return Cn.addListener(r,i,e,t),Cn.notify(r),{cancel:function(){Cn.removeListener(r,i)}}}var s=t.doc_ids&&new Set(t.doc_ids);t.since=t.since||0;var o=t.since,a="limit"in t?t.limit:-1;a===0&&(a=1);var c=[],d=0,m=za(t),f=new Map,g,_,b,P;function S(x,N,G){if(!G||!x.length)return;var H=new Array(x.length),re=new Array(x.length);function Q(fe,me){var q=t.processChange(me,fe,t);o=q.seq=fe.seq;var C=m(q);return typeof C=="object"?Promise.reject(C):C?(d++,t.return_docs&&c.push(q),t.attachments&&t.include_docs?new Promise(function(L){xh(me,t,g,function(){qa([q],t.binary).then(function(){L(q)})})}):Promise.resolve(q)):Promise.resolve()}function Z(){for(var fe=[],me=0,q=H.length;me<q&&d!==a;me++){var C=H[me];if(C){var L=re[me];fe.push(Q(L,C))}}Promise.all(fe).then(function(B){for(var F=0,X=B.length;F<X;F++)B[F]&&t.onChange(B[F])}).catch(t.complete),d!==a&&G.continue()}var ce=0;N.forEach(function(fe,me){var q=Ki(fe),C=x[me];w(q,C,function(L,B){re[me]=L,H[me]=B,++ce===x.length&&Z()})})}function y(x,N,G,H){if(G.seq!==N)return H();if(G.winningRev===x._rev)return H(G,x);var re=x._id+"::"+G.winningRev,Q=P.get(re);Q.onsuccess=function(Z){H(G,Ki(Z.target.result))}}function w(x,N,G){if(s&&!s.has(x._id))return G();var H=f.get(x._id);if(H)return y(x,N,H,G);b.get(x._id).onsuccess=function(re){H=_r(re.target.result),f.set(x._id,H),y(x,N,H,G)}}function p(){t.complete(null,{results:c,last_seq:o})}function h(){!t.continuous&&t.attachments?qa(c).then(p):p()}var v=[Le,Je];t.attachments&&v.push(mt);var E=$t(n,v,"readonly");if(E.error)return t.complete(E.error);g=E.txn,g.onabort=Tt(t.complete),g.oncomplete=h,_=g.objectStore(Je),b=g.objectStore(Le),P=_.index("_doc_id_rev");var k=t.since&&!t.descending?IDBKeyRange.lowerBound(t.since,!0):null;Nh(_,k,t.descending,a,S)}var Fr=new Map,la,da=new Map;function Dh(t,e){var r=this;Uw(function(n){Fw(r,t,n)},e,r.constructor)}function Fw(t,e,r){var n=e.name,i=null,s=null;t._meta=null;function o(S){return function(y,w){y&&y instanceof Error&&!y.reason&&s&&(y.reason=s),S(y,w)}}function a(S){var y=S.createObjectStore(Le,{keyPath:"id"});S.createObjectStore(Je,{autoIncrement:!0}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0}),S.createObjectStore(mt,{keyPath:"digest"}),S.createObjectStore(rt,{keyPath:"id",autoIncrement:!1}),S.createObjectStore(fa),y.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),S.createObjectStore(It,{keyPath:"_id"});var w=S.createObjectStore(gr,{autoIncrement:!0});w.createIndex("seq","seq"),w.createIndex("digestSeq","digestSeq",{unique:!0})}function c(S,y){var w=S.objectStore(Le);w.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),w.openCursor().onsuccess=function(p){var h=p.target.result;if(h){var v=h.value,E=Ut(v);v.deletedOrLocal=E?"1":"0",w.put(v),h.continue()}else y()}}function d(S){S.createObjectStore(It,{keyPath:"_id"}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0})}function m(S,y){var w=S.objectStore(It),p=S.objectStore(Le),h=S.objectStore(Je),v=p.openCursor();v.onsuccess=function(E){var k=E.target.result;if(k){var x=k.value,N=x.id,G=wr(N),H=br(x);if(G){var re=N+"::"+H,Q=N+"::",Z=N+"::~",ce=h.index("_doc_id_rev"),fe=IDBKeyRange.bound(Q,Z,!1,!1),me=ce.openCursor(fe);me.onsuccess=function(q){if(me=q.target.result,!me)p.delete(k.primaryKey),k.continue();else{var C=me.value;C._doc_id_rev===re&&w.put(C),h.delete(me.primaryKey),me.continue()}}}else k.continue()}else y&&y()}}function f(S){var y=S.createObjectStore(gr,{autoIncrement:!0});y.createIndex("seq","seq"),y.createIndex("digestSeq","digestSeq",{unique:!0})}function g(S,y){var w=S.objectStore(Je),p=S.objectStore(mt),h=S.objectStore(gr),v=p.count();v.onsuccess=function(E){var k=E.target.result;if(!k)return y();w.openCursor().onsuccess=function(x){var N=x.target.result;if(!N)return y();for(var G=N.value,H=N.primaryKey,re=Object.keys(G._attachments||{}),Q={},Z=0;Z<re.length;Z++){var ce=G._attachments[re[Z]];Q[ce.digest]=!0}var fe=Object.keys(Q);for(Z=0;Z<fe.length;Z++){var me=fe[Z];h.put({seq:H,digestSeq:me+"::"+H})}N.continue()}}}function _(S){function y(v){return v.data?_r(v):(v.deleted=v.deletedOrLocal==="1",v)}var w=S.objectStore(Je),p=S.objectStore(Le),h=p.openCursor();h.onsuccess=function(v){var E=v.target.result;if(!E)return;var k=y(E.value);k.winningRev=k.winningRev||br(k);function x(){var G=k.id+"::",H=k.id+"::\uFFFF",re=w.index("_doc_id_rev").openCursor(IDBKeyRange.bound(G,H)),Q=0;re.onsuccess=function(Z){var ce=Z.target.result;if(!ce)return k.seq=Q,N();var fe=ce.primaryKey;fe>Q&&(Q=fe),ce.continue()}}function N(){var G=Ra(k,k.winningRev,k.deleted),H=p.put(G);H.onsuccess=function(){E.continue()}}if(k.seq)return N();x()}}t._remote=!1,t.type=function(){return"idb"},t._id=fh(function(S){S(null,t._meta.instanceId)}),t._bulkDocs=function(y,w,p){xw(e,y,w,t,i,o(p))},t._get=function(y,w,p){var h,v,E,k=w.ctx;if(!k){var x=$t(i,[Le,Je,mt],"readonly");if(x.error)return p(x.error);k=x.txn}function N(){p(E,{doc:h,metadata:v,ctx:k})}k.objectStore(Le).get(y).onsuccess=function(G){if(v=_r(G.target.result),!v)return E=oe(pt,"missing"),N();var H;if(w.rev)H=w.latest?$0(w.rev,v):w.rev;else{H=v.winningRev;var re=Ut(v);if(re)return E=oe(pt,"deleted"),N()}var Q=k.objectStore(Je),Z=v.id+"::"+H;Q.index("_doc_id_rev").get(Z).onsuccess=function(ce){if(h=ce.target.result,h&&(h=Ki(h)),!h)return E=oe(pt,"missing"),N();N()}}},t._getAttachment=function(S,y,w,p,h){var v;if(p.ctx)v=p.ctx;else{var E=$t(i,[Le,Je,mt],"readonly");if(E.error)return h(E.error);v=E.txn}var k=w.digest,x=w.content_type;v.objectStore(mt).get(k).onsuccess=function(N){var G=N.target.result.body;Ch(G,x,p.binary,function(H){h(null,H)})}},t._info=function(y){var w,p,h=$t(i,[rt,Je],"readonly");if(h.error)return y(h.error);var v=h.txn;v.objectStore(rt).get(rt).onsuccess=function(E){p=E.target.result.docCount},v.objectStore(Je).openKeyCursor(null,"prev").onsuccess=function(E){var k=E.target.result;w=k?k.key:0},v.oncomplete=function(){y(null,{doc_count:p,update_seq:w,idb_attachment_format:t._meta.blobSupport?"binary":"base64"})}},t._allDocs=function(y,w){Bw(y,i,o(w))},t._changes=function(y){return Gw(y,t,n,i)},t._close=function(S){i.close(),Fr.delete(n),S()},t._getRevisionTree=function(S,y){var w=$t(i,[Le],"readonly");if(w.error)return y(w.error);var p=w.txn,h=p.objectStore(Le).get(S);h.onsuccess=function(v){var E=_r(v.target.result);E?y(null,E.rev_tree):y(oe(pt))}},t._doCompaction=function(S,y,w){var p=[Le,Je,mt,gr],h=$t(i,p,"readwrite");if(h.error)return w(h.error);var v=h.txn,E=v.objectStore(Le);E.get(S).onsuccess=function(k){var x=_r(k.target.result);Er(x.rev_tree,function(H,re,Q,Z,ce){var fe=re+"-"+Q;y.indexOf(fe)!==-1&&(ce.status="missing")}),jh(y,S,v);var N=x.winningRev,G=x.deleted;v.objectStore(Le).put(Ra(x,N,G))},v.onabort=Tt(w),v.oncomplete=function(){w()}},t._getLocal=function(S,y){var w=$t(i,[It],"readonly");if(w.error)return y(w.error);var p=w.txn,h=p.objectStore(It).get(S);h.onerror=Tt(y),h.onsuccess=function(v){var E=v.target.result;E?(delete E._doc_id_rev,y(null,E)):y(oe(pt))}},t._putLocal=function(S,y,w){typeof y=="function"&&(w=y,y={}),delete S._revisions;var p=S._rev,h=S._id;p?S._rev="0-"+(parseInt(p.split("-")[1],10)+1):S._rev="0-1";var v=y.ctx,E;if(!v){var k=$t(i,[It],"readwrite");if(k.error)return w(k.error);v=k.txn,v.onerror=Tt(w),v.oncomplete=function(){E&&w(null,E)}}var x=v.objectStore(It),N;p?(N=x.get(h),N.onsuccess=function(G){var H=G.target.result;if(!H||H._rev!==p)w(oe(Vr));else{var re=x.put(S);re.onsuccess=function(){E={ok:!0,id:S._id,rev:S._rev},y.ctx&&w(null,E)}}}):(N=x.add(S),N.onerror=function(G){w(oe(Vr)),G.preventDefault(),G.stopPropagation()},N.onsuccess=function(){E={ok:!0,id:S._id,rev:S._rev},y.ctx&&w(null,E)})},t._removeLocal=function(S,y,w){typeof y=="function"&&(w=y,y={});var p=y.ctx;if(!p){var h=$t(i,[It],"readwrite");if(h.error)return w(h.error);p=h.txn,p.oncomplete=function(){v&&w(null,v)}}var v,E=S._id,k=p.objectStore(It),x=k.get(E);x.onerror=Tt(w),x.onsuccess=function(N){var G=N.target.result;!G||G._rev!==S._rev?w(oe(pt)):(k.delete(E),v={ok:!0,id:E,rev:"0-0"},y.ctx&&w(null,v))}},t._destroy=function(S,y){Cn.removeAllListeners(n);var w=da.get(n);w&&w.result&&(w.result.close(),Fr.delete(n));var p=indexedDB.deleteDatabase(n);p.onsuccess=function(){da.delete(n),Mi()&&n in localStorage&&delete localStorage[n],y(null,{ok:!0})},p.onerror=Tt(y)};var b=Fr.get(n);if(b)return i=b.idb,t._meta=b.global,qt(function(){r(null,t)});var P=indexedDB.open(n,qw);da.set(n,P),P.onupgradeneeded=function(S){var y=S.target.result;if(S.oldVersion<1)return a(y);var w=S.currentTarget.transaction;S.oldVersion<3&&d(y),S.oldVersion<4&&f(y);var p=[c,m,g,_],h=S.oldVersion;function v(){var E=p[h-1];h++,E&&E(w,v)}v()},P.onsuccess=function(S){i=S.target.result,i.onversionchange=function(){i.close(),Fr.delete(n)},i.onabort=function(N){vt("error","Database has a global failure",N.target.error),s=N.target.error,i.close(),Fr.delete(n)};var y=i.transaction([rt,fa,Le],"readwrite"),w=!1,p,h,v,E;function k(){typeof v>"u"||!w||(t._meta={name:n,instanceId:E,blobSupport:v},Fr.set(n,{idb:i,global:t._meta}),r(null,t))}function x(){if(!(typeof h>"u"||typeof p>"u")){var N=n+"_id";N in p?E=p[N]:p[N]=E=Yi(),p.docCount=h,y.objectStore(rt).put(p)}}y.objectStore(rt).get(rt).onsuccess=function(N){p=N.target.result||{id:rt},x()},Lw(y,function(N){h=N,x()}),la||(la=_w(y,fa,"key")),la.then(function(N){v=N,k()}),y.oncomplete=function(){w=!0,k()},y.onabort=Tt(r)},P.onerror=function(S){var y=S.target.error&&S.target.error.message;y?y.indexOf("stored database is a higher version")!==-1&&(y=new Error('This DB was created with the newer "indexeddb" adapter, but you are trying to open it with the older "idb" adapter')):y="Failed to open indexedDB, are you in private browsing mode?",vt("error",y),r(oe(Fa,y))}}Dh.valid=function(){try{return typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}};function zw(t){t.adapter("idb",Dh,!0)}function Kw(t,e){return new Promise(function(r,n){var i=0,s=0,o=0,a=t.length,c;function d(){i++,t[s++]().then(f,g)}function m(){++o===a?c?n(c):r():_()}function f(){i--,m()}function g(b){i--,c=c||b,m()}function _(){for(;i<e&&s<a;)d()}_()})}var Vw=25,Jw=50,ji=5e3,Hw=1e4,ha={};function pa(t){let e=t.doc||t.ok,r=e&&e._attachments;r&&Object.keys(r).forEach(function(n){let i=r[n];i.data=Wa(i.data,i.content_type)})}function vr(t){return/^_design/.test(t)?"_design/"+encodeURIComponent(t.slice(8)):t.startsWith("_local/")?"_local/"+encodeURIComponent(t.slice(7)):encodeURIComponent(t)}function Hd(t){return!t._attachments||!Object.keys(t._attachments)?Promise.resolve():Promise.all(Object.keys(t._attachments).map(function(e){let r=t._attachments[e];if(r.data&&typeof r.data!="string")return new Promise(function(n){Qa(r.data,n)}).then(function(n){r.data=n})}))}function Ww(t){if(!t.prefix)return!1;let e=mh(t.prefix).protocol;return e==="http"||e==="https"}function Qw(t,e){if(Ww(e)){let i=e.name.substr(e.prefix.length);t=e.prefix.replace(/\/?$/,"/")+encodeURIComponent(i)}let r=mh(t);(r.user||r.password)&&(r.auth={username:r.user,password:r.password});let n=r.path.replace(/(^\/|\/$)/g,"").split("/");return r.db=n.pop(),r.db.indexOf("%")===-1&&(r.db=encodeURIComponent(r.db)),r.path=n.join("/"),r}function Ue(t,e){return Bi(t,t.db+"/"+e)}function Bi(t,e){let r=t.path?"/":"";return t.protocol+"://"+t.host+(t.port?":"+t.port:"")+"/"+t.path+r+e}function Ni(t){let e=Object.keys(t);return e.length===0?"":"?"+e.map(r=>r+"="+encodeURIComponent(t[r])).join("&")}function Yw(t){let e=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",r=e.indexOf("msie")!==-1,n=e.indexOf("trident")!==-1,i=e.indexOf("edge")!==-1,s=!("method"in t)||t.method==="GET";return(r||n||i)&&s}function xa(t,e){let r=this,n=Qw(t.name,t),i=Ue(n,"");t=Ge(t);let s=async function(f,g){if(g=g||{},g.headers=g.headers||new zr,g.credentials="include",t.auth||n.auth){let P=t.auth||n.auth,S=P.username+":"+P.password,y=Dn(unescape(encodeURIComponent(S)));g.headers.set("Authorization","Basic "+y)}let _=t.headers||{};return Object.keys(_).forEach(function(P){g.headers.append(P,_[P])}),Yw(g)&&(f+=(f.indexOf("?")===-1?"?":"&")+"_nonce="+Date.now()),await(t.fetch||Ph)(f,g)};function o(f,g){return De(f,function(..._){d().then(function(){return g.apply(this,_)}).catch(function(b){_.pop()(b)})}).bind(r)}async function a(f,g){let _={};g=g||{},g.headers=g.headers||new zr,g.headers.get("Content-Type")||g.headers.set("Content-Type","application/json"),g.headers.get("Accept")||g.headers.set("Accept","application/json");let b=await s(f,g);_.ok=b.ok,_.status=b.status;let P=await b.json();if(_.data=P,!_.ok)throw _.data.status=_.status,Jr(_.data);return Array.isArray(_.data)&&(_.data=_.data.map(function(S){return S.error||S.missing?Jr(S):S})),_}let c;async function d(){return t.skip_setup?Promise.resolve():c||(c=a(i).catch(function(f){return f&&f.status&&f.status===404?(ba(404,"PouchDB is just detecting if the remote exists."),a(i,{method:"PUT"})):Promise.reject(f)}).catch(function(f){return f&&f.status&&f.status===412?!0:Promise.reject(f)}),c.catch(function(){c=null}),c)}qt(function(){e(null,r)}),r._remote=!0,r.type=function(){return"http"},r.id=o("id",async function(f){let g;try{g=await(await s(Bi(n,""))).json()}catch{g={}}let _=g&&g.uuid?g.uuid+n.db:Ue(n,"");f(null,_)}),r.compact=o("compact",async function(f,g){typeof f=="function"&&(g=f,f={}),f=Ge(f),await a(Ue(n,"_compact"),{method:"POST"});function _(){r.info(function(b,P){P&&!P.compact_running?g(null,{ok:!0}):setTimeout(_,f.interval||200)})}_()}),r.bulkGet=De("bulkGet",function(f,g){let _=this;async function b(w){let p={};f.revs&&(p.revs=!0),f.attachments&&(p.attachments=!0),f.latest&&(p.latest=!0);try{let h=await a(Ue(n,"_bulk_get"+Ni(p)),{method:"POST",body:JSON.stringify({docs:f.docs})});f.attachments&&f.binary&&h.data.results.forEach(function(v){v.docs.forEach(pa)}),w(null,h.data)}catch(h){w(h)}}function P(){let w=Jw,p=Math.ceil(f.docs.length/w),h=0,v=new Array(p);function E(k){return function(x,N){v[k]=N.results,++h===p&&g(null,{results:v.flat()})}}for(let k=0;k<p;k++){let x=Nn(f,["revs","attachments","binary","latest"]);x.docs=f.docs.slice(k*w,Math.min(f.docs.length,(k+1)*w)),lh(_,x,E(k))}}let S=Bi(n,""),y=ha[S];typeof y!="boolean"?b(function(w,p){w?(ha[S]=!1,ba(w.status,"PouchDB is just detecting if the remote supports the _bulk_get API."),P()):(ha[S]=!0,g(null,p))}):y?b(g):P()}),r._info=async function(f){try{await d();let _=await(await s(Ue(n,""))).json();_.host=Ue(n,""),f(null,_)}catch(g){f(g)}},r.fetch=async function(f,g){await d();let _=f.substring(0,1)==="/"?Bi(n,f.substring(1)):Ue(n,f);return s(_,g)},r.get=o("get",async function(f,g,_){typeof g=="function"&&(_=g,g={}),g=Ge(g);let b={};g.revs&&(b.revs=!0),g.revs_info&&(b.revs_info=!0),g.latest&&(b.latest=!0),g.open_revs&&(g.open_revs!=="all"&&(g.open_revs=JSON.stringify(g.open_revs)),b.open_revs=g.open_revs),g.rev&&(b.rev=g.rev),g.conflicts&&(b.conflicts=g.conflicts),g.update_seq&&(b.update_seq=g.update_seq),f=vr(f);function P(w){let p=w._attachments,h=p&&Object.keys(p);if(!p||!h.length)return;async function v(k){let x=p[k],N=vr(w._id)+"/"+m(k)+"?rev="+w._rev,G=await s(Ue(n,N)),H;"buffer"in G?H=await G.buffer():H=await G.blob();let re;if(g.binary){let Q=Object.getOwnPropertyDescriptor(H.__proto__,"type");(!Q||Q.set)&&(H.type=x.content_type),re=H}else re=await new Promise(function(Q){Qa(H,Q)});delete x.stub,delete x.length,x.data=re}let E=h.map(function(k){return function(){return v(k)}});return Kw(E,5)}function S(w){return Array.isArray(w)?Promise.all(w.map(function(p){if(p.ok)return P(p.ok)})):P(w)}let y=Ue(n,f+Ni(b));try{let w=await a(y);g.attachments&&await S(w.data),_(null,w.data)}catch(w){w.docId=f,_(w)}}),r.remove=o("remove",async function(f,g,_,b){let P;typeof g=="string"?(P={_id:f,_rev:g},typeof _=="function"&&(b=_,_={})):(P=f,typeof g=="function"?(b=g,_={}):(b=_,_=g));let S=P._rev||_.rev,y=Ue(n,vr(P._id))+"?rev="+S;try{let w=await a(y,{method:"DELETE"});b(null,w.data)}catch(w){b(w)}});function m(f){return f.split("/").map(encodeURIComponent).join("/")}r.getAttachment=o("getAttachment",async function(f,g,_,b){typeof _=="function"&&(b=_,_={});let P=_.rev?"?rev="+_.rev:"",S=Ue(n,vr(f))+"/"+m(g)+P,y;try{let w=await s(S,{method:"GET"});if(!w.ok)throw w;y=w.headers.get("content-type");let p;if(typeof z<"u"&&!z.browser&&typeof w.buffer=="function"?p=await w.buffer():p=await w.blob(),typeof z<"u"&&!z.browser){let h=Object.getOwnPropertyDescriptor(p.__proto__,"type");(!h||h.set)&&(p.type=y)}b(null,p)}catch(w){b(w)}}),r.removeAttachment=o("removeAttachment",async function(f,g,_,b){let P=Ue(n,vr(f)+"/"+m(g))+"?rev="+_;try{let S=await a(P,{method:"DELETE"});b(null,S.data)}catch(S){b(S)}}),r.putAttachment=o("putAttachment",async function(f,g,_,b,P,S){typeof P=="function"&&(S=P,P=b,b=_,_=null);let y=vr(f)+"/"+m(g),w=Ue(n,y);if(_&&(w+="?rev="+_),typeof b=="string"){let p;try{p=Va(b)}catch{return S(oe(hh,"Attachment is not a valid base64 string"))}b=p?Ha(p,P):""}try{let p=await a(w,{headers:new zr({"Content-Type":P}),method:"PUT",body:b});S(null,p.data)}catch(p){S(p)}}),r._bulkDocs=async function(f,g,_){f.new_edits=g.new_edits;try{await d(),await Promise.all(f.docs.map(Hd));let b=await a(Ue(n,"_bulk_docs"),{method:"POST",body:JSON.stringify(f)});_(null,b.data)}catch(b){_(b)}},r._put=async function(f,g,_){try{await d(),await Hd(f);let b=await a(Ue(n,vr(f._id)),{method:"PUT",body:JSON.stringify(f)});_(null,b.data)}catch(b){b.docId=f&&f._id,_(b)}},r.allDocs=o("allDocs",async function(f,g){typeof f=="function"&&(g=f,f={}),f=Ge(f);let _={},b,P="GET";f.conflicts&&(_.conflicts=!0),f.update_seq&&(_.update_seq=!0),f.descending&&(_.descending=!0),f.include_docs&&(_.include_docs=!0),f.attachments&&(_.attachments=!0),f.key&&(_.key=JSON.stringify(f.key)),f.start_key&&(f.startkey=f.start_key),f.startkey&&(_.startkey=JSON.stringify(f.startkey)),f.end_key&&(f.endkey=f.end_key),f.endkey&&(_.endkey=JSON.stringify(f.endkey)),typeof f.inclusive_end<"u"&&(_.inclusive_end=!!f.inclusive_end),typeof f.limit<"u"&&(_.limit=f.limit),typeof f.skip<"u"&&(_.skip=f.skip);let S=Ni(_);typeof f.keys<"u"&&(P="POST",b={keys:f.keys});try{let y=await a(Ue(n,"_all_docs"+S),{method:P,body:JSON.stringify(b)});f.include_docs&&f.attachments&&f.binary&&y.data.rows.forEach(pa),g(null,y.data)}catch(y){g(y)}}),r._changes=function(f){let g="batch_size"in f?f.batch_size:Vw;f=Ge(f),f.continuous&&!("heartbeat"in f)&&(f.heartbeat=Hw);let _="timeout"in f?f.timeout:30*1e3;"timeout"in f&&f.timeout&&_-f.timeout<ji&&(_=f.timeout+ji),"heartbeat"in f&&f.heartbeat&&_-f.heartbeat<ji&&(_=f.heartbeat+ji);let b={};"timeout"in f&&f.timeout&&(b.timeout=f.timeout);let P=typeof f.limit<"u"?f.limit:!1,S=P;if(f.style&&(b.style=f.style),(f.include_docs||f.filter&&typeof f.filter=="function")&&(b.include_docs=!0),f.attachments&&(b.attachments=!0),f.continuous&&(b.feed="longpoll"),f.seq_interval&&(b.seq_interval=f.seq_interval),f.conflicts&&(b.conflicts=!0),f.descending&&(b.descending=!0),f.update_seq&&(b.update_seq=!0),"heartbeat"in f&&f.heartbeat&&(b.heartbeat=f.heartbeat),f.filter&&typeof f.filter=="string"&&(b.filter=f.filter),f.view&&typeof f.view=="string"&&(b.filter="_view",b.view=f.view),f.query_params&&typeof f.query_params=="object")for(let x in f.query_params)Object.prototype.hasOwnProperty.call(f.query_params,x)&&(b[x]=f.query_params[x]);let y="GET",w;f.doc_ids?(b.filter="_doc_ids",y="POST",w={doc_ids:f.doc_ids}):f.selector&&(b.filter="_selector",y="POST",w={selector:f.selector});let p=new AbortController,h,v=async function(x,N){if(f.aborted)return;b.since=x,typeof b.since=="object"&&(b.since=JSON.stringify(b.since)),f.descending?P&&(b.limit=S):b.limit=!P||S>g?g:S;let G=Ue(n,"_changes"+Ni(b)),H={signal:p.signal,method:y,body:JSON.stringify(w)};if(h=x,!f.aborted)try{await d();let re=await a(G,H);N(null,re.data)}catch(re){N(re)}},E={results:[]},k=function(x,N){if(f.aborted)return;let G=0;if(N&&N.results){G=N.results.length,E.last_seq=N.last_seq;let re=null,Q=null;typeof N.pending=="number"&&(re=N.pending),(typeof E.last_seq=="string"||typeof E.last_seq=="number")&&(Q=E.last_seq);let Z={};Z.query=f.query_params,N.results=N.results.filter(function(ce){S--;let fe=za(f)(ce);return fe&&(f.include_docs&&f.attachments&&f.binary&&pa(ce),f.return_docs&&E.results.push(ce),f.onChange(ce,re,Q)),fe})}else if(x){f.aborted=!0,f.complete(x);return}N&&N.last_seq&&(h=N.last_seq);let H=P&&S<=0||N&&G<g||f.descending;f.continuous&&!(P&&S<=0)||!H?qt(function(){v(h,k)}):f.complete(null,E)};return v(f.since||0,k),{cancel:function(){f.aborted=!0,p.abort()}}},r.revsDiff=o("revsDiff",async function(f,g,_){typeof g=="function"&&(_=g,g={});try{let b=await a(Ue(n,"_revs_diff"),{method:"POST",body:JSON.stringify(f)});_(null,b.data)}catch(b){_(b)}}),r._close=function(f){f()},r._destroy=async function(f,g){try{let _=await a(Ue(n,""),{method:"DELETE"});g(null,_)}catch(_){_.status===404?g(null,{ok:!0}):g(_)}}}xa.valid=function(){return!0};function Xw(t){t.adapter("http",xa,!1),t.adapter("https",xa,!1)}var yr=class t extends Error{constructor(e){super(),this.status=400,this.name="query_parse_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,t)}catch{}}},Vi=class t extends Error{constructor(e){super(),this.status=404,this.name="not_found",this.message=e,this.error=!0;try{Error.captureStackTrace(this,t)}catch{}}},Ji=class t extends Error{constructor(e){super(),this.status=500,this.name="invalid_value",this.message=e,this.error=!0;try{Error.captureStackTrace(this,t)}catch{}}};function Bh(t,e){return e&&t.then(function(r){qt(function(){e(null,r)})},function(r){qt(function(){e(r)})}),t}function Zw(t){return function(...e){var r=e.pop(),n=t.apply(this,e);return typeof r=="function"&&Bh(n,r),n}}function e1(t,e){return t.then(function(r){return e().then(function(){return r})},function(r){return e().then(function(){throw r})})}function ma(t,e){return function(){var r=arguments,n=this;return t.add(function(){return e.apply(n,r)})}}function Wd(t){var e=new Set(t),r=new Array(e.size),n=-1;return e.forEach(function(i){r[++n]=i}),r}function va(t){var e=new Array(t.size),r=-1;return t.forEach(function(n,i){e[++r]=i}),e}function Qd(t){var e="builtin "+t+" function requires map values to be numbers or number arrays";return new Ji(e)}function ja(t){for(var e=0,r=0,n=t.length;r<n;r++){var i=t[r];if(typeof i!="number")if(Array.isArray(i)){e=typeof e=="number"?[e]:e;for(var s=0,o=i.length;s<o;s++){var a=i[s];if(typeof a!="number")throw Qd("_sum");typeof e[s]>"u"?e.push(a):e[s]+=a}}else throw Qd("_sum");else typeof e=="number"?e+=i:e[0]+=i}return e}var t1=vt.bind(null,"log"),r1=Array.isArray,n1=JSON.parse;function Lh(t,e){return Ka("return ("+t.replace(/;\s*$/,"")+");",{emit:e,sum:ja,log:t1,isArray:r1,toJSON:n1})}var jn=class{constructor(){this.promise=Promise.resolve()}add(e){return this.promise=this.promise.catch(()=>{}).then(()=>e()),this.promise}finish(){return this.promise}};function Yd(t){if(!t)return"undefined";switch(typeof t){case"function":return t.toString();case"string":return t.toString();default:return JSON.stringify(t)}}function i1(t,e){return Yd(t)+Yd(e)+"undefined"}async function Xd(t,e,r,n,i,s){let o=i1(r,n),a;if(!i&&(a=t._cachedViews=t._cachedViews||{},a[o]))return a[o];let c=t.info().then(async function(d){let m=d.db_name+"-mrview-"+(i?"temp":gh(o));function f(S){S.views=S.views||{};let y=e;y.indexOf("/")===-1&&(y=e+"/"+e);let w=S.views[y]=S.views[y]||{};if(!w[m])return w[m]=!0,S}await Ui(t,"_local/"+s,f);let _=(await t.registerDependentDatabase(m)).db;_.auto_compaction=!0;let b={name:m,db:_,sourceDB:t,adapter:t.adapter,mapFun:r,reduceFun:n},P;try{P=await b.db.get("_local/lastSeq")}catch(S){if(S.status!==404)throw S}return b.seq=P?P.seq:0,a&&b.db.once("destroyed",function(){delete a[o]}),b});return a&&(a[o]=c),c}var Zd={},eh=new jn,s1=50;function ya(t){return t.indexOf("/")===-1?[t,t]:t.split("/")}function o1(t){return t.length===1&&/^1-/.test(t[0].rev)}function th(t,e,r){try{t.emit("error",e)}catch{vt("error",`The user's map/reduce function threw an uncaught error.
13
+ `);return Ka(e,{})}function pw(t,e){if(t.selector&&t.filter&&t.filter!=="_selector"){var r=typeof t.filter=="string"?t.filter:"function";return e(new Error('selector invalid for filter "'+r+'"'))}e()}function mw(t){t.view&&!t.filter&&(t.filter="_view"),t.selector&&!t.filter&&(t.filter="_selector"),t.filter&&typeof t.filter=="string"&&(t.filter==="_view"?t.view=Dd(t.view):t.filter=Dd(t.filter))}function vw(t,e){return e.filter&&typeof e.filter=="string"&&!e.doc_ids&&!Rt(t.db)}function yw(t,e){var r=e.complete;if(e.filter==="_view"){if(!e.view||typeof e.view!="string"){var n=oe(Qi,"`view` filter parameter not found or invalid.");return r(n)}var i=Ea(e.view);t.db.get("_design/"+i[0],function(o,a){if(t.isCancelled)return r(null,{status:"cancelled"});if(o)return r(Jr(o));var c=a&&a.views&&a.views[i[1]]&&a.views[i[1]].map;if(!c)return r(oe(pt,a.views?"missing json key: "+i[1]:"missing json key: views"));e.filter=hw(c),t.doChanges(e)})}else if(e.selector)e.filter=function(o){return lw(o,e.selector)},t.doChanges(e);else{var s=Ea(e.filter);t.db.get("_design/"+s[0],function(o,a){if(t.isCancelled)return r(null,{status:"cancelled"});if(o)return r(Jr(o));var c=a&&a.filters&&a.filters[s[1]];if(!c)return r(oe(pt,a&&a.filters?"missing json key: "+s[1]:"missing json key: filters"));e.filter=dw(c),t.doChanges(e)})}}function gw(t){t._changesFilterPlugin={validate:pw,normalize:mw,shouldFilter:vw,filter:yw}}ae.plugin(gw);ae.version=D0;function _w(t,e,r){return new Promise(function(n){var i=Ja([""]);let s;if(typeof r=="function"){let a=r(i);s=t.objectStore(e).put(a)}else{let o=r;s=t.objectStore(e).put(i,o)}s.onsuccess=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);n(a||!o||parseInt(o[1],10)>=43)},s.onerror=t.onabort=function(o){o.preventDefault(),o.stopPropagation(),n(!1)}}).catch(function(){return!1})}function qh(t){return t.reduce(function(e,r){return e[r]=!0,e},{})}var ww=qh(["_id","_rev","_access","_attachments","_deleted","_revisions","_revs_info","_conflicts","_deleted_conflicts","_local_seq","_rev_tree","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats","_removed"]),bw=qh(["_access","_attachments","_replication_id","_replication_state","_replication_state_time","_replication_state_reason","_replication_stats"]);function Vd(t){if(!/^\d+-/.test(t))return oe(Di);var e=t.indexOf("-"),r=t.substring(0,e),n=t.substring(e+1);return{prefix:parseInt(r,10),id:n}}function Ew(t,e){for(var r=t.start-t.ids.length+1,n=t.ids,i=[n[0],e,[]],s=1,o=n.length;s<o;s++)i=[n[s],{status:"missing"},[i]];return[{pos:r,ids:i}]}function kh(t,e,r){r||(r={deterministic_revs:!0});var n,i,s,o={status:"available"};if(t._deleted&&(o.deleted=!0),e)if(t._id||(t._id=Yi()),i=_h(t,r.deterministic_revs),t._rev){if(s=Vd(t._rev),s.error)return s;t._rev_tree=[{pos:s.prefix,ids:[s.id,{status:"missing"},[[i,o,[]]]]}],n=s.prefix+1}else t._rev_tree=[{pos:1,ids:[i,o,[]]}],n=1;else if(t._revisions&&(t._rev_tree=Ew(t._revisions,o),n=t._revisions.start,i=t._revisions.ids[0]),!t._rev_tree){if(s=Vd(t._rev),s.error)return s;n=s.prefix,i=s.id,t._rev_tree=[{pos:n,ids:[i,o,[]]}]}ph(t._id),t._rev=n+"-"+i;var a={metadata:{},data:{}};for(var c in t)if(Object.prototype.hasOwnProperty.call(t,c)){var d=c[0]==="_";if(d&&!ww[c]){var m=oe(jd,c);throw m.message=jd.message+": "+c,m}else d&&!bw[c]?a.metadata[c.slice(1)]=t[c]:a.data[c]=t[c]}return a}function $w(t){try{return Va(t)}catch{var e=oe(hh,"Attachment is not a valid base64 string");return{error:e}}}function Sw(t,e,r){var n=$w(t.data);if(n.error)return r(n.error);t.length=n.length,e==="blob"?t.data=Ha(n,t.content_type):e==="base64"?t.data=Dn(n):t.data=n,Ya(n,function(i){t.digest="md5-"+i,r()})}function Pw(t,e,r){Ya(t.data,function(n){t.digest="md5-"+n,t.length=t.data.size||t.data.length||0,e==="binary"?yh(t.data,function(i){t.data=i,r()}):e==="base64"?Qa(t.data,function(i){t.data=i,r()}):r()})}function Ow(t,e,r){if(t.stub)return r();typeof t.data=="string"?Sw(t,e,r):Pw(t,e,r)}function Aw(t,e,r){if(!t.length)return r();var n=0,i;t.forEach(function(o){var a=o.data&&o.data._attachments?Object.keys(o.data._attachments):[],c=0;if(!a.length)return s();function d(f){i=f,c++,c===a.length&&s()}for(var m in o.data._attachments)Object.prototype.hasOwnProperty.call(o.data._attachments,m)&&Ow(o.data._attachments[m],e,d)});function s(){n++,t.length===n&&(i?r(i):r())}}function Iw(t,e,r,n,i,s,o,a){if(b0(e.rev_tree,r.metadata.rev)&&!a)return n[i]=r,s();var c=e.winningRev||br(e),d="deleted"in e?e.deleted:Ut(e,c),m="deleted"in r.metadata?r.metadata.deleted:Ut(r.metadata),f=/^1-/.test(r.metadata.rev);if(d&&!m&&a&&f){var y=r.data;y._rev=c,y._id=r.metadata.id,r=kh(y,a)}var _=Eh(e.rev_tree,r.metadata.rev_tree[0],t),b=a&&(d&&m&&_.conflicts!=="new_leaf"||!d&&_.conflicts!=="new_leaf"||d&&!m&&_.conflicts==="new_branch");if(b){var P=oe(Vr);return n[i]=P,s()}var S=r.metadata.rev;r.metadata.rev_tree=_.tree,r.stemmedRevs=_.stemmedRevs||[],e.rev_map&&(r.metadata.rev_map=e.rev_map);var g=br(r.metadata),w=Ut(r.metadata,g),p=d===w?0:d<w?-1:1,h;S===g?h=w:h=Ut(r.metadata,S),o(r,g,w,h,!0,p,i,s)}function Tw(t){return t.metadata.rev_tree[0].ids[1].status==="missing"}function Rw(t,e,r,n,i,s,o,a,c){t=t||1e3;function d(P,S,g){var w=br(P.metadata),p=Ut(P.metadata,w);if("was_delete"in a&&p)return s[S]=oe(pt,"deleted"),g();var h=m&&Tw(P);if(h){var v=oe(Vr);return s[S]=v,g()}var E=p?0:1;o(P,w,p,p,!1,E,S,g)}var m=a.new_edits,f=new Map,y=0,_=e.length;function b(){++y===_&&c&&c()}e.forEach(function(P,S){if(P._id&&wr(P._id)){var g=P._deleted?"_removeLocal":"_putLocal";r[g](P,{ctx:i},function(p,h){s[S]=p||h,b()});return}var w=P.metadata.id;f.has(w)?(_--,f.get(w).push([P,S])):f.set(w,[[P,S]])}),f.forEach(function(P,S){var g=0;function w(){++g<P.length?p():b()}function p(){var h=P[g],v=h[0],E=h[1];if(n.has(S))Iw(t,n.get(S),v,s,E,w,o,m);else{var k=Eh([],v.metadata.rev_tree[0],t);v.metadata.rev_tree=k.tree,v.stemmedRevs=k.stemmedRevs||[],d(v,E,w)}}p()})}var qw=5,Le="document-store",Je="by-sequence",mt="attach-store",gr="attach-seq-store",rt="meta-store",It="local-store",fa="detect-blob-support";function kw(t){try{return JSON.parse(t)}catch{return Ua.default.parse(t)}}function Cw(t){try{return JSON.stringify(t)}catch{return Ua.default.stringify(t)}}function Tt(t){return function(e){var r="unknown_error";e.target&&e.target.error&&(r=e.target.error.name||e.target.error.message),t(oe(Fa,r,e.type))}}function Ra(t,e,r){return{data:Cw(t),winningRev:e,deletedOrLocal:r?"1":"0",seq:t.seq,id:t.id}}function _r(t){if(!t)return null;var e=kw(t.data);return e.winningRev=t.winningRev,e.deleted=t.deletedOrLocal==="1",e.seq=t.seq,e}function Ki(t){if(!t)return t;var e=t._doc_id_rev.lastIndexOf(":");return t._id=t._doc_id_rev.substring(0,e-1),t._rev=t._doc_id_rev.substring(e+1),delete t._doc_id_rev,t}function Ch(t,e,r,n){r?n(t?typeof t!="string"?t:Wa(t,e):Ja([""],{type:e})):t?typeof t!="string"?vh(t,function(i){n(Dn(i))}):n(t):n("")}function xh(t,e,r,n){var i=Object.keys(t._attachments||{});if(!i.length)return n&&n();var s=0;function o(){++s===i.length&&n&&n()}function a(c,d){var m=c._attachments[d],f=m.digest,y=r.objectStore(mt).get(f);y.onsuccess=function(_){m.body=_.target.result.body,o()}}i.forEach(function(c){e.attachments&&e.include_docs?a(t,c):(t._attachments[c].stub=!0,o())})}function qa(t,e){return Promise.all(t.map(function(r){if(r.doc&&r.doc._attachments){var n=Object.keys(r.doc._attachments);return Promise.all(n.map(function(i){var s=r.doc._attachments[i];if("body"in s){var o=s.body,a=s.content_type;return new Promise(function(c){Ch(o,a,e,function(d){r.doc._attachments[i]=Object.assign(jn(s,["digest","content_type"]),{data:d}),c()})})}}))}}))}function Nh(t,e,r){var n=[],i=r.objectStore(Je),s=r.objectStore(mt),o=r.objectStore(gr),a=t.length;function c(){a--,a||d()}function d(){n.length&&n.forEach(function(m){var f=o.index("digestSeq").count(IDBKeyRange.bound(m+"::",m+"::\uFFFF",!1,!1));f.onsuccess=function(y){var _=y.target.result;_||s.delete(m)}})}t.forEach(function(m){var f=i.index("_doc_id_rev"),y=e+"::"+m;f.getKey(y).onsuccess=function(_){var b=_.target.result;if(typeof b!="number")return c();i.delete(b);var P=o.index("seq").openCursor(IDBKeyRange.only(b));P.onsuccess=function(S){var g=S.target.result;if(g){var w=g.value.digestSeq.split("::")[0];n.push(w),o.delete(g.primaryKey),g.continue()}else c()}}})}function $t(t,e,r){try{return{txn:t.transaction(e,r)}}catch(n){return{error:n}}}var Cn=new wa;function xw(t,e,r,n,i,s){for(var o=e.docs,a,c,d,m,f,y,_,b,P=0,S=o.length;P<S;P++){var g=o[P];g._id&&wr(g._id)||(g=o[P]=kh(g,r.new_edits,t),g.error&&!_&&(_=g))}if(_)return s(_);var w=!1,p=0,h=new Array(o.length),v=new Map,E=!1,k=n._meta.blobSupport?"blob":"base64";Aw(o,k,function(B){if(B)return s(B);x()});function x(){var B=[Le,Je,mt,It,gr,rt],F=$t(i,B,"readwrite");if(F.error)return s(F.error);a=F.txn,a.onabort=Tt(s),a.ontimeout=Tt(s),a.oncomplete=Q,c=a.objectStore(Le),d=a.objectStore(Je),m=a.objectStore(mt),f=a.objectStore(gr),y=a.objectStore(rt),y.get(rt).onsuccess=function(X){b=X.target.result,H()},ce(function(X){if(X)return E=!0,s(X);re()})}function j(){w=!0,H()}function G(){Rw(t.revs_limit,o,n,v,a,h,fe,r,j)}function H(){!b||!w||(b.docCount+=p,y.put(b))}function re(){if(!o.length)return;var B=0;function F(){++B===o.length&&G()}function X(W){var ee=_r(W.target.result);ee&&v.set(ee.id,ee),F()}for(var ie=0,J=o.length;ie<J;ie++){var D=o[ie];if(D._id&&wr(D._id)){F();continue}var M=c.get(D.metadata.id);M.onsuccess=X}}function Q(){E||(Cn.notify(n._meta.name),s(null,h))}function Z(B,F){var X=m.get(B);X.onsuccess=function(ie){if(ie.target.result)F();else{var J=oe(Z_,"unknown stub attachment with digest "+B);J.status=412,F(J)}}}function ce(B){var F=[];if(o.forEach(function(D){D.data&&D.data._attachments&&Object.keys(D.data._attachments).forEach(function(M){var W=D.data._attachments[M];W.stub&&F.push(W.digest)})}),!F.length)return B();var X=0,ie;function J(){++X===F.length&&B(ie)}F.forEach(function(D){Z(D,function(M){M&&!ie&&(ie=M),J()})})}function fe(B,F,X,ie,J,D,M,W){B.metadata.winningRev=F,B.metadata.deleted=X;var ee=B.data;ee._id=B.metadata.id,ee._rev=B.metadata.rev,ie&&(ee._deleted=!0);var ne=ee._attachments&&Object.keys(ee._attachments).length;if(ne)return q(B,F,X,J,M,W);p+=D,H(),me(B,F,X,J,M,W)}function me(B,F,X,ie,J,D){var M=B.data,W=B.metadata;M._doc_id_rev=W.id+"::"+W.rev,delete M._id,delete M._rev;function ee(Re){var We=B.stemmedRevs||[];ie&&n.auto_compaction&&(We=We.concat(p0(B.metadata))),We&&We.length&&Nh(We,B.metadata.id,a),W.seq=Re.target.result;var ct=Ra(W,F,X),ve=c.put(ct);ve.onsuccess=Ee}function ne(Re){Re.preventDefault(),Re.stopPropagation();var We=d.index("_doc_id_rev"),ct=We.getKey(M._doc_id_rev);ct.onsuccess=function(ve){var ge=d.put(M,ve.target.result);ge.onsuccess=ee}}function Ee(){h[J]={ok:!0,id:W.id,rev:W.rev},v.set(B.metadata.id,B.metadata),C(B,W.seq,D)}var $e=d.put(M);$e.onsuccess=ee,$e.onerror=ne}function q(B,F,X,ie,J,D){var M=B.data,W=0,ee=Object.keys(M._attachments);function ne(){W===ee.length&&me(B,F,X,ie,J,D)}function Ee(){W++,ne()}ee.forEach(function($e){var Re=B.data._attachments[$e];if(Re.stub)W++,ne();else{var We=Re.data;delete Re.data,Re.revpos=parseInt(F,10);var ct=Re.digest;L(ct,We,Ee)}})}function C(B,F,X){var ie=0,J=Object.keys(B.data._attachments||{});if(!J.length)return X();function D(){++ie===J.length&&X()}function M(ee){var ne=B.data._attachments[ee].digest,Ee=f.put({seq:F,digestSeq:ne+"::"+F});Ee.onsuccess=D,Ee.onerror=function($e){$e.preventDefault(),$e.stopPropagation(),D()}}for(var W=0;W<J.length;W++)M(J[W])}function L(B,F,X){var ie=m.count(B);ie.onsuccess=function(J){var D=J.target.result;if(D)return X();var M={digest:B,body:F},W=m.put(M);W.onsuccess=X}}}function jh(t,e,r,n,i){n===-1&&(n=1e3);var s=typeof t.getAll=="function"&&typeof t.getAllKeys=="function"&&n>1&&!r,o,a,c;function d(_){a=_.target.result,o&&i(o,a,c)}function m(_){o=_.target.result,a&&i(o,a,c)}function f(){if(!o.length)return i();var _=o[o.length-1],b;if(e&&e.upper)try{b=IDBKeyRange.bound(_,e.upper,!0,e.upperOpen)}catch(P){if(P.name==="DataError"&&P.code===0)return i()}else b=IDBKeyRange.lowerBound(_,!0);e=b,o=null,a=null,t.getAll(e,n).onsuccess=d,t.getAllKeys(e,n).onsuccess=m}function y(_){var b=_.target.result;if(!b)return i();i([b.key],[b.value],b)}s?(c={continue:f},t.getAll(e,n).onsuccess=d,t.getAllKeys(e,n).onsuccess=m):r?t.openCursor(e,"prev").onsuccess=y:t.openCursor(e).onsuccess=y}function Nw(t,e,r){if(typeof t.getAll=="function"){t.getAll(e).onsuccess=r;return}var n=[];function i(s){var o=s.target.result;o?(n.push(o.value),o.continue()):r({target:{result:n}})}t.openCursor(e).onsuccess=i}function jw(t,e,r){var n=new Array(t.length),i=0;t.forEach(function(s,o){e.get(s).onsuccess=function(a){a.target.result?n[o]=a.target.result:n[o]={key:s,error:"not_found"},i++,i===t.length&&r(t,n,{})}})}function Dw(t,e,r,n,i){try{if(t&&e)return i?IDBKeyRange.bound(e,t,!r,!1):IDBKeyRange.bound(t,e,!1,!r);if(t)return i?IDBKeyRange.upperBound(t):IDBKeyRange.lowerBound(t);if(e)return i?IDBKeyRange.lowerBound(e,!r):IDBKeyRange.upperBound(e,!r);if(n)return IDBKeyRange.only(n)}catch(s){return{error:s}}return null}function Bw(t,e,r){var n="startkey"in t?t.startkey:!1,i="endkey"in t?t.endkey:!1,s="key"in t?t.key:!1,o="keys"in t?t.keys:!1,a=t.skip||0,c=typeof t.limit=="number"?t.limit:-1,d=t.inclusive_end!==!1,m,f;if(!o&&(m=Dw(n,i,d,s,t.descending),f=m&&m.error,f&&!(f.name==="DataError"&&f.code===0)))return r(oe(Fa,f.name,f.message));var y=[Le,Je,rt];t.attachments&&y.push(mt);var _=$t(e,y,"readonly");if(_.error)return r(_.error);var b=_.txn;b.oncomplete=re,b.onabort=Tt(r);var P=b.objectStore(Le),S=b.objectStore(Je),g=b.objectStore(rt),w=S.index("_doc_id_rev"),p=[],h,v;g.get(rt).onsuccess=function(Q){h=Q.target.result.docCount},t.update_seq&&(S.openKeyCursor(null,"prev").onsuccess=Q=>{var Z=Q.target.result;Z&&Z.key&&(v=Z.key)});function E(Q,Z,ce){var fe=Q.id+"::"+ce;w.get(fe).onsuccess=function(q){if(Z.doc=Ki(q.target.result)||{},t.conflicts){var C=Za(Q);C.length&&(Z.doc._conflicts=C)}xh(Z.doc,t,b)}}function k(Q,Z){var ce={id:Z.id,key:Z.id,value:{rev:Q}},fe=Z.deleted;fe?o&&(p.push(ce),ce.value.deleted=!0,ce.doc=null):a--<=0&&(p.push(ce),t.include_docs&&E(Z,ce,Q))}function x(Q){for(var Z=0,ce=Q.length;Z<ce&&p.length!==c;Z++){var fe=Q[Z];if(fe.error&&o){p.push(fe);continue}var me=_r(fe),q=me.winningRev;k(q,me)}}function j(Q,Z,ce){ce&&(x(Z),p.length<c&&ce.continue())}function G(Q){var Z=Q.target.result;t.descending&&(Z=Z.reverse()),x(Z)}function H(){var Q={total_rows:h,offset:t.skip,rows:p};t.update_seq&&v!==void 0&&(Q.update_seq=v),r(null,Q)}function re(){t.attachments?qa(p,t.binary).then(H):H()}if(!(f||c===0)){if(o)return jw(o,P,j);if(c===-1)return Nw(P,m,G);jh(P,m,t.descending,c+a,j)}}function Lw(t,e){var r=t.objectStore(Le).index("deletedOrLocal");r.count(IDBKeyRange.only("0")).onsuccess=function(n){e(n.target.result)}}var ka=!1,Ca=[];function Mw(t,e,r,n){try{t(e,r)}catch(i){n.emit("error",i)}}function Jd(){ka||!Ca.length||(ka=!0,Ca.shift()())}function Uw(t,e,r){Ca.push(function(){t(function(s,o){Mw(e,s,o,r),ka=!1,qt(function(){Jd(r)})})}),Jd()}function Gw(t,e,r,n){if(t=Ge(t),t.continuous){var i=r+":"+Yi();return Cn.addListener(r,i,e,t),Cn.notify(r),{cancel:function(){Cn.removeListener(r,i)}}}var s=t.doc_ids&&new Set(t.doc_ids);t.since=t.since||0;var o=t.since,a="limit"in t?t.limit:-1;a===0&&(a=1);var c=[],d=0,m=za(t),f=new Map,y,_,b,P;function S(x,j,G){if(!G||!x.length)return;var H=new Array(x.length),re=new Array(x.length);function Q(fe,me){var q=t.processChange(me,fe,t);o=q.seq=fe.seq;var C=m(q);return typeof C=="object"?Promise.reject(C):C?(d++,t.return_docs&&c.push(q),t.attachments&&t.include_docs?new Promise(function(L){xh(me,t,y,function(){qa([q],t.binary).then(function(){L(q)})})}):Promise.resolve(q)):Promise.resolve()}function Z(){for(var fe=[],me=0,q=H.length;me<q&&d!==a;me++){var C=H[me];if(C){var L=re[me];fe.push(Q(L,C))}}Promise.all(fe).then(function(B){for(var F=0,X=B.length;F<X;F++)B[F]&&t.onChange(B[F])}).catch(t.complete),d!==a&&G.continue()}var ce=0;j.forEach(function(fe,me){var q=Ki(fe),C=x[me];w(q,C,function(L,B){re[me]=L,H[me]=B,++ce===x.length&&Z()})})}function g(x,j,G,H){if(G.seq!==j)return H();if(G.winningRev===x._rev)return H(G,x);var re=x._id+"::"+G.winningRev,Q=P.get(re);Q.onsuccess=function(Z){H(G,Ki(Z.target.result))}}function w(x,j,G){if(s&&!s.has(x._id))return G();var H=f.get(x._id);if(H)return g(x,j,H,G);b.get(x._id).onsuccess=function(re){H=_r(re.target.result),f.set(x._id,H),g(x,j,H,G)}}function p(){t.complete(null,{results:c,last_seq:o})}function h(){!t.continuous&&t.attachments?qa(c).then(p):p()}var v=[Le,Je];t.attachments&&v.push(mt);var E=$t(n,v,"readonly");if(E.error)return t.complete(E.error);y=E.txn,y.onabort=Tt(t.complete),y.oncomplete=h,_=y.objectStore(Je),b=y.objectStore(Le),P=_.index("_doc_id_rev");var k=t.since&&!t.descending?IDBKeyRange.lowerBound(t.since,!0):null;jh(_,k,t.descending,a,S)}var Fr=new Map,la,da=new Map;function Dh(t,e){var r=this;Uw(function(n){Fw(r,t,n)},e,r.constructor)}function Fw(t,e,r){var n=e.name,i=null,s=null;t._meta=null;function o(S){return function(g,w){g&&g instanceof Error&&!g.reason&&s&&(g.reason=s),S(g,w)}}function a(S){var g=S.createObjectStore(Le,{keyPath:"id"});S.createObjectStore(Je,{autoIncrement:!0}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0}),S.createObjectStore(mt,{keyPath:"digest"}),S.createObjectStore(rt,{keyPath:"id",autoIncrement:!1}),S.createObjectStore(fa),g.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),S.createObjectStore(It,{keyPath:"_id"});var w=S.createObjectStore(gr,{autoIncrement:!0});w.createIndex("seq","seq"),w.createIndex("digestSeq","digestSeq",{unique:!0})}function c(S,g){var w=S.objectStore(Le);w.createIndex("deletedOrLocal","deletedOrLocal",{unique:!1}),w.openCursor().onsuccess=function(p){var h=p.target.result;if(h){var v=h.value,E=Ut(v);v.deletedOrLocal=E?"1":"0",w.put(v),h.continue()}else g()}}function d(S){S.createObjectStore(It,{keyPath:"_id"}).createIndex("_doc_id_rev","_doc_id_rev",{unique:!0})}function m(S,g){var w=S.objectStore(It),p=S.objectStore(Le),h=S.objectStore(Je),v=p.openCursor();v.onsuccess=function(E){var k=E.target.result;if(k){var x=k.value,j=x.id,G=wr(j),H=br(x);if(G){var re=j+"::"+H,Q=j+"::",Z=j+"::~",ce=h.index("_doc_id_rev"),fe=IDBKeyRange.bound(Q,Z,!1,!1),me=ce.openCursor(fe);me.onsuccess=function(q){if(me=q.target.result,!me)p.delete(k.primaryKey),k.continue();else{var C=me.value;C._doc_id_rev===re&&w.put(C),h.delete(me.primaryKey),me.continue()}}}else k.continue()}else g&&g()}}function f(S){var g=S.createObjectStore(gr,{autoIncrement:!0});g.createIndex("seq","seq"),g.createIndex("digestSeq","digestSeq",{unique:!0})}function y(S,g){var w=S.objectStore(Je),p=S.objectStore(mt),h=S.objectStore(gr),v=p.count();v.onsuccess=function(E){var k=E.target.result;if(!k)return g();w.openCursor().onsuccess=function(x){var j=x.target.result;if(!j)return g();for(var G=j.value,H=j.primaryKey,re=Object.keys(G._attachments||{}),Q={},Z=0;Z<re.length;Z++){var ce=G._attachments[re[Z]];Q[ce.digest]=!0}var fe=Object.keys(Q);for(Z=0;Z<fe.length;Z++){var me=fe[Z];h.put({seq:H,digestSeq:me+"::"+H})}j.continue()}}}function _(S){function g(v){return v.data?_r(v):(v.deleted=v.deletedOrLocal==="1",v)}var w=S.objectStore(Je),p=S.objectStore(Le),h=p.openCursor();h.onsuccess=function(v){var E=v.target.result;if(!E)return;var k=g(E.value);k.winningRev=k.winningRev||br(k);function x(){var G=k.id+"::",H=k.id+"::\uFFFF",re=w.index("_doc_id_rev").openCursor(IDBKeyRange.bound(G,H)),Q=0;re.onsuccess=function(Z){var ce=Z.target.result;if(!ce)return k.seq=Q,j();var fe=ce.primaryKey;fe>Q&&(Q=fe),ce.continue()}}function j(){var G=Ra(k,k.winningRev,k.deleted),H=p.put(G);H.onsuccess=function(){E.continue()}}if(k.seq)return j();x()}}t._remote=!1,t.type=function(){return"idb"},t._id=fh(function(S){S(null,t._meta.instanceId)}),t._bulkDocs=function(g,w,p){xw(e,g,w,t,i,o(p))},t._get=function(g,w,p){var h,v,E,k=w.ctx;if(!k){var x=$t(i,[Le,Je,mt],"readonly");if(x.error)return p(x.error);k=x.txn}function j(){p(E,{doc:h,metadata:v,ctx:k})}k.objectStore(Le).get(g).onsuccess=function(G){if(v=_r(G.target.result),!v)return E=oe(pt,"missing"),j();var H;if(w.rev)H=w.latest?$0(w.rev,v):w.rev;else{H=v.winningRev;var re=Ut(v);if(re)return E=oe(pt,"deleted"),j()}var Q=k.objectStore(Je),Z=v.id+"::"+H;Q.index("_doc_id_rev").get(Z).onsuccess=function(ce){if(h=ce.target.result,h&&(h=Ki(h)),!h)return E=oe(pt,"missing"),j();j()}}},t._getAttachment=function(S,g,w,p,h){var v;if(p.ctx)v=p.ctx;else{var E=$t(i,[Le,Je,mt],"readonly");if(E.error)return h(E.error);v=E.txn}var k=w.digest,x=w.content_type;v.objectStore(mt).get(k).onsuccess=function(j){var G=j.target.result.body;Ch(G,x,p.binary,function(H){h(null,H)})}},t._info=function(g){var w,p,h=$t(i,[rt,Je],"readonly");if(h.error)return g(h.error);var v=h.txn;v.objectStore(rt).get(rt).onsuccess=function(E){p=E.target.result.docCount},v.objectStore(Je).openKeyCursor(null,"prev").onsuccess=function(E){var k=E.target.result;w=k?k.key:0},v.oncomplete=function(){g(null,{doc_count:p,update_seq:w,idb_attachment_format:t._meta.blobSupport?"binary":"base64"})}},t._allDocs=function(g,w){Bw(g,i,o(w))},t._changes=function(g){return Gw(g,t,n,i)},t._close=function(S){i.close(),Fr.delete(n),S()},t._getRevisionTree=function(S,g){var w=$t(i,[Le],"readonly");if(w.error)return g(w.error);var p=w.txn,h=p.objectStore(Le).get(S);h.onsuccess=function(v){var E=_r(v.target.result);E?g(null,E.rev_tree):g(oe(pt))}},t._doCompaction=function(S,g,w){var p=[Le,Je,mt,gr],h=$t(i,p,"readwrite");if(h.error)return w(h.error);var v=h.txn,E=v.objectStore(Le);E.get(S).onsuccess=function(k){var x=_r(k.target.result);Er(x.rev_tree,function(H,re,Q,Z,ce){var fe=re+"-"+Q;g.indexOf(fe)!==-1&&(ce.status="missing")}),Nh(g,S,v);var j=x.winningRev,G=x.deleted;v.objectStore(Le).put(Ra(x,j,G))},v.onabort=Tt(w),v.oncomplete=function(){w()}},t._getLocal=function(S,g){var w=$t(i,[It],"readonly");if(w.error)return g(w.error);var p=w.txn,h=p.objectStore(It).get(S);h.onerror=Tt(g),h.onsuccess=function(v){var E=v.target.result;E?(delete E._doc_id_rev,g(null,E)):g(oe(pt))}},t._putLocal=function(S,g,w){typeof g=="function"&&(w=g,g={}),delete S._revisions;var p=S._rev,h=S._id;p?S._rev="0-"+(parseInt(p.split("-")[1],10)+1):S._rev="0-1";var v=g.ctx,E;if(!v){var k=$t(i,[It],"readwrite");if(k.error)return w(k.error);v=k.txn,v.onerror=Tt(w),v.oncomplete=function(){E&&w(null,E)}}var x=v.objectStore(It),j;p?(j=x.get(h),j.onsuccess=function(G){var H=G.target.result;if(!H||H._rev!==p)w(oe(Vr));else{var re=x.put(S);re.onsuccess=function(){E={ok:!0,id:S._id,rev:S._rev},g.ctx&&w(null,E)}}}):(j=x.add(S),j.onerror=function(G){w(oe(Vr)),G.preventDefault(),G.stopPropagation()},j.onsuccess=function(){E={ok:!0,id:S._id,rev:S._rev},g.ctx&&w(null,E)})},t._removeLocal=function(S,g,w){typeof g=="function"&&(w=g,g={});var p=g.ctx;if(!p){var h=$t(i,[It],"readwrite");if(h.error)return w(h.error);p=h.txn,p.oncomplete=function(){v&&w(null,v)}}var v,E=S._id,k=p.objectStore(It),x=k.get(E);x.onerror=Tt(w),x.onsuccess=function(j){var G=j.target.result;!G||G._rev!==S._rev?w(oe(pt)):(k.delete(E),v={ok:!0,id:E,rev:"0-0"},g.ctx&&w(null,v))}},t._destroy=function(S,g){Cn.removeAllListeners(n);var w=da.get(n);w&&w.result&&(w.result.close(),Fr.delete(n));var p=indexedDB.deleteDatabase(n);p.onsuccess=function(){da.delete(n),Mi()&&n in localStorage&&delete localStorage[n],g(null,{ok:!0})},p.onerror=Tt(g)};var b=Fr.get(n);if(b)return i=b.idb,t._meta=b.global,qt(function(){r(null,t)});var P=indexedDB.open(n,qw);da.set(n,P),P.onupgradeneeded=function(S){var g=S.target.result;if(S.oldVersion<1)return a(g);var w=S.currentTarget.transaction;S.oldVersion<3&&d(g),S.oldVersion<4&&f(g);var p=[c,m,y,_],h=S.oldVersion;function v(){var E=p[h-1];h++,E&&E(w,v)}v()},P.onsuccess=function(S){i=S.target.result,i.onversionchange=function(){i.close(),Fr.delete(n)},i.onabort=function(j){vt("error","Database has a global failure",j.target.error),s=j.target.error,i.close(),Fr.delete(n)};var g=i.transaction([rt,fa,Le],"readwrite"),w=!1,p,h,v,E;function k(){typeof v>"u"||!w||(t._meta={name:n,instanceId:E,blobSupport:v},Fr.set(n,{idb:i,global:t._meta}),r(null,t))}function x(){if(!(typeof h>"u"||typeof p>"u")){var j=n+"_id";j in p?E=p[j]:p[j]=E=Yi(),p.docCount=h,g.objectStore(rt).put(p)}}g.objectStore(rt).get(rt).onsuccess=function(j){p=j.target.result||{id:rt},x()},Lw(g,function(j){h=j,x()}),la||(la=_w(g,fa,"key")),la.then(function(j){v=j,k()}),g.oncomplete=function(){w=!0,k()},g.onabort=Tt(r)},P.onerror=function(S){var g=S.target.error&&S.target.error.message;g?g.indexOf("stored database is a higher version")!==-1&&(g=new Error('This DB was created with the newer "indexeddb" adapter, but you are trying to open it with the older "idb" adapter')):g="Failed to open indexedDB, are you in private browsing mode?",vt("error",g),r(oe(Fa,g))}}Dh.valid=function(){try{return typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}};function zw(t){t.adapter("idb",Dh,!0)}function Kw(t,e){return new Promise(function(r,n){var i=0,s=0,o=0,a=t.length,c;function d(){i++,t[s++]().then(f,y)}function m(){++o===a?c?n(c):r():_()}function f(){i--,m()}function y(b){i--,c=c||b,m()}function _(){for(;i<e&&s<a;)d()}_()})}var Vw=25,Jw=50,Ni=5e3,Hw=1e4,ha={};function pa(t){let e=t.doc||t.ok,r=e&&e._attachments;r&&Object.keys(r).forEach(function(n){let i=r[n];i.data=Wa(i.data,i.content_type)})}function vr(t){return/^_design/.test(t)?"_design/"+encodeURIComponent(t.slice(8)):t.startsWith("_local/")?"_local/"+encodeURIComponent(t.slice(7)):encodeURIComponent(t)}function Hd(t){return!t._attachments||!Object.keys(t._attachments)?Promise.resolve():Promise.all(Object.keys(t._attachments).map(function(e){let r=t._attachments[e];if(r.data&&typeof r.data!="string")return new Promise(function(n){Qa(r.data,n)}).then(function(n){r.data=n})}))}function Ww(t){if(!t.prefix)return!1;let e=mh(t.prefix).protocol;return e==="http"||e==="https"}function Qw(t,e){if(Ww(e)){let i=e.name.substr(e.prefix.length);t=e.prefix.replace(/\/?$/,"/")+encodeURIComponent(i)}let r=mh(t);(r.user||r.password)&&(r.auth={username:r.user,password:r.password});let n=r.path.replace(/(^\/|\/$)/g,"").split("/");return r.db=n.pop(),r.db.indexOf("%")===-1&&(r.db=encodeURIComponent(r.db)),r.path=n.join("/"),r}function Ue(t,e){return Bi(t,t.db+"/"+e)}function Bi(t,e){let r=t.path?"/":"";return t.protocol+"://"+t.host+(t.port?":"+t.port:"")+"/"+t.path+r+e}function ji(t){let e=Object.keys(t);return e.length===0?"":"?"+e.map(r=>r+"="+encodeURIComponent(t[r])).join("&")}function Yw(t){let e=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",r=e.indexOf("msie")!==-1,n=e.indexOf("trident")!==-1,i=e.indexOf("edge")!==-1,s=!("method"in t)||t.method==="GET";return(r||n||i)&&s}function xa(t,e){let r=this,n=Qw(t.name,t),i=Ue(n,"");t=Ge(t);let s=async function(f,y){if(y=y||{},y.headers=y.headers||new zr,y.credentials="include",t.auth||n.auth){let P=t.auth||n.auth,S=P.username+":"+P.password,g=Dn(unescape(encodeURIComponent(S)));y.headers.set("Authorization","Basic "+g)}let _=t.headers||{};return Object.keys(_).forEach(function(P){y.headers.append(P,_[P])}),Yw(y)&&(f+=(f.indexOf("?")===-1?"?":"&")+"_nonce="+Date.now()),await(t.fetch||Ph)(f,y)};function o(f,y){return De(f,function(..._){d().then(function(){return y.apply(this,_)}).catch(function(b){_.pop()(b)})}).bind(r)}async function a(f,y){let _={};y=y||{},y.headers=y.headers||new zr,y.headers.get("Content-Type")||y.headers.set("Content-Type","application/json"),y.headers.get("Accept")||y.headers.set("Accept","application/json");let b=await s(f,y);_.ok=b.ok,_.status=b.status;let P=await b.json();if(_.data=P,!_.ok)throw _.data.status=_.status,Jr(_.data);return Array.isArray(_.data)&&(_.data=_.data.map(function(S){return S.error||S.missing?Jr(S):S})),_}let c;async function d(){return t.skip_setup?Promise.resolve():c||(c=a(i).catch(function(f){return f&&f.status&&f.status===404?(ba(404,"PouchDB is just detecting if the remote exists."),a(i,{method:"PUT"})):Promise.reject(f)}).catch(function(f){return f&&f.status&&f.status===412?!0:Promise.reject(f)}),c.catch(function(){c=null}),c)}qt(function(){e(null,r)}),r._remote=!0,r.type=function(){return"http"},r.id=o("id",async function(f){let y;try{y=await(await s(Bi(n,""))).json()}catch{y={}}let _=y&&y.uuid?y.uuid+n.db:Ue(n,"");f(null,_)}),r.compact=o("compact",async function(f,y){typeof f=="function"&&(y=f,f={}),f=Ge(f),await a(Ue(n,"_compact"),{method:"POST"});function _(){r.info(function(b,P){P&&!P.compact_running?y(null,{ok:!0}):setTimeout(_,f.interval||200)})}_()}),r.bulkGet=De("bulkGet",function(f,y){let _=this;async function b(w){let p={};f.revs&&(p.revs=!0),f.attachments&&(p.attachments=!0),f.latest&&(p.latest=!0);try{let h=await a(Ue(n,"_bulk_get"+ji(p)),{method:"POST",body:JSON.stringify({docs:f.docs})});f.attachments&&f.binary&&h.data.results.forEach(function(v){v.docs.forEach(pa)}),w(null,h.data)}catch(h){w(h)}}function P(){let w=Jw,p=Math.ceil(f.docs.length/w),h=0,v=new Array(p);function E(k){return function(x,j){v[k]=j.results,++h===p&&y(null,{results:v.flat()})}}for(let k=0;k<p;k++){let x=jn(f,["revs","attachments","binary","latest"]);x.docs=f.docs.slice(k*w,Math.min(f.docs.length,(k+1)*w)),lh(_,x,E(k))}}let S=Bi(n,""),g=ha[S];typeof g!="boolean"?b(function(w,p){w?(ha[S]=!1,ba(w.status,"PouchDB is just detecting if the remote supports the _bulk_get API."),P()):(ha[S]=!0,y(null,p))}):g?b(y):P()}),r._info=async function(f){try{await d();let _=await(await s(Ue(n,""))).json();_.host=Ue(n,""),f(null,_)}catch(y){f(y)}},r.fetch=async function(f,y){await d();let _=f.substring(0,1)==="/"?Bi(n,f.substring(1)):Ue(n,f);return s(_,y)},r.get=o("get",async function(f,y,_){typeof y=="function"&&(_=y,y={}),y=Ge(y);let b={};y.revs&&(b.revs=!0),y.revs_info&&(b.revs_info=!0),y.latest&&(b.latest=!0),y.open_revs&&(y.open_revs!=="all"&&(y.open_revs=JSON.stringify(y.open_revs)),b.open_revs=y.open_revs),y.rev&&(b.rev=y.rev),y.conflicts&&(b.conflicts=y.conflicts),y.update_seq&&(b.update_seq=y.update_seq),f=vr(f);function P(w){let p=w._attachments,h=p&&Object.keys(p);if(!p||!h.length)return;async function v(k){let x=p[k],j=vr(w._id)+"/"+m(k)+"?rev="+w._rev,G=await s(Ue(n,j)),H;"buffer"in G?H=await G.buffer():H=await G.blob();let re;if(y.binary){let Q=Object.getOwnPropertyDescriptor(H.__proto__,"type");(!Q||Q.set)&&(H.type=x.content_type),re=H}else re=await new Promise(function(Q){Qa(H,Q)});delete x.stub,delete x.length,x.data=re}let E=h.map(function(k){return function(){return v(k)}});return Kw(E,5)}function S(w){return Array.isArray(w)?Promise.all(w.map(function(p){if(p.ok)return P(p.ok)})):P(w)}let g=Ue(n,f+ji(b));try{let w=await a(g);y.attachments&&await S(w.data),_(null,w.data)}catch(w){w.docId=f,_(w)}}),r.remove=o("remove",async function(f,y,_,b){let P;typeof y=="string"?(P={_id:f,_rev:y},typeof _=="function"&&(b=_,_={})):(P=f,typeof y=="function"?(b=y,_={}):(b=_,_=y));let S=P._rev||_.rev,g=Ue(n,vr(P._id))+"?rev="+S;try{let w=await a(g,{method:"DELETE"});b(null,w.data)}catch(w){b(w)}});function m(f){return f.split("/").map(encodeURIComponent).join("/")}r.getAttachment=o("getAttachment",async function(f,y,_,b){typeof _=="function"&&(b=_,_={});let P=_.rev?"?rev="+_.rev:"",S=Ue(n,vr(f))+"/"+m(y)+P,g;try{let w=await s(S,{method:"GET"});if(!w.ok)throw w;g=w.headers.get("content-type");let p;if(typeof z<"u"&&!z.browser&&typeof w.buffer=="function"?p=await w.buffer():p=await w.blob(),typeof z<"u"&&!z.browser){let h=Object.getOwnPropertyDescriptor(p.__proto__,"type");(!h||h.set)&&(p.type=g)}b(null,p)}catch(w){b(w)}}),r.removeAttachment=o("removeAttachment",async function(f,y,_,b){let P=Ue(n,vr(f)+"/"+m(y))+"?rev="+_;try{let S=await a(P,{method:"DELETE"});b(null,S.data)}catch(S){b(S)}}),r.putAttachment=o("putAttachment",async function(f,y,_,b,P,S){typeof P=="function"&&(S=P,P=b,b=_,_=null);let g=vr(f)+"/"+m(y),w=Ue(n,g);if(_&&(w+="?rev="+_),typeof b=="string"){let p;try{p=Va(b)}catch{return S(oe(hh,"Attachment is not a valid base64 string"))}b=p?Ha(p,P):""}try{let p=await a(w,{headers:new zr({"Content-Type":P}),method:"PUT",body:b});S(null,p.data)}catch(p){S(p)}}),r._bulkDocs=async function(f,y,_){f.new_edits=y.new_edits;try{await d(),await Promise.all(f.docs.map(Hd));let b=await a(Ue(n,"_bulk_docs"),{method:"POST",body:JSON.stringify(f)});_(null,b.data)}catch(b){_(b)}},r._put=async function(f,y,_){try{await d(),await Hd(f);let b=await a(Ue(n,vr(f._id)),{method:"PUT",body:JSON.stringify(f)});_(null,b.data)}catch(b){b.docId=f&&f._id,_(b)}},r.allDocs=o("allDocs",async function(f,y){typeof f=="function"&&(y=f,f={}),f=Ge(f);let _={},b,P="GET";f.conflicts&&(_.conflicts=!0),f.update_seq&&(_.update_seq=!0),f.descending&&(_.descending=!0),f.include_docs&&(_.include_docs=!0),f.attachments&&(_.attachments=!0),f.key&&(_.key=JSON.stringify(f.key)),f.start_key&&(f.startkey=f.start_key),f.startkey&&(_.startkey=JSON.stringify(f.startkey)),f.end_key&&(f.endkey=f.end_key),f.endkey&&(_.endkey=JSON.stringify(f.endkey)),typeof f.inclusive_end<"u"&&(_.inclusive_end=!!f.inclusive_end),typeof f.limit<"u"&&(_.limit=f.limit),typeof f.skip<"u"&&(_.skip=f.skip);let S=ji(_);typeof f.keys<"u"&&(P="POST",b={keys:f.keys});try{let g=await a(Ue(n,"_all_docs"+S),{method:P,body:JSON.stringify(b)});f.include_docs&&f.attachments&&f.binary&&g.data.rows.forEach(pa),y(null,g.data)}catch(g){y(g)}}),r._changes=function(f){let y="batch_size"in f?f.batch_size:Vw;f=Ge(f),f.continuous&&!("heartbeat"in f)&&(f.heartbeat=Hw);let _="timeout"in f?f.timeout:30*1e3;"timeout"in f&&f.timeout&&_-f.timeout<Ni&&(_=f.timeout+Ni),"heartbeat"in f&&f.heartbeat&&_-f.heartbeat<Ni&&(_=f.heartbeat+Ni);let b={};"timeout"in f&&f.timeout&&(b.timeout=f.timeout);let P=typeof f.limit<"u"?f.limit:!1,S=P;if(f.style&&(b.style=f.style),(f.include_docs||f.filter&&typeof f.filter=="function")&&(b.include_docs=!0),f.attachments&&(b.attachments=!0),f.continuous&&(b.feed="longpoll"),f.seq_interval&&(b.seq_interval=f.seq_interval),f.conflicts&&(b.conflicts=!0),f.descending&&(b.descending=!0),f.update_seq&&(b.update_seq=!0),"heartbeat"in f&&f.heartbeat&&(b.heartbeat=f.heartbeat),f.filter&&typeof f.filter=="string"&&(b.filter=f.filter),f.view&&typeof f.view=="string"&&(b.filter="_view",b.view=f.view),f.query_params&&typeof f.query_params=="object")for(let x in f.query_params)Object.prototype.hasOwnProperty.call(f.query_params,x)&&(b[x]=f.query_params[x]);let g="GET",w;f.doc_ids?(b.filter="_doc_ids",g="POST",w={doc_ids:f.doc_ids}):f.selector&&(b.filter="_selector",g="POST",w={selector:f.selector});let p=new AbortController,h,v=async function(x,j){if(f.aborted)return;b.since=x,typeof b.since=="object"&&(b.since=JSON.stringify(b.since)),f.descending?P&&(b.limit=S):b.limit=!P||S>y?y:S;let G=Ue(n,"_changes"+ji(b)),H={signal:p.signal,method:g,body:JSON.stringify(w)};if(h=x,!f.aborted)try{await d();let re=await a(G,H);j(null,re.data)}catch(re){j(re)}},E={results:[]},k=function(x,j){if(f.aborted)return;let G=0;if(j&&j.results){G=j.results.length,E.last_seq=j.last_seq;let re=null,Q=null;typeof j.pending=="number"&&(re=j.pending),(typeof E.last_seq=="string"||typeof E.last_seq=="number")&&(Q=E.last_seq);let Z={};Z.query=f.query_params,j.results=j.results.filter(function(ce){S--;let fe=za(f)(ce);return fe&&(f.include_docs&&f.attachments&&f.binary&&pa(ce),f.return_docs&&E.results.push(ce),f.onChange(ce,re,Q)),fe})}else if(x){f.aborted=!0,f.complete(x);return}j&&j.last_seq&&(h=j.last_seq);let H=P&&S<=0||j&&G<y||f.descending;f.continuous&&!(P&&S<=0)||!H?qt(function(){v(h,k)}):f.complete(null,E)};return v(f.since||0,k),{cancel:function(){f.aborted=!0,p.abort()}}},r.revsDiff=o("revsDiff",async function(f,y,_){typeof y=="function"&&(_=y,y={});try{let b=await a(Ue(n,"_revs_diff"),{method:"POST",body:JSON.stringify(f)});_(null,b.data)}catch(b){_(b)}}),r._close=function(f){f()},r._destroy=async function(f,y){try{let _=await a(Ue(n,""),{method:"DELETE"});y(null,_)}catch(_){_.status===404?y(null,{ok:!0}):y(_)}}}xa.valid=function(){return!0};function Xw(t){t.adapter("http",xa,!1),t.adapter("https",xa,!1)}var yr=class t extends Error{constructor(e){super(),this.status=400,this.name="query_parse_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,t)}catch{}}},Vi=class t extends Error{constructor(e){super(),this.status=404,this.name="not_found",this.message=e,this.error=!0;try{Error.captureStackTrace(this,t)}catch{}}},Ji=class t extends Error{constructor(e){super(),this.status=500,this.name="invalid_value",this.message=e,this.error=!0;try{Error.captureStackTrace(this,t)}catch{}}};function Bh(t,e){return e&&t.then(function(r){qt(function(){e(null,r)})},function(r){qt(function(){e(r)})}),t}function Zw(t){return function(...e){var r=e.pop(),n=t.apply(this,e);return typeof r=="function"&&Bh(n,r),n}}function e1(t,e){return t.then(function(r){return e().then(function(){return r})},function(r){return e().then(function(){throw r})})}function ma(t,e){return function(){var r=arguments,n=this;return t.add(function(){return e.apply(n,r)})}}function Wd(t){var e=new Set(t),r=new Array(e.size),n=-1;return e.forEach(function(i){r[++n]=i}),r}function va(t){var e=new Array(t.size),r=-1;return t.forEach(function(n,i){e[++r]=i}),e}function Qd(t){var e="builtin "+t+" function requires map values to be numbers or number arrays";return new Ji(e)}function Na(t){for(var e=0,r=0,n=t.length;r<n;r++){var i=t[r];if(typeof i!="number")if(Array.isArray(i)){e=typeof e=="number"?[e]:e;for(var s=0,o=i.length;s<o;s++){var a=i[s];if(typeof a!="number")throw Qd("_sum");typeof e[s]>"u"?e.push(a):e[s]+=a}}else throw Qd("_sum");else typeof e=="number"?e+=i:e[0]+=i}return e}var t1=vt.bind(null,"log"),r1=Array.isArray,n1=JSON.parse;function Lh(t,e){return Ka("return ("+t.replace(/;\s*$/,"")+");",{emit:e,sum:Na,log:t1,isArray:r1,toJSON:n1})}var Nn=class{constructor(){this.promise=Promise.resolve()}add(e){return this.promise=this.promise.catch(()=>{}).then(()=>e()),this.promise}finish(){return this.promise}};function Yd(t){if(!t)return"undefined";switch(typeof t){case"function":return t.toString();case"string":return t.toString();default:return JSON.stringify(t)}}function i1(t,e){return Yd(t)+Yd(e)+"undefined"}async function Xd(t,e,r,n,i,s){let o=i1(r,n),a;if(!i&&(a=t._cachedViews=t._cachedViews||{},a[o]))return a[o];let c=t.info().then(async function(d){let m=d.db_name+"-mrview-"+(i?"temp":gh(o));function f(S){S.views=S.views||{};let g=e;g.indexOf("/")===-1&&(g=e+"/"+e);let w=S.views[g]=S.views[g]||{};if(!w[m])return w[m]=!0,S}await Ui(t,"_local/"+s,f);let _=(await t.registerDependentDatabase(m)).db;_.auto_compaction=!0;let b={name:m,db:_,sourceDB:t,adapter:t.adapter,mapFun:r,reduceFun:n},P;try{P=await b.db.get("_local/lastSeq")}catch(S){if(S.status!==404)throw S}return b.seq=P?P.seq:0,a&&b.db.once("destroyed",function(){delete a[o]}),b});return a&&(a[o]=c),c}var Zd={},eh=new Nn,s1=50;function ya(t){return t.indexOf("/")===-1?[t,t]:t.split("/")}function o1(t){return t.length===1&&/^1-/.test(t[0].rev)}function th(t,e,r){try{t.emit("error",e)}catch{vt("error",`The user's map/reduce function threw an uncaught error.
14
14
  You can debug this error by doing:
15
15
  myDatabase.on('error', function (err) { debugger; });
16
- Please double-check your map/reduce function.`),vt("error",e,r)}}function a1(t,e,r,n){function i(q,C,L){try{C(L)}catch(B){th(q,B,{fun:C,doc:L})}}function s(q,C,L,B,F){try{return{output:C(L,B,F)}}catch(X){return th(q,X,{fun:C,keys:L,values:B,rereduce:F}),{error:X}}}function o(q,C){let L=Be(q.key,C.key);return L!==0?L:Be(q.value,C.value)}function a(q,C,L){return L=L||0,typeof C=="number"?q.slice(L,C+L):L>0?q.slice(L):q}function c(q){let C=q.value;return C&&typeof C=="object"&&C._id||q.id}function d(q){for(let C of q.rows){let L=C.doc&&C.doc._attachments;if(L)for(let B of Object.keys(L)){let F=L[B];L[B].data=Wa(F.data,F.content_type)}}}function m(q){return function(C){return q.include_docs&&q.attachments&&q.binary&&d(C),C}}function f(q,C,L,B){let F=C[q];typeof F<"u"&&(B&&(F=encodeURIComponent(JSON.stringify(F))),L.push(q+"="+F))}function g(q){if(typeof q<"u"){let C=Number(q);return!isNaN(C)&&C===parseInt(q,10)?C:q}}function _(q){return q.group_level=g(q.group_level),q.limit=g(q.limit),q.skip=g(q.skip),q}function b(q){if(q){if(typeof q!="number")return new yr(`Invalid value for integer: "${q}"`);if(q<0)return new yr(`Invalid value for positive integer: "${q}"`)}}function P(q,C){let L=q.descending?"endkey":"startkey",B=q.descending?"startkey":"endkey";if(typeof q[L]<"u"&&typeof q[B]<"u"&&Be(q[L],q[B])>0)throw new yr("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(C.reduce&&q.reduce!==!1){if(q.include_docs)throw new yr("{include_docs:true} is invalid for reduce");if(q.keys&&q.keys.length>1&&!q.group&&!q.group_level)throw new yr("Multi-key fetches for reduce views must use {group: true}")}for(let F of["group_level","limit","skip"]){let X=b(q[F]);if(X)throw X}}async function S(q,C,L){let B=[],F,X="GET",ie;if(f("reduce",L,B),f("include_docs",L,B),f("attachments",L,B),f("limit",L,B),f("descending",L,B),f("group",L,B),f("group_level",L,B),f("skip",L,B),f("stale",L,B),f("conflicts",L,B),f("startkey",L,B,!0),f("start_key",L,B,!0),f("endkey",L,B,!0),f("end_key",L,B,!0),f("inclusive_end",L,B),f("key",L,B,!0),f("update_seq",L,B),B=B.join("&"),B=B===""?"":"?"+B,typeof L.keys<"u"){let W=`keys=${encodeURIComponent(JSON.stringify(L.keys))}`;W.length+B.length+1<=2e3?B+=(B[0]==="?"?"&":"?")+W:(X="POST",typeof C=="string"?F={keys:L.keys}:C.keys=L.keys)}if(typeof C=="string"){let M=ya(C),W=await q.fetch("_design/"+M[0]+"/_view/"+M[1]+B,{headers:new zr({"Content-Type":"application/json"}),method:X,body:JSON.stringify(F)});ie=W.ok;let ee=await W.json();if(!ie)throw ee.status=W.status,Jr(ee);for(let ne of ee.rows)if(ne.value&&ne.value.error&&ne.value.error==="builtin_reduce_error")throw new Error(ne.reason);return new Promise(function(ne){ne(ee)}).then(m(L))}F=F||{};for(let M of Object.keys(C))Array.isArray(C[M])?F[M]=C[M]:F[M]=C[M].toString();let J=await q.fetch("_temp_view"+B,{headers:new zr({"Content-Type":"application/json"}),method:"POST",body:JSON.stringify(F)});ie=J.ok;let D=await J.json();if(!ie)throw D.status=J.status,Jr(D);return new Promise(function(M){M(D)}).then(m(L))}function y(q,C,L){return new Promise(function(B,F){q._query(C,L,function(X,ie){if(X)return F(X);B(ie)})})}function w(q){return new Promise(function(C,L){q._viewCleanup(function(B,F){if(B)return L(B);C(F)})})}function p(q){return function(C){if(C.status===404)return q;throw C}}async function h(q,C,L){let B="_local/doc_"+q,F={_id:B,keys:[]},X=L.get(q),ie=X[0],J=X[1];function D(){return o1(J)?Promise.resolve(F):C.db.get(B).catch(p(F))}function M(Ee){return Ee.keys.length?C.db.allDocs({keys:Ee.keys,include_docs:!0}):Promise.resolve({rows:[]})}function W(Ee,$e){let Re=[],We=new Set;for(let ve of $e.rows){let ge=ve.doc;if(ge&&(Re.push(ge),We.add(ge._id),ge._deleted=!ie.has(ge._id),!ge._deleted)){let Se=ie.get(ge._id);"value"in Se&&(ge.value=Se.value)}}let ct=va(ie);for(let ve of ct)if(!We.has(ve)){let ge={_id:ve},Se=ie.get(ve);"value"in Se&&(ge.value=Se.value),Re.push(ge)}return Ee.keys=Wd(ct.concat(Ee.keys)),Re.push(Ee),Re}let ee=await D(),ne=await M(ee);return W(ee,ne)}function v(q){return q.sourceDB.get("_local/purges").then(function(C){let L=C.purgeSeq;return q.db.get("_local/purgeSeq").then(function(B){return B._rev}).catch(p(void 0)).then(function(B){return q.db.put({_id:"_local/purgeSeq",_rev:B,purgeSeq:L})})}).catch(function(C){if(C.status!==404)throw C})}function E(q,C,L){var B="_local/lastSeq";return q.db.get(B).catch(p({_id:B,seq:0})).then(function(F){var X=va(C);return Promise.all(X.map(function(ie){return h(ie,q,C)})).then(function(ie){var J=ie.flat();return F.seq=L,J.push(F),q.db.bulkDocs({docs:J})}).then(()=>v(q))})}function k(q){let C=typeof q=="string"?q:q.name,L=Zd[C];return L||(L=Zd[C]=new jn),L}async function x(q,C){return ma(k(q),function(){return N(q,C)})()}async function N(q,C){let L,B,F;function X(ve,ge){let Se={id:B._id,key:$r(ve)};typeof ge<"u"&&ge!==null&&(Se.value=$r(ge)),L.push(Se)}let ie=e(q.mapFun,X),J=q.seq||0;function D(){return q.sourceDB.info().then(function(ve){F=q.sourceDB.activeTasks.add({name:"view_indexing",total_items:ve.update_seq-J})})}function M(ve,ge){return function(){return E(q,ve,ge)}}let W=0,ee={view:q.name,indexed_docs:W};q.sourceDB.emit("indexing",ee);let ne=new jn;async function Ee(){let ve=await q.sourceDB.changes({return_docs:!0,conflicts:!0,include_docs:!0,style:"all_docs",since:J,limit:C.changes_batch_size}),ge=await $e();return Re(ve,ge)}function $e(){return q.db.get("_local/purgeSeq").then(function(ve){return ve.purgeSeq}).catch(p(-1)).then(function(ve){return q.sourceDB.get("_local/purges").then(function(ge){let Se=ge.purges.filter(function(Fe,Pe){return Pe>ve}).map(Fe=>Fe.docId),nt=Se.filter(function(Fe,Pe){return Se.indexOf(Fe)===Pe});return Promise.all(nt.map(function(Fe){return q.sourceDB.get(Fe).then(function(Pe){return{docId:Fe,doc:Pe}}).catch(p({docId:Fe}))}))}).catch(p([]))})}function Re(ve,ge){let Se=ve.results;if(!Se.length&&!ge.length)return;for(let Pe of ge)if(Se.findIndex(function(tr){return tr.id===Pe.docId})<0){let tr={_id:Pe.docId,doc:{_id:Pe.docId,_deleted:1},changes:[]};Pe.doc&&(tr.doc=Pe.doc,tr.changes.push({rev:Pe.doc._rev})),Se.push(tr)}let nt=We(Se);ne.add(M(nt,J)),W=W+Se.length;let Fe={view:q.name,last_seq:ve.last_seq,results_count:Se.length,indexed_docs:W};if(q.sourceDB.emit("indexing",Fe),q.sourceDB.activeTasks.update(F,{completed_items:W}),!(Se.length<C.changes_batch_size))return Ee()}function We(ve){let ge=new Map;for(let Se of ve){if(Se.doc._id[0]!=="_"){L=[],B=Se.doc,B._deleted||i(q.sourceDB,ie,B),L.sort(o);let nt=ct(L);ge.set(Se.doc._id,[nt,Se.changes])}J=Se.seq}return ge}function ct(ve){let ge=new Map,Se;for(let nt=0,Fe=ve.length;nt<Fe;nt++){let Pe=ve[nt],er=[Pe.key,Pe.id];nt>0&&Be(Pe.key,Se)===0&&er.push(nt),ge.set(Et(er),Pe),Se=Pe.key}return ge}try{await D(),await Ee(),await ne.finish(),q.seq=J,q.sourceDB.activeTasks.remove(F)}catch(ve){q.sourceDB.activeTasks.remove(F,ve)}}function G(q,C,L){L.group_level===0&&delete L.group_level;let B=L.group||L.group_level,F=r(q.reduceFun),X=[],ie=isNaN(L.group_level)?Number.POSITIVE_INFINITY:L.group_level;for(let J of C){let D=X[X.length-1],M=B?J.key:null;if(B&&Array.isArray(M)&&(M=M.slice(0,ie)),D&&Be(D.groupKey,M)===0){D.keys.push([J.key,J.id]),D.values.push(J.value);continue}X.push({keys:[[J.key,J.id]],values:[J.value],groupKey:M})}C=[];for(let J of X){let D=s(q.sourceDB,F,J.keys,J.values,!1);if(D.error&&D.error instanceof Ji)throw D.error;C.push({value:D.error?null:D.output,key:J.groupKey})}return{rows:a(C,L.limit,L.skip)}}function H(q,C){return ma(k(q),function(){return re(q,C)})()}async function re(q,C){let L,B=q.reduceFun&&C.reduce!==!1,F=C.skip||0;typeof C.keys<"u"&&!C.keys.length&&(C.limit=0,delete C.keys);async function X(J){J.include_docs=!0;let D=await q.db.allDocs(J);return L=D.total_rows,D.rows.map(function(M){if("value"in M.doc&&typeof M.doc.value=="object"&&M.doc.value!==null){let ee=Object.keys(M.doc.value).sort(),ne=["id","key","value"];if(!(ee<ne||ee>ne))return M.doc.value}let W=X0(M.doc._id);return{key:W[0],id:W[1],value:"value"in M.doc?M.doc.value:null}})}async function ie(J){let D;if(B?D=G(q,J,C):typeof C.keys>"u"?D={total_rows:L,offset:F,rows:J}:D={total_rows:L,offset:F,rows:a(J,C.limit,C.skip)},C.update_seq&&(D.update_seq=q.seq),C.include_docs){let M=Wd(J.map(c)),W=await q.sourceDB.allDocs({keys:M,include_docs:!0,conflicts:C.conflicts,attachments:C.attachments,binary:C.binary}),ee=new Map;for(let ne of W.rows)ee.set(ne.id,ne.doc);for(let ne of J){let Ee=c(ne),$e=ee.get(Ee);$e&&(ne.doc=$e)}}return D}if(typeof C.keys<"u"){let D=C.keys.map(function(ee){let ne={startkey:Et([ee]),endkey:Et([ee,{}])};return C.update_seq&&(ne.update_seq=!0),X(ne)}),W=(await Promise.all(D)).flat();return ie(W)}else{let J={descending:C.descending};C.update_seq&&(J.update_seq=!0);let D,M;if("start_key"in C&&(D=C.start_key),"startkey"in C&&(D=C.startkey),"end_key"in C&&(M=C.end_key),"endkey"in C&&(M=C.endkey),typeof D<"u"&&(J.startkey=C.descending?Et([D,{}]):Et([D])),typeof M<"u"){let ee=C.inclusive_end!==!1;C.descending&&(ee=!ee),J.endkey=Et(ee?[M,{}]:[M])}if(typeof C.key<"u"){let ee=Et([C.key]),ne=Et([C.key,{}]);J.descending?(J.endkey=ee,J.startkey=ne):(J.startkey=ee,J.endkey=ne)}B||(typeof C.limit=="number"&&(J.limit=C.limit),J.skip=F);let W=await X(J);return ie(W)}}async function Q(q){return(await q.fetch("_view_cleanup",{headers:new zr({"Content-Type":"application/json"}),method:"POST"})).json()}async function Z(q){try{let C=await q.get("_local/"+t),L=new Map;for(let D of Object.keys(C.views)){let M=ya(D),W="_design/"+M[0],ee=M[1],ne=L.get(W);ne||(ne=new Set,L.set(W,ne)),ne.add(ee)}let B={keys:va(L),include_docs:!0},F=await q.allDocs(B),X={};for(let D of F.rows){let M=D.key.substring(8);for(let W of L.get(D.key)){let ee=M+"/"+W;C.views[ee]||(ee=W);let ne=Object.keys(C.views[ee]),Ee=D.doc&&D.doc.views&&D.doc.views[W];for(let $e of ne)X[$e]=X[$e]||Ee}}let J=Object.keys(X).filter(function(D){return!X[D]}).map(function(D){return ma(k(D),function(){return new q.constructor(D,q.__opts).destroy()})()});return Promise.all(J).then(function(){return{ok:!0}})}catch(C){if(C.status===404)return{ok:!0};throw C}}async function ce(q,C,L){if(typeof q._query=="function")return y(q,C,L);if(Rt(q))return S(q,C,L);let B={changes_batch_size:q.__opts.view_update_changes_batch_size||s1};if(typeof C!="string")return P(L,C),eh.add(async function(){let F=await Xd(q,"temp_view/temp_view",C.map,C.reduce,!0,t);return e1(x(F,B).then(function(){return H(F,L)}),function(){return F.db.destroy()})}),eh.finish();{let F=C,X=ya(F),ie=X[0],J=X[1],D=await q.get("_design/"+ie);if(C=D.views&&D.views[J],!C)throw new Vi(`ddoc ${D._id} has no view named ${J}`);n(D,J),P(L,C);let M=await Xd(q,F,C.map,C.reduce,!1,t);return L.stale==="ok"||L.stale==="update_after"?(L.stale==="update_after"&&qt(function(){x(M,B)}),H(M,L)):(await x(M,B),H(M,L))}}function fe(q,C,L){let B=this;typeof C=="function"&&(L=C,C={}),C=C?_(C):{},typeof q=="function"&&(q={map:q});let F=Promise.resolve().then(function(){return ce(B,q,C)});return Bh(F,L),F}let me=Zw(function(){let q=this;return typeof q._viewCleanup=="function"?w(q):Rt(q)?Q(q):Z(q)});return{query:fe,viewCleanup:me}}var ga={_sum:function(t,e){return ja(e)},_count:function(t,e){return e.length},_stats:function(t,e){function r(n){for(var i=0,s=0,o=n.length;s<o;s++){var a=n[s];i+=a*a}return i}return{sum:ja(e),min:Math.min.apply(null,e),max:Math.max.apply(null,e),count:e.length,sumsqr:r(e)}}};function u1(t){if(/^_sum/.test(t))return ga._sum;if(/^_count/.test(t))return ga._count;if(/^_stats/.test(t))return ga._stats;if(/^_/.test(t))throw new Error(t+" is not a supported reduce function.")}function c1(t,e){if(typeof t=="function"&&t.length===2){var r=t;return function(n){return r(n,e)}}else return Lh(t.toString(),e)}function f1(t){var e=t.toString(),r=u1(e);return r||Lh(e)}function l1(t,e){var r=t.views&&t.views[e];if(typeof r.map!="string")throw new Vi("ddoc "+t._id+" has no string view named "+e+", instead found object of type: "+typeof r.map)}var d1="mrviews",Mh=a1(d1,c1,f1,l1);function h1(t,e,r){return Mh.query.call(this,t,e,r)}function p1(t){return Mh.viewCleanup.call(this,t)}var m1={query:h1,viewCleanup:p1};function v1(t,e,r){return!t._attachments||!t._attachments[r]||t._attachments[r].digest!==e._attachments[r].digest}function rh(t,e){var r=Object.keys(e._attachments);return Promise.all(r.map(function(n){return t.getAttachment(e._id,n,{rev:e._rev})}))}function y1(t,e,r){var n=Rt(e)&&!Rt(t),i=Object.keys(r._attachments);return n?t.get(r._id).then(function(s){return Promise.all(i.map(function(o){return v1(s,r,o)?e.getAttachment(r._id,o):t.getAttachment(s._id,o)}))}).catch(function(s){if(s.status!==404)throw s;return rh(e,r)}):rh(e,r)}function g1(t){var e=[];return Object.keys(t).forEach(function(r){var n=t[r].missing;n.forEach(function(i){e.push({id:r,rev:i})})}),{docs:e,revs:!0,latest:!0}}function _1(t,e,r,n){r=Ge(r);var i=[],s=!0;function o(){var c=g1(r);if(c.docs.length)return t.bulkGet(c).then(function(d){if(n.cancelled)throw new Error("cancelled");return Promise.all(d.results.map(function(m){return Promise.all(m.docs.map(function(f){var g=f.ok;return f.error&&(s=!1),!g||!g._attachments?g:y1(e,t,g).then(_=>{var b=Object.keys(g._attachments);return _.forEach(function(P,S){var y=g._attachments[b[S]];delete y.stub,delete y.length,y.data=P}),g})}))})).then(function(m){i=i.concat(m.flat().filter(Boolean))})})}function a(){return{ok:s,docs:i}}return Promise.resolve().then(o).then(a)}var nh=1,ih="pouchdb",w1=5,bt=0;function Na(t,e,r,n,i){return t.get(e).catch(function(s){if(s.status===404)return(t.adapter==="http"||t.adapter==="https")&&ba(404,"PouchDB is just checking if a remote checkpoint exists."),{session_id:n,_id:e,history:[],replicator:ih,version:nh};throw s}).then(function(s){if(!i.cancelled&&s.last_seq!==r)return s.history=(s.history||[]).filter(function(o){return o.session_id!==n}),s.history.unshift({last_seq:r,session_id:n}),s.history=s.history.slice(0,w1),s.version=nh,s.replicator=ih,s.session_id=n,s.last_seq=r,t.put(s).catch(function(o){if(o.status===409)return Na(t,e,r,n,i);throw o})})}var Hi=class{constructor(e,r,n,i,s={writeSourceCheckpoint:!0,writeTargetCheckpoint:!0}){this.src=e,this.target=r,this.id=n,this.returnValue=i,this.opts=s,typeof s.writeSourceCheckpoint>"u"&&(s.writeSourceCheckpoint=!0),typeof s.writeTargetCheckpoint>"u"&&(s.writeTargetCheckpoint=!0)}writeCheckpoint(e,r){var n=this;return this.updateTarget(e,r).then(function(){return n.updateSource(e,r)})}updateTarget(e,r){return this.opts.writeTargetCheckpoint?Na(this.target,this.id,e,r,this.returnValue):Promise.resolve(!0)}updateSource(e,r){if(this.opts.writeSourceCheckpoint){var n=this;return Na(this.src,this.id,e,r,this.returnValue).catch(function(i){if(oh(i))return n.opts.writeSourceCheckpoint=!1,!0;throw i})}else return Promise.resolve(!0)}getCheckpoint(){var e=this;return!e.opts.writeSourceCheckpoint&&!e.opts.writeTargetCheckpoint?Promise.resolve(bt):e.opts&&e.opts.writeSourceCheckpoint&&!e.opts.writeTargetCheckpoint?e.src.get(e.id).then(function(r){return r.last_seq||bt}).catch(function(r){if(r.status!==404)throw r;return bt}):e.target.get(e.id).then(function(r){return e.opts&&e.opts.writeTargetCheckpoint&&!e.opts.writeSourceCheckpoint?r.last_seq||bt:e.src.get(e.id).then(function(n){if(r.version!==n.version)return bt;var i;return r.version?i=r.version.toString():i="undefined",i in sh?sh[i](r,n):bt},function(n){if(n.status===404&&r.last_seq)return e.src.put({_id:e.id,last_seq:bt}).then(function(){return bt},function(i){return oh(i)?(e.opts.writeSourceCheckpoint=!1,r.last_seq):bt});throw n})}).catch(function(r){if(r.status!==404)throw r;return bt})}},sh={undefined:function(t,e){return Be(t.last_seq,e.last_seq)===0?e.last_seq:0},1:function(t,e){return b1(e,t).last_seq}};function b1(t,e){return t.session_id===e.session_id?{last_seq:t.last_seq,history:t.history}:Uh(t.history,e.history)}function Uh(t,e){var r=t[0],n=t.slice(1),i=e[0],s=e.slice(1);if(!r||e.length===0)return{last_seq:bt,history:[]};var o=r.session_id;if(Da(o,e))return{last_seq:r.last_seq,history:t};var a=i.session_id;return Da(a,n)?{last_seq:i.last_seq,history:s}:Uh(n,s)}function Da(t,e){var r=e[0],n=e.slice(1);return!t||e.length===0?!1:t===r.session_id?!0:Da(t,n)}function oh(t){return typeof t.status=="number"&&Math.floor(t.status/100)===4}function Gh(t,e,r,n,i){return this instanceof Hi?Gh:new Hi(t,e,r,n,i)}var ah=0;function E1(t,e,r,n){if(t.retry===!1){e.emit("error",r),e.removeAllListeners();return}if(typeof t.back_off_function!="function"&&(t.back_off_function=H_),e.emit("requestError",r),e.state==="active"||e.state==="pending"){e.emit("paused",r),e.state="stopped";var i=function(){t.current_back_off=ah},s=function(){e.removeListener("active",i)};e.once("paused",s),e.once("active",i)}t.current_back_off=t.current_back_off||ah,t.current_back_off=t.back_off_function(t.current_back_off),setTimeout(n,t.current_back_off)}function $1(t){return Object.keys(t).sort(Be).reduce(function(e,r){return e[r]=t[r],e},{})}function S1(t,e,r){var n=r.doc_ids?r.doc_ids.sort(Be):"",i=r.filter?r.filter.toString():"",s="",o="",a="";return r.selector&&(a=JSON.stringify(r.selector)),r.filter&&r.query_params&&(s=JSON.stringify($1(r.query_params))),r.filter&&r.filter==="_view"&&(o=r.view.toString()),Promise.all([t.id(),e.id()]).then(function(c){var d=c[0]+c[1]+i+o+s+n+a;return new Promise(function(m){Ya(d,m)})}).then(function(c){return c=c.replace(/\//g,".").replace(/\+/g,"_"),"_local/"+c})}function Fh(t,e,r,n,i){var s=[],o,a={seq:0,changes:[],docs:[]},c=!1,d=!1,m=!1,f=0,g=0,_=r.continuous||r.live||!1,b=r.batch_size||100,P=r.batches_limit||10,S=r.style||"all_docs",y=!1,w=r.doc_ids,p=r.selector,h,v,E=[],k=Yi(),x;i=i||{ok:!0,start_time:new Date().toISOString(),docs_read:0,docs_written:0,doc_write_failures:0,errors:[]};var N={};n.ready(t,e);function G(){return v?Promise.resolve():S1(t,e,r).then(function(D){h=D;var M={};r.checkpoint===!1?M={writeSourceCheckpoint:!1,writeTargetCheckpoint:!1}:r.checkpoint==="source"?M={writeSourceCheckpoint:!0,writeTargetCheckpoint:!1}:r.checkpoint==="target"?M={writeSourceCheckpoint:!1,writeTargetCheckpoint:!0}:M={writeSourceCheckpoint:!0,writeTargetCheckpoint:!0},v=new Gh(t,e,h,n,M)})}function H(){if(E=[],o.docs.length!==0){var D=o.docs,M={timeout:r.timeout};return e.bulkDocs({docs:D,new_edits:!1},M).then(function(W){if(n.cancelled)throw q(),new Error("cancelled");var ee=Object.create(null);W.forEach(function(Ee){Ee.error&&(ee[Ee.id]=Ee)});var ne=Object.keys(ee).length;i.doc_write_failures+=ne,i.docs_written+=D.length-ne,D.forEach(function(Ee){var $e=ee[Ee._id];if($e){i.errors.push($e);var Re=($e.name||"").toLowerCase();if(Re==="unauthorized"||Re==="forbidden")n.emit("denied",Ge($e));else throw $e}else E.push(Ee)})},function(W){throw i.doc_write_failures+=D.length,W})}}function re(){if(o.error)throw new Error("There was a problem getting docs.");i.last_seq=g=o.seq;var D=Ge(i);return E.length&&(D.docs=E,typeof o.pending=="number"&&(D.pending=o.pending,delete o.pending),n.emit("change",D)),c=!0,t.info().then(function(M){var W=t.activeTasks.get(x);if(!(!o||!W)){var ee=W.completed_items||0,ne=parseInt(M.update_seq,10)-parseInt(f,10);t.activeTasks.update(x,{completed_items:ee+o.changes.length,total_items:ne})}}),v.writeCheckpoint(o.seq,k).then(function(){if(n.emit("checkpoint",{checkpoint:o.seq}),c=!1,n.cancelled)throw q(),new Error("cancelled");o=void 0,F()}).catch(function(M){throw J(M),M})}function Q(){var D={};return o.changes.forEach(function(M){n.emit("checkpoint",{revs_diff:M}),M.id!=="_user/"&&(D[M.id]=M.changes.map(function(W){return W.rev}))}),e.revsDiff(D).then(function(M){if(n.cancelled)throw q(),new Error("cancelled");o.diffs=M})}function Z(){return _1(t,e,o.diffs,n).then(function(D){o.error=!D.ok,D.docs.forEach(function(M){delete o.diffs[M._id],i.docs_read++,o.docs.push(M)})})}function ce(){if(!(n.cancelled||o)){if(s.length===0){fe(!0);return}o=s.shift(),n.emit("checkpoint",{start_next_batch:o.seq}),Q().then(Z).then(H).then(re).then(ce).catch(function(D){me("batch processing terminated with error",D)})}}function fe(D){if(a.changes.length===0){s.length===0&&!o&&((_&&N.live||d)&&(n.state="pending",n.emit("paused")),d&&q());return}(D||d||a.changes.length>=b)&&(s.push(a),a={seq:0,changes:[],docs:[]},(n.state==="pending"||n.state==="stopped")&&(n.state="active",n.emit("active")),ce())}function me(D,M){m||(M.message||(M.message=D),i.ok=!1,i.status="aborting",s=[],a={seq:0,changes:[],docs:[]},q(M))}function q(D){if(!m&&!(n.cancelled&&(i.status="cancelled",c)))if(i.status=i.status||"complete",i.end_time=new Date().toISOString(),i.last_seq=g,m=!0,t.activeTasks.remove(x,D),D){D=oe(D),D.result=i;var M=(D.name||"").toLowerCase();M==="unauthorized"||M==="forbidden"?(n.emit("error",D),n.removeAllListeners()):E1(r,n,D,function(){Fh(t,e,r,n)})}else n.emit("complete",i),n.removeAllListeners()}function C(D,M,W){if(n.cancelled)return q();typeof M=="number"&&(a.pending=M);var ee=za(r)(D);if(!ee){var ne=t.activeTasks.get(x);if(ne){var Ee=ne.completed_items||0;t.activeTasks.update(x,{completed_items:++Ee})}return}a.seq=D.seq||W,a.changes.push(D),n.emit("checkpoint",{pending_batch:a.seq}),qt(function(){fe(s.length===0&&N.live)})}function L(D){if(y=!1,n.cancelled)return q();if(D.results.length>0)N.since=D.results[D.results.length-1].seq,F(),fe(!0);else{var M=function(){_?(N.live=!0,F()):d=!0,fe(!0)};!o&&D.results.length===0?(c=!0,v.writeCheckpoint(D.last_seq,k).then(function(){if(c=!1,i.last_seq=g=D.last_seq,n.cancelled)throw q(),new Error("cancelled");M()}).catch(J)):M()}}function B(D){if(y=!1,n.cancelled)return q();me("changes rejected",D)}function F(){if(!(!y&&!d&&s.length<P))return;y=!0;function D(){W.cancel()}function M(){n.removeListener("cancel",D)}n._changes&&(n.removeListener("cancel",n._abortChanges),n._changes.cancel()),n.once("cancel",D);var W=t.changes(N).on("change",C);W.then(M,M),W.then(L).catch(B),r.retry&&(n._changes=W,n._abortChanges=D)}function X(D){return t.info().then(function(M){var W=typeof r.since>"u"?parseInt(M.update_seq,10)-parseInt(D,10):parseInt(M.update_seq,10);return x=t.activeTasks.add({name:`${_?"continuous ":""}replication from ${M.db_name}`,total_items:W}),D})}function ie(){G().then(function(){if(n.cancelled){q();return}return v.getCheckpoint().then(X).then(function(D){g=D,f=D,N={since:g,limit:b,batch_size:b,style:S,doc_ids:w,selector:p,return_docs:!0},r.filter&&(typeof r.filter!="string"?N.include_docs=!0:N.filter=r.filter),"heartbeat"in r&&(N.heartbeat=r.heartbeat),"timeout"in r&&(N.timeout=r.timeout),r.query_params&&(N.query_params=r.query_params),r.view&&(N.view=r.view),F()})}).catch(function(D){me("getCheckpoint rejected with ",D)})}function J(D){c=!1,me("writeCheckpoint completed with error",D)}if(n.cancelled){q();return}n._addedListeners||(n.once("cancel",q),typeof r.complete=="function"&&(n.once("error",r.complete),n.once("complete",function(D){r.complete(null,D)})),n._addedListeners=!0),typeof r.since>"u"?ie():G().then(function(){return c=!0,v.writeCheckpoint(r.since,k)}).then(function(){if(c=!1,n.cancelled){q();return}g=r.since,ie()}).catch(J)}var Ba=class extends ut{constructor(){super(),this.cancelled=!1,this.state="pending";let e=new Promise((r,n)=>{this.once("complete",r),this.once("error",n)});this.then=function(r,n){return e.then(r,n)},this.catch=function(r){return e.catch(r)},this.catch(function(){})}cancel(){this.cancelled=!0,this.state="cancelled",this.emit("cancel")}ready(e,r){if(this._readyCalled)return;this._readyCalled=!0;let n=()=>{this.cancel()};e.once("destroyed",n),r.once("destroyed",n);function i(){e.removeListener("destroyed",n),r.removeListener("destroyed",n)}this.once("complete",i),this.once("error",i)}};function Wi(t,e){var r=e.PouchConstructor;return typeof t=="string"?new r(t,e):t}function La(t,e,r,n){if(typeof r=="function"&&(n=r,r={}),typeof r>"u"&&(r={}),r.doc_ids&&!Array.isArray(r.doc_ids))throw oe(Qi,"`doc_ids` filter parameter is not a list.");r.complete=n,r=Ge(r),r.continuous=r.continuous||r.live,r.retry="retry"in r?r.retry:!1,r.PouchConstructor=r.PouchConstructor||this;var i=new Ba(r),s=Wi(t,r),o=Wi(e,r);return Fh(s,o,r,i),i}function P1(t,e,r,n){return typeof r=="function"&&(n=r,r={}),typeof r>"u"&&(r={}),r=Ge(r),r.PouchConstructor=r.PouchConstructor||this,t=Wi(t,r),e=Wi(e,r),new Ma(t,e,r,n)}var Ma=class extends ut{constructor(e,r,n,i){super(),this.canceled=!1;let s=n.push?Object.assign({},n,n.push):n,o=n.pull?Object.assign({},n,n.pull):n;this.push=La(e,r,s),this.pull=La(r,e,o),this.pushPaused=!0,this.pullPaused=!0;let a=p=>{this.emit("change",{direction:"pull",change:p})},c=p=>{this.emit("change",{direction:"push",change:p})},d=p=>{this.emit("denied",{direction:"push",doc:p})},m=p=>{this.emit("denied",{direction:"pull",doc:p})},f=()=>{this.pushPaused=!0,this.pullPaused&&this.emit("paused")},g=()=>{this.pullPaused=!0,this.pushPaused&&this.emit("paused")},_=()=>{this.pushPaused=!1,this.pullPaused&&this.emit("active",{direction:"push"})},b=()=>{this.pullPaused=!1,this.pushPaused&&this.emit("active",{direction:"pull"})},P={},S=p=>(h,v)=>{(h==="change"&&(v===a||v===c)||h==="denied"&&(v===m||v===d)||h==="paused"&&(v===g||v===f)||h==="active"&&(v===b||v===_))&&(h in P||(P[h]={}),P[h][p]=!0,Object.keys(P[h]).length===2&&this.removeAllListeners(h))};n.live&&(this.push.on("complete",this.pull.cancel.bind(this.pull)),this.pull.on("complete",this.push.cancel.bind(this.push)));function y(p,h,v){p.listeners(h).indexOf(v)==-1&&p.on(h,v)}this.on("newListener",function(p){p==="change"?(y(this.pull,"change",a),y(this.push,"change",c)):p==="denied"?(y(this.pull,"denied",m),y(this.push,"denied",d)):p==="active"?(y(this.pull,"active",b),y(this.push,"active",_)):p==="paused"&&(y(this.pull,"paused",g),y(this.push,"paused",f))}),this.on("removeListener",function(p){p==="change"?(this.pull.removeListener("change",a),this.push.removeListener("change",c)):p==="denied"?(this.pull.removeListener("denied",m),this.push.removeListener("denied",d)):p==="active"?(this.pull.removeListener("active",b),this.push.removeListener("active",_)):p==="paused"&&(this.pull.removeListener("paused",g),this.push.removeListener("paused",f))}),this.pull.on("removeListener",S("pull")),this.push.on("removeListener",S("push"));let w=Promise.all([this.push,this.pull]).then(p=>{let h={push:p[0],pull:p[1]};return this.emit("complete",h),i&&i(null,h),this.removeAllListeners(),h},p=>{if(this.cancel(),i?i(p):this.emit("error",p),this.removeAllListeners(),i)throw p});this.then=function(p,h){return w.then(p,h)},this.catch=function(p){return w.catch(p)}}cancel(){this.canceled||(this.canceled=!0,this.push.cancel(),this.pull.cancel())}};function O1(t){t.replicate=La,t.sync=P1,Object.defineProperty(t.prototype,"replicate",{get:function(){var e=this;return typeof this.replicateMethods>"u"&&(this.replicateMethods={from:function(r,n,i){return e.constructor.replicate(r,e,n,i)},to:function(r,n,i){return e.constructor.replicate(e,r,n,i)}}),this.replicateMethods}}),t.prototype.sync=function(e,r,n){return this.constructor.sync(this,e,r,n)}}ae.plugin(zw).plugin(Xw).plugin(m1).plugin(O1);var zh=ae;I();R();T();var Yt=t=>`${t.source}/${encodeURIComponent(t.actor)}/${encodeURIComponent(t.name)}`,ru=t=>{let e=t.split("/"),r=e.pop(),n=e.pop();if(!r||!n||!e.length)throw new Jc;return{name:decodeURIComponent(r),actor:decodeURIComponent(n),source:e.join("/")}};function nu(t=16){let e=new Uint8Array(t);return crypto.getRandomValues(e),btoa(String.fromCodePoint(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}function Hr(t){return typeof t=="string"?{location:ru(t),uri:t}:{location:{name:t.name,actor:t.actor,source:t.source},uri:Yt(t)}}function Kh(t,e){return t.lastModified>e.lastModified||t.lastModified===e.lastModified&&!t.tombstone&&e.tombstone}function Xi(t,e,r,n){let i=r[e];if(!(!i||!i.length))try{n[e]=t(n[e],i,!0,!1).newDocument}catch(s){throw typeof s=="object"&&s&&"name"in s&&typeof s.name=="string"&&"message"in s&&typeof s.message=="string"?s.name==="TEST_OPERATION_FAILED"?new zc(s.message):new Tr(s.name+": "+s.message):s}}function Wr(t,e){try{return t.compile(e)}catch(r){throw new Mc(r instanceof Error?r.message:void 0)}}function Bn(t,e,r){t.actor!==r?.actor&&(t.allowed=t.allowed&&r?[r.actor]:void 0,t.channels=t.channels.filter(n=>e.includes(n)))}function Ln(t,e){return t.allowed===void 0||t.allowed===null||!!e?.actor&&(t.actor===e.actor||t.allowed.includes(e.actor))}I();R();T();var su=function(t,e){return su=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},su(t,e)};function A1(t,e){su(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Yr(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(m){try{d(n.next(m))}catch(f){o(f)}}function c(m){try{d(n.throw(m))}catch(f){o(f)}}function d(m){m.done?s(m.value):i(m.value).then(a,c)}d((n=n.apply(t,e||[])).next())})}function Xt(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(d){return function(m){return c([d,m])}}function c(d){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=d[0]&2?i.return:d[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,d[1])).done)return s;switch(i=0,s&&(d=[d[0]&2,s.value]),d[0]){case 0:case 1:s=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,i=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!s||d[1]>s[0]&&d[1]<s[3])){r.label=d[1];break}if(d[0]===6&&r.label<s[1]){r.label=s[1],s=d;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(d);break}s[2]&&r.ops.pop(),r.trys.pop();continue}d=e.call(t,r)}catch(m){d=[6,m],i=0}finally{n=s=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Xr(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Un(t){return this instanceof Un?(this.v=t,this):new Un(t)}function I1(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(g){n[g]&&(i[g]=function(_){return new Promise(function(b,P){s.push([g,_,b,P])>1||a(g,_)})})}function a(g,_){try{c(n[g](_))}catch(b){f(s[0][3],b)}}function c(g){g.value instanceof Un?Promise.resolve(g.value.v).then(d,m):f(s[0][2],g)}function d(g){a("next",g)}function m(g){a("throw",g)}function f(g,_){g(_),s.shift(),s.length&&a(s[0][0],s[0][1])}}var Hh=function(t){A1(e,t);function e(r){var n=t.call(this,r)||this;return Object.defineProperty(n,"name",{value:"RepeaterOverflowError",enumerable:!1}),typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf(n,n.constructor.prototype):n.__proto__=n.constructor.prototype,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(n,n.constructor),n}return e}(Error),qA=function(){function t(e){if(e<0)throw new RangeError("Capacity may not be less than 0");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),t.prototype.add=function(e){if(this.full)throw new Error("Buffer full");this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}(),kA=function(){function t(e){if(e<1)throw new RangeError("Capacity may not be less than 1");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(e){for(;this._q.length>=this._c;)this._q.shift();this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}(),CA=function(){function t(e){if(e<1)throw new RangeError("Capacity may not be less than 1");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(e){this._q.length<this._c&&this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}();function ou(t){t!=null&&typeof t.then=="function"&&t.then(rs,rs)}var iu=0,Vh=1,Pr=2,es=3,au=4,ts=1024,rs=function(){};function Qr(t){var e=t.err,r=Promise.resolve(t.execution).then(function(n){if(e!=null)throw e;return n});return t.err=void 0,t.execution=r.then(function(){},function(){}),t.pending===void 0?r:t.pending.then(function(){return r})}function Sr(t,e){var r=t.state>=es;return Promise.resolve(e).then(function(n){return!r&&t.state>=au?Qr(t).then(function(i){return{value:i,done:!0}}):{value:n,done:r}})}function uu(t,e){var r,n;if(!(t.state>=Pr))if(t.state=Pr,t.onnext(),t.onstop(),t.err==null&&(t.err=e),t.pushes.length===0&&(typeof t.buffer>"u"||t.buffer.empty))Mn(t);else try{for(var i=Xr(t.pushes),s=i.next();!s.done;s=i.next()){var o=s.value;o.resolve()}}catch(a){r={error:a}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}function Mn(t){var e,r;if(!(t.state>=es)){t.state<Pr&&uu(t),t.state=es,t.buffer=void 0;try{for(var n=Xr(t.nexts),i=n.next();!i.done;i=n.next()){var s=i.value,o=t.pending===void 0?Qr(t):t.pending.then(function(){return Qr(t)});s.resolve(Sr(t,o))}}catch(a){e={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}t.pushes=[],t.nexts=[]}}function Jh(t){t.state>=au||(t.state<es&&Mn(t),t.state=au)}function T1(t,e){if(ou(e),t.pushes.length>=ts)throw new Hh("No more than "+ts+" pending calls to push are allowed on a single repeater.");if(t.state>=Pr)return Promise.resolve(void 0);var r=t.pending===void 0?Promise.resolve(e):t.pending.then(function(){return e});r=r.catch(function(c){t.state<Pr&&(t.err=c),Jh(t)});var n;if(t.nexts.length){var i=t.nexts.shift();i.resolve(Sr(t,r)),t.nexts.length?n=Promise.resolve(t.nexts[0].value):typeof t.buffer<"u"&&!t.buffer.full?n=Promise.resolve(void 0):n=new Promise(function(c){return t.onnext=c})}else typeof t.buffer<"u"&&!t.buffer.full?(t.buffer.add(r),n=Promise.resolve(void 0)):n=new Promise(function(c){return t.pushes.push({resolve:c,value:r})});var s=!0,o={},a=n.catch(function(c){if(s)throw c});return o.then=function(c,d){return s=!1,Promise.prototype.then.call(n,c,d)},o.catch=function(c){return s=!1,Promise.prototype.catch.call(n,c)},o.finally=n.finally.bind(n),t.pending=r.then(function(){return a}).catch(function(c){t.err=c,Jh(t)}),o}function R1(t){var e=uu.bind(null,t),r=new Promise(function(n){return t.onstop=n});return e.then=r.then.bind(r),e.catch=r.catch.bind(r),e.finally=r.finally.bind(r),e}function q1(t){if(!(t.state>=Vh)){t.state=Vh;var e=T1.bind(null,t),r=R1(t);t.execution=new Promise(function(n){return n(t.executor(e,r))}),t.execution.catch(function(){return uu(t)})}}var Zi=new WeakMap,kt=function(){function t(e,r){Zi.set(this,{executor:e,buffer:r,err:void 0,state:iu,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:rs,onstop:rs})}return t.prototype.next=function(e){ou(e);var r=Zi.get(this);if(r===void 0)throw new Error("WeakMap error");if(r.nexts.length>=ts)throw new Hh("No more than "+ts+" pending calls to next are allowed on a single repeater.");if(r.state<=iu&&q1(r),r.onnext(e),typeof r.buffer<"u"&&!r.buffer.empty){var n=Sr(r,r.buffer.remove());if(r.pushes.length){var i=r.pushes.shift();r.buffer.add(i.value),r.onnext=i.resolve}return n}else if(r.pushes.length){var s=r.pushes.shift();return r.onnext=s.resolve,Sr(r,s.value)}else if(r.state>=Pr)return Mn(r),Sr(r,Qr(r));return new Promise(function(o){return r.nexts.push({resolve:o,value:e})})},t.prototype.return=function(e){ou(e);var r=Zi.get(this);if(r===void 0)throw new Error("WeakMap error");return Mn(r),r.execution=Promise.resolve(r.execution).then(function(){return e}),Sr(r,Qr(r))},t.prototype.throw=function(e){var r=Zi.get(this);if(r===void 0)throw new Error("WeakMap error");return r.state<=iu||r.state>=Pr||typeof r.buffer<"u"&&!r.buffer.empty?(Mn(r),r.err==null&&(r.err=e),Sr(r,Qr(r))):this.next(Promise.reject(e))},t.prototype[Symbol.asyncIterator]=function(){return this},t.race=k1,t.merge=C1,t.zip=x1,t.latest=j1,t}();function ns(t,e){var r,n,i=[],s=function(d){d!=null&&typeof d[Symbol.asyncIterator]=="function"?i.push(d[Symbol.asyncIterator]()):d!=null&&typeof d[Symbol.iterator]=="function"?i.push(d[Symbol.iterator]()):i.push(function(){return I1(this,arguments,function(){return Xt(this,function(g){switch(g.label){case 0:return e.yieldValues?[4,Un(d)]:[3,3];case 1:return[4,g.sent()];case 2:g.sent(),g.label=3;case 3:return e.returnValues?[4,Un(d)]:[3,5];case 4:return[2,g.sent()];case 5:return[2]}})})}())};try{for(var o=Xr(t),a=o.next();!a.done;a=o.next()){var c=a.value;s(c)}}catch(d){r={error:d}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}function k1(t){var e=this,r=ns(t,{returnValues:!0});return new kt(function(n,i){return Yr(e,void 0,void 0,function(){var s,o,a,c,d,m;return Xt(this,function(f){switch(f.label){case 0:if(!r.length)return i(),[2];o=!1,i.then(function(){s(),o=!0}),f.label=1;case 1:f.trys.push([1,,5,7]),c=void 0,d=0,m=function(){var g,_,b,P,S,y;return Xt(this,function(w){switch(w.label){case 0:g=d;try{for(_=(S=void 0,Xr(r)),b=_.next();!b.done;b=_.next())P=b.value,Promise.resolve(P.next()).then(function(p){p.done?(i(),a===void 0&&(a=p)):d===g&&(d++,s(p))},function(p){return i(p)})}catch(p){S={error:p}}finally{try{b&&!b.done&&(y=_.return)&&y.call(_)}finally{if(S)throw S.error}}return[4,new Promise(function(p){return s=p})];case 1:return c=w.sent(),c===void 0?[3,3]:[4,n(c.value)];case 2:w.sent(),w.label=3;case 3:return[2]}})},f.label=2;case 2:return o?[3,4]:[5,m()];case 3:return f.sent(),[3,2];case 4:return[2,a&&a.value];case 5:return i(),[4,Promise.race(r.map(function(g){return g.return&&g.return()}))];case 6:return f.sent(),[7];case 7:return[2]}})})})}function C1(t){var e=this,r=ns(t,{yieldValues:!0});return new kt(function(n,i){return Yr(e,void 0,void 0,function(){var s,o,a,c=this;return Xt(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2];s=[],o=!1,i.then(function(){var m,f;o=!0;try{for(var g=Xr(s),_=g.next();!_.done;_=g.next()){var b=_.value;b()}}catch(P){m={error:P}}finally{try{_&&!_.done&&(f=g.return)&&f.call(g)}finally{if(m)throw m.error}}}),d.label=1;case 1:return d.trys.push([1,,3,4]),[4,Promise.all(r.map(function(m,f){return Yr(c,void 0,void 0,function(){var g,_;return Xt(this,function(b){switch(b.label){case 0:b.trys.push([0,,6,9]),b.label=1;case 1:return o?[3,5]:(Promise.resolve(m.next()).then(function(P){return s[f](P)},function(P){return i(P)}),[4,new Promise(function(P){s[f]=P})]);case 2:return g=b.sent(),g===void 0?[3,4]:g.done?(a=g,[2]):[4,n(g.value)];case 3:b.sent(),b.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return _=m.return,_?[4,m.return()]:[3,8];case 7:_=b.sent(),b.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return d.sent(),[2,a&&a.value];case 3:return i(),[7];case 4:return[2]}})})})}function x1(t){var e=this,r=ns(t,{returnValues:!0});return new kt(function(n,i){return Yr(e,void 0,void 0,function(){var s,o,a,c;return Xt(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2,[]];o=!1,i.then(function(){s(),o=!0}),d.label=1;case 1:d.trys.push([1,,6,8]),d.label=2;case 2:return o?[3,5]:(Promise.all(r.map(function(m){return m.next()})).then(function(m){return s(m)},function(m){return i(m)}),[4,new Promise(function(m){return s=m})]);case 3:return a=d.sent(),a===void 0?[2]:(c=a.map(function(m){return m.value}),a.some(function(m){return m.done})?[2,c]:[4,n(c)]);case 4:return d.sent(),[3,2];case 5:return[3,8];case 6:return i(),[4,Promise.all(r.map(function(m){return m.return&&m.return()}))];case 7:return d.sent(),[7];case 8:return[2]}})})})}function j1(t){var e=this,r=ns(t,{yieldValues:!0,returnValues:!0});return new kt(function(n,i){return Yr(e,void 0,void 0,function(){var s,o,a,c,d,m=this;return Xt(this,function(f){switch(f.label){case 0:if(!r.length)return i(),[2,[]];o=[],a=!1,i.then(function(){var g,_;s();try{for(var b=Xr(o),P=b.next();!P.done;P=b.next()){var S=P.value;S()}}catch(y){g={error:y}}finally{try{P&&!P.done&&(_=b.return)&&_.call(b)}finally{if(g)throw g.error}}a=!0}),f.label=1;case 1:return f.trys.push([1,,5,7]),Promise.all(r.map(function(g){return g.next()})).then(function(g){return s(g)},function(g){return i(g)}),[4,new Promise(function(g){return s=g})];case 2:return c=f.sent(),c===void 0?[2]:(d=c.map(function(g){return g.value}),c.every(function(g){return g.done})?[2,d]:[4,n(d.slice())]);case 3:return f.sent(),[4,Promise.all(r.map(function(g,_){return Yr(m,void 0,void 0,function(){var b;return Xt(this,function(P){switch(P.label){case 0:if(c[_].done)return[2,c[_].value];P.label=1;case 1:return a?[3,4]:(Promise.resolve(g.next()).then(function(S){return o[_](S)},function(S){return i(S)}),[4,new Promise(function(S){return o[_]=S})]);case 2:return b=P.sent(),b===void 0?[2,c[_].value]:b.done?[2,b.value]:(d[_]=b.value,[4,n(d.slice())]);case 3:return P.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,f.sent()];case 5:return i(),[4,Promise.all(r.map(function(g){return g.return&&g.return()}))];case 6:return f.sent(),[7];case 7:return[2]}})})})}var Yh=en(Ri());I();R();T();var cu={};hs(cu,{JsonPatchError:()=>je,_areEquals:()=>zn,applyOperation:()=>Or,applyPatch:()=>Zt,applyReducer:()=>M1,deepClone:()=>B1,getValueByPointer:()=>us,validate:()=>Qh,validator:()=>cs});I();R();T();I();R();T();var N1=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)i.hasOwnProperty(s)&&(n[s]=i[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),D1=Object.prototype.hasOwnProperty;function ss(t,e){return D1.call(t,e)}function os(t){if(Array.isArray(t)){for(var e=new Array(t.length),r=0;r<e.length;r++)e[r]=""+r;return e}if(Object.keys)return Object.keys(t);var n=[];for(var i in t)ss(t,i)&&n.push(i);return n}function He(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function as(t){for(var e=0,r=t.length,n;e<r;){if(n=t.charCodeAt(e),n>=48&&n<=57){e++;continue}return!1}return!0}function Ct(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Gn(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function is(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,r=t.length;e<r;e++)if(is(t[e]))return!0}else if(typeof t=="object"){for(var n=os(t),i=n.length,s=0;s<i;s++)if(is(t[n[s]]))return!0}}return!1}function Wh(t,e){var r=[t];for(var n in e){var i=typeof e[n]=="object"?JSON.stringify(e[n],null,2):e[n];typeof i<"u"&&r.push(n+": "+i)}return r.join(`
17
- `)}var Fn=function(t){N1(e,t);function e(r,n,i,s,o){var a=this.constructor,c=t.call(this,Wh(r,{name:n,index:i,operation:s,tree:o}))||this;return c.name=n,c.index=i,c.operation=s,c.tree=o,Object.setPrototypeOf(c,a.prototype),c.message=Wh(r,{name:n,index:i,operation:s,tree:o}),c}return e}(Error);var je=Fn,B1=He,Zr={add:function(t,e,r){return t[e]=this.value,{newDocument:r}},remove:function(t,e,r){var n=t[e];return delete t[e],{newDocument:r,removed:n}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:function(t,e,r){var n=us(r,this.path);n&&(n=He(n));var i=Or(r,{op:"remove",path:this.from}).removed;return Or(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(t,e,r){var n=us(r,this.from);return Or(r,{op:"add",path:this.path,value:He(n)}),{newDocument:r}},test:function(t,e,r){return{newDocument:r,test:zn(t[e],this.value)}},_get:function(t,e,r){return this.value=t[e],{newDocument:r}}},L1={add:function(t,e,r){return as(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:r,index:e}},remove:function(t,e,r){var n=t.splice(e,1);return{newDocument:r,removed:n[0]}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:Zr.move,copy:Zr.copy,test:Zr.test,_get:Zr._get};function us(t,e){if(e=="")return t;var r={op:"_get",path:e};return Or(t,r),r.value}function Or(t,e,r,n,i,s){if(r===void 0&&(r=!1),n===void 0&&(n=!0),i===void 0&&(i=!0),s===void 0&&(s=0),r&&(typeof r=="function"?r(e,0,t,e.path):cs(e,0)),e.path===""){var o={newDocument:t};if(e.op==="add")return o.newDocument=e.value,o;if(e.op==="replace")return o.newDocument=e.value,o.removed=t,o;if(e.op==="move"||e.op==="copy")return o.newDocument=us(t,e.from),e.op==="move"&&(o.removed=t),o;if(e.op==="test"){if(o.test=zn(t,e.value),o.test===!1)throw new je("Test operation failed","TEST_OPERATION_FAILED",s,e,t);return o.newDocument=t,o}else{if(e.op==="remove")return o.removed=t,o.newDocument=null,o;if(e.op==="_get")return e.value=t,o;if(r)throw new je("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,e,t);return o}}else{n||(t=He(t));var a=e.path||"",c=a.split("/"),d=t,m=1,f=c.length,g=void 0,_=void 0,b=void 0;for(typeof r=="function"?b=r:b=cs;;){if(_=c[m],_&&_.indexOf("~")!=-1&&(_=Gn(_)),i&&(_=="__proto__"||_=="prototype"&&m>0&&c[m-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&g===void 0&&(d[_]===void 0?g=c.slice(0,m).join("/"):m==f-1&&(g=e.path),g!==void 0&&b(e,0,t,g)),m++,Array.isArray(d)){if(_==="-")_=d.length;else{if(r&&!as(_))throw new je("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",s,e,t);as(_)&&(_=~~_)}if(m>=f){if(r&&e.op==="add"&&_>d.length)throw new je("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,e,t);var o=L1[e.op].call(e,d,_,t);if(o.test===!1)throw new je("Test operation failed","TEST_OPERATION_FAILED",s,e,t);return o}}else if(m>=f){var o=Zr[e.op].call(e,d,_,t);if(o.test===!1)throw new je("Test operation failed","TEST_OPERATION_FAILED",s,e,t);return o}if(d=d[_],r&&m<f&&(!d||typeof d!="object"))throw new je("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,e,t)}}}function Zt(t,e,r,n,i){if(n===void 0&&(n=!0),i===void 0&&(i=!0),r&&!Array.isArray(e))throw new je("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(t=He(t));for(var s=new Array(e.length),o=0,a=e.length;o<a;o++)s[o]=Or(t,e[o],r,!0,i,o),t=s[o].newDocument;return s.newDocument=t,s}function M1(t,e,r){var n=Or(t,e);if(n.test===!1)throw new je("Test operation failed","TEST_OPERATION_FAILED",r,e,t);return n.newDocument}function cs(t,e,r,n){if(typeof t!="object"||t===null||Array.isArray(t))throw new je("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,r);if(Zr[t.op]){if(typeof t.path!="string")throw new je("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,r);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new je('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,r);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new je("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new je("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&is(t.value))throw new je("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,r);if(r){if(t.op=="add"){var i=t.path.split("/").length,s=n.split("/").length;if(i!==s+1&&i!==s)throw new je("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,r)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==n)throw new je("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,r)}else if(t.op==="move"||t.op==="copy"){var o={op:"_get",path:t.from,value:void 0},a=Qh([o],r);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new je("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,r)}}}else throw new je("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,r)}function Qh(t,e,r){try{if(!Array.isArray(t))throw new je("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Zt(He(e),He(t),r||!0);else{r=r||cs;for(var n=0;n<t.length;n++)r(t[n],n,e,void 0)}}catch(i){if(i instanceof je)return i;throw i}}function zn(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=Array.isArray(t),n=Array.isArray(e),i,s,o;if(r&&n){if(s=t.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!zn(t[i],e[i]))return!1;return!0}if(r!=n)return!1;var a=Object.keys(t);if(s=a.length,s!==Object.keys(e).length)return!1;for(i=s;i--!==0;)if(!e.hasOwnProperty(a[i]))return!1;for(i=s;i--!==0;)if(o=a[i],!zn(t[o],e[o]))return!1;return!0}return t!==t&&e!==e}var hu={};hs(hu,{compare:()=>H1,generate:()=>fu,observe:()=>J1,unobserve:()=>V1});I();R();T();var lu=new WeakMap,U1=function(){function t(e){this.observers=new Map,this.obj=e}return t}(),G1=function(){function t(e,r){this.callback=e,this.observer=r}return t}();function F1(t){return lu.get(t)}function z1(t,e){return t.observers.get(e)}function K1(t,e){t.observers.delete(e.callback)}function V1(t,e){e.unobserve()}function J1(t,e){var r=[],n,i=F1(t);if(!i)i=new U1(t),lu.set(t,i);else{var s=z1(i,e);n=s&&s.observer}if(n)return n;if(n={},i.value=He(t),e){n.callback=e,n.next=null;var o=function(){fu(n)},a=function(){clearTimeout(n.next),n.next=setTimeout(o)};typeof window<"u"&&(window.addEventListener("mouseup",a),window.addEventListener("keyup",a),window.addEventListener("mousedown",a),window.addEventListener("keydown",a),window.addEventListener("change",a))}return n.patches=r,n.object=t,n.unobserve=function(){fu(n),clearTimeout(n.next),K1(i,n),typeof window<"u"&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a))},i.observers.set(e,new G1(e,n)),n}function fu(t,e){e===void 0&&(e=!1);var r=lu.get(t.object);du(r.value,t.object,t.patches,"",e),t.patches.length&&Zt(r.value,t.patches);var n=t.patches;return n.length>0&&(t.patches=[],t.callback&&t.callback(n)),n}function du(t,e,r,n,i){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var s=os(e),o=os(t),a=!1,c=!1,d=o.length-1;d>=0;d--){var m=o[d],f=t[m];if(ss(e,m)&&!(e[m]===void 0&&f!==void 0&&Array.isArray(e)===!1)){var g=e[m];typeof f=="object"&&f!=null&&typeof g=="object"&&g!=null&&Array.isArray(f)===Array.isArray(g)?du(f,g,r,n+"/"+Ct(m),i):f!==g&&(a=!0,i&&r.push({op:"test",path:n+"/"+Ct(m),value:He(f)}),r.push({op:"replace",path:n+"/"+Ct(m),value:He(g)}))}else Array.isArray(t)===Array.isArray(e)?(i&&r.push({op:"test",path:n+"/"+Ct(m),value:He(f)}),r.push({op:"remove",path:n+"/"+Ct(m)}),c=!0):(i&&r.push({op:"test",path:n,value:t}),r.push({op:"replace",path:n,value:e}),a=!0)}if(!(!c&&s.length==o.length))for(var d=0;d<s.length;d++){var m=s[d];!ss(t,m)&&e[m]!==void 0&&r.push({op:"add",path:n+"/"+Ct(m),value:He(e[m])})}}}function H1(t,e,r){r===void 0&&(r=!1);var n=[];return du(t,e,n,"",r),n}var XA=Object.assign({},cu,hu,{JsonPatchError:Fn,deepClone:He,escapePathComponent:Ct,unescapePathComponent:Gn});var fs=class{db;source="local";tombstoneRetention=864e5;ajv;constructor(e,r){this.ajv=r??new Yh.default({strict:!1}),this.source=e?.sourceName??this.source,this.tombstoneRetention=e?.tombstoneRetention??this.tombstoneRetention;let n={name:"graffitiDb",...e?.pouchDBOptions};this.db=new zh(n.name,n),this.db.put({_id:"_design/indexes",views:{objectsPerChannelAndLastModified:{map:function(i){let s=i.lastModified.toString().padStart(15,"0");i.channels.forEach(function(o){let a=encodeURIComponent(o)+"/"+s;emit(a)})}.toString()},orphansPerActorAndLastModified:{map:function(i){if(i.channels.length===0){let s=i.lastModified.toString().padStart(15,"0"),o=encodeURIComponent(i.actor)+"/"+s;emit(o)}}.toString()},channelStatsPerActor:{map:function(i){i.tombstone||i.channels.forEach(function(s){let o=encodeURIComponent(i.actor)+"/"+encodeURIComponent(s);emit(o,i.lastModified)})}.toString(),reduce:"_stats"}}}).catch(i=>{if(!(i&&typeof i=="object"&&"name"in i&&i.name==="conflict"))throw i})}async queryByLocation(e){let r=Yt(e)+"/";return(await this.db.allDocs({startkey:r,endkey:r+"\uFFFF",include_docs:!0})).rows.map(s=>s.doc).reduce((s,o)=>(o&&s.push(o),s),[])}docId(e){return Yt(e)+"/"+nu()}get=async(...e)=>{let[r,n,i]=e,{location:s}=Hr(r),a=(await this.queryByLocation(s)).filter(_=>Ln(_,i));if(!a.length)throw new Wn;let c=a.reduce((_,b)=>Kh(_,b)?_:b),{_id:d,_rev:m,...f}=c;if(Bn(f,[],i),!Wr(this.ajv,n)(f))throw new Gc;return f};async deleteAtLocation(e,r=!1){let i=(await this.queryByLocation(e)).filter(f=>!f.tombstone);if(!i.length)return;let s=i.map(f=>f.lastModified).reduce((f,g)=>f>g?f:g),o=i.filter(f=>!r||f.lastModified<s),a=i.filter(f=>r&&f.lastModified===s);if(a.length){let f=a.map(_=>_._id).reduce((_,b)=>_>b?_:b),g=a.filter(_=>_._id!==f);o.push(...g)}let c=r?s:new Date().getTime(),d=await this.db.bulkDocs(o.map(f=>({...f,tombstone:!0,lastModified:c}))),m;for(let f of d)if("ok"in f){let{id:g}=f,_=o.find(b=>b._id===g);if(_){let{_id:b,_rev:P,_conflicts:S,_attachments:y,...w}=_;m={...w,tombstone:!0,lastModified:c};break}}return m}delete=async(...e)=>{let[r,n]=e,{location:i}=Hr(r);if(i.actor!==n.actor)throw new rn;let s=await this.deleteAtLocation(i);if(!s)throw new Wn;return s};put=async(...e)=>{let[r,n]=e;if(r.actor&&r.actor!==n.actor)throw new rn;if(r.source&&r.source!==this.source)throw new rn("Putting an object that does not match this source");let i={value:r.value,channels:r.channels,allowed:r.allowed,name:r.name??nu(),source:this.source,actor:n.actor,tombstone:!1,lastModified:new Date().getTime()};await this.db.put({_id:this.docId(i),...i});let s=await this.deleteAtLocation(i,!0);return s||{...i,value:{},channels:[],allowed:void 0,tombstone:!0}};patch=async(...e)=>{let[r,n,i]=e,{location:s}=Hr(n);if(s.actor!==i.actor)throw new rn;let o=await this.get(n,{},i);if(o.tombstone)throw new Wn("The object you are trying to patch has been deleted");let a={...o};for(let c of["value","channels","allowed"])Xi(Zt,c,r,a);if(typeof a.value!="object"||Array.isArray(a.value)||!a.value)throw new Tr("value is no longer an object");if(!Array.isArray(a.channels)||!a.channels.every(c=>typeof c=="string"))throw new Tr("channels are no longer an array of strings");if(a.allowed&&(!Array.isArray(a.allowed)||!a.allowed.every(c=>typeof c=="string")))throw new Tr("allowed list is not an array of strings");return a.lastModified=new Date().getTime(),await this.db.put({...a,_id:this.docId(a)}),await this.deleteAtLocation(a,!0),{...o,tombstone:!0,lastModified:a.lastModified}};queryLastModifiedSuffixes(e){let r="",n="\uFFFF",i=e.properties?.lastModified;if(i?.minimum){let s=Math.ceil(i.minimum);s===i.minimum&&i.exclusiveMinimum&&s++,r=s.toString().padStart(15,"0")}if(i?.maximum){let s=Math.floor(i.maximum);s===i.maximum&&i.exclusiveMaximum&&s--,n=s.toString().padStart(15,"0")}return{startKeySuffix:r,endKeySuffix:n}}discover=(...e)=>{let[r,n,i]=e,s=Wr(this.ajv,n),{startKeySuffix:o,endKeySuffix:a}=this.queryLastModifiedSuffixes(n);return new kt(async(d,m)=>{let f=new Set;for(let g of r){let _=encodeURIComponent(g)+"/",b=_+o,P=_+a,S=await this.db.query("indexes/objectsPerChannelAndLastModified",{startkey:b,endkey:P,include_docs:!0});for(let y of S.rows){let w=y.doc;if(!w)continue;let{_id:p,_rev:h,...v}=w;f.has(p)||(f.add(p),Ln(w,i)&&(Bn(v,r,i),s(v)&&await d({value:v})))}}return m(),{tombstoneRetention:this.tombstoneRetention}})};recoverOrphans=(e,r)=>{let n=Wr(this.ajv,e),{startKeySuffix:i,endKeySuffix:s}=this.queryLastModifiedSuffixes(e),o=encodeURIComponent(r.actor)+"/",a=o+i,c=o+s;return new kt(async(m,f)=>{let g=await this.db.query("indexes/orphansPerActorAndLastModified",{startkey:a,endkey:c,include_docs:!0});for(let _ of g.rows){let b=_.doc;if(!b)continue;let{_id:P,_rev:S,...y}=b;n(y)&&await m({value:y})}return f(),{tombstoneRetention:this.tombstoneRetention}})};channelStats=e=>new kt(async(n,i)=>{let s=encodeURIComponent(e.actor)+"/",o=await this.db.query("indexes/channelStatsPerActor",{startkey:s,endkey:s+"\uFFFF",reduce:!0,group:!0});for(let a of o.rows){let c=a.key.split("/")[1];if(typeof c!="string")continue;let{count:d,max:m}=a.value;typeof d!="number"||typeof m!="number"||await n({value:{channel:decodeURIComponent(c),count:d,lastModified:m}})}i()})};I();R();T();var Xh=en(Ri());var ls=class{synchronizeEvents=new EventTarget;ajv;graffiti;constructor(e,r){this.ajv=r??new Xh.default({strict:!1}),this.graffiti=e}synchronizeDispatch(e,r){let n=new CustomEvent("change",{detail:{oldObject:e,newObject:r}});this.synchronizeEvents.dispatchEvent(n)}get=async(...e)=>{let r=await this.graffiti.get(...e);return this.synchronizeDispatch(r),r};put=async(...e)=>{let r=await this.graffiti.put(...e),n=e[0],i={...r,value:n.value,channels:n.channels,allowed:n.allowed,tombstone:!1};return this.synchronizeDispatch(r,i),r};patch=async(...e)=>{let r=await this.graffiti.patch(...e),n={...r};n.tombstone=!1;for(let i of["value","channels","allowed"])Xi(Zt,i,e[0],n);return this.synchronizeDispatch(r,n),r};delete=async(...e)=>{let r=await this.graffiti.delete(...e);return this.synchronizeDispatch(r),r};objectStream(e){let r=this.synchronizeDispatch.bind(this);return async function*(){let i=await e.next();for(;!i.done;)i.value.error||r(i.value.value),yield i.value,i=await e.next();return i.value}()}discover=(...e)=>{let r=this.graffiti.discover(...e);return this.objectStream(r)};recoverOrphans=(...e)=>{let r=this.graffiti.recoverOrphans(...e);return this.objectStream(r)};synchronize(e,r,n,i){let s=Wr(this.ajv,n);return new kt(async(a,c)=>{let d=m=>{let{oldObject:f,newObject:g}=m.detail;for(let _ of[g,f])if(_&&e(_)&&Ln(_,i)){let b={..._};if(Bn(b,r,i),s(b)){a({value:b});break}}};this.synchronizeEvents.addEventListener("change",d),await c,this.synchronizeEvents.removeEventListener("change",d)})}synchronizeDiscover=(...e)=>{let[r,n,i]=e;function s(o){return o.channels.some(a=>r.includes(a))}return this.synchronize(s,r,n,i)};synchronizeGet=(...e)=>{let[r,n,i]=e;function s(o){let a=Yt(o),{uri:c}=Hr(r);return a===c}return this.synchronize(s,[],n,i)};synchronizeRecoverOrphans=(...e)=>{let[r,n]=e;function i(s){return s.actor===n.actor&&s.channels.length===0}return this.synchronize(i,[],r,n)}};var Zh=class extends Dc{locationToUri=Yt;uriToLocation=ru;login;logout;sessionEvents;put;get;patch;delete;discover;recoverOrphans;synchronizeGet;synchronizeDiscover;synchronizeRecoverOrphans;channelStats;constructor(e){super();let r=new qi;this.login=r.login.bind(r),this.logout=r.logout.bind(r),this.sessionEvents=r.sessionEvents;let n=new ep.default({strict:!1}),i=new fs(e,n),s=new ls(i,n);this.put=s.put.bind(s),this.get=s.get.bind(s),this.patch=s.patch.bind(s),this.delete=s.delete.bind(s),this.discover=s.discover.bind(s),this.recoverOrphans=s.recoverOrphans.bind(i),this.channelStats=i.channelStats.bind(i),this.synchronizeDiscover=s.synchronizeDiscover.bind(s),this.synchronizeGet=s.synchronizeGet.bind(s),this.synchronizeRecoverOrphans=s.synchronizeRecoverOrphans.bind(s)}};export{Zh as GraffitiLocal};
16
+ Please double-check your map/reduce function.`),vt("error",e,r)}}function a1(t,e,r,n){function i(q,C,L){try{C(L)}catch(B){th(q,B,{fun:C,doc:L})}}function s(q,C,L,B,F){try{return{output:C(L,B,F)}}catch(X){return th(q,X,{fun:C,keys:L,values:B,rereduce:F}),{error:X}}}function o(q,C){let L=Be(q.key,C.key);return L!==0?L:Be(q.value,C.value)}function a(q,C,L){return L=L||0,typeof C=="number"?q.slice(L,C+L):L>0?q.slice(L):q}function c(q){let C=q.value;return C&&typeof C=="object"&&C._id||q.id}function d(q){for(let C of q.rows){let L=C.doc&&C.doc._attachments;if(L)for(let B of Object.keys(L)){let F=L[B];L[B].data=Wa(F.data,F.content_type)}}}function m(q){return function(C){return q.include_docs&&q.attachments&&q.binary&&d(C),C}}function f(q,C,L,B){let F=C[q];typeof F<"u"&&(B&&(F=encodeURIComponent(JSON.stringify(F))),L.push(q+"="+F))}function y(q){if(typeof q<"u"){let C=Number(q);return!isNaN(C)&&C===parseInt(q,10)?C:q}}function _(q){return q.group_level=y(q.group_level),q.limit=y(q.limit),q.skip=y(q.skip),q}function b(q){if(q){if(typeof q!="number")return new yr(`Invalid value for integer: "${q}"`);if(q<0)return new yr(`Invalid value for positive integer: "${q}"`)}}function P(q,C){let L=q.descending?"endkey":"startkey",B=q.descending?"startkey":"endkey";if(typeof q[L]<"u"&&typeof q[B]<"u"&&Be(q[L],q[B])>0)throw new yr("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(C.reduce&&q.reduce!==!1){if(q.include_docs)throw new yr("{include_docs:true} is invalid for reduce");if(q.keys&&q.keys.length>1&&!q.group&&!q.group_level)throw new yr("Multi-key fetches for reduce views must use {group: true}")}for(let F of["group_level","limit","skip"]){let X=b(q[F]);if(X)throw X}}async function S(q,C,L){let B=[],F,X="GET",ie;if(f("reduce",L,B),f("include_docs",L,B),f("attachments",L,B),f("limit",L,B),f("descending",L,B),f("group",L,B),f("group_level",L,B),f("skip",L,B),f("stale",L,B),f("conflicts",L,B),f("startkey",L,B,!0),f("start_key",L,B,!0),f("endkey",L,B,!0),f("end_key",L,B,!0),f("inclusive_end",L,B),f("key",L,B,!0),f("update_seq",L,B),B=B.join("&"),B=B===""?"":"?"+B,typeof L.keys<"u"){let W=`keys=${encodeURIComponent(JSON.stringify(L.keys))}`;W.length+B.length+1<=2e3?B+=(B[0]==="?"?"&":"?")+W:(X="POST",typeof C=="string"?F={keys:L.keys}:C.keys=L.keys)}if(typeof C=="string"){let M=ya(C),W=await q.fetch("_design/"+M[0]+"/_view/"+M[1]+B,{headers:new zr({"Content-Type":"application/json"}),method:X,body:JSON.stringify(F)});ie=W.ok;let ee=await W.json();if(!ie)throw ee.status=W.status,Jr(ee);for(let ne of ee.rows)if(ne.value&&ne.value.error&&ne.value.error==="builtin_reduce_error")throw new Error(ne.reason);return new Promise(function(ne){ne(ee)}).then(m(L))}F=F||{};for(let M of Object.keys(C))Array.isArray(C[M])?F[M]=C[M]:F[M]=C[M].toString();let J=await q.fetch("_temp_view"+B,{headers:new zr({"Content-Type":"application/json"}),method:"POST",body:JSON.stringify(F)});ie=J.ok;let D=await J.json();if(!ie)throw D.status=J.status,Jr(D);return new Promise(function(M){M(D)}).then(m(L))}function g(q,C,L){return new Promise(function(B,F){q._query(C,L,function(X,ie){if(X)return F(X);B(ie)})})}function w(q){return new Promise(function(C,L){q._viewCleanup(function(B,F){if(B)return L(B);C(F)})})}function p(q){return function(C){if(C.status===404)return q;throw C}}async function h(q,C,L){let B="_local/doc_"+q,F={_id:B,keys:[]},X=L.get(q),ie=X[0],J=X[1];function D(){return o1(J)?Promise.resolve(F):C.db.get(B).catch(p(F))}function M(Ee){return Ee.keys.length?C.db.allDocs({keys:Ee.keys,include_docs:!0}):Promise.resolve({rows:[]})}function W(Ee,$e){let Re=[],We=new Set;for(let ve of $e.rows){let ge=ve.doc;if(ge&&(Re.push(ge),We.add(ge._id),ge._deleted=!ie.has(ge._id),!ge._deleted)){let Se=ie.get(ge._id);"value"in Se&&(ge.value=Se.value)}}let ct=va(ie);for(let ve of ct)if(!We.has(ve)){let ge={_id:ve},Se=ie.get(ve);"value"in Se&&(ge.value=Se.value),Re.push(ge)}return Ee.keys=Wd(ct.concat(Ee.keys)),Re.push(Ee),Re}let ee=await D(),ne=await M(ee);return W(ee,ne)}function v(q){return q.sourceDB.get("_local/purges").then(function(C){let L=C.purgeSeq;return q.db.get("_local/purgeSeq").then(function(B){return B._rev}).catch(p(void 0)).then(function(B){return q.db.put({_id:"_local/purgeSeq",_rev:B,purgeSeq:L})})}).catch(function(C){if(C.status!==404)throw C})}function E(q,C,L){var B="_local/lastSeq";return q.db.get(B).catch(p({_id:B,seq:0})).then(function(F){var X=va(C);return Promise.all(X.map(function(ie){return h(ie,q,C)})).then(function(ie){var J=ie.flat();return F.seq=L,J.push(F),q.db.bulkDocs({docs:J})}).then(()=>v(q))})}function k(q){let C=typeof q=="string"?q:q.name,L=Zd[C];return L||(L=Zd[C]=new Nn),L}async function x(q,C){return ma(k(q),function(){return j(q,C)})()}async function j(q,C){let L,B,F;function X(ve,ge){let Se={id:B._id,key:$r(ve)};typeof ge<"u"&&ge!==null&&(Se.value=$r(ge)),L.push(Se)}let ie=e(q.mapFun,X),J=q.seq||0;function D(){return q.sourceDB.info().then(function(ve){F=q.sourceDB.activeTasks.add({name:"view_indexing",total_items:ve.update_seq-J})})}function M(ve,ge){return function(){return E(q,ve,ge)}}let W=0,ee={view:q.name,indexed_docs:W};q.sourceDB.emit("indexing",ee);let ne=new Nn;async function Ee(){let ve=await q.sourceDB.changes({return_docs:!0,conflicts:!0,include_docs:!0,style:"all_docs",since:J,limit:C.changes_batch_size}),ge=await $e();return Re(ve,ge)}function $e(){return q.db.get("_local/purgeSeq").then(function(ve){return ve.purgeSeq}).catch(p(-1)).then(function(ve){return q.sourceDB.get("_local/purges").then(function(ge){let Se=ge.purges.filter(function(Fe,Pe){return Pe>ve}).map(Fe=>Fe.docId),nt=Se.filter(function(Fe,Pe){return Se.indexOf(Fe)===Pe});return Promise.all(nt.map(function(Fe){return q.sourceDB.get(Fe).then(function(Pe){return{docId:Fe,doc:Pe}}).catch(p({docId:Fe}))}))}).catch(p([]))})}function Re(ve,ge){let Se=ve.results;if(!Se.length&&!ge.length)return;for(let Pe of ge)if(Se.findIndex(function(tr){return tr.id===Pe.docId})<0){let tr={_id:Pe.docId,doc:{_id:Pe.docId,_deleted:1},changes:[]};Pe.doc&&(tr.doc=Pe.doc,tr.changes.push({rev:Pe.doc._rev})),Se.push(tr)}let nt=We(Se);ne.add(M(nt,J)),W=W+Se.length;let Fe={view:q.name,last_seq:ve.last_seq,results_count:Se.length,indexed_docs:W};if(q.sourceDB.emit("indexing",Fe),q.sourceDB.activeTasks.update(F,{completed_items:W}),!(Se.length<C.changes_batch_size))return Ee()}function We(ve){let ge=new Map;for(let Se of ve){if(Se.doc._id[0]!=="_"){L=[],B=Se.doc,B._deleted||i(q.sourceDB,ie,B),L.sort(o);let nt=ct(L);ge.set(Se.doc._id,[nt,Se.changes])}J=Se.seq}return ge}function ct(ve){let ge=new Map,Se;for(let nt=0,Fe=ve.length;nt<Fe;nt++){let Pe=ve[nt],er=[Pe.key,Pe.id];nt>0&&Be(Pe.key,Se)===0&&er.push(nt),ge.set(Et(er),Pe),Se=Pe.key}return ge}try{await D(),await Ee(),await ne.finish(),q.seq=J,q.sourceDB.activeTasks.remove(F)}catch(ve){q.sourceDB.activeTasks.remove(F,ve)}}function G(q,C,L){L.group_level===0&&delete L.group_level;let B=L.group||L.group_level,F=r(q.reduceFun),X=[],ie=isNaN(L.group_level)?Number.POSITIVE_INFINITY:L.group_level;for(let J of C){let D=X[X.length-1],M=B?J.key:null;if(B&&Array.isArray(M)&&(M=M.slice(0,ie)),D&&Be(D.groupKey,M)===0){D.keys.push([J.key,J.id]),D.values.push(J.value);continue}X.push({keys:[[J.key,J.id]],values:[J.value],groupKey:M})}C=[];for(let J of X){let D=s(q.sourceDB,F,J.keys,J.values,!1);if(D.error&&D.error instanceof Ji)throw D.error;C.push({value:D.error?null:D.output,key:J.groupKey})}return{rows:a(C,L.limit,L.skip)}}function H(q,C){return ma(k(q),function(){return re(q,C)})()}async function re(q,C){let L,B=q.reduceFun&&C.reduce!==!1,F=C.skip||0;typeof C.keys<"u"&&!C.keys.length&&(C.limit=0,delete C.keys);async function X(J){J.include_docs=!0;let D=await q.db.allDocs(J);return L=D.total_rows,D.rows.map(function(M){if("value"in M.doc&&typeof M.doc.value=="object"&&M.doc.value!==null){let ee=Object.keys(M.doc.value).sort(),ne=["id","key","value"];if(!(ee<ne||ee>ne))return M.doc.value}let W=X0(M.doc._id);return{key:W[0],id:W[1],value:"value"in M.doc?M.doc.value:null}})}async function ie(J){let D;if(B?D=G(q,J,C):typeof C.keys>"u"?D={total_rows:L,offset:F,rows:J}:D={total_rows:L,offset:F,rows:a(J,C.limit,C.skip)},C.update_seq&&(D.update_seq=q.seq),C.include_docs){let M=Wd(J.map(c)),W=await q.sourceDB.allDocs({keys:M,include_docs:!0,conflicts:C.conflicts,attachments:C.attachments,binary:C.binary}),ee=new Map;for(let ne of W.rows)ee.set(ne.id,ne.doc);for(let ne of J){let Ee=c(ne),$e=ee.get(Ee);$e&&(ne.doc=$e)}}return D}if(typeof C.keys<"u"){let D=C.keys.map(function(ee){let ne={startkey:Et([ee]),endkey:Et([ee,{}])};return C.update_seq&&(ne.update_seq=!0),X(ne)}),W=(await Promise.all(D)).flat();return ie(W)}else{let J={descending:C.descending};C.update_seq&&(J.update_seq=!0);let D,M;if("start_key"in C&&(D=C.start_key),"startkey"in C&&(D=C.startkey),"end_key"in C&&(M=C.end_key),"endkey"in C&&(M=C.endkey),typeof D<"u"&&(J.startkey=C.descending?Et([D,{}]):Et([D])),typeof M<"u"){let ee=C.inclusive_end!==!1;C.descending&&(ee=!ee),J.endkey=Et(ee?[M,{}]:[M])}if(typeof C.key<"u"){let ee=Et([C.key]),ne=Et([C.key,{}]);J.descending?(J.endkey=ee,J.startkey=ne):(J.startkey=ee,J.endkey=ne)}B||(typeof C.limit=="number"&&(J.limit=C.limit),J.skip=F);let W=await X(J);return ie(W)}}async function Q(q){return(await q.fetch("_view_cleanup",{headers:new zr({"Content-Type":"application/json"}),method:"POST"})).json()}async function Z(q){try{let C=await q.get("_local/"+t),L=new Map;for(let D of Object.keys(C.views)){let M=ya(D),W="_design/"+M[0],ee=M[1],ne=L.get(W);ne||(ne=new Set,L.set(W,ne)),ne.add(ee)}let B={keys:va(L),include_docs:!0},F=await q.allDocs(B),X={};for(let D of F.rows){let M=D.key.substring(8);for(let W of L.get(D.key)){let ee=M+"/"+W;C.views[ee]||(ee=W);let ne=Object.keys(C.views[ee]),Ee=D.doc&&D.doc.views&&D.doc.views[W];for(let $e of ne)X[$e]=X[$e]||Ee}}let J=Object.keys(X).filter(function(D){return!X[D]}).map(function(D){return ma(k(D),function(){return new q.constructor(D,q.__opts).destroy()})()});return Promise.all(J).then(function(){return{ok:!0}})}catch(C){if(C.status===404)return{ok:!0};throw C}}async function ce(q,C,L){if(typeof q._query=="function")return g(q,C,L);if(Rt(q))return S(q,C,L);let B={changes_batch_size:q.__opts.view_update_changes_batch_size||s1};if(typeof C!="string")return P(L,C),eh.add(async function(){let F=await Xd(q,"temp_view/temp_view",C.map,C.reduce,!0,t);return e1(x(F,B).then(function(){return H(F,L)}),function(){return F.db.destroy()})}),eh.finish();{let F=C,X=ya(F),ie=X[0],J=X[1],D=await q.get("_design/"+ie);if(C=D.views&&D.views[J],!C)throw new Vi(`ddoc ${D._id} has no view named ${J}`);n(D,J),P(L,C);let M=await Xd(q,F,C.map,C.reduce,!1,t);return L.stale==="ok"||L.stale==="update_after"?(L.stale==="update_after"&&qt(function(){x(M,B)}),H(M,L)):(await x(M,B),H(M,L))}}function fe(q,C,L){let B=this;typeof C=="function"&&(L=C,C={}),C=C?_(C):{},typeof q=="function"&&(q={map:q});let F=Promise.resolve().then(function(){return ce(B,q,C)});return Bh(F,L),F}let me=Zw(function(){let q=this;return typeof q._viewCleanup=="function"?w(q):Rt(q)?Q(q):Z(q)});return{query:fe,viewCleanup:me}}var ga={_sum:function(t,e){return Na(e)},_count:function(t,e){return e.length},_stats:function(t,e){function r(n){for(var i=0,s=0,o=n.length;s<o;s++){var a=n[s];i+=a*a}return i}return{sum:Na(e),min:Math.min.apply(null,e),max:Math.max.apply(null,e),count:e.length,sumsqr:r(e)}}};function u1(t){if(/^_sum/.test(t))return ga._sum;if(/^_count/.test(t))return ga._count;if(/^_stats/.test(t))return ga._stats;if(/^_/.test(t))throw new Error(t+" is not a supported reduce function.")}function c1(t,e){if(typeof t=="function"&&t.length===2){var r=t;return function(n){return r(n,e)}}else return Lh(t.toString(),e)}function f1(t){var e=t.toString(),r=u1(e);return r||Lh(e)}function l1(t,e){var r=t.views&&t.views[e];if(typeof r.map!="string")throw new Vi("ddoc "+t._id+" has no string view named "+e+", instead found object of type: "+typeof r.map)}var d1="mrviews",Mh=a1(d1,c1,f1,l1);function h1(t,e,r){return Mh.query.call(this,t,e,r)}function p1(t){return Mh.viewCleanup.call(this,t)}var m1={query:h1,viewCleanup:p1};function v1(t,e,r){return!t._attachments||!t._attachments[r]||t._attachments[r].digest!==e._attachments[r].digest}function rh(t,e){var r=Object.keys(e._attachments);return Promise.all(r.map(function(n){return t.getAttachment(e._id,n,{rev:e._rev})}))}function y1(t,e,r){var n=Rt(e)&&!Rt(t),i=Object.keys(r._attachments);return n?t.get(r._id).then(function(s){return Promise.all(i.map(function(o){return v1(s,r,o)?e.getAttachment(r._id,o):t.getAttachment(s._id,o)}))}).catch(function(s){if(s.status!==404)throw s;return rh(e,r)}):rh(e,r)}function g1(t){var e=[];return Object.keys(t).forEach(function(r){var n=t[r].missing;n.forEach(function(i){e.push({id:r,rev:i})})}),{docs:e,revs:!0,latest:!0}}function _1(t,e,r,n){r=Ge(r);var i=[],s=!0;function o(){var c=g1(r);if(c.docs.length)return t.bulkGet(c).then(function(d){if(n.cancelled)throw new Error("cancelled");return Promise.all(d.results.map(function(m){return Promise.all(m.docs.map(function(f){var y=f.ok;return f.error&&(s=!1),!y||!y._attachments?y:y1(e,t,y).then(_=>{var b=Object.keys(y._attachments);return _.forEach(function(P,S){var g=y._attachments[b[S]];delete g.stub,delete g.length,g.data=P}),y})}))})).then(function(m){i=i.concat(m.flat().filter(Boolean))})})}function a(){return{ok:s,docs:i}}return Promise.resolve().then(o).then(a)}var nh=1,ih="pouchdb",w1=5,bt=0;function ja(t,e,r,n,i){return t.get(e).catch(function(s){if(s.status===404)return(t.adapter==="http"||t.adapter==="https")&&ba(404,"PouchDB is just checking if a remote checkpoint exists."),{session_id:n,_id:e,history:[],replicator:ih,version:nh};throw s}).then(function(s){if(!i.cancelled&&s.last_seq!==r)return s.history=(s.history||[]).filter(function(o){return o.session_id!==n}),s.history.unshift({last_seq:r,session_id:n}),s.history=s.history.slice(0,w1),s.version=nh,s.replicator=ih,s.session_id=n,s.last_seq=r,t.put(s).catch(function(o){if(o.status===409)return ja(t,e,r,n,i);throw o})})}var Hi=class{constructor(e,r,n,i,s={writeSourceCheckpoint:!0,writeTargetCheckpoint:!0}){this.src=e,this.target=r,this.id=n,this.returnValue=i,this.opts=s,typeof s.writeSourceCheckpoint>"u"&&(s.writeSourceCheckpoint=!0),typeof s.writeTargetCheckpoint>"u"&&(s.writeTargetCheckpoint=!0)}writeCheckpoint(e,r){var n=this;return this.updateTarget(e,r).then(function(){return n.updateSource(e,r)})}updateTarget(e,r){return this.opts.writeTargetCheckpoint?ja(this.target,this.id,e,r,this.returnValue):Promise.resolve(!0)}updateSource(e,r){if(this.opts.writeSourceCheckpoint){var n=this;return ja(this.src,this.id,e,r,this.returnValue).catch(function(i){if(oh(i))return n.opts.writeSourceCheckpoint=!1,!0;throw i})}else return Promise.resolve(!0)}getCheckpoint(){var e=this;return!e.opts.writeSourceCheckpoint&&!e.opts.writeTargetCheckpoint?Promise.resolve(bt):e.opts&&e.opts.writeSourceCheckpoint&&!e.opts.writeTargetCheckpoint?e.src.get(e.id).then(function(r){return r.last_seq||bt}).catch(function(r){if(r.status!==404)throw r;return bt}):e.target.get(e.id).then(function(r){return e.opts&&e.opts.writeTargetCheckpoint&&!e.opts.writeSourceCheckpoint?r.last_seq||bt:e.src.get(e.id).then(function(n){if(r.version!==n.version)return bt;var i;return r.version?i=r.version.toString():i="undefined",i in sh?sh[i](r,n):bt},function(n){if(n.status===404&&r.last_seq)return e.src.put({_id:e.id,last_seq:bt}).then(function(){return bt},function(i){return oh(i)?(e.opts.writeSourceCheckpoint=!1,r.last_seq):bt});throw n})}).catch(function(r){if(r.status!==404)throw r;return bt})}},sh={undefined:function(t,e){return Be(t.last_seq,e.last_seq)===0?e.last_seq:0},1:function(t,e){return b1(e,t).last_seq}};function b1(t,e){return t.session_id===e.session_id?{last_seq:t.last_seq,history:t.history}:Uh(t.history,e.history)}function Uh(t,e){var r=t[0],n=t.slice(1),i=e[0],s=e.slice(1);if(!r||e.length===0)return{last_seq:bt,history:[]};var o=r.session_id;if(Da(o,e))return{last_seq:r.last_seq,history:t};var a=i.session_id;return Da(a,n)?{last_seq:i.last_seq,history:s}:Uh(n,s)}function Da(t,e){var r=e[0],n=e.slice(1);return!t||e.length===0?!1:t===r.session_id?!0:Da(t,n)}function oh(t){return typeof t.status=="number"&&Math.floor(t.status/100)===4}function Gh(t,e,r,n,i){return this instanceof Hi?Gh:new Hi(t,e,r,n,i)}var ah=0;function E1(t,e,r,n){if(t.retry===!1){e.emit("error",r),e.removeAllListeners();return}if(typeof t.back_off_function!="function"&&(t.back_off_function=H_),e.emit("requestError",r),e.state==="active"||e.state==="pending"){e.emit("paused",r),e.state="stopped";var i=function(){t.current_back_off=ah},s=function(){e.removeListener("active",i)};e.once("paused",s),e.once("active",i)}t.current_back_off=t.current_back_off||ah,t.current_back_off=t.back_off_function(t.current_back_off),setTimeout(n,t.current_back_off)}function $1(t){return Object.keys(t).sort(Be).reduce(function(e,r){return e[r]=t[r],e},{})}function S1(t,e,r){var n=r.doc_ids?r.doc_ids.sort(Be):"",i=r.filter?r.filter.toString():"",s="",o="",a="";return r.selector&&(a=JSON.stringify(r.selector)),r.filter&&r.query_params&&(s=JSON.stringify($1(r.query_params))),r.filter&&r.filter==="_view"&&(o=r.view.toString()),Promise.all([t.id(),e.id()]).then(function(c){var d=c[0]+c[1]+i+o+s+n+a;return new Promise(function(m){Ya(d,m)})}).then(function(c){return c=c.replace(/\//g,".").replace(/\+/g,"_"),"_local/"+c})}function Fh(t,e,r,n,i){var s=[],o,a={seq:0,changes:[],docs:[]},c=!1,d=!1,m=!1,f=0,y=0,_=r.continuous||r.live||!1,b=r.batch_size||100,P=r.batches_limit||10,S=r.style||"all_docs",g=!1,w=r.doc_ids,p=r.selector,h,v,E=[],k=Yi(),x;i=i||{ok:!0,start_time:new Date().toISOString(),docs_read:0,docs_written:0,doc_write_failures:0,errors:[]};var j={};n.ready(t,e);function G(){return v?Promise.resolve():S1(t,e,r).then(function(D){h=D;var M={};r.checkpoint===!1?M={writeSourceCheckpoint:!1,writeTargetCheckpoint:!1}:r.checkpoint==="source"?M={writeSourceCheckpoint:!0,writeTargetCheckpoint:!1}:r.checkpoint==="target"?M={writeSourceCheckpoint:!1,writeTargetCheckpoint:!0}:M={writeSourceCheckpoint:!0,writeTargetCheckpoint:!0},v=new Gh(t,e,h,n,M)})}function H(){if(E=[],o.docs.length!==0){var D=o.docs,M={timeout:r.timeout};return e.bulkDocs({docs:D,new_edits:!1},M).then(function(W){if(n.cancelled)throw q(),new Error("cancelled");var ee=Object.create(null);W.forEach(function(Ee){Ee.error&&(ee[Ee.id]=Ee)});var ne=Object.keys(ee).length;i.doc_write_failures+=ne,i.docs_written+=D.length-ne,D.forEach(function(Ee){var $e=ee[Ee._id];if($e){i.errors.push($e);var Re=($e.name||"").toLowerCase();if(Re==="unauthorized"||Re==="forbidden")n.emit("denied",Ge($e));else throw $e}else E.push(Ee)})},function(W){throw i.doc_write_failures+=D.length,W})}}function re(){if(o.error)throw new Error("There was a problem getting docs.");i.last_seq=y=o.seq;var D=Ge(i);return E.length&&(D.docs=E,typeof o.pending=="number"&&(D.pending=o.pending,delete o.pending),n.emit("change",D)),c=!0,t.info().then(function(M){var W=t.activeTasks.get(x);if(!(!o||!W)){var ee=W.completed_items||0,ne=parseInt(M.update_seq,10)-parseInt(f,10);t.activeTasks.update(x,{completed_items:ee+o.changes.length,total_items:ne})}}),v.writeCheckpoint(o.seq,k).then(function(){if(n.emit("checkpoint",{checkpoint:o.seq}),c=!1,n.cancelled)throw q(),new Error("cancelled");o=void 0,F()}).catch(function(M){throw J(M),M})}function Q(){var D={};return o.changes.forEach(function(M){n.emit("checkpoint",{revs_diff:M}),M.id!=="_user/"&&(D[M.id]=M.changes.map(function(W){return W.rev}))}),e.revsDiff(D).then(function(M){if(n.cancelled)throw q(),new Error("cancelled");o.diffs=M})}function Z(){return _1(t,e,o.diffs,n).then(function(D){o.error=!D.ok,D.docs.forEach(function(M){delete o.diffs[M._id],i.docs_read++,o.docs.push(M)})})}function ce(){if(!(n.cancelled||o)){if(s.length===0){fe(!0);return}o=s.shift(),n.emit("checkpoint",{start_next_batch:o.seq}),Q().then(Z).then(H).then(re).then(ce).catch(function(D){me("batch processing terminated with error",D)})}}function fe(D){if(a.changes.length===0){s.length===0&&!o&&((_&&j.live||d)&&(n.state="pending",n.emit("paused")),d&&q());return}(D||d||a.changes.length>=b)&&(s.push(a),a={seq:0,changes:[],docs:[]},(n.state==="pending"||n.state==="stopped")&&(n.state="active",n.emit("active")),ce())}function me(D,M){m||(M.message||(M.message=D),i.ok=!1,i.status="aborting",s=[],a={seq:0,changes:[],docs:[]},q(M))}function q(D){if(!m&&!(n.cancelled&&(i.status="cancelled",c)))if(i.status=i.status||"complete",i.end_time=new Date().toISOString(),i.last_seq=y,m=!0,t.activeTasks.remove(x,D),D){D=oe(D),D.result=i;var M=(D.name||"").toLowerCase();M==="unauthorized"||M==="forbidden"?(n.emit("error",D),n.removeAllListeners()):E1(r,n,D,function(){Fh(t,e,r,n)})}else n.emit("complete",i),n.removeAllListeners()}function C(D,M,W){if(n.cancelled)return q();typeof M=="number"&&(a.pending=M);var ee=za(r)(D);if(!ee){var ne=t.activeTasks.get(x);if(ne){var Ee=ne.completed_items||0;t.activeTasks.update(x,{completed_items:++Ee})}return}a.seq=D.seq||W,a.changes.push(D),n.emit("checkpoint",{pending_batch:a.seq}),qt(function(){fe(s.length===0&&j.live)})}function L(D){if(g=!1,n.cancelled)return q();if(D.results.length>0)j.since=D.results[D.results.length-1].seq,F(),fe(!0);else{var M=function(){_?(j.live=!0,F()):d=!0,fe(!0)};!o&&D.results.length===0?(c=!0,v.writeCheckpoint(D.last_seq,k).then(function(){if(c=!1,i.last_seq=y=D.last_seq,n.cancelled)throw q(),new Error("cancelled");M()}).catch(J)):M()}}function B(D){if(g=!1,n.cancelled)return q();me("changes rejected",D)}function F(){if(!(!g&&!d&&s.length<P))return;g=!0;function D(){W.cancel()}function M(){n.removeListener("cancel",D)}n._changes&&(n.removeListener("cancel",n._abortChanges),n._changes.cancel()),n.once("cancel",D);var W=t.changes(j).on("change",C);W.then(M,M),W.then(L).catch(B),r.retry&&(n._changes=W,n._abortChanges=D)}function X(D){return t.info().then(function(M){var W=typeof r.since>"u"?parseInt(M.update_seq,10)-parseInt(D,10):parseInt(M.update_seq,10);return x=t.activeTasks.add({name:`${_?"continuous ":""}replication from ${M.db_name}`,total_items:W}),D})}function ie(){G().then(function(){if(n.cancelled){q();return}return v.getCheckpoint().then(X).then(function(D){y=D,f=D,j={since:y,limit:b,batch_size:b,style:S,doc_ids:w,selector:p,return_docs:!0},r.filter&&(typeof r.filter!="string"?j.include_docs=!0:j.filter=r.filter),"heartbeat"in r&&(j.heartbeat=r.heartbeat),"timeout"in r&&(j.timeout=r.timeout),r.query_params&&(j.query_params=r.query_params),r.view&&(j.view=r.view),F()})}).catch(function(D){me("getCheckpoint rejected with ",D)})}function J(D){c=!1,me("writeCheckpoint completed with error",D)}if(n.cancelled){q();return}n._addedListeners||(n.once("cancel",q),typeof r.complete=="function"&&(n.once("error",r.complete),n.once("complete",function(D){r.complete(null,D)})),n._addedListeners=!0),typeof r.since>"u"?ie():G().then(function(){return c=!0,v.writeCheckpoint(r.since,k)}).then(function(){if(c=!1,n.cancelled){q();return}y=r.since,ie()}).catch(J)}var Ba=class extends ut{constructor(){super(),this.cancelled=!1,this.state="pending";let e=new Promise((r,n)=>{this.once("complete",r),this.once("error",n)});this.then=function(r,n){return e.then(r,n)},this.catch=function(r){return e.catch(r)},this.catch(function(){})}cancel(){this.cancelled=!0,this.state="cancelled",this.emit("cancel")}ready(e,r){if(this._readyCalled)return;this._readyCalled=!0;let n=()=>{this.cancel()};e.once("destroyed",n),r.once("destroyed",n);function i(){e.removeListener("destroyed",n),r.removeListener("destroyed",n)}this.once("complete",i),this.once("error",i)}};function Wi(t,e){var r=e.PouchConstructor;return typeof t=="string"?new r(t,e):t}function La(t,e,r,n){if(typeof r=="function"&&(n=r,r={}),typeof r>"u"&&(r={}),r.doc_ids&&!Array.isArray(r.doc_ids))throw oe(Qi,"`doc_ids` filter parameter is not a list.");r.complete=n,r=Ge(r),r.continuous=r.continuous||r.live,r.retry="retry"in r?r.retry:!1,r.PouchConstructor=r.PouchConstructor||this;var i=new Ba(r),s=Wi(t,r),o=Wi(e,r);return Fh(s,o,r,i),i}function P1(t,e,r,n){return typeof r=="function"&&(n=r,r={}),typeof r>"u"&&(r={}),r=Ge(r),r.PouchConstructor=r.PouchConstructor||this,t=Wi(t,r),e=Wi(e,r),new Ma(t,e,r,n)}var Ma=class extends ut{constructor(e,r,n,i){super(),this.canceled=!1;let s=n.push?Object.assign({},n,n.push):n,o=n.pull?Object.assign({},n,n.pull):n;this.push=La(e,r,s),this.pull=La(r,e,o),this.pushPaused=!0,this.pullPaused=!0;let a=p=>{this.emit("change",{direction:"pull",change:p})},c=p=>{this.emit("change",{direction:"push",change:p})},d=p=>{this.emit("denied",{direction:"push",doc:p})},m=p=>{this.emit("denied",{direction:"pull",doc:p})},f=()=>{this.pushPaused=!0,this.pullPaused&&this.emit("paused")},y=()=>{this.pullPaused=!0,this.pushPaused&&this.emit("paused")},_=()=>{this.pushPaused=!1,this.pullPaused&&this.emit("active",{direction:"push"})},b=()=>{this.pullPaused=!1,this.pushPaused&&this.emit("active",{direction:"pull"})},P={},S=p=>(h,v)=>{(h==="change"&&(v===a||v===c)||h==="denied"&&(v===m||v===d)||h==="paused"&&(v===y||v===f)||h==="active"&&(v===b||v===_))&&(h in P||(P[h]={}),P[h][p]=!0,Object.keys(P[h]).length===2&&this.removeAllListeners(h))};n.live&&(this.push.on("complete",this.pull.cancel.bind(this.pull)),this.pull.on("complete",this.push.cancel.bind(this.push)));function g(p,h,v){p.listeners(h).indexOf(v)==-1&&p.on(h,v)}this.on("newListener",function(p){p==="change"?(g(this.pull,"change",a),g(this.push,"change",c)):p==="denied"?(g(this.pull,"denied",m),g(this.push,"denied",d)):p==="active"?(g(this.pull,"active",b),g(this.push,"active",_)):p==="paused"&&(g(this.pull,"paused",y),g(this.push,"paused",f))}),this.on("removeListener",function(p){p==="change"?(this.pull.removeListener("change",a),this.push.removeListener("change",c)):p==="denied"?(this.pull.removeListener("denied",m),this.push.removeListener("denied",d)):p==="active"?(this.pull.removeListener("active",b),this.push.removeListener("active",_)):p==="paused"&&(this.pull.removeListener("paused",y),this.push.removeListener("paused",f))}),this.pull.on("removeListener",S("pull")),this.push.on("removeListener",S("push"));let w=Promise.all([this.push,this.pull]).then(p=>{let h={push:p[0],pull:p[1]};return this.emit("complete",h),i&&i(null,h),this.removeAllListeners(),h},p=>{if(this.cancel(),i?i(p):this.emit("error",p),this.removeAllListeners(),i)throw p});this.then=function(p,h){return w.then(p,h)},this.catch=function(p){return w.catch(p)}}cancel(){this.canceled||(this.canceled=!0,this.push.cancel(),this.pull.cancel())}};function O1(t){t.replicate=La,t.sync=P1,Object.defineProperty(t.prototype,"replicate",{get:function(){var e=this;return typeof this.replicateMethods>"u"&&(this.replicateMethods={from:function(r,n,i){return e.constructor.replicate(r,e,n,i)},to:function(r,n,i){return e.constructor.replicate(e,r,n,i)}}),this.replicateMethods}}),t.prototype.sync=function(e,r,n){return this.constructor.sync(this,e,r,n)}}ae.plugin(zw).plugin(Xw).plugin(m1).plugin(O1);var zh=ae;I();R();T();var Yt=t=>`${t.source}/${encodeURIComponent(t.actor)}/${encodeURIComponent(t.name)}`,ru=t=>{let e=t.split("/"),r=e.pop(),n=e.pop();if(!r||!n||!e.length)throw new Jc;return{name:decodeURIComponent(r),actor:decodeURIComponent(n),source:e.join("/")}};function nu(t=16){let e=new Uint8Array(t);return crypto.getRandomValues(e),btoa(String.fromCodePoint(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=+$/,"")}function Hr(t){return typeof t=="string"?{location:ru(t),uri:t}:{location:{name:t.name,actor:t.actor,source:t.source},uri:Yt(t)}}function Kh(t,e){return t.lastModified>e.lastModified||t.lastModified===e.lastModified&&!t.tombstone&&e.tombstone}function Xi(t,e,r,n){let i=r[e];if(!(!i||!i.length))try{n[e]=t(n[e],i,!0,!1).newDocument}catch(s){throw typeof s=="object"&&s&&"name"in s&&typeof s.name=="string"&&"message"in s&&typeof s.message=="string"?s.name==="TEST_OPERATION_FAILED"?new zc(s.message):new Tr(s.name+": "+s.message):s}}function Wr(t,e){try{return t.compile(e)}catch(r){throw new Mc(r instanceof Error?r.message:void 0)}}function Bn(t,e,r){t.actor!==r?.actor&&(t.allowed=t.allowed&&r?[r.actor]:void 0,t.channels=t.channels.filter(n=>e.includes(n)))}function Ln(t,e){return t.allowed===void 0||t.allowed===null||!!e?.actor&&(t.actor===e.actor||t.allowed.includes(e.actor))}I();R();T();var su=function(t,e){return su=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},su(t,e)};function A1(t,e){su(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Yr(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(m){try{d(n.next(m))}catch(f){o(f)}}function c(m){try{d(n.throw(m))}catch(f){o(f)}}function d(m){m.done?s(m.value):i(m.value).then(a,c)}d((n=n.apply(t,e||[])).next())})}function Xt(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(d){return function(m){return c([d,m])}}function c(d){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=d[0]&2?i.return:d[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,d[1])).done)return s;switch(i=0,s&&(d=[d[0]&2,s.value]),d[0]){case 0:case 1:s=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,i=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!s||d[1]>s[0]&&d[1]<s[3])){r.label=d[1];break}if(d[0]===6&&r.label<s[1]){r.label=s[1],s=d;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(d);break}s[2]&&r.ops.pop(),r.trys.pop();continue}d=e.call(t,r)}catch(m){d=[6,m],i=0}finally{n=s=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function Xr(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Un(t){return this instanceof Un?(this.v=t,this):new Un(t)}function I1(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(y){n[y]&&(i[y]=function(_){return new Promise(function(b,P){s.push([y,_,b,P])>1||a(y,_)})})}function a(y,_){try{c(n[y](_))}catch(b){f(s[0][3],b)}}function c(y){y.value instanceof Un?Promise.resolve(y.value.v).then(d,m):f(s[0][2],y)}function d(y){a("next",y)}function m(y){a("throw",y)}function f(y,_){y(_),s.shift(),s.length&&a(s[0][0],s[0][1])}}var Hh=function(t){A1(e,t);function e(r){var n=t.call(this,r)||this;return Object.defineProperty(n,"name",{value:"RepeaterOverflowError",enumerable:!1}),typeof Object.setPrototypeOf=="function"?Object.setPrototypeOf(n,n.constructor.prototype):n.__proto__=n.constructor.prototype,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(n,n.constructor),n}return e}(Error),qA=function(){function t(e){if(e<0)throw new RangeError("Capacity may not be less than 0");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),t.prototype.add=function(e){if(this.full)throw new Error("Buffer full");this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}(),kA=function(){function t(e){if(e<1)throw new RangeError("Capacity may not be less than 1");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(e){for(;this._q.length>=this._c;)this._q.shift();this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}(),CA=function(){function t(e){if(e<1)throw new RangeError("Capacity may not be less than 1");this._c=e,this._q=[]}return Object.defineProperty(t.prototype,"empty",{get:function(){return this._q.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(e){this._q.length<this._c&&this._q.push(e)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()},t}();function ou(t){t!=null&&typeof t.then=="function"&&t.then(rs,rs)}var iu=0,Vh=1,Pr=2,es=3,au=4,ts=1024,rs=function(){};function Qr(t){var e=t.err,r=Promise.resolve(t.execution).then(function(n){if(e!=null)throw e;return n});return t.err=void 0,t.execution=r.then(function(){},function(){}),t.pending===void 0?r:t.pending.then(function(){return r})}function Sr(t,e){var r=t.state>=es;return Promise.resolve(e).then(function(n){return!r&&t.state>=au?Qr(t).then(function(i){return{value:i,done:!0}}):{value:n,done:r}})}function uu(t,e){var r,n;if(!(t.state>=Pr))if(t.state=Pr,t.onnext(),t.onstop(),t.err==null&&(t.err=e),t.pushes.length===0&&(typeof t.buffer>"u"||t.buffer.empty))Mn(t);else try{for(var i=Xr(t.pushes),s=i.next();!s.done;s=i.next()){var o=s.value;o.resolve()}}catch(a){r={error:a}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}function Mn(t){var e,r;if(!(t.state>=es)){t.state<Pr&&uu(t),t.state=es,t.buffer=void 0;try{for(var n=Xr(t.nexts),i=n.next();!i.done;i=n.next()){var s=i.value,o=t.pending===void 0?Qr(t):t.pending.then(function(){return Qr(t)});s.resolve(Sr(t,o))}}catch(a){e={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}t.pushes=[],t.nexts=[]}}function Jh(t){t.state>=au||(t.state<es&&Mn(t),t.state=au)}function T1(t,e){if(ou(e),t.pushes.length>=ts)throw new Hh("No more than "+ts+" pending calls to push are allowed on a single repeater.");if(t.state>=Pr)return Promise.resolve(void 0);var r=t.pending===void 0?Promise.resolve(e):t.pending.then(function(){return e});r=r.catch(function(c){t.state<Pr&&(t.err=c),Jh(t)});var n;if(t.nexts.length){var i=t.nexts.shift();i.resolve(Sr(t,r)),t.nexts.length?n=Promise.resolve(t.nexts[0].value):typeof t.buffer<"u"&&!t.buffer.full?n=Promise.resolve(void 0):n=new Promise(function(c){return t.onnext=c})}else typeof t.buffer<"u"&&!t.buffer.full?(t.buffer.add(r),n=Promise.resolve(void 0)):n=new Promise(function(c){return t.pushes.push({resolve:c,value:r})});var s=!0,o={},a=n.catch(function(c){if(s)throw c});return o.then=function(c,d){return s=!1,Promise.prototype.then.call(n,c,d)},o.catch=function(c){return s=!1,Promise.prototype.catch.call(n,c)},o.finally=n.finally.bind(n),t.pending=r.then(function(){return a}).catch(function(c){t.err=c,Jh(t)}),o}function R1(t){var e=uu.bind(null,t),r=new Promise(function(n){return t.onstop=n});return e.then=r.then.bind(r),e.catch=r.catch.bind(r),e.finally=r.finally.bind(r),e}function q1(t){if(!(t.state>=Vh)){t.state=Vh;var e=T1.bind(null,t),r=R1(t);t.execution=new Promise(function(n){return n(t.executor(e,r))}),t.execution.catch(function(){return uu(t)})}}var Zi=new WeakMap,kt=function(){function t(e,r){Zi.set(this,{executor:e,buffer:r,err:void 0,state:iu,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:rs,onstop:rs})}return t.prototype.next=function(e){ou(e);var r=Zi.get(this);if(r===void 0)throw new Error("WeakMap error");if(r.nexts.length>=ts)throw new Hh("No more than "+ts+" pending calls to next are allowed on a single repeater.");if(r.state<=iu&&q1(r),r.onnext(e),typeof r.buffer<"u"&&!r.buffer.empty){var n=Sr(r,r.buffer.remove());if(r.pushes.length){var i=r.pushes.shift();r.buffer.add(i.value),r.onnext=i.resolve}return n}else if(r.pushes.length){var s=r.pushes.shift();return r.onnext=s.resolve,Sr(r,s.value)}else if(r.state>=Pr)return Mn(r),Sr(r,Qr(r));return new Promise(function(o){return r.nexts.push({resolve:o,value:e})})},t.prototype.return=function(e){ou(e);var r=Zi.get(this);if(r===void 0)throw new Error("WeakMap error");return Mn(r),r.execution=Promise.resolve(r.execution).then(function(){return e}),Sr(r,Qr(r))},t.prototype.throw=function(e){var r=Zi.get(this);if(r===void 0)throw new Error("WeakMap error");return r.state<=iu||r.state>=Pr||typeof r.buffer<"u"&&!r.buffer.empty?(Mn(r),r.err==null&&(r.err=e),Sr(r,Qr(r))):this.next(Promise.reject(e))},t.prototype[Symbol.asyncIterator]=function(){return this},t.race=k1,t.merge=C1,t.zip=x1,t.latest=N1,t}();function ns(t,e){var r,n,i=[],s=function(d){d!=null&&typeof d[Symbol.asyncIterator]=="function"?i.push(d[Symbol.asyncIterator]()):d!=null&&typeof d[Symbol.iterator]=="function"?i.push(d[Symbol.iterator]()):i.push(function(){return I1(this,arguments,function(){return Xt(this,function(y){switch(y.label){case 0:return e.yieldValues?[4,Un(d)]:[3,3];case 1:return[4,y.sent()];case 2:y.sent(),y.label=3;case 3:return e.returnValues?[4,Un(d)]:[3,5];case 4:return[2,y.sent()];case 5:return[2]}})})}())};try{for(var o=Xr(t),a=o.next();!a.done;a=o.next()){var c=a.value;s(c)}}catch(d){r={error:d}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}function k1(t){var e=this,r=ns(t,{returnValues:!0});return new kt(function(n,i){return Yr(e,void 0,void 0,function(){var s,o,a,c,d,m;return Xt(this,function(f){switch(f.label){case 0:if(!r.length)return i(),[2];o=!1,i.then(function(){s(),o=!0}),f.label=1;case 1:f.trys.push([1,,5,7]),c=void 0,d=0,m=function(){var y,_,b,P,S,g;return Xt(this,function(w){switch(w.label){case 0:y=d;try{for(_=(S=void 0,Xr(r)),b=_.next();!b.done;b=_.next())P=b.value,Promise.resolve(P.next()).then(function(p){p.done?(i(),a===void 0&&(a=p)):d===y&&(d++,s(p))},function(p){return i(p)})}catch(p){S={error:p}}finally{try{b&&!b.done&&(g=_.return)&&g.call(_)}finally{if(S)throw S.error}}return[4,new Promise(function(p){return s=p})];case 1:return c=w.sent(),c===void 0?[3,3]:[4,n(c.value)];case 2:w.sent(),w.label=3;case 3:return[2]}})},f.label=2;case 2:return o?[3,4]:[5,m()];case 3:return f.sent(),[3,2];case 4:return[2,a&&a.value];case 5:return i(),[4,Promise.race(r.map(function(y){return y.return&&y.return()}))];case 6:return f.sent(),[7];case 7:return[2]}})})})}function C1(t){var e=this,r=ns(t,{yieldValues:!0});return new kt(function(n,i){return Yr(e,void 0,void 0,function(){var s,o,a,c=this;return Xt(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2];s=[],o=!1,i.then(function(){var m,f;o=!0;try{for(var y=Xr(s),_=y.next();!_.done;_=y.next()){var b=_.value;b()}}catch(P){m={error:P}}finally{try{_&&!_.done&&(f=y.return)&&f.call(y)}finally{if(m)throw m.error}}}),d.label=1;case 1:return d.trys.push([1,,3,4]),[4,Promise.all(r.map(function(m,f){return Yr(c,void 0,void 0,function(){var y,_;return Xt(this,function(b){switch(b.label){case 0:b.trys.push([0,,6,9]),b.label=1;case 1:return o?[3,5]:(Promise.resolve(m.next()).then(function(P){return s[f](P)},function(P){return i(P)}),[4,new Promise(function(P){s[f]=P})]);case 2:return y=b.sent(),y===void 0?[3,4]:y.done?(a=y,[2]):[4,n(y.value)];case 3:b.sent(),b.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return _=m.return,_?[4,m.return()]:[3,8];case 7:_=b.sent(),b.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return d.sent(),[2,a&&a.value];case 3:return i(),[7];case 4:return[2]}})})})}function x1(t){var e=this,r=ns(t,{returnValues:!0});return new kt(function(n,i){return Yr(e,void 0,void 0,function(){var s,o,a,c;return Xt(this,function(d){switch(d.label){case 0:if(!r.length)return i(),[2,[]];o=!1,i.then(function(){s(),o=!0}),d.label=1;case 1:d.trys.push([1,,6,8]),d.label=2;case 2:return o?[3,5]:(Promise.all(r.map(function(m){return m.next()})).then(function(m){return s(m)},function(m){return i(m)}),[4,new Promise(function(m){return s=m})]);case 3:return a=d.sent(),a===void 0?[2]:(c=a.map(function(m){return m.value}),a.some(function(m){return m.done})?[2,c]:[4,n(c)]);case 4:return d.sent(),[3,2];case 5:return[3,8];case 6:return i(),[4,Promise.all(r.map(function(m){return m.return&&m.return()}))];case 7:return d.sent(),[7];case 8:return[2]}})})})}function N1(t){var e=this,r=ns(t,{yieldValues:!0,returnValues:!0});return new kt(function(n,i){return Yr(e,void 0,void 0,function(){var s,o,a,c,d,m=this;return Xt(this,function(f){switch(f.label){case 0:if(!r.length)return i(),[2,[]];o=[],a=!1,i.then(function(){var y,_;s();try{for(var b=Xr(o),P=b.next();!P.done;P=b.next()){var S=P.value;S()}}catch(g){y={error:g}}finally{try{P&&!P.done&&(_=b.return)&&_.call(b)}finally{if(y)throw y.error}}a=!0}),f.label=1;case 1:return f.trys.push([1,,5,7]),Promise.all(r.map(function(y){return y.next()})).then(function(y){return s(y)},function(y){return i(y)}),[4,new Promise(function(y){return s=y})];case 2:return c=f.sent(),c===void 0?[2]:(d=c.map(function(y){return y.value}),c.every(function(y){return y.done})?[2,d]:[4,n(d.slice())]);case 3:return f.sent(),[4,Promise.all(r.map(function(y,_){return Yr(m,void 0,void 0,function(){var b;return Xt(this,function(P){switch(P.label){case 0:if(c[_].done)return[2,c[_].value];P.label=1;case 1:return a?[3,4]:(Promise.resolve(y.next()).then(function(S){return o[_](S)},function(S){return i(S)}),[4,new Promise(function(S){return o[_]=S})]);case 2:return b=P.sent(),b===void 0?[2,c[_].value]:b.done?[2,b.value]:(d[_]=b.value,[4,n(d.slice())]);case 3:return P.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,f.sent()];case 5:return i(),[4,Promise.all(r.map(function(y){return y.return&&y.return()}))];case 6:return f.sent(),[7];case 7:return[2]}})})})}var Yh=en(Ri());I();R();T();var cu={};hs(cu,{JsonPatchError:()=>Ne,_areEquals:()=>zn,applyOperation:()=>Or,applyPatch:()=>Zt,applyReducer:()=>M1,deepClone:()=>B1,getValueByPointer:()=>us,validate:()=>Qh,validator:()=>cs});I();R();T();I();R();T();var j1=function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)i.hasOwnProperty(s)&&(n[s]=i[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}}(),D1=Object.prototype.hasOwnProperty;function ss(t,e){return D1.call(t,e)}function os(t){if(Array.isArray(t)){for(var e=new Array(t.length),r=0;r<e.length;r++)e[r]=""+r;return e}if(Object.keys)return Object.keys(t);var n=[];for(var i in t)ss(t,i)&&n.push(i);return n}function He(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function as(t){for(var e=0,r=t.length,n;e<r;){if(n=t.charCodeAt(e),n>=48&&n<=57){e++;continue}return!1}return!0}function Ct(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Gn(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function is(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,r=t.length;e<r;e++)if(is(t[e]))return!0}else if(typeof t=="object"){for(var n=os(t),i=n.length,s=0;s<i;s++)if(is(t[n[s]]))return!0}}return!1}function Wh(t,e){var r=[t];for(var n in e){var i=typeof e[n]=="object"?JSON.stringify(e[n],null,2):e[n];typeof i<"u"&&r.push(n+": "+i)}return r.join(`
17
+ `)}var Fn=function(t){j1(e,t);function e(r,n,i,s,o){var a=this.constructor,c=t.call(this,Wh(r,{name:n,index:i,operation:s,tree:o}))||this;return c.name=n,c.index=i,c.operation=s,c.tree=o,Object.setPrototypeOf(c,a.prototype),c.message=Wh(r,{name:n,index:i,operation:s,tree:o}),c}return e}(Error);var Ne=Fn,B1=He,Zr={add:function(t,e,r){return t[e]=this.value,{newDocument:r}},remove:function(t,e,r){var n=t[e];return delete t[e],{newDocument:r,removed:n}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:function(t,e,r){var n=us(r,this.path);n&&(n=He(n));var i=Or(r,{op:"remove",path:this.from}).removed;return Or(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(t,e,r){var n=us(r,this.from);return Or(r,{op:"add",path:this.path,value:He(n)}),{newDocument:r}},test:function(t,e,r){return{newDocument:r,test:zn(t[e],this.value)}},_get:function(t,e,r){return this.value=t[e],{newDocument:r}}},L1={add:function(t,e,r){return as(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:r,index:e}},remove:function(t,e,r){var n=t.splice(e,1);return{newDocument:r,removed:n[0]}},replace:function(t,e,r){var n=t[e];return t[e]=this.value,{newDocument:r,removed:n}},move:Zr.move,copy:Zr.copy,test:Zr.test,_get:Zr._get};function us(t,e){if(e=="")return t;var r={op:"_get",path:e};return Or(t,r),r.value}function Or(t,e,r,n,i,s){if(r===void 0&&(r=!1),n===void 0&&(n=!0),i===void 0&&(i=!0),s===void 0&&(s=0),r&&(typeof r=="function"?r(e,0,t,e.path):cs(e,0)),e.path===""){var o={newDocument:t};if(e.op==="add")return o.newDocument=e.value,o;if(e.op==="replace")return o.newDocument=e.value,o.removed=t,o;if(e.op==="move"||e.op==="copy")return o.newDocument=us(t,e.from),e.op==="move"&&(o.removed=t),o;if(e.op==="test"){if(o.test=zn(t,e.value),o.test===!1)throw new Ne("Test operation failed","TEST_OPERATION_FAILED",s,e,t);return o.newDocument=t,o}else{if(e.op==="remove")return o.removed=t,o.newDocument=null,o;if(e.op==="_get")return e.value=t,o;if(r)throw new Ne("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,e,t);return o}}else{n||(t=He(t));var a=e.path||"",c=a.split("/"),d=t,m=1,f=c.length,y=void 0,_=void 0,b=void 0;for(typeof r=="function"?b=r:b=cs;;){if(_=c[m],_&&_.indexOf("~")!=-1&&(_=Gn(_)),i&&(_=="__proto__"||_=="prototype"&&m>0&&c[m-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&y===void 0&&(d[_]===void 0?y=c.slice(0,m).join("/"):m==f-1&&(y=e.path),y!==void 0&&b(e,0,t,y)),m++,Array.isArray(d)){if(_==="-")_=d.length;else{if(r&&!as(_))throw new Ne("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",s,e,t);as(_)&&(_=~~_)}if(m>=f){if(r&&e.op==="add"&&_>d.length)throw new Ne("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,e,t);var o=L1[e.op].call(e,d,_,t);if(o.test===!1)throw new Ne("Test operation failed","TEST_OPERATION_FAILED",s,e,t);return o}}else if(m>=f){var o=Zr[e.op].call(e,d,_,t);if(o.test===!1)throw new Ne("Test operation failed","TEST_OPERATION_FAILED",s,e,t);return o}if(d=d[_],r&&m<f&&(!d||typeof d!="object"))throw new Ne("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,e,t)}}}function Zt(t,e,r,n,i){if(n===void 0&&(n=!0),i===void 0&&(i=!0),r&&!Array.isArray(e))throw new Ne("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(t=He(t));for(var s=new Array(e.length),o=0,a=e.length;o<a;o++)s[o]=Or(t,e[o],r,!0,i,o),t=s[o].newDocument;return s.newDocument=t,s}function M1(t,e,r){var n=Or(t,e);if(n.test===!1)throw new Ne("Test operation failed","TEST_OPERATION_FAILED",r,e,t);return n.newDocument}function cs(t,e,r,n){if(typeof t!="object"||t===null||Array.isArray(t))throw new Ne("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,r);if(Zr[t.op]){if(typeof t.path!="string")throw new Ne("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,r);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new Ne('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,r);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new Ne("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new Ne("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,r);if((t.op==="add"||t.op==="replace"||t.op==="test")&&is(t.value))throw new Ne("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,r);if(r){if(t.op=="add"){var i=t.path.split("/").length,s=n.split("/").length;if(i!==s+1&&i!==s)throw new Ne("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,r)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==n)throw new Ne("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,r)}else if(t.op==="move"||t.op==="copy"){var o={op:"_get",path:t.from,value:void 0},a=Qh([o],r);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new Ne("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,r)}}}else throw new Ne("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,r)}function Qh(t,e,r){try{if(!Array.isArray(t))throw new Ne("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Zt(He(e),He(t),r||!0);else{r=r||cs;for(var n=0;n<t.length;n++)r(t[n],n,e,void 0)}}catch(i){if(i instanceof Ne)return i;throw i}}function zn(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=Array.isArray(t),n=Array.isArray(e),i,s,o;if(r&&n){if(s=t.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!zn(t[i],e[i]))return!1;return!0}if(r!=n)return!1;var a=Object.keys(t);if(s=a.length,s!==Object.keys(e).length)return!1;for(i=s;i--!==0;)if(!e.hasOwnProperty(a[i]))return!1;for(i=s;i--!==0;)if(o=a[i],!zn(t[o],e[o]))return!1;return!0}return t!==t&&e!==e}var hu={};hs(hu,{compare:()=>H1,generate:()=>fu,observe:()=>J1,unobserve:()=>V1});I();R();T();var lu=new WeakMap,U1=function(){function t(e){this.observers=new Map,this.obj=e}return t}(),G1=function(){function t(e,r){this.callback=e,this.observer=r}return t}();function F1(t){return lu.get(t)}function z1(t,e){return t.observers.get(e)}function K1(t,e){t.observers.delete(e.callback)}function V1(t,e){e.unobserve()}function J1(t,e){var r=[],n,i=F1(t);if(!i)i=new U1(t),lu.set(t,i);else{var s=z1(i,e);n=s&&s.observer}if(n)return n;if(n={},i.value=He(t),e){n.callback=e,n.next=null;var o=function(){fu(n)},a=function(){clearTimeout(n.next),n.next=setTimeout(o)};typeof window<"u"&&(window.addEventListener("mouseup",a),window.addEventListener("keyup",a),window.addEventListener("mousedown",a),window.addEventListener("keydown",a),window.addEventListener("change",a))}return n.patches=r,n.object=t,n.unobserve=function(){fu(n),clearTimeout(n.next),K1(i,n),typeof window<"u"&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a))},i.observers.set(e,new G1(e,n)),n}function fu(t,e){e===void 0&&(e=!1);var r=lu.get(t.object);du(r.value,t.object,t.patches,"",e),t.patches.length&&Zt(r.value,t.patches);var n=t.patches;return n.length>0&&(t.patches=[],t.callback&&t.callback(n)),n}function du(t,e,r,n,i){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var s=os(e),o=os(t),a=!1,c=!1,d=o.length-1;d>=0;d--){var m=o[d],f=t[m];if(ss(e,m)&&!(e[m]===void 0&&f!==void 0&&Array.isArray(e)===!1)){var y=e[m];typeof f=="object"&&f!=null&&typeof y=="object"&&y!=null&&Array.isArray(f)===Array.isArray(y)?du(f,y,r,n+"/"+Ct(m),i):f!==y&&(a=!0,i&&r.push({op:"test",path:n+"/"+Ct(m),value:He(f)}),r.push({op:"replace",path:n+"/"+Ct(m),value:He(y)}))}else Array.isArray(t)===Array.isArray(e)?(i&&r.push({op:"test",path:n+"/"+Ct(m),value:He(f)}),r.push({op:"remove",path:n+"/"+Ct(m)}),c=!0):(i&&r.push({op:"test",path:n,value:t}),r.push({op:"replace",path:n,value:e}),a=!0)}if(!(!c&&s.length==o.length))for(var d=0;d<s.length;d++){var m=s[d];!ss(t,m)&&e[m]!==void 0&&r.push({op:"add",path:n+"/"+Ct(m),value:He(e[m])})}}}function H1(t,e,r){r===void 0&&(r=!1);var n=[];return du(t,e,n,"",r),n}var XA=Object.assign({},cu,hu,{JsonPatchError:Fn,deepClone:He,escapePathComponent:Ct,unescapePathComponent:Gn});var fs=class{db;source="local";tombstoneRetention=864e5;ajv;constructor(e,r){this.ajv=r??new Yh.default({strict:!1}),this.source=e?.sourceName??this.source,this.tombstoneRetention=e?.tombstoneRetention??this.tombstoneRetention;let n={name:"graffitiDb",...e?.pouchDBOptions};this.db=new zh(n.name,n),this.db.put({_id:"_design/indexes",views:{objectsPerChannelAndLastModified:{map:function(i){let s=i.lastModified.toString().padStart(15,"0");i.channels.forEach(function(o){let a=encodeURIComponent(o)+"/"+s;emit(a)})}.toString()},orphansPerActorAndLastModified:{map:function(i){if(i.channels.length===0){let s=i.lastModified.toString().padStart(15,"0"),o=encodeURIComponent(i.actor)+"/"+s;emit(o)}}.toString()},channelStatsPerActor:{map:function(i){i.tombstone||i.channels.forEach(function(s){let o=encodeURIComponent(i.actor)+"/"+encodeURIComponent(s);emit(o,i.lastModified)})}.toString(),reduce:"_stats"}}}).catch(i=>{if(!(i&&typeof i=="object"&&"name"in i&&i.name==="conflict"))throw i})}async queryByLocation(e){let r=Yt(e)+"/";return(await this.db.allDocs({startkey:r,endkey:r+"\uFFFF",include_docs:!0})).rows.map(s=>s.doc).reduce((s,o)=>(o&&s.push(o),s),[])}docId(e){return Yt(e)+"/"+nu()}get=async(...e)=>{let[r,n,i]=e,{location:s}=Hr(r),a=(await this.queryByLocation(s)).filter(_=>Ln(_,i));if(!a.length)throw new Wn;let c=a.reduce((_,b)=>Kh(_,b)?_:b),{_id:d,_rev:m,...f}=c;if(Bn(f,[],i),!Wr(this.ajv,n)(f))throw new Gc;return f};async deleteAtLocation(e,r=!1){let i=(await this.queryByLocation(e)).filter(f=>!f.tombstone);if(!i.length)return;let s=i.map(f=>f.lastModified).reduce((f,y)=>f>y?f:y),o=i.filter(f=>!r||f.lastModified<s),a=i.filter(f=>r&&f.lastModified===s);if(a.length){let f=a.map(_=>_._id).reduce((_,b)=>_>b?_:b),y=a.filter(_=>_._id!==f);o.push(...y)}let c=r?s:new Date().getTime(),d=await this.db.bulkDocs(o.map(f=>({...f,tombstone:!0,lastModified:c}))),m;for(let f of d)if("ok"in f){let{id:y}=f,_=o.find(b=>b._id===y);if(_){let{_id:b,_rev:P,_conflicts:S,_attachments:g,...w}=_;m={...w,tombstone:!0,lastModified:c};break}}return m}delete=async(...e)=>{let[r,n]=e,{location:i}=Hr(r);if(i.actor!==n.actor)throw new rn;let s=await this.deleteAtLocation(i);if(!s)throw new Wn;return s};put=async(...e)=>{let[r,n]=e;if(r.actor&&r.actor!==n.actor)throw new rn;if(r.source&&r.source!==this.source)throw new rn("Putting an object that does not match this source");let i={value:r.value,channels:r.channels,allowed:r.allowed,name:r.name??nu(),source:this.source,actor:n.actor,tombstone:!1,lastModified:new Date().getTime()};await this.db.put({_id:this.docId(i),...i});let s=await this.deleteAtLocation(i,!0);return s||{...i,value:{},channels:[],allowed:void 0,tombstone:!0}};patch=async(...e)=>{let[r,n,i]=e,{location:s}=Hr(n);if(s.actor!==i.actor)throw new rn;let o=await this.get(n,{},i);if(o.tombstone)throw new Wn("The object you are trying to patch has been deleted");let a={...o};for(let c of["value","channels","allowed"])Xi(Zt,c,r,a);if(typeof a.value!="object"||Array.isArray(a.value)||!a.value)throw new Tr("value is no longer an object");if(!Array.isArray(a.channels)||!a.channels.every(c=>typeof c=="string"))throw new Tr("channels are no longer an array of strings");if(a.allowed&&(!Array.isArray(a.allowed)||!a.allowed.every(c=>typeof c=="string")))throw new Tr("allowed list is not an array of strings");return a.lastModified=new Date().getTime(),await this.db.put({...a,_id:this.docId(a)}),await this.deleteAtLocation(a,!0),{...o,tombstone:!0,lastModified:a.lastModified}};queryLastModifiedSuffixes(e){let r="",n="\uFFFF",i=e.properties?.lastModified;if(i?.minimum){let s=Math.ceil(i.minimum);s===i.minimum&&i.exclusiveMinimum&&s++,r=s.toString().padStart(15,"0")}if(i?.maximum){let s=Math.floor(i.maximum);s===i.maximum&&i.exclusiveMaximum&&s--,n=s.toString().padStart(15,"0")}return{startKeySuffix:r,endKeySuffix:n}}discover=(...e)=>{let[r,n,i]=e,s=Wr(this.ajv,n),{startKeySuffix:o,endKeySuffix:a}=this.queryLastModifiedSuffixes(n);return new kt(async(d,m)=>{let f=new Set;for(let y of r){let _=encodeURIComponent(y)+"/",b=_+o,P=_+a,S=await this.db.query("indexes/objectsPerChannelAndLastModified",{startkey:b,endkey:P,include_docs:!0});for(let g of S.rows){let w=g.doc;if(!w)continue;let{_id:p,_rev:h,...v}=w;f.has(p)||(f.add(p),Ln(w,i)&&(Bn(v,r,i),s(v)&&await d({value:v})))}}return m(),{tombstoneRetention:this.tombstoneRetention}})};recoverOrphans=(e,r)=>{let n=Wr(this.ajv,e),{startKeySuffix:i,endKeySuffix:s}=this.queryLastModifiedSuffixes(e),o=encodeURIComponent(r.actor)+"/",a=o+i,c=o+s;return new kt(async(m,f)=>{let y=await this.db.query("indexes/orphansPerActorAndLastModified",{startkey:a,endkey:c,include_docs:!0});for(let _ of y.rows){let b=_.doc;if(!b)continue;let{_id:P,_rev:S,...g}=b;n(g)&&await m({value:g})}return f(),{tombstoneRetention:this.tombstoneRetention}})};channelStats=e=>new kt(async(n,i)=>{let s=encodeURIComponent(e.actor)+"/",o=await this.db.query("indexes/channelStatsPerActor",{startkey:s,endkey:s+"\uFFFF",reduce:!0,group:!0});for(let a of o.rows){let c=a.key.split("/")[1];if(typeof c!="string")continue;let{count:d,max:m}=a.value;typeof d!="number"||typeof m!="number"||await n({value:{channel:decodeURIComponent(c),count:d,lastModified:m}})}i()})};I();R();T();var Xh=en(Ri());var ls=class{ajv;graffiti;callbacks=new Set;constructor(e,r){this.ajv=r??new Xh.default({strict:!1}),this.graffiti=e}async synchronizeDispatch(e,r){for(let n of this.callbacks)n(e,r);await Promise.resolve(),await Promise.resolve(),await Promise.resolve()}get=async(...e)=>{let r=await this.graffiti.get(...e);return this.synchronizeDispatch(r),r};put=async(...e)=>{let r=await this.graffiti.put(...e),n=e[0],i={...r,value:n.value,channels:n.channels,allowed:n.allowed,tombstone:!1};return await this.synchronizeDispatch(r,i),r};patch=async(...e)=>{let r=await this.graffiti.patch(...e),n={...r};n.tombstone=!1;for(let i of["value","channels","allowed"])Xi(Zt,i,e[0],n);return await this.synchronizeDispatch(r,n),r};delete=async(...e)=>{let r=await this.graffiti.delete(...e);return await this.synchronizeDispatch(r),r};objectStream(e){let r=this.synchronizeDispatch.bind(this);return async function*(){let i=await e.next();for(;!i.done;)i.value.error||r(i.value.value),yield i.value,i=await e.next();return i.value}()}discover=(...e)=>{let r=this.graffiti.discover(...e);return this.objectStream(r)};recoverOrphans=(...e)=>{let r=this.graffiti.recoverOrphans(...e);return this.objectStream(r)};synchronize(e,r,n,i){let s=Wr(this.ajv,n);return new kt(async(a,c)=>{let d=async(m,f)=>{for(let y of[f,m])if(y&&e(y)&&Ln(y,i)){let _={...y};if(Bn(_,r,i),s(_)){a({value:_});break}}};this.callbacks.add(d),await c,this.callbacks.delete(d)})}synchronizeDiscover=(...e)=>{let[r,n,i]=e;function s(o){return o.channels.some(a=>r.includes(a))}return this.synchronize(s,r,n,i)};synchronizeGet=(...e)=>{let[r,n,i]=e;function s(o){let a=Yt(o),{uri:c}=Hr(r);return a===c}return this.synchronize(s,[],n,i)};synchronizeRecoverOrphans=(...e)=>{let[r,n]=e;function i(s){return s.actor===n.actor&&s.channels.length===0}return this.synchronize(i,[],r,n)}};var Zh=class extends Dc{locationToUri=Yt;uriToLocation=ru;login;logout;sessionEvents;put;get;patch;delete;discover;recoverOrphans;synchronizeGet;synchronizeDiscover;synchronizeRecoverOrphans;channelStats;constructor(e){super();let r=new qi;this.login=r.login.bind(r),this.logout=r.logout.bind(r),this.sessionEvents=r.sessionEvents;let n=new ep.default({strict:!1}),i=new fs(e,n),s=new ls(i,n);this.put=s.put.bind(s),this.get=s.get.bind(s),this.patch=s.patch.bind(s),this.delete=s.delete.bind(s),this.discover=s.discover.bind(s),this.recoverOrphans=s.recoverOrphans.bind(i),this.channelStats=i.channelStats.bind(i),this.synchronizeDiscover=s.synchronizeDiscover.bind(s),this.synchronizeGet=s.synchronizeGet.bind(s),this.synchronizeRecoverOrphans=s.synchronizeRecoverOrphans.bind(s)}};export{Zh as GraffitiLocal};
18
18
  /*! Bundled license information:
19
19
 
20
20
  @jspm/core/nodelibs/browser/chunk-DtuTasat.js: