dexie 4.0.1-beta.2 → 4.0.1-beta.4

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,2 +1,2 @@
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 _=function(){return(_=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 f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=Object.keys,g=Array.isArray;function u(t,n){return"object"!=typeof n||x(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||f.Promise||(f.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){l(t,e,n[e])})}var a=Object.defineProperty;function l(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),l(t.prototype,"constructor",t),{extend:r.bind(null,t.prototype)}}}}var h=Object.getOwnPropertyDescriptor;function d(e,t){return h(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 b(e){if(!e)throw new Error("Assertion Failed")}function w(e){f.setImmediate?setImmediate(e):setTimeout(e,0)}function k(e,t){if("string"==typeof t&&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 O(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){b("string"!=typeof n&&"length"in n);for(var r=0,i=t.length;r<i;++r)O(e,t[r],n[r])}else{var o,a,u=t.indexOf(".");-1!==u?(o=t.substr(0,u),""===(a=t.substr(u+1))?void 0===n?g(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n:O(u=!(u=e[o])||!m(e,o)?e[o]={}:u,a,n)):void 0===n?g(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 E(e){return t.apply([],e)}var e="Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(E([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return f[e]}),K=new Set(e.map(function(e){return f[e]}));var S=null;function j(e){S=new WeakMap;e=function e(t){if(!t||"object"!=typeof t)return t;var n=S.get(t);if(n)return n;if(g(t)){n=[],S.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(K.has(t.constructor))n=t;else{var o,a=c(t);for(o in n=a===Object.prototype?{}:Object.create(a),S.set(t,n),t)m(t,o)&&(n[o]=e(t[o]))}return n}(e);return S=null,e}var A={}.toString;function C(e){return A.call(e).slice(8,-1)}var q="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",D="symbol"==typeof q?function(e){var t;return null!=e&&(t=e[q])&&t.apply(e)}:function(){return null};function I(e,t){t=e.indexOf(t);return 0<=t&&e.splice(t,1),0<=t}var T={};function R(e){var t,n,r,i;if(1===arguments.length){if(g(e))return e.slice();if(this===T&&"string"==typeof e)return[e];if(i=D(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 B="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},L=!new Error("").stack;function U(){if(L)try{throw new Error}catch(e){return e}return new Error}function z(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),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 Q(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 X(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,this.failures)}o(Q).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+z(this._e,2))}},toString:function(){return this.name+": "+this.message}}),o(H).from(Q),o(X).from(Q);var J=W.reduce(function(e,t){return e[t]=t+"Error",e},{}),$=Q,Z=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="".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 o(t).from($),e[n]=t,e},{});Z.Syntax=SyntaxError,Z.Type=TypeError,Z.Range=RangeError;var ee=V.reduce(function(e,t){return e[t+"Error"]=Z[t],e},{});var te=W.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=Z[t]),e},{});function ne(){}function re(e){return e}function ie(t,n){return null==t||t===re?n:function(e){return n(t(e))}}function oe(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ae(i,o){return i===ne?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?oe(t,this.onsuccess):t),n&&(this.onerror=this.onerror?oe(n,this.onerror):n),void 0!==r?r:e}}function ue(n,r){return n===ne?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 se(i,o){return i===ne?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?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 ce(e,t){return e===ne?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function le(i,o){return i===ne?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)}}te.ModifyError=H,te.DexieError=Q,te.BulkError=X;var fe={},he=100,de=100,e="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]}(),V=e[0],pe=e[1],W=e[2],e=pe&&pe.then,ye=V&&V.constructor,ve=!!W,me=!1;var be=function(e,t){Ke.push([e,t]),we&&(queueMicrotask(Fe),we=!1)},ge=!0,we=!0,_e=[],xe=[],ke=null,Oe=re,Pe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ne,pgp:!1,env:{},finalize:ne},Ee=Pe,Ke=[],Se=0,je=[];function Ae(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=Ee;if(F&&(this._stackHolder=U(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==fe)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&De(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&&Me();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof Ae?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Ie(r)),e&&Ne()}},De.bind(null,r))}catch(e){De(r,e)}}(this,e)}var Ce={get:function(){var u=Ee,t=Ge;function e(n,r){var i=this,o=!u.global&&(u!==Ee||t!==Ge),a=o&&!$e(),e=new Ae(function(e,t){Te(i,new qe(it(n,u,o,a),it(r,u,o,a),e,t,u))});return F&&Be(e,this),e}return e.prototype=fe,e},set:function(e){l(this,"then",e&&e.prototype===fe?Ce:{get:function(){return e},set:Ce.set})}};function qe(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 De(t,n){var e,r;xe.push(n),null===t._state&&(e=t._lib&&Me(),n=Oe(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=d(n,"stack");n._promise=t,l(n,"stack",{get:function(){return me?e&&(e.get?e.get.apply(n):e.value):t.stack}})}),r=t,_e.some(function(e){return e._value===r._value})||_e.push(r),Ie(t),e&&Ne())}function Ie(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Te(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===Se&&(++Se,be(function(){0==--Se&&Le()},[]))}function Te(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,++Se,be(Re,[n,e,t])}else e._listeners.push(t)}function Re(e,t,n){try{var r,i=(ke=t)._value;t._state?r=e(i):(xe.length&&(xe=[]),r=e(i),-1===xe.indexOf(i)&&function(e){var t=_e.length;for(;t;)if(_e[--t]._value===e._value)return _e.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{ke=null,0==--Se&&Le(),--n.psd.ref||n.psd.finalize()}}function Be(e,t){var n=t?t._numPrev+1:0;n<he&&(e._prev=t,e._numPrev=n)}function Fe(){rt(Pe,function(){Me()&&Ne()})}function Me(){var e=ge;return we=ge=!1,e}function Ne(){var e,t,n;do{for(;0<Ke.length;)for(e=Ke,Ke=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<Ke.length);we=ge=!0}function Le(){var e=_e;_e=[],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 Ue(e){return new Ae(fe,!1,e)}function ze(n,r){var i=Ee;return function(){var e=Me(),t=Ee;try{return tt(i,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{tt(t,!1),e&&Ne()}}}r(Ae.prototype,{then:Ce,_then:function(e,t){Te(this,new qe(null,null,e,t,Ee))},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:Ue)(e)}):this.then(null,function(e){return(e&&e.name===t?n:Ue)(e)})},finally:function(t){return this.then(function(e){return Ae.resolve(t()).then(function(){return e})},function(e){return Ae.resolve(t()).then(function(){return Ue(e)})})},stack:{get:function(){if(this._stack)return this._stack;try{me=!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=z(o,0)):(a=o,u=""),n.push(a+(u?": "+u:"")+i))}F&&((i=z(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{me=!1}}},timeout:function(r,i){var o=this;return r<1/0?new Ae(function(e,t){var n=setTimeout(function(){return t(new Z.Timeout(i))},r);o.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&l(Ae.prototype,Symbol.toStringTag,"Dexie.Promise"),Pe.env=nt(),r(Ae,{all:function(){var o=R.apply(null,arguments).map(Ze);return new Ae(function(n,r){0===o.length&&n([]);var i=o.length;o.forEach(function(e,t){return Ae.resolve(e).then(function(e){o[t]=e,--i||n(o)},r)})})},resolve:function(n){if(n instanceof Ae)return n;if(n&&"function"==typeof n.then)return new Ae(function(e,t){n.then(e,t)});var e=new Ae(fe,!0,n);return Be(e,ke),e},reject:Ue,race:function(){var e=R.apply(null,arguments).map(Ze);return new Ae(function(t,n){e.map(function(e){return Ae.resolve(e).then(t,n)})})},PSD:{get:function(){return Ee},set:function(e){return Ee=e}},totalEchoes:{get:function(){return Ge}},newPSD:Xe,usePSD:rt,scheduler:{get:function(){return be},set:function(e){be=e}},rejectionMapper:{get:function(){return Oe},set:function(e){Oe=e}},follow:function(i,n){return new Ae(function(e,t){return Xe(function(n,r){var e=Ee;e.unhandleds=[],e.onunhandled=r,e.finalize=oe(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)}),++Se,be(function(){0==--Se&&Le()},[])},e.finalize),i()},n,e,t)})}}),ye&&(ye.allSettled&&l(Ae,"allSettled",function(){var e=R.apply(null,arguments).map(Ze);return new Ae(function(n){0===e.length&&n([]);var r=e.length,i=new Array(r);e.forEach(function(e,t){return Ae.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)})})})}),ye.any&&"undefined"!=typeof AggregateError&&l(Ae,"any",function(){var e=R.apply(null,arguments).map(Ze);return new Ae(function(n,r){0===e.length&&r(new AggregateError([]));var i=e.length,o=new Array(i);e.forEach(function(e,t){return Ae.resolve(e).then(function(e){return n(e)},function(e){o[t]=e,--i||r(new AggregateError(o))})})})}));var Ve={awaits:0,echoes:0,id:0},We=0,Ye=[],Qe=0,Ge=0,He=0;function Xe(e,t,n,r){var i=Ee,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++He;var a=Pe.env;o.env=ve?{Promise:Ae,PromiseProp:{value:Ae,configurable:!0,writable:!0},all:Ae.all,race:Ae.race,allSettled:Ae.allSettled,any:Ae.any,resolve:Ae.resolve,reject:Ae.reject,nthen:ot(a.nthen,o),gthen:ot(a.gthen,o)}:{},t&&u(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};r=rt(o,e,n,r);return 0===o.ref&&o.finalize(),r}function Je(){return Ve.id||(Ve.id=++We),++Ve.awaits,Ve.echoes+=de,Ve.id}function $e(){return!!Ve.awaits&&(0==--Ve.awaits&&(Ve.id=0),Ve.echoes=Ve.awaits*de,!0)}function Ze(e){return Ve.echoes&&e&&e.constructor===ye?(Je(),e.then(function(e){return $e(),e},function(e){return $e(),at(e)})):e}function et(){var e=Ye[Ye.length-1];Ye.pop(),tt(e,!1)}function tt(e,t){var n,r=Ee;(t?!Ve.echoes||Qe++&&e===Ee:!Qe||--Qe&&e===Ee)||queueMicrotask(t?function(e){++Ge,Ve.echoes&&0!=--Ve.echoes||(Ve.echoes=Ve.id=0),Ye.push(Ee),tt(e,!0)}.bind(null,e):et),e!==Ee&&(Ee=e,r===Pe&&(Pe.env=nt()),ve&&(n=Pe.env.Promise,t=e.env,pe.then=t.nthen,n.prototype.then=t.gthen,(r.global||e.global)&&(Object.defineProperty(f,"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 nt(){var e=f.Promise;return ve?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(f,"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 rt(e,t,n,r,i){var o=Ee;try{return tt(e,!0),t(n,r,i)}finally{tt(o,!1)}}function it(t,n,r,i){return"function"!=typeof t?t:function(){var e=Ee;r&&Je(),tt(n,!0);try{return t.apply(this,arguments)}finally{tt(e,!1),i&&queueMicrotask($e)}}}function ot(n,r){return function(e,t){return n.call(this,it(e,r),it(t,r))}}-1===(""+e).indexOf("[native code]")&&(Je=$e=ne);var at=Ae.reject;function ut(e){return!/(dexie\.js|dexie\.min\.js)/.test(e)}var W="4.0.1-beta.2",st=String.fromCharCode(65535),ct="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lt="String expected.",ft=[],ht="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),dt=ht,pt=ht,yt="__dbnames",vt="readonly",mt="readwrite";function bt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var gt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function wt(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 _t(){throw Z.Type()}function xt(e,t){try{var n=kt(e),r=kt(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}(Ot(e),Ot(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=xt(e[o],t[o]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function kt(e){var t=typeof e;if("object"!=t)return t;if(ArrayBuffer.isView(e))return"binary";e=C(e);return"ArrayBuffer"===e?"binary":e}function Ot(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Pt=(Et.prototype._trans=function(e,r,t){var n=this._tx||Ee.trans,i=this.name;function o(e,t,n){if(!n.schema[i])throw new Z.NotFound("Table "+i+" not part of transaction");return r(n.idbtrans,n)}var a=Me();try{return n&&n.db._novip===this.db._novip?n===Ee.trans?n._promise(e,o,t):Xe(function(){return n._promise(e,o,t)},{trans:n,transless:Ee.transless||Ee}):function t(n,r,i,o){if(n.idbdb&&(n._state.openComplete||Ee.letThrough||n._vip)){var a=n._createTransaction(r,i,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,i,o)})):at(e)}return a._promise(r,function(e,t){return Xe(function(){return Ee.trans=a,o(e,t,a)})}).then(function(e){if("readwrite"===r)try{a.idbtrans.commit()}catch(e){}return"readonly"===r?e:a._completion.then(function(){return e})})}if(n._state.openComplete)return at(new Z.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return at(new Z.DatabaseClosed);n.open().catch(ne)}return n._state.dbReadyPromise.then(function(){return t(n,r,i,o)})}(this.db,e,[this.name],o)}finally{a&&Ne()}},Et.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)},Et.prototype.where=function(o){if("string"==typeof o)return new this.db.WhereClause(this,o);if(g(o))return new this.db.WhereClause(this,"[".concat(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){if(t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})){for(var e=0;e<n.length;++e)if(-1===n.indexOf(t.keyPath[e]))return!1;return!0}return!1}).sort(function(e,t){return e.keyPath.length-t.keyPath.length})[0];if(e&&this.db._maxKey!==st){var t=e.keyPath.slice(0,n.length);return this.where(t).equals(t.map(function(e){return o[e]}))}!e&&F&&console.warn("The query ".concat(JSON.stringify(o)," 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){return 0===r.cmp(e,t)}var i=n.reduce(function(e,t){var n=e[0],r=e[1],e=a[t],i=o[t];return[n||e,n||!e?bt(r,e&&e.multi?function(e){e=k(e,t);return g(e)&&e.some(function(e){return u(i,e)})}:function(e){return u(i,k(e,t))}):r]},[null,null]),t=i[0],i=i[1];return t?this.where(t.name).equals(o[t.keyPath]).filter(i):e?this.filter(i):this.where(n).equals("")},Et.prototype.filter=function(e){return this.toCollection().and(e)},Et.prototype.count=function(e){return this.toCollection().count(e)},Et.prototype.offset=function(e){return this.toCollection().offset(e)},Et.prototype.limit=function(e){return this.toCollection().limit(e)},Et.prototype.each=function(e){return this.toCollection().each(e)},Et.prototype.toArray=function(e){return this.toCollection().toArray(e)},Et.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},Et.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,g(e)?"[".concat(e.join("+"),"]"):e))},Et.prototype.reverse=function(){return this.toCollection().reverse()},Et.prototype.mapToClass=function(r){var e,t=this.db,n=this.name;function i(){return null!==e&&e.apply(this,arguments)||this}(this.schema.mappedClass=r).prototype instanceof _t&&(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)}(i,e=r),Object.defineProperty(i.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),i.prototype.table=function(){return n},r=i);for(var o=new Set,a=r.prototype;a;a=c(a))Object.getOwnPropertyNames(a).forEach(function(e){return o.add(e)});function u(e){if(!e)return e;var t,n=Object.create(r.prototype);for(t in e)if(!o.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},Et.prototype.defineClass=function(){return this.mapToClass(function(e){u(this,e)})},Et.prototype.add=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,a=t;return o&&i&&(a=wt(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?Ae.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{O(t,o,e)}catch(e){}return e})},Et.prototype.update=function(e,t){if("object"!=typeof e||g(e))return this.where(":id").equals(e).modify(t);e=k(e,this.schema.primKey.keyPath);return void 0===e?at(new Z.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)},Et.prototype.put=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,a=t;return o&&i&&(a=wt(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?Ae.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{O(t,o,e)}catch(e){}return e})},Et.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?Ae.reject(e.failures[0]):void 0})},Et.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:gt})}).then(function(e){return e.numFailures?Ae.reject(e.failures[0]):void 0})},Et.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)})})})},Et.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 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 i=r.length,t=t&&n?r.map(wt(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 X("".concat(o.name,".bulkAdd(): ").concat(t," of ").concat(i," operations failed"),e)})})},Et.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 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 i=r.length,t=t&&n?r.map(wt(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 X("".concat(o.name,".bulkPut(): ").concat(t," of ").concat(i," operations failed"),e)})})},Et.prototype.bulkUpdate=function(t){var h=this,n=this.core,r=t.map(function(e){return e.key}),i=t.map(function(e){return e.changes}),d=[];return this._trans("readwrite",function(e){return n.getMany({trans:e,keys:r,cache:"clone"}).then(function(c){var l=[],f=[];t.forEach(function(e,t){var n=e.key,r=e.changes,i=c[t];if(i){for(var o=0,a=Object.keys(r);o<a.length;o++){var u=a[o],s=r[u];if(u===h.schema.primKey.keyPath){if(0!==xt(s,n))throw new Z.Constraint("Cannot update primary key in bulkUpdate()")}else O(i,u,s)}d.push(t),l.push(n),f.push(i)}});var s=l.length;return n.mutate({trans:e,type:"put",keys:l,values:f,updates:{keys:r,changeSpecs:i}}).then(function(e){var t=e.numFailures,n=e.failures;if(0===t)return s;for(var r=0,i=Object.keys(n);r<i.length;r++){var o,a=i[r],u=d[Number(a)];null!=u&&(o=n[a],delete n[a],n[u]=o)}throw new X("".concat(h.name,".bulkUpdate(): ").concat(t," of ").concat(s," operations failed"),n)})})})},Et.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 X("".concat(r.name,".bulkDelete(): ").concat(t," of ").concat(i," operations failed"),e)})},Et);function Et(){}function Kt(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||ce;var o={subscribers:[],fire:r=r||ne,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(g(t))u(e,i[e][0],i[e][1]);else{if("asap"!==t)throw new Z.InvalidArgument("Invalid event config");var n=u(e,re,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 St(e,t){return o(t).from({prototype:e}),t}function jt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function At(e,t){e.filter=bt(e.filter,t)}function Ct(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return bt(r(),t())}:t,e.justLimit=n&&!r}function qt(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 Dt(e,t,n){var r=qt(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 It(e,o,t,n){var a=e.replayFilter?bt(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),Tt(Dt(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return Tt(Dt(e,n,t),bt(e.algorithm,a),o,!e.keysOnly&&e.valueMapper)}function Tt(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=ne},function(e){n.fail(e),t=ne})||a(n.value,n,function(e){return t=e}),t()})})}var Rt=(Bt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,at.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Bt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,at.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Bt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=bt(t.algorithm,e)},Bt.prototype._iterate=function(e,t){return It(this._ctx,e,t,this._ctx.table.core)},Bt.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},Bt.prototype.raw=function(){return this._ctx.valueMapper=null,this},Bt.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return It(n,t,e,n.table.core)})},Bt.prototype.count=function(e){var i=this;return this._read(function(e){var t=i._ctx,n=t.table.core;if(jt(t,!0))return n.count({trans:e,query:{index:qt(t,n.schema),range:t.range}}).then(function(e){return Math.min(e,t.limit)});var r=0;return It(t,function(){return++r,!1},e,n).then(function(){return r})}).then(e)},Bt.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)},Bt.prototype.toArray=function(e){var o=this;return this._read(function(e){var t=o._ctx;if("next"===t.dir&&jt(t,!0)&&0<t.limit){var n=t.valueMapper,r=qt(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 It(t,function(e){return i.push(e)},e,t.table.core).then(function(){return i})},e)},Bt.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,jt(e)?Ct(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):Ct(e,function(){var e=t;return function(){return--e<0}})),this},Bt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Ct(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},Bt.prototype.until=function(r,i){return At(this._ctx,function(e,t,n){return!r(e.value)||(t(n),i)}),this},Bt.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Bt.prototype.last=function(e){return this.reverse().first(e)},Bt.prototype.filter=function(t){var e;return At(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=bt(e.isMatch,t),this},Bt.prototype.and=function(e){return this.filter(e)},Bt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Bt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Bt.prototype.desc=function(){return this.reverse()},Bt.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},Bt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Bt.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},Bt.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)},Bt.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&jt(n,!0)&&0<n.limit)return this._read(function(e){var t=qt(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)},Bt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Bt.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Bt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Bt.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 At(this._ctx,function(e){var t=e.primaryKey.toString(),e=m(n,t);return n[t]=!0,!e}),this},Bt.prototype.modify=function(w){var n=this,_=this._ctx;return this._write(function(d){var o,a,p;p="function"==typeof w?w:(o=x(w),a=o.length,function(e){for(var t=!1,n=0;n<a;++n){var r=o[n],i=w[r];k(e,r)!==i&&(O(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=_.table.core,e=v.schema.primaryKey,m=e.outbound,b=e.extractKey,g=n.db._options.modifyChunkSize||200,u=[],s=0,t=[];return n.clone().primaryKeys().then(function(f){function h(c){var l=Math.min(g,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:j(a),primKey:f[c+o]};!1!==p.call(u,u.value,u)&&(null==u.value?i.push(f[c+o]):m||0===xt(b(a),b(u.value))?(t.push(u.value),m&&r.push(f[c+o])):(i.push(f[c+o]),n.push(u.value)))}var s=jt(_)&&_.limit===1/0&&("function"!=typeof w||w===Ft)&&{index:_.index,range:_.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 w)&&v.mutate({trans:d,type:"put",keys:r,values:t,criteria:s,changeSpec:"function"!=typeof w&&w}).then(function(e){return y(t.length,e)})}).then(function(){return(0<i.length||s&&w===Ft)&&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+g)})})}return h(0).then(function(){if(0<u.length)throw new H("Error modifying one or more objects",u,s,t);return f.length})})})},Bt.prototype.delete=function(){var i=this._ctx,n=i.range;return jt(i)&&(i.isPrimKey&&!pt||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(Ft)},Bt);function Bt(){}var Ft=function(e,t){return t.value=null};function Mt(e,t){return e<t?-1:e===t?0:1}function Nt(e,t){return t<e?-1:e===t?0:1}function Lt(e,t,n){e=e instanceof Yt?new e.Collection(e):e;return e._ctx.error=new(n||TypeError)(t),e}function Ut(e){return new e.Collection(e,function(){return Wt("")}).limit(0)}function zt(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 Lt(e,lt);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?Mt:Nt;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 Vt(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 Vt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Wt(e){return{type:1,lower:e,upper:e}}var Yt=(Object.defineProperty(Qt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Qt.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)?Ut(this):new this.Collection(this,function(){return Vt(e,t,!n,!r)})}catch(e){return Lt(this,ct)}},Qt.prototype.equals=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Wt(e)})},Qt.prototype.above=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Vt(e,void 0,!0)})},Qt.prototype.aboveOrEqual=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Vt(e,void 0,!1)})},Qt.prototype.below=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Vt(void 0,e,!1,!0)})},Qt.prototype.belowOrEqual=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Vt(void 0,e)})},Qt.prototype.startsWith=function(e){return"string"!=typeof e?Lt(this,lt):this.between(e,e+st,!0,!0)},Qt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):zt(this,function(e,t){return 0===e.indexOf(t[0])},[e],st)},Qt.prototype.equalsIgnoreCase=function(e){return zt(this,function(e,t){return e===t[0]},[e],"")},Qt.prototype.anyOfIgnoreCase=function(){var e=R.apply(T,arguments);return 0===e.length?Ut(this):zt(this,function(e,t){return-1!==t.indexOf(e)},e,"")},Qt.prototype.startsWithAnyOfIgnoreCase=function(){var e=R.apply(T,arguments);return 0===e.length?Ut(this):zt(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,st)},Qt.prototype.anyOf=function(){var t=this,i=R.apply(T,arguments),o=this._cmp;try{i.sort(o)}catch(e){return Lt(this,ct)}if(0===i.length)return Ut(this);var e=new this.Collection(this,function(){return Vt(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},Qt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Qt.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 Lt(this,ct)}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})},Qt.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 Ut(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&u(e[0],e[1])<=0}))return Lt(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,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 Lt(this,ct)}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 Vt(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},Qt.prototype.startsWithAnyOf=function(){var e=R.apply(T,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Ut(this):this.inAnyRange(e.map(function(e){return[e,e+st]})):Lt(this,"startsWithAnyOf() only works with strings")},Qt);function Qt(){}function Gt(t){return ze(function(e){return Ht(e),t(e.target.error),!1})}function Ht(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Xt="storagemutated",Jt="x-storagemutated-1",$t=Kt(null,Xt),Zt=(en.prototype._lock=function(){return b(!Ee.global),++this._reculock,1!==this._reculock||Ee.global||(Ee.lockOwnerFor=this),this},en.prototype._unlock=function(){if(b(!Ee.global),0==--this._reculock)for(Ee.global||(Ee.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{rt(e[1],e[0])}catch(e){}}return this},en.prototype._locked=function(){return this._reculock&&Ee.lockOwnerFor!==this},en.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(b(!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 b(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||e).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=ze(function(e){Ht(e),n._reject(t.error)}),t.onabort=ze(function(e){Ht(e),n.active&&n._reject(new Z.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=ze(function(){n.active=!1,n._resolve(),"mutatedParts"in t&&$t.storagemutated.fire(t.mutatedParts)}),this},en.prototype._promise=function(n,r,i){var o=this;if("readwrite"===n&&"readwrite"!==this.mode)return at(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return at(new Z.TransactionInactive);if(this._locked())return new Ae(function(e,t){o._blockedFuncs.push([function(){o._promise(n,r,i).then(e,t)},Ee])});if(i)return Xe(function(){var e=new Ae(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 Ae(function(e,t){var n=r(e,t,o);n&&n.then&&n.then(e,t)});return e._lib=!0,e},en.prototype._root=function(){return this.parent?this.parent._root():this},en.prototype.waitFor=function(e){var t,r=this._root(),i=Ae.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 Ae(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)})})},en.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new Z.Abort))},en.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},en);function en(){}function tn(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?"++":"")+nn(t)}}function nn(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function rn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(e){return[e.name,e]},n.reduce(function(e,t,n){n=r(t,n);return n&&(e[n[0]]=n[1]),e},{}))};var r}var on=function(e){try{return e.only([[]]),on=function(){return[[]]},[[]]}catch(e){return on=function(){return st},st}};function an(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 un(e){return[].slice.call(e)}var sn=0;function cn(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function ln(e,i,t){function _(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,w=e.name;return{name:w,schema:e,mutate:function(e){var y=e.trans,v=e.type,m=e.keys,b=e.values,g=e.range;return new Promise(function(t,e){t=ze(t);var n=y.objectStore(w),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||b||{length:1}).length;if(m&&b&&m.length!==b.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,Ht(e)}var s=[],c=[],l=0;if("deleteRange"===v){if(4===g.type)return t({numFailures:l,failures:c,results:[],lastResult:void 0});3===g.type?s.push(o=n.clear()):s.push(o=n.delete(_(g)))}else{var r=i?r?[b,m]:[b,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(w),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=Gt(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(w).get(i);n.onsuccess=function(e){return t(e.target.result)},n.onerror=Gt(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(w),l=l.isPrimaryKey?t:t.index(l.name),s=_(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=Gt(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=Gt(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(w),i=e.isPrimaryKey?i:i.index(e.name),e=u?l?"prevunique":"prev":l?"nextunique":"next",s=!o&&"openKeyCursor"in i?i.openKeyCursor(_(r),e):i.openCursor(_(r),e);s.onerror=Gt(n),s.onsuccess=ze(function(e){var r,i,o,a,u=s.result;u?(u.___id=++sn,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=Gt(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(w),r=o.isPrimaryKey?n:n.index(o.name),n=_(a),r=n?r.count(n):r.count();r.onsuccess=ze(function(e){return t(e.target.result)}),r.onerror=Gt(e)})}}}var r,o,a,u=(o=t,a=un((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=g(e),i={},n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:an(e)},indexes:un(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:g(e),keyPath:e,unique:n,multiEntry:r,extractKey:an(e)};return i[cn(e)]=r}),getIndexByKeyPath:function(e){return i[cn(e)]}};return i[":id"]=n.primaryKey,null!=e&&(i[cn(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 '".concat(e,"' not found"));return c[e]},MIN_KEY:-1/0,MAX_KEY:on(i),schema:t}}function fn(e,t,n,r){var i=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=ln(t,i,r),e.dbcore.reduce(function(e,t){t=t.create;return _(_({},e),t(e))},r))}}function hn(n,e){var t=e.db,e=fn(n._middlewares,t,n._deps,e);n.core=e.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 dn(i,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)&&(e===i.Transaction.prototype||e instanceof i.Transaction?l(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 i.Table(n,r))})})}function pn(n,e){e.forEach(function(e){for(var t in e)e[t]instanceof n.Table&&delete e[t]})}function yn(e,t){return e._cfg.version-t._cfg.version}function vn(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=Ee.transless||Ee;Xe(function(){var s,c,l,f,t,e,h,d;Ee.trans=a,Ee.transless=p,0===r?(x(o).forEach(function(e){bn(i,e,o[e].primKey,o[e].indexes)}),hn(n,i),Ae.follow(function(){return n.on.populate.fire(a)}).catch(u)):(c=r,l=a,f=i,t=[],e=(s=n)._versions,h=s._dbSchema=wn(0,s.idbdb,f),d=!1,e.filter(function(e){return e._cfg.version>=c}).forEach(function(u){t.push(function(){var t=h,e=u._cfg.dbschema;_n(s,t,f),_n(s,e,f),h=s._dbSchema=e;var n=mn(t,e);n.add.forEach(function(e){bn(f,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=f.objectStore(e.name);e.add.forEach(function(e){return gn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),gn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var r=u._cfg.contentUpgrade;if(r&&u._cfg.version>c){hn(s,f),l._memoizedTables={},d=!0;var i=P(e);n.del.forEach(function(e){i[e]=t[e]}),pn(s,[s.Transaction.prototype]),dn(s,[s.Transaction.prototype],x(i),i),l.schema=i;var o,a=B(r);a&&Je();n=Ae.follow(function(){var e;(o=r(l))&&a&&(e=$e.bind(null,null),o.then(e,e))});return o&&"function"==typeof o.then?Ae.resolve(o):n.then(function(){return o})}}),t.push(function(e){var t,n,r;d&&dt||(t=u._cfg.dbschema,n=t,r=e,[].slice.call(r.db.objectStoreNames).forEach(function(e){return null==n[e]&&r.db.deleteObjectStore(e)})),pn(s,[s.Transaction.prototype]),dn(s,[s.Transaction.prototype],s._storeNames,s._dbSchema),l.schema=s._dbSchema})}),function e(){return t.length?Ae.resolve(t.shift()(l.idbtrans)).then(e):Ae.resolve()}().then(function(){var t,n;n=f,x(t=h).forEach(function(e){n.db.objectStoreNames.contains(e)||bn(n,e,t[e].primKey,t[e].indexes)})}).catch(u))})}function mn(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&&!ht)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 bn(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 gn(i,e)}),i}function gn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function wn(e,t,u){var s={};return y(t.objectStoreNames,0).forEach(function(e){for(var t=u.objectStore(e),n=tn(nn(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=tn(o.name,a,!!o.unique,!!o.multiEntry,!1,a&&"string"!=typeof a,!1);r.push(o)}s[e]=rn(e,n,r)}),s}function _n(e,t,n){for(var r=n.db.objectStoreNames,i=0;i<r.length;++i){var o=r[i],a=n.objectStore(o);e._hasGetAll="getAll"in a;for(var u=0;u<a.indexNames.length;++u){var s=a.indexNames[u],c=a.index(s).keyPath,l="string"==typeof c?c:"["+y(c).join("+")+"]";!t[o]||(c=t[o].idxByName[l])&&(c.name=s,delete t[o].idxByName[l],t[o].idxByName[s]=c)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&f.WorkerGlobalScope&&f instanceof f.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}var xn=(kn.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 tn(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),g(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")}),i[e]=rn(e,n,t)}})},kn.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,pn(t,[t._allTables,t,t.Transaction.prototype]),dn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],x(r),r),t._storeNames=x(r),this},kn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=le(this._cfg.contentUpgrade||ne,e),this},kn);function kn(){}function On(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new sr(yt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Pn(e){return e&&"function"==typeof e.databases}function En(e){return Xe(function(){return Ee.letThrough=!0,e()})}function Kn(e){return!("from"in e)}var Sn=function(e,t){if(!this){var n=new Sn;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 jn(e,t,n){var r=xt(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(Kn(e))return u(e,{from:t,to:n,d:1});var i=e.l,r=e.r;if(xt(n,e.from)<0)return i?jn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Dn(e);if(0<xt(t,e.to))return r?jn(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Dn(e);xt(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<xt(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);n=!e.r;i&&!e.l&&An(e,i),r&&n&&An(e,r)}}function An(e,t){Kn(t)||function e(t,n){var r=n.from,i=n.to,o=n.l,n=n.r;jn(t,r,i),o&&e(t,o),n&&e(t,n)}(e,t)}function Cn(e,t){var n=qn(t),r=n.next();if(r.done)return!1;for(var i=r.value,o=qn(e),a=o.next(i.from),u=a.value;!r.done&&!a.done;){if(xt(u.from,i.to)<=0&&0<=xt(u.to,i.from))return!0;xt(i.from,u.from)<0?i=(r=n.next(u.from)).value:u=(a=o.next(i.from)).value}return!1}function qn(e){var n=Kn(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&&xt(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||xt(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 Dn(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=_({},e),r=e[i],e.from=r.from,e.to=r.to,e[i]=r[i],n[i]=r[t],(e[t]=n).d=In(n)),e.d=In(e)}function In(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}function Tn(t,n){return x(n).forEach(function(e){t[e]?An(t[e],n[e]):t[e]=function e(t){var n,r,i={};for(n in t)m(t,n)&&(r=t[n],i[n]=!r||"object"!=typeof r||K.has(r.constructor)?r:e(r));return i}(n[e])}),t}function Rn(t,n){return Object.keys(t).some(function(e){return n[e]&&Cn(n[e],t[e])})}r(Sn.prototype,((e={add:function(e){return An(this,e),this},addKey:function(e){return jn(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return jn(t,e,e)}),this}})[q]=function(){return qn(this)},e));var Bn={},Fn={},Mn=!1;function Nn(e){Tn(Fn,e),Mn||(Mn=!0,setTimeout(function(){Mn=!1;var e=Fn;Fn={},Ln(e)},0))}function Ln(e,t){void 0===t&&(t=!1);var n,r=new Set;for(n in e){var i,o=/^idb\:\/\/(.*)\/(.*)\//.exec(n);o&&(i=o[1],o=o[2],(o=Bn["idb://".concat(i,"/").concat(o)])&&function(e,t,n,r){for(var i=r&&[],o=0,a=Object.entries(e.queries.query);o<a.length;o++){for(var u=a[o],s=u[0],u=u[1],c=r&&[],l=0,f=u;l<f.length;l++){var h=f[l];h.obsSet&&Rn(t,h.obsSet)?h.subscribers.forEach(function(e){return n.add(e)}):r&&c.push(h)}r&&i.push([s,c])}if(r)for(var d=0,p=i;d<p.length;d++){var y=p[d],s=y[0],c=y[1];e.queries.query[s]=c}}(o,e,r,t))}r.forEach(function(e){return e()})}function Un(f){var h=f._state,r=f._deps.indexedDB;if(h.isBeingOpened||f.idbdb)return h.dbReadyPromise.then(function(){return h.dbOpenError?at(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 Z.DatabaseClosed("db.open() was cancelled")}function n(){return new Ae(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=Gt(n),l.onblocked=ze(f._fireOnBlocked),l.onupgradeneeded=ze(function(e){var t;d=l.transaction,h.autoSchema&&!f._options.allowEmptyDB?(l.onerror=Ht,d.abort(),l.result.close(),(t=r.deleteDatabase(c)).onsuccess=t.onerror=ze(function(){n(new Z.NoSuchDatabase("Database ".concat(c," doesnt exist")))})):(d.onerror=Gt(n),e=e.oldVersion>Math.pow(2,62)?0:e.oldVersion,p=e<1,f.idbdb=l.result,vn(f,e/10,d,n))},n),l.onsuccess=ze(function(){d=null;var e,t,n,r,i,o=f.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=f).verno=t.version/10,n=e._dbSchema=wn(0,t,n),e._storeNames=y(t.objectStoreNames,0),dn(e,[e._allTables],x(n),n)):(_n(f,f._dbSchema,u),((i=mn(wn(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.")),hn(f,u)}catch(e){}ft.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,Pn(o)||u===yt||On(o,i).put({name:u}).catch(ne)),s()},n)}).catch(function(e){return e&&"UnknownError"===e.name&&0<h.PR1398_maxLoop?(h.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),n()):Ae.reject(e)})}var i,o=h.dbReadyResolve,d=null,p=!1;return Ae.race([t,("undefined"==typeof navigator?Ae.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)}i=setInterval(t,100),t()}).finally(function(){return clearInterval(i)}):Promise.resolve()).then(n)]).then(function(){return e(),h.onReadyBeingFired=[],Ae.resolve(En(function(){return f.on.ready.fire(f.vip)})).then(function e(){if(0<h.onReadyBeingFired.length){var t=h.onReadyBeingFired.reduce(le,ne);return h.onReadyBeingFired=[],Ae.resolve(En(function(){return t(f.vip)})).then(e)}})}).finally(function(){h.openCanceller===t&&(h.onReadyBeingFired=null,h.isBeingOpened=!1)}).catch(function(e){h.dbOpenError=e;try{d&&d.abort()}catch(e){}return t===h.openCanceller&&f._close(),at(e)}).finally(function(){h.openComplete=!0,o()}).then(function(){var n;return p&&(n={},f.tables.forEach(function(t){t.schema.indexes.forEach(function(e){e.name&&(n["idb://".concat(f.name,"/").concat(t.name,"/").concat(e.name)]=new Sn(-1/0,[[[]]]))}),n["idb://".concat(f.name,"/").concat(t.name,"/")]=n["idb://".concat(f.name,"/").concat(t.name,"/:dels")]=new Sn(-1/0,[[[]]])}),$t(Xt).fire(n),Ln(n,!0)),f})}function zn(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):g(e)?Promise.all(e).then(r,i):r(e)}}return n(e)()}function Vn(e,t,n){for(var r=g(e)?e.slice():[e],i=0;i<n;++i)r.push(t);return r}var Wn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(f){return _(_({},f),{table:function(e){var a=f.table(e),t=a.schema,u={},s=[];function c(e,t,n){var r=cn(e),i=u[r]=u[r]||[],o=null==e?0:"string"==typeof e?1:e.length,a=0<t,a=_(_({},n),{name:a?"".concat(r,"(virtual-from:").concat(n.name,")"):n.name,lowLevelIndex:n,isVirtual:a,keyTail:t,keyLength:o,extractKey:an(e),unique:!a&&n.unique});return i.push(a),a.isPrimaryKey||s.push(a),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}),a}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?_(_({},e),{query:{index:n.lowLevelIndex,range:(t=e.query.range,n=n.keyTail,{type:1===t.type?2:t.type,lower:Vn(t.lower,t.lowerOpen?f.MAX_KEY:f.MIN_KEY,n),lowerOpen:!0,upper:Vn(t.upper,t.upperOpen?f.MIN_KEY:f.MAX_KEY,n),upperOpen:!0})}}):e}return _(_({},a),{schema:_(_({},t),{primaryKey:e,indexes:s,getIndexByKeyPath:function(e){return(e=u[cn(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(Vn(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(Vn(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 Yn(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=C(t))!==C(n)?a[u+e]=o[e]:"Object"===r?Yn(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}function Qn(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}var Gn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return _(_({},e),{table:function(r){var y=e.table(r),v=y.schema.primaryKey;return _(_({},y),{mutate:function(e){var t=Ee.trans,n=t.table(r).hook,h=n.deleting,d=n.creating,p=n.updating;switch(e.type){case"add":if(d.fire===ne)break;return t._promise("readwrite",function(){return a(e)},!0);case"put":if(d.fire===ne&&p.fire===ne)break;return t._promise("readwrite",function(){return a(e)},!0);case"delete":if(h.fire===ne)break;return t._promise("readwrite",function(){return a(e)},!0);case"deleteRange":if(h.fire===ne)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,_(_({},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=Ee.trans,f=c.keys||Qn(v,c);if(!f)throw new Error("Keys missing");return"delete"!==(c="add"===c.type||"put"===c.type?_(_({},c),{keys:f}):_({},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||O(c.values[t],v.keyPath,e))):(n=Yn(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]:O(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 Hn(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===xt(t.keys[i],e[o])&&(r.push(n?j(t.values[i]):t.values[i]),++o);return r.length===e.length?r:null}catch(e){return null}}var Xn={stack:"dbcore",level:-1,create:function(t){return{table:function(e){var n=t.table(e);return _(_({},n),{getMany:function(t){if(!t.cache)return n.getMany(t);var e=Hn(t.keys,t.trans._cache,"clone"===t.cache);return e?Ae.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 Jn(e,t){return"readonly"===e.trans.mode&&!!e.subscr&&!e.trans.explicit&&"disabled"!==e.trans.db._options.cache&&!t.schema.primaryKey.outbound}function $n(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Zn={stack:"dbcore",level:0,name:"Observability",create:function(r){var m=r.schema.name,b=new Sn(r.MIN_KEY,r.MAX_KEY);return _(_({},r),{transaction:function(e,t,n){if(Ee.subscr&&"readonly"!==t)throw new Z.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(Ee.querier));return r.transaction(e,t,n)},table:function(d){function e(e){var e=(t=e.query).index,t=t.range;return[e,new Sn(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,v=y.primaryKey,c=v.extractKey,l=v.outbound,t=_(_({},p),{mutate:function(t){function n(e){return e="idb://".concat(m,"/").concat(d,"/").concat(e),i[e]||(i[e]=new Sn)}var e,o,a,r=t.trans,i=t.mutatedParts||(t.mutatedParts={}),u=n(""),s=n(":dels"),c=t.type,l="deleteRange"===t.type?[t.range]:"delete"===t.type?[t.keys]:t.values.length<50?[Qn(v,t).filter(function(e){return e}),t.values]:[],f=l[0],h=l[1],l=t.trans._cache;return g(f)?(u.addKeys(f),(l="delete"===c||f.length===h.length?Hn(f,l):null)||"add"===c||s.addKeys(f),(l||h)&&(e=n,o=l,a=h,y.indexes.forEach(function(t){var n=e(t.name||"");function r(e){return null!=e?t.extractKey(e):null}function i(e){return t.multiEntry&&g(e)?e.forEach(function(e){return n.addKey(e)}):n.addKey(e)}(o||a).forEach(function(e,t){var n=o&&r(o[t]),t=a&&r(a[t]);0!==xt(n,t)&&(null!=n&&i(n),null!=t&&i(t))})}))):f?(h={from:f.lower,to:f.upper},s.add(h),u.add(h)):(u.add(b),s.add(b),y.indexes.forEach(function(e){return n(e.name).add(b)})),p.mutate(t).then(function(e){return!f||"add"!==t.type&&"put"!==t.type||u.addKeys(e.results),r.mutatedParts=Tn(r.mutatedParts||{},i),e})}}),f={get:function(e){return[v,new Sn(e.key)]},getMany:function(e){return[v,(new Sn).addKeys(e.keys)]},count:e,query:e,openCursor:e};return x(f).forEach(function(s){t[s]=function(i){var e=Ee.subscr,t=!!e,n=Jn(Ee,p)&&$n(s,i)?i.obsSet={}:e;if(t){var r=function(e){e="idb://".concat(m,"/").concat(d,"/").concat(e);return n[e]||(n[e]=new Sn)},o=r(""),a=r(":dels"),e=f[s](i),t=e[0],e=e[1];if(r(t.name||"").add(e),!t.isPrimaryKey){if("count"!==s){var u="query"===s&&l&&i.values&&p.query(_(_({},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(b)}}return p[s].apply(this,arguments)}}),t}})}};function er(e,t,n){if(0===n.numFailures)return t;if("deleteRange"===t.type)return null;var r=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1;if(n.numFailures===r)return null;t=_({},t);return g(t.keys)&&(t.keys=t.keys.filter(function(e,t){return!(t in n.failures)})),"values"in t&&g(t.values)&&(t.values=t.values.filter(function(e,t){return!(t in n.failures)})),t}function tr(e,t){return n=e,(void 0===(r=t).lower||(r.lowerOpen?0<xt(n,r.lower):0<=xt(n,r.lower)))&&(e=e,void 0===(t=t).upper||(t.upperOpen?xt(e,t.upper)<0:xt(e,t.upper)<=0));var n,r}function nr(e,u,t,n,r,s){if(!t||0===t.length)return e;var i=u.query.index,c=n.schema.primaryKey.extractKey,l=i.extractKey,o=(i.lowLevelIndex||i).extractKey,t=t.reduce(function(e,t){var n=e,r="add"===t.type||"put"===t.type?t.values.filter(function(e){return tr(l(e),u.query.range)}).map(function(e){return e=j(e),s&&Object.freeze(e),e}):[];switch(t.type){case"add":n=e.concat(u.values?r:r.map(function(e){return c(e)}));break;case"put":var i=(new Sn).addKeys(t.values.map(function(e){return c(e)})),n=e.filter(function(e){e=u.values?c(e):e;return!Cn(new Sn(e),i)}).concat(u.values?r:r.map(function(e){return c(e)}));break;case"delete":var o=(new Sn).addKeys(t.keys);n=e.filter(function(e){e=u.values?c(e):e;return!Cn(new Sn(e),o)});break;case"deleteRange":var a=t.range;n=e.filter(function(e){return!tr(c(e),a)})}return n},e);return t===e?e:(t.sort(function(e,t){return xt(o(e),o(t))||xt(c(e),c(t))}),u.limit&&u.limit<1/0&&(t.length>u.limit?t.length=u.limit:e.length===u.limit&&t.length<u.limit&&(r.dirty=!0)),s?Object.freeze(t):t)}function rr(e,t){return 0===xt(e.lower,t.lower)&&0===xt(e.upper,t.upper)&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function ir(e,t){return function(e,t,n,r){if(void 0===e)return void 0!==t?-1:0;if(void 0===t)return 1;if(0===(t=xt(e,t))){if(n&&r)return 0;if(n)return 1;if(r)return-1}return t}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(e,t,n,r){if(void 0===e)return void 0!==t?1:0;if(void 0===t)return-1;if(0===(t=xt(e,t))){if(n&&r)return 0;if(n)return-1;if(r)return 1}return t}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function or(n,r,i,e){n.subscribers.add(i),e.addEventListener("abort",function(){var e,t;n.subscribers.delete(i),0===n.subscribers.size&&(e=n,t=r,setTimeout(function(){0===e.subscribers.size&&I(t,e)},3e3))})}var ar={stack:"dbcore",level:0,name:"Cache",create:function(g){var w=g.schema.name;return _(_({},g),{transaction:function(y,v,e){var m,t,b=g.transaction(y,v,e);return"readwrite"===v&&(t=(m=new AbortController).signal,e=function(p){return function(){if(m.abort(),"readwrite"===v){for(var t=new Set,e=0,n=y;e<n.length;e++){var r=n[e],i=Bn["idb://".concat(w,"/").concat(r)],o=g.table(r);if(i){var a=i.optimisticOps.filter(function(e){return e.trans===b});if(0<a.length){i.optimisticOps=i.optimisticOps.filter(function(e){return e.trans!==b});for(var u=0,s=Object.values(i.queries.query);u<s.length;u++)for(var c=s[u],l=0,f=c.slice();l<f.length;l++){var h,d=f[l];null!=d.res&&b.mutatedParts&&(p&&!d.dirty?(h=Object.isFrozen(d.res),h=nr(d.res,d.req,a,o,d,h),d.dirty?(I(c,d),d.subscribers.forEach(function(e){return t.add(e)})):h!==d.res&&(d.res=h,d.promise=Ae.resolve({result:h}))):(d.dirty&&I(c,d),d.subscribers.forEach(function(e){return t.add(e)})))}}}}t.forEach(function(e){return e()})}}},b.addEventListener("abort",e(!1),{signal:t}),b.addEventListener("error",e(!1),{signal:t}),b.addEventListener("complete",e(!0),{signal:t})),b},table:function(c){var l=g.table(c),i=l.schema.primaryKey;return _(_({},l),{mutate:function(t){if(i.outbound||"disabled"===Ee.trans.db._options.cache)return l.mutate(t);var r=Bn["idb://".concat(w,"/").concat(c)];if(!r)return l.mutate(t);var e=l.mutate(t);return"add"!==t.type&&"put"!==t.type||!(50<=t.values.length||Qn(i,t).some(function(e){return null==e}))?(r.optimisticOps.push(t),Nn(t.mutatedParts),e.then(function(e){0<e.numFailures&&(I(r.optimisticOps,t),(e=er(0,t,e))&&r.optimisticOps.push(e),Nn(t.mutatedParts))}),e.catch(function(){I(r.optimisticOps,t),Nn(t.mutatedParts)})):e.then(function(n){var e=er(0,_(_({},t),{values:t.values.map(function(e,t){e=i.keyPath.includes(".")?j(e):_({},e);return O(e,i.keyPath,n.results[t]),e})}),n);r.optimisticOps.push(e),queueMicrotask(function(){return Nn(t.mutatedParts)})}),e},query:function(t){if(!Jn(Ee,l)||!$n("query",t))return l.query(t);var i="immutable"===Ee.trans.db._options.cache,e=Ee,n=e.requery,r=e.signal,o=function(e,t,n,r){var i=Bn["idb://".concat(e,"/").concat(t)];if(!i)return[];if(!(t=i.queries[n]))return[null,!1,i,null];var o=t[(r.query?r.query.index.name:null)||""];if(!o)return[null,!1,i,null];switch(n){case"query":var a=o.find(function(e){return e.req.limit===r.limit&&e.req.values===r.values&&rr(e.req.query.range,r.query.range)});return a?[a,!0,i,o]:[o.find(function(e){return("limit"in e.req?e.req.limit:1/0)>=r.limit&&(!r.values||e.req.values)&&ir(e.req.query.range,r.query.range)}),!1,i,o];case"count":a=o.find(function(e){return rr(e.req.query.range,r.query.range)});return[a,!!a,i,o]}}(w,c,"query",t),a=o[0],e=o[1],u=o[2],s=o[3];return a&&e?a.obsSet=t.obsSet:(e=l.query(t).then(function(e){var t=e.result;if(a.res=t,i){for(var n=0,r=t.length;n<r;++n)Object.freeze(t[n]);Object.freeze(t)}else e.result=j(t);return e}).catch(function(e){return s&&a&&I(s,a),Promise.reject(e)}),a={obsSet:t.obsSet,promise:e,subscribers:new Set,type:"query",req:t,dirty:!1},s?s.push(a):(s=[a],(u=u||(Bn["idb://".concat(w,"/").concat(c)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[t.query.index.name||""]=s)),or(a,s,n,r),a.promise.then(function(e){return{result:nr(e.result,t,null==u?void 0:u.optimisticOps,l,a,i)}})}})}})}};function ur(e,r){return new Proxy(e,{get:function(e,t,n){return"db"===t?r:Reflect.get(e,t,n)}})}var sr=(cr.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(yn),n.stores({}),this._state.autoSchema=!1,n)},cr.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||Ee.letThrough||this._vip)?e():new Ae(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(ne)}n._state.dbReadyPromise.then(e,t)}).then(e)},cr.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},cr.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},cr.prototype.open=function(){var e=this;return rt(Pe,function(){return Un(e)})},cr.prototype._close=function(){var n=this._state,e=ft.indexOf(this);if(0<=e&&ft.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(e){}this.idbdb=null}n.dbReadyPromise=new Ae(function(e){n.dbReadyResolve=e}),n.openCanceller=new Ae(function(e,t){n.cancelOpen=t})},cr.prototype.close=function(e){var t=(void 0===e?{disableAutoOpen:!0}:e).disableAutoOpen;this._close();e=this._state;t&&(this._options.autoOpen=!1),e.dbOpenError=new Z.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)},cr.prototype.delete=function(){var i=this,n=0<arguments.length,o=this._state;return new Ae(function(r,t){function e(){i.close({disableAutoOpen:!1});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,Pn(n)||t===yt||On(n,e).delete(t).catch(ne),r()}),e.onerror=Gt(t),e.onblocked=i._fireOnBlocked}if(n)throw new Z.InvalidArgument("Arguments not allowed in db.delete()");o.isBeingOpened?o.dbReadyPromise.then(e):e()})},cr.prototype.backendDB=function(){return this.idbdb},cr.prototype.isOpen=function(){return null!==this.idbdb},cr.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},cr.prototype.hasFailed=function(){return null!==this._state.dbOpenError},cr.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(cr.prototype,"tables",{get:function(){var t=this;return x(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),cr.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 i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,E(i),n]}.apply(this,arguments);return this._transaction.apply(this,e)},cr.prototype._transaction=function(e,t,n){var r=this,i=Ee.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===vt)o=vt;else{if("rw"!=e&&e!=mt)throw new Z.InvalidArgument("Invalid transaction mode: "+e);o=mt}if(i){if(i.mode===vt&&o===mt){if(!u)throw new Z.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 Z.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)}):at(n)}var s=function i(o,a,u,s,c){return Ae.resolve().then(function(){var e=Ee.transless||Ee,t=o._createTransaction(a,u,o._dbSchema,s);if(t.explicit=!0,e={trans:t,transless:e},s)t.idbtrans=s.idbtrans;else try{t.create(),o._state.PR1398_maxLoop=3}catch(e){return e.name===J.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)})):at(e)}var n,r=B(c);return r&&Je(),e=Ae.follow(function(){var e;(n=c.call(t,t))&&(r?(e=$e.bind(null,null),n.then(e,e)):"function"==typeof n.next&&"function"==typeof n.throw&&(n=zn(n)))},e),(n&&"function"==typeof n.then?Ae.resolve(n).then(function(e){return t.active?e:at(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),at(e)})})}.bind(null,this,o,a,i,n);return i?i._promise(o,s,"lock"):Ee.trans?rt(Ee.transless,function(){return r._whenReady(s)}):this._whenReady(s)},cr.prototype.table=function(e){if(!m(this._allTables,e))throw new Z.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},cr);function cr(e,t){var o=this;this._middlewares={},this.verno=0;var n=cr.dependencies;this._options=t=_({addons:cr.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,cache:"cloned"},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:ne,dbReadyPromise:null,cancelOpen:ne,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};c.dbReadyPromise=new Ae(function(e){c.dbReadyResolve=e}),c.openCanceller=new Ae(function(e,t){c.cancelOpen=t}),this._state=c,this.name=e,this.on=Kt(this,"populate","blocked","versionchange","close",{ready:[le,ne]}),this.on.ready.subscribe=v(this.on.ready.subscribe,function(i){return function(n,r){cr.vip(function(){var t,e=o._state;e.openComplete?(e.dbOpenError||Ae.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,St(Rt.prototype,function(e,t){this.db=a;var n=gt,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!==re?e:null}})),this.Table=(r=this,St(Pt.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:Kt(null,{creating:[ae,ne],reading:[ie,re],updating:[se,ne],deleting:[ue,ne]})})),this.Transaction=(u=this,St(Zt.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=Kt(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 Ae(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(),at(e)})})),this.Version=(i=this,St(xn.prototype,function(e){this.db=i,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,St(Yt.prototype,function(e,t,n){if(this.db=s,this._ctx={table:e,index:":id"===t?null:t,or:n},this._cmp=this._ascending=xt,this._descending=function(e,t){return xt(t,e)},this._max=function(e,t){return 0<xt(e,t)?e:t},this._min=function(e,t){return xt(e,t)<0?e:t},this._IDBKeyRange=s._deps.IDBKeyRange,!this._IDBKeyRange)throw new Z.MissingAPI})),this.on("versionchange",function(e){0<e.newVersion?console.warn("Another connection wants to upgrade database '".concat(o.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(o.name,"'. Closing db now to resume the delete request.")),o.close({disableAutoOpen:!1}),o._state.openComplete=!1}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('".concat(o.name,"') was blocked")):console.warn("Upgrade '".concat(o.name,"' blocked by other connection holding version ").concat(e.oldVersion/10))}),this._maxKey=on(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),ft.filter(function(e){return e.name===o.name&&e!==o&&!e._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(Xn),this.use(ar),this.use(Zn),this.use(Wn),this.use(Gn);var l=new Proxy(this,{get:function(e,t,n){if("_vip"===t)return!0;if("table"===t)return function(e){return ur(o.table(e),l)};var r=Reflect.get(e,t,n);return r instanceof Pt?ur(r,l):"tables"===t?r.map(function(e){return ur(e,l)}):"_createTransaction"===t?function(){return ur(r.apply(this,arguments),l)}:r}});this.vip=l,n.forEach(function(e){return e(o)})}var lr,e="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable",fr=(hr.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},hr.prototype[e]=function(){return this},hr);function hr(e){this._subscribe=e}try{lr={indexedDB:f.indexedDB||f.mozIndexedDB||f.webkitIndexedDB||f.msIndexedDB,IDBKeyRange:f.IDBKeyRange||f.webkitIDBKeyRange}}catch(e){lr={indexedDB:null,IDBKeyRange:null}}function dr(h){var d,p=!1,e=new fr(function(r){var i=B(h);var o,a=!1,u={},s={},e={get closed(){return a},unsubscribe:function(){a||(a=!0,o&&o.abort(),c&&$t.storagemutated.unsubscribe(l))}};r.start&&r.start(e);var c=!1;var l=function(e){Tn(u,e),Rn(s,u)&&f()},f=function(){var t,n,e;!a&&lr.indexedDB&&(u={},t={},o&&o.abort(),o=new AbortController,e=function(e){var t=Me();try{i&&Je();var n=Xe(h,e);return i&&(n=n.finally($e)),Promise.resolve(n).finally(function(){if(Ee.subscr===e.subscr)return console.warn("Dexie liveQuery()'s querier callback did'nt await all of its spawned promises. Querier source: ".concat(h)),new ye(function(e){return setTimeout(e,0)})})}finally{t&&Ne()}}(n={subscr:t,signal:o.signal,requery:f,querier:h,trans:null}),Promise.resolve(e).then(function(e){p=!0,d=e,a||n.signal.aborted||(u={},function(e){for(var t in e)if(m(e,t))return;return 1}(s=t)||c||($t(Xt,l),c=!0),r.next&&r.next(e))},function(e){p=!1,["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||a||r.error&&r.error(e)}))};return f(),e});return e.hasValue=function(){return p},e.getValue=function(){return d},e}var pr=sr;function yr(e){var t=mr;try{mr=!0,$t.storagemutated.fire(e),Ln(e,!0)}finally{mr=t}}r(pr,_(_({},te),{delete:function(e){return new pr(e,{addons:[]}).delete()},exists:function(e){return new pr(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=pr.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Pn(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==yt})}):On(n,t).toCollection().primaryKeys()).then(e)}catch(e){return at(new Z.MissingAPI)}var t,n},defineClass:function(){return function(e){u(this,e)}},ignoreTransaction:function(e){return Ee.trans?rt(Ee.transless,e):e()},vip:En,async:function(t){return function(){try{var e=zn(t.apply(this,arguments));return e&&"function"==typeof e.then?e:Ae.resolve(e)}catch(e){return at(e)}}},spawn:function(e,t,n){try{var r=zn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Ae.resolve(r)}catch(e){return at(e)}},currentTransaction:{get:function(){return Ee.trans||null}},waitFor:function(e,t){t=Ae.resolve("function"==typeof e?pr.ignoreTransaction(e):e).timeout(t||6e4);return Ee.trans?Ee.trans.waitFor(t):t},Promise:Ae,debug:{get:function(){return F},set:function(e){M(e,"dexie"===e?function(){return!0}:ut)}},derive:o,extend:u,props:r,override:v,Events:Kt,on:$t,liveQuery:dr,extendObservabilitySet:Tn,getByKeyPath:k,setByKeyPath:O,delByKeyPath:function(t,e){"string"==typeof e?O(t,e,void 0):"length"in e&&[].map.call(e,function(e){O(t,e,void 0)})},shallowClone:P,deepClone:j,getObjectDiff:Yn,cmp:xt,asap:w,minKey:-1/0,addons:[],connections:ft,errnames:J,dependencies:lr,cache:Bn,semVer:W,version:W.split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),pr.maxKey=on(pr.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&($t(Xt,function(e){var t;mr||(ht?(t=document.createEvent("CustomEvent")).initCustomEvent(Jt,!0,!0,e):t=new CustomEvent(Jt,{detail:e}),mr=!0,dispatchEvent(t),mr=!1)}),addEventListener(Jt,function(e){e=e.detail;mr||yr(e)}));var vr,mr=!1;return"undefined"!=typeof BroadcastChannel?("function"==typeof(vr=new BroadcastChannel(Jt)).unref&&vr.unref(),$t(Xt,function(e){mr||vr.postMessage(e)}),vr.onmessage=function(e){e.data&&yr(e.data)}):"undefined"!=typeof self&&"undefined"!=typeof navigator&&($t(Xt,function(t){try{mr||("undefined"!=typeof localStorage&&localStorage.setItem(Jt,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:Jt,changedParts:t})}))}catch(e){}}),"undefined"!=typeof addEventListener&&addEventListener("storage",function(e){e.key!==Jt||(e=JSON.parse(e.newValue))&&yr(e.changedParts)}),(W=self.document&&navigator.serviceWorker)&&W.addEventListener("message",function(e){e=e.data;e&&e.type===Jt&&yr(e.changedParts)})),Ae.rejectionMapper=function(e,t){return!e||e instanceof Q||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ee[e.name]?e:(t=new ee[e.name](t||e.message,e),"stack"in e&&l(t,"stack",{get:function(){return this.inner.stack}}),t)},M(F,ut),_(sr,Object.freeze({__proto__:null,Dexie:sr,liveQuery:dr,Entity:_t,cmp:xt,default:sr,RangeSet:Sn,mergeRanges:An,rangesOverlap:Cn}),{default:sr}),sr});
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 _=function(){return(_=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 f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=Object.keys,g=Array.isArray;function u(t,n){return"object"!=typeof n||x(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||f.Promise||(f.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){l(t,e,n[e])})}var a=Object.defineProperty;function l(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),l(t.prototype,"constructor",t),{extend:r.bind(null,t.prototype)}}}}var h=Object.getOwnPropertyDescriptor;function d(e,t){return h(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 b(e){if(!e)throw new Error("Assertion Failed")}function w(e){f.setImmediate?setImmediate(e):setTimeout(e,0)}function k(e,t){if("string"==typeof t&&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 O(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){b("string"!=typeof n&&"length"in n);for(var r=0,i=t.length;r<i;++r)O(e,t[r],n[r])}else{var o,a,u=t.indexOf(".");-1!==u?(o=t.substr(0,u),""===(a=t.substr(u+1))?void 0===n?g(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n:O(u=!(u=e[o])||!m(e,o)?e[o]={}:u,a,n)):void 0===n?g(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 E(e){return t.apply([],e)}var e="Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(E([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return f[e]}),K=new Set(e.map(function(e){return f[e]}));var S=null;function j(e){S=new WeakMap;e=function e(t){if(!t||"object"!=typeof t)return t;var n=S.get(t);if(n)return n;if(g(t)){n=[],S.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(K.has(t.constructor))n=t;else{var o,a=c(t);for(o in n=a===Object.prototype?{}:Object.create(a),S.set(t,n),t)m(t,o)&&(n[o]=e(t[o]))}return n}(e);return S=null,e}var A={}.toString;function C(e){return A.call(e).slice(8,-1)}var q="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",D="symbol"==typeof q?function(e){var t;return null!=e&&(t=e[q])&&t.apply(e)}:function(){return null};function T(e,t){t=e.indexOf(t);return 0<=t&&e.splice(t,1),0<=t}var I={};function R(e){var t,n,r,i;if(1===arguments.length){if(g(e))return e.slice();if(this===I&&"string"==typeof e)return[e];if(i=D(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 B="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},L=!new Error("").stack;function U(){if(L)try{throw new Error}catch(e){return e}return new Error}function z(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),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 Q(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 X(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,this.failures)}o(Q).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+z(this._e,2))}},toString:function(){return this.name+": "+this.message}}),o(H).from(Q),o(X).from(Q);var J=W.reduce(function(e,t){return e[t]=t+"Error",e},{}),$=Q,Z=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="".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 o(t).from($),e[n]=t,e},{});Z.Syntax=SyntaxError,Z.Type=TypeError,Z.Range=RangeError;var ee=V.reduce(function(e,t){return e[t+"Error"]=Z[t],e},{});var te=W.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=Z[t]),e},{});function ne(){}function re(e){return e}function ie(t,n){return null==t||t===re?n:function(e){return n(t(e))}}function oe(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ae(i,o){return i===ne?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?oe(t,this.onsuccess):t),n&&(this.onerror=this.onerror?oe(n,this.onerror):n),void 0!==r?r:e}}function ue(n,r){return n===ne?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 se(i,o){return i===ne?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?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 ce(e,t){return e===ne?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function le(i,o){return i===ne?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)}}te.ModifyError=H,te.DexieError=Q,te.BulkError=X;var fe={},he=100,de=100,e="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]}(),V=e[0],pe=e[1],W=e[2],e=pe&&pe.then,ye=V&&V.constructor,ve=!!W,me=!1;var be=function(e,t){Ke.push([e,t]),we&&(queueMicrotask(Fe),we=!1)},ge=!0,we=!0,_e=[],xe=[],ke=null,Oe=re,Pe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ne,pgp:!1,env:{},finalize:ne},Ee=Pe,Ke=[],Se=0,je=[];function Ae(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=Ee;if(F&&(this._stackHolder=U(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==fe)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&De(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&&Me();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof Ae?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Te(r)),e&&Ne()}},De.bind(null,r))}catch(e){De(r,e)}}(this,e)}var Ce={get:function(){var u=Ee,t=Ge;function e(n,r){var i=this,o=!u.global&&(u!==Ee||t!==Ge),a=o&&!$e(),e=new Ae(function(e,t){Ie(i,new qe(it(n,u,o,a),it(r,u,o,a),e,t,u))});return F&&Be(e,this),e}return e.prototype=fe,e},set:function(e){l(this,"then",e&&e.prototype===fe?Ce:{get:function(){return e},set:Ce.set})}};function qe(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 De(t,n){var e,r;xe.push(n),null===t._state&&(e=t._lib&&Me(),n=Oe(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=d(n,"stack");n._promise=t,l(n,"stack",{get:function(){return me?e&&(e.get?e.get.apply(n):e.value):t.stack}})}),r=t,_e.some(function(e){return e._value===r._value})||_e.push(r),Te(t),e&&Ne())}function Te(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Ie(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===Se&&(++Se,be(function(){0==--Se&&Le()},[]))}function Ie(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,++Se,be(Re,[n,e,t])}else e._listeners.push(t)}function Re(e,t,n){try{var r,i=(ke=t)._value;t._state?r=e(i):(xe.length&&(xe=[]),r=e(i),-1===xe.indexOf(i)&&function(e){var t=_e.length;for(;t;)if(_e[--t]._value===e._value)return _e.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{ke=null,0==--Se&&Le(),--n.psd.ref||n.psd.finalize()}}function Be(e,t){var n=t?t._numPrev+1:0;n<he&&(e._prev=t,e._numPrev=n)}function Fe(){rt(Pe,function(){Me()&&Ne()})}function Me(){var e=ge;return we=ge=!1,e}function Ne(){var e,t,n;do{for(;0<Ke.length;)for(e=Ke,Ke=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<Ke.length);we=ge=!0}function Le(){var e=_e;_e=[],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 Ue(e){return new Ae(fe,!1,e)}function ze(n,r){var i=Ee;return function(){var e=Me(),t=Ee;try{return tt(i,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{tt(t,!1),e&&Ne()}}}r(Ae.prototype,{then:Ce,_then:function(e,t){Ie(this,new qe(null,null,e,t,Ee))},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:Ue)(e)}):this.then(null,function(e){return(e&&e.name===t?n:Ue)(e)})},finally:function(t){return this.then(function(e){return Ae.resolve(t()).then(function(){return e})},function(e){return Ae.resolve(t()).then(function(){return Ue(e)})})},stack:{get:function(){if(this._stack)return this._stack;try{me=!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=z(o,0)):(a=o,u=""),n.push(a+(u?": "+u:"")+i))}F&&((i=z(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{me=!1}}},timeout:function(r,i){var o=this;return r<1/0?new Ae(function(e,t){var n=setTimeout(function(){return t(new Z.Timeout(i))},r);o.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&l(Ae.prototype,Symbol.toStringTag,"Dexie.Promise"),Pe.env=nt(),r(Ae,{all:function(){var o=R.apply(null,arguments).map(Ze);return new Ae(function(n,r){0===o.length&&n([]);var i=o.length;o.forEach(function(e,t){return Ae.resolve(e).then(function(e){o[t]=e,--i||n(o)},r)})})},resolve:function(n){if(n instanceof Ae)return n;if(n&&"function"==typeof n.then)return new Ae(function(e,t){n.then(e,t)});var e=new Ae(fe,!0,n);return Be(e,ke),e},reject:Ue,race:function(){var e=R.apply(null,arguments).map(Ze);return new Ae(function(t,n){e.map(function(e){return Ae.resolve(e).then(t,n)})})},PSD:{get:function(){return Ee},set:function(e){return Ee=e}},totalEchoes:{get:function(){return Ge}},newPSD:Xe,usePSD:rt,scheduler:{get:function(){return be},set:function(e){be=e}},rejectionMapper:{get:function(){return Oe},set:function(e){Oe=e}},follow:function(i,n){return new Ae(function(e,t){return Xe(function(n,r){var e=Ee;e.unhandleds=[],e.onunhandled=r,e.finalize=oe(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)}),++Se,be(function(){0==--Se&&Le()},[])},e.finalize),i()},n,e,t)})}}),ye&&(ye.allSettled&&l(Ae,"allSettled",function(){var e=R.apply(null,arguments).map(Ze);return new Ae(function(n){0===e.length&&n([]);var r=e.length,i=new Array(r);e.forEach(function(e,t){return Ae.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)})})})}),ye.any&&"undefined"!=typeof AggregateError&&l(Ae,"any",function(){var e=R.apply(null,arguments).map(Ze);return new Ae(function(n,r){0===e.length&&r(new AggregateError([]));var i=e.length,o=new Array(i);e.forEach(function(e,t){return Ae.resolve(e).then(function(e){return n(e)},function(e){o[t]=e,--i||r(new AggregateError(o))})})})}));var Ve={awaits:0,echoes:0,id:0},We=0,Ye=[],Qe=0,Ge=0,He=0;function Xe(e,t,n,r){var i=Ee,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++He;var a=Pe.env;o.env=ve?{Promise:Ae,PromiseProp:{value:Ae,configurable:!0,writable:!0},all:Ae.all,race:Ae.race,allSettled:Ae.allSettled,any:Ae.any,resolve:Ae.resolve,reject:Ae.reject,nthen:ot(a.nthen,o),gthen:ot(a.gthen,o)}:{},t&&u(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};r=rt(o,e,n,r);return 0===o.ref&&o.finalize(),r}function Je(){return Ve.id||(Ve.id=++We),++Ve.awaits,Ve.echoes+=de,Ve.id}function $e(){return!!Ve.awaits&&(0==--Ve.awaits&&(Ve.id=0),Ve.echoes=Ve.awaits*de,!0)}function Ze(e){return Ve.echoes&&e&&e.constructor===ye?(Je(),e.then(function(e){return $e(),e},function(e){return $e(),at(e)})):e}function et(){var e=Ye[Ye.length-1];Ye.pop(),tt(e,!1)}function tt(e,t){var n,r=Ee;(t?!Ve.echoes||Qe++&&e===Ee:!Qe||--Qe&&e===Ee)||queueMicrotask(t?function(e){++Ge,Ve.echoes&&0!=--Ve.echoes||(Ve.echoes=Ve.id=0),Ye.push(Ee),tt(e,!0)}.bind(null,e):et),e!==Ee&&(Ee=e,r===Pe&&(Pe.env=nt()),ve&&(n=Pe.env.Promise,t=e.env,pe.then=t.nthen,n.prototype.then=t.gthen,(r.global||e.global)&&(Object.defineProperty(f,"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 nt(){var e=f.Promise;return ve?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(f,"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 rt(e,t,n,r,i){var o=Ee;try{return tt(e,!0),t(n,r,i)}finally{tt(o,!1)}}function it(t,n,r,i){return"function"!=typeof t?t:function(){var e=Ee;r&&Je(),tt(n,!0);try{return t.apply(this,arguments)}finally{tt(e,!1),i&&queueMicrotask($e)}}}function ot(n,r){return function(e,t){return n.call(this,it(e,r),it(t,r))}}-1===(""+e).indexOf("[native code]")&&(Je=$e=ne);var at=Ae.reject;function ut(e){return!/(dexie\.js|dexie\.min\.js)/.test(e)}var W="4.0.1-beta.4",st=String.fromCharCode(65535),ct="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",lt="String expected.",ft=[],ht="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),dt=ht,pt=ht,yt="__dbnames",vt="readonly",mt="readwrite";function bt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var gt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function wt(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 _t(){throw Z.Type()}function xt(e,t){try{var n=kt(e),r=kt(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}(Ot(e),Ot(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=xt(e[o],t[o]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function kt(e){var t=typeof e;if("object"!=t)return t;if(ArrayBuffer.isView(e))return"binary";e=C(e);return"ArrayBuffer"===e?"binary":e}function Ot(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Pt=(Et.prototype._trans=function(e,r,t){var n=this._tx||Ee.trans,i=this.name;function o(e,t,n){if(!n.schema[i])throw new Z.NotFound("Table "+i+" not part of transaction");return r(n.idbtrans,n)}var a=Me();try{return n&&n.db._novip===this.db._novip?n===Ee.trans?n._promise(e,o,t):Xe(function(){return n._promise(e,o,t)},{trans:n,transless:Ee.transless||Ee}):function t(n,r,i,o){if(n.idbdb&&(n._state.openComplete||Ee.letThrough||n._vip)){var a=n._createTransaction(r,i,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,i,o)})):at(e)}return a._promise(r,function(e,t){return Xe(function(){return Ee.trans=a,o(e,t,a)})}).then(function(e){if("readwrite"===r)try{a.idbtrans.commit()}catch(e){}return"readonly"===r?e:a._completion.then(function(){return e})})}if(n._state.openComplete)return at(new Z.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return at(new Z.DatabaseClosed);n.open().catch(ne)}return n._state.dbReadyPromise.then(function(){return t(n,r,i,o)})}(this.db,e,[this.name],o)}finally{a&&Ne()}},Et.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)},Et.prototype.where=function(o){if("string"==typeof o)return new this.db.WhereClause(this,o);if(g(o))return new this.db.WhereClause(this,"[".concat(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){if(t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})){for(var e=0;e<n.length;++e)if(-1===n.indexOf(t.keyPath[e]))return!1;return!0}return!1}).sort(function(e,t){return e.keyPath.length-t.keyPath.length})[0];if(e&&this.db._maxKey!==st){var t=e.keyPath.slice(0,n.length);return this.where(t).equals(t.map(function(e){return o[e]}))}!e&&F&&console.warn("The query ".concat(JSON.stringify(o)," 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){return 0===r.cmp(e,t)}var i=n.reduce(function(e,t){var n=e[0],r=e[1],e=a[t],i=o[t];return[n||e,n||!e?bt(r,e&&e.multi?function(e){e=k(e,t);return g(e)&&e.some(function(e){return u(i,e)})}:function(e){return u(i,k(e,t))}):r]},[null,null]),t=i[0],i=i[1];return t?this.where(t.name).equals(o[t.keyPath]).filter(i):e?this.filter(i):this.where(n).equals("")},Et.prototype.filter=function(e){return this.toCollection().and(e)},Et.prototype.count=function(e){return this.toCollection().count(e)},Et.prototype.offset=function(e){return this.toCollection().offset(e)},Et.prototype.limit=function(e){return this.toCollection().limit(e)},Et.prototype.each=function(e){return this.toCollection().each(e)},Et.prototype.toArray=function(e){return this.toCollection().toArray(e)},Et.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},Et.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,g(e)?"[".concat(e.join("+"),"]"):e))},Et.prototype.reverse=function(){return this.toCollection().reverse()},Et.prototype.mapToClass=function(r){var e,t=this.db,n=this.name;function i(){return null!==e&&e.apply(this,arguments)||this}(this.schema.mappedClass=r).prototype instanceof _t&&(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)}(i,e=r),Object.defineProperty(i.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),i.prototype.table=function(){return n},r=i);for(var o=new Set,a=r.prototype;a;a=c(a))Object.getOwnPropertyNames(a).forEach(function(e){return o.add(e)});function u(e){if(!e)return e;var t,n=Object.create(r.prototype);for(t in e)if(!o.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},Et.prototype.defineClass=function(){return this.mapToClass(function(e){u(this,e)})},Et.prototype.add=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,a=t;return o&&i&&(a=wt(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?Ae.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{O(t,o,e)}catch(e){}return e})},Et.prototype.update=function(e,t){if("object"!=typeof e||g(e))return this.where(":id").equals(e).modify(t);e=k(e,this.schema.primKey.keyPath);return void 0===e?at(new Z.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)},Et.prototype.put=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,a=t;return o&&i&&(a=wt(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?Ae.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{O(t,o,e)}catch(e){}return e})},Et.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?Ae.reject(e.failures[0]):void 0})},Et.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:gt})}).then(function(e){return e.numFailures?Ae.reject(e.failures[0]):void 0})},Et.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)})})})},Et.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 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 i=r.length,t=t&&n?r.map(wt(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 X("".concat(o.name,".bulkAdd(): ").concat(t," of ").concat(i," operations failed"),e)})})},Et.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 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 i=r.length,t=t&&n?r.map(wt(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 X("".concat(o.name,".bulkPut(): ").concat(t," of ").concat(i," operations failed"),e)})})},Et.prototype.bulkUpdate=function(t){var h=this,n=this.core,r=t.map(function(e){return e.key}),i=t.map(function(e){return e.changes}),d=[];return this._trans("readwrite",function(e){return n.getMany({trans:e,keys:r,cache:"clone"}).then(function(c){var l=[],f=[];t.forEach(function(e,t){var n=e.key,r=e.changes,i=c[t];if(i){for(var o=0,a=Object.keys(r);o<a.length;o++){var u=a[o],s=r[u];if(u===h.schema.primKey.keyPath){if(0!==xt(s,n))throw new Z.Constraint("Cannot update primary key in bulkUpdate()")}else O(i,u,s)}d.push(t),l.push(n),f.push(i)}});var s=l.length;return n.mutate({trans:e,type:"put",keys:l,values:f,updates:{keys:r,changeSpecs:i}}).then(function(e){var t=e.numFailures,n=e.failures;if(0===t)return s;for(var r=0,i=Object.keys(n);r<i.length;r++){var o,a=i[r],u=d[Number(a)];null!=u&&(o=n[a],delete n[a],n[u]=o)}throw new X("".concat(h.name,".bulkUpdate(): ").concat(t," of ").concat(s," operations failed"),n)})})})},Et.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 X("".concat(r.name,".bulkDelete(): ").concat(t," of ").concat(i," operations failed"),e)})},Et);function Et(){}function Kt(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||ce;var o={subscribers:[],fire:r=r||ne,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(g(t))u(e,i[e][0],i[e][1]);else{if("asap"!==t)throw new Z.InvalidArgument("Invalid event config");var n=u(e,re,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 St(e,t){return o(t).from({prototype:e}),t}function jt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function At(e,t){e.filter=bt(e.filter,t)}function Ct(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return bt(r(),t())}:t,e.justLimit=n&&!r}function qt(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 Dt(e,t,n){var r=qt(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?bt(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),It(Dt(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return It(Dt(e,n,t),bt(e.algorithm,a),o,!e.keysOnly&&e.valueMapper)}function It(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=ne},function(e){n.fail(e),t=ne})||a(n.value,n,function(e){return t=e}),t()})})}var Rt=(Bt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,at.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Bt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,at.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Bt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=bt(t.algorithm,e)},Bt.prototype._iterate=function(e,t){return Tt(this._ctx,e,t,this._ctx.table.core)},Bt.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},Bt.prototype.raw=function(){return this._ctx.valueMapper=null,this},Bt.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return Tt(n,t,e,n.table.core)})},Bt.prototype.count=function(e){var i=this;return this._read(function(e){var t=i._ctx,n=t.table.core;if(jt(t,!0))return n.count({trans:e,query:{index:qt(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)},Bt.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)},Bt.prototype.toArray=function(e){var o=this;return this._read(function(e){var t=o._ctx;if("next"===t.dir&&jt(t,!0)&&0<t.limit){var n=t.valueMapper,r=qt(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)},Bt.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,jt(e)?Ct(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):Ct(e,function(){var e=t;return function(){return--e<0}})),this},Bt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Ct(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},Bt.prototype.until=function(r,i){return At(this._ctx,function(e,t,n){return!r(e.value)||(t(n),i)}),this},Bt.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Bt.prototype.last=function(e){return this.reverse().first(e)},Bt.prototype.filter=function(t){var e;return At(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=bt(e.isMatch,t),this},Bt.prototype.and=function(e){return this.filter(e)},Bt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Bt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Bt.prototype.desc=function(){return this.reverse()},Bt.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},Bt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Bt.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},Bt.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)},Bt.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&jt(n,!0)&&0<n.limit)return this._read(function(e){var t=qt(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)},Bt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Bt.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Bt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Bt.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 At(this._ctx,function(e){var t=e.primaryKey.toString(),e=m(n,t);return n[t]=!0,!e}),this},Bt.prototype.modify=function(w){var n=this,_=this._ctx;return this._write(function(d){var o,a,p;p="function"==typeof w?w:(o=x(w),a=o.length,function(e){for(var t=!1,n=0;n<a;++n){var r=o[n],i=w[r];k(e,r)!==i&&(O(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=_.table.core,e=v.schema.primaryKey,m=e.outbound,b=e.extractKey,g=n.db._options.modifyChunkSize||200,u=[],s=0,t=[];return n.clone().primaryKeys().then(function(f){function h(c){var l=Math.min(g,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:j(a),primKey:f[c+o]};!1!==p.call(u,u.value,u)&&(null==u.value?i.push(f[c+o]):m||0===xt(b(a),b(u.value))?(t.push(u.value),m&&r.push(f[c+o])):(i.push(f[c+o]),n.push(u.value)))}var s=jt(_)&&_.limit===1/0&&("function"!=typeof w||w===Ft)&&{index:_.index,range:_.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 w)&&v.mutate({trans:d,type:"put",keys:r,values:t,criteria:s,changeSpec:"function"!=typeof w&&w}).then(function(e){return y(t.length,e)})}).then(function(){return(0<i.length||s&&w===Ft)&&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+g)})})}return h(0).then(function(){if(0<u.length)throw new H("Error modifying one or more objects",u,s,t);return f.length})})})},Bt.prototype.delete=function(){var i=this._ctx,n=i.range;return jt(i)&&(i.isPrimKey&&!pt||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(Ft)},Bt);function Bt(){}var Ft=function(e,t){return t.value=null};function Mt(e,t){return e<t?-1:e===t?0:1}function Nt(e,t){return t<e?-1:e===t?0:1}function Lt(e,t,n){e=e instanceof Yt?new e.Collection(e):e;return e._ctx.error=new(n||TypeError)(t),e}function Ut(e){return new e.Collection(e,function(){return Wt("")}).limit(0)}function zt(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 Lt(e,lt);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?Mt:Nt;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 Vt(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 Vt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Wt(e){return{type:1,lower:e,upper:e}}var Yt=(Object.defineProperty(Qt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Qt.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)?Ut(this):new this.Collection(this,function(){return Vt(e,t,!n,!r)})}catch(e){return Lt(this,ct)}},Qt.prototype.equals=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Wt(e)})},Qt.prototype.above=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Vt(e,void 0,!0)})},Qt.prototype.aboveOrEqual=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Vt(e,void 0,!1)})},Qt.prototype.below=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Vt(void 0,e,!1,!0)})},Qt.prototype.belowOrEqual=function(e){return null==e?Lt(this,ct):new this.Collection(this,function(){return Vt(void 0,e)})},Qt.prototype.startsWith=function(e){return"string"!=typeof e?Lt(this,lt):this.between(e,e+st,!0,!0)},Qt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):zt(this,function(e,t){return 0===e.indexOf(t[0])},[e],st)},Qt.prototype.equalsIgnoreCase=function(e){return zt(this,function(e,t){return e===t[0]},[e],"")},Qt.prototype.anyOfIgnoreCase=function(){var e=R.apply(I,arguments);return 0===e.length?Ut(this):zt(this,function(e,t){return-1!==t.indexOf(e)},e,"")},Qt.prototype.startsWithAnyOfIgnoreCase=function(){var e=R.apply(I,arguments);return 0===e.length?Ut(this):zt(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,st)},Qt.prototype.anyOf=function(){var t=this,i=R.apply(I,arguments),o=this._cmp;try{i.sort(o)}catch(e){return Lt(this,ct)}if(0===i.length)return Ut(this);var e=new this.Collection(this,function(){return Vt(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},Qt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Qt.prototype.noneOf=function(){var e=R.apply(I,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Lt(this,ct)}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})},Qt.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 Ut(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&u(e[0],e[1])<=0}))return Lt(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,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 Lt(this,ct)}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 Vt(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},Qt.prototype.startsWithAnyOf=function(){var e=R.apply(I,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Ut(this):this.inAnyRange(e.map(function(e){return[e,e+st]})):Lt(this,"startsWithAnyOf() only works with strings")},Qt);function Qt(){}function Gt(t){return ze(function(e){return Ht(e),t(e.target.error),!1})}function Ht(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Xt="storagemutated",Jt="x-storagemutated-1",$t=Kt(null,Xt),Zt=(en.prototype._lock=function(){return b(!Ee.global),++this._reculock,1!==this._reculock||Ee.global||(Ee.lockOwnerFor=this),this},en.prototype._unlock=function(){if(b(!Ee.global),0==--this._reculock)for(Ee.global||(Ee.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{rt(e[1],e[0])}catch(e){}}return this},en.prototype._locked=function(){return this._reculock&&Ee.lockOwnerFor!==this},en.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(b(!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 b(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||e).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=ze(function(e){Ht(e),n._reject(t.error)}),t.onabort=ze(function(e){Ht(e),n.active&&n._reject(new Z.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=ze(function(){n.active=!1,n._resolve(),"mutatedParts"in t&&$t.storagemutated.fire(t.mutatedParts)}),this},en.prototype._promise=function(n,r,i){var o=this;if("readwrite"===n&&"readwrite"!==this.mode)return at(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return at(new Z.TransactionInactive);if(this._locked())return new Ae(function(e,t){o._blockedFuncs.push([function(){o._promise(n,r,i).then(e,t)},Ee])});if(i)return Xe(function(){var e=new Ae(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 Ae(function(e,t){var n=r(e,t,o);n&&n.then&&n.then(e,t)});return e._lib=!0,e},en.prototype._root=function(){return this.parent?this.parent._root():this},en.prototype.waitFor=function(e){var t,r=this._root(),i=Ae.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 Ae(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)})})},en.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new Z.Abort))},en.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},en);function en(){}function tn(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?"++":"")+nn(t)}}function nn(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function rn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(e){return[e.name,e]},n.reduce(function(e,t,n){n=r(t,n);return n&&(e[n[0]]=n[1]),e},{}))};var r}var on=function(e){try{return e.only([[]]),on=function(){return[[]]},[[]]}catch(e){return on=function(){return st},st}};function an(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 un(e){return[].slice.call(e)}var sn=0;function cn(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function ln(e,i,t){function _(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,w=e.name;return{name:w,schema:e,mutate:function(e){var y=e.trans,v=e.type,m=e.keys,b=e.values,g=e.range;return new Promise(function(t,e){t=ze(t);var n=y.objectStore(w),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||b||{length:1}).length;if(m&&b&&m.length!==b.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,Ht(e)}var s=[],c=[],l=0;if("deleteRange"===v){if(4===g.type)return t({numFailures:l,failures:c,results:[],lastResult:void 0});3===g.type?s.push(o=n.clear()):s.push(o=n.delete(_(g)))}else{var r=i?r?[b,m]:[b,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(w),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=Gt(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(w).get(i);n.onsuccess=function(e){return t(e.target.result)},n.onerror=Gt(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(w),l=l.isPrimaryKey?t:t.index(l.name),s=_(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=Gt(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=Gt(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(w),i=e.isPrimaryKey?i:i.index(e.name),e=u?l?"prevunique":"prev":l?"nextunique":"next",s=!o&&"openKeyCursor"in i?i.openKeyCursor(_(r),e):i.openCursor(_(r),e);s.onerror=Gt(n),s.onsuccess=ze(function(e){var r,i,o,a,u=s.result;u?(u.___id=++sn,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=Gt(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(w),r=o.isPrimaryKey?n:n.index(o.name),n=_(a),r=n?r.count(n):r.count();r.onsuccess=ze(function(e){return t(e.target.result)}),r.onerror=Gt(e)})}}}var r,o,a,u=(o=t,a=un((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=g(e),i={},n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:an(e)},indexes:un(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:g(e),keyPath:e,unique:n,multiEntry:r,extractKey:an(e)};return i[cn(e)]=r}),getIndexByKeyPath:function(e){return i[cn(e)]}};return i[":id"]=n.primaryKey,null!=e&&(i[cn(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 '".concat(e,"' not found"));return c[e]},MIN_KEY:-1/0,MAX_KEY:on(i),schema:t}}function fn(e,t,n,r){var i=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=ln(t,i,r),e.dbcore.reduce(function(e,t){t=t.create;return _(_({},e),t(e))},r))}}function hn(n,e){var t=e.db,e=fn(n._middlewares,t,n._deps,e);n.core=e.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 dn(i,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)&&(e===i.Transaction.prototype||e instanceof i.Transaction?l(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 i.Table(n,r))})})}function pn(n,e){e.forEach(function(e){for(var t in e)e[t]instanceof n.Table&&delete e[t]})}function yn(e,t){return e._cfg.version-t._cfg.version}function vn(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=Ee.transless||Ee;Xe(function(){var s,c,l,f,t,e,h,d;Ee.trans=a,Ee.transless=p,0===r?(x(o).forEach(function(e){bn(i,e,o[e].primKey,o[e].indexes)}),hn(n,i),Ae.follow(function(){return n.on.populate.fire(a)}).catch(u)):(c=r,l=a,f=i,t=[],e=(s=n)._versions,h=s._dbSchema=wn(0,s.idbdb,f),d=!1,e.filter(function(e){return e._cfg.version>=c}).forEach(function(u){t.push(function(){var t=h,e=u._cfg.dbschema;_n(s,t,f),_n(s,e,f),h=s._dbSchema=e;var n=mn(t,e);n.add.forEach(function(e){bn(f,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=f.objectStore(e.name);e.add.forEach(function(e){return gn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),gn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var r=u._cfg.contentUpgrade;if(r&&u._cfg.version>c){hn(s,f),l._memoizedTables={},d=!0;var i=P(e);n.del.forEach(function(e){i[e]=t[e]}),pn(s,[s.Transaction.prototype]),dn(s,[s.Transaction.prototype],x(i),i),l.schema=i;var o,a=B(r);a&&Je();n=Ae.follow(function(){var e;(o=r(l))&&a&&(e=$e.bind(null,null),o.then(e,e))});return o&&"function"==typeof o.then?Ae.resolve(o):n.then(function(){return o})}}),t.push(function(e){var t,n,r;d&&dt||(t=u._cfg.dbschema,n=t,r=e,[].slice.call(r.db.objectStoreNames).forEach(function(e){return null==n[e]&&r.db.deleteObjectStore(e)})),pn(s,[s.Transaction.prototype]),dn(s,[s.Transaction.prototype],s._storeNames,s._dbSchema),l.schema=s._dbSchema})}),function e(){return t.length?Ae.resolve(t.shift()(l.idbtrans)).then(e):Ae.resolve()}().then(function(){var t,n;n=f,x(t=h).forEach(function(e){n.db.objectStoreNames.contains(e)||bn(n,e,t[e].primKey,t[e].indexes)})}).catch(u))})}function mn(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&&!ht)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 bn(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 gn(i,e)}),i}function gn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function wn(e,t,u){var s={};return y(t.objectStoreNames,0).forEach(function(e){for(var t=u.objectStore(e),n=tn(nn(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=tn(o.name,a,!!o.unique,!!o.multiEntry,!1,a&&"string"!=typeof a,!1);r.push(o)}s[e]=rn(e,n,r)}),s}function _n(e,t,n){for(var r=n.db.objectStoreNames,i=0;i<r.length;++i){var o=r[i],a=n.objectStore(o);e._hasGetAll="getAll"in a;for(var u=0;u<a.indexNames.length;++u){var s=a.indexNames[u],c=a.index(s).keyPath,l="string"==typeof c?c:"["+y(c).join("+")+"]";!t[o]||(c=t[o].idxByName[l])&&(c.name=s,delete t[o].idxByName[l],t[o].idxByName[s]=c)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&f.WorkerGlobalScope&&f instanceof f.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}var xn=(kn.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 tn(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),g(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")}),i[e]=rn(e,n,t)}})},kn.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,pn(t,[t._allTables,t,t.Transaction.prototype]),dn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],x(r),r),t._storeNames=x(r),this},kn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=le(this._cfg.contentUpgrade||ne,e),this},kn);function kn(){}function On(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new sr(yt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Pn(e){return e&&"function"==typeof e.databases}function En(e){return Xe(function(){return Ee.letThrough=!0,e()})}function Kn(e){return!("from"in e)}var Sn=function(e,t){if(!this){var n=new Sn;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 jn(e,t,n){var r=xt(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(Kn(e))return u(e,{from:t,to:n,d:1});var i=e.l,r=e.r;if(xt(n,e.from)<0)return i?jn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Dn(e);if(0<xt(t,e.to))return r?jn(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Dn(e);xt(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<xt(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);n=!e.r;i&&!e.l&&An(e,i),r&&n&&An(e,r)}}function An(e,t){Kn(t)||function e(t,n){var r=n.from,i=n.to,o=n.l,n=n.r;jn(t,r,i),o&&e(t,o),n&&e(t,n)}(e,t)}function Cn(e,t){var n=qn(t),r=n.next();if(r.done)return!1;for(var i=r.value,o=qn(e),a=o.next(i.from),u=a.value;!r.done&&!a.done;){if(xt(u.from,i.to)<=0&&0<=xt(u.to,i.from))return!0;xt(i.from,u.from)<0?i=(r=n.next(u.from)).value:u=(a=o.next(i.from)).value}return!1}function qn(e){var n=Kn(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&&xt(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||xt(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 Dn(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=_({},e),r=e[i],e.from=r.from,e.to=r.to,e[i]=r[i],n[i]=r[t],(e[t]=n).d=Tn(n)),e.d=Tn(e)}function Tn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}function In(t,n){return x(n).forEach(function(e){t[e]?An(t[e],n[e]):t[e]=function e(t){var n,r,i={};for(n in t)m(t,n)&&(r=t[n],i[n]=!r||"object"!=typeof r||K.has(r.constructor)?r:e(r));return i}(n[e])}),t}function Rn(t,n){return Object.keys(t).some(function(e){return n[e]&&Cn(n[e],t[e])})}r(Sn.prototype,((e={add:function(e){return An(this,e),this},addKey:function(e){return jn(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return jn(t,e,e)}),this}})[q]=function(){return qn(this)},e));var Bn={},Fn={},Mn=!1;function Nn(e){In(Fn,e),Mn||(Mn=!0,setTimeout(function(){Mn=!1;var e=Fn;Fn={},Ln(e)},0))}function Ln(e,t){void 0===t&&(t=!1);var n,r=new Set;for(n in e){var i,o=/^idb\:\/\/(.*)\/(.*)\//.exec(n);o&&(i=o[1],o=o[2],(o=Bn["idb://".concat(i,"/").concat(o)])&&function(e,t,n,r){for(var i=r&&[],o=0,a=Object.entries(e.queries.query);o<a.length;o++){for(var u=a[o],s=u[0],u=u[1],c=r&&[],l=0,f=u;l<f.length;l++){var h=f[l];h.obsSet&&Rn(t,h.obsSet)?h.subscribers.forEach(function(e){return n.add(e)}):r&&c.push(h)}r&&i.push([s,c])}if(r)for(var d=0,p=i;d<p.length;d++){var y=p[d],s=y[0],c=y[1];e.queries.query[s]=c}}(o,e,r,t))}r.forEach(function(e){return e()})}function Un(f){var h=f._state,r=f._deps.indexedDB;if(h.isBeingOpened||f.idbdb)return h.dbReadyPromise.then(function(){return h.dbOpenError?at(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 Z.DatabaseClosed("db.open() was cancelled")}function n(){return new Ae(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=Gt(n),l.onblocked=ze(f._fireOnBlocked),l.onupgradeneeded=ze(function(e){var t;d=l.transaction,h.autoSchema&&!f._options.allowEmptyDB?(l.onerror=Ht,d.abort(),l.result.close(),(t=r.deleteDatabase(c)).onsuccess=t.onerror=ze(function(){n(new Z.NoSuchDatabase("Database ".concat(c," doesnt exist")))})):(d.onerror=Gt(n),e=e.oldVersion>Math.pow(2,62)?0:e.oldVersion,p=e<1,f.idbdb=l.result,vn(f,e/10,d,n))},n),l.onsuccess=ze(function(){d=null;var e,t,n,r,i,o=f.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=f).verno=t.version/10,n=e._dbSchema=wn(0,t,n),e._storeNames=y(t.objectStoreNames,0),dn(e,[e._allTables],x(n),n)):(_n(f,f._dbSchema,u),((i=mn(wn(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.")),hn(f,u)}catch(e){}ft.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,Pn(o)||u===yt||On(o,i).put({name:u}).catch(ne)),s()},n)}).catch(function(e){return e&&"UnknownError"===e.name&&0<h.PR1398_maxLoop?(h.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),n()):Ae.reject(e)})}var i,o=h.dbReadyResolve,d=null,p=!1;return Ae.race([t,("undefined"==typeof navigator?Ae.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)}i=setInterval(t,100),t()}).finally(function(){return clearInterval(i)}):Promise.resolve()).then(n)]).then(function(){return e(),h.onReadyBeingFired=[],Ae.resolve(En(function(){return f.on.ready.fire(f.vip)})).then(function e(){if(0<h.onReadyBeingFired.length){var t=h.onReadyBeingFired.reduce(le,ne);return h.onReadyBeingFired=[],Ae.resolve(En(function(){return t(f.vip)})).then(e)}})}).finally(function(){h.openCanceller===t&&(h.onReadyBeingFired=null,h.isBeingOpened=!1)}).catch(function(e){h.dbOpenError=e;try{d&&d.abort()}catch(e){}return t===h.openCanceller&&f._close(),at(e)}).finally(function(){h.openComplete=!0,o()}).then(function(){var n;return p&&(n={},f.tables.forEach(function(t){t.schema.indexes.forEach(function(e){e.name&&(n["idb://".concat(f.name,"/").concat(t.name,"/").concat(e.name)]=new Sn(-1/0,[[[]]]))}),n["idb://".concat(f.name,"/").concat(t.name,"/")]=n["idb://".concat(f.name,"/").concat(t.name,"/:dels")]=new Sn(-1/0,[[[]]])}),$t(Xt).fire(n),Ln(n,!0)),f})}function zn(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):g(e)?Promise.all(e).then(r,i):r(e)}}return n(e)()}function Vn(e,t,n){for(var r=g(e)?e.slice():[e],i=0;i<n;++i)r.push(t);return r}var Wn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(f){return _(_({},f),{table:function(e){var a=f.table(e),t=a.schema,u={},s=[];function c(e,t,n){var r=cn(e),i=u[r]=u[r]||[],o=null==e?0:"string"==typeof e?1:e.length,a=0<t,a=_(_({},n),{name:a?"".concat(r,"(virtual-from:").concat(n.name,")"):n.name,lowLevelIndex:n,isVirtual:a,keyTail:t,keyLength:o,extractKey:an(e),unique:!a&&n.unique});return i.push(a),a.isPrimaryKey||s.push(a),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}),a}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?_(_({},e),{query:{index:n.lowLevelIndex,range:(t=e.query.range,n=n.keyTail,{type:1===t.type?2:t.type,lower:Vn(t.lower,t.lowerOpen?f.MAX_KEY:f.MIN_KEY,n),lowerOpen:!0,upper:Vn(t.upper,t.upperOpen?f.MIN_KEY:f.MAX_KEY,n),upperOpen:!0})}}):e}return _(_({},a),{schema:_(_({},t),{primaryKey:e,indexes:s,getIndexByKeyPath:function(e){return(e=u[cn(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(Vn(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(Vn(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 Yn(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=C(t))!==C(n)?a[u+e]=o[e]:"Object"===r?Yn(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}function Qn(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}var Gn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return _(_({},e),{table:function(r){var y=e.table(r),v=y.schema.primaryKey;return _(_({},y),{mutate:function(e){var t=Ee.trans,n=t.table(r).hook,h=n.deleting,d=n.creating,p=n.updating;switch(e.type){case"add":if(d.fire===ne)break;return t._promise("readwrite",function(){return a(e)},!0);case"put":if(d.fire===ne&&p.fire===ne)break;return t._promise("readwrite",function(){return a(e)},!0);case"delete":if(h.fire===ne)break;return t._promise("readwrite",function(){return a(e)},!0);case"deleteRange":if(h.fire===ne)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,_(_({},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=Ee.trans,f=c.keys||Qn(v,c);if(!f)throw new Error("Keys missing");return"delete"!==(c="add"===c.type||"put"===c.type?_(_({},c),{keys:f}):_({},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||O(c.values[t],v.keyPath,e))):(n=Yn(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]:O(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 Hn(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===xt(t.keys[i],e[o])&&(r.push(n?j(t.values[i]):t.values[i]),++o);return r.length===e.length?r:null}catch(e){return null}}var Xn={stack:"dbcore",level:-1,create:function(t){return{table:function(e){var n=t.table(e);return _(_({},n),{getMany:function(t){if(!t.cache)return n.getMany(t);var e=Hn(t.keys,t.trans._cache,"clone"===t.cache);return e?Ae.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 Jn(e,t){return"readonly"===e.trans.mode&&!!e.subscr&&!e.trans.explicit&&"disabled"!==e.trans.db._options.cache&&!t.schema.primaryKey.outbound}function $n(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Zn={stack:"dbcore",level:0,name:"Observability",create:function(r){var m=r.schema.name,b=new Sn(r.MIN_KEY,r.MAX_KEY);return _(_({},r),{transaction:function(e,t,n){if(Ee.subscr&&"readonly"!==t)throw new Z.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(Ee.querier));return r.transaction(e,t,n)},table:function(d){function e(e){var e=(t=e.query).index,t=t.range;return[e,new Sn(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,v=y.primaryKey,c=v.extractKey,l=v.outbound,t=_(_({},p),{mutate:function(t){function n(e){return e="idb://".concat(m,"/").concat(d,"/").concat(e),i[e]||(i[e]=new Sn)}var e,o,a,r=t.trans,i=t.mutatedParts||(t.mutatedParts={}),u=n(""),s=n(":dels"),c=t.type,l="deleteRange"===t.type?[t.range]:"delete"===t.type?[t.keys]:t.values.length<50?[Qn(v,t).filter(function(e){return e}),t.values]:[],f=l[0],h=l[1],l=t.trans._cache;return g(f)?(u.addKeys(f),(l="delete"===c||f.length===h.length?Hn(f,l):null)||"add"===c||s.addKeys(f),(l||h)&&(e=n,o=l,a=h,y.indexes.forEach(function(t){var n=e(t.name||"");function r(e){return null!=e?t.extractKey(e):null}function i(e){return t.multiEntry&&g(e)?e.forEach(function(e){return n.addKey(e)}):n.addKey(e)}(o||a).forEach(function(e,t){var n=o&&r(o[t]),t=a&&r(a[t]);0!==xt(n,t)&&(null!=n&&i(n),null!=t&&i(t))})}))):f?(h={from:f.lower,to:f.upper},s.add(h),u.add(h)):(u.add(b),s.add(b),y.indexes.forEach(function(e){return n(e.name).add(b)})),p.mutate(t).then(function(e){return!f||"add"!==t.type&&"put"!==t.type||u.addKeys(e.results),r.mutatedParts=In(r.mutatedParts||{},i),e})}}),f={get:function(e){return[v,new Sn(e.key)]},getMany:function(e){return[v,(new Sn).addKeys(e.keys)]},count:e,query:e,openCursor:e};return x(f).forEach(function(s){t[s]=function(i){var e=Ee.subscr,t=!!e,n=Jn(Ee,p)&&$n(s,i)?i.obsSet={}:e;if(t){var r=function(e){e="idb://".concat(m,"/").concat(d,"/").concat(e);return n[e]||(n[e]=new Sn)},o=r(""),a=r(":dels"),e=f[s](i),t=e[0],e=e[1];if(r(t.name||"").add(e),!t.isPrimaryKey){if("count"!==s){var u="query"===s&&l&&i.values&&p.query(_(_({},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(b)}}return p[s].apply(this,arguments)}}),t}})}};function er(e,t,n){if(0===n.numFailures)return t;if("deleteRange"===t.type)return null;var r=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1;if(n.numFailures===r)return null;t=_({},t);return g(t.keys)&&(t.keys=t.keys.filter(function(e,t){return!(t in n.failures)})),"values"in t&&g(t.values)&&(t.values=t.values.filter(function(e,t){return!(t in n.failures)})),t}function tr(e,t){return n=e,(void 0===(r=t).lower||(r.lowerOpen?0<xt(n,r.lower):0<=xt(n,r.lower)))&&(e=e,void 0===(t=t).upper||(t.upperOpen?xt(e,t.upper)<0:xt(e,t.upper)<=0));var n,r}function nr(e,u,t,n,r,s){if(!t||0===t.length)return e;var i=u.query.index,c=n.schema.primaryKey.extractKey,l=i.extractKey,o=(i.lowLevelIndex||i).extractKey,t=t.reduce(function(e,t){var n=e,r="add"===t.type||"put"===t.type?t.values.filter(function(e){return tr(l(e),u.query.range)}).map(function(e){return e=j(e),s&&Object.freeze(e),e}):[];switch(t.type){case"add":n=e.concat(u.values?r:r.map(function(e){return c(e)}));break;case"put":var i=(new Sn).addKeys(t.values.map(function(e){return c(e)})),n=e.filter(function(e){e=u.values?c(e):e;return!Cn(new Sn(e),i)}).concat(u.values?r:r.map(function(e){return c(e)}));break;case"delete":var o=(new Sn).addKeys(t.keys);n=e.filter(function(e){e=u.values?c(e):e;return!Cn(new Sn(e),o)});break;case"deleteRange":var a=t.range;n=e.filter(function(e){return!tr(c(e),a)})}return n},e);return t===e?e:(t.sort(function(e,t){return xt(o(e),o(t))||xt(c(e),c(t))}),u.limit&&u.limit<1/0&&(t.length>u.limit?t.length=u.limit:e.length===u.limit&&t.length<u.limit&&(r.dirty=!0)),s?Object.freeze(t):t)}function rr(e,t){return 0===xt(e.lower,t.lower)&&0===xt(e.upper,t.upper)&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function ir(e,t){return function(e,t,n,r){if(void 0===e)return void 0!==t?-1:0;if(void 0===t)return 1;if(0===(t=xt(e,t))){if(n&&r)return 0;if(n)return 1;if(r)return-1}return t}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(e,t,n,r){if(void 0===e)return void 0!==t?1:0;if(void 0===t)return-1;if(0===(t=xt(e,t))){if(n&&r)return 0;if(n)return-1;if(r)return 1}return t}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function or(n,r,i,e){n.subscribers.add(i),e.addEventListener("abort",function(){var e,t;n.subscribers.delete(i),0===n.subscribers.size&&(e=n,t=r,setTimeout(function(){0===e.subscribers.size&&T(t,e)},3e3))})}var ar={stack:"dbcore",level:0,name:"Cache",create:function(g){var w=g.schema.name;return _(_({},g),{transaction:function(y,v,e){var m,t,b=g.transaction(y,v,e);return"readwrite"===v&&(t=(m=new AbortController).signal,e=function(p){return function(){if(m.abort(),"readwrite"===v){for(var t=new Set,e=0,n=y;e<n.length;e++){var r=n[e],i=Bn["idb://".concat(w,"/").concat(r)],o=g.table(r);if(i){var a=i.optimisticOps.filter(function(e){return e.trans===b});if(0<a.length){i.optimisticOps=i.optimisticOps.filter(function(e){return e.trans!==b});for(var u=0,s=Object.values(i.queries.query);u<s.length;u++)for(var c=s[u],l=0,f=c.slice();l<f.length;l++){var h,d=f[l];null!=d.res&&b.mutatedParts&&(p&&!d.dirty?(h=Object.isFrozen(d.res),h=nr(d.res,d.req,a,o,d,h),d.dirty?(T(c,d),d.subscribers.forEach(function(e){return t.add(e)})):h!==d.res&&(d.res=h,d.promise=Ae.resolve({result:h}))):(d.dirty&&T(c,d),d.subscribers.forEach(function(e){return t.add(e)})))}}}}t.forEach(function(e){return e()})}}},b.addEventListener("abort",e(!1),{signal:t}),b.addEventListener("error",e(!1),{signal:t}),b.addEventListener("complete",e(!0),{signal:t})),b},table:function(c){var l=g.table(c),i=l.schema.primaryKey;return _(_({},l),{mutate:function(t){if(i.outbound||"disabled"===Ee.trans.db._options.cache)return l.mutate(t);var r=Bn["idb://".concat(w,"/").concat(c)];if(!r)return l.mutate(t);var e=l.mutate(t);return"add"!==t.type&&"put"!==t.type||!(50<=t.values.length||Qn(i,t).some(function(e){return null==e}))?(r.optimisticOps.push(t),Nn(t.mutatedParts),e.then(function(e){0<e.numFailures&&(T(r.optimisticOps,t),(e=er(0,t,e))&&r.optimisticOps.push(e),Nn(t.mutatedParts))}),e.catch(function(){T(r.optimisticOps,t),Nn(t.mutatedParts)})):e.then(function(n){var e=er(0,_(_({},t),{values:t.values.map(function(e,t){e=i.keyPath.includes(".")?j(e):_({},e);return O(e,i.keyPath,n.results[t]),e})}),n);r.optimisticOps.push(e),queueMicrotask(function(){return Nn(t.mutatedParts)})}),e},query:function(t){if(!Jn(Ee,l)||!$n("query",t))return l.query(t);var i="immutable"===Ee.trans.db._options.cache,e=Ee,n=e.requery,r=e.signal,o=function(e,t,n,r){var i=Bn["idb://".concat(e,"/").concat(t)];if(!i)return[];if(!(t=i.queries[n]))return[null,!1,i,null];var o=t[(r.query?r.query.index.name:null)||""];if(!o)return[null,!1,i,null];switch(n){case"query":var a=o.find(function(e){return e.req.limit===r.limit&&e.req.values===r.values&&rr(e.req.query.range,r.query.range)});return a?[a,!0,i,o]:[o.find(function(e){return("limit"in e.req?e.req.limit:1/0)>=r.limit&&(!r.values||e.req.values)&&ir(e.req.query.range,r.query.range)}),!1,i,o];case"count":a=o.find(function(e){return rr(e.req.query.range,r.query.range)});return[a,!!a,i,o]}}(w,c,"query",t),a=o[0],e=o[1],u=o[2],s=o[3];return a&&e?a.obsSet=t.obsSet:(e=l.query(t).then(function(e){var t=e.result;if(a.res=t,i){for(var n=0,r=t.length;n<r;++n)Object.freeze(t[n]);Object.freeze(t)}else e.result=j(t);return e}).catch(function(e){return s&&a&&T(s,a),Promise.reject(e)}),a={obsSet:t.obsSet,promise:e,subscribers:new Set,type:"query",req:t,dirty:!1},s?s.push(a):(s=[a],(u=u||(Bn["idb://".concat(w,"/").concat(c)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[t.query.index.name||""]=s)),or(a,s,n,r),a.promise.then(function(e){return{result:nr(e.result,t,null==u?void 0:u.optimisticOps,l,a,i)}})}})}})}};function ur(e,r){return new Proxy(e,{get:function(e,t,n){return"db"===t?r:Reflect.get(e,t,n)}})}var sr=(cr.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(yn),n.stores({}),this._state.autoSchema=!1,n)},cr.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||Ee.letThrough||this._vip)?e():new Ae(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(ne)}n._state.dbReadyPromise.then(e,t)}).then(e)},cr.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},cr.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},cr.prototype.open=function(){var e=this;return rt(Pe,function(){return Un(e)})},cr.prototype._close=function(){var n=this._state,e=ft.indexOf(this);if(0<=e&&ft.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(e){}this.idbdb=null}n.dbReadyPromise=new Ae(function(e){n.dbReadyResolve=e}),n.openCanceller=new Ae(function(e,t){n.cancelOpen=t})},cr.prototype.close=function(e){var t=(void 0===e?{disableAutoOpen:!0}:e).disableAutoOpen;this._close();e=this._state;t&&(this._options.autoOpen=!1),e.dbOpenError=new Z.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)},cr.prototype.delete=function(){var i=this,n=0<arguments.length,o=this._state;return new Ae(function(r,t){function e(){i.close({disableAutoOpen:!1});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,Pn(n)||t===yt||On(n,e).delete(t).catch(ne),r()}),e.onerror=Gt(t),e.onblocked=i._fireOnBlocked}if(n)throw new Z.InvalidArgument("Arguments not allowed in db.delete()");o.isBeingOpened?o.dbReadyPromise.then(e):e()})},cr.prototype.backendDB=function(){return this.idbdb},cr.prototype.isOpen=function(){return null!==this.idbdb},cr.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},cr.prototype.hasFailed=function(){return null!==this._state.dbOpenError},cr.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(cr.prototype,"tables",{get:function(){var t=this;return x(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),cr.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 i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,E(i),n]}.apply(this,arguments);return this._transaction.apply(this,e)},cr.prototype._transaction=function(e,t,n){var r=this,i=Ee.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===vt)o=vt;else{if("rw"!=e&&e!=mt)throw new Z.InvalidArgument("Invalid transaction mode: "+e);o=mt}if(i){if(i.mode===vt&&o===mt){if(!u)throw new Z.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 Z.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)}):at(n)}var s=function i(o,a,u,s,c){return Ae.resolve().then(function(){var e=Ee.transless||Ee,t=o._createTransaction(a,u,o._dbSchema,s);if(t.explicit=!0,e={trans:t,transless:e},s)t.idbtrans=s.idbtrans;else try{t.create(),o._state.PR1398_maxLoop=3}catch(e){return e.name===J.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)})):at(e)}var n,r=B(c);return r&&Je(),e=Ae.follow(function(){var e;(n=c.call(t,t))&&(r?(e=$e.bind(null,null),n.then(e,e)):"function"==typeof n.next&&"function"==typeof n.throw&&(n=zn(n)))},e),(n&&"function"==typeof n.then?Ae.resolve(n).then(function(e){return t.active?e:at(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),at(e)})})}.bind(null,this,o,a,i,n);return i?i._promise(o,s,"lock"):Ee.trans?rt(Ee.transless,function(){return r._whenReady(s)}):this._whenReady(s)},cr.prototype.table=function(e){if(!m(this._allTables,e))throw new Z.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},cr);function cr(e,t){var o=this;this._middlewares={},this.verno=0;var n=cr.dependencies;this._options=t=_({addons:cr.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,cache:"cloned"},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:ne,dbReadyPromise:null,cancelOpen:ne,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};c.dbReadyPromise=new Ae(function(e){c.dbReadyResolve=e}),c.openCanceller=new Ae(function(e,t){c.cancelOpen=t}),this._state=c,this.name=e,this.on=Kt(this,"populate","blocked","versionchange","close",{ready:[le,ne]}),this.on.ready.subscribe=v(this.on.ready.subscribe,function(i){return function(n,r){cr.vip(function(){var t,e=o._state;e.openComplete?(e.dbOpenError||Ae.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,St(Rt.prototype,function(e,t){this.db=a;var n=gt,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!==re?e:null}})),this.Table=(r=this,St(Pt.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:Kt(null,{creating:[ae,ne],reading:[ie,re],updating:[se,ne],deleting:[ue,ne]})})),this.Transaction=(u=this,St(Zt.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=Kt(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 Ae(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(),at(e)})})),this.Version=(i=this,St(xn.prototype,function(e){this.db=i,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,St(Yt.prototype,function(e,t,n){if(this.db=s,this._ctx={table:e,index:":id"===t?null:t,or:n},this._cmp=this._ascending=xt,this._descending=function(e,t){return xt(t,e)},this._max=function(e,t){return 0<xt(e,t)?e:t},this._min=function(e,t){return xt(e,t)<0?e:t},this._IDBKeyRange=s._deps.IDBKeyRange,!this._IDBKeyRange)throw new Z.MissingAPI})),this.on("versionchange",function(e){0<e.newVersion?console.warn("Another connection wants to upgrade database '".concat(o.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(o.name,"'. Closing db now to resume the delete request.")),o.close({disableAutoOpen:!1}),o._state.openComplete=!1}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('".concat(o.name,"') was blocked")):console.warn("Upgrade '".concat(o.name,"' blocked by other connection holding version ").concat(e.oldVersion/10))}),this._maxKey=on(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),ft.filter(function(e){return e.name===o.name&&e!==o&&!e._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(Xn),this.use(ar),this.use(Zn),this.use(Wn),this.use(Gn);var l=new Proxy(this,{get:function(e,t,n){if("_vip"===t)return!0;if("table"===t)return function(e){return ur(o.table(e),l)};var r=Reflect.get(e,t,n);return r instanceof Pt?ur(r,l):"tables"===t?r.map(function(e){return ur(e,l)}):"_createTransaction"===t?function(){return ur(r.apply(this,arguments),l)}:r}});this.vip=l,n.forEach(function(e){return e(o)})}var lr,e="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable",fr=(hr.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},hr.prototype[e]=function(){return this},hr);function hr(e){this._subscribe=e}try{lr={indexedDB:f.indexedDB||f.mozIndexedDB||f.webkitIndexedDB||f.msIndexedDB,IDBKeyRange:f.IDBKeyRange||f.webkitIDBKeyRange}}catch(e){lr={indexedDB:null,IDBKeyRange:null}}function dr(h){var d,p=!1,e=new fr(function(r){var i=B(h);var o,a=!1,u={},s={},e={get closed(){return a},unsubscribe:function(){a||(a=!0,o&&o.abort(),c&&$t.storagemutated.unsubscribe(l))}};r.start&&r.start(e);var c=!1;var l=function(e){In(u,e),Rn(s,u)&&f()},t=function(){var t,n,e;!a&&lr.indexedDB&&(u={},t={},o&&o.abort(),o=new AbortController,e=function(e){var t=Me();try{i&&Je();var n=Xe(h,e);return i&&(n=n.finally($e)),Promise.resolve(n).finally(function(){return Ee.subscr===e.subscr?(console.warn("Dexie liveQuery()'s querier callback did'nt await all of its spawned promises. Querier source: ".concat(h)),new ye(function(e){return setTimeout(e,0)})):Promise.PSD?new ye(function(e){return setTimeout(e,0)}):void 0})}finally{t&&Ne()}}(n={subscr:t,signal:o.signal,requery:f,querier:h,trans:null}),Promise.resolve(e).then(function(e){p=!0,d=e,a||n.signal.aborted||(u={},function(e){for(var t in e)if(m(e,t))return;return 1}(s=t)||c||($t(Xt,l),c=!0),r.next&&r.next(e))},function(e){p=!1,["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||a||r.error&&r.error(e)}))},f=function(){Ee.global&&!Promise.PSD?t():setTimeout(t,0)};return f(),e});return e.hasValue=function(){return p},e.getValue=function(){return d},e}var pr=sr;function yr(e){var t=mr;try{mr=!0,$t.storagemutated.fire(e),Ln(e,!0)}finally{mr=t}}r(pr,_(_({},te),{delete:function(e){return new pr(e,{addons:[]}).delete()},exists:function(e){return new pr(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=pr.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Pn(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==yt})}):On(n,t).toCollection().primaryKeys()).then(e)}catch(e){return at(new Z.MissingAPI)}var t,n},defineClass:function(){return function(e){u(this,e)}},ignoreTransaction:function(e){return Ee.trans?rt(Ee.transless,e):e()},vip:En,async:function(t){return function(){try{var e=zn(t.apply(this,arguments));return e&&"function"==typeof e.then?e:Ae.resolve(e)}catch(e){return at(e)}}},spawn:function(e,t,n){try{var r=zn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Ae.resolve(r)}catch(e){return at(e)}},currentTransaction:{get:function(){return Ee.trans||null}},waitFor:function(e,t){t=Ae.resolve("function"==typeof e?pr.ignoreTransaction(e):e).timeout(t||6e4);return Ee.trans?Ee.trans.waitFor(t):t},Promise:Ae,debug:{get:function(){return F},set:function(e){M(e,"dexie"===e?function(){return!0}:ut)}},derive:o,extend:u,props:r,override:v,Events:Kt,on:$t,liveQuery:dr,extendObservabilitySet:In,getByKeyPath:k,setByKeyPath:O,delByKeyPath:function(t,e){"string"==typeof e?O(t,e,void 0):"length"in e&&[].map.call(e,function(e){O(t,e,void 0)})},shallowClone:P,deepClone:j,getObjectDiff:Yn,cmp:xt,asap:w,minKey:-1/0,addons:[],connections:ft,errnames:J,dependencies:lr,cache:Bn,semVer:W,version:W.split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),pr.maxKey=on(pr.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&($t(Xt,function(e){var t;mr||(ht?(t=document.createEvent("CustomEvent")).initCustomEvent(Jt,!0,!0,e):t=new CustomEvent(Jt,{detail:e}),mr=!0,dispatchEvent(t),mr=!1)}),addEventListener(Jt,function(e){e=e.detail;mr||yr(e)}));var vr,mr=!1;return"undefined"!=typeof BroadcastChannel?("function"==typeof(vr=new BroadcastChannel(Jt)).unref&&vr.unref(),$t(Xt,function(e){mr||vr.postMessage(e)}),vr.onmessage=function(e){e.data&&yr(e.data)}):"undefined"!=typeof self&&"undefined"!=typeof navigator&&($t(Xt,function(t){try{mr||("undefined"!=typeof localStorage&&localStorage.setItem(Jt,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:Jt,changedParts:t})}))}catch(e){}}),"undefined"!=typeof addEventListener&&addEventListener("storage",function(e){e.key!==Jt||(e=JSON.parse(e.newValue))&&yr(e.changedParts)}),(W=self.document&&navigator.serviceWorker)&&W.addEventListener("message",function(e){e=e.data;e&&e.type===Jt&&yr(e.changedParts)})),Ae.rejectionMapper=function(e,t){return!e||e instanceof Q||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ee[e.name]?e:(t=new ee[e.name](t||e.message,e),"stack"in e&&l(t,"stack",{get:function(){return this.inner.stack}}),t)},M(F,ut),_(sr,Object.freeze({__proto__:null,Dexie:sr,liveQuery:dr,Entity:_t,cmp:xt,default:sr,RangeSet:Sn,mergeRanges:An,rangesOverlap:Cn}),{default:sr}),sr});
2
2
  //# sourceMappingURL=dexie.min.js.map