dexie 3.2.1-beta.2 → 4.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dexie.min.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Dexie=t()})(this,function(){"use strict";var g=function(){return(g=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||((r=r||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=Object.keys,b=Array.isArray;function u(t,n){return"object"!=typeof n||x(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||h.Promise||(h.Promise=Promise);var s=Object.getPrototypeOf,n={}.hasOwnProperty;function m(e,t){return n.call(e,t)}function r(t,n){"function"==typeof n&&(n=n(s(t))),("undefined"==typeof Reflect?x:Reflect.ownKeys)(n).forEach(function(e){c(t,e,n[e])})}var a=Object.defineProperty;function c(e,t,n,r){a(e,t,u(n&&m(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function o(t){return{from:function(e){return t.prototype=Object.create(e.prototype),c(t.prototype,"constructor",t),{extend:r.bind(null,t.prototype)}}}}var l=Object.getOwnPropertyDescriptor;function f(e,t){return l(e,t)||(e=s(e))&&f(e,t)}var d=[].slice;function y(e,t,n){return d.call(e,t,n)}function p(e,t){return t(e)}function v(e){if(!e)throw new Error("Assertion Failed")}function _(e){h.setImmediate?setImmediate(e):setTimeout(e,0)}function w(e,r){return e.reduce(function(e,t,n){n=r(t,n);return n&&(e[n[0]]=n[1]),e},{})}function k(e,t){if(m(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,i=t.length;r<i;++r){var o=k(e,t[r]);n.push(o)}return n}var a=t.indexOf(".");if(-1!==a){var u=e[t.substr(0,a)];return void 0===u?void 0:k(u,t.substr(a+1))}}function E(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){v("string"!=typeof n&&"length"in n);for(var r=0,i=t.length;r<i;++r)E(e,t[r],n[r])}else{var o,a=t.indexOf(".");-1!==a?(o=t.substr(0,a),""===(a=t.substr(a+1))?void 0===n?b(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n:E(e[o]||(e[o]={}),a,n)):void 0===n?b(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function P(e){var t,n={};for(t in e)m(e,t)&&(n[t]=e[t]);return n}var t=[].concat;function K(e){return t.apply([],e)}var e="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(K([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return h[e]}),O=e.map(function(e){return h[e]});w(e,function(e){return[e,!0]});var S=null;function A(e){S="undefined"!=typeof WeakMap&&new WeakMap;e=function e(t){if(!t||"object"!=typeof t)return t;var n=S&&S.get(t);if(n)return n;if(b(t)){n=[],S&&S.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(0<=O.indexOf(t.constructor))n=t;else{var o,a=s(t);for(o in n=a===Object.prototype?{}:Object.create(a),S&&S.set(t,n),t)m(t,o)&&(n[o]=e(t[o]))}return n}(e);return S=null,e}var C={}.toString;function j(e){return C.call(e).slice(8,-1)}var D="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",I="symbol"==typeof D?function(e){var t;return null!=e&&(t=e[D])&&t.apply(e)}:function(){return null},B={};function T(e){var t,n,r,i;if(1===arguments.length){if(b(e))return e.slice();if(this===B&&"string"==typeof e)return[e];if(i=I(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var R="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},F="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function M(e,t){F=e,N=t}var N=function(){return!0},q=!new Error("").stack;function U(){if(q)try{throw new Error}catch(e){return e}return new Error}function L(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(function(e){return"\n"+e}).join("")):""}var V=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],W=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(V),z={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 Y(e,t){this._e=U(),this.name=e,this.message=t}function G(e,t){return e+". Errors: "+Object.keys(t).map(function(e){return t[e].toString()}).filter(function(e,t,n){return n.indexOf(e)===t}).join("\n")}function H(e,t,n,r){this._e=U(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=G(e,t)}function Q(e,t){this._e=U(),this.name="BulkError",this.failures=Object.keys(t).map(function(e){return t[e]}),this.failuresByPos=t,this.message=G(e,t)}o(Y).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+L(this._e,2))}},toString:function(){return this.name+": "+this.message}}),o(H).from(Y),o(Q).from(Y);var X=W.reduce(function(e,t){return e[t]=t+"Error",e},{}),J=Y,$=W.reduce(function(e,n){var r=n+"Error";function t(e,t){this._e=U(),this.name=r,e?"string"==typeof e?(this.message=e+(t?"\n "+t:""),this.inner=t||null):"object"==typeof e&&(this.message=e.name+" "+e.message,this.inner=e):(this.message=z[n]||r,this.inner=null)}return o(t).from(J),e[n]=t,e},{});$.Syntax=SyntaxError,$.Type=TypeError,$.Range=RangeError;var Z=V.reduce(function(e,t){return e[t+"Error"]=$[t],e},{});e=W.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=$[t]),e},{});function ee(){}function te(e){return e}function ne(t,n){return null==t||t===te?n:function(e){return n(t(e))}}function re(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ie(i,o){return i===ee?o:function(){var e=i.apply(this,arguments);void 0!==e&&(arguments[0]=e);var t=this.onsuccess,n=this.onerror;this.onsuccess=null,this.onerror=null;var r=o.apply(this,arguments);return t&&(this.onsuccess=this.onsuccess?re(t,this.onsuccess):t),n&&(this.onerror=this.onerror?re(n,this.onerror):n),void 0!==r?r:e}}function oe(n,r){return n===ee?r:function(){n.apply(this,arguments);var e=this.onsuccess,t=this.onerror;this.onsuccess=this.onerror=null,r.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?re(e,this.onsuccess):e),t&&(this.onerror=this.onerror?re(t,this.onerror):t)}}function ae(i,o){return i===ee?o:function(e){var t=i.apply(this,arguments);u(e,t);var n=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;e=o.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?re(n,this.onsuccess):n),r&&(this.onerror=this.onerror?re(r,this.onerror):r),void 0===t?void 0===e?void 0:e:u(t,e)}}function ue(e,t){return e===ee?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function se(i,o){return i===ee?o:function(){var e=i.apply(this,arguments);if(e&&"function"==typeof e.then){for(var t=this,n=arguments.length,r=new Array(n);n--;)r[n]=arguments[n];return e.then(function(){return o.apply(t,r)})}return o.apply(this,arguments)}}e.ModifyError=H,e.DexieError=Y,e.BulkError=Q;var ce={},le=100,fe=100,V="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,s(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,s(t),e]}(),he=V[0],de=V[1],pe=V[2],ye=de&&de.then,ve=he&&he.constructor,me=!!pe,ge=!1,be=pe?function(){pe.then(qe)}:h.setImmediate?setImmediate.bind(null,qe):h.MutationObserver?function(){var e=document.createElement("div");new MutationObserver(function(){qe(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:function(){setTimeout(qe,0)},_e=function(e,t){Ae.push([e,t]),xe&&(be(),xe=!1)},we=!0,xe=!0,ke=[],Ee=[],Pe=null,Ke=te,Oe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:lt,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(function(e){try{lt(e[0],e[1])}catch(e){}})}},Se=Oe,Ae=[],Ce=0,je=[];function De(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ee,this._lib=!1;var t=this._PSD=Se;if(F&&(this._stackHolder=U(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==ce)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,function t(r,e){try{e(function(n){if(null===r._state){if(n===r)throw new TypeError("A promise cannot be resolved with itself.");var e=r._lib&&Ue();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof De?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Re(r)),e&&Le()}},Te.bind(null,r))}catch(e){Te(r,e)}}(this,e)}var Ie={get:function(){var u=Se,t=Xe;function e(n,r){var i=this,o=!u.global&&(u!==Se||t!==Xe),a=o&&!et(),e=new De(function(e,t){Fe(i,new Be(ut(n,u,o,a),ut(r,u,o,a),e,t,u))});return F&&Ne(e,this),e}return e.prototype=ce,e},set:function(e){c(this,"then",e&&e.prototype===ce?Ie:{get:function(){return e},set:Ie.set})}};function Be(e,t,n,r,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=i}function Te(t,n){var e,r;Ee.push(n),null===t._state&&(e=t._lib&&Ue(),n=Ke(n),t._state=!1,t._value=n,F&&null!==n&&"object"==typeof n&&!n._promise&&function(e,t,n){try{e.apply(null,n)}catch(e){t&&t(e)}}(function(){var e=f(n,"stack");n._promise=t,c(n,"stack",{get:function(){return ge?e&&(e.get?e.get.apply(n):e.value):t.stack}})}),r=t,ke.some(function(e){return e._value===r._value})||ke.push(r),Re(t),e&&Le())}function Re(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Fe(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===Ce&&(++Ce,_e(function(){0==--Ce&&Ve()},[]))}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,++Ce,_e(Me,[n,e,t])}else e._listeners.push(t)}function Me(e,t,n){try{var r,i=(Pe=t)._value;t._state?r=e(i):(Ee.length&&(Ee=[]),r=e(i),-1===Ee.indexOf(i)&&function(e){var t=ke.length;for(;t;)if(ke[--t]._value===e._value)return ke.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{Pe=null,0==--Ce&&Ve(),--n.psd.ref||n.psd.finalize()}}function Ne(e,t){var n=t?t._numPrev+1:0;n<le&&(e._prev=t,e._numPrev=n)}function qe(){Ue()&&Le()}function Ue(){var e=we;return xe=we=!1,e}function Le(){var e,t,n;do{for(;0<Ae.length;)for(e=Ae,Ae=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<Ae.length);xe=we=!0}function Ve(){var e=ke;ke=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=je.slice(0),n=t.length;n;)t[--n]()}function We(e){return new De(ce,!1,e)}function ze(n,r){var i=Se;return function(){var e=Ue(),t=Se;try{return rt(i,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{rt(t,!1),e&&Le()}}}r(De.prototype,{then:Ie,_then:function(e,t){Fe(this,new Be(null,null,e,t,Se))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=e,n=arguments[1];return"function"==typeof t?this.then(null,function(e){return(e instanceof t?n:We)(e)}):this.then(null,function(e){return(e&&e.name===t?n:We)(e)})},finally:function(t){return this.then(function(e){return t(),e},function(e){return t(),We(e)})},stack:{get:function(){if(this._stack)return this._stack;try{ge=!0;var e=function e(t,n,r){if(n.length===r)return n;var i="";{var o,a,u;!1===t._state&&(null!=(o=t._value)?(a=o.name||"Error",u=o.message||o,i=L(o,0)):(a=o,u=""),n.push(a+(u?": "+u:"")+i))}F&&((i=L(t._stackHolder,2))&&-1===n.indexOf(i)&&n.push(i),t._prev&&e(t._prev,n,r));return n}(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{ge=!1}}},timeout:function(r,i){var o=this;return r<1/0?new De(function(e,t){var n=setTimeout(function(){return t(new $.Timeout(i))},r);o.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&c(De.prototype,Symbol.toStringTag,"Dexie.Promise"),Oe.env=it(),r(De,{all:function(){var o=T.apply(null,arguments).map(tt);return new De(function(n,r){0===o.length&&n([]);var i=o.length;o.forEach(function(e,t){return De.resolve(e).then(function(e){o[t]=e,--i||n(o)},r)})})},resolve:function(n){if(n instanceof De)return n;if(n&&"function"==typeof n.then)return new De(function(e,t){n.then(e,t)});var e=new De(ce,!0,n);return Ne(e,Pe),e},reject:We,race:function(){var e=T.apply(null,arguments).map(tt);return new De(function(t,n){e.map(function(e){return De.resolve(e).then(t,n)})})},PSD:{get:function(){return Se},set:function(e){return Se=e}},totalEchoes:{get:function(){return Xe}},newPSD:$e,usePSD:ot,scheduler:{get:function(){return _e},set:function(e){_e=e}},rejectionMapper:{get:function(){return Ke},set:function(e){Ke=e}},follow:function(i,n){return new De(function(e,t){return $e(function(n,r){var e=Se;e.unhandleds=[],e.onunhandled=r,e.finalize=re(function(){var t,e=this;t=function(){0===e.unhandleds.length?n():r(e.unhandleds[0])},je.push(function e(){t(),je.splice(je.indexOf(e),1)}),++Ce,_e(function(){0==--Ce&&Ve()},[])},e.finalize),i()},n,e,t)})}}),ve&&(ve.allSettled&&c(De,"allSettled",function(){var e=T.apply(null,arguments).map(tt);return new De(function(n){0===e.length&&n([]);var r=e.length,i=new Array(r);e.forEach(function(e,t){return De.resolve(e).then(function(e){return i[t]={status:"fulfilled",value:e}},function(e){return i[t]={status:"rejected",reason:e}}).then(function(){return--r||n(i)})})})}),ve.any&&"undefined"!=typeof AggregateError&&c(De,"any",function(){var e=T.apply(null,arguments).map(tt);return new De(function(n,r){0===e.length&&r(new AggregateError([]));var i=e.length,o=new Array(i);e.forEach(function(e,t){return De.resolve(e).then(function(e){return n(e)},function(e){o[t]=e,--i||r(new AggregateError(o))})})})}));var Ye={awaits:0,echoes:0,id:0},Ge=0,He=[],Qe=0,Xe=0,Je=0;function $e(e,t,n,r){var i=Se,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++Je;var a=Oe.env;o.env=me?{Promise:De,PromiseProp:{value:De,configurable:!0,writable:!0},all:De.all,race:De.race,allSettled:De.allSettled,any:De.any,resolve:De.resolve,reject:De.reject,nthen:st(a.nthen,o),gthen:st(a.gthen,o)}:{},t&&u(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};r=ot(o,e,n,r);return 0===o.ref&&o.finalize(),r}function Ze(){return Ye.id||(Ye.id=++Ge),++Ye.awaits,Ye.echoes+=fe,Ye.id}function et(){return!!Ye.awaits&&(0==--Ye.awaits&&(Ye.id=0),Ye.echoes=Ye.awaits*fe,!0)}function tt(e){return Ye.echoes&&e&&e.constructor===ve?(Ze(),e.then(function(e){return et(),e},function(e){return et(),ft(e)})):e}function nt(){var e=He[He.length-1];He.pop(),rt(e,!1)}function rt(e,t){var n,r=Se;(t?!Ye.echoes||Qe++&&e===Se:!Qe||--Qe&&e===Se)||at(t?function(e){++Xe,Ye.echoes&&0!=--Ye.echoes||(Ye.echoes=Ye.id=0),He.push(Se),rt(e,!0)}.bind(null,e):nt),e!==Se&&(Se=e,r===Oe&&(Oe.env=it()),me&&(n=Oe.env.Promise,t=e.env,de.then=t.nthen,n.prototype.then=t.gthen,(r.global||e.global)&&(Object.defineProperty(h,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function it(){var e=h.Promise;return me?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(h,"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,i){var o=Se;try{return rt(e,!0),t(n,r,i)}finally{rt(o,!1)}}function at(e){ye.call(he,e)}function ut(t,n,r,i){return"function"!=typeof t?t:function(){var e=Se;r&&Ze(),rt(n,!0);try{return t.apply(this,arguments)}finally{rt(e,!1),i&&at(et)}}}function st(n,r){return function(e,t){return n.call(this,ut(e,r),ut(t,r))}}-1===(""+ye).indexOf("[native code]")&&(Ze=et=ee);var ct="unhandledrejection";function lt(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,i={promise:t,reason:e};if(h.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ct,!0,!0),u(r,i)):h.CustomEvent&&u(r=new CustomEvent(ct,{detail:i}),i),r&&h.dispatchEvent&&(dispatchEvent(r),!h.PromiseRejectionEvent&&h.onunhandledrejection))try{h.onunhandledrejection(r)}catch(e){}F&&r&&!r.defaultPrevented&&console.warn("Unhandled rejection: "+(e.stack||e))}catch(e){}}var ft=De.reject;function ht(e){return!/(dexie\.js|dexie\.min\.js)/.test(e)}var W="3.2.1-beta.2",dt=String.fromCharCode(65535),pt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",yt="String expected.",vt=[],mt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),gt=mt,bt=mt,_t="__dbnames",wt="readonly",xt="readwrite";function kt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Et={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Pt(t){return"string"!=typeof t||/\./.test(t)?function(e){return e}:function(e){return void 0===e[t]&&t in e&&delete(e=A(e))[t],e}}var Kt=(Ot.prototype._trans=function(e,r,t){var n=this._tx||Se.trans,i=this.name;function o(e,t,n){if(!n.schema[i])throw new $.NotFound("Table "+i+" not part of transaction");return r(n.idbtrans,n)}var a=Ue();try{return n&&n.db===this.db?n===Se.trans?n._promise(e,o,t):$e(function(){return n._promise(e,o,t)},{trans:n,transless:Se.transless||Se}):function t(n,r,i,o){if(n.idbdb&&(n._state.openComplete||Se.letThrough||n._vip)){var a=n._createTransaction(r,i,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(e){return e.name===X.InvalidState&&n.isOpen()&&0<--n._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(function(){return t(n,r,i,o)})):ft(e)}return a._promise(r,function(e,t){return $e(function(){return Se.trans=a,o(e,t,a)})}).then(function(e){return a._completion.then(function(){return e})})}if(n._state.openComplete)return ft(new $.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return ft(new $.DatabaseClosed);n.open().catch(ee)}return n._state.dbReadyPromise.then(function(){return t(n,r,i,o)})}(this.db,e,[this.name],o)}finally{a&&Le()}},Ot.prototype.get=function(t,e){var n=this;return t&&t.constructor===Object?this.where(t).first(e):this._trans("readonly",function(e){return n.core.get({trans:e,key:t}).then(function(e){return n.hook.reading.fire(e)})}).then(e)},Ot.prototype.where=function(o){if("string"==typeof o)return new this.db.WhereClause(this,o);if(b(o))return new this.db.WhereClause(this,"["+o.join("+")+"]");var n=x(o);if(1===n.length)return this.where(n[0]).equals(o[n[0]]);var e=this.schema.indexes.concat(this.schema.primKey).filter(function(t){return t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})&&t.keyPath.every(function(e){return 0<=n.indexOf(e)})})[0];if(e&&this.db._maxKey!==dt)return this.where(e.name).equals(e.keyPath.map(function(e){return o[e]}));!e&&F&&console.warn("The query "+JSON.stringify(o)+" on "+this.name+" would benefit of a compound index ["+n.join("+")+"]");var a=this.schema.idxByName,r=this.db._deps.indexedDB;function u(e,t){try{return 0===r.cmp(e,t)}catch(e){return!1}}var t=n.reduce(function(e,t){var n=e[0],r=e[1],e=a[t],i=o[t];return[n||e,n||!e?kt(r,e&&e.multi?function(e){e=k(e,t);return b(e)&&e.some(function(e){return u(i,e)})}:function(e){return u(i,k(e,t))}):r]},[null,null]),i=t[0],t=t[1];return i?this.where(i.name).equals(o[i.keyPath]).filter(t):e?this.filter(t):this.where(n).equals("")},Ot.prototype.filter=function(e){return this.toCollection().and(e)},Ot.prototype.count=function(e){return this.toCollection().count(e)},Ot.prototype.offset=function(e){return this.toCollection().offset(e)},Ot.prototype.limit=function(e){return this.toCollection().limit(e)},Ot.prototype.each=function(e){return this.toCollection().each(e)},Ot.prototype.toArray=function(e){return this.toCollection().toArray(e)},Ot.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},Ot.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,b(e)?"["+e.join("+")+"]":e))},Ot.prototype.reverse=function(){return this.toCollection().reverse()},Ot.prototype.mapToClass=function(r){this.schema.mappedClass=r;function e(e){if(!e)return e;var t,n=Object.create(r.prototype);for(t in e)if(m(e,t))try{n[t]=e[t]}catch(e){}return n}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=e,this.hook("reading",e),r},Ot.prototype.defineClass=function(){return this.mapToClass(function(e){u(this,e)})},Ot.prototype.add=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,a=t;return o&&i&&(a=Pt(o)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})}).then(function(e){return e.numFailures?De.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{E(t,o,e)}catch(e){}return e})},Ot.prototype.update=function(t,n){if("object"!=typeof t||b(t))return this.where(":id").equals(t).modify(n);var e=k(t,this.schema.primKey.keyPath);if(void 0===e)return ft(new $.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?x(n).forEach(function(e){E(t,e,n[e])}):n(t,{value:t,primKey:e})}catch(e){}return this.where(":id").equals(e).modify(n)},Ot.prototype.put=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,a=t;return o&&i&&(a=Pt(o)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})}).then(function(e){return e.numFailures?De.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{E(t,o,e)}catch(e){}return e})},Ot.prototype.delete=function(t){var n=this;return this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"delete",keys:[t]})}).then(function(e){return e.numFailures?De.reject(e.failures[0]):void 0})},Ot.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:Et})}).then(function(e){return e.numFailures?De.reject(e.failures[0]):void 0})},Ot.prototype.bulkGet=function(t){var n=this;return this._trans("readonly",function(e){return n.core.getMany({keys:t,trans:e}).then(function(e){return e.map(function(e){return n.hook.reading.fire(e)})})})},Ot.prototype.bulkAdd=function(r,e,t){var o=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=o.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new $.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new $.InvalidArgument("Arguments objects and keys must have the same length");var i=r.length,t=t&&n?r.map(Pt(t)):r;return o.core.mutate({trans:e,type:"add",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new Q(o.name+".bulkAdd(): "+t+" of "+i+" operations failed",e)})})},Ot.prototype.bulkPut=function(r,e,t){var o=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=o.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new $.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new $.InvalidArgument("Arguments objects and keys must have the same length");var i=r.length,t=t&&n?r.map(Pt(t)):r;return o.core.mutate({trans:e,type:"put",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new Q(o.name+".bulkPut(): "+t+" of "+i+" operations failed",e)})})},Ot.prototype.bulkDelete=function(t){var r=this,i=t.length;return this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"delete",keys:t})}).then(function(e){var t=e.numFailures,n=e.lastResult,e=e.failures;if(0===t)return n;throw new Q(r.name+".bulkDelete(): "+t+" of "+i+" operations failed",e)})},Ot);function Ot(){}function St(i){function t(e,t){if(t){for(var n=arguments.length,r=new Array(n-1);--n;)r[n-1]=arguments[n];return a[e].subscribe.apply(null,r),i}if("string"==typeof e)return a[e]}var a={};t.addEventType=u;for(var e=1,n=arguments.length;e<n;++e)u(arguments[e]);return t;function u(e,n,r){if("object"!=typeof e){var i;n=n||ue;var o={subscribers:[],fire:r=r||ee,subscribe:function(e){-1===o.subscribers.indexOf(e)&&(o.subscribers.push(e),o.fire=n(o.fire,e))},unsubscribe:function(t){o.subscribers=o.subscribers.filter(function(e){return e!==t}),o.fire=o.subscribers.reduce(n,r)}};return a[e]=t[e]=o}x(i=e).forEach(function(e){var t=i[e];if(b(t))u(e,i[e][0],i[e][1]);else{if("asap"!==t)throw new $.InvalidArgument("Invalid event config");var n=u(e,te,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){_(function(){e.apply(null,t)})})})}})}}function At(e,t){return o(t).from({prototype:e}),t}function Ct(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function jt(e,t){e.filter=kt(e.filter,t)}function Dt(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return kt(r(),t())}:t,e.justLimit=n&&!r}function It(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new $.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Bt(e,t,n){var r=It(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 Tt(e,o,t,n){var a=e.replayFilter?kt(e.filter,e.replayFilter()):e.filter;if(e.or){var u={},r=function(e,t,n){var r,i;a&&!a(t,n,function(e){return t.stop(e)},function(e){return t.fail(e)})||("[object ArrayBuffer]"===(i=""+(r=t.primaryKey))&&(i=""+new Uint8Array(r)),m(u,i)||(u[i]=!0,o(e,t,n)))};return Promise.all([e.or._iterate(r,t),Rt(Bt(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return Rt(Bt(e,n,t),kt(e.algorithm,a),o,!e.keysOnly&&e.valueMapper)}function Rt(e,r,i,o){var a=ze(o?function(e,t,n){return i(o(e),t,n)}:i);return e.then(function(n){if(n)return n.start(function(){var t=function(){return n.continue()};r&&!r(n,function(e){return t=e},function(e){n.stop(e),t=ee},function(e){n.fail(e),t=ee})||a(n.value,n,function(e){return t=e}),t()})})}function Ft(e,t){try{var n=Mt(e),r=Mt(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 t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o)if(e[o]!==t[o])return e[o]<t[o]?-1:1;return n===r?0:n<r?-1:1}(Nt(e),Nt(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o){var a=Ft(e[o],t[o]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function Mt(e){var t=typeof e;if("object"!=t)return t;if(ArrayBuffer.isView(e))return"binary";e=j(e);return"ArrayBuffer"===e?"binary":e}function Nt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var qt=(Ut.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,ft.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Ut.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,ft.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Ut.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=kt(t.algorithm,e)},Ut.prototype._iterate=function(e,t){return Tt(this._ctx,e,t,this._ctx.table.core)},Ut.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&u(n,e),t._ctx=n,t},Ut.prototype.raw=function(){return this._ctx.valueMapper=null,this},Ut.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return Tt(n,t,e,n.table.core)})},Ut.prototype.count=function(e){var i=this;return this._read(function(e){var t=i._ctx,n=t.table.core;if(Ct(t,!0))return n.count({trans:e,query:{index:It(t,n.schema),range:t.range}}).then(function(e){return Math.min(e,t.limit)});var r=0;return Tt(t,function(){return++r,!1},e,n).then(function(){return r})}).then(e)},Ut.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],i=n.length-1;function o(e,t){return t?o(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function u(e,t){e=o(e,i),t=o(t,i);return e<t?-a:t<e?a:0}return this.toArray(function(e){return e.sort(u)}).then(t)},Ut.prototype.toArray=function(e){var o=this;return this._read(function(e){var t=o._ctx;if("next"===t.dir&&Ct(t,!0)&&0<t.limit){var n=t.valueMapper,r=It(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(function(e){e=e.result;return n?e.map(n):e})}var i=[];return Tt(t,function(e){return i.push(e)},e,t.table.core).then(function(){return i})},e)},Ut.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,Ct(e)?Dt(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):Dt(e,function(){var e=t;return function(){return--e<0}})),this},Ut.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Dt(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},Ut.prototype.until=function(r,i){return jt(this._ctx,function(e,t,n){return!r(e.value)||(t(n),i)}),this},Ut.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Ut.prototype.last=function(e){return this.reverse().first(e)},Ut.prototype.filter=function(t){var e;return jt(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=kt(e.isMatch,t),this},Ut.prototype.and=function(e){return this.filter(e)},Ut.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Ut.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Ut.prototype.desc=function(){return this.reverse()},Ut.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},Ut.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Ut.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},Ut.prototype.keys=function(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)},Ut.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&Ct(n,!0)&&0<n.limit)return this._read(function(e){var t=It(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(function(e){return e.result}).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)},Ut.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Ut.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Ut.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Ut.prototype.distinct=function(){var e=this._ctx,e=e.index&&e.table.schema.idxByName[e.index];if(!e||!e.multi)return this;var n={};return jt(this._ctx,function(e){var t=e.primaryKey.toString(),e=m(n,t);return n[t]=!0,!e}),this},Ut.prototype.modify=function(_){var n=this,w=this._ctx;return this._write(function(d){var o,a,p;p="function"==typeof _?_:(o=x(_),a=o.length,function(e){for(var t=!1,n=0;n<a;++n){var r=o[n],i=_[r];k(e,r)!==i&&(E(e,r,i),t=!0)}return t});function y(e,t){var n=t.failures,t=t.numFailures;s+=e-t;for(var r=0,i=x(n);r<i.length;r++){var o=i[r];u.push(n[o])}}var v=w.table.core,e=v.schema.primaryKey,m=e.outbound,g=e.extractKey,b=n.db._options.modifyChunkSize||200,u=[],s=0,t=[];return n.clone().primaryKeys().then(function(f){function h(c){var l=Math.min(b,f.length-c);return v.getMany({trans:d,keys:f.slice(c,c+l),cache:"immutable"}).then(function(e){for(var n=[],t=[],r=m?[]:null,i=[],o=0;o<l;++o){var a=e[o],u={value:A(a),primKey:f[c+o]};!1!==p.call(u,u.value,u)&&(null==u.value?i.push(f[c+o]):m||0===Ft(g(a),g(u.value))?(t.push(u.value),m&&r.push(f[c+o])):(i.push(f[c+o]),n.push(u.value)))}var s=Ct(w)&&w.limit===1/0&&("function"!=typeof _||_===Lt)&&{index:w.index,range:w.range};return Promise.resolve(0<n.length&&v.mutate({trans:d,type:"add",values:n}).then(function(e){for(var t in e.failures)i.splice(parseInt(t),1);y(n.length,e)})).then(function(){return(0<t.length||s&&"object"==typeof _)&&v.mutate({trans:d,type:"put",keys:r,values:t,criteria:s,changeSpec:"function"!=typeof _&&_}).then(function(e){return y(t.length,e)})}).then(function(){return(0<i.length||s&&_===Lt)&&v.mutate({trans:d,type:"delete",keys:i,criteria:s}).then(function(e){return y(i.length,e)})}).then(function(){return f.length>c+l&&h(c+b)})})}return h(0).then(function(){if(0<u.length)throw new H("Error modifying one or more objects",u,s,t);return f.length})})})},Ut.prototype.delete=function(){var i=this._ctx,n=i.range;return Ct(i)&&(i.isPrimKey&&!bt||3===n.type)?this._write(function(e){var t=i.table.core.schema.primaryKey,r=n;return i.table.core.count({trans:e,query:{index:t,range:r}}).then(function(n){return i.table.core.mutate({trans:e,type:"deleteRange",range:r}).then(function(e){var t=e.failures;e.lastResult,e.results;e=e.numFailures;if(e)throw new H("Could not delete some values",Object.keys(t).map(function(e){return t[e]}),n-e);return n-e})})}):this.modify(Lt)},Ut);function Ut(){}var Lt=function(e,t){return t.value=null};function Vt(e,t){return e<t?-1:e===t?0:1}function Wt(e,t){return t<e?-1:e===t?0:1}function zt(e,t,n){e=e instanceof Xt?new e.Collection(e):e;return e._ctx.error=new(n||TypeError)(t),e}function Yt(e){return new e.Collection(e,function(){return Qt("")}).limit(0)}function Gt(e,s,n,r){var i,c,l,f,h,d,p,y=n.length;if(!n.every(function(e){return"string"==typeof e}))return zt(e,yt);function t(e){i="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},c="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},l="next"===e?Vt:Wt;var t=n.map(function(e){return{lower:c(e),upper:i(e)}}).sort(function(e,t){return l(e.lower,t.lower)});f=t.map(function(e){return e.upper}),h=t.map(function(e){return e.lower}),p="next"===(d=e)?"":r}t("next");e=new e.Collection(e,function(){return Ht(f[0],h[y-1]+r)});e._ondirectionchange=function(e){t(e)};var v=0;return e._addAlgorithm(function(e,t,n){var r=e.key;if("string"!=typeof r)return!1;var i=c(r);if(s(i,h,v))return!0;for(var o=null,a=v;a<y;++a){var u=function(e,t,n,r,i,o){for(var a=Math.min(e.length,r.length),u=-1,s=0;s<a;++s){var c=t[s];if(c!==r[s])return i(e[s],n[s])<0?e.substr(0,s)+n[s]+n.substr(s+1):i(e[s],r[s])<0?e.substr(0,s)+r[s]+n.substr(s+1):0<=u?e.substr(0,u)+t[u]+n.substr(u+1):null;i(e[s],c)<0&&(u=s)}return a<r.length&&"next"===o?e+n.substr(e.length):a<e.length&&"prev"===o?e.substr(0,n.length):u<0?null:e.substr(0,u)+r[u]+n.substr(u+1)}(r,i,f[a],h[a],l,d);null===u&&null===o?v=a+1:(null===o||0<l(o,u))&&(o=u)}return t(null!==o?function(){e.continue(o+p)}:n),!1}),e}function Ht(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Qt(e){return{type:1,lower:e,upper:e}}var Xt=(Object.defineProperty(Jt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Jt.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(e,t)||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Yt(this):new this.Collection(this,function(){return Ht(e,t,!n,!r)})}catch(e){return zt(this,pt)}},Jt.prototype.equals=function(e){return null==e?zt(this,pt):new this.Collection(this,function(){return Qt(e)})},Jt.prototype.above=function(e){return null==e?zt(this,pt):new this.Collection(this,function(){return Ht(e,void 0,!0)})},Jt.prototype.aboveOrEqual=function(e){return null==e?zt(this,pt):new this.Collection(this,function(){return Ht(e,void 0,!1)})},Jt.prototype.below=function(e){return null==e?zt(this,pt):new this.Collection(this,function(){return Ht(void 0,e,!1,!0)})},Jt.prototype.belowOrEqual=function(e){return null==e?zt(this,pt):new this.Collection(this,function(){return Ht(void 0,e)})},Jt.prototype.startsWith=function(e){return"string"!=typeof e?zt(this,yt):this.between(e,e+dt,!0,!0)},Jt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Gt(this,function(e,t){return 0===e.indexOf(t[0])},[e],dt)},Jt.prototype.equalsIgnoreCase=function(e){return Gt(this,function(e,t){return e===t[0]},[e],"")},Jt.prototype.anyOfIgnoreCase=function(){var e=T.apply(B,arguments);return 0===e.length?Yt(this):Gt(this,function(e,t){return-1!==t.indexOf(e)},e,"")},Jt.prototype.startsWithAnyOfIgnoreCase=function(){var e=T.apply(B,arguments);return 0===e.length?Yt(this):Gt(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,dt)},Jt.prototype.anyOf=function(){var t=this,i=T.apply(B,arguments),o=this._cmp;try{i.sort(o)}catch(e){return zt(this,pt)}if(0===i.length)return Yt(this);var e=new this.Collection(this,function(){return Ht(i[0],i[i.length-1])});e._ondirectionchange=function(e){o="next"===e?t._ascending:t._descending,i.sort(o)};var a=0;return e._addAlgorithm(function(e,t,n){for(var r=e.key;0<o(r,i[a]);)if(++a===i.length)return t(n),!1;return 0===o(r,i[a])||(t(function(){e.continue(i[a])}),!1)}),e},Jt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Jt.prototype.noneOf=function(){var e=T.apply(B,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return zt(this,pt)}var t=e.reduce(function(e,t){return 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})},Jt.prototype.inAnyRange=function(e,t){var o=this,a=this._cmp,u=this._ascending,n=this._descending,s=this._min,c=this._max;if(0===e.length)return Yt(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&u(e[0],e[1])<=0}))return zt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",$.InvalidArgument);var r=!t||!1!==t.includeLowers,i=t&&!0===t.includeUppers;var l,f=u;function h(e,t){return f(e[0],t[0])}try{(l=e.reduce(function(e,t){for(var n=0,r=e.length;n<r;++n){var i=e[n];if(a(t[0],i[1])<0&&0<a(t[1],i[0])){i[0]=s(i[0],t[0]),i[1]=c(i[1],t[1]);break}}return n===r&&e.push(t),e},[])).sort(h)}catch(e){return zt(this,pt)}var d=0,p=i?function(e){return 0<u(e,l[d][1])}:function(e){return 0<=u(e,l[d][1])},y=r?function(e){return 0<n(e,l[d][0])}:function(e){return 0<=n(e,l[d][0])};var v=p,e=new this.Collection(this,function(){return Ht(l[0][0],l[l.length-1][1],!r,!i)});return e._ondirectionchange=function(e){f="next"===e?(v=p,u):(v=y,n),l.sort(h)},e._addAlgorithm(function(e,t,n){for(var r,i=e.key;v(i);)if(++d===l.length)return t(n),!1;return!p(r=i)&&!y(r)||(0===o._cmp(i,l[d][1])||0===o._cmp(i,l[d][0])||t(function(){f===u?e.continue(l[d][0]):e.continue(l[d][1])}),!1)}),e},Jt.prototype.startsWithAnyOf=function(){var e=T.apply(B,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Yt(this):this.inAnyRange(e.map(function(e){return[e,e+dt]})):zt(this,"startsWithAnyOf() only works with strings")},Jt);function Jt(){}function $t(t){return ze(function(e){return Zt(e),t(e.target.error),!1})}function Zt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var en="storagemutated",tn="x-storagemutated-1",nn=St(null,en),rn=(on.prototype._lock=function(){return v(!Se.global),++this._reculock,1!==this._reculock||Se.global||(Se.lockOwnerFor=this),this},on.prototype._unlock=function(){if(v(!Se.global),0==--this._reculock)for(Se.global||(Se.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{ot(e[1],e[0])}catch(e){}}return this},on.prototype._locked=function(){return this._reculock&&Se.lockOwnerFor!==this},on.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(v(!this.idbtrans),!t&&!e)switch(r&&r.name){case"DatabaseClosedError":throw new $.DatabaseClosed(r);case"MissingAPIError":throw new $.MissingAPI(r.message,r);default:throw new $.OpenFailed(r)}if(!this.active)throw new $.TransactionInactive;return v(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||e).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=ze(function(e){Zt(e),n._reject(t.error)}),t.onabort=ze(function(e){Zt(e),n.active&&n._reject(new $.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=ze(function(){n.active=!1,n._resolve(),"mutatedParts"in t&&nn.storagemutated.fire(t.mutatedParts)}),this},on.prototype._promise=function(n,r,i){var o=this;if("readwrite"===n&&"readwrite"!==this.mode)return ft(new $.ReadOnly("Transaction is readonly"));if(!this.active)return ft(new $.TransactionInactive);if(this._locked())return new De(function(e,t){o._blockedFuncs.push([function(){o._promise(n,r,i).then(e,t)},Se])});if(i)return $e(function(){var e=new De(function(e,t){o._lock();var n=r(e,t,o);n&&n.then&&n.then(e,t)});return e.finally(function(){return o._unlock()}),e._lib=!0,e});var e=new De(function(e,t){var n=r(e,t,o);n&&n.then&&n.then(e,t)});return e._lib=!0,e},on.prototype._root=function(){return this.parent?this.parent._root():this},on.prototype.waitFor=function(e){var t,r=this._root(),i=De.resolve(e);r._waitingFor?r._waitingFor=r._waitingFor.then(function(){return i}):(r._waitingFor=i,r._waitingQueue=[],t=r.idbtrans.objectStore(r.storeNames[0]),function e(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(t.get(-1/0).onsuccess=e)}());var o=r._waitingFor;return new De(function(t,n){i.then(function(e){return r._waitingQueue.push(ze(t.bind(null,e)))},function(e){return r._waitingQueue.push(ze(n.bind(null,e)))}).finally(function(){r._waitingFor===o&&(r._waitingFor=null)})})},on.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new $.Abort))},on.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(m(t,e))return t[e];var n=this.schema[e];if(!n)throw new $.NotFound("Table "+e+" not part of transaction");n=new this.db.Table(e,n,this);return n.core=this.db.core.table(e),t[e]=n},on);function on(){}function an(e,t,n,r,i,o,a){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:o,src:(n&&!a?"&":"")+(r?"*":"")+(i?"++":"")+un(t)}}function un(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function sn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:w(n,function(e){return[e.name,e]})}}var cn=function(e){try{return e.only([[]]),cn=function(){return[[]]},[[]]}catch(e){return cn=function(){return dt},dt}};function ln(t){return null==t?function(){}:"string"==typeof t?1===(n=t).split(".").length?function(e){return e[n]}:function(e){return k(e,n)}:function(e){return k(e,t)};var n}function fn(e){return[].slice.call(e)}var hn=0;function dn(e){return null==e?":id":"string"==typeof e?e:"["+e.join("+")+"]"}function pn(e,i,t){function w(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,n=e.upper,r=e.lowerOpen,e=e.upperOpen;return void 0===t?void 0===n?null:i.upperBound(n,!!e):void 0===n?i.lowerBound(t,!!r):i.bound(t,n,!!r,!!e)}function n(e){var h,_=e.name;return{name:_,schema:e,mutate:function(e){var y=e.trans,v=e.type,m=e.keys,g=e.values,b=e.range;return new Promise(function(t,e){t=ze(t);var n=y.objectStore(_),r=null==n.keyPath,i="put"===v||"add"===v;if(!i&&"delete"!==v&&"deleteRange"!==v)throw new Error("Invalid operation type: "+v);var o,a=(m||g||{length:1}).length;if(m&&g&&m.length!==g.length)throw new Error("Given keys array must have same length as given values array.");if(0===a)return t({numFailures:0,failures:{},results:[],lastResult:void 0});function u(e){++l,Zt(e)}var s=[],c=[],l=0;if("deleteRange"===v){if(4===b.type)return t({numFailures:l,failures:c,results:[],lastResult:void 0});3===b.type?s.push(o=n.clear()):s.push(o=n.delete(w(b)))}else{var r=i?r?[g,m]:[g,null]:[m,null],f=r[0],h=r[1];if(i)for(var d=0;d<a;++d)s.push(o=h&&void 0!==h[d]?n[v](f[d],h[d]):n[v](f[d])),o.onerror=u;else for(d=0;d<a;++d)s.push(o=n[v](f[d])),o.onerror=u}function p(e){e=e.target.result,s.forEach(function(e,t){return null!=e.error&&(c[t]=e.error)}),t({numFailures:l,failures:c,results:"delete"===v?m:s.map(function(e){return e.result}),lastResult:e})}o.onerror=function(e){u(e),p(e)},o.onsuccess=p})},getMany:function(e){var f=e.trans,h=e.keys;return new Promise(function(t,e){t=ze(t);for(var n,r=f.objectStore(_),i=h.length,o=new Array(i),a=0,u=0,s=function(e){e=e.target;o[e._pos]=e.result,++u===a&&t(o)},c=$t(e),l=0;l<i;++l)null!=h[l]&&((n=r.get(h[l]))._pos=l,n.onsuccess=s,n.onerror=c,++a);0===a&&t(o)})},get:function(e){var r=e.trans,i=e.key;return new Promise(function(t,e){t=ze(t);var n=r.objectStore(_).get(i);n.onsuccess=function(e){return t(e.target.result)},n.onerror=$t(e)})},query:(h=s,function(f){return new Promise(function(n,e){n=ze(n);var r,i,o,t=f.trans,a=f.values,u=f.limit,s=f.query,c=u===1/0?void 0:u,l=s.index,s=s.range,t=t.objectStore(_),l=l.isPrimaryKey?t:t.index(l.name),s=w(s);if(0===u)return n({result:[]});h?((c=a?l.getAll(s,c):l.getAllKeys(s,c)).onsuccess=function(e){return n({result:e.target.result})},c.onerror=$t(e)):(r=0,i=!a&&"openKeyCursor"in l?l.openKeyCursor(s):l.openCursor(s),o=[],i.onsuccess=function(e){var t=i.result;return t?(o.push(a?t.value:t.primaryKey),++r===u?n({result:o}):void t.continue()):n({result:o})},i.onerror=$t(e))})}),openCursor:function(e){var c=e.trans,o=e.values,a=e.query,u=e.reverse,l=e.unique;return new Promise(function(t,n){t=ze(t);var e=a.index,r=a.range,i=c.objectStore(_),i=e.isPrimaryKey?i:i.index(e.name),e=u?l?"prevunique":"prev":l?"nextunique":"next",s=!o&&"openKeyCursor"in i?i.openKeyCursor(w(r),e):i.openCursor(w(r),e);s.onerror=$t(n),s.onsuccess=ze(function(e){var r,i,o,a,u=s.result;u?(u.___id=++hn,u.done=!1,r=u.continue.bind(u),i=(i=u.continuePrimaryKey)&&i.bind(u),o=u.advance.bind(u),a=function(){throw new Error("Cursor not stopped")},u.trans=c,u.stop=u.continue=u.continuePrimaryKey=u.advance=function(){throw new Error("Cursor not started")},u.fail=ze(n),u.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},u.start=function(e){function t(){if(s.result)try{e()}catch(e){u.fail(e)}else u.done=!0,u.start=function(){throw new Error("Cursor behind last entry")},u.stop()}var n=new Promise(function(t,e){t=ze(t),s.onerror=$t(e),u.fail=e,u.stop=function(e){u.stop=u.continue=u.continuePrimaryKey=u.advance=a,t(e)}});return s.onsuccess=ze(function(e){s.onsuccess=t,t()}),u.continue=r,u.continuePrimaryKey=i,u.advance=o,t(),n},t(u)):t(null)},n)})},count:function(e){var t=e.query,i=e.trans,o=t.index,a=t.range;return new Promise(function(t,e){var n=i.objectStore(_),r=o.isPrimaryKey?n:n.index(o.name),n=w(a),r=n?r.count(n):r.count();r.onsuccess=ze(function(e){return t(e.target.result)}),r.onerror=$t(e)})}}}var r,o,a,u=(o=t,a=fn((r=e).objectStoreNames),{schema:{name:r.name,tables:a.map(function(e){return o.objectStore(e)}).map(function(t){var e=t.keyPath,n=t.autoIncrement,r=b(e),i={},n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:ln(e)},indexes:fn(t.indexNames).map(function(e){return t.index(e)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,e=e.keyPath,r={name:t,compound:b(e),keyPath:e,unique:n,multiEntry:r,extractKey:ln(e)};return i[dn(e)]=r}),getIndexByKeyPath:function(e){return i[dn(e)]}};return i[":id"]=n.primaryKey,null!=e&&(i[dn(e)]=n.primaryKey),n})},hasGetAll:0<a.length&&"getAll"in o.objectStore(a[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),t=u.schema,s=u.hasGetAll,u=t.tables.map(n),c={};return u.forEach(function(e){return c[e.name]=e}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!c[e])throw new Error("Table '"+e+"' not found");return c[e]},MIN_KEY:-1/0,MAX_KEY:cn(i),schema:t}}function yn(e,t,n,r){var i=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=pn(t,i,r),e.dbcore.reduce(function(e,t){t=t.create;return g(g({},e),t(e))},r))}}function vn(e,t){var n=e._novip,e=t.db,t=yn(n._middlewares,e,n._deps,t);n.core=t.dbcore,n.tables.forEach(function(e){var t=e.name;n.core.schema.tables.some(function(e){return e.name===t})&&(e.core=n.core.table(t),n[t]instanceof n.Table&&(n[t].core=e.core))})}function mn(e,t,n,i){var o=e._novip;n.forEach(function(n){var r=i[n];t.forEach(function(e){var t=f(e,n);(!t||"value"in t&&void 0===t.value)&&(e===o.Transaction.prototype||e instanceof o.Transaction?c(e,n,{get:function(){return this.table(n)},set:function(e){a(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):e[n]=new o.Table(n,r))})})}function gn(e,t){var n=e._novip;t.forEach(function(e){for(var t in e)e[t]instanceof n.Table&&delete e[t]})}function bn(e,t){return e._cfg.version-t._cfg.version}function _n(n,r,i,e){var o=n._dbSchema,a=n._createTransaction("readwrite",n._storeNames,o);a.create(i),a._completion.catch(e);var u=a._reject.bind(a),p=Se.transless||Se;$e(function(){var e,s,c,l,f,t,h,d;Se.trans=a,Se.transless=p,0===r?(x(o).forEach(function(e){xn(i,e,o[e].primKey,o[e].indexes)}),vn(n,i),De.follow(function(){return n.on.populate.fire(a)}).catch(u)):(s=r,c=a,l=i,f=(e=n)._novip,t=[],e=f._versions,h=f._dbSchema=En(0,f.idbdb,l),d=!1,e.filter(function(e){return e._cfg.version>=s}).forEach(function(u){t.push(function(){var t=h,e=u._cfg.dbschema;Pn(f,t,l),Pn(f,e,l),h=f._dbSchema=e;var n=wn(t,e);n.add.forEach(function(e){xn(l,e[0],e[1].primKey,e[1].indexes)}),n.change.forEach(function(e){if(e.recreate)throw new $.Upgrade("Not yet support for changing primary key");var t=l.objectStore(e.name);e.add.forEach(function(e){return kn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),kn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var r=u._cfg.contentUpgrade;if(r&&u._cfg.version>s){vn(f,l),c._memoizedTables={},d=!0;var i=P(e);n.del.forEach(function(e){i[e]=t[e]}),gn(f,[f.Transaction.prototype]),mn(f,[f.Transaction.prototype],x(i),i),c.schema=i;var o,a=R(r);a&&Ze();n=De.follow(function(){var e;(o=r(c))&&a&&(e=et.bind(null,null),o.then(e,e))});return o&&"function"==typeof o.then?De.resolve(o):n.then(function(){return o})}}),t.push(function(e){var t,n,r;d&&gt||(t=u._cfg.dbschema,n=t,r=e,[].slice.call(r.db.objectStoreNames).forEach(function(e){return null==n[e]&&r.db.deleteObjectStore(e)})),gn(f,[f.Transaction.prototype]),mn(f,[f.Transaction.prototype],f._storeNames,f._dbSchema),c.schema=f._dbSchema})}),function e(){return t.length?De.resolve(t.shift()(c.idbtrans)).then(e):De.resolve()}().then(function(){var t,n;n=l,x(t=h).forEach(function(e){n.db.objectStoreNames.contains(e)||xn(n,e,t[e].primKey,t[e].indexes)})}).catch(u))})}function wn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var i=e[n],o=t[n];if(i){var a={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||i.primKey.auto!==o.primKey.auto&&!mt)a.recreate=!0,r.change.push(a);else{var u=i.idxByName,s=o.idxByName,c=void 0;for(c in u)s[c]||a.del.push(c);for(c in s){var l=u[c],f=s[c];l?l.src!==f.src&&a.change.push(f):a.add.push(f)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,o])}return r}function xn(e,t,n,r){var i=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(e){return kn(i,e)}),i}function kn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function En(e,t,u){var s={};return y(t.objectStoreNames,0).forEach(function(e){for(var t=u.objectStore(e),n=an(un(a=t.keyPath),a||"",!1,!1,!!t.autoIncrement,a&&"string"!=typeof a,!0),r=[],i=0;i<t.indexNames.length;++i){var o=t.index(t.indexNames[i]),a=o.keyPath,o=an(o.name,a,!!o.unique,!!o.multiEntry,!1,a&&"string"!=typeof a,!1);r.push(o)}s[e]=sn(e,n,r)}),s}function Pn(e,t,n){for(var r=e._novip,i=n.db.objectStoreNames,o=0;o<i.length;++o){var a=i[o],u=n.objectStore(a);r._hasGetAll="getAll"in u;for(var s=0;s<u.indexNames.length;++s){var c=u.indexNames[s],l=u.index(c).keyPath,f="string"==typeof l?l:"["+y(l).join("+")+"]";!t[a]||(l=t[a].idxByName[f])&&(l.name=c,delete t[a].idxByName[f],t[a].idxByName[c]=l)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&h.WorkerGlobalScope&&h instanceof h.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(r._hasGetAll=!1)}var Kn=(On.prototype._parseStoresSpec=function(r,i){x(r).forEach(function(e){if(null!==r[e]){var t=r[e].split(",").map(function(e,t){var n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return an(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),b(r),0===t)}),n=t.shift();if(n.multi)throw new $.Schema("Primary key cannot be multi-valued");t.forEach(function(e){if(e.auto)throw new $.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new $.Schema("Index must have a name and cannot be an empty string")}),i[e]=sn(e,n,t)}})},On.prototype.stores=function(e){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?u(this._cfg.storesSource,e):e;var e=t._versions,n={},r={};return e.forEach(function(e){u(n,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(n,r)}),t._dbSchema=r,gn(t,[t._allTables,t,t.Transaction.prototype]),mn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],x(r),r),t._storeNames=x(r),this},On.prototype.upgrade=function(e){return this._cfg.contentUpgrade=se(this._cfg.contentUpgrade||ee,e),this},On);function On(){}function Sn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Hn(_t,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function An(e){return e&&"function"==typeof e.databases}function Cn(e){return $e(function(){return Se.letThrough=!0,e()})}function jn(f){var h=f._state,r=f._deps.indexedDB;if(h.isBeingOpened||f.idbdb)return h.dbReadyPromise.then(function(){return h.dbOpenError?ft(h.dbOpenError):f});F&&(h.openCanceller._stackHolder=U()),h.isBeingOpened=!0,h.dbOpenError=null,h.openComplete=!1;var t=h.openCanceller;function e(){if(h.openCanceller!==t)throw new $.DatabaseClosed("db.open() was cancelled")}var n,i=h.dbReadyResolve,d=null,p=!1;return De.race([t,("undefined"==typeof navigator?De.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(function(){return new De(function(s,n){if(e(),!r)throw new $.MissingAPI;var c=f.name,l=h.autoSchema?r.open(c):r.open(c,Math.round(10*f.verno));if(!l)throw new $.MissingAPI;l.onerror=$t(n),l.onblocked=ze(f._fireOnBlocked),l.onupgradeneeded=ze(function(e){var t;d=l.transaction,h.autoSchema&&!f._options.allowEmptyDB?(l.onerror=Zt,d.abort(),l.result.close(),(t=r.deleteDatabase(c)).onsuccess=t.onerror=ze(function(){n(new $.NoSuchDatabase("Database "+c+" doesnt exist"))})):(d.onerror=$t(n),e=e.oldVersion>Math.pow(2,62)?0:e.oldVersion,p=e<1,f._novip.idbdb=l.result,_n(f,e/10,d,n))},n),l.onsuccess=ze(function(){d=null;var e,t,n,r,i,o=f._novip.idbdb=l.result,a=y(o.objectStoreNames);if(0<a.length)try{var u=o.transaction(1===(r=a).length?r[0]:r,"readonly");h.autoSchema?(t=o,n=u,(e=(e=f)._novip).verno=t.version/10,n=e._dbSchema=En(0,t,n),e._storeNames=y(t.objectStoreNames,0),mn(e,[e._allTables],x(n),n)):(Pn(f,f._dbSchema,u),((i=wn(En(0,(i=f).idbdb,u),i._dbSchema)).add.length||i.change.some(function(e){return e.add.length||e.change.length}))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),vn(f,u)}catch(e){}vt.push(f),o.onversionchange=ze(function(e){h.vcFired=!0,f.on("versionchange").fire(e)}),o.onclose=ze(function(e){f.on("close").fire(e)}),p&&(i=f._deps,u=c,o=i.indexedDB,i=i.IDBKeyRange,An(o)||u===_t||Sn(o,i).put({name:u}).catch(ee)),s()},n)})})]).then(function(){return e(),h.onReadyBeingFired=[],De.resolve(Cn(function(){return f.on.ready.fire(f.vip)})).then(function e(){if(0<h.onReadyBeingFired.length){var t=h.onReadyBeingFired.reduce(se,ee);return h.onReadyBeingFired=[],De.resolve(Cn(function(){return t(f.vip)})).then(e)}})}).finally(function(){h.onReadyBeingFired=null,h.isBeingOpened=!1}).then(function(){return f}).catch(function(e){h.dbOpenError=e;try{d&&d.abort()}catch(e){}return t===h.openCanceller&&f._close(),ft(e)}).finally(function(){h.openComplete=!0,i()})}function Dn(t){function e(e){return t.next(e)}var r=n(e),i=n(function(e){return t.throw(e)});function n(n){return function(e){var t=n(e),e=t.value;return t.done?e:e&&"function"==typeof e.then?e.then(r,i):b(e)?Promise.all(e).then(r,i):r(e)}}return n(e)()}function In(e,t,n){for(var r=b(e)?e.slice():[e],i=0;i<n;++i)r.push(t);return r}var Bn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(f){return g(g({},f),{table:function(e){var a=f.table(e),t=a.schema,u={},s=[];function c(e,t,n){var r=dn(e),i=u[r]=u[r]||[],o=null==e?0:"string"==typeof e?1:e.length,r=0<t,r=g(g({},n),{isVirtual:r,keyTail:t,keyLength:o,extractKey:ln(e),unique:!r&&n.unique});return i.push(r),r.isPrimaryKey||s.push(r),1<o&&c(2===o?e[0]:e.slice(0,o-1),t+1,n),i.sort(function(e,t){return e.keyTail-t.keyTail}),r}e=c(t.primaryKey.keyPath,0,t.primaryKey);u[":id"]=[e];for(var n=0,r=t.indexes;n<r.length;n++){var i=r[n];c(i.keyPath,0,i)}function l(e){var t,n=e.query.index;return n.isVirtual?g(g({},e),{query:{index:n,range:(t=e.query.range,n=n.keyTail,{type:1===t.type?2:t.type,lower:In(t.lower,t.lowerOpen?f.MAX_KEY:f.MIN_KEY,n),lowerOpen:!0,upper:In(t.upper,t.upperOpen?f.MIN_KEY:f.MAX_KEY,n),upperOpen:!0})}}):e}return g(g({},a),{schema:g(g({},t),{primaryKey:e,indexes:s,getIndexByKeyPath:function(e){return(e=u[dn(e)])&&e[0]}}),count:function(e){return a.count(l(e))},query:function(e){return a.query(l(e))},openCursor:function(t){var e=t.query.index,r=e.keyTail,n=e.isVirtual,i=e.keyLength;return n?a.openCursor(l(t)).then(function(e){return e&&o(e)}):a.openCursor(t);function o(n){return Object.create(n,{continue:{value:function(e){null!=e?n.continue(In(e,t.reverse?f.MAX_KEY:f.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?f.MIN_KEY:f.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value:function(e,t){n.continuePrimaryKey(In(e,f.MAX_KEY,r),t)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:function(){return n.value}}})}}})}})}};function Tn(i,o,a,u){return a=a||{},u=u||"",x(i).forEach(function(e){var t,n,r;m(o,e)?(t=i[e],n=o[e],"object"==typeof t&&"object"==typeof n&&t&&n?(r=j(t))!==j(n)?a[u+e]=o[e]:"Object"===r?Tn(t,n,a,u+e+"."):t!==n&&(a[u+e]=o[e]):t!==n&&(a[u+e]=o[e])):a[u+e]=void 0}),x(o).forEach(function(e){m(i,e)||(a[u+e]=o[e])}),a}var Rn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return g(g({},e),{table:function(r){var y=e.table(r),v=y.schema.primaryKey;return g(g({},y),{mutate:function(e){var t=Se.trans,n=t.table(r).hook,h=n.deleting,d=n.creating,p=n.updating;switch(e.type){case"add":if(d.fire===ee)break;return t._promise("readwrite",function(){return a(e)},!0);case"put":if(d.fire===ee&&p.fire===ee)break;return t._promise("readwrite",function(){return a(e)},!0);case"delete":if(h.fire===ee)break;return t._promise("readwrite",function(){return a(e)},!0);case"deleteRange":if(h.fire===ee)break;return t._promise("readwrite",function(){return function n(r,i,o){return y.query({trans:r,values:!1,query:{index:v,range:i},limit:o}).then(function(e){var t=e.result;return a({type:"delete",keys:t,trans:r}).then(function(e){return 0<e.numFailures?Promise.reject(e.failures[0]):t.length<o?{failures:[],numFailures:0,lastResult:void 0}:n(r,g(g({},i),{lower:t[t.length-1],lowerOpen:!0}),o)})})}(e.trans,e.range,1e4)},!0)}return y.mutate(e);function a(c){var e,t,n,l=Se.trans,f=c.keys||(t=v,"delete"===(n=c).type?n.keys:n.keys||n.values.map(t.extractKey));if(!f)throw new Error("Keys missing");return"delete"!==(c="add"===c.type||"put"===c.type?g(g({},c),{keys:f}):g({},c)).type&&(c.values=i([],c.values,!0)),c.keys&&(c.keys=i([],c.keys,!0)),e=y,n=f,("add"===(t=c).type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})).then(function(u){var s=f.map(function(e,t){var n,r,i,o=u[t],a={onerror:null,onsuccess:null};return"delete"===c.type?h.fire.call(a,e,o,l):"add"===c.type||void 0===o?(n=d.fire.call(a,e,c.values[t],l),null==e&&null!=n&&(c.keys[t]=e=n,v.outbound||E(c.values[t],v.keyPath,e))):(n=Tn(o,c.values[t]),(r=p.fire.call(a,n,e,o,l))&&(i=c.values[t],Object.keys(r).forEach(function(e){m(i,e)?i[e]=r[e]:E(i,e,r[e])}))),a});return y.mutate(c).then(function(e){for(var t=e.failures,n=e.results,r=e.numFailures,e=e.lastResult,i=0;i<f.length;++i){var o=(n||f)[i],a=s[i];null==o?a.onerror&&a.onerror(t[i]):a.onsuccess&&a.onsuccess("put"===c.type&&u[i]?c.values[i]:o)}return{failures:t,results:n,numFailures:r,lastResult:e}}).catch(function(t){return s.forEach(function(e){return e.onerror&&e.onerror(t)}),Promise.reject(t)})})}}})}})}};function Fn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;for(var r=[],i=0,o=0;i<t.keys.length&&o<e.length;++i)0===Ft(t.keys[i],e[o])&&(r.push(n?A(t.values[i]):t.values[i]),++o);return r.length===e.length?r:null}catch(e){return null}}var Mn={stack:"dbcore",level:-1,create:function(t){return{table:function(e){var n=t.table(e);return g(g({},n),{getMany:function(t){if(!t.cache)return n.getMany(t);var e=Fn(t.keys,t.trans._cache,"clone"===t.cache);return e?De.resolve(e):n.getMany(t).then(function(e){return t.trans._cache={keys:t.keys,values:"clone"===t.cache?A(e):e},e})},mutate:function(e){return"add"!==e.type&&(e.trans._cache=null),n.mutate(e)}})}}}};function Nn(e){return!("from"in e)}var qn=function(e,t){if(!this){var n=new qn;return e&&"d"in e&&u(n,e),n}u(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function Un(e,t,n){var r=Ft(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(Nn(e))return u(e,{from:t,to:n,d:1});var i=e.l,r=e.r;if(Ft(n,e.from)<0)return i?Un(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},zn(e);if(0<Ft(t,e.to))return r?Un(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},zn(e);Ft(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<Ft(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);n=!e.r;i&&!e.l&&Ln(e,i),r&&n&&Ln(e,r)}}function Ln(e,t){Nn(t)||function e(t,n){var r=n.from,i=n.to,o=n.l,n=n.r;Un(t,r,i),o&&e(t,o),n&&e(t,n)}(e,t)}function Vn(e,t){var n=Wn(t),r=n.next();if(r.done)return!1;for(var i=r.value,o=Wn(e),a=o.next(i.from),u=a.value;!r.done&&!a.done;){if(Ft(u.from,i.to)<=0&&0<=Ft(u.to,i.from))return!0;Ft(i.from,u.from)<0?i=(r=n.next(u.from)).value:u=(a=o.next(i.from)).value}return!1}function Wn(e){var n=Nn(e)?null:{s:0,n:e};return{next:function(e){for(var t=0<arguments.length;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&Ft(e,n.n.from)<0;)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||Ft(e,n.n.to)<=0)return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function zn(e){var t,n,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),i=1<r?"r":r<-1?"l":"";i&&(t="r"==i?"l":"r",n=g({},e),r=e[i],e.from=r.from,e.to=r.to,e[i]=r[i],n[i]=r[t],(e[t]=n).d=Yn(n)),e.d=Yn(e)}function Yn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}r(qn.prototype,((V={add:function(e){return Ln(this,e),this},addKey:function(e){return Un(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return Un(t,e,e)}),this}})[D]=function(){return Wn(this)},V));var Gn={stack:"dbcore",level:0,create:function(r){var v=r.schema.name,m=new qn(r.MIN_KEY,r.MAX_KEY);return g(g({},r),{table:function(d){function e(e){var e=(t=e.query).index,t=t.range;return[e,new qn(null!==(e=t.lower)&&void 0!==e?e:r.MIN_KEY,null!==(t=t.upper)&&void 0!==t?t:r.MAX_KEY)]}var p=r.table(d),y=p.schema,t=y.primaryKey,c=t.extractKey,l=t.outbound,n=g(g({},p),{mutate:function(e){function n(e){return r[e="idb://"+v+"/"+d+"/"+e]||(r[e]=new qn)}var t=e.trans,r=t.mutatedParts||(t.mutatedParts={}),i=n(""),s=n(":dels"),c=e.type,t="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],l=t[0],f=t[1],h=e.trans._cache;return p.mutate(e).then(function(e){var t,o,a,u;return b(l)?("delete"!==c&&(l=e.results),i.addKeys(l),(t=Fn(l,h))||"add"===c||s.addKeys(l),(t||f)&&(o=n,a=t,u=f,y.indexes.forEach(function(t){var n=o(t.name||"");function r(e){return null!=e?t.extractKey(e):null}function i(e){return t.multiEntry&&b(e)?e.forEach(function(e){return n.addKey(e)}):n.addKey(e)}(a||u).forEach(function(e,t){var n=a&&r(a[t]),t=u&&r(u[t]);0!==Ft(n,t)&&(null!=n&&i(n),null!=t&&i(t))})}))):l?(t={from:l.lower,to:l.upper},s.add(t),i.add(t)):(i.add(m),s.add(m),y.indexes.forEach(function(e){return n(e.name).add(m)})),e})}}),f={get:function(e){return[t,new qn(e.key)]},getMany:function(e){return[t,(new qn).addKeys(e.keys)]},count:e,query:e,openCursor:e};return x(f).forEach(function(s){n[s]=function(i){var t=Se.subscr;if(t){var e=function(e){e="idb://"+v+"/"+d+"/"+e;return t[e]||(t[e]=new qn)},o=e(""),a=e(":dels"),n=f[s](i),r=n[0],n=n[1];if(e(r.name||"").add(n),!r.isPrimaryKey){if("count"!==s){var u="query"===s&&l&&i.values&&p.query(g(g({},i),{values:!1}));return p[s].apply(this,arguments).then(function(t){if("query"===s){if(l&&i.values)return u.then(function(e){e=e.result;return o.addKeys(e),t});var e=i.values?t.result.map(c):t.result;(i.values?o:a).addKeys(e)}else if("openCursor"===s){var n=t,r=i.values;return n&&Object.create(n,{key:{get:function(){return a.addKey(n.primaryKey),n.key}},primaryKey:{get:function(){var e=n.primaryKey;return a.addKey(e),e}},value:{get:function(){return r&&o.addKey(n.primaryKey),n.value}}})}return t})}a.add(m)}}return p[s].apply(this,arguments)}}),n}})}};var Hn=(Qn.prototype.version=function(t){if(isNaN(t)||t<.1)throw new $.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new $.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);var e=this._versions,n=e.filter(function(e){return e._cfg.version===t})[0];return n||(n=new this.Version(t),e.push(n),e.sort(bn),n.stores({}),this._state.autoSchema=!1,n)},Qn.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||Se.letThrough||this._vip)?e():new De(function(e,t){if(n._state.openComplete)return t(new $.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return void t(new $.DatabaseClosed);n.open().catch(ee)}n._state.dbReadyPromise.then(e,t)}).then(e)},Qn.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,i=e.name;i&&this.unuse({stack:t,name:i});e=this._middlewares[t]||(this._middlewares[t]=[]);return e.push({stack:t,create:n,level:null==r?10:r,name:i}),e.sort(function(e,t){return e.level-t.level}),this},Qn.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(e){return r?e.create!==r:!!n&&e.name!==n})),this},Qn.prototype.open=function(){return jn(this)},Qn.prototype._close=function(){var n=this._state,e=vt.indexOf(this);if(0<=e&&vt.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}n.dbReadyPromise=new De(function(e){n.dbReadyResolve=e}),n.openCanceller=new De(function(e,t){n.cancelOpen=t})},Qn.prototype.close=function(){this._close();var e=this._state;this._options.autoOpen=!1,e.dbOpenError=new $.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)},Qn.prototype.delete=function(){var i=this,n=0<arguments.length,o=this._state;return new De(function(r,t){function e(){i.close();var e=i._deps.indexedDB.deleteDatabase(i.name);e.onsuccess=ze(function(){var e,t,n;e=i._deps,t=i.name,n=e.indexedDB,e=e.IDBKeyRange,An(n)||t===_t||Sn(n,e).delete(t).catch(ee),r()}),e.onerror=$t(t),e.onblocked=i._fireOnBlocked}if(n)throw new $.InvalidArgument("Arguments not allowed in db.delete()");o.isBeingOpened?o.dbReadyPromise.then(e):e()})},Qn.prototype.backendDB=function(){return this.idbdb},Qn.prototype.isOpen=function(){return null!==this.idbdb},Qn.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},Qn.prototype.hasFailed=function(){return null!==this._state.dbOpenError},Qn.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(Qn.prototype,"tables",{get:function(){var t=this;return x(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),Qn.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new $.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,K(i),n]}.apply(this,arguments);return this._transaction.apply(this,e)},Qn.prototype._transaction=function(e,t,n){var r=this,i=Se.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);var o,a,u=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=t.map(function(e){e=e instanceof r.Table?e.name:e;if("string"!=typeof e)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e}),"r"==e||e===wt)o=wt;else{if("rw"!=e&&e!=xt)throw new $.InvalidArgument("Invalid transaction mode: "+e);o=xt}if(i){if(i.mode===wt&&o===xt){if(!u)throw new $.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&a.forEach(function(e){if(i&&-1===i.storeNames.indexOf(e)){if(!u)throw new $.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),u&&i&&!i.active&&(i=null)}}catch(n){return i?i._promise(null,function(e,t){t(n)}):ft(n)}var s=function i(o,a,u,s,c){return De.resolve().then(function(){var e=Se.transless||Se,t=o._createTransaction(a,u,o._dbSchema,s),e={trans:t,transless:e};if(s)t.idbtrans=s.idbtrans;else try{t.create(),o._state.PR1398_maxLoop=3}catch(e){return e.name===X.InvalidState&&o.isOpen()&&0<--o._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),o._close(),o.open().then(function(){return i(o,a,u,null,c)})):ft(e)}var n,r=R(c);return r&&Ze(),e=De.follow(function(){var e;(n=c.call(t,t))&&(r?(e=et.bind(null,null),n.then(e,e)):"function"==typeof n.next&&"function"==typeof n.throw&&(n=Dn(n)))},e),(n&&"function"==typeof n.then?De.resolve(n).then(function(e){return t.active?e:ft(new $.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):e.then(function(){return n})).then(function(e){return s&&t._resolve(),t._completion.then(function(){return e})}).catch(function(e){return t._reject(e),ft(e)})})}.bind(null,this,o,a,i,n);return i?i._promise(o,s,"lock"):Se.trans?ot(Se.transless,function(){return r._whenReady(s)}):this._whenReady(s)},Qn.prototype.table=function(e){if(!m(this._allTables,e))throw new $.InvalidTable("Table "+e+" does not exist");return this._allTables[e]},Qn);function Qn(e,t){var o=this;this._middlewares={},this.verno=0;var n=Qn.dependencies;this._options=t=g({addons:Qn.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};n=t.addons;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var a,r,u,i,s,c={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ee,dbReadyPromise:null,cancelOpen:ee,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};c.dbReadyPromise=new De(function(e){c.dbReadyResolve=e}),c.openCanceller=new De(function(e,t){c.cancelOpen=t}),this._state=c,this.name=e,this.on=St(this,"populate","blocked","versionchange","close",{ready:[se,ee]}),this.on.ready.subscribe=p(this.on.ready.subscribe,function(i){return function(n,r){Qn.vip(function(){var t,e=o._state;e.openComplete?(e.dbOpenError||De.resolve().then(n),r&&i(n)):e.onReadyBeingFired?(e.onReadyBeingFired.push(n),r&&i(n)):(i(n),t=o,r||i(function e(){t.on.ready.unsubscribe(n),t.on.ready.unsubscribe(e)}))})}}),this.Collection=(a=this,At(qt.prototype,function(e,t){this.db=a;var n=Et,r=null;if(t)try{n=t()}catch(e){r=e}var i=e._ctx,t=i.table,e=t.hook.reading.fire;this._ctx={table:t,index:i.index,isPrimKey:!i.index||t.schema.primKey.keyPath&&i.index===t.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:i.or,valueMapper:e!==te?e:null}})),this.Table=(r=this,At(Kt.prototype,function(e,t,n){this.db=r,this._tx=n,this.name=e,this.schema=t,this.hook=r._allTables[e]?r._allTables[e].hook:St(null,{creating:[ie,ee],reading:[ne,te],updating:[ae,ee],deleting:[oe,ee]})})),this.Transaction=(u=this,At(rn.prototype,function(e,t,n,r,i){var o=this;this.db=u,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,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 De(function(e,t){o._resolve=e,o._reject=t}),this._completion.then(function(){o.active=!1,o.on.complete.fire()},function(e){var t=o.active;return o.active=!1,o.on.error.fire(e),o.parent?o.parent._reject(e):t&&o.idbtrans&&o.idbtrans.abort(),ft(e)})})),this.Version=(i=this,At(Kn.prototype,function(e){this.db=i,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,At(Xt.prototype,function(e,t,n){this.db=s,this._ctx={table:e,index:":id"===t?null:t,or:n};var r=s._deps.indexedDB;if(!r)throw new $.MissingAPI;this._cmp=this._ascending=r.cmp.bind(r),this._descending=function(e,t){return r.cmp(t,e)},this._max=function(e,t){return 0<r.cmp(e,t)?e:t},this._min=function(e,t){return r.cmp(e,t)<0?e:t},this._IDBKeyRange=s._deps.IDBKeyRange})),this.on("versionchange",function(e){0<e.newVersion?console.warn("Another connection wants to upgrade database '"+o.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+o.name+"'. Closing db now to resume the delete request."),o.close()}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('"+o.name+"') was blocked"):console.warn("Upgrade '"+o.name+"' blocked by other connection holding version "+e.oldVersion/10)}),this._maxKey=cn(t.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new o.Transaction(e,t,n,o._options.chromeTransactionDurability,r)},this._fireOnBlocked=function(t){o.on("blocked").fire(t),vt.filter(function(e){return e.name===o.name&&e!==o&&!e._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(Bn),this.use(Rn),this.use(Gn),this.use(Mn),this.vip=Object.create(this,{_vip:{value:!0}}),n.forEach(function(e){return e(o)})}var Xn,V="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable",Jn=($n.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},$n.prototype[V]=function(){return this},$n);function $n(e){this._subscribe=e}function Zn(t,n){return x(n).forEach(function(e){Ln(t[e]||(t[e]=new qn),n[e])}),t}function er(d){return new Jn(function(n){var r=R(d);var i=!1,o={},a={},u={get closed(){return i},unsubscribe:function(){i=!0,nn.storagemutated.unsubscribe(f)}};n.start&&n.start(u);var s=!1,c=!1;function l(){return x(a).some(function(e){return o[e]&&Vn(o[e],a[e])})}var f=function(e){Zn(o,e),l()&&h()},h=function(){var t,e;s||i||(o={},e=function(e){r&&Ze();var t=function(){return $e(d,{subscr:e,trans:null})},t=Se.trans?ot(Se.transless,t):t();return r&&t.then(et,et),t}(t={}),c||(nn(en,f),c=!0),s=!0,Promise.resolve(e).then(function(e){s=!1,i||(l()?h():(o={},a=t,n.next&&n.next(e)))},function(e){s=!1,n.error&&n.error(e),u.unsubscribe()}))};return h(),u})}try{Xn={indexedDB:h.indexedDB||h.mozIndexedDB||h.webkitIndexedDB||h.msIndexedDB,IDBKeyRange:h.IDBKeyRange||h.webkitIDBKeyRange}}catch(e){Xn={indexedDB:null,IDBKeyRange:null}}var tr=Hn;function nr(e){var t=ir;try{ir=!0,nn.storagemutated.fire(e)}finally{ir=t}}r(tr,g(g({},e),{delete:function(e){return new tr(e,{addons:[]}).delete()},exists:function(e){return new tr(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=tr.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(An(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==_t})}):Sn(n,t).toCollection().primaryKeys()).then(e)}catch(e){return ft(new $.MissingAPI)}var t,n},defineClass:function(){return function(e){u(this,e)}},ignoreTransaction:function(e){return Se.trans?ot(Se.transless,e):e()},vip:Cn,async:function(t){return function(){try{var e=Dn(t.apply(this,arguments));return e&&"function"==typeof e.then?e:De.resolve(e)}catch(e){return ft(e)}}},spawn:function(e,t,n){try{var r=Dn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:De.resolve(r)}catch(e){return ft(e)}},currentTransaction:{get:function(){return Se.trans||null}},waitFor:function(e,t){t=De.resolve("function"==typeof e?tr.ignoreTransaction(e):e).timeout(t||6e4);return Se.trans?Se.trans.waitFor(t):t},Promise:De,debug:{get:function(){return F},set:function(e){M(e,"dexie"===e?function(){return!0}:ht)}},derive:o,extend:u,props:r,override:p,Events:St,on:nn,liveQuery:er,extendObservabilitySet:Zn,getByKeyPath:k,setByKeyPath:E,delByKeyPath:function(t,e){"string"==typeof e?E(t,e,void 0):"length"in e&&[].map.call(e,function(e){E(t,e,void 0)})},shallowClone:P,deepClone:A,getObjectDiff:Tn,cmp:Ft,asap:_,minKey:-1/0,addons:[],connections:vt,errnames:X,dependencies:Xn,semVer:W,version:W.split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),tr.maxKey=cn(tr.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(nn(en,function(e){var t;ir||(mt?(t=document.createEvent("CustomEvent")).initCustomEvent(tn,!0,!0,e):t=new CustomEvent(tn,{detail:e}),ir=!0,dispatchEvent(t),ir=!1)}),addEventListener(tn,function(e){e=e.detail;ir||nr(e)}));var rr,ir=!1;return"undefined"!=typeof BroadcastChannel?(rr=new BroadcastChannel(tn),nn(en,function(e){ir||rr.postMessage(e)}),rr.onmessage=function(e){e.data&&nr(e.data)}):"undefined"!=typeof self&&"undefined"!=typeof navigator&&(nn(en,function(t){try{ir||("undefined"!=typeof localStorage&&localStorage.setItem(tn,JSON.stringify({trig:Math.random(),changedParts:t})),"object"==typeof self.clients&&i([],self.clients.matchAll({includeUncontrolled:!0}),!0).forEach(function(e){return e.postMessage({type:tn,changedParts:t})}))}catch(e){}}),addEventListener("storage",function(e){e.key!==tn||(e=JSON.parse(e.newValue))&&nr(e.changedParts)}),(W=self.document&&navigator.serviceWorker)&&W.addEventListener("message",function(e){e=e.data;e&&e.type===tn&&nr(e.changedParts)})),De.rejectionMapper=function(e,t){return!e||e instanceof Y||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Z[e.name]?e:(t=new Z[e.name](t||e.message,e),"stack"in e&&c(t,"stack",{get:function(){return this.inner.stack}}),t)},M(F,ht),g(Hn,Object.freeze({__proto__:null,Dexie:Hn,liveQuery:er,default:Hn,RangeSet:qn,mergeRanges:Ln,rangesOverlap:Vn}),{default:Hn}),Hn});
1
+ (function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Dexie=t()})(this,function(){"use strict";var s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};var g=function(){return(g=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function o(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=Object.keys,b=Array.isArray;function u(t,n){return"object"!=typeof n||x(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||h.Promise||(h.Promise=Promise);var c=Object.getPrototypeOf,n={}.hasOwnProperty;function m(e,t){return n.call(e,t)}function r(t,n){"function"==typeof n&&(n=n(c(t))),("undefined"==typeof Reflect?x:Reflect.ownKeys)(n).forEach(function(e){a(t,e,n[e])})}var i=Object.defineProperty;function a(e,t,n,r){i(e,t,u(n&&m(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function l(t){return{from:function(e){return t.prototype=Object.create(e.prototype),a(t.prototype,"constructor",t),{extend:r.bind(null,t.prototype)}}}}var f=Object.getOwnPropertyDescriptor;function d(e,t){return f(e,t)||(e=c(e))&&d(e,t)}var p=[].slice;function y(e,t,n){return p.call(e,t,n)}function v(e,t){return t(e)}function _(e){if(!e)throw new Error("Assertion Failed")}function w(e){h.setImmediate?setImmediate(e):setTimeout(e,0)}function k(e,r){return e.reduce(function(e,t,n){n=r(t,n);return n&&(e[n[0]]=n[1]),e},{})}function E(e,t){if(m(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,o=t.length;r<o;++r){var i=E(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var u=e[t.substr(0,a)];return void 0===u?void 0:E(u,t.substr(a+1))}}function P(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){_("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)P(e,t[r],n[r])}else{var i,a=t.indexOf(".");-1!==a?(i=t.substr(0,a),""===(a=t.substr(a+1))?void 0===n?b(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n:P(e[i]||(e[i]={}),a,n)):void 0===n?b(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function O(e){var t,n={};for(t in e)m(e,t)&&(n[t]=e[t]);return n}var t=[].concat;function K(e){return t.apply([],e)}var e="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(K([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return h[e]}),S=e.map(function(e){return h[e]});k(e,function(e){return[e,!0]});var A=null;function j(e){A="undefined"!=typeof WeakMap&&new WeakMap;e=function e(t){if(!t||"object"!=typeof t)return t;var n=A&&A.get(t);if(n)return n;if(b(t)){n=[],A&&A.set(t,n);for(var r=0,o=t.length;r<o;++r)n.push(e(t[r]))}else if(0<=S.indexOf(t.constructor))n=t;else{var i,a=c(t);for(i in n=a===Object.prototype?{}:Object.create(a),A&&A.set(t,n),t)m(t,i)&&(n[i]=e(t[i]))}return n}(e);return A=null,e}var C={}.toString;function D(e){return C.call(e).slice(8,-1)}var I="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",B="symbol"==typeof I?function(e){var t;return null!=e&&(t=e[I])&&t.apply(e)}:function(){return null},T={};function R(e){var t,n,r,o;if(1===arguments.length){if(b(e))return e.slice();if(this===T&&"string"==typeof e)return[e];if(o=B(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var F="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},M="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function N(e,t){M=e,q=t}var q=function(){return!0},U=!new Error("").stack;function L(){if(U)try{throw 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(q).map(function(e){return"\n"+e}).join("")):""}var W=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],z=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(W),Y={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 G(e,t){this._e=L(),this.name=e,this.message=t}function H(e,t){return e+". Errors: "+Object.keys(t).map(function(e){return t[e].toString()}).filter(function(e,t,n){return n.indexOf(e)===t}).join("\n")}function Q(e,t,n,r){this._e=L(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=H(e,t)}function X(e,t){this._e=L(),this.name="BulkError",this.failures=Object.keys(t).map(function(e){return t[e]}),this.failuresByPos=t,this.message=H(e,t)}l(G).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}}),l(Q).from(G),l(X).from(G);var J=z.reduce(function(e,t){return e[t]=t+"Error",e},{}),$=G,Z=z.reduce(function(e,n){var r=n+"Error";function t(e,t){this._e=L(),this.name=r,e?"string"==typeof e?(this.message="".concat(e).concat(t?"\n "+t:""),this.inner=t||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=Y[n]||r,this.inner=null)}return l(t).from($),e[n]=t,e},{});Z.Syntax=SyntaxError,Z.Type=TypeError,Z.Range=RangeError;var ee=W.reduce(function(e,t){return e[t+"Error"]=Z[t],e},{});e=z.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=Z[t]),e},{});function te(){}function ne(e){return e}function re(t,n){return null==t||t===ne?n:function(e){return n(t(e))}}function oe(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ie(o,i){return o===te?i:function(){var e=o.apply(this,arguments);void 0!==e&&(arguments[0]=e);var t=this.onsuccess,n=this.onerror;this.onsuccess=null,this.onerror=null;var r=i.apply(this,arguments);return t&&(this.onsuccess=this.onsuccess?oe(t,this.onsuccess):t),n&&(this.onerror=this.onerror?oe(n,this.onerror):n),void 0!==r?r:e}}function ae(n,r){return n===te?r:function(){n.apply(this,arguments);var e=this.onsuccess,t=this.onerror;this.onsuccess=this.onerror=null,r.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?oe(e,this.onsuccess):e),t&&(this.onerror=this.onerror?oe(t,this.onerror):t)}}function ue(o,i){return o===te?i:function(e){var t=o.apply(this,arguments);u(e,t);var n=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;e=i.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?oe(n,this.onsuccess):n),r&&(this.onerror=this.onerror?oe(r,this.onerror):r),void 0===t?void 0===e?void 0:e:u(t,e)}}function se(e,t){return e===te?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ce(o,i){return o===te?i:function(){var e=o.apply(this,arguments);if(e&&"function"==typeof e.then){for(var t=this,n=arguments.length,r=new Array(n);n--;)r[n]=arguments[n];return e.then(function(){return i.apply(t,r)})}return i.apply(this,arguments)}}e.ModifyError=Q,e.DexieError=G,e.BulkError=X;var le={},fe=100,he=100,W="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,c(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,c(t),e]}(),de=W[0],pe=W[1],ye=W[2],ve=pe&&pe.then,me=de&&de.constructor,ge=!!ye,be=!1,_e=ye?function(){ye.then(Ue)}:h.setImmediate?setImmediate.bind(null,Ue):h.MutationObserver?function(){var e=document.createElement("div");new MutationObserver(function(){Ue(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:function(){setTimeout(Ue,0)},we=function(e,t){je.push([e,t]),ke&&(_e(),ke=!1)},xe=!0,ke=!0,Ee=[],Pe=[],Oe=null,Ke=ne,Se={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ft,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(function(e){try{ft(e[0],e[1])}catch(e){}})}},Ae=Se,je=[],Ce=0,De=[];function Ie(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=Ae;if(M&&(this._stackHolder=L(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==le)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Re(this,this._value))}this._state=null,this._value=null,++t.ref,function t(r,e){try{e(function(n){if(null===r._state){if(n===r)throw new TypeError("A promise cannot be resolved with itself.");var e=r._lib&&Le();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof Ie?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Fe(r)),e&&Ve()}},Re.bind(null,r))}catch(e){Re(r,e)}}(this,e)}var Be={get:function(){var u=Ae,t=Je;function e(n,r){var o=this,i=!u.global&&(u!==Ae||t!==Je),a=i&&!tt(),e=new Ie(function(e,t){Me(o,new Te(st(n,u,i,a),st(r,u,i,a),e,t,u))});return M&&qe(e,this),e}return e.prototype=le,e},set:function(e){a(this,"then",e&&e.prototype===le?Be:{get:function(){return e},set:Be.set})}};function Te(e,t,n,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=o}function Re(t,n){var e,r;Pe.push(n),null===t._state&&(e=t._lib&&Le(),n=Ke(n),t._state=!1,t._value=n,M&&null!==n&&"object"==typeof n&&!n._promise&&function(e,t,n){try{e.apply(null,n)}catch(e){t&&t(e)}}(function(){var e=d(n,"stack");n._promise=t,a(n,"stack",{get:function(){return be?e&&(e.get?e.get.apply(n):e.value):t.stack}})}),r=t,Ee.some(function(e){return e._value===r._value})||Ee.push(r),Fe(t),e&&Ve())}function Fe(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Me(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===Ce&&(++Ce,we(function(){0==--Ce&&We()},[]))}function Me(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,++Ce,we(Ne,[n,e,t])}else e._listeners.push(t)}function Ne(e,t,n){try{var r,o=(Oe=t)._value;t._state?r=e(o):(Pe.length&&(Pe=[]),r=e(o),-1===Pe.indexOf(o)&&function(e){var t=Ee.length;for(;t;)if(Ee[--t]._value===e._value)return Ee.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{Oe=null,0==--Ce&&We(),--n.psd.ref||n.psd.finalize()}}function qe(e,t){var n=t?t._numPrev+1:0;n<fe&&(e._prev=t,e._numPrev=n)}function Ue(){Le()&&Ve()}function Le(){var e=xe;return ke=xe=!1,e}function Ve(){var e,t,n;do{for(;0<je.length;)for(e=je,je=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<je.length);ke=xe=!0}function We(){var e=Ee;Ee=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=De.slice(0),n=t.length;n;)t[--n]()}function ze(e){return new Ie(le,!1,e)}function Ye(n,r){var o=Ae;return function(){var e=Le(),t=Ae;try{return ot(o,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{ot(t,!1),e&&Ve()}}}r(Ie.prototype,{then:Be,_then:function(e,t){Me(this,new Te(null,null,e,t,Ae))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=e,n=arguments[1];return"function"==typeof t?this.then(null,function(e){return(e instanceof t?n:ze)(e)}):this.then(null,function(e){return(e&&e.name===t?n:ze)(e)})},finally:function(t){return this.then(function(e){return t(),e},function(e){return t(),ze(e)})},stack:{get:function(){if(this._stack)return this._stack;try{be=!0;var e=function e(t,n,r){if(n.length===r)return n;var o="";{var i,a,u;!1===t._state&&(null!=(i=t._value)?(a=i.name||"Error",u=i.message||i,o=V(i,0)):(a=i,u=""),n.push(a+(u?": "+u:"")+o))}M&&((o=V(t._stackHolder,2))&&-1===n.indexOf(o)&&n.push(o),t._prev&&e(t._prev,n,r));return n}(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{be=!1}}},timeout:function(r,o){var i=this;return r<1/0?new Ie(function(e,t){var n=setTimeout(function(){return t(new Z.Timeout(o))},r);i.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&a(Ie.prototype,Symbol.toStringTag,"Dexie.Promise"),Se.env=it(),r(Ie,{all:function(){var i=R.apply(null,arguments).map(nt);return new Ie(function(n,r){0===i.length&&n([]);var o=i.length;i.forEach(function(e,t){return Ie.resolve(e).then(function(e){i[t]=e,--o||n(i)},r)})})},resolve:function(n){if(n instanceof Ie)return n;if(n&&"function"==typeof n.then)return new Ie(function(e,t){n.then(e,t)});var e=new Ie(le,!0,n);return qe(e,Oe),e},reject:ze,race:function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(t,n){e.map(function(e){return Ie.resolve(e).then(t,n)})})},PSD:{get:function(){return Ae},set:function(e){return Ae=e}},totalEchoes:{get:function(){return Je}},newPSD:Ze,usePSD:at,scheduler:{get:function(){return we},set:function(e){we=e}},rejectionMapper:{get:function(){return Ke},set:function(e){Ke=e}},follow:function(o,n){return new Ie(function(e,t){return Ze(function(n,r){var e=Ae;e.unhandleds=[],e.onunhandled=r,e.finalize=oe(function(){var t,e=this;t=function(){0===e.unhandleds.length?n():r(e.unhandleds[0])},De.push(function e(){t(),De.splice(De.indexOf(e),1)}),++Ce,we(function(){0==--Ce&&We()},[])},e.finalize),o()},n,e,t)})}}),me&&(me.allSettled&&a(Ie,"allSettled",function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(n){0===e.length&&n([]);var r=e.length,o=new Array(r);e.forEach(function(e,t){return Ie.resolve(e).then(function(e){return o[t]={status:"fulfilled",value:e}},function(e){return o[t]={status:"rejected",reason:e}}).then(function(){return--r||n(o)})})})}),me.any&&"undefined"!=typeof AggregateError&&a(Ie,"any",function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(n,r){0===e.length&&r(new AggregateError([]));var o=e.length,i=new Array(o);e.forEach(function(e,t){return Ie.resolve(e).then(function(e){return n(e)},function(e){i[t]=e,--o||r(new AggregateError(i))})})})}));var Ge={awaits:0,echoes:0,id:0},He=0,Qe=[],Xe=0,Je=0,$e=0;function Ze(e,t,n,r){var o=Ae,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++$e;var a=Se.env;i.env=ge?{Promise:Ie,PromiseProp:{value:Ie,configurable:!0,writable:!0},all:Ie.all,race:Ie.race,allSettled:Ie.allSettled,any:Ie.any,resolve:Ie.resolve,reject:Ie.reject,nthen:ct(a.nthen,i),gthen:ct(a.gthen,i)}:{},t&&u(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};r=at(i,e,n,r);return 0===i.ref&&i.finalize(),r}function et(){return Ge.id||(Ge.id=++He),++Ge.awaits,Ge.echoes+=he,Ge.id}function tt(){return!!Ge.awaits&&(0==--Ge.awaits&&(Ge.id=0),Ge.echoes=Ge.awaits*he,!0)}function nt(e){return Ge.echoes&&e&&e.constructor===me?(et(),e.then(function(e){return tt(),e},function(e){return tt(),ht(e)})):e}function rt(){var e=Qe[Qe.length-1];Qe.pop(),ot(e,!1)}function ot(e,t){var n,r=Ae;(t?!Ge.echoes||Xe++&&e===Ae:!Xe||--Xe&&e===Ae)||ut(t?function(e){++Je,Ge.echoes&&0!=--Ge.echoes||(Ge.echoes=Ge.id=0),Qe.push(Ae),ot(e,!0)}.bind(null,e):rt),e!==Ae&&(Ae=e,r===Se&&(Se.env=it()),ge&&(n=Se.env.Promise,t=e.env,pe.then=t.nthen,n.prototype.then=t.gthen,(r.global||e.global)&&(Object.defineProperty(h,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function it(){var e=h.Promise;return ge?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(h,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:pe.then,gthen:e.prototype.then}:{}}function at(e,t,n,r,o){var i=Ae;try{return ot(e,!0),t(n,r,o)}finally{ot(i,!1)}}function ut(e){ve.call(de,e)}function st(t,n,r,o){return"function"!=typeof t?t:function(){var e=Ae;r&&et(),ot(n,!0);try{return t.apply(this,arguments)}finally{ot(e,!1),o&&ut(tt)}}}function ct(n,r){return function(e,t){return n.call(this,st(e,r),st(t,r))}}-1===(""+ve).indexOf("[native code]")&&(et=tt=te);var lt="unhandledrejection";function ft(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,o={promise:t,reason:e};if(h.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(lt,!0,!0),u(r,o)):h.CustomEvent&&u(r=new CustomEvent(lt,{detail:o}),o),r&&h.dispatchEvent&&(dispatchEvent(r),!h.PromiseRejectionEvent&&h.onunhandledrejection))try{h.onunhandledrejection(r)}catch(e){}M&&r&&!r.defaultPrevented&&console.warn("Unhandled rejection: ".concat(e.stack||e))}catch(e){}}var ht=Ie.reject;function dt(e){return!/(dexie\.js|dexie\.min\.js)/.test(e)}var z="4.0.0-alpha.2",pt=String.fromCharCode(65535),yt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",vt="String expected.",mt=[],gt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),bt=gt,_t=gt,wt="__dbnames",xt="readonly",kt="readwrite";function Et(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Pt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ot(t){return"string"!=typeof t||/\./.test(t)?function(e){return e}:function(e){return void 0===e[t]&&t in e&&delete(e=j(e))[t],e}}function Kt(){throw Z.Type()}var St=(At.prototype._trans=function(e,r,t){var n=this._tx||Ae.trans,o=this.name;function i(e,t,n){if(!n.schema[o])throw new Z.NotFound("Table "+o+" not part of transaction");return r(n.idbtrans,n)}var a=Le();try{return n&&n.db===this.db?n===Ae.trans?n._promise(e,i,t):Ze(function(){return n._promise(e,i,t)},{trans:n,transless:Ae.transless||Ae}):function t(n,r,o,i){if(n.idbdb&&(n._state.openComplete||Ae.letThrough||n._vip)){var a=n._createTransaction(r,o,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(e){return e.name===J.InvalidState&&n.isOpen()&&0<--n._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(function(){return t(n,r,o,i)})):ht(e)}return a._promise(r,function(e,t){return Ze(function(){return Ae.trans=a,i(e,t,a)})}).then(function(e){return a._completion.then(function(){return e})})}if(n._state.openComplete)return ht(new Z.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return ht(new Z.DatabaseClosed);n.open().catch(te)}return n._state.dbReadyPromise.then(function(){return t(n,r,o,i)})}(this.db,e,[this.name],i)}finally{a&&Ve()}},At.prototype.get=function(t,e){var n=this;return t&&t.constructor===Object?this.where(t).first(e):this._trans("readonly",function(e){return n.core.get({trans:e,key:t}).then(function(e){return n.hook.reading.fire(e)})}).then(e)},At.prototype.where=function(i){if("string"==typeof i)return new this.db.WhereClause(this,i);if(b(i))return new this.db.WhereClause(this,"[".concat(i.join("+"),"]"));var n=x(i);if(1===n.length)return this.where(n[0]).equals(i[n[0]]);var e=this.schema.indexes.concat(this.schema.primKey).filter(function(t){return t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})&&t.keyPath.every(function(e){return 0<=n.indexOf(e)})})[0];if(e&&this.db._maxKey!==pt)return this.where(e.name).equals(e.keyPath.map(function(e){return i[e]}));!e&&M&&console.warn("The query ".concat(JSON.stringify(i)," on ").concat(this.name," would benefit of a ")+"compound index [".concat(n.join("+"),"]"));var a=this.schema.idxByName,r=this.db._deps.indexedDB;function u(e,t){try{return 0===r.cmp(e,t)}catch(e){return!1}}var t=n.reduce(function(e,t){var n=e[0],r=e[1],e=a[t],o=i[t];return[n||e,n||!e?Et(r,e&&e.multi?function(e){e=E(e,t);return b(e)&&e.some(function(e){return u(o,e)})}:function(e){return u(o,E(e,t))}):r]},[null,null]),o=t[0],t=t[1];return o?this.where(o.name).equals(i[o.keyPath]).filter(t):e?this.filter(t):this.where(n).equals("")},At.prototype.filter=function(e){return this.toCollection().and(e)},At.prototype.count=function(e){return this.toCollection().count(e)},At.prototype.offset=function(e){return this.toCollection().offset(e)},At.prototype.limit=function(e){return this.toCollection().limit(e)},At.prototype.each=function(e){return this.toCollection().each(e)},At.prototype.toArray=function(e){return this.toCollection().toArray(e)},At.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},At.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,b(e)?"[".concat(e.join("+"),"]"):e))},At.prototype.reverse=function(){return this.toCollection().reverse()},At.prototype.mapToClass=function(r){var e,t=this.db,n=this.name;function o(){return null!==e&&e.apply(this,arguments)||this}(this.schema.mappedClass=r).prototype instanceof Kt&&(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(o,e=r),Object.defineProperty(o.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),o.prototype.table=function(){return n},r=o);for(var i=new Set,a=r.prototype;a;a=c(a))Object.getOwnPropertyNames(a).forEach(function(e){return i.add(e)});function u(e){if(!e)return e;var t,n=Object.create(r.prototype);for(t in e)if(!i.has(t))try{n[t]=e[t]}catch(e){}return n}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=u,this.hook("reading",u),r},At.prototype.defineClass=function(){return this.mapToClass(function(e){u(this,e)})},At.prototype.add=function(t,n){var r=this,e=this.schema.primKey,o=e.auto,i=e.keyPath,a=t;return i&&o&&(a=Ot(i)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):e.lastResult}).then(function(e){if(i)try{P(t,i,e)}catch(e){}return e})},At.prototype.update=function(t,n){if("object"!=typeof t||b(t))return this.where(":id").equals(t).modify(n);var e=E(t,this.schema.primKey.keyPath);if(void 0===e)return ht(new Z.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?x(n).forEach(function(e){P(t,e,n[e])}):n(t,{value:t,primKey:e})}catch(e){}return this.where(":id").equals(e).modify(n)},At.prototype.put=function(t,n){var r=this,e=this.schema.primKey,o=e.auto,i=e.keyPath,a=t;return i&&o&&(a=Ot(i)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):e.lastResult}).then(function(e){if(i)try{P(t,i,e)}catch(e){}return e})},At.prototype.delete=function(t){var n=this;return this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"delete",keys:[t]})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):void 0})},At.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:Pt})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):void 0})},At.prototype.bulkGet=function(t){var n=this;return this._trans("readonly",function(e){return n.core.getMany({keys:t,trans:e}).then(function(e){return e.map(function(e){return n.hook.reading.fire(e)})})})},At.prototype.bulkAdd=function(r,e,t){var i=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=i.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new Z.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var o=r.length,t=t&&n?r.map(Ot(t)):r;return i.core.mutate({trans:e,type:"add",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new X("".concat(i.name,".bulkAdd(): ").concat(t," of ").concat(o," operations failed"),e)})})},At.prototype.bulkPut=function(r,e,t){var i=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=i.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new Z.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var o=r.length,t=t&&n?r.map(Ot(t)):r;return i.core.mutate({trans:e,type:"put",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new X("".concat(i.name,".bulkPut(): ").concat(t," of ").concat(o," operations failed"),e)})})},At.prototype.bulkDelete=function(t){var r=this,o=t.length;return this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"delete",keys:t})}).then(function(e){var t=e.numFailures,n=e.lastResult,e=e.failures;if(0===t)return n;throw new X("".concat(r.name,".bulkDelete(): ").concat(t," of ").concat(o," operations failed"),e)})},At);function At(){}function jt(o){function t(e,t){if(t){for(var n=arguments.length,r=new Array(n-1);--n;)r[n-1]=arguments[n];return a[e].subscribe.apply(null,r),o}if("string"==typeof e)return a[e]}var a={};t.addEventType=u;for(var e=1,n=arguments.length;e<n;++e)u(arguments[e]);return t;function u(e,n,r){if("object"!=typeof e){var o;n=n||se;var i={subscribers:[],fire:r=r||te,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=n(i.fire,e))},unsubscribe:function(t){i.subscribers=i.subscribers.filter(function(e){return e!==t}),i.fire=i.subscribers.reduce(n,r)}};return a[e]=t[e]=i}x(o=e).forEach(function(e){var t=o[e];if(b(t))u(e,o[e][0],o[e][1]);else{if("asap"!==t)throw new Z.InvalidArgument("Invalid event config");var n=u(e,ne,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){w(function(){e.apply(null,t)})})})}})}}function Ct(e,t){return l(t).from({prototype:e}),t}function Dt(r){return Ct(St.prototype,function(e,t,n){this.db=r,this._tx=n,this.name=e,this.schema=t,this.hook=r._allTables[e]?r._allTables[e].hook:jt(null,{creating:[ie,te],reading:[re,ne],updating:[ue,te],deleting:[ae,te]})})}function It(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Bt(e,t){e.filter=Et(e.filter,t)}function Tt(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return Et(r(),t())}:t,e.justLimit=n&&!r}function Rt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new Z.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Ft(e,t,n){var r=Rt(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 Mt(e,i,t,n){var a=e.replayFilter?Et(e.filter,e.replayFilter()):e.filter;if(e.or){var u={},r=function(e,t,n){var r,o;a&&!a(t,n,function(e){return t.stop(e)},function(e){return t.fail(e)})||("[object ArrayBuffer]"===(o=""+(r=t.primaryKey))&&(o=""+new Uint8Array(r)),m(u,o)||(u[o]=!0,i(e,t,n)))};return Promise.all([e.or._iterate(r,t),Nt(Ft(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return Nt(Ft(e,n,t),Et(e.algorithm,a),i,!e.keysOnly&&e.valueMapper)}function Nt(e,r,o,i){var a=Ye(i?function(e,t,n){return o(i(e),t,n)}:o);return e.then(function(n){if(n)return n.start(function(){var t=function(){return n.continue()};r&&!r(n,function(e){return t=e},function(e){n.stop(e),t=te},function(e){n.fail(e),t=te})||a(n.value,n,function(e){return t=e}),t()})})}function qt(e,t){try{var n=Ut(e),r=Ut(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 t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,o=n<r?n:r,i=0;i<o;++i)if(e[i]!==t[i])return e[i]<t[i]?-1:1;return n===r?0:n<r?-1:1}(Lt(e),Lt(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,o=n<r?n:r,i=0;i<o;++i){var a=qt(e[i],t[i]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function Ut(e){var t=typeof e;if("object"!=t)return t;if(ArrayBuffer.isView(e))return"binary";e=D(e);return"ArrayBuffer"===e?"binary":e}function Lt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Vt=(Wt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,ht.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Wt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,ht.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Wt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=Et(t.algorithm,e)},Wt.prototype._iterate=function(e,t){return Mt(this._ctx,e,t,this._ctx.table.core)},Wt.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&u(n,e),t._ctx=n,t},Wt.prototype.raw=function(){return this._ctx.valueMapper=null,this},Wt.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return Mt(n,t,e,n.table.core)})},Wt.prototype.count=function(e){var o=this;return this._read(function(e){var t=o._ctx,n=t.table.core;if(It(t,!0))return n.count({trans:e,query:{index:Rt(t,n.schema),range:t.range}}).then(function(e){return Math.min(e,t.limit)});var r=0;return Mt(t,function(){return++r,!1},e,n).then(function(){return r})}).then(e)},Wt.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],o=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 u(e,t){e=i(e,o),t=i(t,o);return e<t?-a:t<e?a:0}return this.toArray(function(e){return e.sort(u)}).then(t)},Wt.prototype.toArray=function(e){var i=this;return this._read(function(e){var t=i._ctx;if("next"===t.dir&&It(t,!0)&&0<t.limit){var n=t.valueMapper,r=Rt(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(function(e){e=e.result;return n?e.map(n):e})}var o=[];return Mt(t,function(e){return o.push(e)},e,t.table.core).then(function(){return o})},e)},Wt.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,It(e)?Tt(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):Tt(e,function(){var e=t;return function(){return--e<0}})),this},Wt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Tt(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},Wt.prototype.until=function(r,o){return Bt(this._ctx,function(e,t,n){return!r(e.value)||(t(n),o)}),this},Wt.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Wt.prototype.last=function(e){return this.reverse().first(e)},Wt.prototype.filter=function(t){var e;return Bt(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=Et(e.isMatch,t),this},Wt.prototype.and=function(e){return this.filter(e)},Wt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Wt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Wt.prototype.desc=function(){return this.reverse()},Wt.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},Wt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Wt.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},Wt.prototype.keys=function(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)},Wt.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&It(n,!0)&&0<n.limit)return this._read(function(e){var t=Rt(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(function(e){return e.result}).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)},Wt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Wt.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Wt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Wt.prototype.distinct=function(){var e=this._ctx,e=e.index&&e.table.schema.idxByName[e.index];if(!e||!e.multi)return this;var n={};return Bt(this._ctx,function(e){var t=e.primaryKey.toString(),e=m(n,t);return n[t]=!0,!e}),this},Wt.prototype.modify=function(_){var n=this,w=this._ctx;return this._write(function(d){var i,a,p;p="function"==typeof _?_:(i=x(_),a=i.length,function(e){for(var t=!1,n=0;n<a;++n){var r=i[n],o=_[r];E(e,r)!==o&&(P(e,r,o),t=!0)}return t});function y(e,t){var n=t.failures,t=t.numFailures;s+=e-t;for(var r=0,o=x(n);r<o.length;r++){var i=o[r];u.push(n[i])}}var v=w.table.core,e=v.schema.primaryKey,m=e.outbound,g=e.extractKey,b=n.db._options.modifyChunkSize||200,u=[],s=0,t=[];return n.clone().primaryKeys().then(function(f){function h(c){var l=Math.min(b,f.length-c);return v.getMany({trans:d,keys:f.slice(c,c+l),cache:"immutable"}).then(function(e){for(var n=[],t=[],r=m?[]:null,o=[],i=0;i<l;++i){var a=e[i],u={value:j(a),primKey:f[c+i]};!1!==p.call(u,u.value,u)&&(null==u.value?o.push(f[c+i]):m||0===qt(g(a),g(u.value))?(t.push(u.value),m&&r.push(f[c+i])):(o.push(f[c+i]),n.push(u.value)))}var s=It(w)&&w.limit===1/0&&("function"!=typeof _||_===zt)&&{index:w.index,range:w.range};return Promise.resolve(0<n.length&&v.mutate({trans:d,type:"add",values:n}).then(function(e){for(var t in e.failures)o.splice(parseInt(t),1);y(n.length,e)})).then(function(){return(0<t.length||s&&"object"==typeof _)&&v.mutate({trans:d,type:"put",keys:r,values:t,criteria:s,changeSpec:"function"!=typeof _&&_}).then(function(e){return y(t.length,e)})}).then(function(){return(0<o.length||s&&_===zt)&&v.mutate({trans:d,type:"delete",keys:o,criteria:s}).then(function(e){return y(o.length,e)})}).then(function(){return f.length>c+l&&h(c+b)})})}return h(0).then(function(){if(0<u.length)throw new Q("Error modifying one or more objects",u,s,t);return f.length})})})},Wt.prototype.delete=function(){var o=this._ctx,n=o.range;return It(o)&&(o.isPrimKey&&!_t||3===n.type)?this._write(function(e){var t=o.table.core.schema.primaryKey,r=n;return o.table.core.count({trans:e,query:{index:t,range:r}}).then(function(n){return o.table.core.mutate({trans:e,type:"deleteRange",range:r}).then(function(e){var t=e.failures;e.lastResult,e.results;e=e.numFailures;if(e)throw new Q("Could not delete some values",Object.keys(t).map(function(e){return t[e]}),n-e);return n-e})})}):this.modify(zt)},Wt);function Wt(){}var zt=function(e,t){return t.value=null};function Yt(e,t){return e<t?-1:e===t?0:1}function Gt(e,t){return t<e?-1:e===t?0:1}function Ht(e,t,n){e=e instanceof Zt?new e.Collection(e):e;return e._ctx.error=new(n||TypeError)(t),e}function Qt(e){return new e.Collection(e,function(){return $t("")}).limit(0)}function Xt(e,s,n,r){var o,c,l,f,h,d,p,y=n.length;if(!n.every(function(e){return"string"==typeof e}))return Ht(e,vt);function t(e){o="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},c="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},l="next"===e?Yt:Gt;var t=n.map(function(e){return{lower:c(e),upper:o(e)}}).sort(function(e,t){return l(e.lower,t.lower)});f=t.map(function(e){return e.upper}),h=t.map(function(e){return e.lower}),p="next"===(d=e)?"":r}t("next");e=new e.Collection(e,function(){return Jt(f[0],h[y-1]+r)});e._ondirectionchange=function(e){t(e)};var v=0;return e._addAlgorithm(function(e,t,n){var r=e.key;if("string"!=typeof r)return!1;var o=c(r);if(s(o,h,v))return!0;for(var i=null,a=v;a<y;++a){var u=function(e,t,n,r,o,i){for(var a=Math.min(e.length,r.length),u=-1,s=0;s<a;++s){var c=t[s];if(c!==r[s])return o(e[s],n[s])<0?e.substr(0,s)+n[s]+n.substr(s+1):o(e[s],r[s])<0?e.substr(0,s)+r[s]+n.substr(s+1):0<=u?e.substr(0,u)+t[u]+n.substr(u+1):null;o(e[s],c)<0&&(u=s)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):u<0?null:e.substr(0,u)+r[u]+n.substr(u+1)}(r,o,f[a],h[a],l,d);null===u&&null===i?v=a+1:(null===i||0<l(i,u))&&(i=u)}return t(null!==i?function(){e.continue(i+p)}:n),!1}),e}function Jt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function $t(e){return{type:1,lower:e,upper:e}}var Zt=(Object.defineProperty(en.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),en.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(e,t)||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Qt(this):new this.Collection(this,function(){return Jt(e,t,!n,!r)})}catch(e){return Ht(this,yt)}},en.prototype.equals=function(e){return null==e?Ht(this,yt):new this.Collection(this,function(){return $t(e)})},en.prototype.above=function(e){return null==e?Ht(this,yt):new this.Collection(this,function(){return Jt(e,void 0,!0)})},en.prototype.aboveOrEqual=function(e){return null==e?Ht(this,yt):new this.Collection(this,function(){return Jt(e,void 0,!1)})},en.prototype.below=function(e){return null==e?Ht(this,yt):new this.Collection(this,function(){return Jt(void 0,e,!1,!0)})},en.prototype.belowOrEqual=function(e){return null==e?Ht(this,yt):new this.Collection(this,function(){return Jt(void 0,e)})},en.prototype.startsWith=function(e){return"string"!=typeof e?Ht(this,vt):this.between(e,e+pt,!0,!0)},en.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Xt(this,function(e,t){return 0===e.indexOf(t[0])},[e],pt)},en.prototype.equalsIgnoreCase=function(e){return Xt(this,function(e,t){return e===t[0]},[e],"")},en.prototype.anyOfIgnoreCase=function(){var e=R.apply(T,arguments);return 0===e.length?Qt(this):Xt(this,function(e,t){return-1!==t.indexOf(e)},e,"")},en.prototype.startsWithAnyOfIgnoreCase=function(){var e=R.apply(T,arguments);return 0===e.length?Qt(this):Xt(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,pt)},en.prototype.anyOf=function(){var t=this,o=R.apply(T,arguments),i=this._cmp;try{o.sort(i)}catch(e){return Ht(this,yt)}if(0===o.length)return Qt(this);var e=new this.Collection(this,function(){return Jt(o[0],o[o.length-1])});e._ondirectionchange=function(e){i="next"===e?t._ascending:t._descending,o.sort(i)};var a=0;return e._addAlgorithm(function(e,t,n){for(var r=e.key;0<i(r,o[a]);)if(++a===o.length)return t(n),!1;return 0===i(r,o[a])||(t(function(){e.continue(o[a])}),!1)}),e},en.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},en.prototype.noneOf=function(){var e=R.apply(T,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Ht(this,yt)}var t=e.reduce(function(e,t){return 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})},en.prototype.inAnyRange=function(e,t){var i=this,a=this._cmp,u=this._ascending,n=this._descending,s=this._min,c=this._max;if(0===e.length)return Qt(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&u(e[0],e[1])<=0}))return Ht(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Z.InvalidArgument);var r=!t||!1!==t.includeLowers,o=t&&!0===t.includeUppers;var l,f=u;function h(e,t){return f(e[0],t[0])}try{(l=e.reduce(function(e,t){for(var n=0,r=e.length;n<r;++n){var o=e[n];if(a(t[0],o[1])<0&&0<a(t[1],o[0])){o[0]=s(o[0],t[0]),o[1]=c(o[1],t[1]);break}}return n===r&&e.push(t),e},[])).sort(h)}catch(e){return Ht(this,yt)}var d=0,p=o?function(e){return 0<u(e,l[d][1])}:function(e){return 0<=u(e,l[d][1])},y=r?function(e){return 0<n(e,l[d][0])}:function(e){return 0<=n(e,l[d][0])};var v=p,e=new this.Collection(this,function(){return Jt(l[0][0],l[l.length-1][1],!r,!o)});return e._ondirectionchange=function(e){f="next"===e?(v=p,u):(v=y,n),l.sort(h)},e._addAlgorithm(function(e,t,n){for(var r,o=e.key;v(o);)if(++d===l.length)return t(n),!1;return!p(r=o)&&!y(r)||(0===i._cmp(o,l[d][1])||0===i._cmp(o,l[d][0])||t(function(){f===u?e.continue(l[d][0]):e.continue(l[d][1])}),!1)}),e},en.prototype.startsWithAnyOf=function(){var e=R.apply(T,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Qt(this):this.inAnyRange(e.map(function(e){return[e,e+pt]})):Ht(this,"startsWithAnyOf() only works with strings")},en);function en(){}function tn(t){return Ye(function(e){return nn(e),t(e.target.error),!1})}function nn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var rn="storagemutated",on="x-storagemutated-1",an=jt(null,rn),un=(sn.prototype._lock=function(){return _(!Ae.global),++this._reculock,1!==this._reculock||Ae.global||(Ae.lockOwnerFor=this),this},sn.prototype._unlock=function(){if(_(!Ae.global),0==--this._reculock)for(Ae.global||(Ae.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{at(e[1],e[0])}catch(e){}}return this},sn.prototype._locked=function(){return this._reculock&&Ae.lockOwnerFor!==this},sn.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(_(!this.idbtrans),!t&&!e)switch(r&&r.name){case"DatabaseClosedError":throw new Z.DatabaseClosed(r);case"MissingAPIError":throw new Z.MissingAPI(r.message,r);default:throw new Z.OpenFailed(r)}if(!this.active)throw new Z.TransactionInactive;return _(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||e).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Ye(function(e){nn(e),n._reject(t.error)}),t.onabort=Ye(function(e){nn(e),n.active&&n._reject(new Z.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=Ye(function(){n.active=!1,n._resolve(),"mutatedParts"in t&&an.storagemutated.fire(t.mutatedParts)}),this},sn.prototype._promise=function(n,r,o){var i=this;if("readwrite"===n&&"readwrite"!==this.mode)return ht(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return ht(new Z.TransactionInactive);if(this._locked())return new Ie(function(e,t){i._blockedFuncs.push([function(){i._promise(n,r,o).then(e,t)},Ae])});if(o)return Ze(function(){var e=new Ie(function(e,t){i._lock();var n=r(e,t,i);n&&n.then&&n.then(e,t)});return e.finally(function(){return i._unlock()}),e._lib=!0,e});var e=new Ie(function(e,t){var n=r(e,t,i);n&&n.then&&n.then(e,t)});return e._lib=!0,e},sn.prototype._root=function(){return this.parent?this.parent._root():this},sn.prototype.waitFor=function(e){var t,r=this._root(),o=Ie.resolve(e);r._waitingFor?r._waitingFor=r._waitingFor.then(function(){return o}):(r._waitingFor=o,r._waitingQueue=[],t=r.idbtrans.objectStore(r.storeNames[0]),function e(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(t.get(-1/0).onsuccess=e)}());var i=r._waitingFor;return new Ie(function(t,n){o.then(function(e){return r._waitingQueue.push(Ye(t.bind(null,e)))},function(e){return r._waitingQueue.push(Ye(n.bind(null,e)))}).finally(function(){r._waitingFor===i&&(r._waitingFor=null)})})},sn.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new Z.Abort))},sn.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(m(t,e))return t[e];var n=this.schema[e];if(!n)throw new Z.NotFound("Table "+e+" not part of transaction");n=new this.db.Table(e,n,this);return n.core=this.db.core.table(e),t[e]=n},sn);function sn(){}function cn(e,t,n,r,o,i,a){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+ln(t)}}function ln(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function fn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:k(n,function(e){return[e.name,e]})}}var hn=function(e){try{return e.only([[]]),hn=function(){return[[]]},[[]]}catch(e){return hn=function(){return pt},pt}};function dn(t){return null==t?function(){}:"string"==typeof t?1===(n=t).split(".").length?function(e){return e[n]}:function(e){return E(e,n)}:function(e){return E(e,t)};var n}function pn(e){return[].slice.call(e)}var yn=0;function vn(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function mn(e,o,t){function w(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,n=e.upper,r=e.lowerOpen,e=e.upperOpen;return void 0===t?void 0===n?null:o.upperBound(n,!!e):void 0===n?o.lowerBound(t,!!r):o.bound(t,n,!!r,!!e)}function n(e){var h,_=e.name;return{name:_,schema:e,mutate:function(e){var y=e.trans,v=e.type,m=e.keys,g=e.values,b=e.range;return new Promise(function(t,e){t=Ye(t);var n=y.objectStore(_),r=null==n.keyPath,o="put"===v||"add"===v;if(!o&&"delete"!==v&&"deleteRange"!==v)throw new Error("Invalid operation type: "+v);var i,a=(m||g||{length:1}).length;if(m&&g&&m.length!==g.length)throw new Error("Given keys array must have same length as given values array.");if(0===a)return t({numFailures:0,failures:{},results:[],lastResult:void 0});function u(e){++l,nn(e)}var s=[],c=[],l=0;if("deleteRange"===v){if(4===b.type)return t({numFailures:l,failures:c,results:[],lastResult:void 0});3===b.type?s.push(i=n.clear()):s.push(i=n.delete(w(b)))}else{var r=o?r?[g,m]:[g,null]:[m,null],f=r[0],h=r[1];if(o)for(var d=0;d<a;++d)s.push(i=h&&void 0!==h[d]?n[v](f[d],h[d]):n[v](f[d])),i.onerror=u;else for(d=0;d<a;++d)s.push(i=n[v](f[d])),i.onerror=u}function p(e){e=e.target.result,s.forEach(function(e,t){return null!=e.error&&(c[t]=e.error)}),t({numFailures:l,failures:c,results:"delete"===v?m:s.map(function(e){return e.result}),lastResult:e})}i.onerror=function(e){u(e),p(e)},i.onsuccess=p})},getMany:function(e){var f=e.trans,h=e.keys;return new Promise(function(t,e){t=Ye(t);for(var n,r=f.objectStore(_),o=h.length,i=new Array(o),a=0,u=0,s=function(e){e=e.target;i[e._pos]=e.result,++u===a&&t(i)},c=tn(e),l=0;l<o;++l)null!=h[l]&&((n=r.get(h[l]))._pos=l,n.onsuccess=s,n.onerror=c,++a);0===a&&t(i)})},get:function(e){var r=e.trans,o=e.key;return new Promise(function(t,e){t=Ye(t);var n=r.objectStore(_).get(o);n.onsuccess=function(e){return t(e.target.result)},n.onerror=tn(e)})},query:(h=s,function(f){return new Promise(function(n,e){n=Ye(n);var r,o,i,t=f.trans,a=f.values,u=f.limit,s=f.query,c=u===1/0?void 0:u,l=s.index,s=s.range,t=t.objectStore(_),l=l.isPrimaryKey?t:t.index(l.name),s=w(s);if(0===u)return n({result:[]});h?((c=a?l.getAll(s,c):l.getAllKeys(s,c)).onsuccess=function(e){return n({result:e.target.result})},c.onerror=tn(e)):(r=0,o=!a&&"openKeyCursor"in l?l.openKeyCursor(s):l.openCursor(s),i=[],o.onsuccess=function(e){var t=o.result;return t?(i.push(a?t.value:t.primaryKey),++r===u?n({result:i}):void t.continue()):n({result:i})},o.onerror=tn(e))})}),openCursor:function(e){var c=e.trans,i=e.values,a=e.query,u=e.reverse,l=e.unique;return new Promise(function(t,n){t=Ye(t);var e=a.index,r=a.range,o=c.objectStore(_),o=e.isPrimaryKey?o:o.index(e.name),e=u?l?"prevunique":"prev":l?"nextunique":"next",s=!i&&"openKeyCursor"in o?o.openKeyCursor(w(r),e):o.openCursor(w(r),e);s.onerror=tn(n),s.onsuccess=Ye(function(e){var r,o,i,a,u=s.result;u?(u.___id=++yn,u.done=!1,r=u.continue.bind(u),o=(o=u.continuePrimaryKey)&&o.bind(u),i=u.advance.bind(u),a=function(){throw new Error("Cursor not stopped")},u.trans=c,u.stop=u.continue=u.continuePrimaryKey=u.advance=function(){throw new Error("Cursor not started")},u.fail=Ye(n),u.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},u.start=function(e){function t(){if(s.result)try{e()}catch(e){u.fail(e)}else u.done=!0,u.start=function(){throw new Error("Cursor behind last entry")},u.stop()}var n=new Promise(function(t,e){t=Ye(t),s.onerror=tn(e),u.fail=e,u.stop=function(e){u.stop=u.continue=u.continuePrimaryKey=u.advance=a,t(e)}});return s.onsuccess=Ye(function(e){s.onsuccess=t,t()}),u.continue=r,u.continuePrimaryKey=o,u.advance=i,t(),n},t(u)):t(null)},n)})},count:function(e){var t=e.query,o=e.trans,i=t.index,a=t.range;return new Promise(function(t,e){var n=o.objectStore(_),r=i.isPrimaryKey?n:n.index(i.name),n=w(a),r=n?r.count(n):r.count();r.onsuccess=Ye(function(e){return t(e.target.result)}),r.onerror=tn(e)})}}}var r,i,a,u=(i=t,a=pn((r=e).objectStoreNames),{schema:{name:r.name,tables:a.map(function(e){return i.objectStore(e)}).map(function(t){var e=t.keyPath,n=t.autoIncrement,r=b(e),o={},n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:dn(e)},indexes:pn(t.indexNames).map(function(e){return t.index(e)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,e=e.keyPath,r={name:t,compound:b(e),keyPath:e,unique:n,multiEntry:r,extractKey:dn(e)};return o[vn(e)]=r}),getIndexByKeyPath:function(e){return o[vn(e)]}};return o[":id"]=n.primaryKey,null!=e&&(o[vn(e)]=n.primaryKey),n})},hasGetAll:0<a.length&&"getAll"in i.objectStore(a[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),t=u.schema,s=u.hasGetAll,u=t.tables.map(n),c={};return u.forEach(function(e){return c[e.name]=e}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!c[e])throw new Error("Table '".concat(e,"' not found"));return c[e]},MIN_KEY:-1/0,MAX_KEY:hn(o),schema:t}}function gn(e,t,n,r){var o=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=mn(t,o,r),e.dbcore.reduce(function(e,t){t=t.create;return g(g({},e),t(e))},r))}}function bn(e,t){var n=e._novip,e=t.db,t=gn(n._middlewares,e,n._deps,t);n.core=t.dbcore,n.tables.forEach(function(e){var t=e.name;n.core.schema.tables.some(function(e){return e.name===t})&&(e.core=n.core.table(t),n[t]instanceof n.Table&&(n[t].core=n.vip[t].core=e.core))})}function _n(e,t,o){t.forEach(function(n){var r=o[n];e.forEach(function(e){var t=d(e,n);(!t||"value"in t&&(void 0===t.value||t.value instanceof St))&&(e instanceof un?a(e,n,{get:function(){return this.table(n)},set:function(e){i(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):e instanceof Jn&&(e._allTables[n]=e[n]=new e.Table(n,r)))})})}function wn(e){e.forEach(function(e){(e instanceof Jn?[e,e._allTables]:[e]).forEach(function(e){for(var t in e)e[t]instanceof St&&delete e[t]})})}function xn(e,t){return e._cfg.version-t._cfg.version}function kn(n,r,o,e){var i=n._dbSchema,a=n._createTransaction("readwrite",n._storeNames,i);a.create(o),a._completion.catch(e);var u=a._reject.bind(a),p=Ae.transless||Ae;Ze(function(){var e,s,c,l,f,t,h,d;Ae.trans=a,Ae.transless=p,0===r?(x(i).forEach(function(e){Pn(o,e,i[e].primKey,i[e].indexes)}),bn(n,o),Ie.follow(function(){return n.on.populate.fire(a)}).catch(u)):(s=r,c=a,l=o,f=(e=n)._novip,t=[],e=f._versions,h=f._dbSchema=Kn(0,f.idbdb,l),d=!1,e.filter(function(e){return e._cfg.version>=s}).forEach(function(u){t.push(function(){var t=h,e=u._cfg.dbschema;Sn(f,t,l),Sn(f,e,l),h=f._dbSchema=e;var n=En(t,e);n.add.forEach(function(e){Pn(l,e[0],e[1].primKey,e[1].indexes)}),n.change.forEach(function(e){if(e.recreate)throw new Z.Upgrade("Not yet support for changing primary key");var t=l.objectStore(e.name);e.add.forEach(function(e){return On(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),On(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var r=u._cfg.contentUpgrade;if(r&&u._cfg.version>s){bn(f,l),c._memoizedTables={},d=!0;var o=O(e);n.del.forEach(function(e){o[e]=t[e]}),wn([f.Transaction.prototype]),_n([f.Transaction.prototype],x(o),o),c.schema=o;var i,a=F(r);a&&et();n=Ie.follow(function(){var e;(i=r(c))&&a&&(e=tt.bind(null,null),i.then(e,e))});return i&&"function"==typeof i.then?Ie.resolve(i):n.then(function(){return i})}}),t.push(function(e){var t,n,r;d&&bt||(t=u._cfg.dbschema,n=t,r=e,[].slice.call(r.db.objectStoreNames).forEach(function(e){return null==n[e]&&r.db.deleteObjectStore(e)})),wn([f.Transaction.prototype]),_n([f.Transaction.prototype],f._storeNames,f._dbSchema),c.schema=f._dbSchema})}),function e(){return t.length?Ie.resolve(t.shift()(c.idbtrans)).then(e):Ie.resolve()}().then(function(){var t,n;n=l,x(t=h).forEach(function(e){n.db.objectStoreNames.contains(e)||Pn(n,e,t[e].primKey,t[e].indexes)})}).catch(u))})}function En(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var o=e[n],i=t[n];if(o){var a={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||o.primKey.auto!==i.primKey.auto&&!gt)a.recreate=!0,r.change.push(a);else{var u=o.idxByName,s=i.idxByName,c=void 0;for(c in u)s[c]||a.del.push(c);for(c in s){var l=u[c],f=s[c];l?l.src!==f.src&&a.change.push(f):a.add.push(f)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,i])}return r}function Pn(e,t,n,r){var o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(e){return On(o,e)}),o}function On(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function Kn(e,t,u){var s={};return y(t.objectStoreNames,0).forEach(function(e){for(var t=u.objectStore(e),n=cn(ln(a=t.keyPath),a||"",!1,!1,!!t.autoIncrement,a&&"string"!=typeof a,!0),r=[],o=0;o<t.indexNames.length;++o){var i=t.index(t.indexNames[o]),a=i.keyPath,i=cn(i.name,a,!!i.unique,!!i.multiEntry,!1,a&&"string"!=typeof a,!1);r.push(i)}s[e]=fn(e,n,r)}),s}function Sn(e,t,n){for(var r=e._novip,o=n.db.objectStoreNames,i=0;i<o.length;++i){var a=o[i],u=n.objectStore(a);r._hasGetAll="getAll"in u;for(var s=0;s<u.indexNames.length;++s){var c=u.indexNames[s],l=u.index(c).keyPath,f="string"==typeof l?l:"["+y(l).join("+")+"]";!t[a]||(l=t[a].idxByName[f])&&(l.name=c,delete t[a].idxByName[f],t[a].idxByName[c]=l)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&h.WorkerGlobalScope&&h instanceof h.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(r._hasGetAll=!1)}var An=(jn.prototype._parseStoresSpec=function(r,o){x(r).forEach(function(e){if(null!==r[e]){var t=r[e].split(",").map(function(e,t){var n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return cn(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),b(r),0===t)}),n=t.shift();if(n.multi)throw new Z.Schema("Primary key cannot be multi-valued");t.forEach(function(e){if(e.auto)throw new Z.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new Z.Schema("Index must have a name and cannot be an empty string")}),o[e]=fn(e,n,t)}})},jn.prototype.stores=function(e){var t=this.db._novip;this._cfg.storesSource=this._cfg.storesSource?u(this._cfg.storesSource,e):e;var e=t._versions,n={},r={};return e.forEach(function(e){u(n,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(n,r)}),t._dbSchema=r,wn([t,t.vip,t.Transaction.prototype]),_n([t,t.vip,t.Transaction.prototype],x(r),r),t._storeNames=x(r),this},jn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=ce(this._cfg.contentUpgrade||te,e),this},jn);function jn(){}function Cn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Jn(wt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Dn(e){return e&&"function"==typeof e.databases}function In(e){return Ze(function(){return Ae.letThrough=!0,e()})}function Bn(f){var h=f._state,r=f._deps.indexedDB;if(h.isBeingOpened||f.idbdb)return h.dbReadyPromise.then(function(){return h.dbOpenError?ht(h.dbOpenError):f});M&&(h.openCanceller._stackHolder=L()),h.isBeingOpened=!0,h.dbOpenError=null,h.openComplete=!1;var t=h.openCanceller;function e(){if(h.openCanceller!==t)throw new Z.DatabaseClosed("db.open() was cancelled")}var n,o=h.dbReadyResolve,d=null,p=!1;return Ie.race([t,("undefined"==typeof navigator?Ie.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(function(){return new Ie(function(s,n){if(e(),!r)throw new Z.MissingAPI;var c=f.name,l=h.autoSchema?r.open(c):r.open(c,Math.round(10*f.verno));if(!l)throw new Z.MissingAPI;l.onerror=tn(n),l.onblocked=Ye(f._fireOnBlocked),l.onupgradeneeded=Ye(function(e){var t;d=l.transaction,h.autoSchema&&!f._options.allowEmptyDB?(l.onerror=nn,d.abort(),l.result.close(),(t=r.deleteDatabase(c)).onsuccess=t.onerror=Ye(function(){n(new Z.NoSuchDatabase("Database ".concat(c," doesnt exist")))})):(d.onerror=tn(n),e=e.oldVersion>Math.pow(2,62)?0:e.oldVersion,p=e<1,f._novip.idbdb=l.result,kn(f,e/10,d,n))},n),l.onsuccess=Ye(function(){d=null;var e,t,n,r,o,i=f._novip.idbdb=l.result,a=y(i.objectStoreNames);if(0<a.length)try{var u=i.transaction(1===(r=a).length?r[0]:r,"readonly");h.autoSchema?(t=i,n=u,(e=(e=f)._novip).verno=t.version/10,n=e._dbSchema=Kn(0,t,n),e._storeNames=y(t.objectStoreNames,0),_n([e,e.vip],x(n),n)):(Sn(f,f._dbSchema,u),((o=En(Kn(0,(o=f).idbdb,u),o._dbSchema)).add.length||o.change.some(function(e){return e.add.length||e.change.length}))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),bn(f,u)}catch(e){}mt.push(f),i.onversionchange=Ye(function(e){h.vcFired=!0,f.on("versionchange").fire(e)}),i.onclose=Ye(function(e){f.on("close").fire(e)}),p&&(o=f._deps,u=c,i=o.indexedDB,o=o.IDBKeyRange,Dn(i)||u===wt||Cn(i,o).put({name:u}).catch(te)),s()},n)})})]).then(function(){return e(),h.onReadyBeingFired=[],Ie.resolve(In(function(){return f.on.ready.fire(f.vip)})).then(function e(){if(0<h.onReadyBeingFired.length){var t=h.onReadyBeingFired.reduce(ce,te);return h.onReadyBeingFired=[],Ie.resolve(In(function(){return t(f.vip)})).then(e)}})}).finally(function(){h.onReadyBeingFired=null,h.isBeingOpened=!1}).then(function(){return f}).catch(function(e){h.dbOpenError=e;try{d&&d.abort()}catch(e){}return t===h.openCanceller&&f._close(),ht(e)}).finally(function(){h.openComplete=!0,o()})}function Tn(t){function e(e){return t.next(e)}var r=n(e),o=n(function(e){return t.throw(e)});function n(n){return function(e){var t=n(e),e=t.value;return t.done?e:e&&"function"==typeof e.then?e.then(r,o):b(e)?Promise.all(e).then(r,o):r(e)}}return n(e)()}function Rn(e,t,n){for(var r=b(e)?e.slice():[e],o=0;o<n;++o)r.push(t);return r}var Fn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(f){return g(g({},f),{table:function(e){var a=f.table(e),t=a.schema,u={},s=[];function c(e,t,n){var r=vn(e),o=u[r]=u[r]||[],i=null==e?0:"string"==typeof e?1:e.length,r=0<t,r=g(g({},n),{isVirtual:r,keyTail:t,keyLength:i,extractKey:dn(e),unique:!r&&n.unique});return o.push(r),r.isPrimaryKey||s.push(r),1<i&&c(2===i?e[0]:e.slice(0,i-1),t+1,n),o.sort(function(e,t){return e.keyTail-t.keyTail}),r}e=c(t.primaryKey.keyPath,0,t.primaryKey);u[":id"]=[e];for(var n=0,r=t.indexes;n<r.length;n++){var o=r[n];c(o.keyPath,0,o)}function l(e){var t,n=e.query.index;return n.isVirtual?g(g({},e),{query:{index:n,range:(t=e.query.range,n=n.keyTail,{type:1===t.type?2:t.type,lower:Rn(t.lower,t.lowerOpen?f.MAX_KEY:f.MIN_KEY,n),lowerOpen:!0,upper:Rn(t.upper,t.upperOpen?f.MIN_KEY:f.MAX_KEY,n),upperOpen:!0})}}):e}return g(g({},a),{schema:g(g({},t),{primaryKey:e,indexes:s,getIndexByKeyPath:function(e){return(e=u[vn(e)])&&e[0]}}),count:function(e){return a.count(l(e))},query:function(e){return a.query(l(e))},openCursor:function(t){var e=t.query.index,r=e.keyTail,n=e.isVirtual,o=e.keyLength;return n?a.openCursor(l(t)).then(function(e){return e&&i(e)}):a.openCursor(t);function i(n){return Object.create(n,{continue:{value:function(e){null!=e?n.continue(Rn(e,t.reverse?f.MAX_KEY:f.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,o).concat(t.reverse?f.MIN_KEY:f.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value:function(e,t){n.continuePrimaryKey(Rn(e,f.MAX_KEY,r),t)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:function(){return n.value}}})}}})}})}};function Mn(o,i,a,u){return a=a||{},u=u||"",x(o).forEach(function(e){var t,n,r;m(i,e)?(t=o[e],n=i[e],"object"==typeof t&&"object"==typeof n&&t&&n?(r=D(t))!==D(n)?a[u+e]=i[e]:"Object"===r?Mn(t,n,a,u+e+"."):t!==n&&(a[u+e]=i[e]):t!==n&&(a[u+e]=i[e])):a[u+e]=void 0}),x(i).forEach(function(e){m(o,e)||(a[u+e]=i[e])}),a}var Nn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return g(g({},e),{table:function(r){var y=e.table(r),v=y.schema.primaryKey;return g(g({},y),{mutate:function(e){var t=Ae.trans,n=t.table(r).hook,h=n.deleting,d=n.creating,p=n.updating;switch(e.type){case"add":if(d.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"put":if(d.fire===te&&p.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"delete":if(h.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"deleteRange":if(h.fire===te)break;return t._promise("readwrite",function(){return function n(r,o,i){return y.query({trans:r,values:!1,query:{index:v,range:o},limit:i}).then(function(e){var t=e.result;return a({type:"delete",keys:t,trans:r}).then(function(e){return 0<e.numFailures?Promise.reject(e.failures[0]):t.length<i?{failures:[],numFailures:0,lastResult:void 0}:n(r,g(g({},o),{lower:t[t.length-1],lowerOpen:!0}),i)})})}(e.trans,e.range,1e4)},!0)}return y.mutate(e);function a(c){var e,t,n,l=Ae.trans,f=c.keys||(t=v,"delete"===(n=c).type?n.keys:n.keys||n.values.map(t.extractKey));if(!f)throw new Error("Keys missing");return"delete"!==(c="add"===c.type||"put"===c.type?g(g({},c),{keys:f}):g({},c)).type&&(c.values=o([],c.values,!0)),c.keys&&(c.keys=o([],c.keys,!0)),e=y,n=f,("add"===(t=c).type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})).then(function(u){var s=f.map(function(e,t){var n,r,o,i=u[t],a={onerror:null,onsuccess:null};return"delete"===c.type?h.fire.call(a,e,i,l):"add"===c.type||void 0===i?(n=d.fire.call(a,e,c.values[t],l),null==e&&null!=n&&(c.keys[t]=e=n,v.outbound||P(c.values[t],v.keyPath,e))):(n=Mn(i,c.values[t]),(r=p.fire.call(a,n,e,i,l))&&(o=c.values[t],Object.keys(r).forEach(function(e){m(o,e)?o[e]=r[e]:P(o,e,r[e])}))),a});return y.mutate(c).then(function(e){for(var t=e.failures,n=e.results,r=e.numFailures,e=e.lastResult,o=0;o<f.length;++o){var i=(n||f)[o],a=s[o];null==i?a.onerror&&a.onerror(t[o]):a.onsuccess&&a.onsuccess("put"===c.type&&u[o]?c.values[o]:i)}return{failures:t,results:n,numFailures:r,lastResult:e}}).catch(function(t){return s.forEach(function(e){return e.onerror&&e.onerror(t)}),Promise.reject(t)})})}}})}})}};function qn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;for(var r=[],o=0,i=0;o<t.keys.length&&i<e.length;++o)0===qt(t.keys[o],e[i])&&(r.push(n?j(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}var Un={stack:"dbcore",level:-1,create:function(t){return{table:function(e){var n=t.table(e);return g(g({},n),{getMany:function(t){if(!t.cache)return n.getMany(t);var e=qn(t.keys,t.trans._cache,"clone"===t.cache);return e?Ie.resolve(e):n.getMany(t).then(function(e){return t.trans._cache={keys:t.keys,values:"clone"===t.cache?j(e):e},e})},mutate:function(e){return"add"!==e.type&&(e.trans._cache=null),n.mutate(e)}})}}}};function Ln(e){return!("from"in e)}var Vn=function(e,t){if(!this){var n=new Vn;return e&&"d"in e&&u(n,e),n}u(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function Wn(e,t,n){var r=qt(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(Ln(e))return u(e,{from:t,to:n,d:1});var o=e.l,r=e.r;if(qt(n,e.from)<0)return o?Wn(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Hn(e);if(0<qt(t,e.to))return r?Wn(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Hn(e);qt(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<qt(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);n=!e.r;o&&!e.l&&zn(e,o),r&&n&&zn(e,r)}}function zn(e,t){Ln(t)||function e(t,n){var r=n.from,o=n.to,i=n.l,n=n.r;Wn(t,r,o),i&&e(t,i),n&&e(t,n)}(e,t)}function Yn(e,t){var n=Gn(t),r=n.next();if(r.done)return!1;for(var o=r.value,i=Gn(e),a=i.next(o.from),u=a.value;!r.done&&!a.done;){if(qt(u.from,o.to)<=0&&0<=qt(u.to,o.from))return!0;qt(o.from,u.from)<0?o=(r=n.next(u.from)).value:u=(a=i.next(o.from)).value}return!1}function Gn(e){var n=Ln(e)?null:{s:0,n:e};return{next:function(e){for(var t=0<arguments.length;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&qt(e,n.n.from)<0;)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||qt(e,n.n.to)<=0)return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function Hn(e){var t,n,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),o=1<r?"r":r<-1?"l":"";o&&(t="r"==o?"l":"r",n=g({},e),r=e[o],e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],(e[t]=n).d=Qn(n)),e.d=Qn(e)}function Qn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}r(Vn.prototype,((W={add:function(e){return zn(this,e),this},addKey:function(e){return Wn(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return Wn(t,e,e)}),this}})[I]=function(){return Gn(this)},W));var Xn={stack:"dbcore",level:0,create:function(r){var v=r.schema.name,m=new Vn(r.MIN_KEY,r.MAX_KEY);return g(g({},r),{table:function(d){function e(e){var e=(t=e.query).index,t=t.range;return[e,new Vn(null!==(e=t.lower)&&void 0!==e?e:r.MIN_KEY,null!==(t=t.upper)&&void 0!==t?t:r.MAX_KEY)]}var p=r.table(d),y=p.schema,t=y.primaryKey,c=t.extractKey,l=t.outbound,n=g(g({},p),{mutate:function(e){function n(e){return e="idb://".concat(v,"/").concat(d,"/").concat(e),r[e]||(r[e]=new Vn)}var t=e.trans,r=t.mutatedParts||(t.mutatedParts={}),o=n(""),s=n(":dels"),c=e.type,t="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],l=t[0],f=t[1],h=e.trans._cache;return p.mutate(e).then(function(e){var t,i,a,u;return b(l)?("delete"!==c&&(l=e.results),o.addKeys(l),(t=qn(l,h))||"add"===c||s.addKeys(l),(t||f)&&(i=n,a=t,u=f,y.indexes.forEach(function(t){var n=i(t.name||"");function r(e){return null!=e?t.extractKey(e):null}function o(e){return t.multiEntry&&b(e)?e.forEach(function(e){return n.addKey(e)}):n.addKey(e)}(a||u).forEach(function(e,t){var n=a&&r(a[t]),t=u&&r(u[t]);0!==qt(n,t)&&(null!=n&&o(n),null!=t&&o(t))})}))):l?(t={from:l.lower,to:l.upper},s.add(t),o.add(t)):(o.add(m),s.add(m),y.indexes.forEach(function(e){return n(e.name).add(m)})),e})}}),f={get:function(e){return[t,new Vn(e.key)]},getMany:function(e){return[t,(new Vn).addKeys(e.keys)]},count:e,query:e,openCursor:e};return x(f).forEach(function(s){n[s]=function(o){var t=Ae.subscr;if(t){var e=function(e){e="idb://".concat(v,"/").concat(d,"/").concat(e);return t[e]||(t[e]=new Vn)},i=e(""),a=e(":dels"),n=f[s](o),r=n[0],n=n[1];if(e(r.name||"").add(n),!r.isPrimaryKey){if("count"!==s){var u="query"===s&&l&&o.values&&p.query(g(g({},o),{values:!1}));return p[s].apply(this,arguments).then(function(t){if("query"===s){if(l&&o.values)return u.then(function(e){e=e.result;return i.addKeys(e),t});var e=o.values?t.result.map(c):t.result;(o.values?i:a).addKeys(e)}else if("openCursor"===s){var n=t,r=o.values;return n&&Object.create(n,{key:{get:function(){return a.addKey(n.primaryKey),n.key}},primaryKey:{get:function(){var e=n.primaryKey;return a.addKey(e),e}},value:{get:function(){return r&&i.addKey(n.primaryKey),n.value}}})}return t})}a.add(m)}}return p[s].apply(this,arguments)}}),n}})}};var Jn=($n.prototype.version=function(t){if(isNaN(t)||t<.1)throw new Z.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new Z.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);var e=this._versions,n=e.filter(function(e){return e._cfg.version===t})[0];return n||(n=new this.Version(t),e.push(n),e.sort(xn),n.stores({}),this._state.autoSchema=!1,n)},$n.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||Ae.letThrough||this._vip)?e():new Ie(function(e,t){if(n._state.openComplete)return t(new Z.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return void t(new Z.DatabaseClosed);n.open().catch(te)}n._state.dbReadyPromise.then(e,t)}).then(e)},$n.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,o=e.name;o&&this.unuse({stack:t,name:o});e=this._middlewares[t]||(this._middlewares[t]=[]);return e.push({stack:t,create:n,level:null==r?10:r,name:o}),e.sort(function(e,t){return e.level-t.level}),this},$n.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(e){return r?e.create!==r:!!n&&e.name!==n})),this},$n.prototype.open=function(){return Bn(this)},$n.prototype._close=function(){var n=this._state,e=mt.indexOf(this);if(0<=e&&mt.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}n.dbReadyPromise=new Ie(function(e){n.dbReadyResolve=e}),n.openCanceller=new Ie(function(e,t){n.cancelOpen=t})},$n.prototype.close=function(){this._close();var e=this._state;this._options.autoOpen=!1,e.dbOpenError=new Z.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)},$n.prototype.delete=function(){var o=this,n=0<arguments.length,i=this._state;return new Ie(function(r,t){function e(){o.close();var e=o._deps.indexedDB.deleteDatabase(o.name);e.onsuccess=Ye(function(){var e,t,n;e=o._deps,t=o.name,n=e.indexedDB,e=e.IDBKeyRange,Dn(n)||t===wt||Cn(n,e).delete(t).catch(te),r()}),e.onerror=tn(t),e.onblocked=o._fireOnBlocked}if(n)throw new Z.InvalidArgument("Arguments not allowed in db.delete()");i.isBeingOpened?i.dbReadyPromise.then(e):e()})},$n.prototype.backendDB=function(){return this.idbdb},$n.prototype.isOpen=function(){return null!==this.idbdb},$n.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},$n.prototype.hasFailed=function(){return null!==this._state.dbOpenError},$n.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty($n.prototype,"tables",{get:function(){var t=this;return x(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),$n.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new Z.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,K(o),n]}.apply(this,arguments);return this._transaction.apply(this,e)},$n.prototype._transaction=function(e,t,n){var r=this,o=Ae.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);var i,a,u=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=t.map(function(e){e=e instanceof r.Table?e.name:e;if("string"!=typeof e)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e}),"r"==e||e===xt)i=xt;else{if("rw"!=e&&e!=kt)throw new Z.InvalidArgument("Invalid transaction mode: "+e);i=kt}if(o){if(o.mode===xt&&i===kt){if(!u)throw new Z.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(function(e){if(o&&-1===o.storeNames.indexOf(e)){if(!u)throw new Z.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),u&&o&&!o.active&&(o=null)}}catch(n){return o?o._promise(null,function(e,t){t(n)}):ht(n)}var s=function o(i,a,u,s,c){return Ie.resolve().then(function(){var e=Ae.transless||Ae,t=i._createTransaction(a,u,i._dbSchema,s),e={trans:t,transless:e};if(s)t.idbtrans=s.idbtrans;else try{t.create(),i._state.PR1398_maxLoop=3}catch(e){return e.name===J.InvalidState&&i.isOpen()&&0<--i._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),i._close(),i.open().then(function(){return o(i,a,u,null,c)})):ht(e)}var n,r=F(c);return r&&et(),e=Ie.follow(function(){var e;(n=c.call(t,t))&&(r?(e=tt.bind(null,null),n.then(e,e)):"function"==typeof n.next&&"function"==typeof n.throw&&(n=Tn(n)))},e),(n&&"function"==typeof n.then?Ie.resolve(n).then(function(e){return t.active?e:ht(new Z.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):e.then(function(){return n})).then(function(e){return s&&t._resolve(),t._completion.then(function(){return e})}).catch(function(e){return t._reject(e),ht(e)})})}.bind(null,this,i,a,o,n);return o?o._promise(i,s,"lock"):Ae.trans?at(Ae.transless,function(){return r._whenReady(s)}):this._whenReady(s)},$n.prototype.table=function(e){if(!m(this._allTables,e))throw new Z.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},$n);function $n(e,t){var i=this;this._middlewares={},this.verno=0;var n=$n.dependencies;this._options=t=g({addons:$n.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};n=t.addons;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var a,u,r,o,s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:te,dbReadyPromise:null,cancelOpen:te,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};s.dbReadyPromise=new Ie(function(e){s.dbReadyResolve=e}),s.openCanceller=new Ie(function(e,t){s.cancelOpen=t}),this._state=s,this.name=e,this.on=jt(this,"populate","blocked","versionchange","close",{ready:[ce,te]}),this.on.ready.subscribe=v(this.on.ready.subscribe,function(o){return function(n,r){$n.vip(function(){var t,e=i._state;e.openComplete?(e.dbOpenError||Ie.resolve().then(n),r&&o(n)):e.onReadyBeingFired?(e.onReadyBeingFired.push(n),r&&o(n)):(o(n),t=i,r||o(function e(){t.on.ready.unsubscribe(n),t.on.ready.unsubscribe(e)}))})}}),this.Collection=(a=this,Ct(Vt.prototype,function(e,t){this.db=a;var n=Pt,r=null;if(t)try{n=t()}catch(e){r=e}var o=e._ctx,t=o.table,e=t.hook.reading.fire;this._ctx={table:t,index:o.index,isPrimKey:!o.index||t.schema.primKey.keyPath&&o.index===t.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:o.or,valueMapper:e!==ne?e:null}})),this.Table=Dt(this),this.Transaction=(u=this,Ct(un.prototype,function(e,t,n,r,o){var i=this;this.db=u,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=jt(this,"complete","error","abort"),this.parent=o||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 Ie(function(e,t){i._resolve=e,i._reject=t}),this._completion.then(function(){i.active=!1,i.on.complete.fire()},function(e){var t=i.active;return i.active=!1,i.on.error.fire(e),i.parent?i.parent._reject(e):t&&i.idbtrans&&i.idbtrans.abort(),ht(e)})})),this.Version=(r=this,Ct(An.prototype,function(e){this.db=r,this._cfg={version:e,storesSource:null,dbschema:{},contentUpgrade:null}})),this.WhereClause=(o=this,Ct(Zt.prototype,function(e,t,n){this.db=o,this._ctx={table:e,index:":id"===t?null:t,or:n};var r=o._deps.indexedDB;if(!r)throw new Z.MissingAPI;this._cmp=this._ascending=r.cmp.bind(r),this._descending=function(e,t){return r.cmp(t,e)},this._max=function(e,t){return 0<r.cmp(e,t)?e:t},this._min=function(e,t){return r.cmp(e,t)<0?e:t},this._IDBKeyRange=o._deps.IDBKeyRange})),this.on("versionchange",function(e){0<e.newVersion?console.warn("Another connection wants to upgrade database '".concat(i.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(i.name,"'. Closing db now to resume the delete request.")),i.close()}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('".concat(i.name,"') was blocked")):console.warn("Upgrade '".concat(i.name,"' blocked by other connection holding version ").concat(e.oldVersion/10))}),this._maxKey=hn(t.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new i.Transaction(e,t,n,i._options.chromeTransactionDurability,r)},this._fireOnBlocked=function(t){i.on("blocked").fire(t),mt.filter(function(e){return e.name===i.name&&e!==i&&!e._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(Fn),this.use(Nn),this.use(Xn),this.use(Un);t=Object.create(this);t._vip=!0,t.Table=Dt(t),t._allTables={},this.vip=t,n.forEach(function(e){return e(i)})}var Zn,W="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable",er=(tr.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},tr.prototype[W]=function(){return this},tr);function tr(e){this._subscribe=e}function nr(t,n){return x(n).forEach(function(e){zn(t[e]||(t[e]=new Vn),n[e])}),t}function rr(d){return new er(function(n){var r=F(d);var o=!1,i={},a={},u={get closed(){return o},unsubscribe:function(){o=!0,an.storagemutated.unsubscribe(f)}};n.start&&n.start(u);var s=!1,c=!1;function l(){return x(a).some(function(e){return i[e]&&Yn(i[e],a[e])})}var f=function(e){nr(i,e),l()&&h()},h=function(){var t,e;s||o||(i={},e=function(e){r&&et();var t=function(){return Ze(d,{subscr:e,trans:null})},t=Ae.trans?at(Ae.transless,t):t();return r&&t.then(tt,tt),t}(t={}),c||(an(rn,f),c=!0),s=!0,Promise.resolve(e).then(function(e){s=!1,o||(l()?h():(i={},a=t,n.next&&n.next(e)))},function(e){["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||(s=!1,n.error&&n.error(e),u.unsubscribe())}))};return h(),u})}try{Zn={indexedDB:h.indexedDB||h.mozIndexedDB||h.webkitIndexedDB||h.msIndexedDB,IDBKeyRange:h.IDBKeyRange||h.webkitIDBKeyRange}}catch(e){Zn={indexedDB:null,IDBKeyRange:null}}var or=Jn;function ir(e){var t=ur;try{ur=!0,an.storagemutated.fire(e)}finally{ur=t}}r(or,g(g({},e),{delete:function(e){return new or(e,{addons:[]}).delete()},exists:function(e){return new or(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=or.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Dn(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==wt})}):Cn(n,t).toCollection().primaryKeys()).then(e)}catch(e){return ht(new Z.MissingAPI)}var t,n},defineClass:function(){return function(e){u(this,e)}},ignoreTransaction:function(e){return Ae.trans?at(Ae.transless,e):e()},vip:In,async:function(t){return function(){try{var e=Tn(t.apply(this,arguments));return e&&"function"==typeof e.then?e:Ie.resolve(e)}catch(e){return ht(e)}}},spawn:function(e,t,n){try{var r=Tn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Ie.resolve(r)}catch(e){return ht(e)}},currentTransaction:{get:function(){return Ae.trans||null}},waitFor:function(e,t){t=Ie.resolve("function"==typeof e?or.ignoreTransaction(e):e).timeout(t||6e4);return Ae.trans?Ae.trans.waitFor(t):t},Promise:Ie,debug:{get:function(){return M},set:function(e){N(e,"dexie"===e?function(){return!0}:dt)}},derive:l,extend:u,props:r,override:v,Events:jt,on:an,liveQuery:rr,extendObservabilitySet:nr,getByKeyPath:E,setByKeyPath:P,delByKeyPath:function(t,e){"string"==typeof e?P(t,e,void 0):"length"in e&&[].map.call(e,function(e){P(t,e,void 0)})},shallowClone:O,deepClone:j,getObjectDiff:Mn,cmp:qt,asap:w,minKey:-1/0,addons:[],connections:mt,errnames:J,dependencies:Zn,semVer:z,version:z.split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),or.maxKey=hn(or.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(an(rn,function(e){var t;ur||(gt?(t=document.createEvent("CustomEvent")).initCustomEvent(on,!0,!0,e):t=new CustomEvent(on,{detail:e}),ur=!0,dispatchEvent(t),ur=!1)}),addEventListener(on,function(e){e=e.detail;ur||ir(e)}));var ar,ur=!1;return"undefined"!=typeof BroadcastChannel?(ar=new BroadcastChannel(on),an(rn,function(e){ur||ar.postMessage(e)}),ar.onmessage=function(e){e.data&&ir(e.data)}):"undefined"!=typeof self&&"undefined"!=typeof navigator&&(an(rn,function(t){try{ur||("undefined"!=typeof localStorage&&localStorage.setItem(on,JSON.stringify({trig:Math.random(),changedParts:t})),"object"==typeof self.clients&&o([],self.clients.matchAll({includeUncontrolled:!0}),!0).forEach(function(e){return e.postMessage({type:on,changedParts:t})}))}catch(e){}}),addEventListener("storage",function(e){e.key!==on||(e=JSON.parse(e.newValue))&&ir(e.changedParts)}),(z=self.document&&navigator.serviceWorker)&&z.addEventListener("message",function(e){e=e.data;e&&e.type===on&&ir(e.changedParts)})),Ie.rejectionMapper=function(e,t){return!e||e instanceof G||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ee[e.name]?e:(t=new ee[e.name](t||e.message,e),"stack"in e&&a(t,"stack",{get:function(){return this.inner.stack}}),t)},N(M,dt),g(Jn,Object.freeze({__proto__:null,Dexie:Jn,liveQuery:rr,Entity:Kt,cmp:qt,default:Jn,RangeSet:Vn,mergeRanges:zn,rangesOverlap:Yn}),{default:Jn}),Jn});