@subwallet/web-runner 1.3.2-0 → 1.3.4-0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- (()=>{"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,n=Object.keys,r=Array.isArray;function s(e,t){return"object"!=typeof t||n(t).forEach((function(n){e[n]=t[n]})),e}"undefined"==typeof Promise||t.Promise||(t.Promise=Promise);const i=Object.getPrototypeOf,a={}.hasOwnProperty;function o(e,t){return a.call(e,t)}function l(e,t){"function"==typeof t&&(t=t(i(e))),("undefined"==typeof Reflect?n:Reflect.ownKeys)(t).forEach((n=>{u(e,n,t[n])}))}const c=Object.defineProperty;function u(e,t,n,r){c(e,t,s(n&&o(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function h(e){return{from:function(t){return e.prototype=Object.create(t.prototype),u(e.prototype,"constructor",e),{extend:l.bind(null,e.prototype)}}}}const d=Object.getOwnPropertyDescriptor;function f(e,t){let n;return d(e,t)||(n=i(e))&&f(n,t)}const y=[].slice;function p(e,t,n){return y.call(e,t,n)}function m(e,t){return t(e)}function g(e){if(!e)throw new Error("Assertion Failed")}function v(e){t.setImmediate?setImmediate(e):setTimeout(e,0)}function b(e,t){return e.reduce(((e,n,r)=>{var s=t(n,r);return s&&(e[s[0]]=s[1]),e}),{})}function w(e,t){if(o(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,s=t.length;r<s;++r){var i=w(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var l=e[t.substr(0,a)];return void 0===l?void 0:w(l,t.substr(a+1))}}function _(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){g("string"!=typeof n&&"length"in n);for(var s=0,i=t.length;s<i;++s)_(e,t[s],n[s])}else{var a=t.indexOf(".");if(-1!==a){var l=t.substr(0,a),c=t.substr(a+1);if(""===c)void 0===n?r(e)&&!isNaN(parseInt(l))?e.splice(l,1):delete e[l]:e[l]=n;else{var u=e[l];u&&o(e,l)||(u=e[l]={}),_(u,c,n)}}else void 0===n?r(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function k(e){var t={};for(var n in e)o(e,n)&&(t[n]=e[n]);return t}const x=[].concat;function E(e){return x.apply([],e)}const S="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(E([8,16,32,64].map((e=>["Int","Uint","Float"].map((t=>t+e+"Array")))))).filter((e=>t[e])),P=S.map((e=>t[e]));b(S,(e=>[e,!0]));let O=null;function K(e){O="undefined"!=typeof WeakMap&&new WeakMap;const t=j(e);return O=null,t}function j(e){if(!e||"object"!=typeof e)return e;let t=O&&O.get(e);if(t)return t;if(r(e)){t=[],O&&O.set(e,t);for(var n=0,s=e.length;n<s;++n)t.push(j(e[n]))}else if(P.indexOf(e.constructor)>=0)t=e;else{const n=i(e);for(var a in t=n===Object.prototype?{}:Object.create(n),O&&O.set(e,t),e)o(e,a)&&(t[a]=j(e[a]))}return t}const{toString:C}={};function R(e){return C.call(e).slice(8,-1)}const A="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",I="symbol"==typeof A?function(e){var t;return null!=e&&(t=e[A])&&t.apply(e)}:function(){return null},D={};function T(e){var t,n,s,i;if(1===arguments.length){if(r(e))return e.slice();if(this===D&&"string"==typeof e)return[e];if(i=I(e)){for(n=[];!(s=i.next()).done;)n.push(s.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}const B="undefined"!=typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var F="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function M(e,t){F=e,N=t}var N=()=>!0;const q=!new Error("").stack;function $(){if(q)try{throw $.arguments,new Error}catch(e){return e}return new Error}function V(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(N).map((e=>"\n"+e)).join("")):""}var U=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],L=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(U),W={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function H(e,t){this._e=$(),this.name=e,this.message=t}function Y(e,t){return e+". Errors: "+Object.keys(t).map((e=>t[e].toString())).filter(((e,t,n)=>n.indexOf(e)===t)).join("\n")}function z(e,t,n,r){this._e=$(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=Y(e,t)}function G(e,t){this._e=$(),this.name="BulkError",this.failures=Object.keys(t).map((e=>t[e])),this.failuresByPos=t,this.message=Y(e,t)}h(H).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+V(this._e,2))}},toString:function(){return this.name+": "+this.message}}),h(z).from(H),h(G).from(H);var J=L.reduce(((e,t)=>(e[t]=t+"Error",e)),{});const Q=H;var X=L.reduce(((e,t)=>{var n=t+"Error";function r(e,r){this._e=$(),this.name=n,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=W[t]||n,this.inner=null)}return h(r).from(Q),e[t]=r,e}),{});X.Syntax=SyntaxError,X.Type=TypeError,X.Range=RangeError;var Z=U.reduce(((e,t)=>(e[t+"Error"]=X[t],e)),{}),ee=L.reduce(((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=X[t]),e)),{});function te(){}function ne(e){return e}function re(e,t){return null==e||e===ne?t:function(n){return t(e(n))}}function se(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ie(e,t){return e===te?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?se(r,this.onsuccess):r),s&&(this.onerror=this.onerror?se(s,this.onerror):s),void 0!==i?i:n}}function ae(e,t){return e===te?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?se(n,this.onsuccess):n),r&&(this.onerror=this.onerror?se(r,this.onerror):r)}}function oe(e,t){return e===te?t:function(n){var r=e.apply(this,arguments);s(n,r);var i=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?se(i,this.onsuccess):i),a&&(this.onerror=this.onerror?se(a,this.onerror):a),void 0===r?void 0===o?void 0:o:s(r,o)}}function le(e,t){return e===te?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ce(e,t){return e===te?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,s=arguments.length,i=new Array(s);s--;)i[s]=arguments[s];return n.then((function(){return t.apply(r,i)}))}return t.apply(this,arguments)}}ee.ModifyError=z,ee.DexieError=H,ee.BulkError=G;var ue={};const[he,de,fe]="undefined"==typeof Promise?[]:(()=>{let e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,i(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,i(t),e]})(),ye=de&&de.then,pe=he&&he.constructor,me=!!fe;var ge=!1,ve=fe?()=>{fe.then($e)}:t.setImmediate?setImmediate.bind(null,$e):t.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver((()=>{$e(),e=null})).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout($e,0)},be=function(e,t){Ke.push([e,t]),_e&&(ve(),_e=!1)},we=!0,_e=!0,ke=[],xe=[],Ee=null,Se=ne,Pe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ht,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach((e=>{try{ht(e[0],e[1])}catch(e){}}))}},Oe=Pe,Ke=[],je=0,Ce=[];function Re(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=te,this._lib=!1;var t=this._PSD=Oe;if(F&&(this._stackHolder=$(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==ue)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Te(this,this._value))}this._state=null,this._value=null,++t.ref,De(this,e)}const Ae={get:function(){var e=Oe,t=Qe;function n(n,r){var s=!e.global&&(e!==Oe||t!==Qe);const i=s&&!tt();var a=new Re(((t,a)=>{Fe(this,new Ie(ct(n,e,s,i),ct(r,e,s,i),t,a,e))}));return F&&qe(a,this),a}return n.prototype=ue,n},set:function(e){u(this,"then",e&&e.prototype===ue?Ae:{get:function(){return e},set:Ae.set})}};function Ie(e,t,n,r,s){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=s}function De(e,t){try{t((t=>{if(null===e._state){if(t===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&Ve();t&&"function"==typeof t.then?De(e,((e,n)=>{t instanceof Re?t._then(e,n):t.then(e,n)})):(e._state=!0,e._value=t,Be(e)),n&&Ue()}}),Te.bind(null,e))}catch(t){Te(e,t)}}function Te(e,t){if(xe.push(t),null===e._state){var n=e._lib&&Ve();t=Se(t),e._state=!1,e._value=t,F&&null!==t&&"object"==typeof t&&!t._promise&&function(e,t,n){try{e.apply(null,void 0)}catch(e){}}((()=>{var n=f(t,"stack");t._promise=e,u(t,"stack",{get:()=>ge?n&&(n.get?n.get.apply(t):n.value):e.stack})})),function(e){ke.some((t=>t._value===e._value))||ke.push(e)}(e),Be(e),n&&Ue()}}function Be(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Fe(e,t[n]);var s=e._PSD;--s.ref||s.finalize(),0===je&&(++je,be((()=>{0==--je&&Le()}),[]))}function Fe(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++je,be(Me,[n,e,t])}else e._listeners.push(t)}function Me(e,t,n){try{Ee=t;var r,s=t._value;t._state?r=e(s):(xe.length&&(xe=[]),r=e(s),-1===xe.indexOf(s)&&function(e){for(var t=ke.length;t;)if(ke[--t]._value===e._value)return void ke.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{Ee=null,0==--je&&Le(),--n.psd.ref||n.psd.finalize()}}function Ne(e,t,n){if(t.length===n)return t;var r="";if(!1===e._state){var s,i,a=e._value;null!=a?(s=a.name||"Error",i=a.message||a,r=V(a,0)):(s=a,i=""),t.push(s+(i?": "+i:"")+r)}return F&&((r=V(e._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),e._prev&&Ne(e._prev,t,n)),t}function qe(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function $e(){Ve()&&Ue()}function Ve(){var e=we;return we=!1,_e=!1,e}function Ue(){var e,t,n;do{for(;Ke.length>0;)for(e=Ke,Ke=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(Ke.length>0);we=!0,_e=!0}function Le(){var e=ke;ke=[],e.forEach((e=>{e._PSD.onunhandled.call(null,e._value,e)}));for(var t=Ce.slice(0),n=t.length;n;)t[--n]()}function We(e){return new Re(ue,!1,e)}function He(e,t){var n=Oe;return function(){var r=Ve(),s=Oe;try{return it(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{it(s,!1),r&&Ue()}}}l(Re.prototype,{then:Ae,_then:function(e,t){Fe(this,new Ie(null,null,e,t,Oe))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,(e=>e instanceof t?n(e):We(e))):this.then(null,(e=>e&&e.name===t?n(e):We(e)))},finally:function(e){return this.then((t=>(e(),t)),(t=>(e(),We(t))))},stack:{get:function(){if(this._stack)return this._stack;try{ge=!0;var e=Ne(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{ge=!1}}},timeout:function(e,t){return e<1/0?new Re(((n,r)=>{var s=setTimeout((()=>r(new X.Timeout(t))),e);this.then(n,r).finally(clearTimeout.bind(null,s))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&u(Re.prototype,Symbol.toStringTag,"Dexie.Promise"),Pe.env=at(),l(Re,{all:function(){var e=T.apply(null,arguments).map(nt);return new Re((function(t,n){0===e.length&&t([]);var r=e.length;e.forEach(((s,i)=>Re.resolve(s).then((n=>{e[i]=n,--r||t(e)}),n)))}))},resolve:e=>{if(e instanceof Re)return e;if(e&&"function"==typeof e.then)return new Re(((t,n)=>{e.then(t,n)}));var t=new Re(ue,!0,e);return qe(t,Ee),t},reject:We,race:function(){var e=T.apply(null,arguments).map(nt);return new Re(((t,n)=>{e.map((e=>Re.resolve(e).then(t,n)))}))},PSD:{get:()=>Oe,set:e=>Oe=e},totalEchoes:{get:()=>Qe},newPSD:Ze,usePSD:ot,scheduler:{get:()=>be,set:e=>{be=e}},rejectionMapper:{get:()=>Se,set:e=>{Se=e}},follow:(e,t)=>new Re(((n,r)=>Ze(((t,n)=>{var r=Oe;r.unhandleds=[],r.onunhandled=n,r.finalize=se((function(){!function(e){Ce.push((function t(){e(),Ce.splice(Ce.indexOf(t),1)})),++je,be((()=>{0==--je&&Le()}),[])}((()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])}))}),r.finalize),e()}),t,n,r)))}),pe&&(pe.allSettled&&u(Re,"allSettled",(function(){const e=T.apply(null,arguments).map(nt);return new Re((t=>{0===e.length&&t([]);let n=e.length;const r=new Array(n);e.forEach(((e,s)=>Re.resolve(e).then((e=>r[s]={status:"fulfilled",value:e}),(e=>r[s]={status:"rejected",reason:e})).then((()=>--n||t(r)))))}))})),pe.any&&"undefined"!=typeof AggregateError&&u(Re,"any",(function(){const e=T.apply(null,arguments).map(nt);return new Re(((t,n)=>{0===e.length&&n(new AggregateError([]));let r=e.length;const s=new Array(r);e.forEach(((e,i)=>Re.resolve(e).then((e=>t(e)),(e=>{s[i]=e,--r||n(new AggregateError(s))}))))}))})));const Ye={awaits:0,echoes:0,id:0};var ze=0,Ge=[],Je=0,Qe=0,Xe=0;function Ze(e,t,n,r){var i=Oe,a=Object.create(i);a.parent=i,a.ref=0,a.global=!1,a.id=++Xe;var o=Pe.env;a.env=me?{Promise:Re,PromiseProp:{value:Re,configurable:!0,writable:!0},all:Re.all,race:Re.race,allSettled:Re.allSettled,any:Re.any,resolve:Re.resolve,reject:Re.reject,nthen:ut(o.nthen,a),gthen:ut(o.gthen,a)}:{},t&&s(a,t),++i.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()};var l=ot(a,e,n,r);return 0===a.ref&&a.finalize(),l}function et(){return Ye.id||(Ye.id=++ze),++Ye.awaits,Ye.echoes+=100,Ye.id}function tt(){return!!Ye.awaits&&(0==--Ye.awaits&&(Ye.id=0),Ye.echoes=100*Ye.awaits,!0)}function nt(e){return Ye.echoes&&e&&e.constructor===pe?(et(),e.then((e=>(tt(),e)),(e=>(tt(),dt(e))))):e}function rt(e){++Qe,Ye.echoes&&0!=--Ye.echoes||(Ye.echoes=Ye.id=0),Ge.push(Oe),it(e,!0)}function st(){var e=Ge[Ge.length-1];Ge.pop(),it(e,!1)}function it(e,n){var r=Oe;if((n?!Ye.echoes||Je++&&e===Oe:!Je||--Je&&e===Oe)||lt(n?rt.bind(null,e):st),e!==Oe&&(Oe=e,r===Pe&&(Pe.env=at()),me)){var s=Pe.env.Promise,i=e.env;de.then=i.nthen,s.prototype.then=i.gthen,(r.global||e.global)&&(Object.defineProperty(t,"Promise",i.PromiseProp),s.all=i.all,s.race=i.race,s.resolve=i.resolve,s.reject=i.reject,i.allSettled&&(s.allSettled=i.allSettled),i.any&&(s.any=i.any))}}function at(){var e=t.Promise;return me?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(t,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:de.then,gthen:e.prototype.then}:{}}function ot(e,t,n,r,s){var i=Oe;try{return it(e,!0),t(n,r,s)}finally{it(i,!1)}}function lt(e){ye.call(he,e)}function ct(e,t,n,r){return"function"!=typeof e?e:function(){var s=Oe;n&&et(),it(t,!0);try{return e.apply(this,arguments)}finally{it(s,!1),r&&lt(tt)}}}function ut(e,t){return function(n,r){return e.call(this,ct(n,t),ct(r,t))}}function ht(e,n){var r;try{r=n.onuncatched(e)}catch(e){}if(!1!==r)try{var i,a={promise:n,reason:e};if(t.document&&document.createEvent?((i=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),s(i,a)):t.CustomEvent&&s(i=new CustomEvent("unhandledrejection",{detail:a}),a),i&&t.dispatchEvent&&(dispatchEvent(i),!t.PromiseRejectionEvent&&t.onunhandledrejection))try{t.onunhandledrejection(i)}catch(e){}F&&i&&!i.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+ye).indexOf("[native code]")&&(et=tt=te);var dt=Re.reject;function ft(e,t,n,r){if(e.idbdb&&(e._state.openComplete||Oe.letThrough||e._vip)){var s=e._createTransaction(t,n,e._dbSchema);try{s.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===J.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>ft(e,t,n,r)))):dt(s)}return s._promise(t,((e,t)=>Ze((()=>(Oe.trans=s,r(e,t,s)))))).then((e=>s._completion.then((()=>e))))}if(e._state.openComplete)return dt(new X.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return dt(new X.DatabaseClosed);e.open().catch(te)}return e._state.dbReadyPromise.then((()=>ft(e,t,n,r)))}const yt=String.fromCharCode(65535),pt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",mt=[],gt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),vt=gt,bt=gt,wt=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function _t(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const kt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function xt(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=K(t))[e],t)}class Et{_trans(e,t,n){const r=this._tx||Oe.trans,s=this.name;function i(e,n,r){if(!r.schema[s])throw new X.NotFound("Table "+s+" not part of transaction");return t(r.idbtrans,r)}const a=Ve();try{return r&&r.db===this.db?r===Oe.trans?r._promise(e,i,n):Ze((()=>r._promise(e,i,n)),{trans:r,transless:Oe.transless||Oe}):ft(this.db,e,[this.name],i)}finally{a&&Ue()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",(t=>this.core.get({trans:t,key:e}).then((e=>this.hook.reading.fire(e))))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(r(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const t=n(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);const s=this.schema.indexes.concat(this.schema.primKey).filter((e=>e.compound&&t.every((t=>e.keyPath.indexOf(t)>=0))&&e.keyPath.every((e=>t.indexOf(e)>=0))))[0];if(s&&this.db._maxKey!==yt)return this.where(s.name).equals(s.keyPath.map((t=>e[t])));!s&&F&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);const{idxByName:i}=this.schema,a=this.db._deps.indexedDB;function o(e,t){try{return 0===a.cmp(e,t)}catch(e){return!1}}const[l,c]=t.reduce((([t,n],s)=>{const a=i[s],l=e[s];return[t||a,t||!a?_t(n,a&&a.multi?e=>{const t=w(e,s);return r(t)&&t.some((e=>o(l,e)))}:e=>o(l,w(e,s))):n]}),[null,null]);return l?this.where(l.name).equals(e[l.keyPath]).filter(c):s?this.filter(c):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,r(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const t=t=>{if(!t)return t;const n=Object.create(e.prototype);for(var r in t)if(o(t,r))try{n[r]=t[r]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass((function(e){s(this,e)}))}add(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let s=e;return r&&n&&(s=xt(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[s]}))).then((e=>e.numFailures?Re.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{_(e,r,t)}catch(e){}return t}))}update(e,t){if("object"!=typeof e||r(e))return this.where(":id").equals(e).modify(t);{const r=w(e,this.schema.primKey.keyPath);if(void 0===r)return dt(new X.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?n(t).forEach((n=>{_(e,n,t[n])})):t(e,{value:e,primKey:r})}catch(e){}return this.where(":id").equals(r).modify(t)}}put(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let s=e;return r&&n&&(s=xt(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"put",values:[s],keys:null!=t?[t]:null}))).then((e=>e.numFailures?Re.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{_(e,r,t)}catch(e){}return t}))}delete(e){return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:[e]}))).then((e=>e.numFailures?Re.reject(e.failures[0]):void 0))}clear(){return this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"deleteRange",range:kt}))).then((e=>e.numFailures?Re.reject(e.failures[0]):void 0))}bulkGet(e){return this._trans("readonly",(t=>this.core.getMany({keys:e,trans:t}).then((e=>e.map((e=>this.hook.reading.fire(e)))))))}bulkAdd(e,t,n){const r=Array.isArray(t)?t:void 0,s=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new X.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");const a=e.length;let o=i&&n?e.map(xt(i)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:o,wantResults:s}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return s?t:n;throw new G(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,r)}))}))}bulkPut(e,t,n){const r=Array.isArray(t)?t:void 0,s=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new X.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");const a=e.length;let o=i&&n?e.map(xt(i)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:o,wantResults:s}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return s?t:n;throw new G(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,r)}))}))}bulkDelete(e){const t=e.length;return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:e}))).then((({numFailures:e,lastResult:n,failures:r})=>{if(0===e)return n;throw new G(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)}))}}function St(e){var t={},s=function(n,r){if(r){for(var s=arguments.length,i=new Array(s-1);--s;)i[s-1]=arguments[s];return t[n].subscribe.apply(null,i),e}if("string"==typeof n)return t[n]};s.addEventType=o;for(var i=1,a=arguments.length;i<a;++i)o(arguments[i]);return s;function o(e,n,r){if("object"==typeof e)return l(e);n||(n=le),r||(r=te);var i={subscribers:[],fire:r,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=n(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter((function(t){return t!==e})),i.fire=i.subscribers.reduce(n,r)}};return t[e]=s[e]=i,i}function l(e){n(e).forEach((function(t){var n=e[t];if(r(n))o(t,e[t][0],e[t][1]);else{if("asap"!==n)throw new X.InvalidArgument("Invalid event config");var s=o(t,ne,(function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];s.subscribers.forEach((function(e){v((function(){e.apply(null,t)}))}))}))}}))}}function Pt(e,t){return h(t).from({prototype:e}),t}function Ot(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Kt(e,t){e.filter=_t(e.filter,t)}function jt(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>_t(r(),t()):t,e.justLimit=n&&!r}function Ct(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new X.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Rt(e,t,n){const r=Ct(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function At(e,t,n,r){const s=e.replayFilter?_t(e.filter,e.replayFilter()):e.filter;if(e.or){const i={},a=(e,n,r)=>{if(!s||s(n,r,(e=>n.stop(e)),(e=>n.fail(e)))){var a=n.primaryKey,l=""+a;"[object ArrayBuffer]"===l&&(l=""+new Uint8Array(a)),o(i,l)||(i[l]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(a,n),It(Rt(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return It(Rt(e,r,n),_t(e.algorithm,s),t,!e.keysOnly&&e.valueMapper)}function It(e,t,n,r){var s=He(r?(e,t,s)=>n(r(e),t,s):n);return e.then((e=>{if(e)return e.start((()=>{var n=()=>e.continue();t&&!t(e,(e=>n=e),(t=>{e.stop(t),n=te}),(t=>{e.fail(t),n=te}))||s(e.value,e,(e=>n=e)),n()}))}))}function Dt(e,t){try{const n=Tt(e),r=Tt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){const n=e.length,r=t.length,s=n<r?n:r;for(let n=0;n<s;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===r?0:n<r?-1:1}(Bt(e),Bt(t));case"Array":return function(e,t){const n=e.length,r=t.length,s=n<r?n:r;for(let n=0;n<s;++n){const r=Dt(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function Tt(e){const t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";const n=R(e);return"ArrayBuffer"===n?"binary":n}function Bt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class Ft{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,dt.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,dt.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=_t(t.algorithm,e)}_iterate(e,t){return At(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&s(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read((n=>At(t,e,n,t.table.core)))}count(e){return this._read((e=>{const t=this._ctx,n=t.table.core;if(Ot(t,!0))return n.count({trans:e,query:{index:Ct(t,n.schema),range:t.range}}).then((e=>Math.min(e,t.limit)));var r=0;return At(t,(()=>(++r,!1)),e,n).then((()=>r))})).then(e)}sortBy(e,t){const n=e.split(".").reverse(),r=n[0],s=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function o(e,t){var n=i(e,s),r=i(t,s);return n<r?-a:n>r?a:0}return this.toArray((function(e){return e.sort(o)})).then(t)}toArray(e){return this._read((e=>{var t=this._ctx;if("next"===t.dir&&Ot(t,!0)&&t.limit>0){const{valueMapper:n}=t,r=Ct(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then((({result:e})=>n?e.map(n):e))}{const n=[];return At(t,(e=>n.push(e)),e,t.table.core).then((()=>n))}}),e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,Ot(t)?jt(t,(()=>{var t=e;return(e,n)=>0===t||(1===t?(--t,!1):(n((()=>{e.advance(t),t=0})),!1))})):jt(t,(()=>{var t=e;return()=>--t<0}))),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),jt(this._ctx,(()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}}),!0),this}until(e,t){return Kt(this._ctx,(function(n,r,s){return!e(n.value)||(r(s),t)})),this}first(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)}last(e){return this.reverse().first(e)}filter(e){var t,n;return Kt(this._ctx,(function(t){return e(t.value)})),t=this._ctx,n=e,t.isMatch=_t(t.isMatch,n),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.key,n)}))}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.primaryKey,n)}))}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.key)})).then((function(){return n})).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&Ot(t,!0)&&t.limit>0)return this._read((e=>{var n=Ct(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})})).then((({result:e})=>e)).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.primaryKey)})).then((function(){return n})).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys((function(e){return e[0]})).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return Kt(this._ctx,(function(e){var t=e.primaryKey.toString(),r=o(n,t);return n[t]=!0,!r})),this}modify(e){var t=this._ctx;return this._write((r=>{var s;if("function"==typeof e)s=e;else{var i=n(e),a=i.length;s=function(t){for(var n=!1,r=0;r<a;++r){var s=i[r],o=e[s];w(t,s)!==o&&(_(t,s,o),n=!0)}return n}}const o=t.table.core,{outbound:l,extractKey:c}=o.schema.primaryKey,u=this.db._options.modifyChunkSize||200,h=[];let d=0;const f=[],y=(e,t)=>{const{failures:r,numFailures:s}=t;d+=e-s;for(let e of n(r))h.push(r[e])};return this.clone().primaryKeys().then((n=>{const i=a=>{const h=Math.min(u,n.length-a);return o.getMany({trans:r,keys:n.slice(a,a+h),cache:"immutable"}).then((d=>{const f=[],p=[],m=l?[]:null,g=[];for(let e=0;e<h;++e){const t=d[e],r={value:K(t),primKey:n[a+e]};!1!==s.call(r,r.value,r)&&(null==r.value?g.push(n[a+e]):l||0===Dt(c(t),c(r.value))?(p.push(r.value),l&&m.push(n[a+e])):(g.push(n[a+e]),f.push(r.value)))}const v=Ot(t)&&t.limit===1/0&&("function"!=typeof e||e===Mt)&&{index:t.index,range:t.range};return Promise.resolve(f.length>0&&o.mutate({trans:r,type:"add",values:f}).then((e=>{for(let t in e.failures)g.splice(parseInt(t),1);y(f.length,e)}))).then((()=>(p.length>0||v&&"object"==typeof e)&&o.mutate({trans:r,type:"put",keys:m,values:p,criteria:v,changeSpec:"function"!=typeof e&&e}).then((e=>y(p.length,e))))).then((()=>(g.length>0||v&&e===Mt)&&o.mutate({trans:r,type:"delete",keys:g,criteria:v}).then((e=>y(g.length,e))))).then((()=>n.length>a+h&&i(a+u)))}))};return i(0).then((()=>{if(h.length>0)throw new z("Error modifying one or more objects",h,d,f);return n.length}))}))}))}delete(){var e=this._ctx,t=e.range;return Ot(e)&&(e.isPrimKey&&!bt||3===t.type)?this._write((n=>{const{primaryKey:r}=e.table.core.schema,s=t;return e.table.core.count({trans:n,query:{index:r,range:s}}).then((t=>e.table.core.mutate({trans:n,type:"deleteRange",range:s}).then((({failures:e,lastResult:n,results:r,numFailures:s})=>{if(s)throw new z("Could not delete some values",Object.keys(e).map((t=>e[t])),t-s);return t-s}))))})):this.modify(Mt)}}const Mt=(e,t)=>t.value=null;function Nt(e,t){return e<t?-1:e===t?0:1}function qt(e,t){return e>t?-1:e===t?0:1}function $t(e,t,n){var r=e instanceof Yt?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function Vt(e){return new e.Collection(e,(()=>Ht(""))).limit(0)}function Ut(e,t,n,r,s,i){for(var a=Math.min(e.length,r.length),o=-1,l=0;l<a;++l){var c=t[l];if(c!==r[l])return s(e[l],n[l])<0?e.substr(0,l)+n[l]+n.substr(l+1):s(e[l],r[l])<0?e.substr(0,l)+r[l]+n.substr(l+1):o>=0?e.substr(0,o)+t[o]+n.substr(o+1):null;s(e[l],c)<0&&(o=l)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):o<0?null:e.substr(0,o)+r[o]+n.substr(o+1)}function Lt(e,t,n,r){var s,i,a,o,l,c,u,h=n.length;if(!n.every((e=>"string"==typeof e)))return $t(e,"String expected.");function d(e){s=function(e){return"next"===e?e=>e.toUpperCase():e=>e.toLowerCase()}(e),i=function(e){return"next"===e?e=>e.toLowerCase():e=>e.toUpperCase()}(e),a="next"===e?Nt:qt;var t=n.map((function(e){return{lower:i(e),upper:s(e)}})).sort((function(e,t){return a(e.lower,t.lower)}));o=t.map((function(e){return e.upper})),l=t.map((function(e){return e.lower})),c=e,u="next"===e?"":r}d("next");var f=new e.Collection(e,(()=>Wt(o[0],l[h-1]+r)));f._ondirectionchange=function(e){d(e)};var y=0;return f._addAlgorithm((function(e,n,r){var s=e.key;if("string"!=typeof s)return!1;var d=i(s);if(t(d,l,y))return!0;for(var f=null,p=y;p<h;++p){var m=Ut(s,d,o[p],l[p],a,c);null===m&&null===f?y=p+1:(null===f||a(f,m)>0)&&(f=m)}return n(null!==f?function(){e.continue(f+u)}:r),!1})),f}function Wt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Ht(e){return{type:1,lower:e,upper:e}}class Yt{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Vt(this):new this.Collection(this,(()=>Wt(e,t,!n,!r)))}catch(e){return $t(this,pt)}}equals(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Ht(e)))}above(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(e,void 0,!0)))}aboveOrEqual(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(e,void 0,!1)))}below(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(void 0,e,!1,!0)))}belowOrEqual(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(void 0,e)))}startsWith(e){return"string"!=typeof e?$t(this,"String expected."):this.between(e,e+yt,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):Lt(this,((e,t)=>0===e.indexOf(t[0])),[e],yt)}equalsIgnoreCase(e){return Lt(this,((e,t)=>e===t[0]),[e],"")}anyOfIgnoreCase(){var e=T.apply(D,arguments);return 0===e.length?Vt(this):Lt(this,((e,t)=>-1!==t.indexOf(e)),e,"")}startsWithAnyOfIgnoreCase(){var e=T.apply(D,arguments);return 0===e.length?Vt(this):Lt(this,((e,t)=>t.some((t=>0===e.indexOf(t)))),e,yt)}anyOf(){const e=T.apply(D,arguments);let t=this._cmp;try{e.sort(t)}catch(e){return $t(this,pt)}if(0===e.length)return Vt(this);const n=new this.Collection(this,(()=>Wt(e[0],e[e.length-1])));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let r=0;return n._addAlgorithm(((n,s,i)=>{const a=n.key;for(;t(a,e[r])>0;)if(++r,r===e.length)return s(i),!1;return 0===t(a,e[r])||(s((()=>{n.continue(e[r])})),!1)})),n}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=T.apply(D,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return $t(this,pt)}const t=e.reduce(((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]),null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){const n=this._cmp,r=this._ascending,s=this._descending,i=this._min,a=this._max;if(0===e.length)return Vt(this);if(!e.every((e=>void 0!==e[0]&&void 0!==e[1]&&r(e[0],e[1])<=0)))return $t(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",X.InvalidArgument);const o=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers;let c,u=r;function h(e,t){return u(e[0],t[0])}try{c=e.reduce((function(e,t){let r=0,s=e.length;for(;r<s;++r){const s=e[r];if(n(t[0],s[1])<0&&n(t[1],s[0])>0){s[0]=i(s[0],t[0]),s[1]=a(s[1],t[1]);break}}return r===s&&e.push(t),e}),[]),c.sort(h)}catch(e){return $t(this,pt)}let d=0;const f=l?e=>r(e,c[d][1])>0:e=>r(e,c[d][1])>=0,y=o?e=>s(e,c[d][0])>0:e=>s(e,c[d][0])>=0;let p=f;const m=new this.Collection(this,(()=>Wt(c[0][0],c[c.length-1][1],!o,!l)));return m._ondirectionchange=e=>{"next"===e?(p=f,u=r):(p=y,u=s),c.sort(h)},m._addAlgorithm(((e,t,n)=>{for(var s=e.key;p(s);)if(++d,d===c.length)return t(n),!1;return!!function(e){return!f(e)&&!y(e)}(s)||(0===this._cmp(s,c[d][1])||0===this._cmp(s,c[d][0])||t((()=>{u===r?e.continue(c[d][0]):e.continue(c[d][1])})),!1)})),m}startsWithAnyOf(){const e=T.apply(D,arguments);return e.every((e=>"string"==typeof e))?0===e.length?Vt(this):this.inAnyRange(e.map((e=>[e,e+yt]))):$t(this,"startsWithAnyOf() only works with strings")}}function zt(e){return He((function(t){return Gt(t),e(t.target.error),!1}))}function Gt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const Jt=St(null,"storagemutated");class Qt{_lock(){return g(!Oe.global),++this._reculock,1!==this._reculock||Oe.global||(Oe.lockOwnerFor=this),this}_unlock(){if(g(!Oe.global),0==--this._reculock)for(Oe.global||(Oe.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{ot(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&Oe.lockOwnerFor!==this}create(e){if(!this.mode)return this;const t=this.db.idbdb,n=this.db._state.dbOpenError;if(g(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new X.DatabaseClosed(n);case"MissingAPIError":throw new X.MissingAPI(n.message,n);default:throw new X.OpenFailed(n)}if(!this.active)throw new X.TransactionInactive;return g(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=He((t=>{Gt(t),this._reject(e.error)})),e.onabort=He((t=>{Gt(t),this.active&&this._reject(new X.Abort(e.error)),this.active=!1,this.on("abort").fire(t)})),e.oncomplete=He((()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Jt.storagemutated.fire(e.mutatedParts)})),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return dt(new X.ReadOnly("Transaction is readonly"));if(!this.active)return dt(new X.TransactionInactive);if(this._locked())return new Re(((r,s)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,s)},Oe])}));if(n)return Ze((()=>{var e=new Re(((e,n)=>{this._lock();const r=t(e,n,this);r&&r.then&&r.then(e,n)}));return e.finally((()=>this._unlock())),e._lib=!0,e}));var r=new Re(((e,n)=>{var r=t(e,n,this);r&&r.then&&r.then(e,n)}));return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();const n=Re.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then((()=>n));else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var s=t._waitingFor;return new Re(((e,r)=>{n.then((n=>t._waitingQueue.push(He(e.bind(null,n)))),(e=>t._waitingQueue.push(He(r.bind(null,e))))).finally((()=>{t._waitingFor===s&&(t._waitingFor=null)}))}))}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new X.Abort))}table(e){const t=this._memoizedTables||(this._memoizedTables={});if(o(t,e))return t[e];const n=this.schema[e];if(!n)throw new X.NotFound("Table "+e+" not part of transaction");const r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function Xt(e,t,n,r,s,i,a){return{name:e,keyPath:t,unique:n,multi:r,auto:s,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(s?"++":"")+Zt(t)}}function Zt(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function en(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:b(n,(e=>[e.name,e]))}}let tn=e=>{try{return e.only([[]]),tn=()=>[[]],[[]]}catch(e){return tn=()=>yt,yt}};function nn(e){return null==e?()=>{}:"string"==typeof e?function(e){return 1===e.split(".").length?t=>t[e]:t=>w(t,e)}(e):t=>w(t,e)}function rn(e){return[].slice.call(e)}let sn=0;function an(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function on(e,t,n){function s(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:n,upper:r,lowerOpen:s,upperOpen:i}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!i):void 0===r?t.lowerBound(n,!!s):t.bound(n,r,!!s,!!i)}const{schema:i,hasGetAll:a}=function(e,t){const n=rn(e.objectStoreNames);return{schema:{name:e.name,tables:n.map((e=>t.objectStore(e))).map((e=>{const{keyPath:t,autoIncrement:n}=e,s=r(t),i=null==t,a={},o={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:i,compound:s,keyPath:t,autoIncrement:n,unique:!0,extractKey:nn(t)},indexes:rn(e.indexNames).map((t=>e.index(t))).map((e=>{const{name:t,unique:n,multiEntry:s,keyPath:i}=e,o={name:t,compound:r(i),keyPath:i,unique:n,multiEntry:s,extractKey:nn(i)};return a[an(i)]=o,o})),getIndexByKeyPath:e=>a[an(e)]};return a[":id"]=o.primaryKey,null!=t&&(a[an(t)]=o.primaryKey),o}))},hasGetAll:n.length>0&&"getAll"in t.objectStore(n[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,n),o=i.tables.map((e=>function(e){const t=e.name;return{name:t,schema:e,mutate:function({trans:e,type:n,keys:r,values:i,range:a}){return new Promise(((o,l)=>{o=He(o);const c=e.objectStore(t),u=null==c.keyPath,h="put"===n||"add"===n;if(!h&&"delete"!==n&&"deleteRange"!==n)throw new Error("Invalid operation type: "+n);const{length:d}=r||i||{length:1};if(r&&i&&r.length!==i.length)throw new Error("Given keys array must have same length as given values array.");if(0===d)return o({numFailures:0,failures:{},results:[],lastResult:void 0});let f;const y=[],p=[];let m=0;const g=e=>{++m,Gt(e)};if("deleteRange"===n){if(4===a.type)return o({numFailures:m,failures:p,results:[],lastResult:void 0});3===a.type?y.push(f=c.clear()):y.push(f=c.delete(s(a)))}else{const[e,t]=h?u?[i,r]:[i,null]:[r,null];if(h)for(let r=0;r<d;++r)y.push(f=t&&void 0!==t[r]?c[n](e[r],t[r]):c[n](e[r])),f.onerror=g;else for(let t=0;t<d;++t)y.push(f=c[n](e[t])),f.onerror=g}const v=e=>{const t=e.target.result;y.forEach(((e,t)=>null!=e.error&&(p[t]=e.error))),o({numFailures:m,failures:p,results:"delete"===n?r:y.map((e=>e.result)),lastResult:t})};f.onerror=e=>{g(e),v(e)},f.onsuccess=v}))},getMany:({trans:e,keys:n})=>new Promise(((r,s)=>{r=He(r);const i=e.objectStore(t),a=n.length,o=new Array(a);let l,c=0,u=0;const h=e=>{const t=e.target;o[t._pos]=t.result,++u===c&&r(o)},d=zt(s);for(let e=0;e<a;++e)null!=n[e]&&(l=i.get(n[e]),l._pos=e,l.onsuccess=h,l.onerror=d,++c);0===c&&r(o)})),get:({trans:e,key:n})=>new Promise(((r,s)=>{r=He(r);const i=e.objectStore(t).get(n);i.onsuccess=e=>r(e.target.result),i.onerror=zt(s)})),query:function(e){return n=>new Promise(((r,i)=>{r=He(r);const{trans:a,values:o,limit:l,query:c}=n,u=l===1/0?void 0:l,{index:h,range:d}=c,f=a.objectStore(t),y=h.isPrimaryKey?f:f.index(h.name),p=s(d);if(0===l)return r({result:[]});if(e){const e=o?y.getAll(p,u):y.getAllKeys(p,u);e.onsuccess=e=>r({result:e.target.result}),e.onerror=zt(i)}else{let e=0;const t=o||!("openKeyCursor"in y)?y.openCursor(p):y.openKeyCursor(p),n=[];t.onsuccess=s=>{const i=t.result;return i?(n.push(o?i.value:i.primaryKey),++e===l?r({result:n}):void i.continue()):r({result:n})},t.onerror=zt(i)}}))}(a),openCursor:function({trans:e,values:n,query:r,reverse:i,unique:a}){return new Promise(((o,l)=>{o=He(o);const{index:c,range:u}=r,h=e.objectStore(t),d=c.isPrimaryKey?h:h.index(c.name),f=i?a?"prevunique":"prev":a?"nextunique":"next",y=n||!("openKeyCursor"in d)?d.openCursor(s(u),f):d.openKeyCursor(s(u),f);y.onerror=zt(l),y.onsuccess=He((t=>{const n=y.result;if(!n)return void o(null);n.___id=++sn,n.done=!1;const r=n.continue.bind(n);let s=n.continuePrimaryKey;s&&(s=s.bind(n));const i=n.advance.bind(n),a=()=>{throw new Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw new Error("Cursor not started")},n.fail=He(l),n.next=function(){let e=1;return this.start((()=>e--?this.continue():this.stop())).then((()=>this))},n.start=e=>{const t=new Promise(((e,t)=>{e=He(e),y.onerror=zt(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=a,e(t)}})),o=()=>{if(y.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw new Error("Cursor behind last entry")},n.stop()};return y.onsuccess=He((e=>{y.onsuccess=o,o()})),n.continue=r,n.continuePrimaryKey=s,n.advance=i,o(),t},o(n)}),l)}))},count({query:e,trans:n}){const{index:r,range:i}=e;return new Promise(((e,a)=>{const o=n.objectStore(t),l=r.isPrimaryKey?o:o.index(r.name),c=s(i),u=c?l.count(c):l.count();u.onsuccess=He((t=>e(t.target.result))),u.onerror=zt(a)}))}}}(e))),l={};return o.forEach((e=>l[e.name]=e)),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!l[e])throw new Error(`Table '${e}' not found`);return l[e]},MIN_KEY:-1/0,MAX_KEY:tn(t),schema:i}}function ln({_novip:e},t){const n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},s){const i=function(e,t){return t.reduce(((e,{create:t})=>({...e,...t(e)})),e)}(on(t,n,s),e.dbcore);return{dbcore:i}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach((t=>{const n=t.name;e.core.schema.tables.some((e=>e.name===n))&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))}))}function cn({_novip:e},t,n,r){n.forEach((n=>{const s=r[n];t.forEach((t=>{const r=f(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?u(t,n,{get(){return this.table(n)},set(e){c(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,s))}))}))}function un({_novip:e},t){t.forEach((t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]}))}function hn(e,t){return e._cfg.version-t._cfg.version}function dn(e,t,r,s){const i=e._dbSchema,a=e._createTransaction("readwrite",e._storeNames,i);a.create(r),a._completion.catch(s);const o=a._reject.bind(a),l=Oe.transless||Oe;Ze((()=>{Oe.trans=a,Oe.transless=l,0===t?(n(i).forEach((e=>{yn(r,e,i[e].primKey,i[e].indexes)})),ln(e,r),Re.follow((()=>e.on.populate.fire(a))).catch(o)):function({_novip:e},t,r,s){const i=[],a=e._versions;let o=e._dbSchema=mn(0,e.idbdb,s),l=!1;return a.filter((e=>e._cfg.version>=t)).forEach((a=>{i.push((()=>{const i=o,c=a._cfg.dbschema;gn(e,i,s),gn(e,c,s),o=e._dbSchema=c;const u=fn(i,c);u.add.forEach((e=>{yn(s,e[0],e[1].primKey,e[1].indexes)})),u.change.forEach((e=>{if(e.recreate)throw new X.Upgrade("Not yet support for changing primary key");{const t=s.objectStore(e.name);e.add.forEach((e=>pn(t,e))),e.change.forEach((e=>{t.deleteIndex(e.name),pn(t,e)})),e.del.forEach((e=>t.deleteIndex(e)))}}));const h=a._cfg.contentUpgrade;if(h&&a._cfg.version>t){ln(e,s),r._memoizedTables={},l=!0;let t=k(c);u.del.forEach((e=>{t[e]=i[e]})),un(e,[e.Transaction.prototype]),cn(e,[e.Transaction.prototype],n(t),t),r.schema=t;const a=B(h);let o;a&&et();const d=Re.follow((()=>{if(o=h(r),o&&a){var e=tt.bind(null,null);o.then(e,e)}}));return o&&"function"==typeof o.then?Re.resolve(o):d.then((()=>o))}})),i.push((t=>{l&&vt||function(e,t){[].slice.call(t.db.objectStoreNames).forEach((n=>null==e[n]&&t.db.deleteObjectStore(n)))}(a._cfg.dbschema,t),un(e,[e.Transaction.prototype]),cn(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema}))})),function e(){return i.length?Re.resolve(i.shift()(r.idbtrans)).then(e):Re.resolve()}().then((()=>{var e,t;t=s,n(e=o).forEach((n=>{t.db.objectStoreNames.contains(n)||yn(t,n,e[n].primKey,e[n].indexes)}))}))}(e,t,a,r).catch(o)}))}function fn(e,t){const n={del:[],add:[],change:[]};let r;for(r in e)t[r]||n.del.push(r);for(r in t){const s=e[r],i=t[r];if(s){const e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||s.primKey.auto!==i.primKey.auto&&!gt)e.recreate=!0,n.change.push(e);else{const t=s.idxByName,r=i.idxByName;let a;for(a in t)r[a]||e.del.push(a);for(a in r){const n=t[a],s=r[a];n?n.src!==s.src&&e.change.push(s):e.add.push(s)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}}else n.add.push([r,i])}return n}function yn(e,t,n,r){const s=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach((e=>pn(s,e))),s}function pn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function mn(e,t,n){const r={};return p(t.objectStoreNames,0).forEach((e=>{const t=n.objectStore(e);let s=t.keyPath;const i=Xt(Zt(s),s||"",!1,!1,!!t.autoIncrement,s&&"string"!=typeof s,!0),a=[];for(let e=0;e<t.indexNames.length;++e){const n=t.index(t.indexNames[e]);s=n.keyPath;var o=Xt(n.name,s,!!n.unique,!!n.multiEntry,!1,s&&"string"!=typeof s,!1);a.push(o)}r[e]=en(e,i,a)})),r}function gn({_novip:e},n,r){const s=r.db.objectStoreNames;for(let t=0;t<s.length;++t){const i=s[t],a=r.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){const t=a.indexNames[e],r=a.index(t).keyPath,s="string"==typeof r?r:"["+p(r).join("+")+"]";if(n[i]){const e=n[i].idxByName[s];e&&(e.name=t,delete n[i].idxByName[s],n[i].idxByName[t]=e)}}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&t.WorkerGlobalScope&&t instanceof t.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class vn{_parseStoresSpec(e,t){n(e).forEach((n=>{if(null!==e[n]){var s=e[n].split(",").map(((e,t)=>{const n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),s=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return Xt(n,s||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),r(s),0===t)})),i=s.shift();if(i.multi)throw new X.Schema("Primary key cannot be multi-valued");s.forEach((e=>{if(e.auto)throw new X.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new X.Schema("Index must have a name and cannot be an empty string")})),t[n]=en(n,i,s)}}))}stores(e){const t=this.db;this._cfg.storesSource=this._cfg.storesSource?s(this._cfg.storesSource,e):e;const r=t._versions,i={};let a={};return r.forEach((e=>{s(i,e._cfg.storesSource),a=e._cfg.dbschema={},e._parseStoresSpec(i,a)})),t._dbSchema=a,un(t,[t._allTables,t,t.Transaction.prototype]),cn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],n(a),a),t._storeNames=n(a),this}upgrade(e){return this._cfg.contentUpgrade=ce(this._cfg.contentUpgrade||te,e),this}}function bn(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new qn("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function wn(e){return e&&"function"==typeof e.databases}function _n(e){return Ze((function(){return Oe.letThrough=!0,e()}))}function kn(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise((function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()})).finally((function(){return clearInterval(e)})):Promise.resolve()}function xn(e){var t=t=>e.next(t),n=i(t),s=i((t=>e.throw(t)));function i(e){return t=>{var i=e(t),a=i.value;return i.done?a:a&&"function"==typeof a.then?a.then(n,s):r(a)?Promise.all(a).then(n,s):n(a)}}return i(t)()}function En(e,t,n){var r=arguments.length;if(r<2)throw new X.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];return n=s.pop(),[e,E(s),n]}function Sn(e,t,n,r,s){return Re.resolve().then((()=>{const i=Oe.transless||Oe,a=e._createTransaction(t,n,e._dbSchema,r),o={trans:a,transless:i};if(r)a.idbtrans=r.idbtrans;else try{a.create(),e._state.PR1398_maxLoop=3}catch(r){return r.name===J.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>Sn(e,t,n,null,s)))):dt(r)}const l=B(s);let c;l&&et();const u=Re.follow((()=>{if(c=s.call(a,a),c)if(l){var e=tt.bind(null,null);c.then(e,e)}else"function"==typeof c.next&&"function"==typeof c.throw&&(c=xn(c))}),o);return(c&&"function"==typeof c.then?Re.resolve(c).then((e=>a.active?e:dt(new X.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn")))):u.then((()=>c))).then((e=>(r&&a._resolve(),a._completion.then((()=>e))))).catch((e=>(a._reject(e),dt(e))))}))}function Pn(e,t,n){const s=r(e)?e.slice():[e];for(let e=0;e<n;++e)s.push(t);return s}const On={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const n=e.table(t),{schema:r}=n,s={},i=[];function a(e,t,n){const r=an(e),o=s[r]=s[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=t>0,u={...n,isVirtual:c,keyTail:t,keyLength:l,extractKey:nn(e),unique:!c&&n.unique};return o.push(u),u.isPrimaryKey||i.push(u),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,n),o.sort(((e,t)=>e.keyTail-t.keyTail)),u}const o=a(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[o];for(const e of r.indexes)a(e.keyPath,0,e);function l(t){const n=t.query.index;return n.isVirtual?{...t,query:{index:n,range:(r=t.query.range,s=n.keyTail,{type:1===r.type?2:r.type,lower:Pn(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,s),lowerOpen:!0,upper:Pn(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,s),upperOpen:!0})}}:t;var r,s}const c={...n,schema:{...r,primaryKey:o,indexes:i,getIndexByKeyPath:function(e){const t=s[an(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){const{keyTail:r,isVirtual:s,keyLength:i}=t.query.index;return s?n.openCursor(l(t)).then((n=>n&&function(n){const s=Object.create(n,{continue:{value:function(s){null!=s?n.continue(Pn(s,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,s){n.continuePrimaryKey(Pn(t,e.MAX_KEY,r),s)}},primaryKey:{get:()=>n.primaryKey},key:{get(){const e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>n.value}});return s}(n))):n.openCursor(t)}};return c}}}};function Kn(e,t,r,s){return r=r||{},s=s||"",n(e).forEach((n=>{if(o(t,n)){var i=e[n],a=t[n];if("object"==typeof i&&"object"==typeof a&&i&&a){const e=R(i);e!==R(a)?r[s+n]=t[n]:"Object"===e?Kn(i,a,r,s+n+"."):i!==a&&(r[s+n]=t[n])}else i!==a&&(r[s+n]=t[n])}else r[s+n]=void 0})),n(t).forEach((n=>{o(e,n)||(r[s+n]=t[n])})),r}const jn={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema,s={...n,mutate(e){const s=Oe.trans,{deleting:i,creating:a,updating:l}=s.table(t).hook;switch(e.type){case"add":if(a.fire===te)break;return s._promise("readwrite",(()=>c(e)),!0);case"put":if(a.fire===te&&l.fire===te)break;return s._promise("readwrite",(()=>c(e)),!0);case"delete":if(i.fire===te)break;return s._promise("readwrite",(()=>c(e)),!0);case"deleteRange":if(i.fire===te)break;return s._promise("readwrite",(()=>function(e){return u(e.trans,e.range,1e4)}(e)),!0)}return n.mutate(e);function c(e){const t=Oe.trans,s=e.keys||function(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}(r,e);if(!s)throw new Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:s}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),function(e,t,n){return"add"===t.type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})}(n,e,s).then((c=>{const u=s.map(((n,s)=>{const u=c[s],h={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(h,n,u,t);else if("add"===e.type||void 0===u){const i=a.fire.call(h,n,e.values[s],t);null==n&&null!=i&&(n=i,e.keys[s]=n,r.outbound||_(e.values[s],r.keyPath,n))}else{const r=Kn(u,e.values[s]),i=l.fire.call(h,r,n,u,t);if(i){const t=e.values[s];Object.keys(i).forEach((e=>{o(t,e)?t[e]=i[e]:_(t,e,i[e])}))}}return h}));return n.mutate(e).then((({failures:t,results:n,numFailures:r,lastResult:i})=>{for(let r=0;r<s.length;++r){const i=n?n[r]:s[r],a=u[r];null==i?a.onerror&&a.onerror(t[r]):a.onsuccess&&a.onsuccess("put"===e.type&&c[r]?e.values[r]:i)}return{failures:t,results:n,numFailures:r,lastResult:i}})).catch((e=>(u.forEach((t=>t.onerror&&t.onerror(e))),Promise.reject(e))))}))}function u(e,t,s){return n.query({trans:e,values:!1,query:{index:r,range:t},limit:s}).then((({result:n})=>c({type:"delete",keys:n,trans:e}).then((r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<s?{failures:[],numFailures:0,lastResult:void 0}:u(e,{...t,lower:n[n.length-1],lowerOpen:!0},s)))))}}};return s}})};function Cn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;const r=[];for(let s=0,i=0;s<t.keys.length&&i<e.length;++s)0===Dt(t.keys[s],e[i])&&(r.push(n?K(t.values[s]):t.values[s]),++i);return r.length===e.length?r:null}catch(e){return null}}const Rn={stack:"dbcore",level:-1,create:e=>({table:t=>{const n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);const t=Cn(e.keys,e.trans._cache,"clone"===e.cache);return t?Re.resolve(t):n.getMany(e).then((t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?K(t):t},t)))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function An(e){return!("from"in e)}const In=function(e,t){if(!this){const t=new In;return e&&"d"in e&&s(t,e),t}s(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function Dn(e,t,n){const r=Dt(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(An(e))return s(e,{from:t,to:n,d:1});const i=e.l,a=e.r;if(Dt(n,e.from)<0)return i?Dn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Fn(e);if(Dt(t,e.to)>0)return a?Dn(a,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Fn(e);Dt(t,e.from)<0&&(e.from=t,e.l=null,e.d=a?a.d+1:1),Dt(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const o=!e.r;i&&!e.l&&Tn(e,i),a&&o&&Tn(e,a)}function Tn(e,t){An(t)||function e(t,{from:n,to:r,l:s,r:i}){Dn(t,n,r),s&&e(t,s),i&&e(t,i)}(e,t)}function Bn(e){let t=An(e)?null:{s:0,n:e};return{next(e){const n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&Dt(e,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||Dt(e,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Fn(e){var t,n;const r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),s=r>1?"r":r<-1?"l":"";if(s){const t="r"===s?"l":"r",n={...e},r=e[s];e.from=r.from,e.to=r.to,e[s]=r[s],n[s]=r[t],e[t]=n,n.d=Mn(n)}e.d=Mn(e)}function Mn({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}l(In.prototype,{add(e){return Tn(this,e),this},addKey(e){return Dn(this,e,e),this},addKeys(e){return e.forEach((e=>Dn(this,e,e))),this},[A](){return Bn(this)}});const Nn={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,s=new In(e.MIN_KEY,e.MAX_KEY);return{...e,table:i=>{const a=e.table(i),{schema:o}=a,{primaryKey:l}=o,{extractKey:c,outbound:u}=l,h={...a,mutate:e=>{const n=e.trans,l=n.mutatedParts||(n.mutatedParts={}),c=e=>{const n=`idb://${t}/${i}/${e}`;return l[n]||(l[n]=new In)},u=c(""),h=c(":dels"),{type:d}=e;let[f,y]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[];const p=e.trans._cache;return a.mutate(e).then((e=>{if(r(f)){"delete"!==d&&(f=e.results),u.addKeys(f);const t=Cn(f,p);t||"add"===d||h.addKeys(f),(t||y)&&function(e,t,n,s){t.indexes.forEach((function(t){const i=e(t.name||"");function a(e){return null!=e?t.extractKey(e):null}const o=e=>t.multiEntry&&r(e)?e.forEach((e=>i.addKey(e))):i.addKey(e);(n||s).forEach(((e,t)=>{const r=n&&a(n[t]),i=s&&a(s[t]);0!==Dt(r,i)&&(null!=r&&o(r),null!=i&&o(i))}))}))}(c,o,t,y)}else if(f){const e={from:f.lower,to:f.upper};h.add(e),u.add(e)}else u.add(s),h.add(s),o.indexes.forEach((e=>c(e.name).add(s)));return e}))}},d=({query:{index:t,range:n}})=>{var r,s;return[t,new In(null!==(r=n.lower)&&void 0!==r?r:e.MIN_KEY,null!==(s=n.upper)&&void 0!==s?s:e.MAX_KEY)]},f={get:e=>[l,new In(e.key)],getMany:e=>[l,(new In).addKeys(e.keys)],count:d,query:d,openCursor:d};return n(f).forEach((e=>{h[e]=function(n){const{subscr:r}=Oe;if(r){const o=e=>{const n=`idb://${t}/${i}/${e}`;return r[n]||(r[n]=new In)},l=o(""),h=o(":dels"),[d,y]=f[e](n);if(o(d.name||"").add(y),!d.isPrimaryKey){if("count"!==e){const t="query"===e&&u&&n.values&&a.query({...n,values:!1});return a[e].apply(this,arguments).then((r=>{if("query"===e){if(u&&n.values)return t.then((({result:e})=>(l.addKeys(e),r)));const e=n.values?r.result.map(c):r.result;n.values?l.addKeys(e):h.addKeys(e)}else if("openCursor"===e){const e=r,t=n.values;return e&&Object.create(e,{key:{get:()=>(h.addKey(e.primaryKey),e.key)},primaryKey:{get(){const t=e.primaryKey;return h.addKey(t),t}},value:{get:()=>(t&&l.addKey(e.primaryKey),e.value)}})}return r}))}h.add(s)}}return a[e].apply(this,arguments)}})),h}}}};class qn{constructor(e,t){this._middlewares={},this.verno=0;const n=qn.dependencies;this._options=t={addons:qn.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:r}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:te,dbReadyPromise:null,cancelOpen:te,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new Re((e=>{s.dbReadyResolve=e})),s.openCanceller=new Re(((e,t)=>{s.cancelOpen=t})),this._state=s,this.name=e,this.on=St(this,"populate","blocked","versionchange","close",{ready:[ce,te]}),this.on.ready.subscribe=m(this.on.ready.subscribe,(e=>(t,n)=>{qn.vip((()=>{const r=this._state;if(r.openComplete)r.dbOpenError||Re.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);const r=this;n||e((function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)}))}}))})),this.Collection=(i=this,Pt(Ft.prototype,(function(e,t){this.db=i;let n=kt,r=null;if(t)try{n=t()}catch(e){r=e}const s=e._ctx,a=s.table,o=a.hook.reading.fire;this._ctx={table:a,index:s.index,isPrimKey:!s.index||a.schema.primKey.keyPath&&s.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:s.or,valueMapper:o!==ne?o:null}}))),this.Table=function(e){return Pt(Et.prototype,(function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:St(null,{creating:[ie,te],reading:[re,ne],updating:[oe,te],deleting:[ae,te]})}))}(this),this.Transaction=function(e){return Pt(Qt.prototype,(function(t,n,r,s,i){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=s,this.idbtrans=null,this.on=St(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new Re(((e,t)=>{this._resolve=e,this._reject=t})),this._completion.then((()=>{this.active=!1,this.on.complete.fire()}),(e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),dt(e)}))}))}(this),this.Version=function(e){return Pt(vn.prototype,(function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}}))}(this),this.WhereClause=function(e){return Pt(Yt.prototype,(function(t,n,r){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r};const s=e._deps.indexedDB;if(!s)throw new X.MissingAPI;this._cmp=this._ascending=s.cmp.bind(s),this._descending=(e,t)=>s.cmp(t,e),this._max=(e,t)=>s.cmp(e,t)>0?e:t,this._min=(e,t)=>s.cmp(e,t)<0?e:t,this._IDBKeyRange=e._deps.IDBKeyRange}))}(this),this.on("versionchange",(e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()})),this.on("blocked",(e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)})),this._maxKey=tn(t.IDBKeyRange),this._createTransaction=(e,t,n,r)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),mt.filter((e=>e.name===this.name&&e!==this&&!e._state.vcFired)).map((t=>t.on("versionchange").fire(e)))},this.use(On),this.use(jn),this.use(Nn),this.use(Rn),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach((e=>e(this)))}version(e){if(isNaN(e)||e<.1)throw new X.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new X.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const t=this._versions;var n=t.filter((t=>t._cfg.version===e))[0];return n||(n=new this.Version(e),t.push(n),t.sort(hn),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||Oe.letThrough||this._vip)?e():new Re(((e,t)=>{if(this._state.openComplete)return t(new X.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new X.DatabaseClosed);this.open().catch(te)}this._state.dbReadyPromise.then(e,t)})).then(e)}use({stack:e,create:t,level:n,name:r}){r&&this.unuse({stack:e,name:r});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:t,level:null==n?10:n,name:r}),s.sort(((e,t)=>e.level-t.level)),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter((e=>n?e.create!==n:!!t&&e.name!==t))),this}open(){return function(e){const t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then((()=>t.dbOpenError?dt(t.dbOpenError):e));F&&(t.openCanceller._stackHolder=$()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const s=t.openCanceller;function i(){if(t.openCanceller!==s)throw new X.DatabaseClosed("db.open() was cancelled")}let a=t.dbReadyResolve,o=null,l=!1;return Re.race([s,("undefined"==typeof navigator?Re.resolve():kn()).then((()=>new Re(((s,a)=>{if(i(),!r)throw new X.MissingAPI;const c=e.name,u=t.autoSchema?r.open(c):r.open(c,Math.round(10*e.verno));if(!u)throw new X.MissingAPI;u.onerror=zt(a),u.onblocked=He(e._fireOnBlocked),u.onupgradeneeded=He((n=>{if(o=u.transaction,t.autoSchema&&!e._options.allowEmptyDB){u.onerror=Gt,o.abort(),u.result.close();const e=r.deleteDatabase(c);e.onsuccess=e.onerror=He((()=>{a(new X.NoSuchDatabase(`Database ${c} doesnt exist`))}))}else{o.onerror=zt(a);var s=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;l=s<1,e._novip.idbdb=u.result,dn(e,s/10,o,a)}}),a),u.onsuccess=He((()=>{o=null;const r=e._novip.idbdb=u.result,i=p(r.objectStoreNames);if(i.length>0)try{const s=r.transaction(1===(a=i).length?a[0]:a,"readonly");t.autoSchema?function({_novip:e},t,r){e.verno=t.version/10;const s=e._dbSchema=mn(0,t,r);e._storeNames=p(t.objectStoreNames,0),cn(e,[e._allTables],n(s),s)}(e,r,s):(gn(e,e._dbSchema,s),function(e,t){const n=fn(mn(0,e.idbdb,t),e._dbSchema);return!(n.add.length||n.change.some((e=>e.add.length||e.change.length)))}(e,s)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),ln(e,s)}catch(e){}var a;mt.push(e),r.onversionchange=He((n=>{t.vcFired=!0,e.on("versionchange").fire(n)})),r.onclose=He((t=>{e.on("close").fire(t)})),l&&function({indexedDB:e,IDBKeyRange:t},n){!wn(e)&&"__dbnames"!==n&&bn(e,t).put({name:n}).catch(te)}(e._deps,c),s()}),a)}))))]).then((()=>(i(),t.onReadyBeingFired=[],Re.resolve(_n((()=>e.on.ready.fire(e.vip)))).then((function n(){if(t.onReadyBeingFired.length>0){let r=t.onReadyBeingFired.reduce(ce,te);return t.onReadyBeingFired=[],Re.resolve(_n((()=>r(e.vip)))).then(n)}}))))).finally((()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1})).then((()=>e)).catch((n=>{t.dbOpenError=n;try{o&&o.abort()}catch(e){}return s===t.openCanceller&&e._close(),dt(n)})).finally((()=>{t.openComplete=!0,a()}))}(this)}_close(){const e=this._state,t=mt.indexOf(this);if(t>=0&&mt.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new Re((t=>{e.dbReadyResolve=t})),e.openCanceller=new Re(((t,n)=>{e.cancelOpen=n}))}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new X.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,t=this._state;return new Re(((n,r)=>{const s=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=He((()=>{!function({indexedDB:e,IDBKeyRange:t},n){!wn(e)&&"__dbnames"!==n&&bn(e,t).delete(n).catch(te)}(this._deps,this.name),n()})),e.onerror=zt(r),e.onblocked=this._fireOnBlocked};if(e)throw new X.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(s):s()}))}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){const e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return n(this._allTables).map((e=>this._allTables[e]))}transaction(){const e=En.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r=Oe.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);const s=-1!==e.indexOf("?");let i,a;e=e.replace("!","").replace("?","");try{if(a=t.map((e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t})),"r"==e||"readonly"===e)i="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new X.InvalidArgument("Invalid transaction mode: "+e);i="readwrite"}if(r){if("readonly"===r.mode&&"readwrite"===i){if(!s)throw new X.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&a.forEach((e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!s)throw new X.SubTransaction("Table "+e+" not included in parent transaction.");r=null}})),s&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,((t,n)=>{n(e)})):dt(e)}const o=Sn.bind(null,this,i,a,r,n);return r?r._promise(i,o,"lock"):Oe.trans?ot(Oe.transless,(()=>this._whenReady(o))):this._whenReady(o)}table(e){if(!o(this._allTables,e))throw new X.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const $n="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class Vn{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[$n](){return this}}function Un(e,t){return n(t).forEach((n=>{Tn(e[n]||(e[n]=new In),t[n])})),e}let Ln;try{Ln={indexedDB:t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,IDBKeyRange:t.IDBKeyRange||t.webkitIDBKeyRange}}catch(t){Ln={indexedDB:null,IDBKeyRange:null}}const Wn=qn;function Hn(e){let t=Yn;try{Yn=!0,Jt.storagemutated.fire(e)}finally{Yn=t}}l(Wn,{...ee,delete:e=>new Wn(e,{addons:[]}).delete(),exists:e=>new Wn(e,{addons:[]}).open().then((e=>(e.close(),!0))).catch("NoSuchDatabaseError",(()=>!1)),getDatabaseNames(e){try{return function({indexedDB:e,IDBKeyRange:t}){return wn(e)?Promise.resolve(e.databases()).then((e=>e.map((e=>e.name)).filter((e=>"__dbnames"!==e)))):bn(e,t).toCollection().primaryKeys()}(Wn.dependencies).then(e)}catch(e){return dt(new X.MissingAPI)}},defineClass:()=>function(e){s(this,e)},ignoreTransaction:e=>Oe.trans?ot(Oe.transless,e):e(),vip:_n,async:function(e){return function(){try{var t=xn(e.apply(this,arguments));return t&&"function"==typeof t.then?t:Re.resolve(t)}catch(e){return dt(e)}}},spawn:function(e,t,n){try{var r=xn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Re.resolve(r)}catch(e){return dt(e)}},currentTransaction:{get:()=>Oe.trans||null},waitFor:function(e,t){const n=Re.resolve("function"==typeof e?Wn.ignoreTransaction(e):e).timeout(t||6e4);return Oe.trans?Oe.trans.waitFor(n):n},Promise:Re,debug:{get:()=>F,set:e=>{M(e,"dexie"===e?()=>!0:wt)}},derive:h,extend:s,props:l,override:m,Events:St,on:Jt,liveQuery:function(e){return new Vn((t=>{const r=B(e);let s=!1,i={},a={};const o={get closed(){return s},unsubscribe:()=>{s=!0,Jt.storagemutated.unsubscribe(h)}};t.start&&t.start(o);let l=!1,c=!1;function u(){return n(a).some((e=>i[e]&&function(e,t){const n=Bn(t);let r=n.next();if(r.done)return!1;let s=r.value;const i=Bn(e);let a=i.next(s.from),o=a.value;for(;!r.done&&!a.done;){if(Dt(o.from,s.to)<=0&&Dt(o.to,s.from)>=0)return!0;Dt(s.from,o.from)<0?s=(r=n.next(o.from)).value:o=(a=i.next(s.from)).value}return!1}(i[e],a[e])))}const h=e=>{Un(i,e),u()&&d()},d=()=>{if(l||s)return;i={};const n={},f=function(t){r&&et();const n=()=>Ze(e,{subscr:t,trans:null}),s=Oe.trans?ot(Oe.transless,n):n();return r&&s.then(tt,tt),s}(n);c||(Jt("storagemutated",h),c=!0),l=!0,Promise.resolve(f).then((e=>{l=!1,s||(u()?d():(i={},a=n,t.next&&t.next(e)))}),(e=>{l=!1,t.error&&t.error(e),o.unsubscribe()}))};return d(),o}))},extendObservabilitySet:Un,getByKeyPath:w,setByKeyPath:_,delByKeyPath:function(e,t){"string"==typeof t?_(e,t,void 0):"length"in t&&[].map.call(t,(function(t){_(e,t,void 0)}))},shallowClone:k,deepClone:K,getObjectDiff:Kn,cmp:Dt,asap:v,minKey:-1/0,addons:[],connections:mt,errnames:J,dependencies:Ln,semVer:"3.2.2",version:"3.2.2".split(".").map((e=>parseInt(e))).reduce(((e,t,n)=>e+t/Math.pow(10,2*n)))}),Wn.maxKey=tn(Wn.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(Jt("storagemutated",(e=>{if(!Yn){let t;gt?(t=document.createEvent("CustomEvent"),t.initCustomEvent("x-storagemutated-1",!0,!0,e)):t=new CustomEvent("x-storagemutated-1",{detail:e}),Yn=!0,dispatchEvent(t),Yn=!1}})),addEventListener("x-storagemutated-1",(({detail:e})=>{Yn||Hn(e)})));let Yn=!1;if("undefined"!=typeof BroadcastChannel){const e=new BroadcastChannel("x-storagemutated-1");Jt("storagemutated",(t=>{Yn||e.postMessage(t)})),e.onmessage=e=>{e.data&&Hn(e.data)}}else if("undefined"!=typeof self&&"undefined"!=typeof navigator){Jt("storagemutated",(e=>{try{Yn||("undefined"!=typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach((t=>t.postMessage({type:"x-storagemutated-1",changedParts:e}))))}catch(e){}})),"undefined"!=typeof addEventListener&&addEventListener("storage",(e=>{if("x-storagemutated-1"===e.key){const t=JSON.parse(e.newValue);t&&Hn(t.changedParts)}}));const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",(function({data:e}){e&&"x-storagemutated-1"===e.type&&Hn(e.changedParts)}))}Re.rejectionMapper=function(e,t){if(!e||e instanceof H||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Z[e.name])return e;var n=new Z[e.name](t||e.message,e);return"stack"in e&&u(n,"stack",{get:function(){return this.inner.stack}}),n},M(F,wt);class zn extends qn{constructor(e="SubWalletDB_v2",t=11){super(e),this.schemaVersion=t,this.conditionalVersion(1,{chain:"slug",asset:"slug",price:"currency",balances:"[tokenSlug+address], tokenSlug, address",nfts:"[chain+address+collectionId+id], [address+chain], chain, id, address, collectionId, name",nftCollections:"[chain+collectionId], chain, collectionId, collectionName",crowdloans:"[chain+address], chain, address",stakings:"[chain+address+type], [chain+address], chain, address, type",transactions:"[chain+address+extrinsicHash], &[chain+address+extrinsicHash], chain, address, extrinsicHash, action",migrations:"[key+name]",chainStakingMetadata:"[chain+type], chain, type",nominatorMetadata:"[chain+address+type], [chain+address], chain, address, type"}),this.conditionalVersion(2,{metadata:"genesisHash, chain"}),this.conditionalVersion(3,{mantaPay:"key, chain"}),this.conditionalVersion(4,{yieldPoolInfo:"slug, chain, type",yieldPosition:"[slug+chain+address], [address+slug], address, chain"}),this.conditionalVersion(5,{campaign:"slug"}),this.conditionalVersion(6,{keyValue:"key"})}conditionalVersion(e,t,n){if(null!=this.schemaVersion&&this.schemaVersion<e)return;const r=this.version(e).stores(t);null!=n&&r.upgrade(n)}static getInstance(e,t){return zn.instance||(zn.instance=new zn(e,t)),zn.instance}}const Gn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this"),Jn="undefined"!=typeof localStorage;class Qn{_storage={};localStorage=Jn?localStorage:void 0;kvDatabase=zn.getInstance().keyValue;isReady=!1;waitReadyHandler=function(){let e=()=>{console.warn("This promise handler is not implemented")},t=()=>{console.warn("This promise handler is not implemented")};const n=new Promise(((n,r)=>{e=n,t=r}));return{resolve:e,reject:t,promise:n}}();get waitReady(){return this.waitReadyHandler.promise}constructor(){this.sync().then((()=>{this.isReady=!0,this.waitReadyHandler.resolve(this)})).catch(console.error)}async setItem(e,t){var n;!this.isReady&&await this.waitReady,this._storage[e]=t,this.localStorage?null===(n=this.localStorage)||void 0===n||n.setItem(e,t):this.kvDatabase.put({key:e,value:t}).catch(console.error)}async getEntries(){return!this.isReady&&await this.waitReady,Object.entries(this._storage)}async setMap(e){if(!this.isReady&&await this.waitReady,this._storage={...this._storage,...e},this.localStorage)Object.entries(e).forEach((([e,t])=>{var n;null===(n=this.localStorage)||void 0===n||n.setItem(e,t)}));else{const t=Object.entries(e).map((([e,t])=>({key:e,value:t})));this.kvDatabase.bulkPut(t).catch(console.error)}}async getItem(e){return!this.isReady&&await this.waitReady,this._storage[e]||null}async getItems(e){return!this.isReady&&await this.waitReady,e.map((e=>this._storage[e]||null))}async getMap(e){return!this.isReady&&await this.waitReady,e.reduce(((e,t)=>(e[t]=this._storage[t]||null,e)),{})}async removeItem(e){!this.isReady&&await this.waitReady,this._storage[e]&&delete this._storage[e],this.localStorage?this.localStorage.removeItem(e):this.kvDatabase.where({key:e}).delete().catch(console.error)}async removeItems(e){!this.isReady&&await this.waitReady,e.forEach((e=>{this._storage[e]&&delete this._storage[e]})),this.localStorage?e.forEach((e=>{this.localStorage&&this.localStorage.removeItem(e)})):this.kvDatabase.where("key").anyOf(e).delete().catch(console.error)}async clear(){!this.isReady&&await this.waitReady,this._storage={},this.localStorage?this.localStorage.clear():this.kvDatabase.clear().catch(console.error)}async key(e){return!this.isReady&&await this.waitReady,Object.keys(this._storage)[e]||null}async length(e){return!this.isReady&&await this.waitReady,Object.keys(this._storage)[e]||null}async keys(){return!this.isReady&&await this.waitReady,Object.keys(this._storage)||[]}async copy(){return!this.isReady&&await this.waitReady,Promise.resolve(JSON.parse(JSON.stringify(this._storage)))}async sync(){if(this.localStorage)this._storage=JSON.parse(JSON.stringify(this.localStorage));else{const e=await this.kvDatabase.toArray();this._storage={},e.forEach((e=>{this._storage[e.key]=e.value}))}}static get instance(){return Gn.SWStorage||(Gn.SWStorage=new Qn),Gn.SWStorage}}const Xn=Qn.instance;e.g.chrome||(e.g.chrome={}),e.g.chrome.extension||(e.g.chrome.extension={getURL:e=>`${e}`}),e.g.chrome.runtime={lastError:void 0,getURL:e=>`/${e}`},e.g.chrome.windows={getCurrent:()=>{}},e.g.chrome.tabs={query:()=>{}},e.g.chrome.storage={local:{get:(e,t)=>{(async()=>{e||(e=await Xn.keys()),"string"==typeof e&&(e=[e]);const t={};return await Promise.all(e.map((async e=>{const n=await Xn.getItem(e);if(null===n)t[e]=void 0;else try{t[e]=JSON.parse(n)}catch(r){t[e]=n}}))),t})().then(t).catch(console.error)},set:(e,t)=>{Promise.all(Object.entries(e).map((async([e,t])=>{await Xn.setItem(e,JSON.stringify(t))}))).then((()=>{t&&t()})).catch(console.error)},remove:(e,t,n)=>{Xn.removeItem(e).then((()=>{n&&n()})).catch(console.error)}}}})();
1
+ (()=>{"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();const t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,n=Object.keys,r=Array.isArray;function s(e,t){return"object"!=typeof t||n(t).forEach((function(n){e[n]=t[n]})),e}"undefined"==typeof Promise||t.Promise||(t.Promise=Promise);const i=Object.getPrototypeOf,a={}.hasOwnProperty;function o(e,t){return a.call(e,t)}function l(e,t){"function"==typeof t&&(t=t(i(e))),("undefined"==typeof Reflect?n:Reflect.ownKeys)(t).forEach((n=>{u(e,n,t[n])}))}const c=Object.defineProperty;function u(e,t,n,r){c(e,t,s(n&&o(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function h(e){return{from:function(t){return e.prototype=Object.create(t.prototype),u(e.prototype,"constructor",e),{extend:l.bind(null,e.prototype)}}}}const d=Object.getOwnPropertyDescriptor;function f(e,t){let n;return d(e,t)||(n=i(e))&&f(n,t)}const y=[].slice;function p(e,t,n){return y.call(e,t,n)}function m(e,t){return t(e)}function g(e){if(!e)throw new Error("Assertion Failed")}function v(e){t.setImmediate?setImmediate(e):setTimeout(e,0)}function b(e,t){return e.reduce(((e,n,r)=>{var s=t(n,r);return s&&(e[s[0]]=s[1]),e}),{})}function w(e,t){if(o(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,s=t.length;r<s;++r){var i=w(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var l=e[t.substr(0,a)];return void 0===l?void 0:w(l,t.substr(a+1))}}function _(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){g("string"!=typeof n&&"length"in n);for(var s=0,i=t.length;s<i;++s)_(e,t[s],n[s])}else{var a=t.indexOf(".");if(-1!==a){var l=t.substr(0,a),c=t.substr(a+1);if(""===c)void 0===n?r(e)&&!isNaN(parseInt(l))?e.splice(l,1):delete e[l]:e[l]=n;else{var u=e[l];u&&o(e,l)||(u=e[l]={}),_(u,c,n)}}else void 0===n?r(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function k(e){var t={};for(var n in e)o(e,n)&&(t[n]=e[n]);return t}const x=[].concat;function E(e){return x.apply([],e)}const S="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(E([8,16,32,64].map((e=>["Int","Uint","Float"].map((t=>t+e+"Array")))))).filter((e=>t[e])),P=S.map((e=>t[e]));b(S,(e=>[e,!0]));let O=null;function K(e){O="undefined"!=typeof WeakMap&&new WeakMap;const t=j(e);return O=null,t}function j(e){if(!e||"object"!=typeof e)return e;let t=O&&O.get(e);if(t)return t;if(r(e)){t=[],O&&O.set(e,t);for(var n=0,s=e.length;n<s;++n)t.push(j(e[n]))}else if(P.indexOf(e.constructor)>=0)t=e;else{const n=i(e);for(var a in t=n===Object.prototype?{}:Object.create(n),O&&O.set(e,t),e)o(e,a)&&(t[a]=j(e[a]))}return t}const{toString:C}={};function R(e){return C.call(e).slice(8,-1)}const A="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",I="symbol"==typeof A?function(e){var t;return null!=e&&(t=e[A])&&t.apply(e)}:function(){return null},D={};function T(e){var t,n,s,i;if(1===arguments.length){if(r(e))return e.slice();if(this===D&&"string"==typeof e)return[e];if(i=I(e)){for(n=[];!(s=i.next()).done;)n.push(s.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}const B="undefined"!=typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var N="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function F(e,t){N=e,M=t}var M=()=>!0;const q=!new Error("").stack;function $(){if(q)try{throw $.arguments,new Error}catch(e){return e}return new Error}function V(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(M).map((e=>"\n"+e)).join("")):""}var U=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],L=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(U),W={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function H(e,t){this._e=$(),this.name=e,this.message=t}function Y(e,t){return e+". Errors: "+Object.keys(t).map((e=>t[e].toString())).filter(((e,t,n)=>n.indexOf(e)===t)).join("\n")}function z(e,t,n,r){this._e=$(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=Y(e,t)}function G(e,t){this._e=$(),this.name="BulkError",this.failures=Object.keys(t).map((e=>t[e])),this.failuresByPos=t,this.message=Y(e,t)}h(H).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+V(this._e,2))}},toString:function(){return this.name+": "+this.message}}),h(z).from(H),h(G).from(H);var J=L.reduce(((e,t)=>(e[t]=t+"Error",e)),{});const Q=H;var X=L.reduce(((e,t)=>{var n=t+"Error";function r(e,r){this._e=$(),this.name=n,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=W[t]||n,this.inner=null)}return h(r).from(Q),e[t]=r,e}),{});X.Syntax=SyntaxError,X.Type=TypeError,X.Range=RangeError;var Z=U.reduce(((e,t)=>(e[t+"Error"]=X[t],e)),{}),ee=L.reduce(((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=X[t]),e)),{});function te(){}function ne(e){return e}function re(e,t){return null==e||e===ne?t:function(n){return t(e(n))}}function se(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ie(e,t){return e===te?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?se(r,this.onsuccess):r),s&&(this.onerror=this.onerror?se(s,this.onerror):s),void 0!==i?i:n}}function ae(e,t){return e===te?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?se(n,this.onsuccess):n),r&&(this.onerror=this.onerror?se(r,this.onerror):r)}}function oe(e,t){return e===te?t:function(n){var r=e.apply(this,arguments);s(n,r);var i=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?se(i,this.onsuccess):i),a&&(this.onerror=this.onerror?se(a,this.onerror):a),void 0===r?void 0===o?void 0:o:s(r,o)}}function le(e,t){return e===te?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ce(e,t){return e===te?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,s=arguments.length,i=new Array(s);s--;)i[s]=arguments[s];return n.then((function(){return t.apply(r,i)}))}return t.apply(this,arguments)}}ee.ModifyError=z,ee.DexieError=H,ee.BulkError=G;var ue={};const[he,de,fe]="undefined"==typeof Promise?[]:(()=>{let e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,i(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,i(t),e]})(),ye=de&&de.then,pe=he&&he.constructor,me=!!fe;var ge=!1,ve=fe?()=>{fe.then($e)}:t.setImmediate?setImmediate.bind(null,$e):t.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver((()=>{$e(),e=null})).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout($e,0)},be=function(e,t){Ke.push([e,t]),_e&&(ve(),_e=!1)},we=!0,_e=!0,ke=[],xe=[],Ee=null,Se=ne,Pe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ht,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach((e=>{try{ht(e[0],e[1])}catch(e){}}))}},Oe=Pe,Ke=[],je=0,Ce=[];function Re(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=te,this._lib=!1;var t=this._PSD=Oe;if(N&&(this._stackHolder=$(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==ue)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Te(this,this._value))}this._state=null,this._value=null,++t.ref,De(this,e)}const Ae={get:function(){var e=Oe,t=Qe;function n(n,r){var s=!e.global&&(e!==Oe||t!==Qe);const i=s&&!tt();var a=new Re(((t,a)=>{Ne(this,new Ie(ct(n,e,s,i),ct(r,e,s,i),t,a,e))}));return N&&qe(a,this),a}return n.prototype=ue,n},set:function(e){u(this,"then",e&&e.prototype===ue?Ae:{get:function(){return e},set:Ae.set})}};function Ie(e,t,n,r,s){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=s}function De(e,t){try{t((t=>{if(null===e._state){if(t===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&Ve();t&&"function"==typeof t.then?De(e,((e,n)=>{t instanceof Re?t._then(e,n):t.then(e,n)})):(e._state=!0,e._value=t,Be(e)),n&&Ue()}}),Te.bind(null,e))}catch(t){Te(e,t)}}function Te(e,t){if(xe.push(t),null===e._state){var n=e._lib&&Ve();t=Se(t),e._state=!1,e._value=t,N&&null!==t&&"object"==typeof t&&!t._promise&&function(e,t,n){try{e.apply(null,void 0)}catch(e){}}((()=>{var n=f(t,"stack");t._promise=e,u(t,"stack",{get:()=>ge?n&&(n.get?n.get.apply(t):n.value):e.stack})})),function(e){ke.some((t=>t._value===e._value))||ke.push(e)}(e),Be(e),n&&Ue()}}function Be(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Ne(e,t[n]);var s=e._PSD;--s.ref||s.finalize(),0===je&&(++je,be((()=>{0==--je&&Le()}),[]))}function Ne(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++je,be(Fe,[n,e,t])}else e._listeners.push(t)}function Fe(e,t,n){try{Ee=t;var r,s=t._value;t._state?r=e(s):(xe.length&&(xe=[]),r=e(s),-1===xe.indexOf(s)&&function(e){for(var t=ke.length;t;)if(ke[--t]._value===e._value)return void ke.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{Ee=null,0==--je&&Le(),--n.psd.ref||n.psd.finalize()}}function Me(e,t,n){if(t.length===n)return t;var r="";if(!1===e._state){var s,i,a=e._value;null!=a?(s=a.name||"Error",i=a.message||a,r=V(a,0)):(s=a,i=""),t.push(s+(i?": "+i:"")+r)}return N&&((r=V(e._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),e._prev&&Me(e._prev,t,n)),t}function qe(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function $e(){Ve()&&Ue()}function Ve(){var e=we;return we=!1,_e=!1,e}function Ue(){var e,t,n;do{for(;Ke.length>0;)for(e=Ke,Ke=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(Ke.length>0);we=!0,_e=!0}function Le(){var e=ke;ke=[],e.forEach((e=>{e._PSD.onunhandled.call(null,e._value,e)}));for(var t=Ce.slice(0),n=t.length;n;)t[--n]()}function We(e){return new Re(ue,!1,e)}function He(e,t){var n=Oe;return function(){var r=Ve(),s=Oe;try{return it(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{it(s,!1),r&&Ue()}}}l(Re.prototype,{then:Ae,_then:function(e,t){Ne(this,new Ie(null,null,e,t,Oe))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,(e=>e instanceof t?n(e):We(e))):this.then(null,(e=>e&&e.name===t?n(e):We(e)))},finally:function(e){return this.then((t=>(e(),t)),(t=>(e(),We(t))))},stack:{get:function(){if(this._stack)return this._stack;try{ge=!0;var e=Me(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{ge=!1}}},timeout:function(e,t){return e<1/0?new Re(((n,r)=>{var s=setTimeout((()=>r(new X.Timeout(t))),e);this.then(n,r).finally(clearTimeout.bind(null,s))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&u(Re.prototype,Symbol.toStringTag,"Dexie.Promise"),Pe.env=at(),l(Re,{all:function(){var e=T.apply(null,arguments).map(nt);return new Re((function(t,n){0===e.length&&t([]);var r=e.length;e.forEach(((s,i)=>Re.resolve(s).then((n=>{e[i]=n,--r||t(e)}),n)))}))},resolve:e=>{if(e instanceof Re)return e;if(e&&"function"==typeof e.then)return new Re(((t,n)=>{e.then(t,n)}));var t=new Re(ue,!0,e);return qe(t,Ee),t},reject:We,race:function(){var e=T.apply(null,arguments).map(nt);return new Re(((t,n)=>{e.map((e=>Re.resolve(e).then(t,n)))}))},PSD:{get:()=>Oe,set:e=>Oe=e},totalEchoes:{get:()=>Qe},newPSD:Ze,usePSD:ot,scheduler:{get:()=>be,set:e=>{be=e}},rejectionMapper:{get:()=>Se,set:e=>{Se=e}},follow:(e,t)=>new Re(((n,r)=>Ze(((t,n)=>{var r=Oe;r.unhandleds=[],r.onunhandled=n,r.finalize=se((function(){!function(e){Ce.push((function t(){e(),Ce.splice(Ce.indexOf(t),1)})),++je,be((()=>{0==--je&&Le()}),[])}((()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])}))}),r.finalize),e()}),t,n,r)))}),pe&&(pe.allSettled&&u(Re,"allSettled",(function(){const e=T.apply(null,arguments).map(nt);return new Re((t=>{0===e.length&&t([]);let n=e.length;const r=new Array(n);e.forEach(((e,s)=>Re.resolve(e).then((e=>r[s]={status:"fulfilled",value:e}),(e=>r[s]={status:"rejected",reason:e})).then((()=>--n||t(r)))))}))})),pe.any&&"undefined"!=typeof AggregateError&&u(Re,"any",(function(){const e=T.apply(null,arguments).map(nt);return new Re(((t,n)=>{0===e.length&&n(new AggregateError([]));let r=e.length;const s=new Array(r);e.forEach(((e,i)=>Re.resolve(e).then((e=>t(e)),(e=>{s[i]=e,--r||n(new AggregateError(s))}))))}))})));const Ye={awaits:0,echoes:0,id:0};var ze=0,Ge=[],Je=0,Qe=0,Xe=0;function Ze(e,t,n,r){var i=Oe,a=Object.create(i);a.parent=i,a.ref=0,a.global=!1,a.id=++Xe;var o=Pe.env;a.env=me?{Promise:Re,PromiseProp:{value:Re,configurable:!0,writable:!0},all:Re.all,race:Re.race,allSettled:Re.allSettled,any:Re.any,resolve:Re.resolve,reject:Re.reject,nthen:ut(o.nthen,a),gthen:ut(o.gthen,a)}:{},t&&s(a,t),++i.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize()};var l=ot(a,e,n,r);return 0===a.ref&&a.finalize(),l}function et(){return Ye.id||(Ye.id=++ze),++Ye.awaits,Ye.echoes+=100,Ye.id}function tt(){return!!Ye.awaits&&(0==--Ye.awaits&&(Ye.id=0),Ye.echoes=100*Ye.awaits,!0)}function nt(e){return Ye.echoes&&e&&e.constructor===pe?(et(),e.then((e=>(tt(),e)),(e=>(tt(),dt(e))))):e}function rt(e){++Qe,Ye.echoes&&0!=--Ye.echoes||(Ye.echoes=Ye.id=0),Ge.push(Oe),it(e,!0)}function st(){var e=Ge[Ge.length-1];Ge.pop(),it(e,!1)}function it(e,n){var r=Oe;if((n?!Ye.echoes||Je++&&e===Oe:!Je||--Je&&e===Oe)||lt(n?rt.bind(null,e):st),e!==Oe&&(Oe=e,r===Pe&&(Pe.env=at()),me)){var s=Pe.env.Promise,i=e.env;de.then=i.nthen,s.prototype.then=i.gthen,(r.global||e.global)&&(Object.defineProperty(t,"Promise",i.PromiseProp),s.all=i.all,s.race=i.race,s.resolve=i.resolve,s.reject=i.reject,i.allSettled&&(s.allSettled=i.allSettled),i.any&&(s.any=i.any))}}function at(){var e=t.Promise;return me?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(t,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:de.then,gthen:e.prototype.then}:{}}function ot(e,t,n,r,s){var i=Oe;try{return it(e,!0),t(n,r,s)}finally{it(i,!1)}}function lt(e){ye.call(he,e)}function ct(e,t,n,r){return"function"!=typeof e?e:function(){var s=Oe;n&&et(),it(t,!0);try{return e.apply(this,arguments)}finally{it(s,!1),r&&lt(tt)}}}function ut(e,t){return function(n,r){return e.call(this,ct(n,t),ct(r,t))}}function ht(e,n){var r;try{r=n.onuncatched(e)}catch(e){}if(!1!==r)try{var i,a={promise:n,reason:e};if(t.document&&document.createEvent?((i=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),s(i,a)):t.CustomEvent&&s(i=new CustomEvent("unhandledrejection",{detail:a}),a),i&&t.dispatchEvent&&(dispatchEvent(i),!t.PromiseRejectionEvent&&t.onunhandledrejection))try{t.onunhandledrejection(i)}catch(e){}N&&i&&!i.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch(e){}}-1===(""+ye).indexOf("[native code]")&&(et=tt=te);var dt=Re.reject;function ft(e,t,n,r){if(e.idbdb&&(e._state.openComplete||Oe.letThrough||e._vip)){var s=e._createTransaction(t,n,e._dbSchema);try{s.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===J.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>ft(e,t,n,r)))):dt(s)}return s._promise(t,((e,t)=>Ze((()=>(Oe.trans=s,r(e,t,s)))))).then((e=>s._completion.then((()=>e))))}if(e._state.openComplete)return dt(new X.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return dt(new X.DatabaseClosed);e.open().catch(te)}return e._state.dbReadyPromise.then((()=>ft(e,t,n,r)))}const yt=String.fromCharCode(65535),pt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",mt=[],gt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),vt=gt,bt=gt,wt=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function _t(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const kt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function xt(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=K(t))[e],t)}class Et{_trans(e,t,n){const r=this._tx||Oe.trans,s=this.name;function i(e,n,r){if(!r.schema[s])throw new X.NotFound("Table "+s+" not part of transaction");return t(r.idbtrans,r)}const a=Ve();try{return r&&r.db===this.db?r===Oe.trans?r._promise(e,i,n):Ze((()=>r._promise(e,i,n)),{trans:r,transless:Oe.transless||Oe}):ft(this.db,e,[this.name],i)}finally{a&&Ue()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",(t=>this.core.get({trans:t,key:e}).then((e=>this.hook.reading.fire(e))))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(r(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const t=n(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);const s=this.schema.indexes.concat(this.schema.primKey).filter((e=>e.compound&&t.every((t=>e.keyPath.indexOf(t)>=0))&&e.keyPath.every((e=>t.indexOf(e)>=0))))[0];if(s&&this.db._maxKey!==yt)return this.where(s.name).equals(s.keyPath.map((t=>e[t])));!s&&N&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${t.join("+")}]`);const{idxByName:i}=this.schema,a=this.db._deps.indexedDB;function o(e,t){try{return 0===a.cmp(e,t)}catch(e){return!1}}const[l,c]=t.reduce((([t,n],s)=>{const a=i[s],l=e[s];return[t||a,t||!a?_t(n,a&&a.multi?e=>{const t=w(e,s);return r(t)&&t.some((e=>o(l,e)))}:e=>o(l,w(e,s))):n]}),[null,null]);return l?this.where(l.name).equals(e[l.keyPath]).filter(c):s?this.filter(c):this.where(t).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,r(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const t=t=>{if(!t)return t;const n=Object.create(e.prototype);for(var r in t)if(o(t,r))try{n[r]=t[r]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e}defineClass(){return this.mapToClass((function(e){s(this,e)}))}add(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let s=e;return r&&n&&(s=xt(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[s]}))).then((e=>e.numFailures?Re.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{_(e,r,t)}catch(e){}return t}))}update(e,t){if("object"!=typeof e||r(e))return this.where(":id").equals(e).modify(t);{const r=w(e,this.schema.primKey.keyPath);if(void 0===r)return dt(new X.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof t?n(t).forEach((n=>{_(e,n,t[n])})):t(e,{value:e,primKey:r})}catch(e){}return this.where(":id").equals(r).modify(t)}}put(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let s=e;return r&&n&&(s=xt(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"put",values:[s],keys:null!=t?[t]:null}))).then((e=>e.numFailures?Re.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{_(e,r,t)}catch(e){}return t}))}delete(e){return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:[e]}))).then((e=>e.numFailures?Re.reject(e.failures[0]):void 0))}clear(){return this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"deleteRange",range:kt}))).then((e=>e.numFailures?Re.reject(e.failures[0]):void 0))}bulkGet(e){return this._trans("readonly",(t=>this.core.getMany({keys:e,trans:t}).then((e=>e.map((e=>this.hook.reading.fire(e)))))))}bulkAdd(e,t,n){const r=Array.isArray(t)?t:void 0,s=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new X.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");const a=e.length;let o=i&&n?e.map(xt(i)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:o,wantResults:s}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return s?t:n;throw new G(`${this.name}.bulkAdd(): ${e} of ${a} operations failed`,r)}))}))}bulkPut(e,t,n){const r=Array.isArray(t)?t:void 0,s=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new X.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");const a=e.length;let o=i&&n?e.map(xt(i)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:o,wantResults:s}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return s?t:n;throw new G(`${this.name}.bulkPut(): ${e} of ${a} operations failed`,r)}))}))}bulkDelete(e){const t=e.length;return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:e}))).then((({numFailures:e,lastResult:n,failures:r})=>{if(0===e)return n;throw new G(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)}))}}function St(e){var t={},s=function(n,r){if(r){for(var s=arguments.length,i=new Array(s-1);--s;)i[s-1]=arguments[s];return t[n].subscribe.apply(null,i),e}if("string"==typeof n)return t[n]};s.addEventType=o;for(var i=1,a=arguments.length;i<a;++i)o(arguments[i]);return s;function o(e,n,r){if("object"==typeof e)return l(e);n||(n=le),r||(r=te);var i={subscribers:[],fire:r,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=n(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter((function(t){return t!==e})),i.fire=i.subscribers.reduce(n,r)}};return t[e]=s[e]=i,i}function l(e){n(e).forEach((function(t){var n=e[t];if(r(n))o(t,e[t][0],e[t][1]);else{if("asap"!==n)throw new X.InvalidArgument("Invalid event config");var s=o(t,ne,(function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];s.subscribers.forEach((function(e){v((function(){e.apply(null,t)}))}))}))}}))}}function Pt(e,t){return h(t).from({prototype:e}),t}function Ot(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Kt(e,t){e.filter=_t(e.filter,t)}function jt(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>_t(r(),t()):t,e.justLimit=n&&!r}function Ct(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new X.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Rt(e,t,n){const r=Ct(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function At(e,t,n,r){const s=e.replayFilter?_t(e.filter,e.replayFilter()):e.filter;if(e.or){const i={},a=(e,n,r)=>{if(!s||s(n,r,(e=>n.stop(e)),(e=>n.fail(e)))){var a=n.primaryKey,l=""+a;"[object ArrayBuffer]"===l&&(l=""+new Uint8Array(a)),o(i,l)||(i[l]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(a,n),It(Rt(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return It(Rt(e,r,n),_t(e.algorithm,s),t,!e.keysOnly&&e.valueMapper)}function It(e,t,n,r){var s=He(r?(e,t,s)=>n(r(e),t,s):n);return e.then((e=>{if(e)return e.start((()=>{var n=()=>e.continue();t&&!t(e,(e=>n=e),(t=>{e.stop(t),n=te}),(t=>{e.fail(t),n=te}))||s(e.value,e,(e=>n=e)),n()}))}))}function Dt(e,t){try{const n=Tt(e),r=Tt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){const n=e.length,r=t.length,s=n<r?n:r;for(let n=0;n<s;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===r?0:n<r?-1:1}(Bt(e),Bt(t));case"Array":return function(e,t){const n=e.length,r=t.length,s=n<r?n:r;for(let n=0;n<s;++n){const r=Dt(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function Tt(e){const t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";const n=R(e);return"ArrayBuffer"===n?"binary":n}function Bt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class Nt{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,dt.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,dt.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=_t(t.algorithm,e)}_iterate(e,t){return At(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&s(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read((n=>At(t,e,n,t.table.core)))}count(e){return this._read((e=>{const t=this._ctx,n=t.table.core;if(Ot(t,!0))return n.count({trans:e,query:{index:Ct(t,n.schema),range:t.range}}).then((e=>Math.min(e,t.limit)));var r=0;return At(t,(()=>(++r,!1)),e,n).then((()=>r))})).then(e)}sortBy(e,t){const n=e.split(".").reverse(),r=n[0],s=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function o(e,t){var n=i(e,s),r=i(t,s);return n<r?-a:n>r?a:0}return this.toArray((function(e){return e.sort(o)})).then(t)}toArray(e){return this._read((e=>{var t=this._ctx;if("next"===t.dir&&Ot(t,!0)&&t.limit>0){const{valueMapper:n}=t,r=Ct(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then((({result:e})=>n?e.map(n):e))}{const n=[];return At(t,(e=>n.push(e)),e,t.table.core).then((()=>n))}}),e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,Ot(t)?jt(t,(()=>{var t=e;return(e,n)=>0===t||(1===t?(--t,!1):(n((()=>{e.advance(t),t=0})),!1))})):jt(t,(()=>{var t=e;return()=>--t<0}))),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),jt(this._ctx,(()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}}),!0),this}until(e,t){return Kt(this._ctx,(function(n,r,s){return!e(n.value)||(r(s),t)})),this}first(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)}last(e){return this.reverse().first(e)}filter(e){var t,n;return Kt(this._ctx,(function(t){return e(t.value)})),t=this._ctx,n=e,t.isMatch=_t(t.isMatch,n),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.key,n)}))}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.primaryKey,n)}))}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.key)})).then((function(){return n})).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&Ot(t,!0)&&t.limit>0)return this._read((e=>{var n=Ct(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})})).then((({result:e})=>e)).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.primaryKey)})).then((function(){return n})).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys((function(e){return e[0]})).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return Kt(this._ctx,(function(e){var t=e.primaryKey.toString(),r=o(n,t);return n[t]=!0,!r})),this}modify(e){var t=this._ctx;return this._write((r=>{var s;if("function"==typeof e)s=e;else{var i=n(e),a=i.length;s=function(t){for(var n=!1,r=0;r<a;++r){var s=i[r],o=e[s];w(t,s)!==o&&(_(t,s,o),n=!0)}return n}}const o=t.table.core,{outbound:l,extractKey:c}=o.schema.primaryKey,u=this.db._options.modifyChunkSize||200,h=[];let d=0;const f=[],y=(e,t)=>{const{failures:r,numFailures:s}=t;d+=e-s;for(let e of n(r))h.push(r[e])};return this.clone().primaryKeys().then((n=>{const i=a=>{const h=Math.min(u,n.length-a);return o.getMany({trans:r,keys:n.slice(a,a+h),cache:"immutable"}).then((d=>{const f=[],p=[],m=l?[]:null,g=[];for(let e=0;e<h;++e){const t=d[e],r={value:K(t),primKey:n[a+e]};!1!==s.call(r,r.value,r)&&(null==r.value?g.push(n[a+e]):l||0===Dt(c(t),c(r.value))?(p.push(r.value),l&&m.push(n[a+e])):(g.push(n[a+e]),f.push(r.value)))}const v=Ot(t)&&t.limit===1/0&&("function"!=typeof e||e===Ft)&&{index:t.index,range:t.range};return Promise.resolve(f.length>0&&o.mutate({trans:r,type:"add",values:f}).then((e=>{for(let t in e.failures)g.splice(parseInt(t),1);y(f.length,e)}))).then((()=>(p.length>0||v&&"object"==typeof e)&&o.mutate({trans:r,type:"put",keys:m,values:p,criteria:v,changeSpec:"function"!=typeof e&&e}).then((e=>y(p.length,e))))).then((()=>(g.length>0||v&&e===Ft)&&o.mutate({trans:r,type:"delete",keys:g,criteria:v}).then((e=>y(g.length,e))))).then((()=>n.length>a+h&&i(a+u)))}))};return i(0).then((()=>{if(h.length>0)throw new z("Error modifying one or more objects",h,d,f);return n.length}))}))}))}delete(){var e=this._ctx,t=e.range;return Ot(e)&&(e.isPrimKey&&!bt||3===t.type)?this._write((n=>{const{primaryKey:r}=e.table.core.schema,s=t;return e.table.core.count({trans:n,query:{index:r,range:s}}).then((t=>e.table.core.mutate({trans:n,type:"deleteRange",range:s}).then((({failures:e,lastResult:n,results:r,numFailures:s})=>{if(s)throw new z("Could not delete some values",Object.keys(e).map((t=>e[t])),t-s);return t-s}))))})):this.modify(Ft)}}const Ft=(e,t)=>t.value=null;function Mt(e,t){return e<t?-1:e===t?0:1}function qt(e,t){return e>t?-1:e===t?0:1}function $t(e,t,n){var r=e instanceof Yt?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function Vt(e){return new e.Collection(e,(()=>Ht(""))).limit(0)}function Ut(e,t,n,r,s,i){for(var a=Math.min(e.length,r.length),o=-1,l=0;l<a;++l){var c=t[l];if(c!==r[l])return s(e[l],n[l])<0?e.substr(0,l)+n[l]+n.substr(l+1):s(e[l],r[l])<0?e.substr(0,l)+r[l]+n.substr(l+1):o>=0?e.substr(0,o)+t[o]+n.substr(o+1):null;s(e[l],c)<0&&(o=l)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):o<0?null:e.substr(0,o)+r[o]+n.substr(o+1)}function Lt(e,t,n,r){var s,i,a,o,l,c,u,h=n.length;if(!n.every((e=>"string"==typeof e)))return $t(e,"String expected.");function d(e){s=function(e){return"next"===e?e=>e.toUpperCase():e=>e.toLowerCase()}(e),i=function(e){return"next"===e?e=>e.toLowerCase():e=>e.toUpperCase()}(e),a="next"===e?Mt:qt;var t=n.map((function(e){return{lower:i(e),upper:s(e)}})).sort((function(e,t){return a(e.lower,t.lower)}));o=t.map((function(e){return e.upper})),l=t.map((function(e){return e.lower})),c=e,u="next"===e?"":r}d("next");var f=new e.Collection(e,(()=>Wt(o[0],l[h-1]+r)));f._ondirectionchange=function(e){d(e)};var y=0;return f._addAlgorithm((function(e,n,r){var s=e.key;if("string"!=typeof s)return!1;var d=i(s);if(t(d,l,y))return!0;for(var f=null,p=y;p<h;++p){var m=Ut(s,d,o[p],l[p],a,c);null===m&&null===f?y=p+1:(null===f||a(f,m)>0)&&(f=m)}return n(null!==f?function(){e.continue(f+u)}:r),!1})),f}function Wt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Ht(e){return{type:1,lower:e,upper:e}}class Yt{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Vt(this):new this.Collection(this,(()=>Wt(e,t,!n,!r)))}catch(e){return $t(this,pt)}}equals(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Ht(e)))}above(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(e,void 0,!0)))}aboveOrEqual(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(e,void 0,!1)))}below(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(void 0,e,!1,!0)))}belowOrEqual(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(void 0,e)))}startsWith(e){return"string"!=typeof e?$t(this,"String expected."):this.between(e,e+yt,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):Lt(this,((e,t)=>0===e.indexOf(t[0])),[e],yt)}equalsIgnoreCase(e){return Lt(this,((e,t)=>e===t[0]),[e],"")}anyOfIgnoreCase(){var e=T.apply(D,arguments);return 0===e.length?Vt(this):Lt(this,((e,t)=>-1!==t.indexOf(e)),e,"")}startsWithAnyOfIgnoreCase(){var e=T.apply(D,arguments);return 0===e.length?Vt(this):Lt(this,((e,t)=>t.some((t=>0===e.indexOf(t)))),e,yt)}anyOf(){const e=T.apply(D,arguments);let t=this._cmp;try{e.sort(t)}catch(e){return $t(this,pt)}if(0===e.length)return Vt(this);const n=new this.Collection(this,(()=>Wt(e[0],e[e.length-1])));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let r=0;return n._addAlgorithm(((n,s,i)=>{const a=n.key;for(;t(a,e[r])>0;)if(++r,r===e.length)return s(i),!1;return 0===t(a,e[r])||(s((()=>{n.continue(e[r])})),!1)})),n}notEqual(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=T.apply(D,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return $t(this,pt)}const t=e.reduce(((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]),null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){const n=this._cmp,r=this._ascending,s=this._descending,i=this._min,a=this._max;if(0===e.length)return Vt(this);if(!e.every((e=>void 0!==e[0]&&void 0!==e[1]&&r(e[0],e[1])<=0)))return $t(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",X.InvalidArgument);const o=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers;let c,u=r;function h(e,t){return u(e[0],t[0])}try{c=e.reduce((function(e,t){let r=0,s=e.length;for(;r<s;++r){const s=e[r];if(n(t[0],s[1])<0&&n(t[1],s[0])>0){s[0]=i(s[0],t[0]),s[1]=a(s[1],t[1]);break}}return r===s&&e.push(t),e}),[]),c.sort(h)}catch(e){return $t(this,pt)}let d=0;const f=l?e=>r(e,c[d][1])>0:e=>r(e,c[d][1])>=0,y=o?e=>s(e,c[d][0])>0:e=>s(e,c[d][0])>=0;let p=f;const m=new this.Collection(this,(()=>Wt(c[0][0],c[c.length-1][1],!o,!l)));return m._ondirectionchange=e=>{"next"===e?(p=f,u=r):(p=y,u=s),c.sort(h)},m._addAlgorithm(((e,t,n)=>{for(var s=e.key;p(s);)if(++d,d===c.length)return t(n),!1;return!!function(e){return!f(e)&&!y(e)}(s)||(0===this._cmp(s,c[d][1])||0===this._cmp(s,c[d][0])||t((()=>{u===r?e.continue(c[d][0]):e.continue(c[d][1])})),!1)})),m}startsWithAnyOf(){const e=T.apply(D,arguments);return e.every((e=>"string"==typeof e))?0===e.length?Vt(this):this.inAnyRange(e.map((e=>[e,e+yt]))):$t(this,"startsWithAnyOf() only works with strings")}}function zt(e){return He((function(t){return Gt(t),e(t.target.error),!1}))}function Gt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const Jt=St(null,"storagemutated");class Qt{_lock(){return g(!Oe.global),++this._reculock,1!==this._reculock||Oe.global||(Oe.lockOwnerFor=this),this}_unlock(){if(g(!Oe.global),0==--this._reculock)for(Oe.global||(Oe.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{ot(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&Oe.lockOwnerFor!==this}create(e){if(!this.mode)return this;const t=this.db.idbdb,n=this.db._state.dbOpenError;if(g(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new X.DatabaseClosed(n);case"MissingAPIError":throw new X.MissingAPI(n.message,n);default:throw new X.OpenFailed(n)}if(!this.active)throw new X.TransactionInactive;return g(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=He((t=>{Gt(t),this._reject(e.error)})),e.onabort=He((t=>{Gt(t),this.active&&this._reject(new X.Abort(e.error)),this.active=!1,this.on("abort").fire(t)})),e.oncomplete=He((()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Jt.storagemutated.fire(e.mutatedParts)})),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return dt(new X.ReadOnly("Transaction is readonly"));if(!this.active)return dt(new X.TransactionInactive);if(this._locked())return new Re(((r,s)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,s)},Oe])}));if(n)return Ze((()=>{var e=new Re(((e,n)=>{this._lock();const r=t(e,n,this);r&&r.then&&r.then(e,n)}));return e.finally((()=>this._unlock())),e._lib=!0,e}));var r=new Re(((e,n)=>{var r=t(e,n,this);r&&r.then&&r.then(e,n)}));return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();const n=Re.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then((()=>n));else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var s=t._waitingFor;return new Re(((e,r)=>{n.then((n=>t._waitingQueue.push(He(e.bind(null,n)))),(e=>t._waitingQueue.push(He(r.bind(null,e))))).finally((()=>{t._waitingFor===s&&(t._waitingFor=null)}))}))}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new X.Abort))}table(e){const t=this._memoizedTables||(this._memoizedTables={});if(o(t,e))return t[e];const n=this.schema[e];if(!n)throw new X.NotFound("Table "+e+" not part of transaction");const r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function Xt(e,t,n,r,s,i,a){return{name:e,keyPath:t,unique:n,multi:r,auto:s,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(s?"++":"")+Zt(t)}}function Zt(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function en(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:b(n,(e=>[e.name,e]))}}let tn=e=>{try{return e.only([[]]),tn=()=>[[]],[[]]}catch(e){return tn=()=>yt,yt}};function nn(e){return null==e?()=>{}:"string"==typeof e?function(e){return 1===e.split(".").length?t=>t[e]:t=>w(t,e)}(e):t=>w(t,e)}function rn(e){return[].slice.call(e)}let sn=0;function an(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function on(e,t,n){function s(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:n,upper:r,lowerOpen:s,upperOpen:i}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!i):void 0===r?t.lowerBound(n,!!s):t.bound(n,r,!!s,!!i)}const{schema:i,hasGetAll:a}=function(e,t){const n=rn(e.objectStoreNames);return{schema:{name:e.name,tables:n.map((e=>t.objectStore(e))).map((e=>{const{keyPath:t,autoIncrement:n}=e,s=r(t),i=null==t,a={},o={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:i,compound:s,keyPath:t,autoIncrement:n,unique:!0,extractKey:nn(t)},indexes:rn(e.indexNames).map((t=>e.index(t))).map((e=>{const{name:t,unique:n,multiEntry:s,keyPath:i}=e,o={name:t,compound:r(i),keyPath:i,unique:n,multiEntry:s,extractKey:nn(i)};return a[an(i)]=o,o})),getIndexByKeyPath:e=>a[an(e)]};return a[":id"]=o.primaryKey,null!=t&&(a[an(t)]=o.primaryKey),o}))},hasGetAll:n.length>0&&"getAll"in t.objectStore(n[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,n),o=i.tables.map((e=>function(e){const t=e.name;return{name:t,schema:e,mutate:function({trans:e,type:n,keys:r,values:i,range:a}){return new Promise(((o,l)=>{o=He(o);const c=e.objectStore(t),u=null==c.keyPath,h="put"===n||"add"===n;if(!h&&"delete"!==n&&"deleteRange"!==n)throw new Error("Invalid operation type: "+n);const{length:d}=r||i||{length:1};if(r&&i&&r.length!==i.length)throw new Error("Given keys array must have same length as given values array.");if(0===d)return o({numFailures:0,failures:{},results:[],lastResult:void 0});let f;const y=[],p=[];let m=0;const g=e=>{++m,Gt(e)};if("deleteRange"===n){if(4===a.type)return o({numFailures:m,failures:p,results:[],lastResult:void 0});3===a.type?y.push(f=c.clear()):y.push(f=c.delete(s(a)))}else{const[e,t]=h?u?[i,r]:[i,null]:[r,null];if(h)for(let r=0;r<d;++r)y.push(f=t&&void 0!==t[r]?c[n](e[r],t[r]):c[n](e[r])),f.onerror=g;else for(let t=0;t<d;++t)y.push(f=c[n](e[t])),f.onerror=g}const v=e=>{const t=e.target.result;y.forEach(((e,t)=>null!=e.error&&(p[t]=e.error))),o({numFailures:m,failures:p,results:"delete"===n?r:y.map((e=>e.result)),lastResult:t})};f.onerror=e=>{g(e),v(e)},f.onsuccess=v}))},getMany:({trans:e,keys:n})=>new Promise(((r,s)=>{r=He(r);const i=e.objectStore(t),a=n.length,o=new Array(a);let l,c=0,u=0;const h=e=>{const t=e.target;o[t._pos]=t.result,++u===c&&r(o)},d=zt(s);for(let e=0;e<a;++e)null!=n[e]&&(l=i.get(n[e]),l._pos=e,l.onsuccess=h,l.onerror=d,++c);0===c&&r(o)})),get:({trans:e,key:n})=>new Promise(((r,s)=>{r=He(r);const i=e.objectStore(t).get(n);i.onsuccess=e=>r(e.target.result),i.onerror=zt(s)})),query:function(e){return n=>new Promise(((r,i)=>{r=He(r);const{trans:a,values:o,limit:l,query:c}=n,u=l===1/0?void 0:l,{index:h,range:d}=c,f=a.objectStore(t),y=h.isPrimaryKey?f:f.index(h.name),p=s(d);if(0===l)return r({result:[]});if(e){const e=o?y.getAll(p,u):y.getAllKeys(p,u);e.onsuccess=e=>r({result:e.target.result}),e.onerror=zt(i)}else{let e=0;const t=o||!("openKeyCursor"in y)?y.openCursor(p):y.openKeyCursor(p),n=[];t.onsuccess=s=>{const i=t.result;return i?(n.push(o?i.value:i.primaryKey),++e===l?r({result:n}):void i.continue()):r({result:n})},t.onerror=zt(i)}}))}(a),openCursor:function({trans:e,values:n,query:r,reverse:i,unique:a}){return new Promise(((o,l)=>{o=He(o);const{index:c,range:u}=r,h=e.objectStore(t),d=c.isPrimaryKey?h:h.index(c.name),f=i?a?"prevunique":"prev":a?"nextunique":"next",y=n||!("openKeyCursor"in d)?d.openCursor(s(u),f):d.openKeyCursor(s(u),f);y.onerror=zt(l),y.onsuccess=He((t=>{const n=y.result;if(!n)return void o(null);n.___id=++sn,n.done=!1;const r=n.continue.bind(n);let s=n.continuePrimaryKey;s&&(s=s.bind(n));const i=n.advance.bind(n),a=()=>{throw new Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw new Error("Cursor not started")},n.fail=He(l),n.next=function(){let e=1;return this.start((()=>e--?this.continue():this.stop())).then((()=>this))},n.start=e=>{const t=new Promise(((e,t)=>{e=He(e),y.onerror=zt(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=a,e(t)}})),o=()=>{if(y.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw new Error("Cursor behind last entry")},n.stop()};return y.onsuccess=He((e=>{y.onsuccess=o,o()})),n.continue=r,n.continuePrimaryKey=s,n.advance=i,o(),t},o(n)}),l)}))},count({query:e,trans:n}){const{index:r,range:i}=e;return new Promise(((e,a)=>{const o=n.objectStore(t),l=r.isPrimaryKey?o:o.index(r.name),c=s(i),u=c?l.count(c):l.count();u.onsuccess=He((t=>e(t.target.result))),u.onerror=zt(a)}))}}}(e))),l={};return o.forEach((e=>l[e.name]=e)),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!l[e])throw new Error(`Table '${e}' not found`);return l[e]},MIN_KEY:-1/0,MAX_KEY:tn(t),schema:i}}function ln({_novip:e},t){const n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},s){const i=function(e,t){return t.reduce(((e,{create:t})=>({...e,...t(e)})),e)}(on(t,n,s),e.dbcore);return{dbcore:i}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach((t=>{const n=t.name;e.core.schema.tables.some((e=>e.name===n))&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))}))}function cn({_novip:e},t,n,r){n.forEach((n=>{const s=r[n];t.forEach((t=>{const r=f(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?u(t,n,{get(){return this.table(n)},set(e){c(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,s))}))}))}function un({_novip:e},t){t.forEach((t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]}))}function hn(e,t){return e._cfg.version-t._cfg.version}function dn(e,t,r,s){const i=e._dbSchema,a=e._createTransaction("readwrite",e._storeNames,i);a.create(r),a._completion.catch(s);const o=a._reject.bind(a),l=Oe.transless||Oe;Ze((()=>{Oe.trans=a,Oe.transless=l,0===t?(n(i).forEach((e=>{yn(r,e,i[e].primKey,i[e].indexes)})),ln(e,r),Re.follow((()=>e.on.populate.fire(a))).catch(o)):function({_novip:e},t,r,s){const i=[],a=e._versions;let o=e._dbSchema=mn(0,e.idbdb,s),l=!1;return a.filter((e=>e._cfg.version>=t)).forEach((a=>{i.push((()=>{const i=o,c=a._cfg.dbschema;gn(e,i,s),gn(e,c,s),o=e._dbSchema=c;const u=fn(i,c);u.add.forEach((e=>{yn(s,e[0],e[1].primKey,e[1].indexes)})),u.change.forEach((e=>{if(e.recreate)throw new X.Upgrade("Not yet support for changing primary key");{const t=s.objectStore(e.name);e.add.forEach((e=>pn(t,e))),e.change.forEach((e=>{t.deleteIndex(e.name),pn(t,e)})),e.del.forEach((e=>t.deleteIndex(e)))}}));const h=a._cfg.contentUpgrade;if(h&&a._cfg.version>t){ln(e,s),r._memoizedTables={},l=!0;let t=k(c);u.del.forEach((e=>{t[e]=i[e]})),un(e,[e.Transaction.prototype]),cn(e,[e.Transaction.prototype],n(t),t),r.schema=t;const a=B(h);let o;a&&et();const d=Re.follow((()=>{if(o=h(r),o&&a){var e=tt.bind(null,null);o.then(e,e)}}));return o&&"function"==typeof o.then?Re.resolve(o):d.then((()=>o))}})),i.push((t=>{l&&vt||function(e,t){[].slice.call(t.db.objectStoreNames).forEach((n=>null==e[n]&&t.db.deleteObjectStore(n)))}(a._cfg.dbschema,t),un(e,[e.Transaction.prototype]),cn(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema}))})),function e(){return i.length?Re.resolve(i.shift()(r.idbtrans)).then(e):Re.resolve()}().then((()=>{var e,t;t=s,n(e=o).forEach((n=>{t.db.objectStoreNames.contains(n)||yn(t,n,e[n].primKey,e[n].indexes)}))}))}(e,t,a,r).catch(o)}))}function fn(e,t){const n={del:[],add:[],change:[]};let r;for(r in e)t[r]||n.del.push(r);for(r in t){const s=e[r],i=t[r];if(s){const e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||s.primKey.auto!==i.primKey.auto&&!gt)e.recreate=!0,n.change.push(e);else{const t=s.idxByName,r=i.idxByName;let a;for(a in t)r[a]||e.del.push(a);for(a in r){const n=t[a],s=r[a];n?n.src!==s.src&&e.change.push(s):e.add.push(s)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}}else n.add.push([r,i])}return n}function yn(e,t,n,r){const s=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach((e=>pn(s,e))),s}function pn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function mn(e,t,n){const r={};return p(t.objectStoreNames,0).forEach((e=>{const t=n.objectStore(e);let s=t.keyPath;const i=Xt(Zt(s),s||"",!1,!1,!!t.autoIncrement,s&&"string"!=typeof s,!0),a=[];for(let e=0;e<t.indexNames.length;++e){const n=t.index(t.indexNames[e]);s=n.keyPath;var o=Xt(n.name,s,!!n.unique,!!n.multiEntry,!1,s&&"string"!=typeof s,!1);a.push(o)}r[e]=en(e,i,a)})),r}function gn({_novip:e},n,r){const s=r.db.objectStoreNames;for(let t=0;t<s.length;++t){const i=s[t],a=r.objectStore(i);e._hasGetAll="getAll"in a;for(let e=0;e<a.indexNames.length;++e){const t=a.indexNames[e],r=a.index(t).keyPath,s="string"==typeof r?r:"["+p(r).join("+")+"]";if(n[i]){const e=n[i].idxByName[s];e&&(e.name=t,delete n[i].idxByName[s],n[i].idxByName[t]=e)}}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&t.WorkerGlobalScope&&t instanceof t.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class vn{_parseStoresSpec(e,t){n(e).forEach((n=>{if(null!==e[n]){var s=e[n].split(",").map(((e,t)=>{const n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),s=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return Xt(n,s||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),r(s),0===t)})),i=s.shift();if(i.multi)throw new X.Schema("Primary key cannot be multi-valued");s.forEach((e=>{if(e.auto)throw new X.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new X.Schema("Index must have a name and cannot be an empty string")})),t[n]=en(n,i,s)}}))}stores(e){const t=this.db;this._cfg.storesSource=this._cfg.storesSource?s(this._cfg.storesSource,e):e;const r=t._versions,i={};let a={};return r.forEach((e=>{s(i,e._cfg.storesSource),a=e._cfg.dbschema={},e._parseStoresSpec(i,a)})),t._dbSchema=a,un(t,[t._allTables,t,t.Transaction.prototype]),cn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],n(a),a),t._storeNames=n(a),this}upgrade(e){return this._cfg.contentUpgrade=ce(this._cfg.contentUpgrade||te,e),this}}function bn(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new qn("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function wn(e){return e&&"function"==typeof e.databases}function _n(e){return Ze((function(){return Oe.letThrough=!0,e()}))}function kn(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise((function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()})).finally((function(){return clearInterval(e)})):Promise.resolve()}function xn(e){var t=t=>e.next(t),n=i(t),s=i((t=>e.throw(t)));function i(e){return t=>{var i=e(t),a=i.value;return i.done?a:a&&"function"==typeof a.then?a.then(n,s):r(a)?Promise.all(a).then(n,s):n(a)}}return i(t)()}function En(e,t,n){var r=arguments.length;if(r<2)throw new X.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];return n=s.pop(),[e,E(s),n]}function Sn(e,t,n,r,s){return Re.resolve().then((()=>{const i=Oe.transless||Oe,a=e._createTransaction(t,n,e._dbSchema,r),o={trans:a,transless:i};if(r)a.idbtrans=r.idbtrans;else try{a.create(),e._state.PR1398_maxLoop=3}catch(r){return r.name===J.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>Sn(e,t,n,null,s)))):dt(r)}const l=B(s);let c;l&&et();const u=Re.follow((()=>{if(c=s.call(a,a),c)if(l){var e=tt.bind(null,null);c.then(e,e)}else"function"==typeof c.next&&"function"==typeof c.throw&&(c=xn(c))}),o);return(c&&"function"==typeof c.then?Re.resolve(c).then((e=>a.active?e:dt(new X.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn")))):u.then((()=>c))).then((e=>(r&&a._resolve(),a._completion.then((()=>e))))).catch((e=>(a._reject(e),dt(e))))}))}function Pn(e,t,n){const s=r(e)?e.slice():[e];for(let e=0;e<n;++e)s.push(t);return s}const On={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const n=e.table(t),{schema:r}=n,s={},i=[];function a(e,t,n){const r=an(e),o=s[r]=s[r]||[],l=null==e?0:"string"==typeof e?1:e.length,c=t>0,u={...n,isVirtual:c,keyTail:t,keyLength:l,extractKey:nn(e),unique:!c&&n.unique};return o.push(u),u.isPrimaryKey||i.push(u),l>1&&a(2===l?e[0]:e.slice(0,l-1),t+1,n),o.sort(((e,t)=>e.keyTail-t.keyTail)),u}const o=a(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[o];for(const e of r.indexes)a(e.keyPath,0,e);function l(t){const n=t.query.index;return n.isVirtual?{...t,query:{index:n,range:(r=t.query.range,s=n.keyTail,{type:1===r.type?2:r.type,lower:Pn(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,s),lowerOpen:!0,upper:Pn(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,s),upperOpen:!0})}}:t;var r,s}const c={...n,schema:{...r,primaryKey:o,indexes:i,getIndexByKeyPath:function(e){const t=s[an(e)];return t&&t[0]}},count:e=>n.count(l(e)),query:e=>n.query(l(e)),openCursor(t){const{keyTail:r,isVirtual:s,keyLength:i}=t.query.index;return s?n.openCursor(l(t)).then((n=>n&&function(n){const s=Object.create(n,{continue:{value:function(s){null!=s?n.continue(Pn(s,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,s){n.continuePrimaryKey(Pn(t,e.MAX_KEY,r),s)}},primaryKey:{get:()=>n.primaryKey},key:{get(){const e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>n.value}});return s}(n))):n.openCursor(t)}};return c}}}};function Kn(e,t,r,s){return r=r||{},s=s||"",n(e).forEach((n=>{if(o(t,n)){var i=e[n],a=t[n];if("object"==typeof i&&"object"==typeof a&&i&&a){const e=R(i);e!==R(a)?r[s+n]=t[n]:"Object"===e?Kn(i,a,r,s+n+"."):i!==a&&(r[s+n]=t[n])}else i!==a&&(r[s+n]=t[n])}else r[s+n]=void 0})),n(t).forEach((n=>{o(e,n)||(r[s+n]=t[n])})),r}const jn={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema,s={...n,mutate(e){const s=Oe.trans,{deleting:i,creating:a,updating:l}=s.table(t).hook;switch(e.type){case"add":if(a.fire===te)break;return s._promise("readwrite",(()=>c(e)),!0);case"put":if(a.fire===te&&l.fire===te)break;return s._promise("readwrite",(()=>c(e)),!0);case"delete":if(i.fire===te)break;return s._promise("readwrite",(()=>c(e)),!0);case"deleteRange":if(i.fire===te)break;return s._promise("readwrite",(()=>function(e){return u(e.trans,e.range,1e4)}(e)),!0)}return n.mutate(e);function c(e){const t=Oe.trans,s=e.keys||function(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}(r,e);if(!s)throw new Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:s}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),function(e,t,n){return"add"===t.type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})}(n,e,s).then((c=>{const u=s.map(((n,s)=>{const u=c[s],h={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(h,n,u,t);else if("add"===e.type||void 0===u){const i=a.fire.call(h,n,e.values[s],t);null==n&&null!=i&&(n=i,e.keys[s]=n,r.outbound||_(e.values[s],r.keyPath,n))}else{const r=Kn(u,e.values[s]),i=l.fire.call(h,r,n,u,t);if(i){const t=e.values[s];Object.keys(i).forEach((e=>{o(t,e)?t[e]=i[e]:_(t,e,i[e])}))}}return h}));return n.mutate(e).then((({failures:t,results:n,numFailures:r,lastResult:i})=>{for(let r=0;r<s.length;++r){const i=n?n[r]:s[r],a=u[r];null==i?a.onerror&&a.onerror(t[r]):a.onsuccess&&a.onsuccess("put"===e.type&&c[r]?e.values[r]:i)}return{failures:t,results:n,numFailures:r,lastResult:i}})).catch((e=>(u.forEach((t=>t.onerror&&t.onerror(e))),Promise.reject(e))))}))}function u(e,t,s){return n.query({trans:e,values:!1,query:{index:r,range:t},limit:s}).then((({result:n})=>c({type:"delete",keys:n,trans:e}).then((r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<s?{failures:[],numFailures:0,lastResult:void 0}:u(e,{...t,lower:n[n.length-1],lowerOpen:!0},s)))))}}};return s}})};function Cn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;const r=[];for(let s=0,i=0;s<t.keys.length&&i<e.length;++s)0===Dt(t.keys[s],e[i])&&(r.push(n?K(t.values[s]):t.values[s]),++i);return r.length===e.length?r:null}catch(e){return null}}const Rn={stack:"dbcore",level:-1,create:e=>({table:t=>{const n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);const t=Cn(e.keys,e.trans._cache,"clone"===e.cache);return t?Re.resolve(t):n.getMany(e).then((t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?K(t):t},t)))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function An(e){return!("from"in e)}const In=function(e,t){if(!this){const t=new In;return e&&"d"in e&&s(t,e),t}s(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function Dn(e,t,n){const r=Dt(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(An(e))return s(e,{from:t,to:n,d:1});const i=e.l,a=e.r;if(Dt(n,e.from)<0)return i?Dn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Nn(e);if(Dt(t,e.to)>0)return a?Dn(a,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Nn(e);Dt(t,e.from)<0&&(e.from=t,e.l=null,e.d=a?a.d+1:1),Dt(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const o=!e.r;i&&!e.l&&Tn(e,i),a&&o&&Tn(e,a)}function Tn(e,t){An(t)||function e(t,{from:n,to:r,l:s,r:i}){Dn(t,n,r),s&&e(t,s),i&&e(t,i)}(e,t)}function Bn(e){let t=An(e)?null:{s:0,n:e};return{next(e){const n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&Dt(e,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||Dt(e,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Nn(e){var t,n;const r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),s=r>1?"r":r<-1?"l":"";if(s){const t="r"===s?"l":"r",n={...e},r=e[s];e.from=r.from,e.to=r.to,e[s]=r[s],n[s]=r[t],e[t]=n,n.d=Fn(n)}e.d=Fn(e)}function Fn({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}l(In.prototype,{add(e){return Tn(this,e),this},addKey(e){return Dn(this,e,e),this},addKeys(e){return e.forEach((e=>Dn(this,e,e))),this},[A](){return Bn(this)}});const Mn={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,s=new In(e.MIN_KEY,e.MAX_KEY);return{...e,table:i=>{const a=e.table(i),{schema:o}=a,{primaryKey:l}=o,{extractKey:c,outbound:u}=l,h={...a,mutate:e=>{const n=e.trans,l=n.mutatedParts||(n.mutatedParts={}),c=e=>{const n=`idb://${t}/${i}/${e}`;return l[n]||(l[n]=new In)},u=c(""),h=c(":dels"),{type:d}=e;let[f,y]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[];const p=e.trans._cache;return a.mutate(e).then((e=>{if(r(f)){"delete"!==d&&(f=e.results),u.addKeys(f);const t=Cn(f,p);t||"add"===d||h.addKeys(f),(t||y)&&function(e,t,n,s){t.indexes.forEach((function(t){const i=e(t.name||"");function a(e){return null!=e?t.extractKey(e):null}const o=e=>t.multiEntry&&r(e)?e.forEach((e=>i.addKey(e))):i.addKey(e);(n||s).forEach(((e,t)=>{const r=n&&a(n[t]),i=s&&a(s[t]);0!==Dt(r,i)&&(null!=r&&o(r),null!=i&&o(i))}))}))}(c,o,t,y)}else if(f){const e={from:f.lower,to:f.upper};h.add(e),u.add(e)}else u.add(s),h.add(s),o.indexes.forEach((e=>c(e.name).add(s)));return e}))}},d=({query:{index:t,range:n}})=>{var r,s;return[t,new In(null!==(r=n.lower)&&void 0!==r?r:e.MIN_KEY,null!==(s=n.upper)&&void 0!==s?s:e.MAX_KEY)]},f={get:e=>[l,new In(e.key)],getMany:e=>[l,(new In).addKeys(e.keys)],count:d,query:d,openCursor:d};return n(f).forEach((e=>{h[e]=function(n){const{subscr:r}=Oe;if(r){const o=e=>{const n=`idb://${t}/${i}/${e}`;return r[n]||(r[n]=new In)},l=o(""),h=o(":dels"),[d,y]=f[e](n);if(o(d.name||"").add(y),!d.isPrimaryKey){if("count"!==e){const t="query"===e&&u&&n.values&&a.query({...n,values:!1});return a[e].apply(this,arguments).then((r=>{if("query"===e){if(u&&n.values)return t.then((({result:e})=>(l.addKeys(e),r)));const e=n.values?r.result.map(c):r.result;n.values?l.addKeys(e):h.addKeys(e)}else if("openCursor"===e){const e=r,t=n.values;return e&&Object.create(e,{key:{get:()=>(h.addKey(e.primaryKey),e.key)},primaryKey:{get(){const t=e.primaryKey;return h.addKey(t),t}},value:{get:()=>(t&&l.addKey(e.primaryKey),e.value)}})}return r}))}h.add(s)}}return a[e].apply(this,arguments)}})),h}}}};class qn{constructor(e,t){this._middlewares={},this.verno=0;const n=qn.dependencies;this._options=t={addons:qn.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:r}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:te,dbReadyPromise:null,cancelOpen:te,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new Re((e=>{s.dbReadyResolve=e})),s.openCanceller=new Re(((e,t)=>{s.cancelOpen=t})),this._state=s,this.name=e,this.on=St(this,"populate","blocked","versionchange","close",{ready:[ce,te]}),this.on.ready.subscribe=m(this.on.ready.subscribe,(e=>(t,n)=>{qn.vip((()=>{const r=this._state;if(r.openComplete)r.dbOpenError||Re.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);const r=this;n||e((function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)}))}}))})),this.Collection=(i=this,Pt(Nt.prototype,(function(e,t){this.db=i;let n=kt,r=null;if(t)try{n=t()}catch(e){r=e}const s=e._ctx,a=s.table,o=a.hook.reading.fire;this._ctx={table:a,index:s.index,isPrimKey:!s.index||a.schema.primKey.keyPath&&s.index===a.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:s.or,valueMapper:o!==ne?o:null}}))),this.Table=function(e){return Pt(Et.prototype,(function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:St(null,{creating:[ie,te],reading:[re,ne],updating:[oe,te],deleting:[ae,te]})}))}(this),this.Transaction=function(e){return Pt(Qt.prototype,(function(t,n,r,s,i){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=s,this.idbtrans=null,this.on=St(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new Re(((e,t)=>{this._resolve=e,this._reject=t})),this._completion.then((()=>{this.active=!1,this.on.complete.fire()}),(e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),dt(e)}))}))}(this),this.Version=function(e){return Pt(vn.prototype,(function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}}))}(this),this.WhereClause=function(e){return Pt(Yt.prototype,(function(t,n,r){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r};const s=e._deps.indexedDB;if(!s)throw new X.MissingAPI;this._cmp=this._ascending=s.cmp.bind(s),this._descending=(e,t)=>s.cmp(t,e),this._max=(e,t)=>s.cmp(e,t)>0?e:t,this._min=(e,t)=>s.cmp(e,t)<0?e:t,this._IDBKeyRange=e._deps.IDBKeyRange}))}(this),this.on("versionchange",(e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()})),this.on("blocked",(e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)})),this._maxKey=tn(t.IDBKeyRange),this._createTransaction=(e,t,n,r)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),mt.filter((e=>e.name===this.name&&e!==this&&!e._state.vcFired)).map((t=>t.on("versionchange").fire(e)))},this.use(On),this.use(jn),this.use(Mn),this.use(Rn),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach((e=>e(this)))}version(e){if(isNaN(e)||e<.1)throw new X.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new X.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const t=this._versions;var n=t.filter((t=>t._cfg.version===e))[0];return n||(n=new this.Version(e),t.push(n),t.sort(hn),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||Oe.letThrough||this._vip)?e():new Re(((e,t)=>{if(this._state.openComplete)return t(new X.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new X.DatabaseClosed);this.open().catch(te)}this._state.dbReadyPromise.then(e,t)})).then(e)}use({stack:e,create:t,level:n,name:r}){r&&this.unuse({stack:e,name:r});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:t,level:null==n?10:n,name:r}),s.sort(((e,t)=>e.level-t.level)),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter((e=>n?e.create!==n:!!t&&e.name!==t))),this}open(){return function(e){const t=e._state,{indexedDB:r}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then((()=>t.dbOpenError?dt(t.dbOpenError):e));N&&(t.openCanceller._stackHolder=$()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const s=t.openCanceller;function i(){if(t.openCanceller!==s)throw new X.DatabaseClosed("db.open() was cancelled")}let a=t.dbReadyResolve,o=null,l=!1;return Re.race([s,("undefined"==typeof navigator?Re.resolve():kn()).then((()=>new Re(((s,a)=>{if(i(),!r)throw new X.MissingAPI;const c=e.name,u=t.autoSchema?r.open(c):r.open(c,Math.round(10*e.verno));if(!u)throw new X.MissingAPI;u.onerror=zt(a),u.onblocked=He(e._fireOnBlocked),u.onupgradeneeded=He((n=>{if(o=u.transaction,t.autoSchema&&!e._options.allowEmptyDB){u.onerror=Gt,o.abort(),u.result.close();const e=r.deleteDatabase(c);e.onsuccess=e.onerror=He((()=>{a(new X.NoSuchDatabase(`Database ${c} doesnt exist`))}))}else{o.onerror=zt(a);var s=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;l=s<1,e._novip.idbdb=u.result,dn(e,s/10,o,a)}}),a),u.onsuccess=He((()=>{o=null;const r=e._novip.idbdb=u.result,i=p(r.objectStoreNames);if(i.length>0)try{const s=r.transaction(1===(a=i).length?a[0]:a,"readonly");t.autoSchema?function({_novip:e},t,r){e.verno=t.version/10;const s=e._dbSchema=mn(0,t,r);e._storeNames=p(t.objectStoreNames,0),cn(e,[e._allTables],n(s),s)}(e,r,s):(gn(e,e._dbSchema,s),function(e,t){const n=fn(mn(0,e.idbdb,t),e._dbSchema);return!(n.add.length||n.change.some((e=>e.add.length||e.change.length)))}(e,s)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),ln(e,s)}catch(e){}var a;mt.push(e),r.onversionchange=He((n=>{t.vcFired=!0,e.on("versionchange").fire(n)})),r.onclose=He((t=>{e.on("close").fire(t)})),l&&function({indexedDB:e,IDBKeyRange:t},n){!wn(e)&&"__dbnames"!==n&&bn(e,t).put({name:n}).catch(te)}(e._deps,c),s()}),a)}))))]).then((()=>(i(),t.onReadyBeingFired=[],Re.resolve(_n((()=>e.on.ready.fire(e.vip)))).then((function n(){if(t.onReadyBeingFired.length>0){let r=t.onReadyBeingFired.reduce(ce,te);return t.onReadyBeingFired=[],Re.resolve(_n((()=>r(e.vip)))).then(n)}}))))).finally((()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1})).then((()=>e)).catch((n=>{t.dbOpenError=n;try{o&&o.abort()}catch(e){}return s===t.openCanceller&&e._close(),dt(n)})).finally((()=>{t.openComplete=!0,a()}))}(this)}_close(){const e=this._state,t=mt.indexOf(this);if(t>=0&&mt.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new Re((t=>{e.dbReadyResolve=t})),e.openCanceller=new Re(((t,n)=>{e.cancelOpen=n}))}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new X.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,t=this._state;return new Re(((n,r)=>{const s=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=He((()=>{!function({indexedDB:e,IDBKeyRange:t},n){!wn(e)&&"__dbnames"!==n&&bn(e,t).delete(n).catch(te)}(this._deps,this.name),n()})),e.onerror=zt(r),e.onblocked=this._fireOnBlocked};if(e)throw new X.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(s):s()}))}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){const e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return n(this._allTables).map((e=>this._allTables[e]))}transaction(){const e=En.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r=Oe.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);const s=-1!==e.indexOf("?");let i,a;e=e.replace("!","").replace("?","");try{if(a=t.map((e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t})),"r"==e||"readonly"===e)i="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new X.InvalidArgument("Invalid transaction mode: "+e);i="readwrite"}if(r){if("readonly"===r.mode&&"readwrite"===i){if(!s)throw new X.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&a.forEach((e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!s)throw new X.SubTransaction("Table "+e+" not included in parent transaction.");r=null}})),s&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,((t,n)=>{n(e)})):dt(e)}const o=Sn.bind(null,this,i,a,r,n);return r?r._promise(i,o,"lock"):Oe.trans?ot(Oe.transless,(()=>this._whenReady(o))):this._whenReady(o)}table(e){if(!o(this._allTables,e))throw new X.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const $n="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class Vn{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[$n](){return this}}function Un(e,t){return n(t).forEach((n=>{Tn(e[n]||(e[n]=new In),t[n])})),e}let Ln;try{Ln={indexedDB:t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB,IDBKeyRange:t.IDBKeyRange||t.webkitIDBKeyRange}}catch(t){Ln={indexedDB:null,IDBKeyRange:null}}const Wn=qn;function Hn(e){let t=Yn;try{Yn=!0,Jt.storagemutated.fire(e)}finally{Yn=t}}l(Wn,{...ee,delete:e=>new Wn(e,{addons:[]}).delete(),exists:e=>new Wn(e,{addons:[]}).open().then((e=>(e.close(),!0))).catch("NoSuchDatabaseError",(()=>!1)),getDatabaseNames(e){try{return function({indexedDB:e,IDBKeyRange:t}){return wn(e)?Promise.resolve(e.databases()).then((e=>e.map((e=>e.name)).filter((e=>"__dbnames"!==e)))):bn(e,t).toCollection().primaryKeys()}(Wn.dependencies).then(e)}catch(e){return dt(new X.MissingAPI)}},defineClass:()=>function(e){s(this,e)},ignoreTransaction:e=>Oe.trans?ot(Oe.transless,e):e(),vip:_n,async:function(e){return function(){try{var t=xn(e.apply(this,arguments));return t&&"function"==typeof t.then?t:Re.resolve(t)}catch(e){return dt(e)}}},spawn:function(e,t,n){try{var r=xn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Re.resolve(r)}catch(e){return dt(e)}},currentTransaction:{get:()=>Oe.trans||null},waitFor:function(e,t){const n=Re.resolve("function"==typeof e?Wn.ignoreTransaction(e):e).timeout(t||6e4);return Oe.trans?Oe.trans.waitFor(n):n},Promise:Re,debug:{get:()=>N,set:e=>{F(e,"dexie"===e?()=>!0:wt)}},derive:h,extend:s,props:l,override:m,Events:St,on:Jt,liveQuery:function(e){return new Vn((t=>{const r=B(e);let s=!1,i={},a={};const o={get closed(){return s},unsubscribe:()=>{s=!0,Jt.storagemutated.unsubscribe(h)}};t.start&&t.start(o);let l=!1,c=!1;function u(){return n(a).some((e=>i[e]&&function(e,t){const n=Bn(t);let r=n.next();if(r.done)return!1;let s=r.value;const i=Bn(e);let a=i.next(s.from),o=a.value;for(;!r.done&&!a.done;){if(Dt(o.from,s.to)<=0&&Dt(o.to,s.from)>=0)return!0;Dt(s.from,o.from)<0?s=(r=n.next(o.from)).value:o=(a=i.next(s.from)).value}return!1}(i[e],a[e])))}const h=e=>{Un(i,e),u()&&d()},d=()=>{if(l||s)return;i={};const n={},f=function(t){r&&et();const n=()=>Ze(e,{subscr:t,trans:null}),s=Oe.trans?ot(Oe.transless,n):n();return r&&s.then(tt,tt),s}(n);c||(Jt("storagemutated",h),c=!0),l=!0,Promise.resolve(f).then((e=>{l=!1,s||(u()?d():(i={},a=n,t.next&&t.next(e)))}),(e=>{l=!1,t.error&&t.error(e),o.unsubscribe()}))};return d(),o}))},extendObservabilitySet:Un,getByKeyPath:w,setByKeyPath:_,delByKeyPath:function(e,t){"string"==typeof t?_(e,t,void 0):"length"in t&&[].map.call(t,(function(t){_(e,t,void 0)}))},shallowClone:k,deepClone:K,getObjectDiff:Kn,cmp:Dt,asap:v,minKey:-1/0,addons:[],connections:mt,errnames:J,dependencies:Ln,semVer:"3.2.2",version:"3.2.2".split(".").map((e=>parseInt(e))).reduce(((e,t,n)=>e+t/Math.pow(10,2*n)))}),Wn.maxKey=tn(Wn.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(Jt("storagemutated",(e=>{if(!Yn){let t;gt?(t=document.createEvent("CustomEvent"),t.initCustomEvent("x-storagemutated-1",!0,!0,e)):t=new CustomEvent("x-storagemutated-1",{detail:e}),Yn=!0,dispatchEvent(t),Yn=!1}})),addEventListener("x-storagemutated-1",(({detail:e})=>{Yn||Hn(e)})));let Yn=!1;if("undefined"!=typeof BroadcastChannel){const e=new BroadcastChannel("x-storagemutated-1");Jt("storagemutated",(t=>{Yn||e.postMessage(t)})),e.onmessage=e=>{e.data&&Hn(e.data)}}else if("undefined"!=typeof self&&"undefined"!=typeof navigator){Jt("storagemutated",(e=>{try{Yn||("undefined"!=typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach((t=>t.postMessage({type:"x-storagemutated-1",changedParts:e}))))}catch(e){}})),"undefined"!=typeof addEventListener&&addEventListener("storage",(e=>{if("x-storagemutated-1"===e.key){const t=JSON.parse(e.newValue);t&&Hn(t.changedParts)}}));const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",(function({data:e}){e&&"x-storagemutated-1"===e.type&&Hn(e.changedParts)}))}Re.rejectionMapper=function(e,t){if(!e||e instanceof H||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Z[e.name])return e;var n=new Z[e.name](t||e.message,e);return"stack"in e&&u(n,"stack",{get:function(){return this.inner.stack}}),n},F(N,wt);class zn extends qn{constructor(e="SubWalletDB_v2",t=11){super(e),this.schemaVersion=t,this.conditionalVersion(1,{chain:"slug",asset:"slug",price:"currency",balances:"[tokenSlug+address], tokenSlug, address",nfts:"[chain+address+collectionId+id], [address+chain], chain, id, address, collectionId, name",nftCollections:"[chain+collectionId], chain, collectionId, collectionName",crowdloans:"[chain+address], chain, address",stakings:"[chain+address+type], [chain+address], chain, address, type",transactions:"[chain+address+extrinsicHash], &[chain+address+extrinsicHash], chain, address, extrinsicHash, action",migrations:"[key+name]",chainStakingMetadata:"[chain+type], chain, type",nominatorMetadata:"[chain+address+type], [chain+address], chain, address, type"}),this.conditionalVersion(2,{metadata:"genesisHash, chain"}),this.conditionalVersion(3,{mantaPay:"key, chain"}),this.conditionalVersion(4,{yieldPoolInfo:"slug, chain, type",yieldPosition:"[slug+chain+address], [address+slug], address, chain"}),this.conditionalVersion(5,{campaign:"slug"}),this.conditionalVersion(6,{keyValue:"key"}),this.conditionalVersion(7,{inappNotification:"id, address, proxyId, [proxyId+actionType], actionType"})}conditionalVersion(e,t,n){if(null!=this.schemaVersion&&this.schemaVersion<e)return;const r=this.version(e).stores(t);null!=n&&r.upgrade(n)}static getInstance(e,t){return zn.instance||(zn.instance=new zn(e,t)),zn.instance}}const Gn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this"),Jn="undefined"!=typeof localStorage;class Qn{_storage={};localStorage=Jn?localStorage:void 0;kvDatabase=zn.getInstance().keyValue;isReady=!1;waitReadyHandler=function(){let e=()=>{console.warn("This promise handler is not implemented")},t=()=>{console.warn("This promise handler is not implemented")};const n=new Promise(((n,r)=>{e=n,t=r}));return{resolve:e,reject:t,promise:n}}();get waitReady(){return this.waitReadyHandler.promise}constructor(){this.sync().then((()=>{this.isReady=!0,this.waitReadyHandler.resolve(this)})).catch(console.error)}async setItem(e,t){var n;!this.isReady&&await this.waitReady,this._storage[e]=t,this.localStorage?null===(n=this.localStorage)||void 0===n||n.setItem(e,t):this.kvDatabase.put({key:e,value:t}).catch(console.error)}async getEntries(){return!this.isReady&&await this.waitReady,Object.entries(this._storage)}async setMap(e){if(!this.isReady&&await this.waitReady,this._storage={...this._storage,...e},this.localStorage)Object.entries(e).forEach((([e,t])=>{var n;null===(n=this.localStorage)||void 0===n||n.setItem(e,t)}));else{const t=Object.entries(e).map((([e,t])=>({key:e,value:t})));this.kvDatabase.bulkPut(t).catch(console.error)}}async getItem(e){return!this.isReady&&await this.waitReady,this._storage[e]||null}async getItems(e){return!this.isReady&&await this.waitReady,e.map((e=>this._storage[e]||null))}async getMap(e){return!this.isReady&&await this.waitReady,e.reduce(((e,t)=>(e[t]=this._storage[t]||null,e)),{})}async removeItem(e){!this.isReady&&await this.waitReady,this._storage[e]&&delete this._storage[e],this.localStorage?this.localStorage.removeItem(e):this.kvDatabase.where({key:e}).delete().catch(console.error)}async removeItems(e){!this.isReady&&await this.waitReady,e.forEach((e=>{this._storage[e]&&delete this._storage[e]})),this.localStorage?e.forEach((e=>{this.localStorage&&this.localStorage.removeItem(e)})):this.kvDatabase.where("key").anyOf(e).delete().catch(console.error)}async clear(){!this.isReady&&await this.waitReady,this._storage={},this.localStorage?this.localStorage.clear():this.kvDatabase.clear().catch(console.error)}async key(e){return!this.isReady&&await this.waitReady,Object.keys(this._storage)[e]||null}async length(e){return!this.isReady&&await this.waitReady,Object.keys(this._storage)[e]||null}async keys(){return!this.isReady&&await this.waitReady,Object.keys(this._storage)||[]}async copy(){return!this.isReady&&await this.waitReady,Promise.resolve(JSON.parse(JSON.stringify(this._storage)))}async sync(){if(this.localStorage)this._storage=JSON.parse(JSON.stringify(this.localStorage));else{const e=await this.kvDatabase.toArray();this._storage={},e.forEach((e=>{this._storage[e.key]=e.value}))}}static get instance(){return Gn.SWStorage||(Gn.SWStorage=new Qn),Gn.SWStorage}}const Xn=Qn.instance;e.g.chrome||(e.g.chrome={}),e.g.chrome.extension||(e.g.chrome.extension={getURL:e=>`${e}`}),e.g.chrome.runtime={lastError:void 0,getURL:e=>`/${e}`},e.g.chrome.windows={getCurrent:()=>{}},e.g.chrome.tabs={query:()=>{}},e.g.chrome.storage={local:{get:(e,t)=>{(async()=>{e||(e=await Xn.keys()),"string"==typeof e&&(e=[e]);const t={};return await Promise.all(e.map((async e=>{const n=await Xn.getItem(e);if(null===n)t[e]=void 0;else try{t[e]=JSON.parse(n)}catch(r){t[e]=n}}))),t})().then(t).catch(console.error)},set:(e,t)=>{Promise.all(Object.entries(e).map((async([e,t])=>{await Xn.setItem(e,JSON.stringify(t))}))).then((()=>{t&&t()})).catch(console.error)},remove:(e,t,n)=>{Xn.removeItem(e).then((()=>{n&&n()})).catch(console.error)}}}})();
package/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"><title>SubWallet</title><script inline inline-asset="fallback.js$" inline-asset-delete></script><script inline inline-asset="web-runner.js$" inline-asset-delete></script><script defer="defer" src="fallback-0b81a7f9f3a8fbf3b257.js"></script><script defer="defer" src="web-runner-4171b2b458674c7c32fc.js"></script></head><body><div id="root">SubWallet</div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"><title>SubWallet</title><script inline inline-asset="fallback.js$" inline-asset-delete></script><script inline inline-asset="web-runner.js$" inline-asset-delete></script><script defer="defer" src="fallback-5289e749417ace6ef22c.js"></script><script defer="defer" src="web-runner-64920586f1d5d6e74b2b.js"></script></head><body><div id="root">SubWallet</div></body></html>
@@ -1373,5 +1373,38 @@
1373
1373
  "Unsupported address": "",
1374
1374
  "Failed to import. Incompatible NFT": "",
1375
1375
  "TON wallets have multiple versions, each with its own wallet address and balance. <highlight>Change versions</highlight> if you don't see balances": "",
1376
- "Change wallet address & version": ""
1376
+ "Change wallet address & version": "",
1377
+ "Mark as unread": "",
1378
+ "Mark as read": "",
1379
+ "Claim token": "",
1380
+ "Claim tokens": "",
1381
+ "Claim confirmation": "",
1382
+ "Claim token transaction": "",
1383
+ "Browser notifications": "",
1384
+ "View notifications in": "",
1385
+ "In-app notifications": "",
1386
+ "Unread": "",
1387
+ "Read": "",
1388
+ "{{networkName}} network is currently disabled. Enable the network and then re-click the notification to start withdrawing your funds": "",
1389
+ "{{networkName}} network is currently disabled. Enable the network and then re-click the notification to start claiming your funds": "",
1390
+ "You’ve {{action}} tokens": "",
1391
+ "You’ve already {{action}} your tokens. Check for unread notifications to stay updated on any important": "",
1392
+ "Your notifications will appear here": "",
1393
+ "No notifications yet": "",
1394
+ "Enable notifications": "",
1395
+ "Enable notifications now to not miss anything!": "",
1396
+ "Notifications are disabled": "",
1397
+ "Mark all as read": "",
1398
+ "Search notification": "",
1399
+ "Withdraw tokens": "",
1400
+ "Claim AVAIL bridge": "",
1401
+ "Today": "",
1402
+ "This week": "",
1403
+ "This month": "",
1404
+ "Notification settings": "",
1405
+ "Show notifications about": "",
1406
+ "Save settings": "",
1407
+ "Invalid asset ID": "",
1408
+ "Please type or paste an asset ID": "",
1409
+ "Asset ID": ""
1377
1410
  }
@@ -1373,5 +1373,38 @@
1373
1373
  "Unsupported address": "",
1374
1374
  "Failed to import. Incompatible NFT": "",
1375
1375
  "TON wallets have multiple versions, each with its own wallet address and balance. <highlight>Change versions</highlight> if you don't see balances": "",
1376
- "Change wallet address & version": ""
1376
+ "Change wallet address & version": "",
1377
+ "Mark as unread": "",
1378
+ "Mark as read": "",
1379
+ "Claim token": "",
1380
+ "Claim tokens": "",
1381
+ "Claim confirmation": "",
1382
+ "Claim token transaction": "",
1383
+ "Browser notifications": "",
1384
+ "View notifications in": "",
1385
+ "In-app notifications": "",
1386
+ "Unread": "",
1387
+ "Read": "",
1388
+ "{{networkName}} network is currently disabled. Enable the network and then re-click the notification to start withdrawing your funds": "",
1389
+ "{{networkName}} network is currently disabled. Enable the network and then re-click the notification to start claiming your funds": "",
1390
+ "You’ve {{action}} tokens": "",
1391
+ "You’ve already {{action}} your tokens. Check for unread notifications to stay updated on any important": "",
1392
+ "Your notifications will appear here": "",
1393
+ "No notifications yet": "",
1394
+ "Enable notifications": "",
1395
+ "Enable notifications now to not miss anything!": "",
1396
+ "Notifications are disabled": "",
1397
+ "Mark all as read": "",
1398
+ "Search notification": "",
1399
+ "Withdraw tokens": "",
1400
+ "Claim AVAIL bridge": "",
1401
+ "Today": "",
1402
+ "This week": "",
1403
+ "This month": "",
1404
+ "Notification settings": "",
1405
+ "Show notifications about": "",
1406
+ "Save settings": "",
1407
+ "Invalid asset ID": "",
1408
+ "Please type or paste an asset ID": "",
1409
+ "Asset ID": ""
1377
1410
  }
@@ -1373,5 +1373,38 @@
1373
1373
  "Unsupported address": "",
1374
1374
  "Failed to import. Incompatible NFT": "",
1375
1375
  "TON wallets have multiple versions, each with its own wallet address and balance. <highlight>Change versions</highlight> if you don't see balances": "",
1376
- "Change wallet address & version": ""
1376
+ "Change wallet address & version": "",
1377
+ "Mark as unread": "",
1378
+ "Mark as read": "",
1379
+ "Claim token": "",
1380
+ "Claim tokens": "",
1381
+ "Claim confirmation": "",
1382
+ "Claim token transaction": "",
1383
+ "Browser notifications": "",
1384
+ "View notifications in": "",
1385
+ "In-app notifications": "",
1386
+ "Unread": "",
1387
+ "Read": "",
1388
+ "{{networkName}} network is currently disabled. Enable the network and then re-click the notification to start withdrawing your funds": "",
1389
+ "{{networkName}} network is currently disabled. Enable the network and then re-click the notification to start claiming your funds": "",
1390
+ "You’ve {{action}} tokens": "",
1391
+ "You’ve already {{action}} your tokens. Check for unread notifications to stay updated on any important": "",
1392
+ "Your notifications will appear here": "",
1393
+ "No notifications yet": "",
1394
+ "Enable notifications": "",
1395
+ "Enable notifications now to not miss anything!": "",
1396
+ "Notifications are disabled": "",
1397
+ "Mark all as read": "",
1398
+ "Search notification": "",
1399
+ "Withdraw tokens": "",
1400
+ "Claim AVAIL bridge": "",
1401
+ "Today": "",
1402
+ "This week": "",
1403
+ "This month": "",
1404
+ "Notification settings": "",
1405
+ "Show notifications about": "",
1406
+ "Save settings": "",
1407
+ "Invalid asset ID": "",
1408
+ "Please type or paste an asset ID": "",
1409
+ "Asset ID": ""
1377
1410
  }
@@ -1373,5 +1373,38 @@
1373
1373
  "Unsupported address": "",
1374
1374
  "Failed to import. Incompatible NFT": "",
1375
1375
  "TON wallets have multiple versions, each with its own wallet address and balance. <highlight>Change versions</highlight> if you don't see balances": "",
1376
- "Change wallet address & version": ""
1376
+ "Change wallet address & version": "",
1377
+ "Mark as unread": "",
1378
+ "Mark as read": "",
1379
+ "Claim token": "",
1380
+ "Claim tokens": "",
1381
+ "Claim confirmation": "",
1382
+ "Claim token transaction": "",
1383
+ "Browser notifications": "",
1384
+ "View notifications in": "",
1385
+ "In-app notifications": "",
1386
+ "Unread": "",
1387
+ "Read": "",
1388
+ "{{networkName}} network is currently disabled. Enable the network and then re-click the notification to start withdrawing your funds": "",
1389
+ "{{networkName}} network is currently disabled. Enable the network and then re-click the notification to start claiming your funds": "",
1390
+ "You’ve {{action}} tokens": "",
1391
+ "You’ve already {{action}} your tokens. Check for unread notifications to stay updated on any important": "",
1392
+ "Your notifications will appear here": "",
1393
+ "No notifications yet": "",
1394
+ "Enable notifications": "",
1395
+ "Enable notifications now to not miss anything!": "",
1396
+ "Notifications are disabled": "",
1397
+ "Mark all as read": "",
1398
+ "Search notification": "",
1399
+ "Withdraw tokens": "",
1400
+ "Claim AVAIL bridge": "",
1401
+ "Today": "",
1402
+ "This week": "",
1403
+ "This month": "",
1404
+ "Notification settings": "",
1405
+ "Show notifications about": "",
1406
+ "Save settings": "",
1407
+ "Invalid asset ID": "",
1408
+ "Please type or paste an asset ID": "",
1409
+ "Asset ID": ""
1377
1410
  }