🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

client-web-storage

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

client-web-storage - npm Package Compare versions

Comparing version

to
1.2.1

2

dist/client-web-storage.min.js

@@ -1,2 +0,2 @@

(()=>{var gt=Object.create;var Ye=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var St=Object.getOwnPropertyNames;var _t=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var i=(g,u)=>Ye(g,"name",{value:u,configurable:!0}),Se=(g=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(g,{get:(u,c)=>(typeof require!="undefined"?require:u)[c]}):g)(function(g){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+g+'" is not supported')});var It=(g,u)=>()=>(u||g((u={exports:{}}).exports,u),u.exports);var Et=(g,u,c,y)=>{if(u&&typeof u=="object"||typeof u=="function")for(let v of St(u))!wt.call(g,v)&&v!==c&&Ye(g,v,{get:()=>u[v],enumerable:!(y=bt(u,v))||y.enumerable});return g};var At=(g,u,c)=>(c=g!=null?gt(_t(g)):{},Et(u||!g||!g.__esModule?Ye(c,"default",{value:g,enumerable:!0}):c,g));var ze=(g,u,c)=>{if(!u.has(g))throw TypeError("Cannot "+c)};var S=(g,u,c)=>(ze(g,u,"read from private field"),c?c.call(g):u.get(g)),z=(g,u,c)=>{if(u.has(g))throw TypeError("Cannot add the same private member more than once");u instanceof WeakSet?u.add(g):u.set(g,c)},K=(g,u,c,y)=>(ze(g,u,"write to private field"),y?y.call(g,c):u.set(g,c),c);var _e=(g,u,c)=>(ze(g,u,"access private method"),c);var mr=It((yr,We)=>{(function(g){if(typeof yr=="object"&&typeof We<"u")We.exports=g();else if(typeof define=="function"&&define.amd)define([],g);else{var u;typeof window<"u"?u=window:typeof global<"u"?u=global:typeof self<"u"?u=self:u=this,u.localforage=g()}})(function(){var g,u,c;return i(function y(v,R,C){function x(M,G){if(!R[M]){if(!v[M]){var p=typeof Se=="function"&&Se;if(!G&&p)return p(M,!0);if(D)return D(M,!0);var _=new Error("Cannot find module '"+M+"'");throw _.code="MODULE_NOT_FOUND",_}var F=R[M]={exports:{}};v[M][0].call(F.exports,function(L){var Q=v[M][1][L];return x(Q||L)},F,F.exports,y,v,R,C)}return R[M].exports}i(x,"s");for(var D=typeof Se=="function"&&Se,Y=0;Y<C.length;Y++)x(C[Y]);return x},"e")({1:[function(y,v,R){(function(C){"use strict";var x=C.MutationObserver||C.WebKitMutationObserver,D;if(x){var Y=0,M=new x(L),G=C.document.createTextNode("");M.observe(G,{characterData:!0}),D=i(function(){G.data=Y=++Y%2},"scheduleDrain")}else if(!C.setImmediate&&typeof C.MessageChannel<"u"){var p=new C.MessageChannel;p.port1.onmessage=L,D=i(function(){p.port2.postMessage(0)},"scheduleDrain")}else"document"in C&&"onreadystatechange"in C.document.createElement("script")?D=i(function(){var U=C.document.createElement("script");U.onreadystatechange=function(){L(),U.onreadystatechange=null,U.parentNode.removeChild(U),U=null},C.document.documentElement.appendChild(U)},"scheduleDrain"):D=i(function(){setTimeout(L,0)},"scheduleDrain");var _,F=[];function L(){_=!0;for(var U,ee,$=F.length;$;){for(ee=F,F=[],U=-1;++U<$;)ee[U]();$=F.length}_=!1}i(L,"nextTick"),v.exports=Q;function Q(U){F.push(U)===1&&!_&&D()}i(Q,"immediate")}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(y,v,R){"use strict";var C=y(1);function x(){}i(x,"INTERNAL");var D={},Y=["REJECTED"],M=["FULFILLED"],G=["PENDING"];v.exports=p;function p(m){if(typeof m!="function")throw new TypeError("resolver must be a function");this.state=G,this.queue=[],this.outcome=void 0,m!==x&&Q(this,m)}i(p,"Promise"),p.prototype.catch=function(m){return this.then(null,m)},p.prototype.then=function(m,E){if(typeof m!="function"&&this.state===M||typeof E!="function"&&this.state===Y)return this;var I=new this.constructor(x);if(this.state!==G){var N=this.state===M?m:E;F(I,N,this.outcome)}else this.queue.push(new _(I,m,E));return I};function _(m,E,I){this.promise=m,typeof E=="function"&&(this.onFulfilled=E,this.callFulfilled=this.otherCallFulfilled),typeof I=="function"&&(this.onRejected=I,this.callRejected=this.otherCallRejected)}i(_,"QueueItem"),_.prototype.callFulfilled=function(m){D.resolve(this.promise,m)},_.prototype.otherCallFulfilled=function(m){F(this.promise,this.onFulfilled,m)},_.prototype.callRejected=function(m){D.reject(this.promise,m)},_.prototype.otherCallRejected=function(m){F(this.promise,this.onRejected,m)};function F(m,E,I){C(function(){var N;try{N=E(I)}catch(k){return D.reject(m,k)}N===m?D.reject(m,new TypeError("Cannot resolve promise with itself")):D.resolve(m,N)})}i(F,"unwrap"),D.resolve=function(m,E){var I=U(L,E);if(I.status==="error")return D.reject(m,I.value);var N=I.value;if(N)Q(m,N);else{m.state=M,m.outcome=E;for(var k=-1,W=m.queue.length;++k<W;)m.queue[k].callFulfilled(E)}return m},D.reject=function(m,E){m.state=Y,m.outcome=E;for(var I=-1,N=m.queue.length;++I<N;)m.queue[I].callRejected(E);return m};function L(m){var E=m&&m.then;if(m&&(typeof m=="object"||typeof m=="function")&&typeof E=="function")return i(function(){E.apply(m,arguments)},"appyThen")}i(L,"getThen");function Q(m,E){var I=!1;function N(j){I||(I=!0,D.reject(m,j))}i(N,"onError");function k(j){I||(I=!0,D.resolve(m,j))}i(k,"onSuccess");function W(){E(k,N)}i(W,"tryToUnwrap");var J=U(W);J.status==="error"&&N(J.value)}i(Q,"safelyResolveThenable");function U(m,E){var I={};try{I.value=m(E),I.status="success"}catch(N){I.status="error",I.value=N}return I}i(U,"tryCatch"),p.resolve=ee;function ee(m){return m instanceof this?m:D.resolve(new this(x),m)}i(ee,"resolve"),p.reject=$;function $(m){var E=new this(x);return D.reject(E,m)}i($,"reject"),p.all=xe;function xe(m){var E=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var I=m.length,N=!1;if(!I)return this.resolve([]);for(var k=new Array(I),W=0,J=-1,j=new this(x);++J<I;)re(m[J],J);return j;function re(pe,Ne){E.resolve(pe).then(Oe,function(ve){N||(N=!0,D.reject(j,ve))});function Oe(ve){k[Ne]=ve,++W===I&&!N&&(N=!0,D.resolve(j,k))}i(Oe,"resolveFromAll")}}i(xe,"all"),p.race=ce;function ce(m){var E=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var I=m.length,N=!1;if(!I)return this.resolve([]);for(var k=-1,W=new this(x);++k<I;)J(m[k]);return W;function J(j){E.resolve(j).then(function(re){N||(N=!0,D.resolve(W,re))},function(re){N||(N=!0,D.reject(W,re))})}}i(ce,"race")},{"1":1}],3:[function(y,v,R){(function(C){"use strict";typeof C.Promise!="function"&&(C.Promise=y(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{"2":2}],4:[function(y,v,R){"use strict";var C=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}i(x,"_classCallCheck");function D(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}i(D,"getIDB");var Y=D();function M(){try{if(!Y||!Y.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}i(M,"isIndexedDBValid");function G(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,a=new r,o=0;o<e.length;o+=1)a.append(e[o]);return a.getBlob(t.type)}}i(G,"createBlob"),typeof Promise>"u"&&y(3);var p=Promise;function _(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}i(_,"executeCallback");function F(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}i(F,"executeTwoCallbacks");function L(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}i(L,"normalizeKey");function Q(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}i(Q,"getCallback");var U="local-forage-detect-blob-support",ee=void 0,$={},xe=Object.prototype.toString,ce="readonly",m="readwrite";function E(e){for(var t=e.length,r=new ArrayBuffer(t),a=new Uint8Array(r),o=0;o<t;o++)a[o]=e.charCodeAt(o);return r}i(E,"_binStringToArrayBuffer");function I(e){return new p(function(t){var r=e.transaction(U,m),a=G([""]);r.objectStore(U).put(a,"key"),r.onabort=function(o){o.preventDefault(),o.stopPropagation(),t(!1)},r.oncomplete=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!o||parseInt(o[1],10)>=43)}}).catch(function(){return!1})}i(I,"_checkBlobSupportWithoutCaching");function N(e){return typeof ee=="boolean"?p.resolve(ee):I(e).then(function(t){return ee=t,ee})}i(N,"_checkBlobSupport");function k(e){var t=$[e.name],r={};r.promise=new p(function(a,o){r.resolve=a,r.reject=o}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}i(k,"_deferReadiness");function W(e){var t=$[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}i(W,"_advanceReadiness");function J(e,t){var r=$[e.name],a=r.deferredOperations.pop();if(a)return a.reject(t),a.promise}i(J,"_rejectReadiness");function j(e,t){return new p(function(r,a){if($[e.name]=$[e.name]||je(),e.db)if(t)k(e),e.db.close();else return r(e.db);var o=[e.name];t&&o.push(e.version);var n=Y.open.apply(Y,o);t&&(n.onupgradeneeded=function(s){var f=n.result;try{f.createObjectStore(e.storeName),s.oldVersion<=1&&f.createObjectStore(U)}catch(l){if(l.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+s.oldVersion+" to version "+s.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw l}}),n.onerror=function(s){s.preventDefault(),a(n.error)},n.onsuccess=function(){var s=n.result;s.onversionchange=function(f){f.target.close()},r(s),W(e)}})}i(j,"_getConnection");function re(e){return j(e,!1)}i(re,"_getOriginalConnection");function pe(e){return j(e,!0)}i(pe,"_getUpgradedConnection");function Ne(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),a=e.version<e.db.version,o=e.version>e.db.version;if(a&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}i(Ne,"_isUpgradeNeeded");function Oe(e){return new p(function(t,r){var a=new FileReader;a.onerror=r,a.onloadend=function(o){var n=btoa(o.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},a.readAsBinaryString(e)})}i(Oe,"_encodeBlob");function ve(e){var t=E(atob(e.data));return G([t],{type:e.type})}i(ve,"_decodeBlob");function Je(e){return e&&e.__local_forage_encoded_blob}i(Je,"_isEncodedBlob");function br(e){var t=this,r=t._initReady().then(function(){var a=$[t._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return F(r,e,e),r}i(br,"_fullyReady");function Sr(e){k(e);for(var t=$[e.name],r=t.forages,a=0;a<r.length;a++){var o=r[a];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,re(e).then(function(n){return e.db=n,Ne(e)?pe(e):n}).then(function(n){e.db=t.db=n;for(var s=0;s<r.length;s++)r[s]._dbInfo.db=n}).catch(function(n){throw J(e,n),n})}i(Sr,"_tryReconnect");function te(e,t,r,a){a===void 0&&(a=1);try{var o=e.db.transaction(e.storeName,t);r(null,o)}catch(n){if(a>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return p.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),pe(e)}).then(function(){return Sr(e).then(function(){te(e,t,r,a-1)})}).catch(r);r(n)}}i(te,"createTransaction");function je(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}i(je,"createDbContext");function _r(e){var t=this,r={db:null};if(e)for(var a in e)r[a]=e[a];var o=$[r.name];o||(o=je(),$[r.name]=o),o.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=br);var n=[];function s(){return p.resolve()}i(s,"ignoreErrors");for(var f=0;f<o.forages.length;f++){var l=o.forages[f];l!==t&&n.push(l._initReady().catch(s))}var d=o.forages.slice(0);return p.all(n).then(function(){return r.db=o.db,re(r)}).then(function(h){return r.db=h,Ne(r,t._defaultConfig.version)?pe(r):h}).then(function(h){r.db=o.db=h,t._dbInfo=r;for(var b=0;b<d.length;b++){var w=d[b];w!==t&&(w._dbInfo.db=r.db,w._dbInfo.version=r.version)}})}i(_r,"_initStorage");function wr(e,t){var r=this;e=L(e);var a=new p(function(o,n){r.ready().then(function(){te(r._dbInfo,ce,function(s,f){if(s)return n(s);try{var l=f.objectStore(r._dbInfo.storeName),d=l.get(e);d.onsuccess=function(){var h=d.result;h===void 0&&(h=null),Je(h)&&(h=ve(h)),o(h)},d.onerror=function(){n(d.error)}}catch(h){n(h)}})}).catch(n)});return _(a,t),a}i(wr,"getItem");function Ir(e,t){var r=this,a=new p(function(o,n){r.ready().then(function(){te(r._dbInfo,ce,function(s,f){if(s)return n(s);try{var l=f.objectStore(r._dbInfo.storeName),d=l.openCursor(),h=1;d.onsuccess=function(){var b=d.result;if(b){var w=b.value;Je(w)&&(w=ve(w));var A=e(w,b.key,h++);A!==void 0?o(A):b.continue()}else o()},d.onerror=function(){n(d.error)}}catch(b){n(b)}})}).catch(n)});return _(a,t),a}i(Ir,"iterate");function Er(e,t,r){var a=this;e=L(e);var o=new p(function(n,s){var f;a.ready().then(function(){return f=a._dbInfo,xe.call(t)==="[object Blob]"?N(f.db).then(function(l){return l?t:Oe(t)}):t}).then(function(l){te(a._dbInfo,m,function(d,h){if(d)return s(d);try{var b=h.objectStore(a._dbInfo.storeName);l===null&&(l=void 0);var w=b.put(l,e);h.oncomplete=function(){l===void 0&&(l=null),n(l)},h.onabort=h.onerror=function(){var A=w.error?w.error:w.transaction.error;s(A)}}catch(A){s(A)}})}).catch(s)});return _(o,r),o}i(Er,"setItem");function Ar(e,t){var r=this;e=L(e);var a=new p(function(o,n){r.ready().then(function(){te(r._dbInfo,m,function(s,f){if(s)return n(s);try{var l=f.objectStore(r._dbInfo.storeName),d=l.delete(e);f.oncomplete=function(){o()},f.onerror=function(){n(d.error)},f.onabort=function(){var h=d.error?d.error:d.transaction.error;n(h)}}catch(h){n(h)}})}).catch(n)});return _(a,t),a}i(Ar,"removeItem");function Tr(e){var t=this,r=new p(function(a,o){t.ready().then(function(){te(t._dbInfo,m,function(n,s){if(n)return o(n);try{var f=s.objectStore(t._dbInfo.storeName),l=f.clear();s.oncomplete=function(){a()},s.onabort=s.onerror=function(){var d=l.error?l.error:l.transaction.error;o(d)}}catch(d){o(d)}})}).catch(o)});return _(r,e),r}i(Tr,"clear");function Dr(e){var t=this,r=new p(function(a,o){t.ready().then(function(){te(t._dbInfo,ce,function(n,s){if(n)return o(n);try{var f=s.objectStore(t._dbInfo.storeName),l=f.count();l.onsuccess=function(){a(l.result)},l.onerror=function(){o(l.error)}}catch(d){o(d)}})}).catch(o)});return _(r,e),r}i(Dr,"length");function Nr(e,t){var r=this,a=new p(function(o,n){if(e<0){o(null);return}r.ready().then(function(){te(r._dbInfo,ce,function(s,f){if(s)return n(s);try{var l=f.objectStore(r._dbInfo.storeName),d=!1,h=l.openKeyCursor();h.onsuccess=function(){var b=h.result;if(!b){o(null);return}e===0||d?o(b.key):(d=!0,b.advance(e))},h.onerror=function(){n(h.error)}}catch(b){n(b)}})}).catch(n)});return _(a,t),a}i(Nr,"key");function Cr(e){var t=this,r=new p(function(a,o){t.ready().then(function(){te(t._dbInfo,ce,function(n,s){if(n)return o(n);try{var f=s.objectStore(t._dbInfo.storeName),l=f.openKeyCursor(),d=[];l.onsuccess=function(){var h=l.result;if(!h){a(d);return}d.push(h.key),h.continue()},l.onerror=function(){o(l.error)}}catch(h){o(h)}})}).catch(o)});return _(r,e),r}i(Cr,"keys");function Rr(e,t){t=Q.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var a=this,o;if(!e.name)o=p.reject("Invalid arguments");else{var n=e.name===r.name&&a._dbInfo.db,s=n?p.resolve(a._dbInfo.db):re(e).then(function(f){var l=$[e.name],d=l.forages;l.db=f;for(var h=0;h<d.length;h++)d[h]._dbInfo.db=f;return f});e.storeName?o=s.then(function(f){if(!!f.objectStoreNames.contains(e.storeName)){var l=f.version+1;k(e);var d=$[e.name],h=d.forages;f.close();for(var b=0;b<h.length;b++){var w=h[b];w._dbInfo.db=null,w._dbInfo.version=l}var A=new p(function(T,P){var O=Y.open(e.name,l);O.onerror=function(q){var be=O.result;be.close(),P(q)},O.onupgradeneeded=function(){var q=O.result;q.deleteObjectStore(e.storeName)},O.onsuccess=function(){var q=O.result;q.close(),T(q)}});return A.then(function(T){d.db=T;for(var P=0;P<h.length;P++){var O=h[P];O._dbInfo.db=T,W(O._dbInfo)}}).catch(function(T){throw(J(e,T)||p.resolve()).catch(function(){}),T})}}):o=s.then(function(f){k(e);var l=$[e.name],d=l.forages;f.close();for(var h=0;h<d.length;h++){var b=d[h];b._dbInfo.db=null}var w=new p(function(A,T){var P=Y.deleteDatabase(e.name);P.onerror=function(){var O=P.result;O&&O.close(),T(P.error)},P.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},P.onsuccess=function(){var O=P.result;O&&O.close(),A(O)}});return w.then(function(A){l.db=A;for(var T=0;T<d.length;T++){var P=d[T];W(P._dbInfo)}}).catch(function(A){throw(J(e,A)||p.resolve()).catch(function(){}),A})})}return _(o,t),o}i(Rr,"dropInstance");var xr={_driver:"asyncStorage",_initStorage:_r,_support:M(),iterate:Ir,getItem:wr,setItem:Er,removeItem:Ar,clear:Tr,length:Dr,key:Nr,keys:Cr,dropInstance:Rr};function Or(){return typeof openDatabase=="function"}i(Or,"isWebSQLValid");var oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Br="~~local_forage_type~",qe=/^~~local_forage_type~([^~]+)~/,Ce="__lfsc__:",Be=Ce.length,Fe="arbf",Pe="blob",Ge="si08",Qe="ui08",He="uic8",Xe="si16",Ze="si32",er="ur16",rr="ui32",tr="fl32",nr="fl64",ar=Be+Fe.length,or=Object.prototype.toString;function ir(e){var t=e.length*.75,r=e.length,a,o=0,n,s,f,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var d=new ArrayBuffer(t),h=new Uint8Array(d);for(a=0;a<r;a+=4)n=oe.indexOf(e[a]),s=oe.indexOf(e[a+1]),f=oe.indexOf(e[a+2]),l=oe.indexOf(e[a+3]),h[o++]=n<<2|s>>4,h[o++]=(s&15)<<4|f>>2,h[o++]=(f&3)<<6|l&63;return d}i(ir,"stringToBuffer");function Le(e){var t=new Uint8Array(e),r="",a;for(a=0;a<t.length;a+=3)r+=oe[t[a]>>2],r+=oe[(t[a]&3)<<4|t[a+1]>>4],r+=oe[(t[a+1]&15)<<2|t[a+2]>>6],r+=oe[t[a+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}i(Le,"bufferToString");function Fr(e,t){var r="";if(e&&(r=or.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&or.call(e.buffer)==="[object ArrayBuffer]")){var a,o=Ce;e instanceof ArrayBuffer?(a=e,o+=Fe):(a=e.buffer,r==="[object Int8Array]"?o+=Ge:r==="[object Uint8Array]"?o+=Qe:r==="[object Uint8ClampedArray]"?o+=He:r==="[object Int16Array]"?o+=Xe:r==="[object Uint16Array]"?o+=er:r==="[object Int32Array]"?o+=Ze:r==="[object Uint32Array]"?o+=rr:r==="[object Float32Array]"?o+=tr:r==="[object Float64Array]"?o+=nr:t(new Error("Failed to get type for BinaryArray"))),t(o+Le(a))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var s=Br+e.type+"~"+Le(this.result);t(Ce+Pe+s)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(s){console.error("Couldn't convert value into a JSON string: ",e),t(null,s)}}i(Fr,"serialize");function Pr(e){if(e.substring(0,Be)!==Ce)return JSON.parse(e);var t=e.substring(ar),r=e.substring(Be,ar),a;if(r===Pe&&qe.test(t)){var o=t.match(qe);a=o[1],t=t.substring(o[0].length)}var n=ir(t);switch(r){case Fe:return n;case Pe:return G([n],{type:a});case Ge:return new Int8Array(n);case Qe:return new Uint8Array(n);case He:return new Uint8ClampedArray(n);case Xe:return new Int16Array(n);case er:return new Uint16Array(n);case Ze:return new Int32Array(n);case rr:return new Uint32Array(n);case tr:return new Float32Array(n);case nr:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}i(Pr,"deserialize");var Ue={serialize:Fr,deserialize:Pr,stringToBuffer:ir,bufferToString:Le};function sr(e,t,r,a){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,a)}i(sr,"createDbTable");function Lr(e){var t=this,r={db:null};if(e)for(var a in e)r[a]=typeof e[a]!="string"?e[a].toString():e[a];var o=new p(function(n,s){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(f){return s(f)}r.db.transaction(function(f){sr(f,r,function(){t._dbInfo=r,n()},function(l,d){s(d)})},s)});return r.serializer=Ue,o}i(Lr,"_initStorage$1");function ie(e,t,r,a,o,n){e.executeSql(r,a,o,function(s,f){f.code===f.SYNTAX_ERR?s.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(l,d){d.rows.length?n(l,f):sr(l,t,function(){l.executeSql(r,a,o,n)},n)},n):n(s,f)},n)}i(ie,"tryExecuteSql");function Ur(e,t){var r=this;e=L(e);var a=new p(function(o,n){r.ready().then(function(){var s=r._dbInfo;s.db.transaction(function(f){ie(f,s,"SELECT * FROM "+s.storeName+" WHERE key = ? LIMIT 1",[e],function(l,d){var h=d.rows.length?d.rows.item(0).value:null;h&&(h=s.serializer.deserialize(h)),o(h)},function(l,d){n(d)})})}).catch(n)});return _(a,t),a}i(Ur,"getItem$1");function $r(e,t){var r=this,a=new p(function(o,n){r.ready().then(function(){var s=r._dbInfo;s.db.transaction(function(f){ie(f,s,"SELECT * FROM "+s.storeName,[],function(l,d){for(var h=d.rows,b=h.length,w=0;w<b;w++){var A=h.item(w),T=A.value;if(T&&(T=s.serializer.deserialize(T)),T=e(T,A.key,w+1),T!==void 0){o(T);return}}o()},function(l,d){n(d)})})}).catch(n)});return _(a,t),a}i($r,"iterate$1");function ur(e,t,r,a){var o=this;e=L(e);var n=new p(function(s,f){o.ready().then(function(){t===void 0&&(t=null);var l=t,d=o._dbInfo;d.serializer.serialize(t,function(h,b){b?f(b):d.db.transaction(function(w){ie(w,d,"INSERT OR REPLACE INTO "+d.storeName+" (key, value) VALUES (?, ?)",[e,h],function(){s(l)},function(A,T){f(T)})},function(w){if(w.code===w.QUOTA_ERR){if(a>0){s(ur.apply(o,[e,l,r,a-1]));return}f(w)}})})}).catch(f)});return _(n,r),n}i(ur,"_setItem");function Vr(e,t,r){return ur.apply(this,[e,t,r,1])}i(Vr,"setItem$1");function Mr(e,t){var r=this;e=L(e);var a=new p(function(o,n){r.ready().then(function(){var s=r._dbInfo;s.db.transaction(function(f){ie(f,s,"DELETE FROM "+s.storeName+" WHERE key = ?",[e],function(){o()},function(l,d){n(d)})})}).catch(n)});return _(a,t),a}i(Mr,"removeItem$1");function kr(e){var t=this,r=new p(function(a,o){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(s){ie(s,n,"DELETE FROM "+n.storeName,[],function(){a()},function(f,l){o(l)})})}).catch(o)});return _(r,e),r}i(kr,"clear$1");function Yr(e){var t=this,r=new p(function(a,o){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(s){ie(s,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(f,l){var d=l.rows.item(0).c;a(d)},function(f,l){o(l)})})}).catch(o)});return _(r,e),r}i(Yr,"length$1");function zr(e,t){var r=this,a=new p(function(o,n){r.ready().then(function(){var s=r._dbInfo;s.db.transaction(function(f){ie(f,s,"SELECT key FROM "+s.storeName+" WHERE id = ? LIMIT 1",[e+1],function(l,d){var h=d.rows.length?d.rows.item(0).key:null;o(h)},function(l,d){n(d)})})}).catch(n)});return _(a,t),a}i(zr,"key$1");function Kr(e){var t=this,r=new p(function(a,o){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(s){ie(s,n,"SELECT key FROM "+n.storeName,[],function(f,l){for(var d=[],h=0;h<l.rows.length;h++)d.push(l.rows.item(h).key);a(d)},function(f,l){o(l)})})}).catch(o)});return _(r,e),r}i(Kr,"keys$1");function Wr(e){return new p(function(t,r){e.transaction(function(a){a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(o,n){for(var s=[],f=0;f<n.rows.length;f++)s.push(n.rows.item(f).name);t({db:e,storeNames:s})},function(o,n){r(n)})},function(a){r(a)})})}i(Wr,"getAllStoreNames");function Jr(e,t){t=Q.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var a=this,o;return e.name?o=new p(function(n){var s;e.name===r.name?s=a._dbInfo.db:s=openDatabase(e.name,"","",0),e.storeName?n({db:s,storeNames:[e.storeName]}):n(Wr(s))}).then(function(n){return new p(function(s,f){n.db.transaction(function(l){function d(A){return new p(function(T,P){l.executeSql("DROP TABLE IF EXISTS "+A,[],function(){T()},function(O,q){P(q)})})}i(d,"dropTable");for(var h=[],b=0,w=n.storeNames.length;b<w;b++)h.push(d(n.storeNames[b]));p.all(h).then(function(){s()}).catch(function(A){f(A)})},function(l){f(l)})})}):o=p.reject("Invalid arguments"),_(o,t),o}i(Jr,"dropInstance$1");var jr={_driver:"webSQLStorage",_initStorage:Lr,_support:Or(),iterate:$r,getItem:Ur,setItem:Vr,removeItem:Mr,clear:kr,length:Yr,key:zr,keys:Kr,dropInstance:Jr};function qr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}i(qr,"isLocalStorageValid");function fr(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}i(fr,"_getKeyPrefix");function Gr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}i(Gr,"checkIfLocalStorageThrows");function Qr(){return!Gr()||localStorage.length>0}i(Qr,"_isLocalStorageUsable");function Hr(e){var t=this,r={};if(e)for(var a in e)r[a]=e[a];return r.keyPrefix=fr(e,t._defaultConfig),Qr()?(t._dbInfo=r,r.serializer=Ue,p.resolve()):p.reject()}i(Hr,"_initStorage$2");function Xr(e){var t=this,r=t.ready().then(function(){for(var a=t._dbInfo.keyPrefix,o=localStorage.length-1;o>=0;o--){var n=localStorage.key(o);n.indexOf(a)===0&&localStorage.removeItem(n)}});return _(r,e),r}i(Xr,"clear$2");function Zr(e,t){var r=this;e=L(e);var a=r.ready().then(function(){var o=r._dbInfo,n=localStorage.getItem(o.keyPrefix+e);return n&&(n=o.serializer.deserialize(n)),n});return _(a,t),a}i(Zr,"getItem$2");function et(e,t){var r=this,a=r.ready().then(function(){for(var o=r._dbInfo,n=o.keyPrefix,s=n.length,f=localStorage.length,l=1,d=0;d<f;d++){var h=localStorage.key(d);if(h.indexOf(n)===0){var b=localStorage.getItem(h);if(b&&(b=o.serializer.deserialize(b)),b=e(b,h.substring(s),l++),b!==void 0)return b}}});return _(a,t),a}i(et,"iterate$2");function rt(e,t){var r=this,a=r.ready().then(function(){var o=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(o.keyPrefix.length)),n});return _(a,t),a}i(rt,"key$2");function tt(e){var t=this,r=t.ready().then(function(){for(var a=t._dbInfo,o=localStorage.length,n=[],s=0;s<o;s++){var f=localStorage.key(s);f.indexOf(a.keyPrefix)===0&&n.push(f.substring(a.keyPrefix.length))}return n});return _(r,e),r}i(tt,"keys$2");function nt(e){var t=this,r=t.keys().then(function(a){return a.length});return _(r,e),r}i(nt,"length$2");function at(e,t){var r=this;e=L(e);var a=r.ready().then(function(){var o=r._dbInfo;localStorage.removeItem(o.keyPrefix+e)});return _(a,t),a}i(at,"removeItem$2");function ot(e,t,r){var a=this;e=L(e);var o=a.ready().then(function(){t===void 0&&(t=null);var n=t;return new p(function(s,f){var l=a._dbInfo;l.serializer.serialize(t,function(d,h){if(h)f(h);else try{localStorage.setItem(l.keyPrefix+e,d),s(n)}catch(b){(b.name==="QuotaExceededError"||b.name==="NS_ERROR_DOM_QUOTA_REACHED")&&f(b),f(b)}})})});return _(o,r),o}i(ot,"setItem$2");function it(e,t){if(t=Q.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var a=this,o;return e.name?o=new p(function(n){e.storeName?n(fr(e,a._defaultConfig)):n(e.name+"/")}).then(function(n){for(var s=localStorage.length-1;s>=0;s--){var f=localStorage.key(s);f.indexOf(n)===0&&localStorage.removeItem(f)}}):o=p.reject("Invalid arguments"),_(o,t),o}i(it,"dropInstance$2");var st={_driver:"localStorageWrapper",_initStorage:Hr,_support:qr(),iterate:et,getItem:Zr,setItem:ot,removeItem:at,clear:Xr,length:nt,key:rt,keys:tt,dropInstance:it},ut=i(function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},"sameValue"),ft=i(function(t,r){for(var a=t.length,o=0;o<a;){if(ut(t[o],r))return!0;o++}return!1},"includes"),cr=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ge={},lr={},ye={INDEXEDDB:xr,WEBSQL:jr,LOCALSTORAGE:st},ct=[ye.INDEXEDDB._driver,ye.WEBSQL._driver,ye.LOCALSTORAGE._driver],Re=["dropInstance"],$e=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Re),lt={description:"",driver:ct.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function dt(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}i(dt,"callWhenReady");function Ve(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(cr(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}i(Ve,"extend");var ht=function(){function e(t){x(this,e);for(var r in ye)if(ye.hasOwnProperty(r)){var a=ye[r],o=a._driver;this[r]=o,ge[o]||this.defineDriver(a)}this._defaultConfig=Ve({},lt),this._config=Ve({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return i(e,"LocalForage"),e.prototype.config=i(function(r){if((typeof r>"u"?"undefined":C(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var a in r){if(a==="storeName"&&(r[a]=r[a].replace(/\W/g,"_")),a==="version"&&typeof r[a]!="number")return new Error("Database version must be a number.");this._config[a]=r[a]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},"config"),e.prototype.defineDriver=i(function(r,a,o){var n=new p(function(s,f){try{var l=r._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){f(d);return}for(var h=$e.concat("_initStorage"),b=0,w=h.length;b<w;b++){var A=h[b],T=!ft(Re,A);if((T||r[A])&&typeof r[A]!="function"){f(d);return}}var P=i(function(){for(var be=i(function(mt){return function(){var pt=new Error("Method "+mt+" is not implemented by the current driver"),dr=p.reject(pt);return _(dr,arguments[arguments.length-1]),dr}},"methodNotImplementedFactory"),Me=0,yt=Re.length;Me<yt;Me++){var ke=Re[Me];r[ke]||(r[ke]=be(ke))}},"configureMissingMethods");P();var O=i(function(be){ge[l]&&console.info("Redefining LocalForage driver: "+l),ge[l]=r,lr[l]=be,s()},"setDriverSupport");"_support"in r?r._support&&typeof r._support=="function"?r._support().then(O,f):O(!!r._support):O(!0)}catch(q){f(q)}});return F(n,a,o),n},"defineDriver"),e.prototype.driver=i(function(){return this._driver||null},"driver"),e.prototype.getDriver=i(function(r,a,o){var n=ge[r]?p.resolve(ge[r]):p.reject(new Error("Driver not found."));return F(n,a,o),n},"getDriver"),e.prototype.getSerializer=i(function(r){var a=p.resolve(Ue);return F(a,r),a},"getSerializer"),e.prototype.ready=i(function(r){var a=this,o=a._driverSet.then(function(){return a._ready===null&&(a._ready=a._initDriver()),a._ready});return F(o,r,r),o},"ready"),e.prototype.setDriver=i(function(r,a,o){var n=this;cr(r)||(r=[r]);var s=this._getSupportedDrivers(r);function f(){n._config.driver=n.driver()}i(f,"setDriverToConfig");function l(b){return n._extend(b),f(),n._ready=n._initStorage(n._config),n._ready}i(l,"extendSelfWithDriver");function d(b){return function(){var w=0;function A(){for(;w<b.length;){var T=b[w];return w++,n._dbInfo=null,n._ready=null,n.getDriver(T).then(l).catch(A)}f();var P=new Error("No available storage method found.");return n._driverSet=p.reject(P),n._driverSet}return i(A,"driverPromiseLoop"),A()}}i(d,"initDriver");var h=this._driverSet!==null?this._driverSet.catch(function(){return p.resolve()}):p.resolve();return this._driverSet=h.then(function(){var b=s[0];return n._dbInfo=null,n._ready=null,n.getDriver(b).then(function(w){n._driver=w._driver,f(),n._wrapLibraryMethodsWithReady(),n._initDriver=d(s)})}).catch(function(){f();var b=new Error("No available storage method found.");return n._driverSet=p.reject(b),n._driverSet}),F(this._driverSet,a,o),this._driverSet},"setDriver"),e.prototype.supports=i(function(r){return!!lr[r]},"supports"),e.prototype._extend=i(function(r){Ve(this,r)},"_extend"),e.prototype._getSupportedDrivers=i(function(r){for(var a=[],o=0,n=r.length;o<n;o++){var s=r[o];this.supports(s)&&a.push(s)}return a},"_getSupportedDrivers"),e.prototype._wrapLibraryMethodsWithReady=i(function(){for(var r=0,a=$e.length;r<a;r++)dt(this,$e[r])},"_wrapLibraryMethodsWithReady"),e.prototype.createInstance=i(function(r){return new e(r)},"createInstance"),e}(),vt=new ht;v.exports=vt},{"3":3}]},{},[4])(4)})});var hr=i(g=>g==null,"isNil");var vr=(g=>(u=12)=>Number(`${g++}`.padStart(u,"0")))(Date.now());var ue=class{constructor(){this.value=vr()}};i(ue,"SchemaId");var Tt=i(g=>{switch(g){case Number:return 0;case Boolean:return!1;case String:return"";case Array:case Float32Array:case Float64Array:case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:return new g;case ArrayBuffer:return new g(0);default:return null}},"getDefaultValue"),Ke=i((g,u)=>{try{return u instanceof g||typeof u===g.name.toLowerCase()}catch{return!1}},"isSameValueType"),Z=class{constructor(u,c=!1,y=null){this.type=u;this.required=c;this.defaultValue=y;if(y!==null&&!Ke(u,y))throw new Error(`Default value "${y}" does not match type "${u.name}"`);this.defaultValue=y??Tt(this.type)}toJSON(){return{type:this.type instanceof ne?this.type.toJSON():this.type.name,required:this.required,defaultValue:this.defaultValue}}toString(){return JSON.stringify(this.toJSON(),null,4)}};i(Z,"SchemaValue");var we,B,Ie,Ee,se=class{constructor(u,c=null,y=!0){z(this,we,["id","createdDate","lastUpdatedDate"]);z(this,B,{id:new Z(ue,!1),createdDate:new Z(Date,!1),lastUpdatedDate:new Z(Date,!1)});z(this,Ie,void 0);z(this,Ee,!0);if(K(this,Ie,u),K(this,Ee,y),y||K(this,B,{}),c){for(let v in c)if(c.hasOwnProperty(v))if(c[v]instanceof Z)S(this,we).includes(v)||(S(this,B)[v]=c[v]);else throw new Error(`Field "${v}" is not a SchemaValue`)}}get name(){return S(this,Ie)}get includeDefaultKeys(){return S(this,Ee)}get defaultKeys(){return S(this,we)}defineField(u,c,{defaultValue:y,required:v}={defaultValue:null,required:!1}){S(this,B)[`${u}`]=new Z(c,v,y)}removeField(u){if(u){let[c,...y]=`${u}`.split("."),v=S(this,B)[c];v&&(y.length?v.type instanceof se&&v.type.removeField(y.join(".")):delete S(this,B)[c])}}hasField(u){if(u){let[c,...y]=`${u}`.split("."),v=S(this,B)[c];if(v)if(y.length){if(v.type instanceof se)return v.type.hasField(y.join("."))}else return S(this,B).hasOwnProperty(c)}return!1}getField(u){if(u){let[c,...y]=`${u}`.split("."),v=S(this,B)[c];return v&&y.length&&v.type instanceof se?v.type.getField(y.join(".")):v??null}return null}isValidFieldValue(u,c=null){if(S(this,B).hasOwnProperty(u)){let y=S(this,B)[`${u}`];return c instanceof Array&&c.some(v=>!Dt(v))?!1:y.type instanceof se?`${c}`=="[object Object]"&&y.type.getInvalidSchemaDataFields(c).length===0:y.required?!hr(c)&&Ke(y.type,c):c===null||c===y.defaultValue||Ke(y.type,c)}return!1}getInvalidSchemaDataFields(u){let c=new Set,y=Object.keys(S(this,B)).filter(v=>S(this,B)[v].required);for(let v of[...Object.keys(u),...y])if(!this.defaultKeys.includes(v)){let R=this.getField(v);if(R?.type instanceof se){let C=u[v];`${C}`=="[object Object]"?R.type.getInvalidSchemaDataFields(C).map(x=>{c.add(`${v}.${x}`)}):c.add(v);continue}this.isValidFieldValue(v,u[v])||c.add(v)}return Array.from(c)}toJSON(){let u={};for(let c in S(this,B))if(S(this,B).hasOwnProperty(c)){let y=S(this,B)[c];u[c]=y.toJSON()}return u}toString(){return JSON.stringify(this.toJSON(),null,4)}toValue(){let u=new Date,c=this.includeDefaultKeys?{id:new ue().value,createdDate:u,lastUpdatedDate:u}:{};for(let y in S(this,B))if(S(this,B).hasOwnProperty(y)&&!this.defaultKeys.includes(y)){let v=S(this,B)[y];switch(!0){case v.type instanceof se:c[y]=v.type.toValue();break;case v.type instanceof Date:c[y]=v.defaultValue??new Date;break;default:c[y]=v.defaultValue}}return c}},ne=se;i(ne,"Schema"),we=new WeakMap,B=new WeakMap,Ie=new WeakMap,Ee=new WeakMap;function Dt(g){return g===null||[ne,ue,Date,Number,String,Boolean,Array,ArrayBuffer,Blob,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array].some(u=>g instanceof u||typeof g===u.name.toLowerCase())}i(Dt,"isSupportedTypeValue");var X=At(mr());var pr="Memory";var gr={version:1,type:[X.INDEXEDDB,X.WEBSQL,X.LOCALSTORAGE],description:"",appName:"App"},V,ae,Te,H,le,De,de,he,Ae,me=class{constructor(u,c,y=gr,v=()=>{}){z(this,he);z(this,V,void 0);z(this,ae,void 0);z(this,Te,void 0);z(this,H,void 0);z(this,le,[]);z(this,De,!1);z(this,de,0);if(K(this,Te,u),K(this,ae,{...gr,...y}),!(c instanceof ne))throw new Error('Missing or unknown "Schema"');let R=S(this,ae).appName||"App";K(this,H,c),K(this,V,X.default.createInstance({driver:S(this,ae).type,version:S(this,ae).version,description:S(this,ae).description,name:R,storeName:u})),S(this,V).ready(()=>{console.info(`[Info] ClientStore "${u}" successfully created`),K(this,De,!0),typeof v=="function"&&v()})}get ready(){return S(this,De)}get type(){return S(this,V).driver()}get name(){return`${S(this,ae).appName}-${S(this,Te)}`}get size(){return S(this,de)}subscribe(u){return typeof u=="function"&&S(this,le).push(u),()=>{K(this,le,S(this,le).filter(c=>c!==u))}}async createItem(u){let c=S(this,H).getInvalidSchemaDataFields(u);if(!c.length){let y=S(this,H).toValue();for(let v in u)u.hasOwnProperty(v)&&!S(this,H).defaultKeys.includes(v)&&(y[v]=u[v]);try{await S(this,V).setItem(`${y.id}`,y),K(this,de,await S(this,V).length())}catch(v){console.error(`Failed to create item "${u}"`,v)}return _e(this,he,Ae).call(this,me.EventType.CREATE,y.id),y}throw new Error(`Failed to create item. Field(s) "${c.join(", ")}" do not match the schema: ${S(this,H)}`)}async updateItem(u,c){for(let R in c)if(c.hasOwnProperty(R)&&!S(this,H).defaultKeys.includes(R)&&!S(this,H).isValidFieldValue(R,c[R]))throw new Error(`Failed to update item "${u}". Key "${R}" is unknown or has invalid value type: ${S(this,H).getField(R)}`);let y=await this.getItem(u),v={...y,...c,lastUpdatedDate:new Date,id:y.id};try{await S(this,V).setItem(`${y.id}`,v)}catch(R){console.error(`Failed to update item "${y}"`,R)}return _e(this,he,Ae).call(this,me.EventType.UPDATE,u),v}async getItems(){let u=await S(this,V).keys();return Promise.all(u.map(c=>S(this,V).getItem(c)))}getItem(u){return S(this,V).getItem(`${u}`)}removeItem(u){return S(this,V).removeItem(`${u}`).then(async()=>{K(this,de,await S(this,V).length()),_e(this,he,Ae).call(this,me.EventType.DELETE,u)})}clear(){return S(this,V).clear().then(async()=>{K(this,de,await S(this,V).length()),_e(this,he,Ae).call(this,me.EventType.CLEAR)})}async findItem(u=()=>!1){return S(this,V).iterate((c,y)=>{if(u(c,y))return c})||null}async findAllItems(u=()=>!1){let c=[];return await S(this,V).iterate((y,v)=>{u(y,v)&&y&&c.push(y)}),c}},fe=me;i(fe,"ClientStore"),V=new WeakMap,ae=new WeakMap,Te=new WeakMap,H=new WeakMap,le=new WeakMap,De=new WeakMap,de=new WeakMap,he=new WeakSet,Ae=i(function(u,c=null){S(this,le).forEach(y=>y(u,c))},"#broadcast");(c=>{let g;(x=>(x.CREATE="created",x.DELETE="deleted",x.UPDATE="updated",x.CLEAR="cleared"))(g=c.EventType||(c.EventType={})),c.Type={LOCALSTORAGE:X.LOCALSTORAGE,WEBSQL:X.WEBSQL,INDEXEDDB:X.INDEXEDDB,MEMORY_STORAGE:pr}})(fe||(fe={}));window&&(window.Schema=ne,window.SchemaValue=Z,window.SchemaId=ue,window.ClientStore=fe);})();
(()=>{var Sr=Object.create;var We=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var Tr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Ar=Object.prototype.hasOwnProperty;var s=(p,i)=>We(p,"name",{value:i,configurable:!0}),_e=(p=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(p,{get:(i,f)=>(typeof require!="undefined"?require:i)[f]}):p)(function(p){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+p+'" is not supported')});var Ir=(p,i)=>()=>(i||p((i={exports:{}}).exports,i),i.exports);var Dr=(p,i,f,h)=>{if(i&&typeof i=="object"||typeof i=="function")for(let v of Tr(i))!Ar.call(p,v)&&v!==f&&We(p,v,{get:()=>i[v],enumerable:!(h=wr(i,v))||h.enumerable});return p};var Rr=(p,i,f)=>(f=p!=null?Sr(_r(p)):{},Dr(i||!p||!p.__esModule?We(f,"default",{value:p,enumerable:!0}):f,p));var Je=(p,i,f)=>{if(!i.has(p))throw TypeError("Cannot "+f)};var E=(p,i,f)=>(Je(p,i,"read from private field"),f?f.call(p):i.get(p)),J=(p,i,f)=>{if(i.has(p))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(p):i.set(p,f)},K=(p,i,f,h)=>(Je(p,i,"write to private field"),h?h.call(p,f):i.set(p,f),f);var H=(p,i,f)=>(Je(p,i,"access private method"),f);var bt=Ir((gt,je)=>{(function(p){if(typeof gt=="object"&&typeof je<"u")je.exports=p();else if(typeof define=="function"&&define.amd)define([],p);else{var i;typeof window<"u"?i=window:typeof global<"u"?i=global:typeof self<"u"?i=self:i=this,i.localforage=p()}})(function(){var p,i,f;return s(function h(v,x,N){function k(O,ee){if(!x[O]){if(!v[O]){var g=typeof _e=="function"&&_e;if(!ee&&g)return g(O,!0);if(D)return D(O,!0);var S=new Error("Cannot find module '"+O+"'");throw S.code="MODULE_NOT_FOUND",S}var P=x[O]={exports:{}};v[O][0].call(P.exports,function(L){var te=v[O][1][L];return k(te||L)},P,P.exports,h,v,x,N)}return x[O].exports}s(k,"s");for(var D=typeof _e=="function"&&_e,z=0;z<N.length;z++)k(N[z]);return k},"e")({1:[function(h,v,x){(function(N){"use strict";var k=N.MutationObserver||N.WebKitMutationObserver,D;if(k){var z=0,O=new k(L),ee=N.document.createTextNode("");O.observe(ee,{characterData:!0}),D=s(function(){ee.data=z=++z%2},"scheduleDrain")}else if(!N.setImmediate&&typeof N.MessageChannel<"u"){var g=new N.MessageChannel;g.port1.onmessage=L,D=s(function(){g.port2.postMessage(0)},"scheduleDrain")}else"document"in N&&"onreadystatechange"in N.document.createElement("script")?D=s(function(){var U=N.document.createElement("script");U.onreadystatechange=function(){L(),U.onreadystatechange=null,U.parentNode.removeChild(U),U=null},N.document.documentElement.appendChild(U)},"scheduleDrain"):D=s(function(){setTimeout(L,0)},"scheduleDrain");var S,P=[];function L(){S=!0;for(var U,ae,V=P.length;V;){for(ae=P,P=[],U=-1;++U<V;)ae[U]();V=P.length}S=!1}s(L,"nextTick"),v.exports=te;function te(U){P.push(U)===1&&!S&&D()}s(te,"immediate")}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(h,v,x){"use strict";var N=h(1);function k(){}s(k,"INTERNAL");var D={},z=["REJECTED"],O=["FULFILLED"],ee=["PENDING"];v.exports=g;function g(m){if(typeof m!="function")throw new TypeError("resolver must be a function");this.state=ee,this.queue=[],this.outcome=void 0,m!==k&&te(this,m)}s(g,"Promise"),g.prototype.catch=function(m){return this.then(null,m)},g.prototype.then=function(m,_){if(typeof m!="function"&&this.state===O||typeof _!="function"&&this.state===z)return this;var T=new this.constructor(k);if(this.state!==ee){var R=this.state===O?m:_;P(T,R,this.outcome)}else this.queue.push(new S(T,m,_));return T};function S(m,_,T){this.promise=m,typeof _=="function"&&(this.onFulfilled=_,this.callFulfilled=this.otherCallFulfilled),typeof T=="function"&&(this.onRejected=T,this.callRejected=this.otherCallRejected)}s(S,"QueueItem"),S.prototype.callFulfilled=function(m){D.resolve(this.promise,m)},S.prototype.otherCallFulfilled=function(m){P(this.promise,this.onFulfilled,m)},S.prototype.callRejected=function(m){D.reject(this.promise,m)},S.prototype.otherCallRejected=function(m){P(this.promise,this.onRejected,m)};function P(m,_,T){N(function(){var R;try{R=_(T)}catch(Y){return D.reject(m,Y)}R===m?D.reject(m,new TypeError("Cannot resolve promise with itself")):D.resolve(m,R)})}s(P,"unwrap"),D.resolve=function(m,_){var T=U(L,_);if(T.status==="error")return D.reject(m,T.value);var R=T.value;if(R)te(m,R);else{m.state=O,m.outcome=_;for(var Y=-1,q=m.queue.length;++Y<q;)m.queue[Y].callFulfilled(_)}return m},D.reject=function(m,_){m.state=z,m.outcome=_;for(var T=-1,R=m.queue.length;++T<R;)m.queue[T].callRejected(_);return m};function L(m){var _=m&&m.then;if(m&&(typeof m=="object"||typeof m=="function")&&typeof _=="function")return s(function(){_.apply(m,arguments)},"appyThen")}s(L,"getThen");function te(m,_){var T=!1;function R(Q){T||(T=!0,D.reject(m,Q))}s(R,"onError");function Y(Q){T||(T=!0,D.resolve(m,Q))}s(Y,"onSuccess");function q(){_(Y,R)}s(q,"tryToUnwrap");var G=U(q);G.status==="error"&&R(G.value)}s(te,"safelyResolveThenable");function U(m,_){var T={};try{T.value=m(_),T.status="success"}catch(R){T.status="error",T.value=R}return T}s(U,"tryCatch"),g.resolve=ae;function ae(m){return m instanceof this?m:D.resolve(new this(k),m)}s(ae,"resolve"),g.reject=V;function V(m){var _=new this(k);return D.reject(_,m)}s(V,"reject"),g.all=Pe;function Pe(m){var _=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var T=m.length,R=!1;if(!T)return this.resolve([]);for(var Y=new Array(T),q=0,G=-1,Q=new this(k);++G<T;)oe(m[G],G);return Q;function oe(Se,Ne){_.resolve(Se).then(Fe,function(be){R||(R=!0,D.reject(Q,be))});function Fe(be){Y[Ne]=be,++q===T&&!R&&(R=!0,D.resolve(Q,Y))}s(Fe,"resolveFromAll")}}s(Pe,"all"),g.race=pe;function pe(m){var _=this;if(Object.prototype.toString.call(m)!=="[object Array]")return this.reject(new TypeError("must be an array"));var T=m.length,R=!1;if(!T)return this.resolve([]);for(var Y=-1,q=new this(k);++Y<T;)G(m[Y]);return q;function G(Q){_.resolve(Q).then(function(oe){R||(R=!0,D.resolve(q,oe))},function(oe){R||(R=!0,D.reject(q,oe))})}}s(pe,"race")},{"1":1}],3:[function(h,v,x){(function(N){"use strict";typeof N.Promise!="function"&&(N.Promise=h(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{"2":2}],4:[function(h,v,x){"use strict";var N=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function k(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}s(k,"_classCallCheck");function D(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}s(D,"getIDB");var z=D();function O(){try{if(!z||!z.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}s(O,"isIndexedDBValid");function ee(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(n){if(n.name!=="TypeError")throw n;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,a=new t,o=0;o<e.length;o+=1)a.append(e[o]);return a.getBlob(r.type)}}s(ee,"createBlob"),typeof Promise>"u"&&h(3);var g=Promise;function S(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}s(S,"executeCallback");function P(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}s(P,"executeTwoCallbacks");function L(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}s(L,"normalizeKey");function te(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}s(te,"getCallback");var U="local-forage-detect-blob-support",ae=void 0,V={},Pe=Object.prototype.toString,pe="readonly",m="readwrite";function _(e){for(var r=e.length,t=new ArrayBuffer(r),a=new Uint8Array(t),o=0;o<r;o++)a[o]=e.charCodeAt(o);return t}s(_,"_binStringToArrayBuffer");function T(e){return new g(function(r){var t=e.transaction(U,m),a=ee([""]);t.objectStore(U).put(a,"key"),t.onabort=function(o){o.preventDefault(),o.stopPropagation(),r(!1)},t.oncomplete=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);r(n||!o||parseInt(o[1],10)>=43)}}).catch(function(){return!1})}s(T,"_checkBlobSupportWithoutCaching");function R(e){return typeof ae=="boolean"?g.resolve(ae):T(e).then(function(r){return ae=r,ae})}s(R,"_checkBlobSupport");function Y(e){var r=V[e.name],t={};t.promise=new g(function(a,o){t.resolve=a,t.reject=o}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}s(Y,"_deferReadiness");function q(e){var r=V[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}s(q,"_advanceReadiness");function G(e,r){var t=V[e.name],a=t.deferredOperations.pop();if(a)return a.reject(r),a.promise}s(G,"_rejectReadiness");function Q(e,r){return new g(function(t,a){if(V[e.name]=V[e.name]||Ge(),e.db)if(r)Y(e),e.db.close();else return t(e.db);var o=[e.name];r&&o.push(e.version);var n=z.open.apply(z,o);r&&(n.onupgradeneeded=function(u){var c=n.result;try{c.createObjectStore(e.storeName),u.oldVersion<=1&&c.createObjectStore(U)}catch(l){if(l.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+u.oldVersion+" to version "+u.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw l}}),n.onerror=function(u){u.preventDefault(),a(n.error)},n.onsuccess=function(){var u=n.result;u.onversionchange=function(c){c.target.close()},t(u),q(e)}})}s(Q,"_getConnection");function oe(e){return Q(e,!1)}s(oe,"_getOriginalConnection");function Se(e){return Q(e,!0)}s(Se,"_getUpgradedConnection");function Ne(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),a=e.version<e.db.version,o=e.version>e.db.version;if(a&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),o||t){if(t){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}s(Ne,"_isUpgradeNeeded");function Fe(e){return new g(function(r,t){var a=new FileReader;a.onerror=t,a.onloadend=function(o){var n=btoa(o.target.result||"");r({__local_forage_encoded_blob:!0,data:n,type:e.type})},a.readAsBinaryString(e)})}s(Fe,"_encodeBlob");function be(e){var r=_(atob(e.data));return ee([r],{type:e.type})}s(be,"_decodeBlob");function qe(e){return e&&e.__local_forage_encoded_blob}s(qe,"_isEncodedBlob");function wt(e){var r=this,t=r._initReady().then(function(){var a=V[r._dbInfo.name];if(a&&a.dbReady)return a.dbReady});return P(t,e,e),t}s(wt,"_fullyReady");function Tt(e){Y(e);for(var r=V[e.name],t=r.forages,a=0;a<t.length;a++){var o=t[a];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,oe(e).then(function(n){return e.db=n,Ne(e)?Se(e):n}).then(function(n){e.db=r.db=n;for(var u=0;u<t.length;u++)t[u]._dbInfo.db=n}).catch(function(n){throw G(e,n),n})}s(Tt,"_tryReconnect");function ie(e,r,t,a){a===void 0&&(a=1);try{var o=e.db.transaction(e.storeName,r);t(null,o)}catch(n){if(a>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return g.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),Se(e)}).then(function(){return Tt(e).then(function(){ie(e,r,t,a-1)})}).catch(t);t(n)}}s(ie,"createTransaction");function Ge(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}s(Ge,"createDbContext");function _t(e){var r=this,t={db:null};if(e)for(var a in e)t[a]=e[a];var o=V[t.name];o||(o=Ge(),V[t.name]=o),o.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=wt);var n=[];function u(){return g.resolve()}s(u,"ignoreErrors");for(var c=0;c<o.forages.length;c++){var l=o.forages[c];l!==r&&n.push(l._initReady().catch(u))}var d=o.forages.slice(0);return g.all(n).then(function(){return t.db=o.db,oe(t)}).then(function(y){return t.db=y,Ne(t,r._defaultConfig.version)?Se(t):y}).then(function(y){t.db=o.db=y,r._dbInfo=t;for(var b=0;b<d.length;b++){var w=d[b];w!==r&&(w._dbInfo.db=t.db,w._dbInfo.version=t.version)}})}s(_t,"_initStorage");function At(e,r){var t=this;e=L(e);var a=new g(function(o,n){t.ready().then(function(){ie(t._dbInfo,pe,function(u,c){if(u)return n(u);try{var l=c.objectStore(t._dbInfo.storeName),d=l.get(e);d.onsuccess=function(){var y=d.result;y===void 0&&(y=null),qe(y)&&(y=be(y)),o(y)},d.onerror=function(){n(d.error)}}catch(y){n(y)}})}).catch(n)});return S(a,r),a}s(At,"getItem");function It(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){ie(t._dbInfo,pe,function(u,c){if(u)return n(u);try{var l=c.objectStore(t._dbInfo.storeName),d=l.openCursor(),y=1;d.onsuccess=function(){var b=d.result;if(b){var w=b.value;qe(w)&&(w=be(w));var A=e(w,b.key,y++);A!==void 0?o(A):b.continue()}else o()},d.onerror=function(){n(d.error)}}catch(b){n(b)}})}).catch(n)});return S(a,r),a}s(It,"iterate");function Dt(e,r,t){var a=this;e=L(e);var o=new g(function(n,u){var c;a.ready().then(function(){return c=a._dbInfo,Pe.call(r)==="[object Blob]"?R(c.db).then(function(l){return l?r:Fe(r)}):r}).then(function(l){ie(a._dbInfo,m,function(d,y){if(d)return u(d);try{var b=y.objectStore(a._dbInfo.storeName);l===null&&(l=void 0);var w=b.put(l,e);y.oncomplete=function(){l===void 0&&(l=null),n(l)},y.onabort=y.onerror=function(){var A=w.error?w.error:w.transaction.error;u(A)}}catch(A){u(A)}})}).catch(u)});return S(o,t),o}s(Dt,"setItem");function Rt(e,r){var t=this;e=L(e);var a=new g(function(o,n){t.ready().then(function(){ie(t._dbInfo,m,function(u,c){if(u)return n(u);try{var l=c.objectStore(t._dbInfo.storeName),d=l.delete(e);c.oncomplete=function(){o()},c.onerror=function(){n(d.error)},c.onabort=function(){var y=d.error?d.error:d.transaction.error;n(y)}}catch(y){n(y)}})}).catch(n)});return S(a,r),a}s(Rt,"removeItem");function Ct(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ie(r._dbInfo,m,function(n,u){if(n)return o(n);try{var c=u.objectStore(r._dbInfo.storeName),l=c.clear();u.oncomplete=function(){a()},u.onabort=u.onerror=function(){var d=l.error?l.error:l.transaction.error;o(d)}}catch(d){o(d)}})}).catch(o)});return S(t,e),t}s(Ct,"clear");function Nt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ie(r._dbInfo,pe,function(n,u){if(n)return o(n);try{var c=u.objectStore(r._dbInfo.storeName),l=c.count();l.onsuccess=function(){a(l.result)},l.onerror=function(){o(l.error)}}catch(d){o(d)}})}).catch(o)});return S(t,e),t}s(Nt,"length");function Ot(e,r){var t=this,a=new g(function(o,n){if(e<0){o(null);return}t.ready().then(function(){ie(t._dbInfo,pe,function(u,c){if(u)return n(u);try{var l=c.objectStore(t._dbInfo.storeName),d=!1,y=l.openKeyCursor();y.onsuccess=function(){var b=y.result;if(!b){o(null);return}e===0||d?o(b.key):(d=!0,b.advance(e))},y.onerror=function(){n(y.error)}}catch(b){n(b)}})}).catch(n)});return S(a,r),a}s(Ot,"key");function xt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){ie(r._dbInfo,pe,function(n,u){if(n)return o(n);try{var c=u.objectStore(r._dbInfo.storeName),l=c.openKeyCursor(),d=[];l.onsuccess=function(){var y=l.result;if(!y){a(d);return}d.push(y.key),y.continue()},l.onerror=function(){o(l.error)}}catch(y){o(y)}})}).catch(o)});return S(t,e),t}s(xt,"keys");function Bt(e,r){r=te.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var a=this,o;if(!e.name)o=g.reject("Invalid arguments");else{var n=e.name===t.name&&a._dbInfo.db,u=n?g.resolve(a._dbInfo.db):oe(e).then(function(c){var l=V[e.name],d=l.forages;l.db=c;for(var y=0;y<d.length;y++)d[y]._dbInfo.db=c;return c});e.storeName?o=u.then(function(c){if(!!c.objectStoreNames.contains(e.storeName)){var l=c.version+1;Y(e);var d=V[e.name],y=d.forages;c.close();for(var b=0;b<y.length;b++){var w=y[b];w._dbInfo.db=null,w._dbInfo.version=l}var A=new g(function(I,F){var B=z.open(e.name,l);B.onerror=function(X){var Te=B.result;Te.close(),F(X)},B.onupgradeneeded=function(){var X=B.result;X.deleteObjectStore(e.storeName)},B.onsuccess=function(){var X=B.result;X.close(),I(X)}});return A.then(function(I){d.db=I;for(var F=0;F<y.length;F++){var B=y[F];B._dbInfo.db=I,q(B._dbInfo)}}).catch(function(I){throw(G(e,I)||g.resolve()).catch(function(){}),I})}}):o=u.then(function(c){Y(e);var l=V[e.name],d=l.forages;c.close();for(var y=0;y<d.length;y++){var b=d[y];b._dbInfo.db=null}var w=new g(function(A,I){var F=z.deleteDatabase(e.name);F.onerror=function(){var B=F.result;B&&B.close(),I(F.error)},F.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},F.onsuccess=function(){var B=F.result;B&&B.close(),A(B)}});return w.then(function(A){l.db=A;for(var I=0;I<d.length;I++){var F=d[I];q(F._dbInfo)}}).catch(function(A){throw(G(e,A)||g.resolve()).catch(function(){}),A})})}return S(o,r),o}s(Bt,"dropInstance");var Pt={_driver:"asyncStorage",_initStorage:_t,_support:O(),iterate:It,getItem:At,setItem:Dt,removeItem:Rt,clear:Ct,length:Nt,key:Ot,keys:xt,dropInstance:Bt};function Ft(){return typeof openDatabase=="function"}s(Ft,"isWebSQLValid");var le="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Lt="~~local_forage_type~",Qe=/^~~local_forage_type~([^~]+)~/,Oe="__lfsc__:",Le=Oe.length,Ue="arbf",$e="blob",Xe="si08",Ze="ui08",et="uic8",tt="si16",rt="si32",nt="ur16",at="ui32",ot="fl32",it="fl64",st=Le+Ue.length,ut=Object.prototype.toString;function ft(e){var r=e.length*.75,t=e.length,a,o=0,n,u,c,l;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var d=new ArrayBuffer(r),y=new Uint8Array(d);for(a=0;a<t;a+=4)n=le.indexOf(e[a]),u=le.indexOf(e[a+1]),c=le.indexOf(e[a+2]),l=le.indexOf(e[a+3]),y[o++]=n<<2|u>>4,y[o++]=(u&15)<<4|c>>2,y[o++]=(c&3)<<6|l&63;return d}s(ft,"stringToBuffer");function Ve(e){var r=new Uint8Array(e),t="",a;for(a=0;a<r.length;a+=3)t+=le[r[a]>>2],t+=le[(r[a]&3)<<4|r[a+1]>>4],t+=le[(r[a+1]&15)<<2|r[a+2]>>6],t+=le[r[a+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}s(Ve,"bufferToString");function Ut(e,r){var t="";if(e&&(t=ut.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&ut.call(e.buffer)==="[object ArrayBuffer]")){var a,o=Oe;e instanceof ArrayBuffer?(a=e,o+=Ue):(a=e.buffer,t==="[object Int8Array]"?o+=Xe:t==="[object Uint8Array]"?o+=Ze:t==="[object Uint8ClampedArray]"?o+=et:t==="[object Int16Array]"?o+=tt:t==="[object Uint16Array]"?o+=nt:t==="[object Int32Array]"?o+=rt:t==="[object Uint32Array]"?o+=at:t==="[object Float32Array]"?o+=ot:t==="[object Float64Array]"?o+=it:r(new Error("Failed to get type for BinaryArray"))),r(o+Ve(a))}else if(t==="[object Blob]"){var n=new FileReader;n.onload=function(){var u=Lt+e.type+"~"+Ve(this.result);r(Oe+$e+u)},n.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(u){console.error("Couldn't convert value into a JSON string: ",e),r(null,u)}}s(Ut,"serialize");function $t(e){if(e.substring(0,Le)!==Oe)return JSON.parse(e);var r=e.substring(st),t=e.substring(Le,st),a;if(t===$e&&Qe.test(r)){var o=r.match(Qe);a=o[1],r=r.substring(o[0].length)}var n=ft(r);switch(t){case Ue:return n;case $e:return ee([n],{type:a});case Xe:return new Int8Array(n);case Ze:return new Uint8Array(n);case et:return new Uint8ClampedArray(n);case tt:return new Int16Array(n);case nt:return new Uint16Array(n);case rt:return new Int32Array(n);case at:return new Uint32Array(n);case ot:return new Float32Array(n);case it:return new Float64Array(n);default:throw new Error("Unkown type: "+t)}}s($t,"deserialize");var Me={serialize:Ut,deserialize:$t,stringToBuffer:ft,bufferToString:Ve};function ct(e,r,t,a){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,a)}s(ct,"createDbTable");function Vt(e){var r=this,t={db:null};if(e)for(var a in e)t[a]=typeof e[a]!="string"?e[a].toString():e[a];var o=new g(function(n,u){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(c){return u(c)}t.db.transaction(function(c){ct(c,t,function(){r._dbInfo=t,n()},function(l,d){u(d)})},u)});return t.serializer=Me,o}s(Vt,"_initStorage$1");function de(e,r,t,a,o,n){e.executeSql(t,a,o,function(u,c){c.code===c.SYNTAX_ERR?u.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(l,d){d.rows.length?n(l,c):ct(l,r,function(){l.executeSql(t,a,o,n)},n)},n):n(u,c)},n)}s(de,"tryExecuteSql");function Mt(e,r){var t=this;e=L(e);var a=new g(function(o,n){t.ready().then(function(){var u=t._dbInfo;u.db.transaction(function(c){de(c,u,"SELECT * FROM "+u.storeName+" WHERE key = ? LIMIT 1",[e],function(l,d){var y=d.rows.length?d.rows.item(0).value:null;y&&(y=u.serializer.deserialize(y)),o(y)},function(l,d){n(d)})})}).catch(n)});return S(a,r),a}s(Mt,"getItem$1");function kt(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){var u=t._dbInfo;u.db.transaction(function(c){de(c,u,"SELECT * FROM "+u.storeName,[],function(l,d){for(var y=d.rows,b=y.length,w=0;w<b;w++){var A=y.item(w),I=A.value;if(I&&(I=u.serializer.deserialize(I)),I=e(I,A.key,w+1),I!==void 0){o(I);return}}o()},function(l,d){n(d)})})}).catch(n)});return S(a,r),a}s(kt,"iterate$1");function lt(e,r,t,a){var o=this;e=L(e);var n=new g(function(u,c){o.ready().then(function(){r===void 0&&(r=null);var l=r,d=o._dbInfo;d.serializer.serialize(r,function(y,b){b?c(b):d.db.transaction(function(w){de(w,d,"INSERT OR REPLACE INTO "+d.storeName+" (key, value) VALUES (?, ?)",[e,y],function(){u(l)},function(A,I){c(I)})},function(w){if(w.code===w.QUOTA_ERR){if(a>0){u(lt.apply(o,[e,l,t,a-1]));return}c(w)}})})}).catch(c)});return S(n,t),n}s(lt,"_setItem");function Yt(e,r,t){return lt.apply(this,[e,r,t,1])}s(Yt,"setItem$1");function zt(e,r){var t=this;e=L(e);var a=new g(function(o,n){t.ready().then(function(){var u=t._dbInfo;u.db.transaction(function(c){de(c,u,"DELETE FROM "+u.storeName+" WHERE key = ?",[e],function(){o()},function(l,d){n(d)})})}).catch(n)});return S(a,r),a}s(zt,"removeItem$1");function Kt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(u){de(u,n,"DELETE FROM "+n.storeName,[],function(){a()},function(c,l){o(l)})})}).catch(o)});return S(t,e),t}s(Kt,"clear$1");function Wt(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(u){de(u,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(c,l){var d=l.rows.item(0).c;a(d)},function(c,l){o(l)})})}).catch(o)});return S(t,e),t}s(Wt,"length$1");function Jt(e,r){var t=this,a=new g(function(o,n){t.ready().then(function(){var u=t._dbInfo;u.db.transaction(function(c){de(c,u,"SELECT key FROM "+u.storeName+" WHERE id = ? LIMIT 1",[e+1],function(l,d){var y=d.rows.length?d.rows.item(0).key:null;o(y)},function(l,d){n(d)})})}).catch(n)});return S(a,r),a}s(Jt,"key$1");function Ht(e){var r=this,t=new g(function(a,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(u){de(u,n,"SELECT key FROM "+n.storeName,[],function(c,l){for(var d=[],y=0;y<l.rows.length;y++)d.push(l.rows.item(y).key);a(d)},function(c,l){o(l)})})}).catch(o)});return S(t,e),t}s(Ht,"keys$1");function jt(e){return new g(function(r,t){e.transaction(function(a){a.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(o,n){for(var u=[],c=0;c<n.rows.length;c++)u.push(n.rows.item(c).name);r({db:e,storeNames:u})},function(o,n){t(n)})},function(a){t(a)})})}s(jt,"getAllStoreNames");function qt(e,r){r=te.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var a=this,o;return e.name?o=new g(function(n){var u;e.name===t.name?u=a._dbInfo.db:u=openDatabase(e.name,"","",0),e.storeName?n({db:u,storeNames:[e.storeName]}):n(jt(u))}).then(function(n){return new g(function(u,c){n.db.transaction(function(l){function d(A){return new g(function(I,F){l.executeSql("DROP TABLE IF EXISTS "+A,[],function(){I()},function(B,X){F(X)})})}s(d,"dropTable");for(var y=[],b=0,w=n.storeNames.length;b<w;b++)y.push(d(n.storeNames[b]));g.all(y).then(function(){u()}).catch(function(A){c(A)})},function(l){c(l)})})}):o=g.reject("Invalid arguments"),S(o,r),o}s(qt,"dropInstance$1");var Gt={_driver:"webSQLStorage",_initStorage:Vt,_support:Ft(),iterate:kt,getItem:Mt,setItem:Yt,removeItem:zt,clear:Kt,length:Wt,key:Jt,keys:Ht,dropInstance:qt};function Qt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}s(Qt,"isLocalStorageValid");function dt(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}s(dt,"_getKeyPrefix");function Xt(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}s(Xt,"checkIfLocalStorageThrows");function Zt(){return!Xt()||localStorage.length>0}s(Zt,"_isLocalStorageUsable");function er(e){var r=this,t={};if(e)for(var a in e)t[a]=e[a];return t.keyPrefix=dt(e,r._defaultConfig),Zt()?(r._dbInfo=t,t.serializer=Me,g.resolve()):g.reject()}s(er,"_initStorage$2");function tr(e){var r=this,t=r.ready().then(function(){for(var a=r._dbInfo.keyPrefix,o=localStorage.length-1;o>=0;o--){var n=localStorage.key(o);n.indexOf(a)===0&&localStorage.removeItem(n)}});return S(t,e),t}s(tr,"clear$2");function rr(e,r){var t=this;e=L(e);var a=t.ready().then(function(){var o=t._dbInfo,n=localStorage.getItem(o.keyPrefix+e);return n&&(n=o.serializer.deserialize(n)),n});return S(a,r),a}s(rr,"getItem$2");function nr(e,r){var t=this,a=t.ready().then(function(){for(var o=t._dbInfo,n=o.keyPrefix,u=n.length,c=localStorage.length,l=1,d=0;d<c;d++){var y=localStorage.key(d);if(y.indexOf(n)===0){var b=localStorage.getItem(y);if(b&&(b=o.serializer.deserialize(b)),b=e(b,y.substring(u),l++),b!==void 0)return b}}});return S(a,r),a}s(nr,"iterate$2");function ar(e,r){var t=this,a=t.ready().then(function(){var o=t._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(o.keyPrefix.length)),n});return S(a,r),a}s(ar,"key$2");function or(e){var r=this,t=r.ready().then(function(){for(var a=r._dbInfo,o=localStorage.length,n=[],u=0;u<o;u++){var c=localStorage.key(u);c.indexOf(a.keyPrefix)===0&&n.push(c.substring(a.keyPrefix.length))}return n});return S(t,e),t}s(or,"keys$2");function ir(e){var r=this,t=r.keys().then(function(a){return a.length});return S(t,e),t}s(ir,"length$2");function sr(e,r){var t=this;e=L(e);var a=t.ready().then(function(){var o=t._dbInfo;localStorage.removeItem(o.keyPrefix+e)});return S(a,r),a}s(sr,"removeItem$2");function ur(e,r,t){var a=this;e=L(e);var o=a.ready().then(function(){r===void 0&&(r=null);var n=r;return new g(function(u,c){var l=a._dbInfo;l.serializer.serialize(r,function(d,y){if(y)c(y);else try{localStorage.setItem(l.keyPrefix+e,d),u(n)}catch(b){(b.name==="QuotaExceededError"||b.name==="NS_ERROR_DOM_QUOTA_REACHED")&&c(b),c(b)}})})});return S(o,t),o}s(ur,"setItem$2");function fr(e,r){if(r=te.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var a=this,o;return e.name?o=new g(function(n){e.storeName?n(dt(e,a._defaultConfig)):n(e.name+"/")}).then(function(n){for(var u=localStorage.length-1;u>=0;u--){var c=localStorage.key(u);c.indexOf(n)===0&&localStorage.removeItem(c)}}):o=g.reject("Invalid arguments"),S(o,r),o}s(fr,"dropInstance$2");var cr={_driver:"localStorageWrapper",_initStorage:er,_support:Qt(),iterate:nr,getItem:rr,setItem:ur,removeItem:sr,clear:tr,length:ir,key:ar,keys:or,dropInstance:fr},lr=s(function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},"sameValue"),dr=s(function(r,t){for(var a=r.length,o=0;o<a;){if(lr(r[o],t))return!0;o++}return!1},"includes"),ht=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},we={},vt={},Ee={INDEXEDDB:Pt,WEBSQL:Gt,LOCALSTORAGE:cr},hr=[Ee.INDEXEDDB._driver,Ee.WEBSQL._driver,Ee.LOCALSTORAGE._driver],xe=["dropInstance"],ke=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(xe),vr={description:"",driver:hr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function yr(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}s(yr,"callWhenReady");function Ye(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(ht(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}s(Ye,"extend");var pr=function(){function e(r){k(this,e);for(var t in Ee)if(Ee.hasOwnProperty(t)){var a=Ee[t],o=a._driver;this[t]=o,we[o]||this.defineDriver(a)}this._defaultConfig=Ye({},vr),this._config=Ye({},this._defaultConfig,r),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return s(e,"LocalForage"),e.prototype.config=s(function(t){if((typeof t>"u"?"undefined":N(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var a in t){if(a==="storeName"&&(t[a]=t[a].replace(/\W/g,"_")),a==="version"&&typeof t[a]!="number")return new Error("Database version must be a number.");this._config[a]=t[a]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},"config"),e.prototype.defineDriver=s(function(t,a,o){var n=new g(function(u,c){try{var l=t._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){c(d);return}for(var y=ke.concat("_initStorage"),b=0,w=y.length;b<w;b++){var A=y[b],I=!dr(xe,A);if((I||t[A])&&typeof t[A]!="function"){c(d);return}}var F=s(function(){for(var Te=s(function(br){return function(){var Er=new Error("Method "+br+" is not implemented by the current driver"),yt=g.reject(Er);return S(yt,arguments[arguments.length-1]),yt}},"methodNotImplementedFactory"),ze=0,gr=xe.length;ze<gr;ze++){var Ke=xe[ze];t[Ke]||(t[Ke]=Te(Ke))}},"configureMissingMethods");F();var B=s(function(Te){we[l]&&console.info("Redefining LocalForage driver: "+l),we[l]=t,vt[l]=Te,u()},"setDriverSupport");"_support"in t?t._support&&typeof t._support=="function"?t._support().then(B,c):B(!!t._support):B(!0)}catch(X){c(X)}});return P(n,a,o),n},"defineDriver"),e.prototype.driver=s(function(){return this._driver||null},"driver"),e.prototype.getDriver=s(function(t,a,o){var n=we[t]?g.resolve(we[t]):g.reject(new Error("Driver not found."));return P(n,a,o),n},"getDriver"),e.prototype.getSerializer=s(function(t){var a=g.resolve(Me);return P(a,t),a},"getSerializer"),e.prototype.ready=s(function(t){var a=this,o=a._driverSet.then(function(){return a._ready===null&&(a._ready=a._initDriver()),a._ready});return P(o,t,t),o},"ready"),e.prototype.setDriver=s(function(t,a,o){var n=this;ht(t)||(t=[t]);var u=this._getSupportedDrivers(t);function c(){n._config.driver=n.driver()}s(c,"setDriverToConfig");function l(b){return n._extend(b),c(),n._ready=n._initStorage(n._config),n._ready}s(l,"extendSelfWithDriver");function d(b){return function(){var w=0;function A(){for(;w<b.length;){var I=b[w];return w++,n._dbInfo=null,n._ready=null,n.getDriver(I).then(l).catch(A)}c();var F=new Error("No available storage method found.");return n._driverSet=g.reject(F),n._driverSet}return s(A,"driverPromiseLoop"),A()}}s(d,"initDriver");var y=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=y.then(function(){var b=u[0];return n._dbInfo=null,n._ready=null,n.getDriver(b).then(function(w){n._driver=w._driver,c(),n._wrapLibraryMethodsWithReady(),n._initDriver=d(u)})}).catch(function(){c();var b=new Error("No available storage method found.");return n._driverSet=g.reject(b),n._driverSet}),P(this._driverSet,a,o),this._driverSet},"setDriver"),e.prototype.supports=s(function(t){return!!vt[t]},"supports"),e.prototype._extend=s(function(t){Ye(this,t)},"_extend"),e.prototype._getSupportedDrivers=s(function(t){for(var a=[],o=0,n=t.length;o<n;o++){var u=t[o];this.supports(u)&&a.push(u)}return a},"_getSupportedDrivers"),e.prototype._wrapLibraryMethodsWithReady=s(function(){for(var t=0,a=ke.length;t<a;t++)yr(this,ke[t])},"_wrapLibraryMethodsWithReady"),e.prototype.createInstance=s(function(t){return new e(t)},"createInstance"),e}(),mr=new pr;v.exports=mr},{"3":3}]},{},[4])(4)})});var pt=s(p=>p==null,"isNil");var mt=(p=>(i=12)=>Number(`${p++}`.padStart(i,"0")))(Date.now());var ve=class{constructor(){this.value=mt()}};s(ve,"SchemaId");var Cr=s(p=>{switch(p){case Number:return 0;case Boolean:return!1;case String:return"";case Array:case Float32Array:case Float64Array:case Int8Array:case Int16Array:case Int32Array:case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:return new p;case ArrayBuffer:return new p(0);default:return null}},"getDefaultValue"),He=s((p,i)=>{try{return i instanceof p||typeof i===p.name.toLowerCase()}catch{return!1}},"isSameValueType"),ne=class{constructor(i,f=!1,h=null){this.type=i;this.required=f;this.defaultValue=h;if(h!==null&&!He(i,h))throw new Error(`Default value "${h}" does not match type "${i.name}"`);this.defaultValue=h??Cr(this.type)}toJSON(){return{type:this.type instanceof se?this.type.toJSON():this.type.name,required:this.required,defaultValue:this.defaultValue}}toString(){return JSON.stringify(this.toJSON(),null,4)}};s(ne,"SchemaValue");var Ae,$,Ie,De,he=class{constructor(i,f=null,h=!0){J(this,Ae,["id","createdDate","lastUpdatedDate"]);J(this,$,{id:new ne(ve,!1),createdDate:new ne(Date,!1),lastUpdatedDate:new ne(Date,!1)});J(this,Ie,void 0);J(this,De,!0);if(K(this,Ie,i),K(this,De,h),h||K(this,$,{}),f){for(let v in f)if(f.hasOwnProperty(v))if(f[v]instanceof ne)E(this,Ae).includes(v)||(E(this,$)[v]=f[v]);else throw new Error(`Field "${v}" is not a SchemaValue`)}}get name(){return E(this,Ie)}get includeDefaultKeys(){return E(this,De)}get defaultKeys(){return E(this,Ae)}defineField(i,f,{defaultValue:h,required:v}={defaultValue:null,required:!1}){E(this,$)[`${i}`]=new ne(f,v,h)}removeField(i){if(i){let[f,...h]=`${i}`.split("."),v=E(this,$)[f];v&&(h.length?v.type instanceof he&&v.type.removeField(h.join(".")):delete E(this,$)[f])}}hasField(i){if(i){let[f,...h]=`${i}`.split("."),v=E(this,$)[f];if(v)if(h.length){if(v.type instanceof he)return v.type.hasField(h.join("."))}else return E(this,$).hasOwnProperty(f)}return!1}getField(i){if(i){let[f,...h]=`${i}`.split("."),v=E(this,$)[f];return v&&h.length&&v.type instanceof he?v.type.getField(h.join(".")):v??null}return null}isValidFieldValue(i,f=null){let h=this.getField(`${i}`);return h?f instanceof Array&&f.some(v=>!Nr(v))?!1:h.type instanceof he?`${f}`=="[object Object]"&&h.type.getInvalidSchemaDataFields(f).length===0:h.required?!pt(f)&&He(h.type,f):f===null||f===h.defaultValue||He(h.type,f):!1}getInvalidSchemaDataFields(i){let f=new Set,h=Object.keys(E(this,$)).filter(v=>E(this,$)[v].required);for(let v of[...Object.keys(i),...h])if(!this.defaultKeys.includes(v)){let x=this.getField(v);if(x?.type instanceof he){let N=i[v];`${N}`=="[object Object]"?x.type.getInvalidSchemaDataFields(N).map(k=>{f.add(`${v}.${k}`)}):f.add(v);continue}this.isValidFieldValue(v,i[v])||f.add(v)}return Array.from(f)}toJSON(){let i={};for(let f in E(this,$))if(E(this,$).hasOwnProperty(f)){let h=E(this,$)[f];i[f]=h.toJSON()}return i}toString(){return JSON.stringify(this.toJSON(),null,4)}toValue(){let i=new Date,f=this.includeDefaultKeys?{id:new ve().value,createdDate:i,lastUpdatedDate:i}:{};for(let h in E(this,$))if(E(this,$).hasOwnProperty(h)&&!this.defaultKeys.includes(h)){let v=E(this,$)[h];switch(!0){case v.type instanceof he:f[h]=v.type.toValue();break;case v.type instanceof Date:f[h]=v.defaultValue??new Date;break;default:f[h]=v.defaultValue}}return f}},se=he;s(se,"Schema"),Ae=new WeakMap,$=new WeakMap,Ie=new WeakMap,De=new WeakMap;function Nr(p){return p===null||[se,ve,Date,Number,String,Boolean,Array,ArrayBuffer,Blob,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array].some(i=>p instanceof i||typeof p===i.name.toLowerCase())}s(Nr,"isSupportedTypeValue");var Z=Rr(bt());var ue=s((p,i)=>typeof i=="function"?i(null,p):Promise.resolve(p),"callBackOrPromise"),Be="Memory",Et=s(()=>{let p=new Map;return{_driver:Be,_initStorage(){return p},async clear(i){ue(p.clear(),i)},async getItem(i,f){return ue(p.get(i)??null,f)||null},async iterate(i,f){let h=0,v;for(let[x,N]of p.entries()){if(v=i(N,x,h),v!==void 0)return ue(v,f);h+=1}return ue(null,f)},async key(i,f){return ue(Array.from(p.keys())[i],f)||""},async keys(i){return ue(Array.from(p.keys()),i)||[]},async length(i){return ue(p.size,i)||0},async removeItem(i,f){return ue(p.delete(i),f)},async setItem(i,f,h){return ue(p.set(i,f),h)}}},"MemoryStore");Z.default.defineDriver(Et());var St={version:1,type:[Z.INDEXEDDB,Z.WEBSQL,Z.LOCALSTORAGE,Be],description:"",appName:"App"},M,fe,Re,re,me,ce,Ce,ge,W,j,C=class{constructor(i,f,h=St){J(this,W);J(this,M,void 0);J(this,fe,void 0);J(this,Re,void 0);J(this,re,void 0);J(this,me,[]);J(this,ce,s(()=>!0,"#beforeChangeHandler"));J(this,Ce,!1);J(this,ge,0);if(K(this,Re,i),K(this,fe,{...St,...h}),!(f instanceof se))throw new Error('Missing or unknown "Schema"');let v=E(this,fe).appName||"App";K(this,re,f),K(this,M,Z.default.createInstance({driver:E(this,fe).type,version:E(this,fe).version,description:E(this,fe).description,name:v,storeName:i})),E(this,M).ready(()=>{console.info(`[Info] ClientStore "${i}" successfully created`),K(this,Ce,!0),H(this,W,j).call(this,C.EventType.READY,!0)})}get ready(){return E(this,Ce)}get type(){return E(this,M).driver()}get name(){return`${E(this,fe).appName}-${E(this,Re)}`}get size(){return E(this,ge)}subscribe(i){return typeof i=="function"&&E(this,me).push(i),()=>{K(this,me,E(this,me).filter(f=>f!==i))}}beforeChange(i){return typeof i=="function"&&K(this,ce,i),()=>{K(this,ce,()=>!0)}}async loadItems(i=[]){if(i.length){let f=new Set(await E(this,M).keys());return Promise.all(i.map(h=>f.has(`${h.id}`)?this.updateItem(h.id,h):this.createItem(h)))}return null}async createItem(i){let f=E(this,re).getInvalidSchemaDataFields(i);if(!f.length){let h=E(this,re).toValue();for(let v in i)i.hasOwnProperty(v)&&!E(this,re).defaultKeys.includes(v)&&(h[v]=i[v]);try{if(await E(this,ce).call(this,C.EventType.CREATED,h)===!0)return await E(this,M).setItem(`${h.id}`,h),K(this,ge,await E(this,M).length()),H(this,W,j).call(this,C.EventType.CREATED,h),h;H(this,W,j).call(this,C.EventType.ABORTED,{action:C.EventType.CREATED,data:i})}catch(v){console.error(`Failed to create item "${i}"`,v),H(this,W,j).call(this,C.EventType.ERROR,{action:C.EventType.CREATED,error:v,data:h})}return null}throw new Error(`Failed to create item. Field(s) "${f.join(", ")}" do not match the schema: ${E(this,re)}`)}async updateItem(i,f){for(let x in f)if(f.hasOwnProperty(x)&&!E(this,re).defaultKeys.includes(x)&&!E(this,re).isValidFieldValue(x,f[x]))throw new Error(`Failed to update item "${i}". Key "${x}" is unknown or has invalid value type: ${E(this,re).getField(x)}`);let h=await this.getItem(i),v={...h,...f,createdDate:h.createdDate,lastUpdatedDate:new Date,id:h.id};try{if(await E(this,ce).call(this,C.EventType.UPDATED,v)===!0)return await E(this,M).setItem(`${h.id}`,v),H(this,W,j).call(this,C.EventType.UPDATED,v),v;H(this,W,j).call(this,C.EventType.ABORTED,{action:C.EventType.UPDATED,data:v})}catch(x){console.error(`Failed to update item "${h}"`,x),H(this,W,j).call(this,C.EventType.ERROR,{action:C.EventType.UPDATED,error:x,data:v})}return null}async getItems(){return this.findItems(()=>!0)}getItem(i){return E(this,M).getItem(`${i}`)}async removeItem(i){try{if(await E(this,ce).call(this,C.EventType.DELETED,i)===!0)return await E(this,M).removeItem(`${i}`),K(this,ge,await E(this,M).length()),H(this,W,j).call(this,C.EventType.DELETED,i),!0;H(this,W,j).call(this,C.EventType.ABORTED,{action:C.EventType.DELETED,data:i})}catch(f){console.error(`Failed to delete item with id "${i}"`,f),H(this,W,j).call(this,C.EventType.ERROR,{action:C.EventType.DELETED,error:f,data:i})}return null}async clear(){let i=(await E(this,M).keys()).map(Number);try{if(await E(this,ce).call(this,C.EventType.CLEARED,i))return await E(this,M).clear(),K(this,ge,await E(this,M).length()),H(this,W,j).call(this,C.EventType.CLEARED,i),i;H(this,W,j).call(this,C.EventType.ABORTED,{action:C.EventType.CLEARED,data:i})}catch(f){console.error("Failed to clear the store",f),H(this,W,j).call(this,C.EventType.ERROR,{action:C.EventType.CLEARED,error:f,data:i})}return null}async findItem(i=()=>!1){return E(this,M).iterate((f,h)=>{if(i(f,h))return f})||null}async findItems(i=()=>!1){let f=[];return await E(this,M).iterate((h,v)=>{i(h,v)&&h&&f.push(h)}),f}},ye=C;s(ye,"ClientStore"),M=new WeakMap,fe=new WeakMap,Re=new WeakMap,re=new WeakMap,me=new WeakMap,ce=new WeakMap,Ce=new WeakMap,ge=new WeakMap,W=new WeakSet,j=s(function(i,f){E(this,me).forEach(h=>h(i,f))},"#broadcast");(f=>{let p;(O=>(O.READY="ready",O.CREATED="created",O.ERROR="error",O.ABORTED="aborted",O.DELETED="deleted",O.UPDATED="updated",O.CLEARED="cleared"))(p=f.EventType||(f.EventType={})),f.Type={LOCALSTORAGE:Z.LOCALSTORAGE,WEBSQL:Z.WEBSQL,INDEXEDDB:Z.INDEXEDDB,MEMORY_STORAGE:Be}})(ye||(ye={}));window&&(window.Schema=se,window.SchemaValue=ne,window.SchemaId=ve,window.ClientStore=ye);})();
/*!

@@ -3,0 +3,0 @@ localForage -- Offline Storage, Improved

import { Schema } from "./Schema";
export declare type StoreSubscriber = (eventType: ClientStore.EventType, id?: number | null) => void;
export declare type StoreUnSubscriber = () => void;
export declare class ClientStore<T extends Schema.DefaultValue> {
#private;
constructor(storeName: string, schema: Schema<T>, config?: ClientStore.Config, whenReady?: () => void);
constructor(storeName: string, schema: Schema<T>, config?: ClientStore.Config);
get ready(): boolean;

@@ -11,13 +9,18 @@ get type(): string;

get size(): number;
subscribe(sub: StoreSubscriber): StoreUnSubscriber;
createItem(value: Partial<T>): Promise<T>;
updateItem(id: T['id'], data: Partial<T>): Promise<any>;
getItems(): Promise<Array<T | null>>;
subscribe(sub: ClientStore.StoreSubscriber): ClientStore.UnSubscriber;
beforeChange(handler: ClientStore.BeforeChangeHandler): ClientStore.UnSubscriber;
loadItems(items?: Partial<T>[]): Promise<Array<T | null> | null>;
createItem(value: Partial<T>): Promise<T | null>;
updateItem(id: T['id'], data: Partial<T>): Promise<T | null>;
getItems(): Promise<Array<T>>;
getItem(id: T['id']): Promise<T | null>;
removeItem(id: T['id']): Promise<void>;
clear(): Promise<void>;
removeItem(id: T['id']): Promise<true | null>;
clear(): Promise<number[] | null>;
findItem(cb?: (value: T, key: string) => boolean): Promise<any>;
findAllItems(cb?: (value: T, key: string) => boolean): Promise<T[]>;
findItems(cb?: (value: T, key: string) => boolean): Promise<T[]>;
}
export declare namespace ClientStore {
type StoreSubscriber = (eventType: ClientStore.EventType, id?: number | number[] | null) => void;
type UnSubscriber = () => void;
type BeforeChangeHandler = (eventType: ClientStore.EventType, data: any) => Promise<boolean> | boolean;
interface Config {

@@ -30,6 +33,9 @@ appName?: string;

enum EventType {
CREATE = "created",
DELETE = "deleted",
UPDATE = "updated",
CLEAR = "cleared"
READY = "ready",
CREATED = "created",
ERROR = "error",
ABORTED = "aborted",
DELETED = "deleted",
UPDATED = "updated",
CLEARED = "cleared"
}

@@ -36,0 +42,0 @@ const Type: {

@@ -36,3 +36,3 @@ "use strict";

};
var _ClientStore_instances, _ClientStore_store, _ClientStore_config, _ClientStore_storeName, _ClientStore_schema, _ClientStore_subscribers, _ClientStore_ready, _ClientStore_size, _ClientStore_broadcast;
var _ClientStore_instances, _ClientStore_store, _ClientStore_config, _ClientStore_storeName, _ClientStore_schema, _ClientStore_subscribers, _ClientStore_beforeChangeHandler, _ClientStore_ready, _ClientStore_size, _ClientStore_broadcast;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -43,5 +43,6 @@ exports.ClientStore = void 0;

const MemoryStore_1 = require("./MemoryStore");
localforage_1.default.defineDriver((0, MemoryStore_1.MemoryStore)());
const defaultConfig = {
version: 1,
type: [localforage_1.INDEXEDDB, localforage_1.WEBSQL, localforage_1.LOCALSTORAGE],
type: [localforage_1.INDEXEDDB, localforage_1.WEBSQL, localforage_1.LOCALSTORAGE, MemoryStore_1.MEMORY_STORAGE],
description: "",

@@ -51,4 +52,3 @@ appName: "App",

class ClientStore {
constructor(storeName, schema, config = defaultConfig, whenReady = () => {
}) {
constructor(storeName, schema, config = defaultConfig) {
_ClientStore_instances.add(this);

@@ -60,2 +60,3 @@ _ClientStore_store.set(this, void 0);

_ClientStore_subscribers.set(this, []);
_ClientStore_beforeChangeHandler.set(this, () => true);
_ClientStore_ready.set(this, false);

@@ -80,5 +81,3 @@ _ClientStore_size.set(this, 0);

__classPrivateFieldSet(this, _ClientStore_ready, true, "f");
if (typeof whenReady === 'function') {
whenReady();
}
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.READY, true);
});

@@ -106,2 +105,22 @@ }

}
beforeChange(handler) {
if (typeof handler === 'function') {
__classPrivateFieldSet(this, _ClientStore_beforeChangeHandler, handler, "f");
}
return () => {
__classPrivateFieldSet(this, _ClientStore_beforeChangeHandler, () => true, "f");
};
}
async loadItems(items = []) {
if (items.length) {
const keys = new Set(await __classPrivateFieldGet(this, _ClientStore_store, "f").keys());
return Promise.all(items.map(item => {
if (keys.has(`${item.id}`)) {
return this.updateItem(item.id, item);
}
return this.createItem(item);
}));
}
return null;
}
async createItem(value) {

@@ -117,10 +136,25 @@ const invalidFields = __classPrivateFieldGet(this, _ClientStore_schema, "f").getInvalidSchemaDataFields(value);

try {
await __classPrivateFieldGet(this, _ClientStore_store, "f").setItem(`${newItem.id}`, newItem);
__classPrivateFieldSet(this, _ClientStore_size, await __classPrivateFieldGet(this, _ClientStore_store, "f").length(), "f");
const shouldChange = await __classPrivateFieldGet(this, _ClientStore_beforeChangeHandler, "f").call(this, ClientStore.EventType.CREATED, newItem);
if (shouldChange === true) {
await __classPrivateFieldGet(this, _ClientStore_store, "f").setItem(`${newItem.id}`, newItem);
__classPrivateFieldSet(this, _ClientStore_size, await __classPrivateFieldGet(this, _ClientStore_store, "f").length(), "f");
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.CREATED, newItem);
return newItem;
}
else {
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.ABORTED, {
action: ClientStore.EventType.CREATED,
data: value
});
}
}
catch (error) {
console.error(`Failed to create item "${value}"`, error);
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.ERROR, {
action: ClientStore.EventType.CREATED,
error,
data: newItem
});
}
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.CREATE, newItem.id);
return newItem;
return null;
}

@@ -139,2 +173,3 @@ throw new Error(`Failed to create item. Field(s) "${invalidFields.join(', ')}" do not match the schema: ${__classPrivateFieldGet(this, _ClientStore_schema, "f")}`);

...data,
createdDate: item.createdDate,
lastUpdatedDate: new Date(),

@@ -144,13 +179,27 @@ id: item.id

try {
await __classPrivateFieldGet(this, _ClientStore_store, "f").setItem(`${item.id}`, updatedItem);
const shouldChange = await __classPrivateFieldGet(this, _ClientStore_beforeChangeHandler, "f").call(this, ClientStore.EventType.UPDATED, updatedItem);
if (shouldChange === true) {
await __classPrivateFieldGet(this, _ClientStore_store, "f").setItem(`${item.id}`, updatedItem);
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.UPDATED, updatedItem);
return updatedItem;
}
else {
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.ABORTED, {
action: ClientStore.EventType.UPDATED,
data: updatedItem
});
}
}
catch (error) {
console.error(`Failed to update item "${item}"`, error);
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.ERROR, {
action: ClientStore.EventType.UPDATED,
error,
data: updatedItem
});
}
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.UPDATE, id);
return updatedItem;
return null;
}
async getItems() {
const keys = await __classPrivateFieldGet(this, _ClientStore_store, "f").keys();
return Promise.all(keys.map(key => __classPrivateFieldGet(this, _ClientStore_store, "f").getItem(key)));
return this.findItems(() => true);
}

@@ -160,13 +209,54 @@ getItem(id) {

}
removeItem(id) {
return __classPrivateFieldGet(this, _ClientStore_store, "f").removeItem(`${id}`).then(async () => {
__classPrivateFieldSet(this, _ClientStore_size, await __classPrivateFieldGet(this, _ClientStore_store, "f").length(), "f");
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.DELETE, id);
});
async removeItem(id) {
try {
const shouldChange = await __classPrivateFieldGet(this, _ClientStore_beforeChangeHandler, "f").call(this, ClientStore.EventType.DELETED, id);
if (shouldChange === true) {
await __classPrivateFieldGet(this, _ClientStore_store, "f").removeItem(`${id}`);
__classPrivateFieldSet(this, _ClientStore_size, await __classPrivateFieldGet(this, _ClientStore_store, "f").length(), "f");
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.DELETED, id);
return true;
}
else {
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.ABORTED, {
action: ClientStore.EventType.DELETED,
data: id
});
}
}
catch (error) {
console.error(`Failed to delete item with id "${id}"`, error);
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.ERROR, {
action: ClientStore.EventType.DELETED,
error,
data: id
});
}
return null;
}
clear() {
return __classPrivateFieldGet(this, _ClientStore_store, "f").clear().then(async () => {
__classPrivateFieldSet(this, _ClientStore_size, await __classPrivateFieldGet(this, _ClientStore_store, "f").length(), "f");
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.CLEAR);
});
async clear() {
const keys = (await __classPrivateFieldGet(this, _ClientStore_store, "f").keys()).map(Number);
try {
const shouldChange = await __classPrivateFieldGet(this, _ClientStore_beforeChangeHandler, "f").call(this, ClientStore.EventType.CLEARED, keys);
if (shouldChange) {
await __classPrivateFieldGet(this, _ClientStore_store, "f").clear();
__classPrivateFieldSet(this, _ClientStore_size, await __classPrivateFieldGet(this, _ClientStore_store, "f").length(), "f");
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.CLEARED, keys);
return keys;
}
else {
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.ABORTED, {
action: ClientStore.EventType.CLEARED,
data: keys
});
}
}
catch (error) {
console.error(`Failed to clear the store`, error);
__classPrivateFieldGet(this, _ClientStore_instances, "m", _ClientStore_broadcast).call(this, ClientStore.EventType.ERROR, {
action: ClientStore.EventType.CLEARED,
error,
data: keys
});
}
return null;
}

@@ -181,3 +271,3 @@ async findItem(cb = () => false) {

}
async findAllItems(cb = () => false) {
async findItems(cb = () => false) {
const items = [];

@@ -193,4 +283,4 @@ await __classPrivateFieldGet(this, _ClientStore_store, "f").iterate((value, key) => {

exports.ClientStore = ClientStore;
_ClientStore_store = new WeakMap(), _ClientStore_config = new WeakMap(), _ClientStore_storeName = new WeakMap(), _ClientStore_schema = new WeakMap(), _ClientStore_subscribers = new WeakMap(), _ClientStore_ready = new WeakMap(), _ClientStore_size = new WeakMap(), _ClientStore_instances = new WeakSet(), _ClientStore_broadcast = function _ClientStore_broadcast(eventType, id = null) {
__classPrivateFieldGet(this, _ClientStore_subscribers, "f").forEach(sub => sub(eventType, id));
_ClientStore_store = new WeakMap(), _ClientStore_config = new WeakMap(), _ClientStore_storeName = new WeakMap(), _ClientStore_schema = new WeakMap(), _ClientStore_subscribers = new WeakMap(), _ClientStore_beforeChangeHandler = new WeakMap(), _ClientStore_ready = new WeakMap(), _ClientStore_size = new WeakMap(), _ClientStore_instances = new WeakSet(), _ClientStore_broadcast = function _ClientStore_broadcast(eventType, data) {
__classPrivateFieldGet(this, _ClientStore_subscribers, "f").forEach(sub => sub(eventType, data));
};

@@ -200,6 +290,9 @@ (function (ClientStore) {

(function (EventType) {
EventType["CREATE"] = "created";
EventType["DELETE"] = "deleted";
EventType["UPDATE"] = "updated";
EventType["CLEAR"] = "cleared";
EventType["READY"] = "ready";
EventType["CREATED"] = "created";
EventType["ERROR"] = "error";
EventType["ABORTED"] = "aborted";
EventType["DELETED"] = "deleted";
EventType["UPDATED"] = "updated";
EventType["CLEARED"] = "cleared";
})(EventType = ClientStore.EventType || (ClientStore.EventType = {}));

@@ -206,0 +299,0 @@ ClientStore.Type = {

export { Schema, SchemaValue, SchemaId } from './Schema';
export { ClientStore, StoreUnSubscriber, StoreSubscriber } from './ClientStore';
export { ClientStore } from './ClientStore';

@@ -25,3 +25,3 @@ export declare class SchemaId {

getField(name: string | keyof T): SchemaValue | null;
isValidFieldValue(name: keyof T, value?: any): boolean;
isValidFieldValue(name: string | keyof T, value?: any): boolean;
getInvalidSchemaDataFields(value: {

@@ -28,0 +28,0 @@ [k: string]: any;

@@ -168,4 +168,4 @@ "use strict";

isValidFieldValue(name, value = null) {
if (__classPrivateFieldGet(this, _Schema_obj, "f").hasOwnProperty(name)) {
const val = __classPrivateFieldGet(this, _Schema_obj, "f")[`${name}`];
const val = this.getField(`${name}`);
if (val) {
if (value instanceof Array && value.some(v => !isSupportedTypeValue(v))) {

@@ -172,0 +172,0 @@ return false;

{
"name": "client-web-storage",
"description": "Web browser (client) storage interface for IndexedDB, WebSQL, LocalStorage, and in memory data with Schema validation.",
"version": "1.2.1-beta",
"main": "dist/index.js",
"version": "1.2.1",
"main": "dist/",
"repository": {

@@ -7,0 +7,0 @@ "url": "https://github.com/beforesemicolon/client-web-storage",

@@ -6,2 +6,66 @@ # Client Web Storage

## Documentation
### In Node Projects:
```bash
npm install client-web-storage
```
```js
import {Schema, ClientStore} from "client-web-storage";
```
### In the Browser
```html
<!-- use the latest version -->
<script src="https://unpkg.com/client-web-storage/dist/client-web-storage.min.js"></script>
<!-- use a specific version -->
<script src="https://unpkg.com/client-web-storage@1.0.0/dist/client-web-storage.min.js"></script>
```
```js
const {Schema, ClientStore} = window;
```
## Get Started
The library is very small but super powerful. There are only few things to interact with:
- **[Schema](https://github.com/beforesemicolon/client-web-storage/blob/main/docs/Schema.md)** : Determines how the data looks like;
- **[SchemaValue](https://github.com/beforesemicolon/client-web-storage/blob/main/docs/SchemaValue.md)** : Creates a single value in the schema;
- **[ClientStore](https://github.com/beforesemicolon/client-web-storage/blob/main/docs/ClientStore.md)** : Manages the data (CRUD);
```ts
// Define schema TS type
import {ClientStore, Schema} from "client-web-storage";
interface ToDo extends Schema.DefaultValue {
name: string;
description: string;
complete: boolean;
}
// create and define schema
const todoShema = new Schema<ToDo>("todo");
todoShema.defineField("name", String, {required: true});
todoShema.defineField("description", String);
todoShema.defineField("complete", Boolean);
// create and use the store
const todoStore = new ClientStore("todos", todoShema);
todoStore.createItem({
name: "Go to Gym" // only name is required
});
/* Creates item in the store
{
id: 3284732894792342, // generated id
name: "Go to Gym",
description: "",
complete: false,
createdDate: "January, 4th 2022",
lastUpdatedDate: "January, 4th 2022",
}
*/
```