UNPKG

lendb-client

Version:

(WIP) Browser-client for connecting to [LenDB]{https://github.com/paradis-A/lendb-server}.

1 lines 117 kB
var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r,n=function(t,e){var r="000000000"+t;return r.substr(r.length-e)},i=n,o="object"==typeof window?window:self,s=Object.keys(o).length,a=i(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+s.toString(36),4),c="undefined"!=typeof window&&(window.crypto||window.msCrypto)||"undefined"!=typeof self&&self.crypto;if(c){var u=Math.pow(2,32)-1;r=function(){return Math.abs(c.getRandomValues(new Uint32Array(1))[0]/u)}}else r=Math.random;var l=function(){return a},h=n,f=r,p=0,d=Math.pow(36,4);function y(){return h((f()*d<<0).toString(36),4)}function v(){return p=p<d?p:0,++p-1}function g(){return"c"+(new Date).getTime().toString(36)+h(v().toString(36),4)+l()+(y()+y())}g.slug=function(){var t=(new Date).getTime().toString(36),e=v().toString(36).slice(-4),r=l().slice(0,1)+l().slice(-1),n=y().slice(-2);return t.slice(-2)+e+r+n},g.isCuid=function(t){return"string"==typeof t&&!!t.startsWith("c")},g.isSlug=function(t){if("string"!=typeof t)return!1;var e=t.length;return e>=7&&e<=10},g.fingerprint=l;var m=g;var b=function(){this.__data__=[],this.size=0};var _=function(t,e){return t===e||t!=t&&e!=e},w=_;var x=function(t,e){for(var r=t.length;r--;)if(w(t[r][0],e))return r;return-1},S=x,j=Array.prototype.splice;var k=x;var B=x;var A=x;var E=b,O=function(t){var e=this.__data__,r=S(e,t);return!(r<0)&&(r==e.length-1?e.pop():j.call(e,r,1),--this.size,!0)},C=function(t){var e=this.__data__,r=k(e,t);return r<0?void 0:e[r][1]},P=function(t){return B(this.__data__,t)>-1},D=function(t,e){var r=this.__data__,n=A(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};function R(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}R.prototype.clear=E,R.prototype.delete=O,R.prototype.get=C,R.prototype.has=P,R.prototype.set=D;var z=R,T=z;var H=function(){this.__data__=new T,this.size=0};var N=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r};var M=function(t){return this.__data__.get(t)};var U=function(t){return this.__data__.has(t)},I="object"==typeof t&&t&&t.Object===Object&&t,F=I,L="object"==typeof self&&self&&self.Object===Object&&self,W=F||L||Function("return this")(),q=W.Symbol,K=q,$=Object.prototype,J=$.hasOwnProperty,V=$.toString,X=K?K.toStringTag:void 0;var G=function(t){var e=J.call(t,X),r=t[X];try{t[X]=void 0;var n=!0}catch(t){}var i=V.call(t);return n&&(e?t[X]=r:delete t[X]),i},Z=Object.prototype.toString;var Q=G,Y=function(t){return Z.call(t)},tt=q?q.toStringTag:void 0;var et=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":tt&&tt in Object(t)?Q(t):Y(t)};var rt=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},nt=et,it=rt;var ot,st=function(t){if(!it(t))return!1;var e=nt(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},at=W["__core-js_shared__"],ct=(ot=/[^.]+$/.exec(at&&at.keys&&at.keys.IE_PROTO||""))?"Symbol(src)_1."+ot:"";var ut=function(t){return!!ct&&ct in t},lt=Function.prototype.toString;var ht=function(t){if(null!=t){try{return lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""},ft=st,pt=ut,dt=rt,yt=ht,vt=/^\[object .+?Constructor\]$/,gt=Function.prototype,mt=Object.prototype,bt=gt.toString,_t=mt.hasOwnProperty,wt=RegExp("^"+bt.call(_t).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var xt=function(t){return!(!dt(t)||pt(t))&&(ft(t)?wt:vt).test(yt(t))},St=function(t,e){return null==t?void 0:t[e]};var jt=function(t,e){var r=St(t,e);return xt(r)?r:void 0},kt=jt(W,"Map"),Bt=jt(Object,"create"),At=Bt;var Et=function(){this.__data__=At?At(null):{},this.size=0};var Ot=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Ct=Bt,Pt=Object.prototype.hasOwnProperty;var Dt=function(t){var e=this.__data__;if(Ct){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Pt.call(e,t)?e[t]:void 0},Rt=Bt,zt=Object.prototype.hasOwnProperty;var Tt=Bt;var Ht=Et,Nt=Ot,Mt=Dt,Ut=function(t){var e=this.__data__;return Rt?void 0!==e[t]:zt.call(e,t)},It=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Tt&&void 0===e?"__lodash_hash_undefined__":e,this};function Ft(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Ft.prototype.clear=Ht,Ft.prototype.delete=Nt,Ft.prototype.get=Mt,Ft.prototype.has=Ut,Ft.prototype.set=It;var Lt=Ft,Wt=z,qt=kt;var Kt=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var $t=function(t,e){var r=t.__data__;return Kt(e)?r["string"==typeof e?"string":"hash"]:r.map},Jt=$t;var Vt=$t;var Xt=$t;var Gt=$t;var Zt=function(){this.size=0,this.__data__={hash:new Lt,map:new(qt||Wt),string:new Lt}},Qt=function(t){var e=Jt(this,t).delete(t);return this.size-=e?1:0,e},Yt=function(t){return Vt(this,t).get(t)},te=function(t){return Xt(this,t).has(t)},ee=function(t,e){var r=Gt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function re(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}re.prototype.clear=Zt,re.prototype.delete=Qt,re.prototype.get=Yt,re.prototype.has=te,re.prototype.set=ee;var ne=re,ie=z,oe=kt,se=ne;var ae=z,ce=H,ue=N,le=M,he=U,fe=function(t,e){var r=this.__data__;if(r instanceof ie){var n=r.__data__;if(!oe||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new se(n)}return r.set(t,e),this.size=r.size,this};function pe(t){var e=this.__data__=new ae(t);this.size=e.size}pe.prototype.clear=ce,pe.prototype.delete=ue,pe.prototype.get=le,pe.prototype.has=he,pe.prototype.set=fe;var de=pe;var ye=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t},ve=jt,ge=function(){try{var t=ve(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var me=function(t,e,r){"__proto__"==e&&ge?ge(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r},be=me,_e=_,we=Object.prototype.hasOwnProperty;var xe=function(t,e,r){var n=t[e];we.call(t,e)&&_e(n,r)&&(void 0!==r||e in t)||be(t,e,r)},Se=xe,je=me;var ke=function(t,e,r,n){var i=!r;r||(r={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=n?n(r[a],t[a],a,r,t):void 0;void 0===c&&(c=t[a]),i?je(r,a,c):Se(r,a,c)}return r};var Be=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n};var Ae=function(t){return null!=t&&"object"==typeof t},Ee=et,Oe=Ae;var Ce=function(t){return Oe(t)&&"[object Arguments]"==Ee(t)},Pe=Ae,De=Object.prototype,Re=De.hasOwnProperty,ze=De.propertyIsEnumerable,Te=Ce(function(){return arguments}())?Ce:function(t){return Pe(t)&&Re.call(t,"callee")&&!ze.call(t,"callee")},He=Array.isArray,Ne={exports:{}};var Me=function(){return!1};!function(t,e){var r=W,n=Me,i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,s=o&&o.exports===i?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;t.exports=a}(Ne,Ne.exports);var Ue=/^(?:0|[1-9]\d*)$/;var Ie=function(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Ue.test(t))&&t>-1&&t%1==0&&t<e};var Fe=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},Le=et,We=Fe,qe=Ae,Ke={};Ke["[object Float32Array]"]=Ke["[object Float64Array]"]=Ke["[object Int8Array]"]=Ke["[object Int16Array]"]=Ke["[object Int32Array]"]=Ke["[object Uint8Array]"]=Ke["[object Uint8ClampedArray]"]=Ke["[object Uint16Array]"]=Ke["[object Uint32Array]"]=!0,Ke["[object Arguments]"]=Ke["[object Array]"]=Ke["[object ArrayBuffer]"]=Ke["[object Boolean]"]=Ke["[object DataView]"]=Ke["[object Date]"]=Ke["[object Error]"]=Ke["[object Function]"]=Ke["[object Map]"]=Ke["[object Number]"]=Ke["[object Object]"]=Ke["[object RegExp]"]=Ke["[object Set]"]=Ke["[object String]"]=Ke["[object WeakMap]"]=!1;var $e=function(t){return qe(t)&&We(t.length)&&!!Ke[Le(t)]};var Je=function(t){return function(e){return t(e)}},Ve={exports:{}};!function(t,e){var r=I,n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,o=i&&i.exports===n&&r.process,s=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=s}(Ve,Ve.exports);var Xe=$e,Ge=Je,Ze=Ve.exports,Qe=Ze&&Ze.isTypedArray,Ye=Qe?Ge(Qe):Xe,tr=Be,er=Te,rr=He,nr=Ne.exports,ir=Ie,or=Ye,sr=Object.prototype.hasOwnProperty;var ar=function(t,e){var r=rr(t),n=!r&&er(t),i=!r&&!n&&nr(t),o=!r&&!n&&!i&&or(t),s=r||n||i||o,a=s?tr(t.length,String):[],c=a.length;for(var u in t)!e&&!sr.call(t,u)||s&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||ir(u,c))||a.push(u);return a},cr=Object.prototype;var ur=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||cr)};var lr=function(t,e){return function(r){return t(e(r))}},hr=lr(Object.keys,Object),fr=ur,pr=hr,dr=Object.prototype.hasOwnProperty;var yr=st,vr=Fe;var gr=function(t){return null!=t&&vr(t.length)&&!yr(t)},mr=ar,br=function(t){if(!fr(t))return pr(t);var e=[];for(var r in Object(t))dr.call(t,r)&&"constructor"!=r&&e.push(r);return e},_r=gr;var wr=function(t){return _r(t)?mr(t):br(t)},xr=ke,Sr=wr;var jr=function(t,e){return t&&xr(e,Sr(e),t)};var kr=rt,Br=ur,Ar=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e},Er=Object.prototype.hasOwnProperty;var Or=ar,Cr=function(t){if(!kr(t))return Ar(t);var e=Br(t),r=[];for(var n in t)("constructor"!=n||!e&&Er.call(t,n))&&r.push(n);return r},Pr=gr;var Dr=function(t){return Pr(t)?Or(t,!0):Cr(t)},Rr=ke,zr=Dr;var Tr=function(t,e){return t&&Rr(e,zr(e),t)},Hr={exports:{}};!function(t,e){var r=W,n=e&&!e.nodeType&&e,i=n&&t&&!t.nodeType&&t,o=i&&i.exports===n?r.Buffer:void 0,s=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var r=t.length,n=s?s(r):new t.constructor(r);return t.copy(n),n}}(Hr,Hr.exports);var Nr=function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e};var Mr=function(){return[]},Ur=function(t,e){for(var r=-1,n=null==t?0:t.length,i=0,o=[];++r<n;){var s=t[r];e(s,r,t)&&(o[i++]=s)}return o},Ir=Mr,Fr=Object.prototype.propertyIsEnumerable,Lr=Object.getOwnPropertySymbols,Wr=Lr?function(t){return null==t?[]:(t=Object(t),Ur(Lr(t),(function(e){return Fr.call(t,e)})))}:Ir,qr=ke,Kr=Wr;var $r=function(t,e){return qr(t,Kr(t),e)};var Jr=function(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t},Vr=lr(Object.getPrototypeOf,Object),Xr=Jr,Gr=Vr,Zr=Wr,Qr=Mr,Yr=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Xr(e,Zr(t)),t=Gr(t);return e}:Qr,tn=ke,en=Yr;var rn=function(t,e){return tn(t,en(t),e)},nn=Jr,on=He;var sn=function(t,e,r){var n=e(t);return on(t)?n:nn(n,r(t))},an=sn,cn=Wr,un=wr;var ln=function(t){return an(t,un,cn)},hn=sn,fn=Yr,pn=Dr;var dn=function(t){return hn(t,pn,fn)},yn=jt(W,"DataView"),vn=kt,gn=jt(W,"Promise"),mn=jt(W,"Set"),bn=jt(W,"WeakMap"),_n=et,wn=ht,xn=wn(yn),Sn=wn(vn),jn=wn(gn),kn=wn(mn),Bn=wn(bn),An=_n;(yn&&"[object DataView]"!=An(new yn(new ArrayBuffer(1)))||vn&&"[object Map]"!=An(new vn)||gn&&"[object Promise]"!=An(gn.resolve())||mn&&"[object Set]"!=An(new mn)||bn&&"[object WeakMap]"!=An(new bn))&&(An=function(t){var e=_n(t),r="[object Object]"==e?t.constructor:void 0,n=r?wn(r):"";if(n)switch(n){case xn:return"[object DataView]";case Sn:return"[object Map]";case jn:return"[object Promise]";case kn:return"[object Set]";case Bn:return"[object WeakMap]"}return e});var En=An,On=Object.prototype.hasOwnProperty;var Cn=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&On.call(t,"index")&&(r.index=t.index,r.input=t.input),r},Pn=W.Uint8Array,Dn=Pn;var Rn=function(t){var e=new t.constructor(t.byteLength);return new Dn(e).set(new Dn(t)),e},zn=Rn;var Tn=function(t,e){var r=e?zn(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)},Hn=/\w*$/;var Nn=function(t){var e=new t.constructor(t.source,Hn.exec(t));return e.lastIndex=t.lastIndex,e},Mn=q?q.prototype:void 0,Un=Mn?Mn.valueOf:void 0;var In=Rn;var Fn=Rn,Ln=Tn,Wn=Nn,qn=function(t){return Un?Object(Un.call(t)):{}},Kn=function(t,e){var r=e?In(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)};var $n=function(t,e,r){var n=t.constructor;switch(e){case"[object ArrayBuffer]":return Fn(t);case"[object Boolean]":case"[object Date]":return new n(+t);case"[object DataView]":return Ln(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Kn(t,r);case"[object Map]":case"[object Set]":return new n;case"[object Number]":case"[object String]":return new n(t);case"[object RegExp]":return Wn(t);case"[object Symbol]":return qn(t)}},Jn=rt,Vn=Object.create,Xn=function(){function t(){}return function(e){if(!Jn(e))return{};if(Vn)return Vn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),Gn=Vr,Zn=ur;var Qn=function(t){return"function"!=typeof t.constructor||Zn(t)?{}:Xn(Gn(t))},Yn=En,ti=Ae;var ei=function(t){return ti(t)&&"[object Map]"==Yn(t)},ri=Je,ni=Ve.exports,ii=ni&&ni.isMap,oi=ii?ri(ii):ei,si=En,ai=Ae;var ci=function(t){return ai(t)&&"[object Set]"==si(t)},ui=Je,li=Ve.exports,hi=li&&li.isSet,fi=hi?ui(hi):ci,pi=de,di=ye,yi=xe,vi=jr,gi=Tr,mi=Hr.exports,bi=Nr,_i=$r,wi=rn,xi=ln,Si=dn,ji=En,ki=Cn,Bi=$n,Ai=Qn,Ei=He,Oi=Ne.exports,Ci=oi,Pi=rt,Di=fi,Ri=wr,zi=Dr,Ti={};Ti["[object Arguments]"]=Ti["[object Array]"]=Ti["[object ArrayBuffer]"]=Ti["[object DataView]"]=Ti["[object Boolean]"]=Ti["[object Date]"]=Ti["[object Float32Array]"]=Ti["[object Float64Array]"]=Ti["[object Int8Array]"]=Ti["[object Int16Array]"]=Ti["[object Int32Array]"]=Ti["[object Map]"]=Ti["[object Number]"]=Ti["[object Object]"]=Ti["[object RegExp]"]=Ti["[object Set]"]=Ti["[object String]"]=Ti["[object Symbol]"]=Ti["[object Uint8Array]"]=Ti["[object Uint8ClampedArray]"]=Ti["[object Uint16Array]"]=Ti["[object Uint32Array]"]=!0,Ti["[object Error]"]=Ti["[object Function]"]=Ti["[object WeakMap]"]=!1;var Hi=function t(e,r,n,i,o,s){var a,c=1&r,u=2&r,l=4&r;if(n&&(a=o?n(e,i,o,s):n(e)),void 0!==a)return a;if(!Pi(e))return e;var h=Ei(e);if(h){if(a=ki(e),!c)return bi(e,a)}else{var f=ji(e),p="[object Function]"==f||"[object GeneratorFunction]"==f;if(Oi(e))return mi(e,c);if("[object Object]"==f||"[object Arguments]"==f||p&&!o){if(a=u||p?{}:Ai(e),!c)return u?wi(e,gi(a,e)):_i(e,vi(a,e))}else{if(!Ti[f])return o?e:{};a=Bi(e,f,c)}}s||(s=new pi);var d=s.get(e);if(d)return d;s.set(e,a),Di(e)?e.forEach((function(i){a.add(t(i,r,n,i,e,s))})):Ci(e)&&e.forEach((function(i,o){a.set(o,t(i,r,n,o,e,s))}));var y=h?void 0:(l?u?Si:xi:u?zi:Ri)(e);return di(y||e,(function(i,o){y&&(i=e[o=i]),yi(a,o,t(i,r,n,o,e,s))})),a},Ni=Hi;var Mi=function(t){return Ni(t,5)},Ui=et,Ii=Ae;var Fi=function(t){return Ii(t)&&"[object Date]"==Ui(t)},Li=Je,Wi=Ve.exports,qi=Wi&&Wi.isDate,Ki=qi?Li(qi):Fi;function $i(t){let e={};if(rt(t)){let r=Object.entries(t);for(const t of r){const r=t[0],n=t[1];if(rt(n)&&!Ki(n)){let t={};t=Object.keys(n).every((t=>m.isCuid(t)))?Object.values(n).map((t=>$i(t))):n,e[r]=t}else e[r]=n}}return e}class Ji{http;key;operation;ref;loadedRawData;childProps;singular=!1;httpSettings;emitter;constructor(t,e=!1,r,n){this.operation="save",this.key=m(),"string"==typeof e&&m.isCuid(e)?this.key=e:"boolean"==typeof e&&e&&(this.singular=e,this.key=null),this.http=r,this.emitter=n,this.ref=t;const i=localStorage.getItem("lenDB");this.httpSettings=JSON.parse(i)}async destroy(){try{let t={key:this.key,ref:this.ref,operation:"destroy",singular:this.singular},e=(await this.http.post("lenDB",JSON.stringify(t))).data;return Promise.resolve(e)}catch(t){return Promise.reject(t)}}getOperation(){return this.operation}parse(){try{if(this.ref.includes("*"))return Promise.reject("Error: Adding or Updating must not contain wildcard path.");let t={};if("save"==this.operation?t=this.stripNonData(Object.assign({},this)):"destroy"==this.operation&&(t=Object.assign({},{operation:t?.operation,ref:t.ref,key:t?.key,singular:t?.singular})),!t.key&&0==t.singular)throw new Error("Error: Non-singular must contain key.");return t}catch(t){throw new Error(t)}}clear(){let t=this.toObject();Object.entries(t).forEach((t=>{delete this[t[0]]})),this.operation="save"}async commit(){try{const t=this.parse();let e=(await this.http.post("lenDB",JSON.stringify(t))).data;return"destroy"==this.operation&&(this.clear(),this.key=m()),Promise.resolve(e)}catch(t){return Promise.reject(t)}}stripNonData(t){return delete t.childProps,delete t.loadedRawData,delete t.httpSettings,delete t.emitter,t}async load(){try{let t={operation:"load",key:this.key,ref:this.ref,singular:this.singular},e=(await this.http.post("lenDB",JSON.stringify(t))).data;return console.log("load result",e),e?Promise.resolve($i(e)):Promise.resolve({key:this.key})}catch(t){return Promise.reject(t)}}assign(t){let e=Mi(t);return delete e.childProps,delete e.eventHandles,delete e.loadedRawData,delete e.singular,delete e.ref,delete e.serializer,delete e.singular,delete e.key,Object.assign(this,e),this}child(t){if(this.singular)throw new Error("Error: Singular cannot have child collection");let e=Mi(this);return e.clear(),e.ref=`${this.ref}/${this.key}/${t}`,e.operation="save",e.key=m(),e}clone(){return Mi(this)}toObject(){let t=Mi(this);return delete t.childProps,delete t.loadedRawData,delete t.singular,delete t.ref,delete t.operation,delete t.httpSettings,t}toDestroy(t=!0){return this.operation=t?"destroy":"save",this}}var Vi="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function Xi(){throw new Error("setTimeout has not been defined")}function Gi(){throw new Error("clearTimeout has not been defined")}var Zi=Xi,Qi=Gi;function Yi(t){if(Zi===setTimeout)return setTimeout(t,0);if((Zi===Xi||!Zi)&&setTimeout)return Zi=setTimeout,setTimeout(t,0);try{return Zi(t,0)}catch(e){try{return Zi.call(null,t,0)}catch(e){return Zi.call(this,t,0)}}}"function"==typeof Vi.setTimeout&&(Zi=setTimeout),"function"==typeof Vi.clearTimeout&&(Qi=clearTimeout);var to,eo=[],ro=!1,no=-1;function io(){ro&&to&&(ro=!1,to.length?eo=to.concat(eo):no=-1,eo.length&&oo())}function oo(){if(!ro){var t=Yi(io);ro=!0;for(var e=eo.length;e;){for(to=eo,eo=[];++no<e;)to&&to[no].run();no=-1,e=eo.length}to=null,ro=!1,function(t){if(Qi===clearTimeout)return clearTimeout(t);if((Qi===Gi||!Qi)&&clearTimeout)return Qi=clearTimeout,clearTimeout(t);try{Qi(t)}catch(e){try{return Qi.call(null,t)}catch(e){return Qi.call(this,t)}}}(t)}}function so(t,e){this.fun=t,this.array=e}so.prototype.run=function(){this.fun.apply(null,this.array)};function ao(){}var co=ao,uo=ao,lo=ao,ho=ao,fo=ao,po=ao,yo=ao;var vo=Vi.performance||{},go=vo.now||vo.mozNow||vo.msNow||vo.oNow||vo.webkitNow||function(){return(new Date).getTime()};var mo=new Date;var bo={nextTick:function(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];eo.push(new so(t,e)),1!==eo.length||ro||Yi(oo)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:co,addListener:uo,once:lo,off:ho,removeListener:fo,removeAllListeners:po,emit:yo,binding:function(t){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(t){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(t){var e=.001*go.call(vo),r=Math.floor(e),n=Math.floor(e%1*1e9);return t&&(r-=t[0],(n-=t[1])<0&&(r--,n+=1e9)),[r,n]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-mo)/1e3}},_o={exports:{}},wo=e(_o.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=11)}([function(t,e,r){var n=r(3),i=Object.prototype.toString;function o(t){return Array.isArray(t)}function s(t){return void 0===t}function a(t){return"[object ArrayBuffer]"===i.call(t)}function c(t){return null!==t&&"object"==typeof t}function u(t){if("[object Object]"!==i.call(t))return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function l(t){return"[object Function]"===i.call(t)}function h(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),o(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}t.exports={isArray:o,isArrayBuffer:a,isBuffer:function(t){return null!==t&&!s(t)&&null!==t.constructor&&!s(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"[object FormData]"===i.call(t)},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&a(t.buffer)},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:c,isPlainObject:u,isUndefined:s,isDate:function(t){return"[object Date]"===i.call(t)},isFile:function(t){return"[object File]"===i.call(t)},isBlob:function(t){return"[object Blob]"===i.call(t)},isFunction:l,isStream:function(t){return c(t)&&l(t.pipe)},isURLSearchParams:function(t){return"[object URLSearchParams]"===i.call(t)},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:h,merge:function t(){var e={};function r(r,n){u(e[n])&&u(r)?e[n]=t(e[n],r):u(r)?e[n]=t({},r):o(r)?e[n]=r.slice():e[n]=r}for(var n=0,i=arguments.length;n<i;n++)h(arguments[n],r);return e},extend:function(t,e,r){return h(e,(function(e,i){t[i]=r&&"function"==typeof e?n(e,r):e})),t},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},stripBOM:function(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t}}},function(t,e,r){var n=r(0),i=r(17),o=r(5),s={"Content-Type":"application/x-www-form-urlencoded"};function a(t,e){!n.isUndefined(t)&&n.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var c,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==bo&&"[object process]"===Object.prototype.toString.call(bo))&&(c=r(6)),c),transformRequest:[function(t,e){return i(e,"Accept"),i(e,"Content-Type"),n.isFormData(t)||n.isArrayBuffer(t)||n.isBuffer(t)||n.isStream(t)||n.isFile(t)||n.isBlob(t)?t:n.isArrayBufferView(t)?t.buffer:n.isURLSearchParams(t)?(a(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):n.isObject(t)||e&&"application/json"===e["Content-Type"]?(a(e,"application/json"),function(t,e,r){if(n.isString(t))try{return(e||JSON.parse)(t),n.trim(t)}catch(t){if("SyntaxError"!==t.name)throw t}return(r||JSON.stringify)(t)}(t)):t}],transformResponse:[function(t){var e=this.transitional||u.transitional,r=e&&e.silentJSONParsing,i=e&&e.forcedJSONParsing,s=!r&&"json"===this.responseType;if(s||i&&n.isString(t)&&t.length)try{return JSON.parse(t)}catch(t){if(s){if("SyntaxError"===t.name)throw o(t,this,"E_JSON_PARSE");throw t}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};n.forEach(["delete","get","head"],(function(t){u.headers[t]={}})),n.forEach(["post","put","patch"],(function(t){u.headers[t]=n.merge(s)})),t.exports=u},function(t,e,r){function n(t){this.message=t}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,t.exports=n},function(t,e,r){t.exports=function(t,e){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return t.apply(e,r)}}},function(t,e,r){var n=r(0);function i(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}t.exports=function(t,e,r){if(!e)return t;var o;if(r)o=r(e);else if(n.isURLSearchParams(e))o=e.toString();else{var s=[];n.forEach(e,(function(t,e){null!=t&&(n.isArray(t)?e+="[]":t=[t],n.forEach(t,(function(t){n.isDate(t)?t=t.toISOString():n.isObject(t)&&(t=JSON.stringify(t)),s.push(i(e)+"="+i(t))})))})),o=s.join("&")}if(o){var a=t.indexOf("#");-1!==a&&(t=t.slice(0,a)),t+=(-1===t.indexOf("?")?"?":"&")+o}return t}},function(t,e,r){t.exports=function(t,e,r,n,i){return t.config=e,r&&(t.code=r),t.request=n,t.response=i,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},t}},function(t,e,r){var n=r(0),i=r(18),o=r(19),s=r(4),a=r(20),c=r(23),u=r(24),l=r(7),h=r(1),f=r(2);t.exports=function(t){return new Promise((function(e,r){var p,d=t.data,y=t.headers,v=t.responseType;function g(){t.cancelToken&&t.cancelToken.unsubscribe(p),t.signal&&t.signal.removeEventListener("abort",p)}n.isFormData(d)&&delete y["Content-Type"];var m=new XMLHttpRequest;if(t.auth){var b=t.auth.username||"",_=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";y.Authorization="Basic "+btoa(b+":"+_)}var w=a(t.baseURL,t.url);function x(){if(m){var n="getAllResponseHeaders"in m?c(m.getAllResponseHeaders()):null,o={data:v&&"text"!==v&&"json"!==v?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:n,config:t,request:m};i((function(t){e(t),g()}),(function(t){r(t),g()}),o),m=null}}if(m.open(t.method.toUpperCase(),s(w,t.params,t.paramsSerializer),!0),m.timeout=t.timeout,"onloadend"in m?m.onloadend=x:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(x)},m.onabort=function(){m&&(r(l("Request aborted",t,"ECONNABORTED",m)),m=null)},m.onerror=function(){r(l("Network Error",t,null,m)),m=null},m.ontimeout=function(){var e=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",n=t.transitional||h.transitional;t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),r(l(e,t,n.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",m)),m=null},n.isStandardBrowserEnv()){var S=(t.withCredentials||u(w))&&t.xsrfCookieName?o.read(t.xsrfCookieName):void 0;S&&(y[t.xsrfHeaderName]=S)}"setRequestHeader"in m&&n.forEach(y,(function(t,e){void 0===d&&"content-type"===e.toLowerCase()?delete y[e]:m.setRequestHeader(e,t)})),n.isUndefined(t.withCredentials)||(m.withCredentials=!!t.withCredentials),v&&"json"!==v&&(m.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&m.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&m.upload&&m.upload.addEventListener("progress",t.onUploadProgress),(t.cancelToken||t.signal)&&(p=function(t){m&&(r(!t||t&&t.type?new f("canceled"):t),m.abort(),m=null)},t.cancelToken&&t.cancelToken.subscribe(p),t.signal&&(t.signal.aborted?p():t.signal.addEventListener("abort",p))),d||(d=null),m.send(d)}))}},function(t,e,r){var n=r(5);t.exports=function(t,e,r,i,o){var s=new Error(t);return n(s,e,r,i,o)}},function(t,e,r){t.exports=function(t){return!(!t||!t.__CANCEL__)}},function(t,e,r){var n=r(0);t.exports=function(t,e){e=e||{};var r={};function i(t,e){return n.isPlainObject(t)&&n.isPlainObject(e)?n.merge(t,e):n.isPlainObject(e)?n.merge({},e):n.isArray(e)?e.slice():e}function o(r){return n.isUndefined(e[r])?n.isUndefined(t[r])?void 0:i(void 0,t[r]):i(t[r],e[r])}function s(t){if(!n.isUndefined(e[t]))return i(void 0,e[t])}function a(r){return n.isUndefined(e[r])?n.isUndefined(t[r])?void 0:i(void 0,t[r]):i(void 0,e[r])}function c(r){return r in e?i(t[r],e[r]):r in t?i(void 0,t[r]):void 0}var u={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return n.forEach(Object.keys(t).concat(Object.keys(e)),(function(t){var e=u[t]||o,i=e(t);n.isUndefined(i)&&e!==c||(r[t]=i)})),r}},function(t,e){t.exports={version:"0.26.0"}},function(t,e,r){t.exports=r(12)},function(t,e,r){var n=r(0),i=r(3),o=r(13),s=r(9),a=function t(e){var r=new o(e),a=i(o.prototype.request,r);return n.extend(a,o.prototype,r),n.extend(a,r),a.create=function(r){return t(s(e,r))},a}(r(1));a.Axios=o,a.Cancel=r(2),a.CancelToken=r(26),a.isCancel=r(8),a.VERSION=r(10).version,a.all=function(t){return Promise.all(t)},a.spread=r(27),a.isAxiosError=r(28),t.exports=a,t.exports.default=a},function(t,e,r){var n=r(0),i=r(4),o=r(14),s=r(15),a=r(9),c=r(25),u=c.validators;function l(t){this.defaults=t,this.interceptors={request:new o,response:new o}}l.prototype.request=function(t,e){"string"==typeof t?(e=e||{}).url=t:e=t||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;void 0!==r&&c.assertOptions(r,{silentJSONParsing:u.transitional(u.boolean),forcedJSONParsing:u.transitional(u.boolean),clarifyTimeoutError:u.transitional(u.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(i=i&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var o,l=[];if(this.interceptors.response.forEach((function(t){l.push(t.fulfilled,t.rejected)})),!i){var h=[s,void 0];for(Array.prototype.unshift.apply(h,n),h=h.concat(l),o=Promise.resolve(e);h.length;)o=o.then(h.shift(),h.shift());return o}for(var f=e;n.length;){var p=n.shift(),d=n.shift();try{f=p(f)}catch(t){d(t);break}}try{o=s(f)}catch(t){return Promise.reject(t)}for(;l.length;)o=o.then(l.shift(),l.shift());return o},l.prototype.getUri=function(t){return t=a(this.defaults,t),i(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(t){l.prototype[t]=function(e,r){return this.request(a(r||{},{method:t,url:e,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(t){l.prototype[t]=function(e,r,n){return this.request(a(n||{},{method:t,url:e,data:r}))}})),t.exports=l},function(t,e,r){var n=r(0);function i(){this.handlers=[]}i.prototype.use=function(t,e,r){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},i.prototype.forEach=function(t){n.forEach(this.handlers,(function(e){null!==e&&t(e)}))},t.exports=i},function(t,e,r){var n=r(0),i=r(16),o=r(8),s=r(1),a=r(2);function c(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new a("canceled")}t.exports=function(t){return c(t),t.headers=t.headers||{},t.data=i.call(t,t.data,t.headers,t.transformRequest),t.headers=n.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||s.adapter)(t).then((function(e){return c(t),e.data=i.call(t,e.data,e.headers,t.transformResponse),e}),(function(e){return o(e)||(c(t),e&&e.response&&(e.response.data=i.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))}},function(t,e,r){var n=r(0),i=r(1);t.exports=function(t,e,r){var o=this||i;return n.forEach(r,(function(r){t=r.call(o,t,e)})),t}},function(t,e,r){var n=r(0);t.exports=function(t,e){n.forEach(t,(function(r,n){n!==e&&n.toUpperCase()===e.toUpperCase()&&(t[e]=r,delete t[n])}))}},function(t,e,r){var n=r(7);t.exports=function(t,e,r){var i=r.config.validateStatus;r.status&&i&&!i(r.status)?e(n("Request failed with status code "+r.status,r.config,null,r.request,r)):t(r)}},function(t,e,r){var n=r(0);t.exports=n.isStandardBrowserEnv()?{write:function(t,e,r,i,o,s){var a=[];a.push(t+"="+encodeURIComponent(e)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(i)&&a.push("path="+i),n.isString(o)&&a.push("domain="+o),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(t,e,r){var n=r(21),i=r(22);t.exports=function(t,e){return t&&!n(e)?i(t,e):e}},function(t,e,r){t.exports=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}},function(t,e,r){t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}},function(t,e,r){var n=r(0),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,r,o,s={};return t?(n.forEach(t.split("\n"),(function(t){if(o=t.indexOf(":"),e=n.trim(t.substr(0,o)).toLowerCase(),r=n.trim(t.substr(o+1)),e){if(s[e]&&i.indexOf(e)>=0)return;s[e]="set-cookie"===e?(s[e]?s[e]:[]).concat([r]):s[e]?s[e]+", "+r:r}})),s):s}},function(t,e,r){var n=r(0);t.exports=n.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(t){var n=t;return e&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=i(window.location.href),function(e){var r=n.isString(e)?i(e):e;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}},function(t,e,r){var n=r(10).version,i={};["object","boolean","number","function","string","symbol"].forEach((function(t,e){i[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}}));var o={};i.transitional=function(t,e,r){function i(t,e){return"[Axios v"+n+"] Transitional option '"+t+"'"+e+(r?". "+r:"")}return function(r,n,s){if(!1===t)throw new Error(i(n," has been removed"+(e?" in "+e:"")));return e&&!o[n]&&(o[n]=!0,console.warn(i(n," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(r,n,s)}},t.exports={assertOptions:function(t,e,r){if("object"!=typeof t)throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var o=n[i],s=e[o];if(s){var a=t[o],c=void 0===a||s(a,o,t);if(!0!==c)throw new TypeError("option "+o+" must be "+c)}else if(!0!==r)throw Error("Unknown option "+o)}},validators:i}},function(t,e,r){var n=r(2);function i(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var r=this;this.promise.then((function(t){if(r._listeners){var e,n=r._listeners.length;for(e=0;e<n;e++)r._listeners[e](t);r._listeners=null}})),this.promise.then=function(t){var e,n=new Promise((function(t){r.subscribe(t),e=t})).then(t);return n.cancel=function(){r.unsubscribe(e)},n},t((function(t){r.reason||(r.reason=new n(t),e(r.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(t){this.reason?t(this.reason):this._listeners?this._listeners.push(t):this._listeners=[t]},i.prototype.unsubscribe=function(t){if(this._listeners){var e=this._listeners.indexOf(t);-1!==e&&this._listeners.splice(e,1)}},i.source=function(){var t;return{token:new i((function(e){t=e})),cancel:t}},t.exports=i},function(t,e,r){t.exports=function(t){return function(e){return t.apply(null,e)}}},function(t,e,r){var n=r(0);t.exports=function(t){return n.isObject(t)&&!0===t.isAxiosError}}]));function xo(){}function So(t,e){var r,n=0,i=1,o={},s=(e=e||{}).maxAttempts||1/0;return o.open=function(){(r=new WebSocket(t,e.protocols||[])).onmessage=e.onmessage||xo,r.onopen=function(t){(e.onopen||xo)(t),n=0},r.onclose=function(t){1e3===t.code||1001===t.code||1005===t.code||o.reconnect(t),(e.onclose||xo)(t)},r.onerror=function(t){t&&"ECONNREFUSED"===t.code?o.reconnect(t):(e.onerror||xo)(t)}},o.reconnect=function(t){i&&n++<s?i=setTimeout((function(){(e.onreconnect||xo)(t),o.open()}),e.timeout||1e3):(e.onmaximum||xo)(t)},o.json=function(t){r.send(JSON.stringify(t))},o.send=function(t){r.send(t)},o.close=function(t,e){i=clearTimeout(i),r.close(t||1e3,e)},o.open(),o}function jo(){}Promise.resolve();const ko=[];function Bo(t,e=jo){let r;const n=new Set;function i(e){if(o=e,((i=t)!=i?o==o:i!==o||i&&"object"==typeof i||"function"==typeof i)&&(t=e,r)){const e=!ko.length;for(const e of n)e[1](),ko.push(e,t);if(e){for(let t=0;t<ko.length;t+=2)ko[t][0](ko[t+1]);ko.length=0}}var i,o}return{set:i,update:function(e){i(e(t))},subscribe:function(o,s=jo){const a=[o,s];return n.add(a),1===n.size&&(r=e(i)||jo),o(t),()=>{n.delete(a),0===n.size&&(r(),r=null)}}}}class Ao extends Error{constructor(t){super(t),this.name="TimeoutError"}}async function Eo(t,e={}){const{interval:r=20,timeout:n=Number.POSITIVE_INFINITY,before:i=!0}=e;let o;const s=new Promise(((e,n)=>{const s=async()=>{try{const n=await t();if("boolean"!=typeof n)throw new TypeError("Expected condition to return a boolean");!0===n?e():o=setTimeout(s,r)}catch(t){n(t)}};i?s():o=setTimeout(s,r)}));if(n!==Number.POSITIVE_INFINITY)try{return await function(t,e,r,n){let i;const o=new Promise(((o,s)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);e!==Number.POSITIVE_INFINITY?(n={customTimers:{setTimeout:setTimeout,clearTimeout:clearTimeout},...n},i=n.customTimers.setTimeout.call(void 0,(()=>{if("function"==typeof r){try{o(r())}catch(t){s(t)}return}const n=r instanceof Error?r:new Ao("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),s(n)}),e),(async()=>{try{o(await t)}catch(t){s(t)}finally{n.customTimers.clearTimeout.call(void 0,i)}})()):o(t)}));return o.clear=()=>{clearTimeout(i),i=void 0},o}(s,n)}catch(t){throw o&&clearTimeout(o),t}return s}class Oo{ref;listener;filters={};sorts={};skip=0;limit=100;page=0;executing=!1;listening=!1;authenticating=!1;#t;#e;#r=[];#n=0;#i=!1;timeout=6e4;#o;aggregates;queueBeforeResult=[];operation;exclusion=[];inclusion=[];emitter;hook;controller;signal;ws;compoundFilter={};#s;#a;wsUrl;constructor(t,e,r,n,i){this.ref=t,this.#a=e,this.wsUrl=r,this.emitter=n,this.operation="query",this.#t=Bo([]),this.#e=Bo(0),this.#r=[],this.#n=0,this.emitter.on("login",(()=>{this.listening&&(this.cancel(),this.execute())})),this.emitter.on("logout",(()=>{this.#s=null,(this.listening||this.executing)&&(this.cancel(),this.unsubscribe())}))}get data(){return this.#t}get count(){return this.#e}like(t,e,r){let n="*"+e+"*";return"left"==r&&(n="*"+e),"right"==r&&(n=e+"*"),this.filters[t+"[like]"]=n,this}notLike(t,e,r){let n="*"+e+"*";return"left"==r&&(n="*"+e),"right"==r&&(n=e+"*"),this.filters[t+"[!like]"]=n,this}gt(t,e){return this.filters[t+"[>]"]=e,this}gte(t,e){return this.filters[t+"[>=]"]=e,this}between(t,e){return this.filters[t+"[between]"]=e,this}notBetween(t,e){return this.filters[t+"[!between]"]=e,this}lt(t,e){return this.filters[t+"[<]"]=e,this}lte(t,e){return this.filters[t+"[<=]"]=e,this}eq(t,e){return this.filters[t+"[==]"]=e,this}notEq(t,e){return this.filters[t+"[!=]"]=e,this}in(t,e){return this.filters[t+"[in]"]=e,this}notIn(t,e){return this.filters[t+"[!in]"]=e,this}matches(t,e){return this.filters[t+"[matches]"]=e,this}notMatches(t,e){return this.filters[t+"[!matches]"]=e,this}has(t,e){return this.filters[t+"[has]"]=e,this}notHas(t,e){return this.filters[t]["!has"]=e,this}contains(t,e){return this.filters[t].contains=e,this}notContains(t,e){return this.filters[t]["!contains"]=e,this}sort(t,e=!1){return this.sorts[t]=e?"ASC":"DESC",this}exclude(t){return this.exclusion=t,this}include(t){return this.inclusion=t,this}aggregate(t,e){return this.aggregates=new Co(t),e(this.aggregates),this}compound(t){let e=new Ro;t(e),this.compoundFilter=e.filters}stripNonQuery(t){return delete t.emitter,delete t.wsUrl,delete t.emitter,delete t.queueBeforeResult,delete t.ws,delete t.signal,delete t.listening,delete t.listener,delete t.emitter,t}on(t){let e=new Po;t(e),this.listener=e}clearFilters(){this.filters={}}clearSorts(){this.sorts={}}toWildCardPath(t){return t.split("/").map((t=>m.isCuid(t)?"*":t)).join("/")}createWS(t){try{let e={subscriptionKey:this.#o,query:t},r=wo.CancelToken.source();this.ws=new So(this.wsUrl+"/lenDB",{timeout:5e3,maxAttempts:1/0,onopen:()=>{if(!this.authenticating){this.authenticating=!0;Object.assign(wo,this.#a).post("lenDB_Auth",JSON.stringify({type:"authenticate_ws"}),{timeout:1/0,cancelToken:r.token}).then((t=>{const r=t.data;this.authenticating=!1,this.#s&&1==r?.public&&(this.#s=null),r.key&&(this.#s=r.key),r.public&&(e.public=r.public),e.key=this.#s,this.ws.send(JSON.stringify(e))})).catch((t=>{console.log("Cannot authenticate websocket connection. Retrying.")})),delete e.reconnect}},onerror:t=>{this.authenticating?r.cancel():e.reconnect=!0},onreconnect:()=>{console.log("Disconnected to the server. Reconnecting.")},onclose:()=>{this.listening=!1},onmessage:t=>{let e=t.data;if("string"==typeof t.data&&(e=JSON.parse(t.data)),"add"==e.type){this.listener&&this.listener.getEvent("add")&&this.listener.getEvent("add")(e?.newData);let t=e?.data;t&&Array.isArray(t)&&(t=t.map((t=>$i(t)))),this.#r=t,this.#n=e?.count||e.count,this.#e.set(this.#n),this.#t.set(this.#r)}if("update"==e.type){this.listener&&this.listener.getEvent("update")&&this.listener.getEvent("update")(e?.newData);let t=e?.data;t&&Array.isArray(t)&&(t=t.map((t=>$i(t)))),this.#r=t,this.#n=e?.count||e.count,this.#e.set(this.#n),this.#t.set(this.#r)}if("initialdata"==e.type){let t=e?.data;t&&Array.isArray(t)&&(t=t.map((t=>$i(t)))),this.#r=t,this.#n=e?.count||e.count,this.#e.set(this.#n),this.#t.set(this.#r),this.#i=!0}if("destroy"==e.type){this.listener&&this.listener.getEvent("destroy")&&this.listener.getEvent("destroy")(e?.newData);let t=e?.data;t&&Array.isArray(t)&&(t=t.map((t=>$i(t)))),this.#r=t,this.#n=e?.count||e.count,this.#e.set(this.#n),this.#t.set(this.#r)}}}),this.listening=!0}catch(t){console.log(t)}}unsubscribe(){this.ws&&(this.#o=null,this.listening=!1,this.ws.close(1e3,"unsubscribe"))}async execute(t={live:!0}){try{if(this.ref.includes("__users__")||this.ref.includes("__tokens__"))return Promise.reject("Error: cannot access secured refferences use instance.User() instead.");void 0===t.live&&(t.live=!0),this.executing&&this.cancel();const{page:e,limit:r,timeout:n}=t;e&&"number"==typeof e&&(this.page=e),r&&"number"==typeof r&&(this.limit=r),n&&"number"==typeof n&&(this.timeout=n);let i=this.stripNonQuery(Mi(this));if(i.filters&&rt(i.filters)&&Object.entries(i.filters).length?i.filters=this.transformFilters(i.filters):i.filters=[],i.compoundFilter&&rt(i.compoundFilter)&&Object.entries(i.compoundFilter).length?i.compoundFilter=this.transformFilters(i.compoundFilter):i.compoundFilter=[],i.aggregates&&i?.aggregates.list.length){const{groupBy:t,list:e}=i.aggregates;i.aggregates={groupBy:t,list:e}}if(i.sorts&&rt(i.sorts)&&Object.entries(i.sorts).length){let t=[];for(const e of Object.entries(i.sorts)){let r=e[0],n=e[1];"ASC"==n?t.push([r,!0]):"DESC"==n&&t.push([r,!1])}i.sorts=t}this.unsubscribe(),this.listening=!1,this.executing=!0;let o={data:[],count:0},s=[];if(i.aggregates&&Object.entries(i.aggregates).length&&i.compoundFilter.length)throw Error("Error: Cannot aggregate with compundfilter");return t.live?(i.live=!0,this.createWS(i),await Eo((()=>this.#i),n),this.executing=!1,this.listening=!0,this.#i=!1,Promise.resolve({count:this.#n,data:this.#r})):(this.ws=null,this.controller=new AbortController,this.signal=this.controller.signal,this.signal.onabort=()=>{Promise.reject("Query Cancelled")},o=(await this.#a.post("lenDB",JSON.stringify(i),{signal:this.signal})).data,s=o.data,s&&Array.isArray(s)&&(s=s.map((t=>$i(t)))),this.#r=s,this.#n=o.count,this.#t.set(s),this.#e.set(o?.count),o.data=this.#r,this.executing=!1,Promise.resolve(o))}catch(t){return this.executing=!1,this.listening=!1,this.ws&&this.ws.close(),this.ws=null,Promise.reject(t)}}cancel(){return this.controller&&(this.controller.abort(),this.executing=!1),this}transformFilters(t){try{let e=[];for(const r of Object.entries(t.filters)){let t=r[0],n=r[1];if(t.includes("[")||t.includes("]")){let r=t.indexOf("["),i=t.indexOf("]");if(-1==r||-1==i)throw new Error("Filter must be enclosed with []");let o=t.substring(r+1,i),s=t.substring(0,r);if(!Do.includes(o))throw new Error("Invalid filter");{if("in"==o&&!Array.isArray(n))throw new Error("Invalid filter");if("between"==o&&!Array.isArray(n))throw new Error("Invalid filter");const t={eq:"==",neq:"!=",gt:">",gte:">=",lt:"<",lte:"<="};if(o.startsWith("not")){let r=Object.keys(t).includes(o.substring(2).toLowerCase())?t[o.substring(2).toLowerCase()]:o.substring(2).toLowerCase();e.push([s,r,n])}else e.push([s,o,n])}}else Array.isArray(n)?e.push([t,"in",n]):e.push([t,"==",n])}return e}catch(t){throw Error(t)}}}class Co{list=[];groupBy;constructor(t){this.groupBy=t}sum(t,e){return this.list.push({field:t,operation:"SUM",alias:e}),this}count(t,e){return this.list.push({field:t,operation:"COUNT",alias:e}),this}min(t,e){return this.list.push({field:t,operation:"MIN",alias:e}),this}max(t,e){return this.list.push({field:t,operation:"MAX",alias:e}),this}avg(t,e){return this.list.push({field:t,operation:"AVG",alias:e}),this}}class Po{callbacks=[];add=null;update=null;destroy=null;initial=null;onAdd(t){this.add=t}onInitial(t){this.initial=t}onUpdate(t){this.update=t}onDestroy(t){this.destroy=t}getEvent(t){return"add"==t?this.add:"update"==t?this.update:"destroy"==t?this.destroy:"initial"==t?this.initial:void 0}}const Do=["eq","gt","gte","lt","lte","like","in","neq","has","notHas","contains","notContains","notLike","between","notIn","notBetween","matches","notEq","notMatches","!eq","!has","!contains","!like","!between","!in","!matches","==","!=",">=","<=",">","<"];class Ro{filters={};like(t,e,r){let n="*"+e+"*";return"left"==r&&(n="*"+e),"right"==r&&(n=e+"*"),this.filters[t+"[like]"]=n,this}notLike(t,e,r){let n="*"+e+"*";return"left"==r&&(n="*"+e),"right"==r&&(n=e+"*"),this.filters[t+"[!like]"]=n,this}gt(t,e){return this.filters[t+"[>]"]=e,this}gte(t,e){return this.filters[t+"[>=]"]=e,this}between(t,e){return this.filters[t+"[between]"]=e,this}notBetween(t,e){return this.filters[t+"[!between]"]=e,this}lt(t,e){return this.filters[t+"[<]"]=e,this}lte(t,e){return this.filters[t+"[<=]"]=e,this}eq(t,e){return this.filters[t+"[==]"]=e,this}notEq(t,e){return this.filters[t+"[!=]"]=e,this}in(t,e){return this.filters[t+"[in]"]=e,this}notIn(t,e){return this.filters[t+"[!in]"]=e,this}matches(t,e){return this.filters[t+"[matches]"]=e,this}notMatches(t,e){return this.filters[t+"[!matches]"]=e,this}has(t,e){return this.filters[t+"[has]"]=e,this}notHas(t,e){return this.filters[t]["!has"]=e,this}contains(t,e){return this.filters[t].contains=e,this}notContains(t,e){return this.filters[t]["!contains"]=e,this}}var zo=ne,To=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Ho=function(t){return this.__data__.has(t)};function No(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new zo;++e<r;)this.add(t[e])}No.prototype.add=No.prototype.push=To,No.prototype.has=Ho;var Mo=No,Uo=function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1},Io=function(t,e){return t.has(e)};var Fo=function(t,e,r,n,i,o){var s=1&r,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t),l=o.get(e);if(u&&l)return u==e&&l==t;var h=-1,f=!0,p=2&r?new Mo:void 0;for(o.set(t,e),o.set(e,t);++h<a;){var d=t[h],y=e[h];if(n)var v=s?n(y,d,h,e,t,o):n(d,y,h,t,e,o);if(void 0!==v){if(v)continue;f=!1;break}if(p){if(!Uo(e,(function(t,e){if(!Io(p,e)&&(d===t||i(d,t,r,n,o)))return p.push(e)}))){f=!1;break}}else if(d!==y&&!i(d,y,r,n,o)){f=!1;break}}return o.delete(t),o.delete(e),f};var Lo=Pn,Wo=_,qo=Fo,Ko=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r},$o=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r},Jo=q?q.prototype:void 0,Vo=Jo?Jo.valueOf:void 0;var Xo=function(t,e,r,n,i,o,s){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Lo(t),new Lo(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Wo(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ko;case"[object Set]":var c=1&n;if(a||(a=$o),t.size!=e.size&&!c)return