dexie 4.0.1-alpha.7 → 4.0.1-alpha.8

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.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-alpha.7, Wed Jan 25 2023
7
+ * Version 4.0.1-alpha.8, Fri Feb 17 2023
8
8
  *
9
9
  * https://dexie.org
10
10
  *
package/dist/dexie.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-alpha.7, Wed Jan 25 2023
7
+ * Version 4.0.1-alpha.8, Fri Feb 17 2023
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1300,7 +1300,7 @@
1300
1300
  }
1301
1301
  }
1302
1302
 
1303
- var DEXIE_VERSION = '4.0.1-alpha.7';
1303
+ var DEXIE_VERSION = '4.0.1-alpha.8';
1304
1304
  var maxString = String.fromCharCode(65535);
1305
1305
  var minKey = -Infinity;
1306
1306
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
package/dist/dexie.min.js CHANGED
@@ -1 +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 g=function(){return(g=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function o(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=Object.keys,b=Array.isArray;function u(t,n){return"object"!=typeof n||x(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||h.Promise||(h.Promise=Promise);var c=Object.getPrototypeOf,n={}.hasOwnProperty;function m(e,t){return n.call(e,t)}function r(t,n){"function"==typeof n&&(n=n(c(t))),("undefined"==typeof Reflect?x:Reflect.ownKeys)(n).forEach(function(e){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 i(t){return{from:function(e){return t.prototype=Object.create(e.prototype),l(t.prototype,"constructor",t),{extend:r.bind(null,t.prototype)}}}}var f=Object.getOwnPropertyDescriptor;function d(e,t){return f(e,t)||(e=c(e))&&d(e,t)}var p=[].slice;function y(e,t,n){return p.call(e,t,n)}function v(e,t){return t(e)}function _(e){if(!e)throw new Error("Assertion Failed")}function w(e){h.setImmediate?setImmediate(e):setTimeout(e,0)}function k(e,r){return e.reduce(function(e,t,n){n=r(t,n);return n&&(e[n[0]]=n[1]),e},{})}function E(e,t){if(m(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,o=t.length;r<o;++r){var i=E(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var u=e[t.substr(0,a)];return void 0===u?void 0:E(u,t.substr(a+1))}}function P(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){_("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)P(e,t[r],n[r])}else{var i,a,u=t.indexOf(".");-1!==u?(i=t.substr(0,u),""===(a=t.substr(u+1))?void 0===n?b(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n:P(u=!(u=e[i])||!m(e,i)?e[i]={}:u,a,n)):void 0===n?b(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function O(e){var t,n={};for(t in e)m(e,t)&&(n[t]=e[t]);return n}var t=[].concat;function K(e){return t.apply([],e)}var e="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(K([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return h[e]}),S=e.map(function(e){return h[e]});k(e,function(e){return[e,!0]});var j=null;function A(e){j="undefined"!=typeof WeakMap&&new WeakMap;e=function e(t){if(!t||"object"!=typeof t)return t;var n=j&&j.get(t);if(n)return n;if(b(t)){n=[],j&&j.set(t,n);for(var r=0,o=t.length;r<o;++r)n.push(e(t[r]))}else if(0<=S.indexOf(t.constructor))n=t;else{var i,a=c(t);for(i in n=a===Object.prototype?{}:Object.create(a),j&&j.set(t,n),t)m(t,i)&&(n[i]=e(t[i]))}return n}(e);return j=null,e}var C={}.toString;function D(e){return C.call(e).slice(8,-1)}var I="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",T="symbol"==typeof I?function(e){var t;return null!=e&&(t=e[I])&&t.apply(e)}:function(){return null},B={};function R(e){var t,n,r,o;if(1===arguments.length){if(b(e))return e.slice();if(this===B&&"string"==typeof e)return[e];if(o=T(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var F="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},M="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function N(e,t){M=e,q=t}var q=function(){return!0},U=!new Error("").stack;function L(){if(U)try{throw new Error}catch(e){return e}return new Error}function V(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(q).map(function(e){return"\n"+e}).join("")):""}var W=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],z=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(W),Y={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function G(e,t){this._e=L(),this.name=e,this.message=t}function H(e,t){return e+". Errors: "+Object.keys(t).map(function(e){return t[e].toString()}).filter(function(e,t,n){return n.indexOf(e)===t}).join("\n")}function Q(e,t,n,r){this._e=L(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=H(e,t)}function X(e,t){this._e=L(),this.name="BulkError",this.failures=Object.keys(t).map(function(e){return t[e]}),this.failuresByPos=t,this.message=H(e,this.failures)}i(G).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+V(this._e,2))}},toString:function(){return this.name+": "+this.message}}),i(Q).from(G),i(X).from(G);var J=z.reduce(function(e,t){return e[t]=t+"Error",e},{}),$=G,Z=z.reduce(function(e,n){var r=n+"Error";function t(e,t){this._e=L(),this.name=r,e?"string"==typeof e?(this.message="".concat(e).concat(t?"\n "+t:""),this.inner=t||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=Y[n]||r,this.inner=null)}return i(t).from($),e[n]=t,e},{});Z.Syntax=SyntaxError,Z.Type=TypeError,Z.Range=RangeError;var ee=W.reduce(function(e,t){return e[t+"Error"]=Z[t],e},{});e=z.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=Z[t]),e},{});function te(){}function ne(e){return e}function re(t,n){return null==t||t===ne?n:function(e){return n(t(e))}}function oe(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ie(o,i){return o===te?i:function(){var e=o.apply(this,arguments);void 0!==e&&(arguments[0]=e);var t=this.onsuccess,n=this.onerror;this.onsuccess=null,this.onerror=null;var r=i.apply(this,arguments);return t&&(this.onsuccess=this.onsuccess?oe(t,this.onsuccess):t),n&&(this.onerror=this.onerror?oe(n,this.onerror):n),void 0!==r?r:e}}function ae(n,r){return n===te?r:function(){n.apply(this,arguments);var e=this.onsuccess,t=this.onerror;this.onsuccess=this.onerror=null,r.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?oe(e,this.onsuccess):e),t&&(this.onerror=this.onerror?oe(t,this.onerror):t)}}function ue(o,i){return o===te?i:function(e){var t=o.apply(this,arguments);u(e,t);var n=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;e=i.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?oe(n,this.onsuccess):n),r&&(this.onerror=this.onerror?oe(r,this.onerror):r),void 0===t?void 0===e?void 0:e:u(t,e)}}function se(e,t){return e===te?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ce(o,i){return o===te?i:function(){var e=o.apply(this,arguments);if(e&&"function"==typeof e.then){for(var t=this,n=arguments.length,r=new Array(n);n--;)r[n]=arguments[n];return e.then(function(){return i.apply(t,r)})}return i.apply(this,arguments)}}e.ModifyError=Q,e.DexieError=G,e.BulkError=X;var le={},fe=100,he=100,W="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,c(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,c(t),e]}(),de=W[0],pe=W[1],ye=W[2],ve=pe&&pe.then,me=de&&de.constructor,ge=!!ye,be=!1,_e=ye?function(){ye.then(Ue)}:h.setImmediate?setImmediate.bind(null,Ue):h.MutationObserver?function(){var e=document.createElement("div");new MutationObserver(function(){Ue(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:function(){setTimeout(Ue,0)},we=function(e,t){Ae.push([e,t]),ke&&(_e(),ke=!1)},xe=!0,ke=!0,Ee=[],Pe=[],Oe=null,Ke=ne,Se={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ft,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(function(e){try{ft(e[0],e[1])}catch(e){}})}},je=Se,Ae=[],Ce=0,De=[];function Ie(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=te,this._lib=!1;var t=this._PSD=je;if(M&&(this._stackHolder=L(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==le)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Re(this,this._value))}this._state=null,this._value=null,++t.ref,function t(r,e){try{e(function(n){if(null===r._state){if(n===r)throw new TypeError("A promise cannot be resolved with itself.");var e=r._lib&&Le();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof Ie?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Fe(r)),e&&Ve()}},Re.bind(null,r))}catch(e){Re(r,e)}}(this,e)}var Te={get:function(){var u=je,t=Je;function e(n,r){var o=this,i=!u.global&&(u!==je||t!==Je),a=i&&!tt(),e=new Ie(function(e,t){Me(o,new Be(st(n,u,i,a),st(r,u,i,a),e,t,u))});return M&&qe(e,this),e}return e.prototype=le,e},set:function(e){l(this,"then",e&&e.prototype===le?Te:{get:function(){return e},set:Te.set})}};function Be(e,t,n,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=o}function Re(t,n){var e,r;Pe.push(n),null===t._state&&(e=t._lib&&Le(),n=Ke(n),t._state=!1,t._value=n,M&&null!==n&&"object"==typeof n&&!n._promise&&function(e,t,n){try{e.apply(null,n)}catch(e){t&&t(e)}}(function(){var e=d(n,"stack");n._promise=t,l(n,"stack",{get:function(){return be?e&&(e.get?e.get.apply(n):e.value):t.stack}})}),r=t,Ee.some(function(e){return e._value===r._value})||Ee.push(r),Fe(t),e&&Ve())}function Fe(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Me(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===Ce&&(++Ce,we(function(){0==--Ce&&We()},[]))}function Me(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Ce,we(Ne,[n,e,t])}else e._listeners.push(t)}function Ne(e,t,n){try{var r,o=(Oe=t)._value;t._state?r=e(o):(Pe.length&&(Pe=[]),r=e(o),-1===Pe.indexOf(o)&&function(e){var t=Ee.length;for(;t;)if(Ee[--t]._value===e._value)return Ee.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{Oe=null,0==--Ce&&We(),--n.psd.ref||n.psd.finalize()}}function qe(e,t){var n=t?t._numPrev+1:0;n<fe&&(e._prev=t,e._numPrev=n)}function Ue(){Le()&&Ve()}function Le(){var e=xe;return ke=xe=!1,e}function Ve(){var e,t,n;do{for(;0<Ae.length;)for(e=Ae,Ae=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<Ae.length);ke=xe=!0}function We(){var e=Ee;Ee=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=De.slice(0),n=t.length;n;)t[--n]()}function ze(e){return new Ie(le,!1,e)}function Ye(n,r){var o=je;return function(){var e=Le(),t=je;try{return ot(o,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{ot(t,!1),e&&Ve()}}}r(Ie.prototype,{then:Te,_then:function(e,t){Me(this,new Be(null,null,e,t,je))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=e,n=arguments[1];return"function"==typeof t?this.then(null,function(e){return(e instanceof t?n:ze)(e)}):this.then(null,function(e){return(e&&e.name===t?n:ze)(e)})},finally:function(t){return this.then(function(e){return t(),e},function(e){return t(),ze(e)})},stack:{get:function(){if(this._stack)return this._stack;try{be=!0;var e=function e(t,n,r){if(n.length===r)return n;var o="";{var i,a,u;!1===t._state&&(null!=(i=t._value)?(a=i.name||"Error",u=i.message||i,o=V(i,0)):(a=i,u=""),n.push(a+(u?": "+u:"")+o))}M&&((o=V(t._stackHolder,2))&&-1===n.indexOf(o)&&n.push(o),t._prev&&e(t._prev,n,r));return n}(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{be=!1}}},timeout:function(r,o){var i=this;return r<1/0?new Ie(function(e,t){var n=setTimeout(function(){return t(new Z.Timeout(o))},r);i.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&l(Ie.prototype,Symbol.toStringTag,"Dexie.Promise"),Se.env=it(),r(Ie,{all:function(){var i=R.apply(null,arguments).map(nt);return new Ie(function(n,r){0===i.length&&n([]);var o=i.length;i.forEach(function(e,t){return Ie.resolve(e).then(function(e){i[t]=e,--o||n(i)},r)})})},resolve:function(n){if(n instanceof Ie)return n;if(n&&"function"==typeof n.then)return new Ie(function(e,t){n.then(e,t)});var e=new Ie(le,!0,n);return qe(e,Oe),e},reject:ze,race:function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(t,n){e.map(function(e){return Ie.resolve(e).then(t,n)})})},PSD:{get:function(){return je},set:function(e){return je=e}},totalEchoes:{get:function(){return Je}},newPSD:Ze,usePSD:at,scheduler:{get:function(){return we},set:function(e){we=e}},rejectionMapper:{get:function(){return Ke},set:function(e){Ke=e}},follow:function(o,n){return new Ie(function(e,t){return Ze(function(n,r){var e=je;e.unhandleds=[],e.onunhandled=r,e.finalize=oe(function(){var t,e=this;t=function(){0===e.unhandleds.length?n():r(e.unhandleds[0])},De.push(function e(){t(),De.splice(De.indexOf(e),1)}),++Ce,we(function(){0==--Ce&&We()},[])},e.finalize),o()},n,e,t)})}}),me&&(me.allSettled&&l(Ie,"allSettled",function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(n){0===e.length&&n([]);var r=e.length,o=new Array(r);e.forEach(function(e,t){return Ie.resolve(e).then(function(e){return o[t]={status:"fulfilled",value:e}},function(e){return o[t]={status:"rejected",reason:e}}).then(function(){return--r||n(o)})})})}),me.any&&"undefined"!=typeof AggregateError&&l(Ie,"any",function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(n,r){0===e.length&&r(new AggregateError([]));var o=e.length,i=new Array(o);e.forEach(function(e,t){return Ie.resolve(e).then(function(e){return n(e)},function(e){i[t]=e,--o||r(new AggregateError(i))})})})}));var Ge={awaits:0,echoes:0,id:0},He=0,Qe=[],Xe=0,Je=0,$e=0;function Ze(e,t,n,r){var o=je,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++$e;var a=Se.env;i.env=ge?{Promise:Ie,PromiseProp:{value:Ie,configurable:!0,writable:!0},all:Ie.all,race:Ie.race,allSettled:Ie.allSettled,any:Ie.any,resolve:Ie.resolve,reject:Ie.reject,nthen:ct(a.nthen,i),gthen:ct(a.gthen,i)}:{},t&&u(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};r=at(i,e,n,r);return 0===i.ref&&i.finalize(),r}function et(){return Ge.id||(Ge.id=++He),++Ge.awaits,Ge.echoes+=he,Ge.id}function tt(){return!!Ge.awaits&&(0==--Ge.awaits&&(Ge.id=0),Ge.echoes=Ge.awaits*he,!0)}function nt(e){return Ge.echoes&&e&&e.constructor===me?(et(),e.then(function(e){return tt(),e},function(e){return tt(),ht(e)})):e}function rt(){var e=Qe[Qe.length-1];Qe.pop(),ot(e,!1)}function ot(e,t){var n,r=je;(t?!Ge.echoes||Xe++&&e===je:!Xe||--Xe&&e===je)||ut(t?function(e){++Je,Ge.echoes&&0!=--Ge.echoes||(Ge.echoes=Ge.id=0),Qe.push(je),ot(e,!0)}.bind(null,e):rt),e!==je&&(je=e,r===Se&&(Se.env=it()),ge&&(n=Se.env.Promise,t=e.env,pe.then=t.nthen,n.prototype.then=t.gthen,(r.global||e.global)&&(Object.defineProperty(h,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function it(){var e=h.Promise;return ge?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(h,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:pe.then,gthen:e.prototype.then}:{}}function at(e,t,n,r,o){var i=je;try{return ot(e,!0),t(n,r,o)}finally{ot(i,!1)}}function ut(e){ve.call(de,e)}function st(t,n,r,o){return"function"!=typeof t?t:function(){var e=je;r&&et(),ot(n,!0);try{return t.apply(this,arguments)}finally{ot(e,!1),o&&ut(tt)}}}function ct(n,r){return function(e,t){return n.call(this,st(e,r),st(t,r))}}-1===(""+ve).indexOf("[native code]")&&(et=tt=te);var lt="unhandledrejection";function ft(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,o={promise:t,reason:e};if(h.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(lt,!0,!0),u(r,o)):h.CustomEvent&&u(r=new CustomEvent(lt,{detail:o}),o),r&&h.dispatchEvent&&(dispatchEvent(r),!h.PromiseRejectionEvent&&h.onunhandledrejection))try{h.onunhandledrejection(r)}catch(e){}M&&r&&!r.defaultPrevented&&console.warn("Unhandled rejection: ".concat(e.stack||e))}catch(e){}}var ht=Ie.reject;function dt(e){return!/(dexie\.js|dexie\.min\.js)/.test(e)}var z="4.0.1-alpha.7",pt=String.fromCharCode(65535),yt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",vt="String expected.",mt=[],gt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),bt=gt,_t=gt,wt="__dbnames",xt="readonly",kt="readwrite";function Et(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Pt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ot(t){return"string"!=typeof t||/\./.test(t)?function(e){return e}:function(e){return void 0===e[t]&&t in e&&delete(e=A(e))[t],e}}function Kt(){throw Z.Type()}function St(e,t){try{var n=jt(e),r=jt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,o=n<r?n:r,i=0;i<o;++i)if(e[i]!==t[i])return e[i]<t[i]?-1:1;return n===r?0:n<r?-1:1}(At(e),At(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,o=n<r?n:r,i=0;i<o;++i){var a=St(e[i],t[i]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function jt(e){var t=typeof e;if("object"!=t)return t;if(ArrayBuffer.isView(e))return"binary";e=D(e);return"ArrayBuffer"===e?"binary":e}function At(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Ct=(Dt.prototype._trans=function(e,r,t){var n=this._tx||je.trans,o=this.name;function i(e,t,n){if(!n.schema[o])throw new Z.NotFound("Table "+o+" not part of transaction");return r(n.idbtrans,n)}var a=Le();try{return n&&n.db===this.db?n===je.trans?n._promise(e,i,t):Ze(function(){return n._promise(e,i,t)},{trans:n,transless:je.transless||je}):function t(n,r,o,i){if(n.idbdb&&(n._state.openComplete||je.letThrough||n._vip)){var a=n._createTransaction(r,o,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(e){return e.name===J.InvalidState&&n.isOpen()&&0<--n._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(function(){return t(n,r,o,i)})):ht(e)}return a._promise(r,function(e,t){return Ze(function(){return je.trans=a,i(e,t,a)})}).then(function(e){return a._completion.then(function(){return e})})}if(n._state.openComplete)return ht(new Z.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return ht(new Z.DatabaseClosed);n.open().catch(te)}return n._state.dbReadyPromise.then(function(){return t(n,r,o,i)})}(this.db,e,[this.name],i)}finally{a&&Ve()}},Dt.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)},Dt.prototype.where=function(i){if("string"==typeof i)return new this.db.WhereClause(this,i);if(b(i))return new this.db.WhereClause(this,"[".concat(i.join("+"),"]"));var n=x(i);if(1===n.length)return this.where(n[0]).equals(i[n[0]]);var e=this.schema.indexes.concat(this.schema.primKey).filter(function(t){return t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})&&t.keyPath.every(function(e){return 0<=n.indexOf(e)})})[0];if(e&&this.db._maxKey!==pt)return this.where(e.name).equals(e.keyPath.map(function(e){return i[e]}));!e&&M&&console.warn("The query ".concat(JSON.stringify(i)," on ").concat(this.name," would benefit of a ")+"compound index [".concat(n.join("+"),"]"));var a=this.schema.idxByName,r=this.db._deps.indexedDB;function u(e,t){return 0===r.cmp(e,t)}var t=n.reduce(function(e,t){var n=e[0],r=e[1],e=a[t],o=i[t];return[n||e,n||!e?Et(r,e&&e.multi?function(e){e=E(e,t);return b(e)&&e.some(function(e){return u(o,e)})}:function(e){return u(o,E(e,t))}):r]},[null,null]),o=t[0],t=t[1];return o?this.where(o.name).equals(i[o.keyPath]).filter(t):e?this.filter(t):this.where(n).equals("")},Dt.prototype.filter=function(e){return this.toCollection().and(e)},Dt.prototype.count=function(e){return this.toCollection().count(e)},Dt.prototype.offset=function(e){return this.toCollection().offset(e)},Dt.prototype.limit=function(e){return this.toCollection().limit(e)},Dt.prototype.each=function(e){return this.toCollection().each(e)},Dt.prototype.toArray=function(e){return this.toCollection().toArray(e)},Dt.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},Dt.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,b(e)?"[".concat(e.join("+"),"]"):e))},Dt.prototype.reverse=function(){return this.toCollection().reverse()},Dt.prototype.mapToClass=function(r){var e,t=this.db,n=this.name;function o(){return null!==e&&e.apply(this,arguments)||this}(this.schema.mappedClass=r).prototype instanceof Kt&&(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(o,e=r),Object.defineProperty(o.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),o.prototype.table=function(){return n},r=o);for(var i=new Set,a=r.prototype;a;a=c(a))Object.getOwnPropertyNames(a).forEach(function(e){return i.add(e)});function u(e){if(!e)return e;var t,n=Object.create(r.prototype);for(t in e)if(!i.has(t))try{n[t]=e[t]}catch(e){}return n}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=u,this.hook("reading",u),r},Dt.prototype.defineClass=function(){return this.mapToClass(function(e){u(this,e)})},Dt.prototype.add=function(t,n){var r=this,e=this.schema.primKey,o=e.auto,i=e.keyPath,a=t;return i&&o&&(a=Ot(i)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):e.lastResult}).then(function(e){if(i)try{P(t,i,e)}catch(e){}return e})},Dt.prototype.update=function(t,n){if("object"!=typeof t||b(t))return this.where(":id").equals(t).modify(n);var e=E(t,this.schema.primKey.keyPath);if(void 0===e)return ht(new Z.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?x(n).forEach(function(e){P(t,e,n[e])}):n(t,{value:t,primKey:e})}catch(e){}return this.where(":id").equals(e).modify(n)},Dt.prototype.put=function(t,n){var r=this,e=this.schema.primKey,o=e.auto,i=e.keyPath,a=t;return i&&o&&(a=Ot(i)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):e.lastResult}).then(function(e){if(i)try{P(t,i,e)}catch(e){}return e})},Dt.prototype.delete=function(t){var n=this;return this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"delete",keys:[t]})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):void 0})},Dt.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:Pt})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):void 0})},Dt.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)})})})},Dt.prototype.bulkAdd=function(r,e,t){var i=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=i.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new Z.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var o=r.length,t=t&&n?r.map(Ot(t)):r;return i.core.mutate({trans:e,type:"add",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new X("".concat(i.name,".bulkAdd(): ").concat(t," of ").concat(o," operations failed"),e)})})},Dt.prototype.bulkPut=function(r,e,t){var i=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=i.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new Z.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var o=r.length,t=t&&n?r.map(Ot(t)):r;return i.core.mutate({trans:e,type:"put",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new X("".concat(i.name,".bulkPut(): ").concat(t," of ").concat(o," operations failed"),e)})})},Dt.prototype.bulkUpdate=function(t){var h=this,n=this.core,r=t.map(function(e){return e.key}),o=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,o=c[t];if(o){for(var i=0,a=Object.keys(r);i<a.length;i++){var u=a[i],s=r[u];if(u===h.schema.primKey.keyPath){if(0!==St(s,n))throw new Z.Constraint("Cannot update primary key in bulkUpdate()")}else P(o,u,s)}d.push(t),l.push(n),f.push(o)}});var s=l.length;return n.mutate({trans:e,type:"put",keys:l,values:f,updates:{keys:r,changeSpecs:o}}).then(function(e){var t=e.numFailures,n=e.failures;if(0===t)return s;for(var r=0,o=Object.keys(n);r<o.length;r++){var i,a=o[r],u=d[Number(a)];null!=u&&(i=n[a],delete n[a],n[u]=i)}throw new X("".concat(h.name,".bulkUpdate(): ").concat(t," of ").concat(s," operations failed"),n)})})})},Dt.prototype.bulkDelete=function(t){var r=this,o=t.length;return this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"delete",keys:t})}).then(function(e){var t=e.numFailures,n=e.lastResult,e=e.failures;if(0===t)return n;throw new X("".concat(r.name,".bulkDelete(): ").concat(t," of ").concat(o," operations failed"),e)})},Dt);function Dt(){}function It(o){function t(e,t){if(t){for(var n=arguments.length,r=new Array(n-1);--n;)r[n-1]=arguments[n];return a[e].subscribe.apply(null,r),o}if("string"==typeof e)return a[e]}var a={};t.addEventType=u;for(var e=1,n=arguments.length;e<n;++e)u(arguments[e]);return t;function u(e,n,r){if("object"!=typeof e){var o;n=n||se;var i={subscribers:[],fire:r=r||te,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=n(i.fire,e))},unsubscribe:function(t){i.subscribers=i.subscribers.filter(function(e){return e!==t}),i.fire=i.subscribers.reduce(n,r)}};return a[e]=t[e]=i}x(o=e).forEach(function(e){var t=o[e];if(b(t))u(e,o[e][0],o[e][1]);else{if("asap"!==t)throw new Z.InvalidArgument("Invalid event config");var n=u(e,ne,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){w(function(){e.apply(null,t)})})})}})}}function Tt(e,t){return i(t).from({prototype:e}),t}function Bt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Rt(e,t){e.filter=Et(e.filter,t)}function Ft(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return Et(r(),t())}:t,e.justLimit=n&&!r}function Mt(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 Nt(e,t,n){var r=Mt(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 qt(e,i,t,n){var a=e.replayFilter?Et(e.filter,e.replayFilter()):e.filter;if(e.or){var u={},r=function(e,t,n){var r,o;a&&!a(t,n,function(e){return t.stop(e)},function(e){return t.fail(e)})||("[object ArrayBuffer]"===(o=""+(r=t.primaryKey))&&(o=""+new Uint8Array(r)),m(u,o)||(u[o]=!0,i(e,t,n)))};return Promise.all([e.or._iterate(r,t),Ut(Nt(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return Ut(Nt(e,n,t),Et(e.algorithm,a),i,!e.keysOnly&&e.valueMapper)}function Ut(e,r,o,i){var a=Ye(i?function(e,t,n){return o(i(e),t,n)}:o);return e.then(function(n){if(n)return n.start(function(){var t=function(){return n.continue()};r&&!r(n,function(e){return t=e},function(e){n.stop(e),t=te},function(e){n.fail(e),t=te})||a(n.value,n,function(e){return t=e}),t()})})}var Lt=(Vt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,ht.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Vt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,ht.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Vt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=Et(t.algorithm,e)},Vt.prototype._iterate=function(e,t){return qt(this._ctx,e,t,this._ctx.table.core)},Vt.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},Vt.prototype.raw=function(){return this._ctx.valueMapper=null,this},Vt.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return qt(n,t,e,n.table.core)})},Vt.prototype.count=function(e){var o=this;return this._read(function(e){var t=o._ctx,n=t.table.core;if(Bt(t,!0))return n.count({trans:e,query:{index:Mt(t,n.schema),range:t.range}}).then(function(e){return Math.min(e,t.limit)});var r=0;return qt(t,function(){return++r,!1},e,n).then(function(){return r})}).then(e)},Vt.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],o=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function u(e,t){e=i(e,o),t=i(t,o);return e<t?-a:t<e?a:0}return this.toArray(function(e){return e.sort(u)}).then(t)},Vt.prototype.toArray=function(e){var i=this;return this._read(function(e){var t=i._ctx;if("next"===t.dir&&Bt(t,!0)&&0<t.limit){var n=t.valueMapper,r=Mt(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(function(e){e=e.result;return n?e.map(n):e})}var o=[];return qt(t,function(e){return o.push(e)},e,t.table.core).then(function(){return o})},e)},Vt.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,Bt(e)?Ft(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):Ft(e,function(){var e=t;return function(){return--e<0}})),this},Vt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Ft(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},Vt.prototype.until=function(r,o){return Rt(this._ctx,function(e,t,n){return!r(e.value)||(t(n),o)}),this},Vt.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Vt.prototype.last=function(e){return this.reverse().first(e)},Vt.prototype.filter=function(t){var e;return Rt(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=Et(e.isMatch,t),this},Vt.prototype.and=function(e){return this.filter(e)},Vt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Vt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Vt.prototype.desc=function(){return this.reverse()},Vt.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},Vt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Vt.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},Vt.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)},Vt.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&Bt(n,!0)&&0<n.limit)return this._read(function(e){var t=Mt(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)},Vt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Vt.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Vt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Vt.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 Rt(this._ctx,function(e){var t=e.primaryKey.toString(),e=m(n,t);return n[t]=!0,!e}),this},Vt.prototype.modify=function(_){var n=this,w=this._ctx;return this._write(function(d){var i,a,p;p="function"==typeof _?_:(i=x(_),a=i.length,function(e){for(var t=!1,n=0;n<a;++n){var r=i[n],o=_[r];E(e,r)!==o&&(P(e,r,o),t=!0)}return t});function y(e,t){var n=t.failures,t=t.numFailures;s+=e-t;for(var r=0,o=x(n);r<o.length;r++){var i=o[r];u.push(n[i])}}var v=w.table.core,e=v.schema.primaryKey,m=e.outbound,g=e.extractKey,b=n.db._options.modifyChunkSize||200,u=[],s=0,t=[];return n.clone().primaryKeys().then(function(f){function h(c){var l=Math.min(b,f.length-c);return v.getMany({trans:d,keys:f.slice(c,c+l),cache:"immutable"}).then(function(e){for(var n=[],t=[],r=m?[]:null,o=[],i=0;i<l;++i){var a=e[i],u={value:A(a),primKey:f[c+i]};!1!==p.call(u,u.value,u)&&(null==u.value?o.push(f[c+i]):m||0===St(g(a),g(u.value))?(t.push(u.value),m&&r.push(f[c+i])):(o.push(f[c+i]),n.push(u.value)))}var s=Bt(w)&&w.limit===1/0&&("function"!=typeof _||_===Wt)&&{index:w.index,range:w.range};return Promise.resolve(0<n.length&&v.mutate({trans:d,type:"add",values:n}).then(function(e){for(var t in e.failures)o.splice(parseInt(t),1);y(n.length,e)})).then(function(){return(0<t.length||s&&"object"==typeof _)&&v.mutate({trans:d,type:"put",keys:r,values:t,criteria:s,changeSpec:"function"!=typeof _&&_}).then(function(e){return y(t.length,e)})}).then(function(){return(0<o.length||s&&_===Wt)&&v.mutate({trans:d,type:"delete",keys:o,criteria:s}).then(function(e){return y(o.length,e)})}).then(function(){return f.length>c+l&&h(c+b)})})}return h(0).then(function(){if(0<u.length)throw new Q("Error modifying one or more objects",u,s,t);return f.length})})})},Vt.prototype.delete=function(){var o=this._ctx,n=o.range;return Bt(o)&&(o.isPrimKey&&!_t||3===n.type)?this._write(function(e){var t=o.table.core.schema.primaryKey,r=n;return o.table.core.count({trans:e,query:{index:t,range:r}}).then(function(n){return o.table.core.mutate({trans:e,type:"deleteRange",range:r}).then(function(e){var t=e.failures;e.lastResult,e.results;e=e.numFailures;if(e)throw new Q("Could not delete some values",Object.keys(t).map(function(e){return t[e]}),n-e);return n-e})})}):this.modify(Wt)},Vt);function Vt(){}var Wt=function(e,t){return t.value=null};function zt(e,t){return e<t?-1:e===t?0:1}function Yt(e,t){return t<e?-1:e===t?0:1}function Gt(e,t,n){e=e instanceof $t?new e.Collection(e):e;return e._ctx.error=new(n||TypeError)(t),e}function Ht(e){return new e.Collection(e,function(){return Jt("")}).limit(0)}function Qt(e,s,n,r){var o,c,l,f,h,d,p,y=n.length;if(!n.every(function(e){return"string"==typeof e}))return Gt(e,vt);function t(e){o="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},c="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},l="next"===e?zt:Yt;var t=n.map(function(e){return{lower:c(e),upper:o(e)}}).sort(function(e,t){return l(e.lower,t.lower)});f=t.map(function(e){return e.upper}),h=t.map(function(e){return e.lower}),p="next"===(d=e)?"":r}t("next");e=new e.Collection(e,function(){return Xt(f[0],h[y-1]+r)});e._ondirectionchange=function(e){t(e)};var v=0;return e._addAlgorithm(function(e,t,n){var r=e.key;if("string"!=typeof r)return!1;var o=c(r);if(s(o,h,v))return!0;for(var i=null,a=v;a<y;++a){var u=function(e,t,n,r,o,i){for(var a=Math.min(e.length,r.length),u=-1,s=0;s<a;++s){var c=t[s];if(c!==r[s])return o(e[s],n[s])<0?e.substr(0,s)+n[s]+n.substr(s+1):o(e[s],r[s])<0?e.substr(0,s)+r[s]+n.substr(s+1):0<=u?e.substr(0,u)+t[u]+n.substr(u+1):null;o(e[s],c)<0&&(u=s)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):u<0?null:e.substr(0,u)+r[u]+n.substr(u+1)}(r,o,f[a],h[a],l,d);null===u&&null===i?v=a+1:(null===i||0<l(i,u))&&(i=u)}return t(null!==i?function(){e.continue(i+p)}:n),!1}),e}function Xt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Jt(e){return{type:1,lower:e,upper:e}}var $t=(Object.defineProperty(Zt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Zt.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)?Ht(this):new this.Collection(this,function(){return Xt(e,t,!n,!r)})}catch(e){return Gt(this,yt)}},Zt.prototype.equals=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Jt(e)})},Zt.prototype.above=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Xt(e,void 0,!0)})},Zt.prototype.aboveOrEqual=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Xt(e,void 0,!1)})},Zt.prototype.below=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Xt(void 0,e,!1,!0)})},Zt.prototype.belowOrEqual=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Xt(void 0,e)})},Zt.prototype.startsWith=function(e){return"string"!=typeof e?Gt(this,vt):this.between(e,e+pt,!0,!0)},Zt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Qt(this,function(e,t){return 0===e.indexOf(t[0])},[e],pt)},Zt.prototype.equalsIgnoreCase=function(e){return Qt(this,function(e,t){return e===t[0]},[e],"")},Zt.prototype.anyOfIgnoreCase=function(){var e=R.apply(B,arguments);return 0===e.length?Ht(this):Qt(this,function(e,t){return-1!==t.indexOf(e)},e,"")},Zt.prototype.startsWithAnyOfIgnoreCase=function(){var e=R.apply(B,arguments);return 0===e.length?Ht(this):Qt(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,pt)},Zt.prototype.anyOf=function(){var t=this,o=R.apply(B,arguments),i=this._cmp;try{o.sort(i)}catch(e){return Gt(this,yt)}if(0===o.length)return Ht(this);var e=new this.Collection(this,function(){return Xt(o[0],o[o.length-1])});e._ondirectionchange=function(e){i="next"===e?t._ascending:t._descending,o.sort(i)};var a=0;return e._addAlgorithm(function(e,t,n){for(var r=e.key;0<i(r,o[a]);)if(++a===o.length)return t(n),!1;return 0===i(r,o[a])||(t(function(){e.continue(o[a])}),!1)}),e},Zt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Zt.prototype.noneOf=function(){var e=R.apply(B,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Gt(this,yt)}var t=e.reduce(function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},Zt.prototype.inAnyRange=function(e,t){var i=this,a=this._cmp,u=this._ascending,n=this._descending,s=this._min,c=this._max;if(0===e.length)return Ht(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&u(e[0],e[1])<=0}))return Gt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Z.InvalidArgument);var r=!t||!1!==t.includeLowers,o=t&&!0===t.includeUppers;var l,f=u;function h(e,t){return f(e[0],t[0])}try{(l=e.reduce(function(e,t){for(var n=0,r=e.length;n<r;++n){var o=e[n];if(a(t[0],o[1])<0&&0<a(t[1],o[0])){o[0]=s(o[0],t[0]),o[1]=c(o[1],t[1]);break}}return n===r&&e.push(t),e},[])).sort(h)}catch(e){return Gt(this,yt)}var d=0,p=o?function(e){return 0<u(e,l[d][1])}:function(e){return 0<=u(e,l[d][1])},y=r?function(e){return 0<n(e,l[d][0])}:function(e){return 0<=n(e,l[d][0])};var v=p,e=new this.Collection(this,function(){return Xt(l[0][0],l[l.length-1][1],!r,!o)});return e._ondirectionchange=function(e){f="next"===e?(v=p,u):(v=y,n),l.sort(h)},e._addAlgorithm(function(e,t,n){for(var r,o=e.key;v(o);)if(++d===l.length)return t(n),!1;return!p(r=o)&&!y(r)||(0===i._cmp(o,l[d][1])||0===i._cmp(o,l[d][0])||t(function(){f===u?e.continue(l[d][0]):e.continue(l[d][1])}),!1)}),e},Zt.prototype.startsWithAnyOf=function(){var e=R.apply(B,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Ht(this):this.inAnyRange(e.map(function(e){return[e,e+pt]})):Gt(this,"startsWithAnyOf() only works with strings")},Zt);function Zt(){}function en(t){return Ye(function(e){return tn(e),t(e.target.error),!1})}function tn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var nn="storagemutated",rn="x-storagemutated-1",on=It(null,nn),an=(un.prototype._lock=function(){return _(!je.global),++this._reculock,1!==this._reculock||je.global||(je.lockOwnerFor=this),this},un.prototype._unlock=function(){if(_(!je.global),0==--this._reculock)for(je.global||(je.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{at(e[1],e[0])}catch(e){}}return this},un.prototype._locked=function(){return this._reculock&&je.lockOwnerFor!==this},un.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(_(!this.idbtrans),!t&&!e)switch(r&&r.name){case"DatabaseClosedError":throw new Z.DatabaseClosed(r);case"MissingAPIError":throw new Z.MissingAPI(r.message,r);default:throw new Z.OpenFailed(r)}if(!this.active)throw new Z.TransactionInactive;return _(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||e).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Ye(function(e){tn(e),n._reject(t.error)}),t.onabort=Ye(function(e){tn(e),n.active&&n._reject(new Z.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=Ye(function(){n.active=!1,n._resolve(),"mutatedParts"in t&&on.storagemutated.fire(t.mutatedParts)}),this},un.prototype._promise=function(n,r,o){var i=this;if("readwrite"===n&&"readwrite"!==this.mode)return ht(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return ht(new Z.TransactionInactive);if(this._locked())return new Ie(function(e,t){i._blockedFuncs.push([function(){i._promise(n,r,o).then(e,t)},je])});if(o)return Ze(function(){var e=new Ie(function(e,t){i._lock();var n=r(e,t,i);n&&n.then&&n.then(e,t)});return e.finally(function(){return i._unlock()}),e._lib=!0,e});var e=new Ie(function(e,t){var n=r(e,t,i);n&&n.then&&n.then(e,t)});return e._lib=!0,e},un.prototype._root=function(){return this.parent?this.parent._root():this},un.prototype.waitFor=function(e){var t,r=this._root(),o=Ie.resolve(e);r._waitingFor?r._waitingFor=r._waitingFor.then(function(){return o}):(r._waitingFor=o,r._waitingQueue=[],t=r.idbtrans.objectStore(r.storeNames[0]),function e(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(t.get(-1/0).onsuccess=e)}());var i=r._waitingFor;return new Ie(function(t,n){o.then(function(e){return r._waitingQueue.push(Ye(t.bind(null,e)))},function(e){return r._waitingQueue.push(Ye(n.bind(null,e)))}).finally(function(){r._waitingFor===i&&(r._waitingFor=null)})})},un.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new Z.Abort))},un.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},un);function un(){}function sn(e,t,n,r,o,i,a){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+cn(t)}}function cn(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function ln(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:k(n,function(e){return[e.name,e]})}}var fn=function(e){try{return e.only([[]]),fn=function(){return[[]]},[[]]}catch(e){return fn=function(){return pt},pt}};function hn(t){return null==t?function(){}:"string"==typeof t?1===(n=t).split(".").length?function(e){return e[n]}:function(e){return E(e,n)}:function(e){return E(e,t)};var n}function dn(e){return[].slice.call(e)}var pn=0;function yn(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function vn(e,o,t){function w(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,n=e.upper,r=e.lowerOpen,e=e.upperOpen;return void 0===t?void 0===n?null:o.upperBound(n,!!e):void 0===n?o.lowerBound(t,!!r):o.bound(t,n,!!r,!!e)}function n(e){var h,_=e.name;return{name:_,schema:e,mutate:function(e){var y=e.trans,v=e.type,m=e.keys,g=e.values,b=e.range;return new Promise(function(t,e){t=Ye(t);var n=y.objectStore(_),r=null==n.keyPath,o="put"===v||"add"===v;if(!o&&"delete"!==v&&"deleteRange"!==v)throw new Error("Invalid operation type: "+v);var i,a=(m||g||{length:1}).length;if(m&&g&&m.length!==g.length)throw new Error("Given keys array must have same length as given values array.");if(0===a)return t({numFailures:0,failures:{},results:[],lastResult:void 0});function u(e){++l,tn(e)}var s=[],c=[],l=0;if("deleteRange"===v){if(4===b.type)return t({numFailures:l,failures:c,results:[],lastResult:void 0});3===b.type?s.push(i=n.clear()):s.push(i=n.delete(w(b)))}else{var r=o?r?[g,m]:[g,null]:[m,null],f=r[0],h=r[1];if(o)for(var d=0;d<a;++d)s.push(i=h&&void 0!==h[d]?n[v](f[d],h[d]):n[v](f[d])),i.onerror=u;else for(d=0;d<a;++d)s.push(i=n[v](f[d])),i.onerror=u}function p(e){e=e.target.result,s.forEach(function(e,t){return null!=e.error&&(c[t]=e.error)}),t({numFailures:l,failures:c,results:"delete"===v?m:s.map(function(e){return e.result}),lastResult:e})}i.onerror=function(e){u(e),p(e)},i.onsuccess=p})},getMany:function(e){var f=e.trans,h=e.keys;return new Promise(function(t,e){t=Ye(t);for(var n,r=f.objectStore(_),o=h.length,i=new Array(o),a=0,u=0,s=function(e){e=e.target;i[e._pos]=e.result,++u===a&&t(i)},c=en(e),l=0;l<o;++l)null!=h[l]&&((n=r.get(h[l]))._pos=l,n.onsuccess=s,n.onerror=c,++a);0===a&&t(i)})},get:function(e){var r=e.trans,o=e.key;return new Promise(function(t,e){t=Ye(t);var n=r.objectStore(_).get(o);n.onsuccess=function(e){return t(e.target.result)},n.onerror=en(e)})},query:(h=s,function(f){return new Promise(function(n,e){n=Ye(n);var r,o,i,t=f.trans,a=f.values,u=f.limit,s=f.query,c=u===1/0?void 0:u,l=s.index,s=s.range,t=t.objectStore(_),l=l.isPrimaryKey?t:t.index(l.name),s=w(s);if(0===u)return n({result:[]});h?((c=a?l.getAll(s,c):l.getAllKeys(s,c)).onsuccess=function(e){return n({result:e.target.result})},c.onerror=en(e)):(r=0,o=!a&&"openKeyCursor"in l?l.openKeyCursor(s):l.openCursor(s),i=[],o.onsuccess=function(e){var t=o.result;return t?(i.push(a?t.value:t.primaryKey),++r===u?n({result:i}):void t.continue()):n({result:i})},o.onerror=en(e))})}),openCursor:function(e){var c=e.trans,i=e.values,a=e.query,u=e.reverse,l=e.unique;return new Promise(function(t,n){t=Ye(t);var e=a.index,r=a.range,o=c.objectStore(_),o=e.isPrimaryKey?o:o.index(e.name),e=u?l?"prevunique":"prev":l?"nextunique":"next",s=!i&&"openKeyCursor"in o?o.openKeyCursor(w(r),e):o.openCursor(w(r),e);s.onerror=en(n),s.onsuccess=Ye(function(e){var r,o,i,a,u=s.result;u?(u.___id=++pn,u.done=!1,r=u.continue.bind(u),o=(o=u.continuePrimaryKey)&&o.bind(u),i=u.advance.bind(u),a=function(){throw new Error("Cursor not stopped")},u.trans=c,u.stop=u.continue=u.continuePrimaryKey=u.advance=function(){throw new Error("Cursor not started")},u.fail=Ye(n),u.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},u.start=function(e){function t(){if(s.result)try{e()}catch(e){u.fail(e)}else u.done=!0,u.start=function(){throw new Error("Cursor behind last entry")},u.stop()}var n=new Promise(function(t,e){t=Ye(t),s.onerror=en(e),u.fail=e,u.stop=function(e){u.stop=u.continue=u.continuePrimaryKey=u.advance=a,t(e)}});return s.onsuccess=Ye(function(e){s.onsuccess=t,t()}),u.continue=r,u.continuePrimaryKey=o,u.advance=i,t(),n},t(u)):t(null)},n)})},count:function(e){var t=e.query,o=e.trans,i=t.index,a=t.range;return new Promise(function(t,e){var n=o.objectStore(_),r=i.isPrimaryKey?n:n.index(i.name),n=w(a),r=n?r.count(n):r.count();r.onsuccess=Ye(function(e){return t(e.target.result)}),r.onerror=en(e)})}}}var r,i,a,u=(i=t,a=dn((r=e).objectStoreNames),{schema:{name:r.name,tables:a.map(function(e){return i.objectStore(e)}).map(function(t){var e=t.keyPath,n=t.autoIncrement,r=b(e),o={},n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:hn(e)},indexes:dn(t.indexNames).map(function(e){return t.index(e)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,e=e.keyPath,r={name:t,compound:b(e),keyPath:e,unique:n,multiEntry:r,extractKey:hn(e)};return o[yn(e)]=r}),getIndexByKeyPath:function(e){return o[yn(e)]}};return o[":id"]=n.primaryKey,null!=e&&(o[yn(e)]=n.primaryKey),n})},hasGetAll:0<a.length&&"getAll"in i.objectStore(a[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),t=u.schema,s=u.hasGetAll,u=t.tables.map(n),c={};return u.forEach(function(e){return c[e.name]=e}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!c[e])throw new Error("Table '".concat(e,"' not found"));return c[e]},MIN_KEY:-1/0,MAX_KEY:fn(o),schema:t}}function mn(e,t,n,r){var o=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=vn(t,o,r),e.dbcore.reduce(function(e,t){t=t.create;return g(g({},e),t(e))},r))}}function gn(e,t){var n=e._novip,e=t.db,t=mn(n._middlewares,e,n._deps,t);n.core=t.dbcore,n.tables.forEach(function(e){var t=e.name;n.core.schema.tables.some(function(e){return e.name===t})&&(e.core=n.core.table(t),n[t]instanceof n.Table&&(n[t].core=e.core))})}function bn(e,t,n,o){var i=e._novip;n.forEach(function(n){var r=o[n];t.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 _n(e,t){var n=e._novip;t.forEach(function(e){for(var t in e)e[t]instanceof n.Table&&delete e[t]})}function wn(e,t){return e._cfg.version-t._cfg.version}function xn(n,r,o,e){var i=n._dbSchema,a=n._createTransaction("readwrite",n._storeNames,i);a.create(o),a._completion.catch(e);var u=a._reject.bind(a),p=je.transless||je;Ze(function(){var e,s,c,l,f,t,h,d;je.trans=a,je.transless=p,0===r?(x(i).forEach(function(e){En(o,e,i[e].primKey,i[e].indexes)}),gn(n,o),Ie.follow(function(){return n.on.populate.fire(a)}).catch(u)):(s=r,c=a,l=o,f=(e=n)._novip,t=[],e=f._versions,h=f._dbSchema=On(0,f.idbdb,l),d=!1,e.filter(function(e){return e._cfg.version>=s}).forEach(function(u){t.push(function(){var t=h,e=u._cfg.dbschema;Kn(f,t,l),Kn(f,e,l),h=f._dbSchema=e;var n=kn(t,e);n.add.forEach(function(e){En(l,e[0],e[1].primKey,e[1].indexes)}),n.change.forEach(function(e){if(e.recreate)throw new Z.Upgrade("Not yet support for changing primary key");var t=l.objectStore(e.name);e.add.forEach(function(e){return Pn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),Pn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var r=u._cfg.contentUpgrade;if(r&&u._cfg.version>s){gn(f,l),c._memoizedTables={},d=!0;var o=O(e);n.del.forEach(function(e){o[e]=t[e]}),_n(f,[f.Transaction.prototype]),bn(f,[f.Transaction.prototype],x(o),o),c.schema=o;var i,a=F(r);a&&et();n=Ie.follow(function(){var e;(i=r(c))&&a&&(e=tt.bind(null,null),i.then(e,e))});return i&&"function"==typeof i.then?Ie.resolve(i):n.then(function(){return i})}}),t.push(function(e){var t,n,r;d&&bt||(t=u._cfg.dbschema,n=t,r=e,[].slice.call(r.db.objectStoreNames).forEach(function(e){return null==n[e]&&r.db.deleteObjectStore(e)})),_n(f,[f.Transaction.prototype]),bn(f,[f.Transaction.prototype],f._storeNames,f._dbSchema),c.schema=f._dbSchema})}),function e(){return t.length?Ie.resolve(t.shift()(c.idbtrans)).then(e):Ie.resolve()}().then(function(){var t,n;n=l,x(t=h).forEach(function(e){n.db.objectStoreNames.contains(e)||En(n,e,t[e].primKey,t[e].indexes)})}).catch(u))})}function kn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var o=e[n],i=t[n];if(o){var a={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||o.primKey.auto!==i.primKey.auto&&!gt)a.recreate=!0,r.change.push(a);else{var u=o.idxByName,s=i.idxByName,c=void 0;for(c in u)s[c]||a.del.push(c);for(c in s){var l=u[c],f=s[c];l?l.src!==f.src&&a.change.push(f):a.add.push(f)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,i])}return r}function En(e,t,n,r){var o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(e){return Pn(o,e)}),o}function Pn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function On(e,t,u){var s={};return y(t.objectStoreNames,0).forEach(function(e){for(var t=u.objectStore(e),n=sn(cn(a=t.keyPath),a||"",!1,!1,!!t.autoIncrement,a&&"string"!=typeof a,!0),r=[],o=0;o<t.indexNames.length;++o){var i=t.index(t.indexNames[o]),a=i.keyPath,i=sn(i.name,a,!!i.unique,!!i.multiEntry,!1,a&&"string"!=typeof a,!1);r.push(i)}s[e]=ln(e,n,r)}),s}function Kn(e,t,n){for(var r=e._novip,o=n.db.objectStoreNames,i=0;i<o.length;++i){var a=o[i],u=n.objectStore(a);r._hasGetAll="getAll"in u;for(var s=0;s<u.indexNames.length;++s){var c=u.indexNames[s],l=u.index(c).keyPath,f="string"==typeof l?l:"["+y(l).join("+")+"]";!t[a]||(l=t[a].idxByName[f])&&(l.name=c,delete t[a].idxByName[f],t[a].idxByName[c]=l)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&h.WorkerGlobalScope&&h instanceof h.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(r._hasGetAll=!1)}var Sn=(jn.prototype._parseStoresSpec=function(r,o){x(r).forEach(function(e){if(null!==r[e]){var t=r[e].split(",").map(function(e,t){var n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return sn(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),b(r),0===t)}),n=t.shift();if(n.multi)throw new Z.Schema("Primary key cannot be multi-valued");t.forEach(function(e){if(e.auto)throw new Z.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new Z.Schema("Index must have a name and cannot be an empty string")}),o[e]=ln(e,n,t)}})},jn.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,_n(t,[t._allTables,t,t.Transaction.prototype]),bn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],x(r),r),t._storeNames=x(r),this},jn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=ce(this._cfg.contentUpgrade||te,e),this},jn);function jn(){}function An(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Xn(wt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Cn(e){return e&&"function"==typeof e.databases}function Dn(e){return Ze(function(){return je.letThrough=!0,e()})}function In(f){var h=f._state,r=f._deps.indexedDB;if(h.isBeingOpened||f.idbdb)return h.dbReadyPromise.then(function(){return h.dbOpenError?ht(h.dbOpenError):f});M&&(h.openCanceller._stackHolder=L()),h.isBeingOpened=!0,h.dbOpenError=null,h.openComplete=!1;var t=h.openCanceller;function e(){if(h.openCanceller!==t)throw new Z.DatabaseClosed("db.open() was cancelled")}var n,o=h.dbReadyResolve,d=null,p=!1;return Ie.race([t,("undefined"==typeof navigator?Ie.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(function(){return new Ie(function(s,n){if(e(),!r)throw new Z.MissingAPI;var c=f.name,l=h.autoSchema?r.open(c):r.open(c,Math.round(10*f.verno));if(!l)throw new Z.MissingAPI;l.onerror=en(n),l.onblocked=Ye(f._fireOnBlocked),l.onupgradeneeded=Ye(function(e){var t;d=l.transaction,h.autoSchema&&!f._options.allowEmptyDB?(l.onerror=tn,d.abort(),l.result.close(),(t=r.deleteDatabase(c)).onsuccess=t.onerror=Ye(function(){n(new Z.NoSuchDatabase("Database ".concat(c," doesnt exist")))})):(d.onerror=en(n),e=e.oldVersion>Math.pow(2,62)?0:e.oldVersion,p=e<1,f._novip.idbdb=l.result,xn(f,e/10,d,n))},n),l.onsuccess=Ye(function(){d=null;var e,t,n,r,o,i=f._novip.idbdb=l.result,a=y(i.objectStoreNames);if(0<a.length)try{var u=i.transaction(1===(r=a).length?r[0]:r,"readonly");h.autoSchema?(t=i,n=u,(e=(e=f)._novip).verno=t.version/10,n=e._dbSchema=On(0,t,n),e._storeNames=y(t.objectStoreNames,0),bn(e,[e._allTables],x(n),n)):(Kn(f,f._dbSchema,u),((o=kn(On(0,(o=f).idbdb,u),o._dbSchema)).add.length||o.change.some(function(e){return e.add.length||e.change.length}))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),gn(f,u)}catch(e){}mt.push(f),i.onversionchange=Ye(function(e){h.vcFired=!0,f.on("versionchange").fire(e)}),i.onclose=Ye(function(e){f.on("close").fire(e)}),p&&(o=f._deps,u=c,i=o.indexedDB,o=o.IDBKeyRange,Cn(i)||u===wt||An(i,o).put({name:u}).catch(te)),s()},n)})})]).then(function(){return e(),h.onReadyBeingFired=[],Ie.resolve(Dn(function(){return f.on.ready.fire(f.vip)})).then(function e(){if(0<h.onReadyBeingFired.length){var t=h.onReadyBeingFired.reduce(ce,te);return h.onReadyBeingFired=[],Ie.resolve(Dn(function(){return t(f.vip)})).then(e)}})}).finally(function(){h.onReadyBeingFired=null,h.isBeingOpened=!1}).then(function(){return f}).catch(function(e){h.dbOpenError=e;try{d&&d.abort()}catch(e){}return t===h.openCanceller&&f._close(),ht(e)}).finally(function(){h.openComplete=!0,o()})}function Tn(t){function e(e){return t.next(e)}var r=n(e),o=n(function(e){return t.throw(e)});function n(n){return function(e){var t=n(e),e=t.value;return t.done?e:e&&"function"==typeof e.then?e.then(r,o):b(e)?Promise.all(e).then(r,o):r(e)}}return n(e)()}function Bn(e,t,n){for(var r=b(e)?e.slice():[e],o=0;o<n;++o)r.push(t);return r}var Rn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(f){return g(g({},f),{table:function(e){var a=f.table(e),t=a.schema,u={},s=[];function c(e,t,n){var r=yn(e),o=u[r]=u[r]||[],i=null==e?0:"string"==typeof e?1:e.length,r=0<t,r=g(g({},n),{isVirtual:r,keyTail:t,keyLength:i,extractKey:hn(e),unique:!r&&n.unique});return o.push(r),r.isPrimaryKey||s.push(r),1<i&&c(2===i?e[0]:e.slice(0,i-1),t+1,n),o.sort(function(e,t){return e.keyTail-t.keyTail}),r}e=c(t.primaryKey.keyPath,0,t.primaryKey);u[":id"]=[e];for(var n=0,r=t.indexes;n<r.length;n++){var o=r[n];c(o.keyPath,0,o)}function l(e){var t,n=e.query.index;return n.isVirtual?g(g({},e),{query:{index:n,range:(t=e.query.range,n=n.keyTail,{type:1===t.type?2:t.type,lower:Bn(t.lower,t.lowerOpen?f.MAX_KEY:f.MIN_KEY,n),lowerOpen:!0,upper:Bn(t.upper,t.upperOpen?f.MIN_KEY:f.MAX_KEY,n),upperOpen:!0})}}):e}return g(g({},a),{schema:g(g({},t),{primaryKey:e,indexes:s,getIndexByKeyPath:function(e){return(e=u[yn(e)])&&e[0]}}),count:function(e){return a.count(l(e))},query:function(e){return a.query(l(e))},openCursor:function(t){var e=t.query.index,r=e.keyTail,n=e.isVirtual,o=e.keyLength;return n?a.openCursor(l(t)).then(function(e){return e&&i(e)}):a.openCursor(t);function i(n){return Object.create(n,{continue:{value:function(e){null!=e?n.continue(Bn(e,t.reverse?f.MAX_KEY:f.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,o).concat(t.reverse?f.MIN_KEY:f.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value:function(e,t){n.continuePrimaryKey(Bn(e,f.MAX_KEY,r),t)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:function(){return n.value}}})}}})}})}};function Fn(o,i,a,u){return a=a||{},u=u||"",x(o).forEach(function(e){var t,n,r;m(i,e)?(t=o[e],n=i[e],"object"==typeof t&&"object"==typeof n&&t&&n?(r=D(t))!==D(n)?a[u+e]=i[e]:"Object"===r?Fn(t,n,a,u+e+"."):t!==n&&(a[u+e]=i[e]):t!==n&&(a[u+e]=i[e])):a[u+e]=void 0}),x(i).forEach(function(e){m(o,e)||(a[u+e]=i[e])}),a}var Mn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return g(g({},e),{table:function(r){var y=e.table(r),v=y.schema.primaryKey;return g(g({},y),{mutate:function(e){var t=je.trans,n=t.table(r).hook,h=n.deleting,d=n.creating,p=n.updating;switch(e.type){case"add":if(d.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"put":if(d.fire===te&&p.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"delete":if(h.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"deleteRange":if(h.fire===te)break;return t._promise("readwrite",function(){return function n(r,o,i){return y.query({trans:r,values:!1,query:{index:v,range:o},limit:i}).then(function(e){var t=e.result;return a({type:"delete",keys:t,trans:r}).then(function(e){return 0<e.numFailures?Promise.reject(e.failures[0]):t.length<i?{failures:[],numFailures:0,lastResult:void 0}:n(r,g(g({},o),{lower:t[t.length-1],lowerOpen:!0}),i)})})}(e.trans,e.range,1e4)},!0)}return y.mutate(e);function a(c){var e,t,n,l=je.trans,f=c.keys||(t=v,"delete"===(n=c).type?n.keys:n.keys||n.values.map(t.extractKey));if(!f)throw new Error("Keys missing");return"delete"!==(c="add"===c.type||"put"===c.type?g(g({},c),{keys:f}):g({},c)).type&&(c.values=o([],c.values,!0)),c.keys&&(c.keys=o([],c.keys,!0)),e=y,n=f,("add"===(t=c).type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})).then(function(u){var s=f.map(function(e,t){var n,r,o,i=u[t],a={onerror:null,onsuccess:null};return"delete"===c.type?h.fire.call(a,e,i,l):"add"===c.type||void 0===i?(n=d.fire.call(a,e,c.values[t],l),null==e&&null!=n&&(c.keys[t]=e=n,v.outbound||P(c.values[t],v.keyPath,e))):(n=Fn(i,c.values[t]),(r=p.fire.call(a,n,e,i,l))&&(o=c.values[t],Object.keys(r).forEach(function(e){m(o,e)?o[e]=r[e]:P(o,e,r[e])}))),a});return y.mutate(c).then(function(e){for(var t=e.failures,n=e.results,r=e.numFailures,e=e.lastResult,o=0;o<f.length;++o){var i=(n||f)[o],a=s[o];null==i?a.onerror&&a.onerror(t[o]):a.onsuccess&&a.onsuccess("put"===c.type&&u[o]?c.values[o]:i)}return{failures:t,results:n,numFailures:r,lastResult:e}}).catch(function(t){return s.forEach(function(e){return e.onerror&&e.onerror(t)}),Promise.reject(t)})})}}})}})}};function Nn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;for(var r=[],o=0,i=0;o<t.keys.length&&i<e.length;++o)0===St(t.keys[o],e[i])&&(r.push(n?A(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}var qn={stack:"dbcore",level:-1,create:function(t){return{table:function(e){var n=t.table(e);return g(g({},n),{getMany:function(t){if(!t.cache)return n.getMany(t);var e=Nn(t.keys,t.trans._cache,"clone"===t.cache);return e?Ie.resolve(e):n.getMany(t).then(function(e){return t.trans._cache={keys:t.keys,values:"clone"===t.cache?A(e):e},e})},mutate:function(e){return"add"!==e.type&&(e.trans._cache=null),n.mutate(e)}})}}}};function Un(e){return!("from"in e)}var Ln=function(e,t){if(!this){var n=new Ln;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 Vn(e,t,n){var r=St(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(Un(e))return u(e,{from:t,to:n,d:1});var o=e.l,r=e.r;if(St(n,e.from)<0)return o?Vn(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Gn(e);if(0<St(t,e.to))return r?Vn(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Gn(e);St(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<St(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);n=!e.r;o&&!e.l&&Wn(e,o),r&&n&&Wn(e,r)}}function Wn(e,t){Un(t)||function e(t,n){var r=n.from,o=n.to,i=n.l,n=n.r;Vn(t,r,o),i&&e(t,i),n&&e(t,n)}(e,t)}function zn(e,t){var n=Yn(t),r=n.next();if(r.done)return!1;for(var o=r.value,i=Yn(e),a=i.next(o.from),u=a.value;!r.done&&!a.done;){if(St(u.from,o.to)<=0&&0<=St(u.to,o.from))return!0;St(o.from,u.from)<0?o=(r=n.next(u.from)).value:u=(a=i.next(o.from)).value}return!1}function Yn(e){var n=Un(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&&St(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||St(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 Gn(e){var t,n,r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),o=1<r?"r":r<-1?"l":"";o&&(t="r"==o?"l":"r",n=g({},e),r=e[o],e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],(e[t]=n).d=Hn(n)),e.d=Hn(e)}function Hn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}r(Ln.prototype,((W={add:function(e){return Wn(this,e),this},addKey:function(e){return Vn(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return Vn(t,e,e)}),this}})[I]=function(){return Yn(this)},W));var Qn={stack:"dbcore",level:0,create:function(r){var v=r.schema.name,m=new Ln(r.MIN_KEY,r.MAX_KEY);return g(g({},r),{table:function(d){function e(e){var e=(t=e.query).index,t=t.range;return[e,new Ln(null!==(e=t.lower)&&void 0!==e?e:r.MIN_KEY,null!==(t=t.upper)&&void 0!==t?t:r.MAX_KEY)]}var p=r.table(d),y=p.schema,t=y.primaryKey,c=t.extractKey,l=t.outbound,n=g(g({},p),{mutate:function(e){function n(e){return e="idb://".concat(v,"/").concat(d,"/").concat(e),r[e]||(r[e]=new Ln)}var t=e.trans,r=t.mutatedParts||(t.mutatedParts={}),o=n(""),s=n(":dels"),c=e.type,t="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],l=t[0],f=t[1],h=e.trans._cache;return p.mutate(e).then(function(e){var t,i,a,u;return b(l)?("delete"!==c&&(l=e.results),o.addKeys(l),(t=Nn(l,h))||"add"===c||s.addKeys(l),(t||f)&&(i=n,a=t,u=f,y.indexes.forEach(function(t){var n=i(t.name||"");function r(e){return null!=e?t.extractKey(e):null}function o(e){return t.multiEntry&&b(e)?e.forEach(function(e){return n.addKey(e)}):n.addKey(e)}(a||u).forEach(function(e,t){var n=a&&r(a[t]),t=u&&r(u[t]);0!==St(n,t)&&(null!=n&&o(n),null!=t&&o(t))})}))):l?(t={from:l.lower,to:l.upper},s.add(t),o.add(t)):(o.add(m),s.add(m),y.indexes.forEach(function(e){return n(e.name).add(m)})),e})}}),f={get:function(e){return[t,new Ln(e.key)]},getMany:function(e){return[t,(new Ln).addKeys(e.keys)]},count:e,query:e,openCursor:e};return x(f).forEach(function(s){n[s]=function(o){var t=je.subscr;if(t){var e=function(e){e="idb://".concat(v,"/").concat(d,"/").concat(e);return t[e]||(t[e]=new Ln)},i=e(""),a=e(":dels"),n=f[s](o),r=n[0],n=n[1];if(e(r.name||"").add(n),!r.isPrimaryKey){if("count"!==s){var u="query"===s&&l&&o.values&&p.query(g(g({},o),{values:!1}));return p[s].apply(this,arguments).then(function(t){if("query"===s){if(l&&o.values)return u.then(function(e){e=e.result;return i.addKeys(e),t});var e=o.values?t.result.map(c):t.result;(o.values?i:a).addKeys(e)}else if("openCursor"===s){var n=t,r=o.values;return n&&Object.create(n,{key:{get:function(){return a.addKey(n.primaryKey),n.key}},primaryKey:{get:function(){var e=n.primaryKey;return a.addKey(e),e}},value:{get:function(){return r&&i.addKey(n.primaryKey),n.value}}})}return t})}a.add(m)}}return p[s].apply(this,arguments)}}),n}})}};var Xn=(Jn.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(wn),n.stores({}),this._state.autoSchema=!1,n)},Jn.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||je.letThrough||this._vip)?e():new Ie(function(e,t){if(n._state.openComplete)return t(new Z.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return void t(new Z.DatabaseClosed);n.open().catch(te)}n._state.dbReadyPromise.then(e,t)}).then(e)},Jn.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,o=e.name;o&&this.unuse({stack:t,name:o});e=this._middlewares[t]||(this._middlewares[t]=[]);return e.push({stack:t,create:n,level:null==r?10:r,name:o}),e.sort(function(e,t){return e.level-t.level}),this},Jn.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},Jn.prototype.open=function(){return In(this)},Jn.prototype._close=function(){var n=this._state,e=mt.indexOf(this);if(0<=e&&mt.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}n.dbReadyPromise=new Ie(function(e){n.dbReadyResolve=e}),n.openCanceller=new Ie(function(e,t){n.cancelOpen=t})},Jn.prototype.close=function(){this._close();var e=this._state;this._options.autoOpen=!1,e.dbOpenError=new Z.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)},Jn.prototype.delete=function(){var o=this,n=0<arguments.length,i=this._state;return new Ie(function(r,t){function e(){o.close();var e=o._deps.indexedDB.deleteDatabase(o.name);e.onsuccess=Ye(function(){var e,t,n;e=o._deps,t=o.name,n=e.indexedDB,e=e.IDBKeyRange,Cn(n)||t===wt||An(n,e).delete(t).catch(te),r()}),e.onerror=en(t),e.onblocked=o._fireOnBlocked}if(n)throw new Z.InvalidArgument("Arguments not allowed in db.delete()");i.isBeingOpened?i.dbReadyPromise.then(e):e()})},Jn.prototype.backendDB=function(){return this.idbdb},Jn.prototype.isOpen=function(){return null!==this.idbdb},Jn.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},Jn.prototype.hasFailed=function(){return null!==this._state.dbOpenError},Jn.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(Jn.prototype,"tables",{get:function(){var t=this;return x(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),Jn.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new Z.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,K(o),n]}.apply(this,arguments);return this._transaction.apply(this,e)},Jn.prototype._transaction=function(e,t,n){var r=this,o=je.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);var i,a,u=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=t.map(function(e){e=e instanceof r.Table?e.name:e;if("string"!=typeof e)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e}),"r"==e||e===xt)i=xt;else{if("rw"!=e&&e!=kt)throw new Z.InvalidArgument("Invalid transaction mode: "+e);i=kt}if(o){if(o.mode===xt&&i===kt){if(!u)throw new Z.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(function(e){if(o&&-1===o.storeNames.indexOf(e)){if(!u)throw new Z.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),u&&o&&!o.active&&(o=null)}}catch(n){return o?o._promise(null,function(e,t){t(n)}):ht(n)}var s=function o(i,a,u,s,c){return Ie.resolve().then(function(){var e=je.transless||je,t=i._createTransaction(a,u,i._dbSchema,s),e={trans:t,transless:e};if(s)t.idbtrans=s.idbtrans;else try{t.create(),i._state.PR1398_maxLoop=3}catch(e){return e.name===J.InvalidState&&i.isOpen()&&0<--i._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),i._close(),i.open().then(function(){return o(i,a,u,null,c)})):ht(e)}var n,r=F(c);return r&&et(),e=Ie.follow(function(){var e;(n=c.call(t,t))&&(r?(e=tt.bind(null,null),n.then(e,e)):"function"==typeof n.next&&"function"==typeof n.throw&&(n=Tn(n)))},e),(n&&"function"==typeof n.then?Ie.resolve(n).then(function(e){return t.active?e:ht(new Z.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):e.then(function(){return n})).then(function(e){return s&&t._resolve(),t._completion.then(function(){return e})}).catch(function(e){return t._reject(e),ht(e)})})}.bind(null,this,i,a,o,n);return o?o._promise(i,s,"lock"):je.trans?at(je.transless,function(){return r._whenReady(s)}):this._whenReady(s)},Jn.prototype.table=function(e){if(!m(this._allTables,e))throw new Z.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},Jn);function Jn(e,t){var i=this;this._middlewares={},this.verno=0;var n=Jn.dependencies;this._options=t=g({addons:Jn.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};n=t.addons;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var a,r,u,o,s,c={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:te,dbReadyPromise:null,cancelOpen:te,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};c.dbReadyPromise=new Ie(function(e){c.dbReadyResolve=e}),c.openCanceller=new Ie(function(e,t){c.cancelOpen=t}),this._state=c,this.name=e,this.on=It(this,"populate","blocked","versionchange","close",{ready:[ce,te]}),this.on.ready.subscribe=v(this.on.ready.subscribe,function(o){return function(n,r){Jn.vip(function(){var t,e=i._state;e.openComplete?(e.dbOpenError||Ie.resolve().then(n),r&&o(n)):e.onReadyBeingFired?(e.onReadyBeingFired.push(n),r&&o(n)):(o(n),t=i,r||o(function e(){t.on.ready.unsubscribe(n),t.on.ready.unsubscribe(e)}))})}}),this.Collection=(a=this,Tt(Lt.prototype,function(e,t){this.db=a;var n=Pt,r=null;if(t)try{n=t()}catch(e){r=e}var o=e._ctx,t=o.table,e=t.hook.reading.fire;this._ctx={table:t,index:o.index,isPrimKey:!o.index||t.schema.primKey.keyPath&&o.index===t.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:e!==ne?e:null}})),this.Table=(r=this,Tt(Ct.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:It(null,{creating:[ie,te],reading:[re,ne],updating:[ue,te],deleting:[ae,te]})})),this.Transaction=(u=this,Tt(an.prototype,function(e,t,n,r,o){var i=this;this.db=u,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=It(this,"complete","error","abort"),this.parent=o||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new Ie(function(e,t){i._resolve=e,i._reject=t}),this._completion.then(function(){i.active=!1,i.on.complete.fire()},function(e){var t=i.active;return i.active=!1,i.on.error.fire(e),i.parent?i.parent._reject(e):t&&i.idbtrans&&i.idbtrans.abort(),ht(e)})})),this.Version=(o=this,Tt(Sn.prototype,function(e){this.db=o,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,Tt($t.prototype,function(e,t,n){if(this.db=s,this._ctx={table:e,index:":id"===t?null:t,or:n},this._cmp=this._ascending=St,this._descending=function(e,t){return St(t,e)},this._max=function(e,t){return 0<St(e,t)?e:t},this._min=function(e,t){return St(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(i.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(i.name,"'. Closing db now to resume the delete request.")),i.close()}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('".concat(i.name,"') was blocked")):console.warn("Upgrade '".concat(i.name,"' blocked by other connection holding version ").concat(e.oldVersion/10))}),this._maxKey=fn(t.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new i.Transaction(e,t,n,i._options.chromeTransactionDurability,r)},this._fireOnBlocked=function(t){i.on("blocked").fire(t),mt.filter(function(e){return e.name===i.name&&e!==i&&!e._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(Rn),this.use(Mn),this.use(Qn),this.use(qn),this.vip=Object.create(this,{_vip:{value:!0}}),n.forEach(function(e){return e(i)})}var $n,W="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable",Zn=(er.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},er.prototype[W]=function(){return this},er);function er(e){this._subscribe=e}function tr(t,n){return x(n).forEach(function(e){Wn(t[e]||(t[e]=new Ln),n[e])}),t}function nr(d){return new Zn(function(n){var r=F(d);var o=!1,i={},a={},u={get closed(){return o},unsubscribe:function(){o=!0,on.storagemutated.unsubscribe(f)}};n.start&&n.start(u);var s=!1,c=!1;function l(){return x(a).some(function(e){return i[e]&&zn(i[e],a[e])})}var f=function(e){tr(i,e),l()&&h()},h=function(){var t,e;s||o||(i={},e=function(e){r&&et();var t=function(){return Ze(d,{subscr:e,trans:null})},t=je.trans?at(je.transless,t):t();return r&&t.then(tt,tt),t}(t={}),c||(on(nn,f),c=!0),s=!0,Promise.resolve(e).then(function(e){s=!1,o||(l()?h():(i={},a=t,n.next&&n.next(e)))},function(e){["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||(s=!1,n.error&&n.error(e),u.unsubscribe())}))};return h(),u})}try{$n={indexedDB:h.indexedDB||h.mozIndexedDB||h.webkitIndexedDB||h.msIndexedDB,IDBKeyRange:h.IDBKeyRange||h.webkitIDBKeyRange}}catch(e){$n={indexedDB:null,IDBKeyRange:null}}var rr=Xn;function or(e){var t=ar;try{ar=!0,on.storagemutated.fire(e)}finally{ar=t}}r(rr,g(g({},e),{delete:function(e){return new rr(e,{addons:[]}).delete()},exists:function(e){return new rr(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=rr.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Cn(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==wt})}):An(n,t).toCollection().primaryKeys()).then(e)}catch(e){return ht(new Z.MissingAPI)}var t,n},defineClass:function(){return function(e){u(this,e)}},ignoreTransaction:function(e){return je.trans?at(je.transless,e):e()},vip:Dn,async:function(t){return function(){try{var e=Tn(t.apply(this,arguments));return e&&"function"==typeof e.then?e:Ie.resolve(e)}catch(e){return ht(e)}}},spawn:function(e,t,n){try{var r=Tn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Ie.resolve(r)}catch(e){return ht(e)}},currentTransaction:{get:function(){return je.trans||null}},waitFor:function(e,t){t=Ie.resolve("function"==typeof e?rr.ignoreTransaction(e):e).timeout(t||6e4);return je.trans?je.trans.waitFor(t):t},Promise:Ie,debug:{get:function(){return M},set:function(e){N(e,"dexie"===e?function(){return!0}:dt)}},derive:i,extend:u,props:r,override:v,Events:It,on:on,liveQuery:nr,extendObservabilitySet:tr,getByKeyPath:E,setByKeyPath:P,delByKeyPath:function(t,e){"string"==typeof e?P(t,e,void 0):"length"in e&&[].map.call(e,function(e){P(t,e,void 0)})},shallowClone:O,deepClone:A,getObjectDiff:Fn,cmp:St,asap:w,minKey:-1/0,addons:[],connections:mt,errnames:J,dependencies:$n,semVer:z,version:z.split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),rr.maxKey=fn(rr.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(on(nn,function(e){var t;ar||(gt?(t=document.createEvent("CustomEvent")).initCustomEvent(rn,!0,!0,e):t=new CustomEvent(rn,{detail:e}),ar=!0,dispatchEvent(t),ar=!1)}),addEventListener(rn,function(e){e=e.detail;ar||or(e)}));var ir,ar=!1;return"undefined"!=typeof BroadcastChannel?("function"==typeof(ir=new BroadcastChannel(rn)).unref&&ir.unref(),on(nn,function(e){ar||ir.postMessage(e)}),ir.onmessage=function(e){e.data&&or(e.data)}):"undefined"!=typeof self&&"undefined"!=typeof navigator&&(on(nn,function(t){try{ar||("undefined"!=typeof localStorage&&localStorage.setItem(rn,JSON.stringify({trig:Math.random(),changedParts:t})),"object"==typeof self.clients&&o([],self.clients.matchAll({includeUncontrolled:!0}),!0).forEach(function(e){return e.postMessage({type:rn,changedParts:t})}))}catch(e){}}),"undefined"!=typeof addEventListener&&addEventListener("storage",function(e){e.key!==rn||(e=JSON.parse(e.newValue))&&or(e.changedParts)}),(z=self.document&&navigator.serviceWorker)&&z.addEventListener("message",function(e){e=e.data;e&&e.type===rn&&or(e.changedParts)})),Ie.rejectionMapper=function(e,t){return!e||e instanceof G||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ee[e.name]?e:(t=new ee[e.name](t||e.message,e),"stack"in e&&l(t,"stack",{get:function(){return this.inner.stack}}),t)},N(M,dt),g(Xn,Object.freeze({__proto__:null,Dexie:Xn,liveQuery:nr,Entity:Kt,cmp:St,default:Xn,RangeSet:Ln,mergeRanges:Wn,rangesOverlap:zn}),{default:Xn}),Xn});
1
+ (function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Dexie=t()})(this,function(){"use strict";var s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};var g=function(){return(g=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function o(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,x=Object.keys,b=Array.isArray;function u(t,n){return"object"!=typeof n||x(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||h.Promise||(h.Promise=Promise);var c=Object.getPrototypeOf,n={}.hasOwnProperty;function m(e,t){return n.call(e,t)}function r(t,n){"function"==typeof n&&(n=n(c(t))),("undefined"==typeof Reflect?x:Reflect.ownKeys)(n).forEach(function(e){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 i(t){return{from:function(e){return t.prototype=Object.create(e.prototype),l(t.prototype,"constructor",t),{extend:r.bind(null,t.prototype)}}}}var f=Object.getOwnPropertyDescriptor;function d(e,t){return f(e,t)||(e=c(e))&&d(e,t)}var p=[].slice;function y(e,t,n){return p.call(e,t,n)}function v(e,t){return t(e)}function _(e){if(!e)throw new Error("Assertion Failed")}function w(e){h.setImmediate?setImmediate(e):setTimeout(e,0)}function k(e,r){return e.reduce(function(e,t,n){n=r(t,n);return n&&(e[n[0]]=n[1]),e},{})}function E(e,t){if(m(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,o=t.length;r<o;++r){var i=E(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var u=e[t.substr(0,a)];return void 0===u?void 0:E(u,t.substr(a+1))}}function P(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){_("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)P(e,t[r],n[r])}else{var i,a,u=t.indexOf(".");-1!==u?(i=t.substr(0,u),""===(a=t.substr(u+1))?void 0===n?b(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n:P(u=!(u=e[i])||!m(e,i)?e[i]={}:u,a,n)):void 0===n?b(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function O(e){var t,n={};for(t in e)m(e,t)&&(n[t]=e[t]);return n}var t=[].concat;function K(e){return t.apply([],e)}var e="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(K([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return h[e]}),S=e.map(function(e){return h[e]});k(e,function(e){return[e,!0]});var j=null;function A(e){j="undefined"!=typeof WeakMap&&new WeakMap;e=function e(t){if(!t||"object"!=typeof t)return t;var n=j&&j.get(t);if(n)return n;if(b(t)){n=[],j&&j.set(t,n);for(var r=0,o=t.length;r<o;++r)n.push(e(t[r]))}else if(0<=S.indexOf(t.constructor))n=t;else{var i,a=c(t);for(i in n=a===Object.prototype?{}:Object.create(a),j&&j.set(t,n),t)m(t,i)&&(n[i]=e(t[i]))}return n}(e);return j=null,e}var C={}.toString;function D(e){return C.call(e).slice(8,-1)}var I="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",T="symbol"==typeof I?function(e){var t;return null!=e&&(t=e[I])&&t.apply(e)}:function(){return null},B={};function R(e){var t,n,r,o;if(1===arguments.length){if(b(e))return e.slice();if(this===B&&"string"==typeof e)return[e];if(o=T(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var F="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},M="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function N(e,t){M=e,q=t}var q=function(){return!0},U=!new Error("").stack;function L(){if(U)try{throw new Error}catch(e){return e}return new Error}function V(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(q).map(function(e){return"\n"+e}).join("")):""}var W=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],z=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(W),Y={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function G(e,t){this._e=L(),this.name=e,this.message=t}function H(e,t){return e+". Errors: "+Object.keys(t).map(function(e){return t[e].toString()}).filter(function(e,t,n){return n.indexOf(e)===t}).join("\n")}function Q(e,t,n,r){this._e=L(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=H(e,t)}function X(e,t){this._e=L(),this.name="BulkError",this.failures=Object.keys(t).map(function(e){return t[e]}),this.failuresByPos=t,this.message=H(e,this.failures)}i(G).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+V(this._e,2))}},toString:function(){return this.name+": "+this.message}}),i(Q).from(G),i(X).from(G);var J=z.reduce(function(e,t){return e[t]=t+"Error",e},{}),$=G,Z=z.reduce(function(e,n){var r=n+"Error";function t(e,t){this._e=L(),this.name=r,e?"string"==typeof e?(this.message="".concat(e).concat(t?"\n "+t:""),this.inner=t||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=Y[n]||r,this.inner=null)}return i(t).from($),e[n]=t,e},{});Z.Syntax=SyntaxError,Z.Type=TypeError,Z.Range=RangeError;var ee=W.reduce(function(e,t){return e[t+"Error"]=Z[t],e},{});e=z.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=Z[t]),e},{});function te(){}function ne(e){return e}function re(t,n){return null==t||t===ne?n:function(e){return n(t(e))}}function oe(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ie(o,i){return o===te?i:function(){var e=o.apply(this,arguments);void 0!==e&&(arguments[0]=e);var t=this.onsuccess,n=this.onerror;this.onsuccess=null,this.onerror=null;var r=i.apply(this,arguments);return t&&(this.onsuccess=this.onsuccess?oe(t,this.onsuccess):t),n&&(this.onerror=this.onerror?oe(n,this.onerror):n),void 0!==r?r:e}}function ae(n,r){return n===te?r:function(){n.apply(this,arguments);var e=this.onsuccess,t=this.onerror;this.onsuccess=this.onerror=null,r.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?oe(e,this.onsuccess):e),t&&(this.onerror=this.onerror?oe(t,this.onerror):t)}}function ue(o,i){return o===te?i:function(e){var t=o.apply(this,arguments);u(e,t);var n=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;e=i.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?oe(n,this.onsuccess):n),r&&(this.onerror=this.onerror?oe(r,this.onerror):r),void 0===t?void 0===e?void 0:e:u(t,e)}}function se(e,t){return e===te?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ce(o,i){return o===te?i:function(){var e=o.apply(this,arguments);if(e&&"function"==typeof e.then){for(var t=this,n=arguments.length,r=new Array(n);n--;)r[n]=arguments[n];return e.then(function(){return i.apply(t,r)})}return i.apply(this,arguments)}}e.ModifyError=Q,e.DexieError=G,e.BulkError=X;var le={},fe=100,he=100,W="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,c(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,c(t),e]}(),de=W[0],pe=W[1],ye=W[2],ve=pe&&pe.then,me=de&&de.constructor,ge=!!ye,be=!1,_e=ye?function(){ye.then(Ue)}:h.setImmediate?setImmediate.bind(null,Ue):h.MutationObserver?function(){var e=document.createElement("div");new MutationObserver(function(){Ue(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:function(){setTimeout(Ue,0)},we=function(e,t){Ae.push([e,t]),ke&&(_e(),ke=!1)},xe=!0,ke=!0,Ee=[],Pe=[],Oe=null,Ke=ne,Se={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ft,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(function(e){try{ft(e[0],e[1])}catch(e){}})}},je=Se,Ae=[],Ce=0,De=[];function Ie(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=te,this._lib=!1;var t=this._PSD=je;if(M&&(this._stackHolder=L(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==le)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Re(this,this._value))}this._state=null,this._value=null,++t.ref,function t(r,e){try{e(function(n){if(null===r._state){if(n===r)throw new TypeError("A promise cannot be resolved with itself.");var e=r._lib&&Le();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof Ie?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Fe(r)),e&&Ve()}},Re.bind(null,r))}catch(e){Re(r,e)}}(this,e)}var Te={get:function(){var u=je,t=Je;function e(n,r){var o=this,i=!u.global&&(u!==je||t!==Je),a=i&&!tt(),e=new Ie(function(e,t){Me(o,new Be(st(n,u,i,a),st(r,u,i,a),e,t,u))});return M&&qe(e,this),e}return e.prototype=le,e},set:function(e){l(this,"then",e&&e.prototype===le?Te:{get:function(){return e},set:Te.set})}};function Be(e,t,n,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=o}function Re(t,n){var e,r;Pe.push(n),null===t._state&&(e=t._lib&&Le(),n=Ke(n),t._state=!1,t._value=n,M&&null!==n&&"object"==typeof n&&!n._promise&&function(e,t,n){try{e.apply(null,n)}catch(e){t&&t(e)}}(function(){var e=d(n,"stack");n._promise=t,l(n,"stack",{get:function(){return be?e&&(e.get?e.get.apply(n):e.value):t.stack}})}),r=t,Ee.some(function(e){return e._value===r._value})||Ee.push(r),Fe(t),e&&Ve())}function Fe(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Me(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===Ce&&(++Ce,we(function(){0==--Ce&&We()},[]))}function Me(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Ce,we(Ne,[n,e,t])}else e._listeners.push(t)}function Ne(e,t,n){try{var r,o=(Oe=t)._value;t._state?r=e(o):(Pe.length&&(Pe=[]),r=e(o),-1===Pe.indexOf(o)&&function(e){var t=Ee.length;for(;t;)if(Ee[--t]._value===e._value)return Ee.splice(t,1)}(t)),n.resolve(r)}catch(e){n.reject(e)}finally{Oe=null,0==--Ce&&We(),--n.psd.ref||n.psd.finalize()}}function qe(e,t){var n=t?t._numPrev+1:0;n<fe&&(e._prev=t,e._numPrev=n)}function Ue(){Le()&&Ve()}function Le(){var e=xe;return ke=xe=!1,e}function Ve(){var e,t,n;do{for(;0<Ae.length;)for(e=Ae,Ae=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<Ae.length);ke=xe=!0}function We(){var e=Ee;Ee=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=De.slice(0),n=t.length;n;)t[--n]()}function ze(e){return new Ie(le,!1,e)}function Ye(n,r){var o=je;return function(){var e=Le(),t=je;try{return ot(o,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{ot(t,!1),e&&Ve()}}}r(Ie.prototype,{then:Te,_then:function(e,t){Me(this,new Be(null,null,e,t,je))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=e,n=arguments[1];return"function"==typeof t?this.then(null,function(e){return(e instanceof t?n:ze)(e)}):this.then(null,function(e){return(e&&e.name===t?n:ze)(e)})},finally:function(t){return this.then(function(e){return t(),e},function(e){return t(),ze(e)})},stack:{get:function(){if(this._stack)return this._stack;try{be=!0;var e=function e(t,n,r){if(n.length===r)return n;var o="";{var i,a,u;!1===t._state&&(null!=(i=t._value)?(a=i.name||"Error",u=i.message||i,o=V(i,0)):(a=i,u=""),n.push(a+(u?": "+u:"")+o))}M&&((o=V(t._stackHolder,2))&&-1===n.indexOf(o)&&n.push(o),t._prev&&e(t._prev,n,r));return n}(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{be=!1}}},timeout:function(r,o){var i=this;return r<1/0?new Ie(function(e,t){var n=setTimeout(function(){return t(new Z.Timeout(o))},r);i.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&l(Ie.prototype,Symbol.toStringTag,"Dexie.Promise"),Se.env=it(),r(Ie,{all:function(){var i=R.apply(null,arguments).map(nt);return new Ie(function(n,r){0===i.length&&n([]);var o=i.length;i.forEach(function(e,t){return Ie.resolve(e).then(function(e){i[t]=e,--o||n(i)},r)})})},resolve:function(n){if(n instanceof Ie)return n;if(n&&"function"==typeof n.then)return new Ie(function(e,t){n.then(e,t)});var e=new Ie(le,!0,n);return qe(e,Oe),e},reject:ze,race:function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(t,n){e.map(function(e){return Ie.resolve(e).then(t,n)})})},PSD:{get:function(){return je},set:function(e){return je=e}},totalEchoes:{get:function(){return Je}},newPSD:Ze,usePSD:at,scheduler:{get:function(){return we},set:function(e){we=e}},rejectionMapper:{get:function(){return Ke},set:function(e){Ke=e}},follow:function(o,n){return new Ie(function(e,t){return Ze(function(n,r){var e=je;e.unhandleds=[],e.onunhandled=r,e.finalize=oe(function(){var t,e=this;t=function(){0===e.unhandleds.length?n():r(e.unhandleds[0])},De.push(function e(){t(),De.splice(De.indexOf(e),1)}),++Ce,we(function(){0==--Ce&&We()},[])},e.finalize),o()},n,e,t)})}}),me&&(me.allSettled&&l(Ie,"allSettled",function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(n){0===e.length&&n([]);var r=e.length,o=new Array(r);e.forEach(function(e,t){return Ie.resolve(e).then(function(e){return o[t]={status:"fulfilled",value:e}},function(e){return o[t]={status:"rejected",reason:e}}).then(function(){return--r||n(o)})})})}),me.any&&"undefined"!=typeof AggregateError&&l(Ie,"any",function(){var e=R.apply(null,arguments).map(nt);return new Ie(function(n,r){0===e.length&&r(new AggregateError([]));var o=e.length,i=new Array(o);e.forEach(function(e,t){return Ie.resolve(e).then(function(e){return n(e)},function(e){i[t]=e,--o||r(new AggregateError(i))})})})}));var Ge={awaits:0,echoes:0,id:0},He=0,Qe=[],Xe=0,Je=0,$e=0;function Ze(e,t,n,r){var o=je,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++$e;var a=Se.env;i.env=ge?{Promise:Ie,PromiseProp:{value:Ie,configurable:!0,writable:!0},all:Ie.all,race:Ie.race,allSettled:Ie.allSettled,any:Ie.any,resolve:Ie.resolve,reject:Ie.reject,nthen:ct(a.nthen,i),gthen:ct(a.gthen,i)}:{},t&&u(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};r=at(i,e,n,r);return 0===i.ref&&i.finalize(),r}function et(){return Ge.id||(Ge.id=++He),++Ge.awaits,Ge.echoes+=he,Ge.id}function tt(){return!!Ge.awaits&&(0==--Ge.awaits&&(Ge.id=0),Ge.echoes=Ge.awaits*he,!0)}function nt(e){return Ge.echoes&&e&&e.constructor===me?(et(),e.then(function(e){return tt(),e},function(e){return tt(),ht(e)})):e}function rt(){var e=Qe[Qe.length-1];Qe.pop(),ot(e,!1)}function ot(e,t){var n,r=je;(t?!Ge.echoes||Xe++&&e===je:!Xe||--Xe&&e===je)||ut(t?function(e){++Je,Ge.echoes&&0!=--Ge.echoes||(Ge.echoes=Ge.id=0),Qe.push(je),ot(e,!0)}.bind(null,e):rt),e!==je&&(je=e,r===Se&&(Se.env=it()),ge&&(n=Se.env.Promise,t=e.env,pe.then=t.nthen,n.prototype.then=t.gthen,(r.global||e.global)&&(Object.defineProperty(h,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function it(){var e=h.Promise;return ge?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(h,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:pe.then,gthen:e.prototype.then}:{}}function at(e,t,n,r,o){var i=je;try{return ot(e,!0),t(n,r,o)}finally{ot(i,!1)}}function ut(e){ve.call(de,e)}function st(t,n,r,o){return"function"!=typeof t?t:function(){var e=je;r&&et(),ot(n,!0);try{return t.apply(this,arguments)}finally{ot(e,!1),o&&ut(tt)}}}function ct(n,r){return function(e,t){return n.call(this,st(e,r),st(t,r))}}-1===(""+ve).indexOf("[native code]")&&(et=tt=te);var lt="unhandledrejection";function ft(e,t){var n;try{n=t.onuncatched(e)}catch(e){}if(!1!==n)try{var r,o={promise:t,reason:e};if(h.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(lt,!0,!0),u(r,o)):h.CustomEvent&&u(r=new CustomEvent(lt,{detail:o}),o),r&&h.dispatchEvent&&(dispatchEvent(r),!h.PromiseRejectionEvent&&h.onunhandledrejection))try{h.onunhandledrejection(r)}catch(e){}M&&r&&!r.defaultPrevented&&console.warn("Unhandled rejection: ".concat(e.stack||e))}catch(e){}}var ht=Ie.reject;function dt(e){return!/(dexie\.js|dexie\.min\.js)/.test(e)}var z="4.0.1-alpha.8",pt=String.fromCharCode(65535),yt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",vt="String expected.",mt=[],gt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),bt=gt,_t=gt,wt="__dbnames",xt="readonly",kt="readwrite";function Et(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Pt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ot(t){return"string"!=typeof t||/\./.test(t)?function(e){return e}:function(e){return void 0===e[t]&&t in e&&delete(e=A(e))[t],e}}function Kt(){throw Z.Type()}function St(e,t){try{var n=jt(e),r=jt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,o=n<r?n:r,i=0;i<o;++i)if(e[i]!==t[i])return e[i]<t[i]?-1:1;return n===r?0:n<r?-1:1}(At(e),At(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,o=n<r?n:r,i=0;i<o;++i){var a=St(e[i],t[i]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function jt(e){var t=typeof e;if("object"!=t)return t;if(ArrayBuffer.isView(e))return"binary";e=D(e);return"ArrayBuffer"===e?"binary":e}function At(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Ct=(Dt.prototype._trans=function(e,r,t){var n=this._tx||je.trans,o=this.name;function i(e,t,n){if(!n.schema[o])throw new Z.NotFound("Table "+o+" not part of transaction");return r(n.idbtrans,n)}var a=Le();try{return n&&n.db===this.db?n===je.trans?n._promise(e,i,t):Ze(function(){return n._promise(e,i,t)},{trans:n,transless:je.transless||je}):function t(n,r,o,i){if(n.idbdb&&(n._state.openComplete||je.letThrough||n._vip)){var a=n._createTransaction(r,o,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(e){return e.name===J.InvalidState&&n.isOpen()&&0<--n._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),n._close(),n.open().then(function(){return t(n,r,o,i)})):ht(e)}return a._promise(r,function(e,t){return Ze(function(){return je.trans=a,i(e,t,a)})}).then(function(e){return a._completion.then(function(){return e})})}if(n._state.openComplete)return ht(new Z.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return ht(new Z.DatabaseClosed);n.open().catch(te)}return n._state.dbReadyPromise.then(function(){return t(n,r,o,i)})}(this.db,e,[this.name],i)}finally{a&&Ve()}},Dt.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)},Dt.prototype.where=function(i){if("string"==typeof i)return new this.db.WhereClause(this,i);if(b(i))return new this.db.WhereClause(this,"[".concat(i.join("+"),"]"));var n=x(i);if(1===n.length)return this.where(n[0]).equals(i[n[0]]);var e=this.schema.indexes.concat(this.schema.primKey).filter(function(t){return t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})&&t.keyPath.every(function(e){return 0<=n.indexOf(e)})})[0];if(e&&this.db._maxKey!==pt)return this.where(e.name).equals(e.keyPath.map(function(e){return i[e]}));!e&&M&&console.warn("The query ".concat(JSON.stringify(i)," on ").concat(this.name," would benefit of a ")+"compound index [".concat(n.join("+"),"]"));var a=this.schema.idxByName,r=this.db._deps.indexedDB;function u(e,t){return 0===r.cmp(e,t)}var t=n.reduce(function(e,t){var n=e[0],r=e[1],e=a[t],o=i[t];return[n||e,n||!e?Et(r,e&&e.multi?function(e){e=E(e,t);return b(e)&&e.some(function(e){return u(o,e)})}:function(e){return u(o,E(e,t))}):r]},[null,null]),o=t[0],t=t[1];return o?this.where(o.name).equals(i[o.keyPath]).filter(t):e?this.filter(t):this.where(n).equals("")},Dt.prototype.filter=function(e){return this.toCollection().and(e)},Dt.prototype.count=function(e){return this.toCollection().count(e)},Dt.prototype.offset=function(e){return this.toCollection().offset(e)},Dt.prototype.limit=function(e){return this.toCollection().limit(e)},Dt.prototype.each=function(e){return this.toCollection().each(e)},Dt.prototype.toArray=function(e){return this.toCollection().toArray(e)},Dt.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},Dt.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,b(e)?"[".concat(e.join("+"),"]"):e))},Dt.prototype.reverse=function(){return this.toCollection().reverse()},Dt.prototype.mapToClass=function(r){var e,t=this.db,n=this.name;function o(){return null!==e&&e.apply(this,arguments)||this}(this.schema.mappedClass=r).prototype instanceof Kt&&(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(o,e=r),Object.defineProperty(o.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),o.prototype.table=function(){return n},r=o);for(var i=new Set,a=r.prototype;a;a=c(a))Object.getOwnPropertyNames(a).forEach(function(e){return i.add(e)});function u(e){if(!e)return e;var t,n=Object.create(r.prototype);for(t in e)if(!i.has(t))try{n[t]=e[t]}catch(e){}return n}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=u,this.hook("reading",u),r},Dt.prototype.defineClass=function(){return this.mapToClass(function(e){u(this,e)})},Dt.prototype.add=function(t,n){var r=this,e=this.schema.primKey,o=e.auto,i=e.keyPath,a=t;return i&&o&&(a=Ot(i)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):e.lastResult}).then(function(e){if(i)try{P(t,i,e)}catch(e){}return e})},Dt.prototype.update=function(t,n){if("object"!=typeof t||b(t))return this.where(":id").equals(t).modify(n);var e=E(t,this.schema.primKey.keyPath);if(void 0===e)return ht(new Z.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof n?x(n).forEach(function(e){P(t,e,n[e])}):n(t,{value:t,primKey:e})}catch(e){}return this.where(":id").equals(e).modify(n)},Dt.prototype.put=function(t,n){var r=this,e=this.schema.primKey,o=e.auto,i=e.keyPath,a=t;return i&&o&&(a=Ot(i)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):e.lastResult}).then(function(e){if(i)try{P(t,i,e)}catch(e){}return e})},Dt.prototype.delete=function(t){var n=this;return this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"delete",keys:[t]})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):void 0})},Dt.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:Pt})}).then(function(e){return e.numFailures?Ie.reject(e.failures[0]):void 0})},Dt.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)})})})},Dt.prototype.bulkAdd=function(r,e,t){var i=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=i.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new Z.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var o=r.length,t=t&&n?r.map(Ot(t)):r;return i.core.mutate({trans:e,type:"add",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new X("".concat(i.name,".bulkAdd(): ").concat(t," of ").concat(o," operations failed"),e)})})},Dt.prototype.bulkPut=function(r,e,t){var i=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=i.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new Z.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var o=r.length,t=t&&n?r.map(Ot(t)):r;return i.core.mutate({trans:e,type:"put",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new X("".concat(i.name,".bulkPut(): ").concat(t," of ").concat(o," operations failed"),e)})})},Dt.prototype.bulkUpdate=function(t){var h=this,n=this.core,r=t.map(function(e){return e.key}),o=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,o=c[t];if(o){for(var i=0,a=Object.keys(r);i<a.length;i++){var u=a[i],s=r[u];if(u===h.schema.primKey.keyPath){if(0!==St(s,n))throw new Z.Constraint("Cannot update primary key in bulkUpdate()")}else P(o,u,s)}d.push(t),l.push(n),f.push(o)}});var s=l.length;return n.mutate({trans:e,type:"put",keys:l,values:f,updates:{keys:r,changeSpecs:o}}).then(function(e){var t=e.numFailures,n=e.failures;if(0===t)return s;for(var r=0,o=Object.keys(n);r<o.length;r++){var i,a=o[r],u=d[Number(a)];null!=u&&(i=n[a],delete n[a],n[u]=i)}throw new X("".concat(h.name,".bulkUpdate(): ").concat(t," of ").concat(s," operations failed"),n)})})})},Dt.prototype.bulkDelete=function(t){var r=this,o=t.length;return this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"delete",keys:t})}).then(function(e){var t=e.numFailures,n=e.lastResult,e=e.failures;if(0===t)return n;throw new X("".concat(r.name,".bulkDelete(): ").concat(t," of ").concat(o," operations failed"),e)})},Dt);function Dt(){}function It(o){function t(e,t){if(t){for(var n=arguments.length,r=new Array(n-1);--n;)r[n-1]=arguments[n];return a[e].subscribe.apply(null,r),o}if("string"==typeof e)return a[e]}var a={};t.addEventType=u;for(var e=1,n=arguments.length;e<n;++e)u(arguments[e]);return t;function u(e,n,r){if("object"!=typeof e){var o;n=n||se;var i={subscribers:[],fire:r=r||te,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=n(i.fire,e))},unsubscribe:function(t){i.subscribers=i.subscribers.filter(function(e){return e!==t}),i.fire=i.subscribers.reduce(n,r)}};return a[e]=t[e]=i}x(o=e).forEach(function(e){var t=o[e];if(b(t))u(e,o[e][0],o[e][1]);else{if("asap"!==t)throw new Z.InvalidArgument("Invalid event config");var n=u(e,ne,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){w(function(){e.apply(null,t)})})})}})}}function Tt(e,t){return i(t).from({prototype:e}),t}function Bt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Rt(e,t){e.filter=Et(e.filter,t)}function Ft(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return Et(r(),t())}:t,e.justLimit=n&&!r}function Mt(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 Nt(e,t,n){var r=Mt(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 qt(e,i,t,n){var a=e.replayFilter?Et(e.filter,e.replayFilter()):e.filter;if(e.or){var u={},r=function(e,t,n){var r,o;a&&!a(t,n,function(e){return t.stop(e)},function(e){return t.fail(e)})||("[object ArrayBuffer]"===(o=""+(r=t.primaryKey))&&(o=""+new Uint8Array(r)),m(u,o)||(u[o]=!0,i(e,t,n)))};return Promise.all([e.or._iterate(r,t),Ut(Nt(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return Ut(Nt(e,n,t),Et(e.algorithm,a),i,!e.keysOnly&&e.valueMapper)}function Ut(e,r,o,i){var a=Ye(i?function(e,t,n){return o(i(e),t,n)}:o);return e.then(function(n){if(n)return n.start(function(){var t=function(){return n.continue()};r&&!r(n,function(e){return t=e},function(e){n.stop(e),t=te},function(e){n.fail(e),t=te})||a(n.value,n,function(e){return t=e}),t()})})}var Lt=(Vt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,ht.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Vt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,ht.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Vt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=Et(t.algorithm,e)},Vt.prototype._iterate=function(e,t){return qt(this._ctx,e,t,this._ctx.table.core)},Vt.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},Vt.prototype.raw=function(){return this._ctx.valueMapper=null,this},Vt.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return qt(n,t,e,n.table.core)})},Vt.prototype.count=function(e){var o=this;return this._read(function(e){var t=o._ctx,n=t.table.core;if(Bt(t,!0))return n.count({trans:e,query:{index:Mt(t,n.schema),range:t.range}}).then(function(e){return Math.min(e,t.limit)});var r=0;return qt(t,function(){return++r,!1},e,n).then(function(){return r})}).then(e)},Vt.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],o=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function u(e,t){e=i(e,o),t=i(t,o);return e<t?-a:t<e?a:0}return this.toArray(function(e){return e.sort(u)}).then(t)},Vt.prototype.toArray=function(e){var i=this;return this._read(function(e){var t=i._ctx;if("next"===t.dir&&Bt(t,!0)&&0<t.limit){var n=t.valueMapper,r=Mt(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(function(e){e=e.result;return n?e.map(n):e})}var o=[];return qt(t,function(e){return o.push(e)},e,t.table.core).then(function(){return o})},e)},Vt.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,Bt(e)?Ft(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):Ft(e,function(){var e=t;return function(){return--e<0}})),this},Vt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Ft(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},Vt.prototype.until=function(r,o){return Rt(this._ctx,function(e,t,n){return!r(e.value)||(t(n),o)}),this},Vt.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Vt.prototype.last=function(e){return this.reverse().first(e)},Vt.prototype.filter=function(t){var e;return Rt(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=Et(e.isMatch,t),this},Vt.prototype.and=function(e){return this.filter(e)},Vt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Vt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Vt.prototype.desc=function(){return this.reverse()},Vt.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},Vt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Vt.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},Vt.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)},Vt.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&Bt(n,!0)&&0<n.limit)return this._read(function(e){var t=Mt(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)},Vt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Vt.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Vt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Vt.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 Rt(this._ctx,function(e){var t=e.primaryKey.toString(),e=m(n,t);return n[t]=!0,!e}),this},Vt.prototype.modify=function(_){var n=this,w=this._ctx;return this._write(function(d){var i,a,p;p="function"==typeof _?_:(i=x(_),a=i.length,function(e){for(var t=!1,n=0;n<a;++n){var r=i[n],o=_[r];E(e,r)!==o&&(P(e,r,o),t=!0)}return t});function y(e,t){var n=t.failures,t=t.numFailures;s+=e-t;for(var r=0,o=x(n);r<o.length;r++){var i=o[r];u.push(n[i])}}var v=w.table.core,e=v.schema.primaryKey,m=e.outbound,g=e.extractKey,b=n.db._options.modifyChunkSize||200,u=[],s=0,t=[];return n.clone().primaryKeys().then(function(f){function h(c){var l=Math.min(b,f.length-c);return v.getMany({trans:d,keys:f.slice(c,c+l),cache:"immutable"}).then(function(e){for(var n=[],t=[],r=m?[]:null,o=[],i=0;i<l;++i){var a=e[i],u={value:A(a),primKey:f[c+i]};!1!==p.call(u,u.value,u)&&(null==u.value?o.push(f[c+i]):m||0===St(g(a),g(u.value))?(t.push(u.value),m&&r.push(f[c+i])):(o.push(f[c+i]),n.push(u.value)))}var s=Bt(w)&&w.limit===1/0&&("function"!=typeof _||_===Wt)&&{index:w.index,range:w.range};return Promise.resolve(0<n.length&&v.mutate({trans:d,type:"add",values:n}).then(function(e){for(var t in e.failures)o.splice(parseInt(t),1);y(n.length,e)})).then(function(){return(0<t.length||s&&"object"==typeof _)&&v.mutate({trans:d,type:"put",keys:r,values:t,criteria:s,changeSpec:"function"!=typeof _&&_}).then(function(e){return y(t.length,e)})}).then(function(){return(0<o.length||s&&_===Wt)&&v.mutate({trans:d,type:"delete",keys:o,criteria:s}).then(function(e){return y(o.length,e)})}).then(function(){return f.length>c+l&&h(c+b)})})}return h(0).then(function(){if(0<u.length)throw new Q("Error modifying one or more objects",u,s,t);return f.length})})})},Vt.prototype.delete=function(){var o=this._ctx,n=o.range;return Bt(o)&&(o.isPrimKey&&!_t||3===n.type)?this._write(function(e){var t=o.table.core.schema.primaryKey,r=n;return o.table.core.count({trans:e,query:{index:t,range:r}}).then(function(n){return o.table.core.mutate({trans:e,type:"deleteRange",range:r}).then(function(e){var t=e.failures;e.lastResult,e.results;e=e.numFailures;if(e)throw new Q("Could not delete some values",Object.keys(t).map(function(e){return t[e]}),n-e);return n-e})})}):this.modify(Wt)},Vt);function Vt(){}var Wt=function(e,t){return t.value=null};function zt(e,t){return e<t?-1:e===t?0:1}function Yt(e,t){return t<e?-1:e===t?0:1}function Gt(e,t,n){e=e instanceof $t?new e.Collection(e):e;return e._ctx.error=new(n||TypeError)(t),e}function Ht(e){return new e.Collection(e,function(){return Jt("")}).limit(0)}function Qt(e,s,n,r){var o,c,l,f,h,d,p,y=n.length;if(!n.every(function(e){return"string"==typeof e}))return Gt(e,vt);function t(e){o="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},c="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},l="next"===e?zt:Yt;var t=n.map(function(e){return{lower:c(e),upper:o(e)}}).sort(function(e,t){return l(e.lower,t.lower)});f=t.map(function(e){return e.upper}),h=t.map(function(e){return e.lower}),p="next"===(d=e)?"":r}t("next");e=new e.Collection(e,function(){return Xt(f[0],h[y-1]+r)});e._ondirectionchange=function(e){t(e)};var v=0;return e._addAlgorithm(function(e,t,n){var r=e.key;if("string"!=typeof r)return!1;var o=c(r);if(s(o,h,v))return!0;for(var i=null,a=v;a<y;++a){var u=function(e,t,n,r,o,i){for(var a=Math.min(e.length,r.length),u=-1,s=0;s<a;++s){var c=t[s];if(c!==r[s])return o(e[s],n[s])<0?e.substr(0,s)+n[s]+n.substr(s+1):o(e[s],r[s])<0?e.substr(0,s)+r[s]+n.substr(s+1):0<=u?e.substr(0,u)+t[u]+n.substr(u+1):null;o(e[s],c)<0&&(u=s)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):u<0?null:e.substr(0,u)+r[u]+n.substr(u+1)}(r,o,f[a],h[a],l,d);null===u&&null===i?v=a+1:(null===i||0<l(i,u))&&(i=u)}return t(null!==i?function(){e.continue(i+p)}:n),!1}),e}function Xt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Jt(e){return{type:1,lower:e,upper:e}}var $t=(Object.defineProperty(Zt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Zt.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)?Ht(this):new this.Collection(this,function(){return Xt(e,t,!n,!r)})}catch(e){return Gt(this,yt)}},Zt.prototype.equals=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Jt(e)})},Zt.prototype.above=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Xt(e,void 0,!0)})},Zt.prototype.aboveOrEqual=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Xt(e,void 0,!1)})},Zt.prototype.below=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Xt(void 0,e,!1,!0)})},Zt.prototype.belowOrEqual=function(e){return null==e?Gt(this,yt):new this.Collection(this,function(){return Xt(void 0,e)})},Zt.prototype.startsWith=function(e){return"string"!=typeof e?Gt(this,vt):this.between(e,e+pt,!0,!0)},Zt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Qt(this,function(e,t){return 0===e.indexOf(t[0])},[e],pt)},Zt.prototype.equalsIgnoreCase=function(e){return Qt(this,function(e,t){return e===t[0]},[e],"")},Zt.prototype.anyOfIgnoreCase=function(){var e=R.apply(B,arguments);return 0===e.length?Ht(this):Qt(this,function(e,t){return-1!==t.indexOf(e)},e,"")},Zt.prototype.startsWithAnyOfIgnoreCase=function(){var e=R.apply(B,arguments);return 0===e.length?Ht(this):Qt(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,pt)},Zt.prototype.anyOf=function(){var t=this,o=R.apply(B,arguments),i=this._cmp;try{o.sort(i)}catch(e){return Gt(this,yt)}if(0===o.length)return Ht(this);var e=new this.Collection(this,function(){return Xt(o[0],o[o.length-1])});e._ondirectionchange=function(e){i="next"===e?t._ascending:t._descending,o.sort(i)};var a=0;return e._addAlgorithm(function(e,t,n){for(var r=e.key;0<i(r,o[a]);)if(++a===o.length)return t(n),!1;return 0===i(r,o[a])||(t(function(){e.continue(o[a])}),!1)}),e},Zt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Zt.prototype.noneOf=function(){var e=R.apply(B,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Gt(this,yt)}var t=e.reduce(function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},Zt.prototype.inAnyRange=function(e,t){var i=this,a=this._cmp,u=this._ascending,n=this._descending,s=this._min,c=this._max;if(0===e.length)return Ht(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&u(e[0],e[1])<=0}))return Gt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Z.InvalidArgument);var r=!t||!1!==t.includeLowers,o=t&&!0===t.includeUppers;var l,f=u;function h(e,t){return f(e[0],t[0])}try{(l=e.reduce(function(e,t){for(var n=0,r=e.length;n<r;++n){var o=e[n];if(a(t[0],o[1])<0&&0<a(t[1],o[0])){o[0]=s(o[0],t[0]),o[1]=c(o[1],t[1]);break}}return n===r&&e.push(t),e},[])).sort(h)}catch(e){return Gt(this,yt)}var d=0,p=o?function(e){return 0<u(e,l[d][1])}:function(e){return 0<=u(e,l[d][1])},y=r?function(e){return 0<n(e,l[d][0])}:function(e){return 0<=n(e,l[d][0])};var v=p,e=new this.Collection(this,function(){return Xt(l[0][0],l[l.length-1][1],!r,!o)});return e._ondirectionchange=function(e){f="next"===e?(v=p,u):(v=y,n),l.sort(h)},e._addAlgorithm(function(e,t,n){for(var r,o=e.key;v(o);)if(++d===l.length)return t(n),!1;return!p(r=o)&&!y(r)||(0===i._cmp(o,l[d][1])||0===i._cmp(o,l[d][0])||t(function(){f===u?e.continue(l[d][0]):e.continue(l[d][1])}),!1)}),e},Zt.prototype.startsWithAnyOf=function(){var e=R.apply(B,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Ht(this):this.inAnyRange(e.map(function(e){return[e,e+pt]})):Gt(this,"startsWithAnyOf() only works with strings")},Zt);function Zt(){}function en(t){return Ye(function(e){return tn(e),t(e.target.error),!1})}function tn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var nn="storagemutated",rn="x-storagemutated-1",on=It(null,nn),an=(un.prototype._lock=function(){return _(!je.global),++this._reculock,1!==this._reculock||je.global||(je.lockOwnerFor=this),this},un.prototype._unlock=function(){if(_(!je.global),0==--this._reculock)for(je.global||(je.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{at(e[1],e[0])}catch(e){}}return this},un.prototype._locked=function(){return this._reculock&&je.lockOwnerFor!==this},un.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(_(!this.idbtrans),!t&&!e)switch(r&&r.name){case"DatabaseClosedError":throw new Z.DatabaseClosed(r);case"MissingAPIError":throw new Z.MissingAPI(r.message,r);default:throw new Z.OpenFailed(r)}if(!this.active)throw new Z.TransactionInactive;return _(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||e).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Ye(function(e){tn(e),n._reject(t.error)}),t.onabort=Ye(function(e){tn(e),n.active&&n._reject(new Z.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=Ye(function(){n.active=!1,n._resolve(),"mutatedParts"in t&&on.storagemutated.fire(t.mutatedParts)}),this},un.prototype._promise=function(n,r,o){var i=this;if("readwrite"===n&&"readwrite"!==this.mode)return ht(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return ht(new Z.TransactionInactive);if(this._locked())return new Ie(function(e,t){i._blockedFuncs.push([function(){i._promise(n,r,o).then(e,t)},je])});if(o)return Ze(function(){var e=new Ie(function(e,t){i._lock();var n=r(e,t,i);n&&n.then&&n.then(e,t)});return e.finally(function(){return i._unlock()}),e._lib=!0,e});var e=new Ie(function(e,t){var n=r(e,t,i);n&&n.then&&n.then(e,t)});return e._lib=!0,e},un.prototype._root=function(){return this.parent?this.parent._root():this},un.prototype.waitFor=function(e){var t,r=this._root(),o=Ie.resolve(e);r._waitingFor?r._waitingFor=r._waitingFor.then(function(){return o}):(r._waitingFor=o,r._waitingQueue=[],t=r.idbtrans.objectStore(r.storeNames[0]),function e(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(t.get(-1/0).onsuccess=e)}());var i=r._waitingFor;return new Ie(function(t,n){o.then(function(e){return r._waitingQueue.push(Ye(t.bind(null,e)))},function(e){return r._waitingQueue.push(Ye(n.bind(null,e)))}).finally(function(){r._waitingFor===i&&(r._waitingFor=null)})})},un.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new Z.Abort))},un.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},un);function un(){}function sn(e,t,n,r,o,i,a){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+cn(t)}}function cn(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function ln(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:k(n,function(e){return[e.name,e]})}}var fn=function(e){try{return e.only([[]]),fn=function(){return[[]]},[[]]}catch(e){return fn=function(){return pt},pt}};function hn(t){return null==t?function(){}:"string"==typeof t?1===(n=t).split(".").length?function(e){return e[n]}:function(e){return E(e,n)}:function(e){return E(e,t)};var n}function dn(e){return[].slice.call(e)}var pn=0;function yn(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function vn(e,o,t){function w(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,n=e.upper,r=e.lowerOpen,e=e.upperOpen;return void 0===t?void 0===n?null:o.upperBound(n,!!e):void 0===n?o.lowerBound(t,!!r):o.bound(t,n,!!r,!!e)}function n(e){var h,_=e.name;return{name:_,schema:e,mutate:function(e){var y=e.trans,v=e.type,m=e.keys,g=e.values,b=e.range;return new Promise(function(t,e){t=Ye(t);var n=y.objectStore(_),r=null==n.keyPath,o="put"===v||"add"===v;if(!o&&"delete"!==v&&"deleteRange"!==v)throw new Error("Invalid operation type: "+v);var i,a=(m||g||{length:1}).length;if(m&&g&&m.length!==g.length)throw new Error("Given keys array must have same length as given values array.");if(0===a)return t({numFailures:0,failures:{},results:[],lastResult:void 0});function u(e){++l,tn(e)}var s=[],c=[],l=0;if("deleteRange"===v){if(4===b.type)return t({numFailures:l,failures:c,results:[],lastResult:void 0});3===b.type?s.push(i=n.clear()):s.push(i=n.delete(w(b)))}else{var r=o?r?[g,m]:[g,null]:[m,null],f=r[0],h=r[1];if(o)for(var d=0;d<a;++d)s.push(i=h&&void 0!==h[d]?n[v](f[d],h[d]):n[v](f[d])),i.onerror=u;else for(d=0;d<a;++d)s.push(i=n[v](f[d])),i.onerror=u}function p(e){e=e.target.result,s.forEach(function(e,t){return null!=e.error&&(c[t]=e.error)}),t({numFailures:l,failures:c,results:"delete"===v?m:s.map(function(e){return e.result}),lastResult:e})}i.onerror=function(e){u(e),p(e)},i.onsuccess=p})},getMany:function(e){var f=e.trans,h=e.keys;return new Promise(function(t,e){t=Ye(t);for(var n,r=f.objectStore(_),o=h.length,i=new Array(o),a=0,u=0,s=function(e){e=e.target;i[e._pos]=e.result,++u===a&&t(i)},c=en(e),l=0;l<o;++l)null!=h[l]&&((n=r.get(h[l]))._pos=l,n.onsuccess=s,n.onerror=c,++a);0===a&&t(i)})},get:function(e){var r=e.trans,o=e.key;return new Promise(function(t,e){t=Ye(t);var n=r.objectStore(_).get(o);n.onsuccess=function(e){return t(e.target.result)},n.onerror=en(e)})},query:(h=s,function(f){return new Promise(function(n,e){n=Ye(n);var r,o,i,t=f.trans,a=f.values,u=f.limit,s=f.query,c=u===1/0?void 0:u,l=s.index,s=s.range,t=t.objectStore(_),l=l.isPrimaryKey?t:t.index(l.name),s=w(s);if(0===u)return n({result:[]});h?((c=a?l.getAll(s,c):l.getAllKeys(s,c)).onsuccess=function(e){return n({result:e.target.result})},c.onerror=en(e)):(r=0,o=!a&&"openKeyCursor"in l?l.openKeyCursor(s):l.openCursor(s),i=[],o.onsuccess=function(e){var t=o.result;return t?(i.push(a?t.value:t.primaryKey),++r===u?n({result:i}):void t.continue()):n({result:i})},o.onerror=en(e))})}),openCursor:function(e){var c=e.trans,i=e.values,a=e.query,u=e.reverse,l=e.unique;return new Promise(function(t,n){t=Ye(t);var e=a.index,r=a.range,o=c.objectStore(_),o=e.isPrimaryKey?o:o.index(e.name),e=u?l?"prevunique":"prev":l?"nextunique":"next",s=!i&&"openKeyCursor"in o?o.openKeyCursor(w(r),e):o.openCursor(w(r),e);s.onerror=en(n),s.onsuccess=Ye(function(e){var r,o,i,a,u=s.result;u?(u.___id=++pn,u.done=!1,r=u.continue.bind(u),o=(o=u.continuePrimaryKey)&&o.bind(u),i=u.advance.bind(u),a=function(){throw new Error("Cursor not stopped")},u.trans=c,u.stop=u.continue=u.continuePrimaryKey=u.advance=function(){throw new Error("Cursor not started")},u.fail=Ye(n),u.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},u.start=function(e){function t(){if(s.result)try{e()}catch(e){u.fail(e)}else u.done=!0,u.start=function(){throw new Error("Cursor behind last entry")},u.stop()}var n=new Promise(function(t,e){t=Ye(t),s.onerror=en(e),u.fail=e,u.stop=function(e){u.stop=u.continue=u.continuePrimaryKey=u.advance=a,t(e)}});return s.onsuccess=Ye(function(e){s.onsuccess=t,t()}),u.continue=r,u.continuePrimaryKey=o,u.advance=i,t(),n},t(u)):t(null)},n)})},count:function(e){var t=e.query,o=e.trans,i=t.index,a=t.range;return new Promise(function(t,e){var n=o.objectStore(_),r=i.isPrimaryKey?n:n.index(i.name),n=w(a),r=n?r.count(n):r.count();r.onsuccess=Ye(function(e){return t(e.target.result)}),r.onerror=en(e)})}}}var r,i,a,u=(i=t,a=dn((r=e).objectStoreNames),{schema:{name:r.name,tables:a.map(function(e){return i.objectStore(e)}).map(function(t){var e=t.keyPath,n=t.autoIncrement,r=b(e),o={},n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:hn(e)},indexes:dn(t.indexNames).map(function(e){return t.index(e)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,e=e.keyPath,r={name:t,compound:b(e),keyPath:e,unique:n,multiEntry:r,extractKey:hn(e)};return o[yn(e)]=r}),getIndexByKeyPath:function(e){return o[yn(e)]}};return o[":id"]=n.primaryKey,null!=e&&(o[yn(e)]=n.primaryKey),n})},hasGetAll:0<a.length&&"getAll"in i.objectStore(a[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),t=u.schema,s=u.hasGetAll,u=t.tables.map(n),c={};return u.forEach(function(e){return c[e.name]=e}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!c[e])throw new Error("Table '".concat(e,"' not found"));return c[e]},MIN_KEY:-1/0,MAX_KEY:fn(o),schema:t}}function mn(e,t,n,r){var o=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=vn(t,o,r),e.dbcore.reduce(function(e,t){t=t.create;return g(g({},e),t(e))},r))}}function gn(e,t){var n=e._novip,e=t.db,t=mn(n._middlewares,e,n._deps,t);n.core=t.dbcore,n.tables.forEach(function(e){var t=e.name;n.core.schema.tables.some(function(e){return e.name===t})&&(e.core=n.core.table(t),n[t]instanceof n.Table&&(n[t].core=e.core))})}function bn(e,t,n,o){var i=e._novip;n.forEach(function(n){var r=o[n];t.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 _n(e,t){var n=e._novip;t.forEach(function(e){for(var t in e)e[t]instanceof n.Table&&delete e[t]})}function wn(e,t){return e._cfg.version-t._cfg.version}function xn(n,r,o,e){var i=n._dbSchema,a=n._createTransaction("readwrite",n._storeNames,i);a.create(o),a._completion.catch(e);var u=a._reject.bind(a),p=je.transless||je;Ze(function(){var e,s,c,l,f,t,h,d;je.trans=a,je.transless=p,0===r?(x(i).forEach(function(e){En(o,e,i[e].primKey,i[e].indexes)}),gn(n,o),Ie.follow(function(){return n.on.populate.fire(a)}).catch(u)):(s=r,c=a,l=o,f=(e=n)._novip,t=[],e=f._versions,h=f._dbSchema=On(0,f.idbdb,l),d=!1,e.filter(function(e){return e._cfg.version>=s}).forEach(function(u){t.push(function(){var t=h,e=u._cfg.dbschema;Kn(f,t,l),Kn(f,e,l),h=f._dbSchema=e;var n=kn(t,e);n.add.forEach(function(e){En(l,e[0],e[1].primKey,e[1].indexes)}),n.change.forEach(function(e){if(e.recreate)throw new Z.Upgrade("Not yet support for changing primary key");var t=l.objectStore(e.name);e.add.forEach(function(e){return Pn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),Pn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var r=u._cfg.contentUpgrade;if(r&&u._cfg.version>s){gn(f,l),c._memoizedTables={},d=!0;var o=O(e);n.del.forEach(function(e){o[e]=t[e]}),_n(f,[f.Transaction.prototype]),bn(f,[f.Transaction.prototype],x(o),o),c.schema=o;var i,a=F(r);a&&et();n=Ie.follow(function(){var e;(i=r(c))&&a&&(e=tt.bind(null,null),i.then(e,e))});return i&&"function"==typeof i.then?Ie.resolve(i):n.then(function(){return i})}}),t.push(function(e){var t,n,r;d&&bt||(t=u._cfg.dbschema,n=t,r=e,[].slice.call(r.db.objectStoreNames).forEach(function(e){return null==n[e]&&r.db.deleteObjectStore(e)})),_n(f,[f.Transaction.prototype]),bn(f,[f.Transaction.prototype],f._storeNames,f._dbSchema),c.schema=f._dbSchema})}),function e(){return t.length?Ie.resolve(t.shift()(c.idbtrans)).then(e):Ie.resolve()}().then(function(){var t,n;n=l,x(t=h).forEach(function(e){n.db.objectStoreNames.contains(e)||En(n,e,t[e].primKey,t[e].indexes)})}).catch(u))})}function kn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var o=e[n],i=t[n];if(o){var a={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||o.primKey.auto!==i.primKey.auto&&!gt)a.recreate=!0,r.change.push(a);else{var u=o.idxByName,s=i.idxByName,c=void 0;for(c in u)s[c]||a.del.push(c);for(c in s){var l=u[c],f=s[c];l?l.src!==f.src&&a.change.push(f):a.add.push(f)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,i])}return r}function En(e,t,n,r){var o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(e){return Pn(o,e)}),o}function Pn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function On(e,t,u){var s={};return y(t.objectStoreNames,0).forEach(function(e){for(var t=u.objectStore(e),n=sn(cn(a=t.keyPath),a||"",!1,!1,!!t.autoIncrement,a&&"string"!=typeof a,!0),r=[],o=0;o<t.indexNames.length;++o){var i=t.index(t.indexNames[o]),a=i.keyPath,i=sn(i.name,a,!!i.unique,!!i.multiEntry,!1,a&&"string"!=typeof a,!1);r.push(i)}s[e]=ln(e,n,r)}),s}function Kn(e,t,n){for(var r=e._novip,o=n.db.objectStoreNames,i=0;i<o.length;++i){var a=o[i],u=n.objectStore(a);r._hasGetAll="getAll"in u;for(var s=0;s<u.indexNames.length;++s){var c=u.indexNames[s],l=u.index(c).keyPath,f="string"==typeof l?l:"["+y(l).join("+")+"]";!t[a]||(l=t[a].idxByName[f])&&(l.name=c,delete t[a].idxByName[f],t[a].idxByName[c]=l)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&h.WorkerGlobalScope&&h instanceof h.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(r._hasGetAll=!1)}var Sn=(jn.prototype._parseStoresSpec=function(r,o){x(r).forEach(function(e){if(null!==r[e]){var t=r[e].split(",").map(function(e,t){var n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return sn(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),b(r),0===t)}),n=t.shift();if(n.multi)throw new Z.Schema("Primary key cannot be multi-valued");t.forEach(function(e){if(e.auto)throw new Z.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new Z.Schema("Index must have a name and cannot be an empty string")}),o[e]=ln(e,n,t)}})},jn.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,_n(t,[t._allTables,t,t.Transaction.prototype]),bn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],x(r),r),t._storeNames=x(r),this},jn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=ce(this._cfg.contentUpgrade||te,e),this},jn);function jn(){}function An(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Xn(wt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Cn(e){return e&&"function"==typeof e.databases}function Dn(e){return Ze(function(){return je.letThrough=!0,e()})}function In(f){var h=f._state,r=f._deps.indexedDB;if(h.isBeingOpened||f.idbdb)return h.dbReadyPromise.then(function(){return h.dbOpenError?ht(h.dbOpenError):f});M&&(h.openCanceller._stackHolder=L()),h.isBeingOpened=!0,h.dbOpenError=null,h.openComplete=!1;var t=h.openCanceller;function e(){if(h.openCanceller!==t)throw new Z.DatabaseClosed("db.open() was cancelled")}var n,o=h.dbReadyResolve,d=null,p=!1;return Ie.race([t,("undefined"==typeof navigator?Ie.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(function(){return new Ie(function(s,n){if(e(),!r)throw new Z.MissingAPI;var c=f.name,l=h.autoSchema?r.open(c):r.open(c,Math.round(10*f.verno));if(!l)throw new Z.MissingAPI;l.onerror=en(n),l.onblocked=Ye(f._fireOnBlocked),l.onupgradeneeded=Ye(function(e){var t;d=l.transaction,h.autoSchema&&!f._options.allowEmptyDB?(l.onerror=tn,d.abort(),l.result.close(),(t=r.deleteDatabase(c)).onsuccess=t.onerror=Ye(function(){n(new Z.NoSuchDatabase("Database ".concat(c," doesnt exist")))})):(d.onerror=en(n),e=e.oldVersion>Math.pow(2,62)?0:e.oldVersion,p=e<1,f._novip.idbdb=l.result,xn(f,e/10,d,n))},n),l.onsuccess=Ye(function(){d=null;var e,t,n,r,o,i=f._novip.idbdb=l.result,a=y(i.objectStoreNames);if(0<a.length)try{var u=i.transaction(1===(r=a).length?r[0]:r,"readonly");h.autoSchema?(t=i,n=u,(e=(e=f)._novip).verno=t.version/10,n=e._dbSchema=On(0,t,n),e._storeNames=y(t.objectStoreNames,0),bn(e,[e._allTables],x(n),n)):(Kn(f,f._dbSchema,u),((o=kn(On(0,(o=f).idbdb,u),o._dbSchema)).add.length||o.change.some(function(e){return e.add.length||e.change.length}))&&console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),gn(f,u)}catch(e){}mt.push(f),i.onversionchange=Ye(function(e){h.vcFired=!0,f.on("versionchange").fire(e)}),i.onclose=Ye(function(e){f.on("close").fire(e)}),p&&(o=f._deps,u=c,i=o.indexedDB,o=o.IDBKeyRange,Cn(i)||u===wt||An(i,o).put({name:u}).catch(te)),s()},n)})})]).then(function(){return e(),h.onReadyBeingFired=[],Ie.resolve(Dn(function(){return f.on.ready.fire(f.vip)})).then(function e(){if(0<h.onReadyBeingFired.length){var t=h.onReadyBeingFired.reduce(ce,te);return h.onReadyBeingFired=[],Ie.resolve(Dn(function(){return t(f.vip)})).then(e)}})}).finally(function(){h.onReadyBeingFired=null,h.isBeingOpened=!1}).then(function(){return f}).catch(function(e){h.dbOpenError=e;try{d&&d.abort()}catch(e){}return t===h.openCanceller&&f._close(),ht(e)}).finally(function(){h.openComplete=!0,o()})}function Tn(t){function e(e){return t.next(e)}var r=n(e),o=n(function(e){return t.throw(e)});function n(n){return function(e){var t=n(e),e=t.value;return t.done?e:e&&"function"==typeof e.then?e.then(r,o):b(e)?Promise.all(e).then(r,o):r(e)}}return n(e)()}function Bn(e,t,n){for(var r=b(e)?e.slice():[e],o=0;o<n;++o)r.push(t);return r}var Rn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(f){return g(g({},f),{table:function(e){var a=f.table(e),t=a.schema,u={},s=[];function c(e,t,n){var r=yn(e),o=u[r]=u[r]||[],i=null==e?0:"string"==typeof e?1:e.length,r=0<t,r=g(g({},n),{isVirtual:r,keyTail:t,keyLength:i,extractKey:hn(e),unique:!r&&n.unique});return o.push(r),r.isPrimaryKey||s.push(r),1<i&&c(2===i?e[0]:e.slice(0,i-1),t+1,n),o.sort(function(e,t){return e.keyTail-t.keyTail}),r}e=c(t.primaryKey.keyPath,0,t.primaryKey);u[":id"]=[e];for(var n=0,r=t.indexes;n<r.length;n++){var o=r[n];c(o.keyPath,0,o)}function l(e){var t,n=e.query.index;return n.isVirtual?g(g({},e),{query:{index:n,range:(t=e.query.range,n=n.keyTail,{type:1===t.type?2:t.type,lower:Bn(t.lower,t.lowerOpen?f.MAX_KEY:f.MIN_KEY,n),lowerOpen:!0,upper:Bn(t.upper,t.upperOpen?f.MIN_KEY:f.MAX_KEY,n),upperOpen:!0})}}):e}return g(g({},a),{schema:g(g({},t),{primaryKey:e,indexes:s,getIndexByKeyPath:function(e){return(e=u[yn(e)])&&e[0]}}),count:function(e){return a.count(l(e))},query:function(e){return a.query(l(e))},openCursor:function(t){var e=t.query.index,r=e.keyTail,n=e.isVirtual,o=e.keyLength;return n?a.openCursor(l(t)).then(function(e){return e&&i(e)}):a.openCursor(t);function i(n){return Object.create(n,{continue:{value:function(e){null!=e?n.continue(Bn(e,t.reverse?f.MAX_KEY:f.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,o).concat(t.reverse?f.MIN_KEY:f.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value:function(e,t){n.continuePrimaryKey(Bn(e,f.MAX_KEY,r),t)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:function(){return n.value}}})}}})}})}};function Fn(o,i,a,u){return a=a||{},u=u||"",x(o).forEach(function(e){var t,n,r;m(i,e)?(t=o[e],n=i[e],"object"==typeof t&&"object"==typeof n&&t&&n?(r=D(t))!==D(n)?a[u+e]=i[e]:"Object"===r?Fn(t,n,a,u+e+"."):t!==n&&(a[u+e]=i[e]):t!==n&&(a[u+e]=i[e])):a[u+e]=void 0}),x(i).forEach(function(e){m(o,e)||(a[u+e]=i[e])}),a}var Mn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return g(g({},e),{table:function(r){var y=e.table(r),v=y.schema.primaryKey;return g(g({},y),{mutate:function(e){var t=je.trans,n=t.table(r).hook,h=n.deleting,d=n.creating,p=n.updating;switch(e.type){case"add":if(d.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"put":if(d.fire===te&&p.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"delete":if(h.fire===te)break;return t._promise("readwrite",function(){return a(e)},!0);case"deleteRange":if(h.fire===te)break;return t._promise("readwrite",function(){return function n(r,o,i){return y.query({trans:r,values:!1,query:{index:v,range:o},limit:i}).then(function(e){var t=e.result;return a({type:"delete",keys:t,trans:r}).then(function(e){return 0<e.numFailures?Promise.reject(e.failures[0]):t.length<i?{failures:[],numFailures:0,lastResult:void 0}:n(r,g(g({},o),{lower:t[t.length-1],lowerOpen:!0}),i)})})}(e.trans,e.range,1e4)},!0)}return y.mutate(e);function a(c){var e,t,n,l=je.trans,f=c.keys||(t=v,"delete"===(n=c).type?n.keys:n.keys||n.values.map(t.extractKey));if(!f)throw new Error("Keys missing");return"delete"!==(c="add"===c.type||"put"===c.type?g(g({},c),{keys:f}):g({},c)).type&&(c.values=o([],c.values,!0)),c.keys&&(c.keys=o([],c.keys,!0)),e=y,n=f,("add"===(t=c).type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})).then(function(u){var s=f.map(function(e,t){var n,r,o,i=u[t],a={onerror:null,onsuccess:null};return"delete"===c.type?h.fire.call(a,e,i,l):"add"===c.type||void 0===i?(n=d.fire.call(a,e,c.values[t],l),null==e&&null!=n&&(c.keys[t]=e=n,v.outbound||P(c.values[t],v.keyPath,e))):(n=Fn(i,c.values[t]),(r=p.fire.call(a,n,e,i,l))&&(o=c.values[t],Object.keys(r).forEach(function(e){m(o,e)?o[e]=r[e]:P(o,e,r[e])}))),a});return y.mutate(c).then(function(e){for(var t=e.failures,n=e.results,r=e.numFailures,e=e.lastResult,o=0;o<f.length;++o){var i=(n||f)[o],a=s[o];null==i?a.onerror&&a.onerror(t[o]):a.onsuccess&&a.onsuccess("put"===c.type&&u[o]?c.values[o]:i)}return{failures:t,results:n,numFailures:r,lastResult:e}}).catch(function(t){return s.forEach(function(e){return e.onerror&&e.onerror(t)}),Promise.reject(t)})})}}})}})}};function Nn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;for(var r=[],o=0,i=0;o<t.keys.length&&i<e.length;++o)0===St(t.keys[o],e[i])&&(r.push(n?A(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}var qn={stack:"dbcore",level:-1,create:function(t){return{table:function(e){var n=t.table(e);return g(g({},n),{getMany:function(t){if(!t.cache)return n.getMany(t);var e=Nn(t.keys,t.trans._cache,"clone"===t.cache);return e?Ie.resolve(e):n.getMany(t).then(function(e){return t.trans._cache={keys:t.keys,values:"clone"===t.cache?A(e):e},e})},mutate:function(e){return"add"!==e.type&&(e.trans._cache=null),n.mutate(e)}})}}}};function Un(e){return!("from"in e)}var Ln=function(e,t){if(!this){var n=new Ln;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 Vn(e,t,n){var r=St(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(Un(e))return u(e,{from:t,to:n,d:1});var o=e.l,r=e.r;if(St(n,e.from)<0)return o?Vn(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Gn(e);if(0<St(t,e.to))return r?Vn(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Gn(e);St(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<St(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);n=!e.r;o&&!e.l&&Wn(e,o),r&&n&&Wn(e,r)}}function Wn(e,t){Un(t)||function e(t,n){var r=n.from,o=n.to,i=n.l,n=n.r;Vn(t,r,o),i&&e(t,i),n&&e(t,n)}(e,t)}function zn(e,t){var n=Yn(t),r=n.next();if(r.done)return!1;for(var o=r.value,i=Yn(e),a=i.next(o.from),u=a.value;!r.done&&!a.done;){if(St(u.from,o.to)<=0&&0<=St(u.to,o.from))return!0;St(o.from,u.from)<0?o=(r=n.next(u.from)).value:u=(a=i.next(o.from)).value}return!1}function Yn(e){var n=Un(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&&St(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||St(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 Gn(e){var t,n,r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),o=1<r?"r":r<-1?"l":"";o&&(t="r"==o?"l":"r",n=g({},e),r=e[o],e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],(e[t]=n).d=Hn(n)),e.d=Hn(e)}function Hn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}r(Ln.prototype,((W={add:function(e){return Wn(this,e),this},addKey:function(e){return Vn(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return Vn(t,e,e)}),this}})[I]=function(){return Yn(this)},W));var Qn={stack:"dbcore",level:0,create:function(r){var v=r.schema.name,m=new Ln(r.MIN_KEY,r.MAX_KEY);return g(g({},r),{table:function(d){function e(e){var e=(t=e.query).index,t=t.range;return[e,new Ln(null!==(e=t.lower)&&void 0!==e?e:r.MIN_KEY,null!==(t=t.upper)&&void 0!==t?t:r.MAX_KEY)]}var p=r.table(d),y=p.schema,t=y.primaryKey,c=t.extractKey,l=t.outbound,n=g(g({},p),{mutate:function(e){function n(e){return e="idb://".concat(v,"/").concat(d,"/").concat(e),r[e]||(r[e]=new Ln)}var t=e.trans,r=t.mutatedParts||(t.mutatedParts={}),o=n(""),s=n(":dels"),c=e.type,t="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[],l=t[0],f=t[1],h=e.trans._cache;return p.mutate(e).then(function(e){var t,i,a,u;return b(l)?("delete"!==c&&(l=e.results),o.addKeys(l),(t=Nn(l,h))||"add"===c||s.addKeys(l),(t||f)&&(i=n,a=t,u=f,y.indexes.forEach(function(t){var n=i(t.name||"");function r(e){return null!=e?t.extractKey(e):null}function o(e){return t.multiEntry&&b(e)?e.forEach(function(e){return n.addKey(e)}):n.addKey(e)}(a||u).forEach(function(e,t){var n=a&&r(a[t]),t=u&&r(u[t]);0!==St(n,t)&&(null!=n&&o(n),null!=t&&o(t))})}))):l?(t={from:l.lower,to:l.upper},s.add(t),o.add(t)):(o.add(m),s.add(m),y.indexes.forEach(function(e){return n(e.name).add(m)})),e})}}),f={get:function(e){return[t,new Ln(e.key)]},getMany:function(e){return[t,(new Ln).addKeys(e.keys)]},count:e,query:e,openCursor:e};return x(f).forEach(function(s){n[s]=function(o){var t=je.subscr;if(t){var e=function(e){e="idb://".concat(v,"/").concat(d,"/").concat(e);return t[e]||(t[e]=new Ln)},i=e(""),a=e(":dels"),n=f[s](o),r=n[0],n=n[1];if(e(r.name||"").add(n),!r.isPrimaryKey){if("count"!==s){var u="query"===s&&l&&o.values&&p.query(g(g({},o),{values:!1}));return p[s].apply(this,arguments).then(function(t){if("query"===s){if(l&&o.values)return u.then(function(e){e=e.result;return i.addKeys(e),t});var e=o.values?t.result.map(c):t.result;(o.values?i:a).addKeys(e)}else if("openCursor"===s){var n=t,r=o.values;return n&&Object.create(n,{key:{get:function(){return a.addKey(n.primaryKey),n.key}},primaryKey:{get:function(){var e=n.primaryKey;return a.addKey(e),e}},value:{get:function(){return r&&i.addKey(n.primaryKey),n.value}}})}return t})}a.add(m)}}return p[s].apply(this,arguments)}}),n}})}};var Xn=(Jn.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(wn),n.stores({}),this._state.autoSchema=!1,n)},Jn.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||je.letThrough||this._vip)?e():new Ie(function(e,t){if(n._state.openComplete)return t(new Z.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._options.autoOpen)return void t(new Z.DatabaseClosed);n.open().catch(te)}n._state.dbReadyPromise.then(e,t)}).then(e)},Jn.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,o=e.name;o&&this.unuse({stack:t,name:o});e=this._middlewares[t]||(this._middlewares[t]=[]);return e.push({stack:t,create:n,level:null==r?10:r,name:o}),e.sort(function(e,t){return e.level-t.level}),this},Jn.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},Jn.prototype.open=function(){return In(this)},Jn.prototype._close=function(){var n=this._state,e=mt.indexOf(this);if(0<=e&&mt.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}n.dbReadyPromise=new Ie(function(e){n.dbReadyResolve=e}),n.openCanceller=new Ie(function(e,t){n.cancelOpen=t})},Jn.prototype.close=function(){this._close();var e=this._state;this._options.autoOpen=!1,e.dbOpenError=new Z.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)},Jn.prototype.delete=function(){var o=this,n=0<arguments.length,i=this._state;return new Ie(function(r,t){function e(){o.close();var e=o._deps.indexedDB.deleteDatabase(o.name);e.onsuccess=Ye(function(){var e,t,n;e=o._deps,t=o.name,n=e.indexedDB,e=e.IDBKeyRange,Cn(n)||t===wt||An(n,e).delete(t).catch(te),r()}),e.onerror=en(t),e.onblocked=o._fireOnBlocked}if(n)throw new Z.InvalidArgument("Arguments not allowed in db.delete()");i.isBeingOpened?i.dbReadyPromise.then(e):e()})},Jn.prototype.backendDB=function(){return this.idbdb},Jn.prototype.isOpen=function(){return null!==this.idbdb},Jn.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},Jn.prototype.hasFailed=function(){return null!==this._state.dbOpenError},Jn.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(Jn.prototype,"tables",{get:function(){var t=this;return x(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),Jn.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new Z.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,K(o),n]}.apply(this,arguments);return this._transaction.apply(this,e)},Jn.prototype._transaction=function(e,t,n){var r=this,o=je.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);var i,a,u=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=t.map(function(e){e=e instanceof r.Table?e.name:e;if("string"!=typeof e)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e}),"r"==e||e===xt)i=xt;else{if("rw"!=e&&e!=kt)throw new Z.InvalidArgument("Invalid transaction mode: "+e);i=kt}if(o){if(o.mode===xt&&i===kt){if(!u)throw new Z.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(function(e){if(o&&-1===o.storeNames.indexOf(e)){if(!u)throw new Z.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),u&&o&&!o.active&&(o=null)}}catch(n){return o?o._promise(null,function(e,t){t(n)}):ht(n)}var s=function o(i,a,u,s,c){return Ie.resolve().then(function(){var e=je.transless||je,t=i._createTransaction(a,u,i._dbSchema,s),e={trans:t,transless:e};if(s)t.idbtrans=s.idbtrans;else try{t.create(),i._state.PR1398_maxLoop=3}catch(e){return e.name===J.InvalidState&&i.isOpen()&&0<--i._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),i._close(),i.open().then(function(){return o(i,a,u,null,c)})):ht(e)}var n,r=F(c);return r&&et(),e=Ie.follow(function(){var e;(n=c.call(t,t))&&(r?(e=tt.bind(null,null),n.then(e,e)):"function"==typeof n.next&&"function"==typeof n.throw&&(n=Tn(n)))},e),(n&&"function"==typeof n.then?Ie.resolve(n).then(function(e){return t.active?e:ht(new Z.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):e.then(function(){return n})).then(function(e){return s&&t._resolve(),t._completion.then(function(){return e})}).catch(function(e){return t._reject(e),ht(e)})})}.bind(null,this,i,a,o,n);return o?o._promise(i,s,"lock"):je.trans?at(je.transless,function(){return r._whenReady(s)}):this._whenReady(s)},Jn.prototype.table=function(e){if(!m(this._allTables,e))throw new Z.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},Jn);function Jn(e,t){var i=this;this._middlewares={},this.verno=0;var n=Jn.dependencies;this._options=t=g({addons:Jn.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};n=t.addons;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var a,r,u,o,s,c={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:te,dbReadyPromise:null,cancelOpen:te,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};c.dbReadyPromise=new Ie(function(e){c.dbReadyResolve=e}),c.openCanceller=new Ie(function(e,t){c.cancelOpen=t}),this._state=c,this.name=e,this.on=It(this,"populate","blocked","versionchange","close",{ready:[ce,te]}),this.on.ready.subscribe=v(this.on.ready.subscribe,function(o){return function(n,r){Jn.vip(function(){var t,e=i._state;e.openComplete?(e.dbOpenError||Ie.resolve().then(n),r&&o(n)):e.onReadyBeingFired?(e.onReadyBeingFired.push(n),r&&o(n)):(o(n),t=i,r||o(function e(){t.on.ready.unsubscribe(n),t.on.ready.unsubscribe(e)}))})}}),this.Collection=(a=this,Tt(Lt.prototype,function(e,t){this.db=a;var n=Pt,r=null;if(t)try{n=t()}catch(e){r=e}var o=e._ctx,t=o.table,e=t.hook.reading.fire;this._ctx={table:t,index:o.index,isPrimKey:!o.index||t.schema.primKey.keyPath&&o.index===t.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:e!==ne?e:null}})),this.Table=(r=this,Tt(Ct.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:It(null,{creating:[ie,te],reading:[re,ne],updating:[ue,te],deleting:[ae,te]})})),this.Transaction=(u=this,Tt(an.prototype,function(e,t,n,r,o){var i=this;this.db=u,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=It(this,"complete","error","abort"),this.parent=o||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new Ie(function(e,t){i._resolve=e,i._reject=t}),this._completion.then(function(){i.active=!1,i.on.complete.fire()},function(e){var t=i.active;return i.active=!1,i.on.error.fire(e),i.parent?i.parent._reject(e):t&&i.idbtrans&&i.idbtrans.abort(),ht(e)})})),this.Version=(o=this,Tt(Sn.prototype,function(e){this.db=o,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,Tt($t.prototype,function(e,t,n){if(this.db=s,this._ctx={table:e,index:":id"===t?null:t,or:n},this._cmp=this._ascending=St,this._descending=function(e,t){return St(t,e)},this._max=function(e,t){return 0<St(e,t)?e:t},this._min=function(e,t){return St(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(i.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(i.name,"'. Closing db now to resume the delete request.")),i.close()}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('".concat(i.name,"') was blocked")):console.warn("Upgrade '".concat(i.name,"' blocked by other connection holding version ").concat(e.oldVersion/10))}),this._maxKey=fn(t.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new i.Transaction(e,t,n,i._options.chromeTransactionDurability,r)},this._fireOnBlocked=function(t){i.on("blocked").fire(t),mt.filter(function(e){return e.name===i.name&&e!==i&&!e._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(Rn),this.use(Mn),this.use(Qn),this.use(qn),this.vip=Object.create(this,{_vip:{value:!0}}),n.forEach(function(e){return e(i)})}var $n,W="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable",Zn=(er.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},er.prototype[W]=function(){return this},er);function er(e){this._subscribe=e}function tr(t,n){return x(n).forEach(function(e){Wn(t[e]||(t[e]=new Ln),n[e])}),t}function nr(d){return new Zn(function(n){var r=F(d);var o=!1,i={},a={},u={get closed(){return o},unsubscribe:function(){o=!0,on.storagemutated.unsubscribe(f)}};n.start&&n.start(u);var s=!1,c=!1;function l(){return x(a).some(function(e){return i[e]&&zn(i[e],a[e])})}var f=function(e){tr(i,e),l()&&h()},h=function(){var t,e;s||o||(i={},e=function(e){r&&et();var t=function(){return Ze(d,{subscr:e,trans:null})},t=je.trans?at(je.transless,t):t();return r&&t.then(tt,tt),t}(t={}),c||(on(nn,f),c=!0),s=!0,Promise.resolve(e).then(function(e){s=!1,o||(l()?h():(i={},a=t,n.next&&n.next(e)))},function(e){["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||(s=!1,n.error&&n.error(e),u.unsubscribe())}))};return h(),u})}try{$n={indexedDB:h.indexedDB||h.mozIndexedDB||h.webkitIndexedDB||h.msIndexedDB,IDBKeyRange:h.IDBKeyRange||h.webkitIDBKeyRange}}catch(e){$n={indexedDB:null,IDBKeyRange:null}}var rr=Xn;function or(e){var t=ar;try{ar=!0,on.storagemutated.fire(e)}finally{ar=t}}r(rr,g(g({},e),{delete:function(e){return new rr(e,{addons:[]}).delete()},exists:function(e){return new rr(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=rr.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Cn(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==wt})}):An(n,t).toCollection().primaryKeys()).then(e)}catch(e){return ht(new Z.MissingAPI)}var t,n},defineClass:function(){return function(e){u(this,e)}},ignoreTransaction:function(e){return je.trans?at(je.transless,e):e()},vip:Dn,async:function(t){return function(){try{var e=Tn(t.apply(this,arguments));return e&&"function"==typeof e.then?e:Ie.resolve(e)}catch(e){return ht(e)}}},spawn:function(e,t,n){try{var r=Tn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Ie.resolve(r)}catch(e){return ht(e)}},currentTransaction:{get:function(){return je.trans||null}},waitFor:function(e,t){t=Ie.resolve("function"==typeof e?rr.ignoreTransaction(e):e).timeout(t||6e4);return je.trans?je.trans.waitFor(t):t},Promise:Ie,debug:{get:function(){return M},set:function(e){N(e,"dexie"===e?function(){return!0}:dt)}},derive:i,extend:u,props:r,override:v,Events:It,on:on,liveQuery:nr,extendObservabilitySet:tr,getByKeyPath:E,setByKeyPath:P,delByKeyPath:function(t,e){"string"==typeof e?P(t,e,void 0):"length"in e&&[].map.call(e,function(e){P(t,e,void 0)})},shallowClone:O,deepClone:A,getObjectDiff:Fn,cmp:St,asap:w,minKey:-1/0,addons:[],connections:mt,errnames:J,dependencies:$n,semVer:z,version:z.split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),rr.maxKey=fn(rr.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(on(nn,function(e){var t;ar||(gt?(t=document.createEvent("CustomEvent")).initCustomEvent(rn,!0,!0,e):t=new CustomEvent(rn,{detail:e}),ar=!0,dispatchEvent(t),ar=!1)}),addEventListener(rn,function(e){e=e.detail;ar||or(e)}));var ir,ar=!1;return"undefined"!=typeof BroadcastChannel?("function"==typeof(ir=new BroadcastChannel(rn)).unref&&ir.unref(),on(nn,function(e){ar||ir.postMessage(e)}),ir.onmessage=function(e){e.data&&or(e.data)}):"undefined"!=typeof self&&"undefined"!=typeof navigator&&(on(nn,function(t){try{ar||("undefined"!=typeof localStorage&&localStorage.setItem(rn,JSON.stringify({trig:Math.random(),changedParts:t})),"object"==typeof self.clients&&o([],self.clients.matchAll({includeUncontrolled:!0}),!0).forEach(function(e){return e.postMessage({type:rn,changedParts:t})}))}catch(e){}}),"undefined"!=typeof addEventListener&&addEventListener("storage",function(e){e.key!==rn||(e=JSON.parse(e.newValue))&&or(e.changedParts)}),(z=self.document&&navigator.serviceWorker)&&z.addEventListener("message",function(e){e=e.data;e&&e.type===rn&&or(e.changedParts)})),Ie.rejectionMapper=function(e,t){return!e||e instanceof G||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ee[e.name]?e:(t=new ee[e.name](t||e.message,e),"stack"in e&&l(t,"stack",{get:function(){return this.inner.stack}}),t)},N(M,dt),g(Xn,Object.freeze({__proto__:null,Dexie:Xn,liveQuery:nr,Entity:Kt,cmp:St,default:Xn,RangeSet:Ln,mergeRanges:Wn,rangesOverlap:zn}),{default:Xn}),Xn});
2
+ //# sourceMappingURL=dexie.min.js.map
package/dist/dexie.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-alpha.7, Wed Jan 25 2023
7
+ * Version 4.0.1-alpha.8, Fri Feb 17 2023
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1294,7 +1294,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1294
1294
  }
1295
1295
  }
1296
1296
 
1297
- var DEXIE_VERSION = '4.0.1-alpha.7';
1297
+ var DEXIE_VERSION = '4.0.1-alpha.8';
1298
1298
  var maxString = String.fromCharCode(65535);
1299
1299
  var minKey = -Infinity;
1300
1300
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -1 +1,2 @@
1
- const e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,t=Object.keys,n=Array.isArray;function r(e,n){return"object"!=typeof n||t(n).forEach((function(t){e[t]=n[t]})),e}"undefined"==typeof Promise||e.Promise||(e.Promise=Promise);const s=Object.getPrototypeOf,i={}.hasOwnProperty;function o(e,t){return i.call(e,t)}function a(e,n){"function"==typeof n&&(n=n(s(e))),("undefined"==typeof Reflect?t:Reflect.ownKeys)(n).forEach((t=>{l(e,t,n[t])}))}const u=Object.defineProperty;function l(e,t,n,s){u(e,t,r(n&&o(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},s))}function c(e){return{from:function(t){return e.prototype=Object.create(t.prototype),l(e.prototype,"constructor",e),{extend:a.bind(null,e.prototype)}}}}const h=Object.getOwnPropertyDescriptor;function d(e,t){let n;return h(e,t)||(n=s(e))&&d(n,t)}const f=[].slice;function p(e,t,n){return f.call(e,t,n)}function y(e,t){return t(e)}function m(e){if(!e)throw new Error("Assertion Failed")}function v(t){e.setImmediate?setImmediate(t):setTimeout(t,0)}function g(e,t){return e.reduce(((e,n,r)=>{var s=t(n,r);return s&&(e[s[0]]=s[1]),e}),{})}function b(e,t){if(o(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,s=t.length;r<s;++r){var i=b(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var u=e[t.substr(0,a)];return void 0===u?void 0:b(u,t.substr(a+1))}}function _(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){m("string"!=typeof r&&"length"in r);for(var s=0,i=t.length;s<i;++s)_(e,t[s],r[s])}else{var a=t.indexOf(".");if(-1!==a){var u=t.substr(0,a),l=t.substr(a+1);if(""===l)void 0===r?n(e)&&!isNaN(parseInt(u))?e.splice(u,1):delete e[u]:e[u]=r;else{var c=e[u];c&&o(e,u)||(c=e[u]={}),_(c,l,r)}}else void 0===r?n(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function w(e){var t={};for(var n in e)o(e,n)&&(t[n]=e[n]);return t}const x=[].concat;function k(e){return x.apply([],e)}const E="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(k([8,16,32,64].map((e=>["Int","Uint","Float"].map((t=>t+e+"Array")))))).filter((t=>e[t])),P=E.map((t=>e[t]));g(E,(e=>[e,!0]));let K=null;function O(e){K="undefined"!=typeof WeakMap&&new WeakMap;const t=S(e);return K=null,t}function S(e){if(!e||"object"!=typeof e)return e;let t=K&&K.get(e);if(t)return t;if(n(e)){t=[],K&&K.set(e,t);for(var r=0,i=e.length;r<i;++r)t.push(S(e[r]))}else if(P.indexOf(e.constructor)>=0)t=e;else{const n=s(e);for(var a in t=n===Object.prototype?{}:Object.create(n),K&&K.set(e,t),e)o(e,a)&&(t[a]=S(e[a]))}return t}const{toString:C}={};function A(e){return C.call(e).slice(8,-1)}const j="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",D="symbol"==typeof j?function(e){var t;return null!=e&&(t=e[j])&&t.apply(e)}:function(){return null},I={};function B(e){var t,r,s,i;if(1===arguments.length){if(n(e))return e.slice();if(this===I&&"string"==typeof e)return[e];if(i=D(e)){for(r=[];!(s=i.next()).done;)r.push(s.value);return r}if(null==e)return[e];if("number"==typeof(t=e.length)){for(r=new Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=new Array(t);t--;)r[t]=arguments[t];return r}const T="undefined"!=typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var R="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function F(e,t){R=e,M=t}var M=()=>!0;const N=!new Error("").stack;function q(){if(N)try{throw q.arguments,new Error}catch(e){return e}return new Error}function $(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(M).map((e=>"\n"+e)).join("")):""}var U=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],L=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(U),V={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 W(e,t){this._e=q(),this.name=e,this.message=t}function Y(e,t){return e+". Errors: "+Object.keys(t).map((e=>t[e].toString())).filter(((e,t,n)=>n.indexOf(e)===t)).join("\n")}function z(e,t,n,r){this._e=q(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=Y(e,t)}function G(e,t){this._e=q(),this.name="BulkError",this.failures=Object.keys(t).map((e=>t[e])),this.failuresByPos=t,this.message=Y(e,this.failures)}c(W).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+$(this._e,2))}},toString:function(){return this.name+": "+this.message}}),c(z).from(W),c(G).from(W);var H=L.reduce(((e,t)=>(e[t]=t+"Error",e)),{});const Q=W;var X=L.reduce(((e,t)=>{var n=t+"Error";function r(e,r){this._e=q(),this.name=n,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=V[t]||n,this.inner=null)}return c(r).from(Q),e[t]=r,e}),{});X.Syntax=SyntaxError,X.Type=TypeError,X.Range=RangeError;var J=U.reduce(((e,t)=>(e[t+"Error"]=X[t],e)),{});var Z=L.reduce(((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=X[t]),e)),{});function ee(){}function te(e){return e}function ne(e,t){return null==e||e===te?t:function(n){return t(e(n))}}function re(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function se(e,t){return e===ee?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?re(r,this.onsuccess):r),s&&(this.onerror=this.onerror?re(s,this.onerror):s),void 0!==i?i:n}}function ie(e,t){return e===ee?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?re(n,this.onsuccess):n),r&&(this.onerror=this.onerror?re(r,this.onerror):r)}}function oe(e,t){return e===ee?t:function(n){var s=e.apply(this,arguments);r(n,s);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?re(i,this.onsuccess):i),o&&(this.onerror=this.onerror?re(o,this.onerror):o),void 0===s?void 0===a?void 0:a:r(s,a)}}function ae(e,t){return e===ee?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ue(e,t){return e===ee?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,s=arguments.length,i=new Array(s);s--;)i[s]=arguments[s];return n.then((function(){return t.apply(r,i)}))}return t.apply(this,arguments)}}Z.ModifyError=z,Z.DexieError=W,Z.BulkError=G;var le={};const[ce,he,de]="undefined"==typeof Promise?[]:(()=>{let e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,s(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,s(t),e]})(),fe=he&&he.then,pe=ce&&ce.constructor,ye=!!de;var me=!1,ve=de?()=>{de.then(qe)}:e.setImmediate?setImmediate.bind(null,qe):e.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver((()=>{qe(),e=null})).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(qe,0)},ge=function(e,t){Oe.push([e,t]),_e&&(ve(),_e=!1)},be=!0,_e=!0,we=[],xe=[],ke=null,Ee=te,Pe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ct,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach((e=>{try{ct(e[0],e[1])}catch(e){}}))}},Ke=Pe,Oe=[],Se=0,Ce=[];function Ae(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ee,this._lib=!1;var t=this._PSD=Ke;if(R&&(this._stackHolder=q(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==le)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Be(this,this._value))}this._state=null,this._value=null,++t.ref,Ie(this,e)}const je={get:function(){var e=Ke,t=Qe;function n(n,r){var s=!e.global&&(e!==Ke||t!==Qe);const i=s&&!et();var o=new Ae(((t,o)=>{Re(this,new De(ut(n,e,s,i),ut(r,e,s,i),t,o,e))}));return R&&Ne(o,this),o}return n.prototype=le,n},set:function(e){l(this,"then",e&&e.prototype===le?je:{get:function(){return e},set:je.set})}};function De(e,t,n,r,s){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=s}function Ie(e,t){try{t((t=>{if(null===e._state){if(t===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&$e();t&&"function"==typeof t.then?Ie(e,((e,n)=>{t instanceof Ae?t._then(e,n):t.then(e,n)})):(e._state=!0,e._value=t,Te(e)),n&&Ue()}}),Be.bind(null,e))}catch(t){Be(e,t)}}function Be(e,t){if(xe.push(t),null===e._state){var n=e._lib&&$e();t=Ee(t),e._state=!1,e._value=t,R&&null!==t&&"object"==typeof t&&!t._promise&&function(e,t,n){try{e.apply(null,n)}catch(e){t&&t(e)}}((()=>{var n=d(t,"stack");t._promise=e,l(t,"stack",{get:()=>me?n&&(n.get?n.get.apply(t):n.value):e.stack})})),function(e){we.some((t=>t._value===e._value))||we.push(e)}(e),Te(e),n&&Ue()}}function Te(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Re(e,t[n]);var s=e._PSD;--s.ref||s.finalize(),0===Se&&(++Se,ge((()=>{0==--Se&&Le()}),[]))}function Re(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,ge(Fe,[n,e,t])}else e._listeners.push(t)}function Fe(e,t,n){try{ke=t;var r,s=t._value;t._state?r=e(s):(xe.length&&(xe=[]),r=e(s),-1===xe.indexOf(s)&&function(e){var t=we.length;for(;t;)if(we[--t]._value===e._value)return void we.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 Me(e,t,n){if(t.length===n)return t;var r="";if(!1===e._state){var s,i,o=e._value;null!=o?(s=o.name||"Error",i=o.message||o,r=$(o,0)):(s=o,i=""),t.push(s+(i?": "+i:"")+r)}return R&&((r=$(e._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),e._prev&&Me(e._prev,t,n)),t}function Ne(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function qe(){$e()&&Ue()}function $e(){var e=be;return be=!1,_e=!1,e}function Ue(){var e,t,n;do{for(;Oe.length>0;)for(e=Oe,Oe=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(Oe.length>0);be=!0,_e=!0}function Le(){var e=we;we=[],e.forEach((e=>{e._PSD.onunhandled.call(null,e._value,e)}));for(var t=Ce.slice(0),n=t.length;n;)t[--n]()}function Ve(e){return new Ae(le,!1,e)}function We(e,t){var n=Ke;return function(){var r=$e(),s=Ke;try{return st(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{st(s,!1),r&&Ue()}}}a(Ae.prototype,{then:je,_then:function(e,t){Re(this,new De(null,null,e,t,Ke))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,(e=>e instanceof t?n(e):Ve(e))):this.then(null,(e=>e&&e.name===t?n(e):Ve(e)))},finally:function(e){return this.then((t=>(e(),t)),(t=>(e(),Ve(t))))},stack:{get:function(){if(this._stack)return this._stack;try{me=!0;var e=Me(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{me=!1}}},timeout:function(e,t){return e<1/0?new Ae(((n,r)=>{var s=setTimeout((()=>r(new X.Timeout(t))),e);this.then(n,r).finally(clearTimeout.bind(null,s))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&l(Ae.prototype,Symbol.toStringTag,"Dexie.Promise"),Pe.env=it(),a(Ae,{all:function(){var e=B.apply(null,arguments).map(tt);return new Ae((function(t,n){0===e.length&&t([]);var r=e.length;e.forEach(((s,i)=>Ae.resolve(s).then((n=>{e[i]=n,--r||t(e)}),n)))}))},resolve:e=>{if(e instanceof Ae)return e;if(e&&"function"==typeof e.then)return new Ae(((t,n)=>{e.then(t,n)}));var t=new Ae(le,!0,e);return Ne(t,ke),t},reject:Ve,race:function(){var e=B.apply(null,arguments).map(tt);return new Ae(((t,n)=>{e.map((e=>Ae.resolve(e).then(t,n)))}))},PSD:{get:()=>Ke,set:e=>Ke=e},totalEchoes:{get:()=>Qe},newPSD:Je,usePSD:ot,scheduler:{get:()=>ge,set:e=>{ge=e}},rejectionMapper:{get:()=>Ee,set:e=>{Ee=e}},follow:(e,t)=>new Ae(((n,r)=>Je(((t,n)=>{var r=Ke;r.unhandleds=[],r.onunhandled=n,r.finalize=re((function(){!function(e){function t(){e(),Ce.splice(Ce.indexOf(t),1)}Ce.push(t),++Se,ge((()=>{0==--Se&&Le()}),[])}((()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])}))}),r.finalize),e()}),t,n,r)))}),pe&&(pe.allSettled&&l(Ae,"allSettled",(function(){const e=B.apply(null,arguments).map(tt);return new Ae((t=>{0===e.length&&t([]);let n=e.length;const r=new Array(n);e.forEach(((e,s)=>Ae.resolve(e).then((e=>r[s]={status:"fulfilled",value:e}),(e=>r[s]={status:"rejected",reason:e})).then((()=>--n||t(r)))))}))})),pe.any&&"undefined"!=typeof AggregateError&&l(Ae,"any",(function(){const e=B.apply(null,arguments).map(tt);return new Ae(((t,n)=>{0===e.length&&n(new AggregateError([]));let r=e.length;const s=new Array(r);e.forEach(((e,i)=>Ae.resolve(e).then((e=>t(e)),(e=>{s[i]=e,--r||n(new AggregateError(s))}))))}))})));const Ye={awaits:0,echoes:0,id:0};var ze=0,Ge=[],He=0,Qe=0,Xe=0;function Je(e,t,n,s){var i=Ke,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++Xe;var a=Pe.env;o.env=ye?{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:lt(a.nthen,o),gthen:lt(a.gthen,o)}:{},t&&r(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=ot(o,e,n,s);return 0===o.ref&&o.finalize(),u}function Ze(){return Ye.id||(Ye.id=++ze),++Ye.awaits,Ye.echoes+=100,Ye.id}function et(){return!!Ye.awaits&&(0==--Ye.awaits&&(Ye.id=0),Ye.echoes=100*Ye.awaits,!0)}function tt(e){return Ye.echoes&&e&&e.constructor===pe?(Ze(),e.then((e=>(et(),e)),(e=>(et(),ht(e))))):e}function nt(e){++Qe,Ye.echoes&&0!=--Ye.echoes||(Ye.echoes=Ye.id=0),Ge.push(Ke),st(e,!0)}function rt(){var e=Ge[Ge.length-1];Ge.pop(),st(e,!1)}function st(t,n){var r=Ke;if((n?!Ye.echoes||He++&&t===Ke:!He||--He&&t===Ke)||at(n?nt.bind(null,t):rt),t!==Ke&&(Ke=t,r===Pe&&(Pe.env=it()),ye)){var s=Pe.env.Promise,i=t.env;he.then=i.nthen,s.prototype.then=i.gthen,(r.global||t.global)&&(Object.defineProperty(e,"Promise",i.PromiseProp),s.all=i.all,s.race=i.race,s.resolve=i.resolve,s.reject=i.reject,i.allSettled&&(s.allSettled=i.allSettled),i.any&&(s.any=i.any))}}function it(){var t=e.Promise;return ye?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(e,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:he.then,gthen:t.prototype.then}:{}}function ot(e,t,n,r,s){var i=Ke;try{return st(e,!0),t(n,r,s)}finally{st(i,!1)}}function at(e){fe.call(ce,e)}function ut(e,t,n,r){return"function"!=typeof e?e:function(){var s=Ke;n&&Ze(),st(t,!0);try{return e.apply(this,arguments)}finally{st(s,!1),r&&at(et)}}}function lt(e,t){return function(n,r){return e.call(this,ut(n,t),ut(r,t))}}-1===(""+fe).indexOf("[native code]")&&(Ze=et=ee);function ct(t,n){var s;try{s=n.onuncatched(t)}catch(e){}if(!1!==s)try{var i,o={promise:n,reason:t};if(e.document&&document.createEvent?((i=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),r(i,o)):e.CustomEvent&&r(i=new CustomEvent("unhandledrejection",{detail:o}),o),i&&e.dispatchEvent&&(dispatchEvent(i),!e.PromiseRejectionEvent&&e.onunhandledrejection))try{e.onunhandledrejection(i)}catch(e){}R&&i&&!i.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch(e){}}var ht=Ae.reject;function dt(e,t,n,r){if(e.idbdb&&(e._state.openComplete||Ke.letThrough||e._vip)){var s=e._createTransaction(t,n,e._dbSchema);try{s.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===H.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>dt(e,t,n,r)))):ht(s)}return s._promise(t,((e,t)=>Je((()=>(Ke.trans=s,r(e,t,s)))))).then((e=>s._completion.then((()=>e))))}if(e._state.openComplete)return ht(new X.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return ht(new X.DatabaseClosed);e.open().catch(ee)}return e._state.dbReadyPromise.then((()=>dt(e,t,n,r)))}const ft=String.fromCharCode(65535),pt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",yt=[],mt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),vt=mt,gt=mt,bt=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function _t(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const wt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function xt(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=O(t))[e],t)}function kt(){throw X.Type()}function Et(e,t){try{const n=Pt(e),r=Pt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){const n=e.length,r=t.length,s=n<r?n:r;for(let n=0;n<s;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===r?0:n<r?-1:1}(Kt(e),Kt(t));case"Array":return function(e,t){const n=e.length,r=t.length,s=n<r?n:r;for(let n=0;n<s;++n){const r=Et(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function Pt(e){const t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";const n=A(e);return"ArrayBuffer"===n?"binary":n}function Kt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class Ot{_trans(e,t,n){const r=this._tx||Ke.trans,s=this.name;function i(e,n,r){if(!r.schema[s])throw new X.NotFound("Table "+s+" not part of transaction");return t(r.idbtrans,r)}const o=$e();try{return r&&r.db===this.db?r===Ke.trans?r._promise(e,i,n):Je((()=>r._promise(e,i,n)),{trans:r,transless:Ke.transless||Ke}):dt(this.db,e,[this.name],i)}finally{o&&Ue()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",(t=>this.core.get({trans:t,key:e}).then((e=>this.hook.reading.fire(e))))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(n(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const r=t(e);if(1===r.length)return this.where(r[0]).equals(e[r[0]]);const s=this.schema.indexes.concat(this.schema.primKey).filter((e=>e.compound&&r.every((t=>e.keyPath.indexOf(t)>=0))&&e.keyPath.every((e=>r.indexOf(e)>=0))))[0];if(s&&this.db._maxKey!==ft)return this.where(s.name).equals(s.keyPath.map((t=>e[t])));!s&&R&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${r.join("+")}]`);const{idxByName:i}=this.schema,o=this.db._deps.indexedDB;function a(e,t){return 0===o.cmp(e,t)}const[u,l]=r.reduce((([t,r],s)=>{const o=i[s],u=e[s];return[t||o,t||!o?_t(r,o&&o.multi?e=>{const t=b(e,s);return n(t)&&t.some((e=>a(u,e)))}:e=>a(u,b(e,s))):r]}),[null,null]);return u?this.where(u.name).equals(e[u.keyPath]).filter(l):s?this.filter(l):this.where(r).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,n(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){const{db:t,name:n}=this;this.schema.mappedClass=e,e.prototype instanceof kt&&(e=class extends e{get db(){return t}table(){return n}});const r=new Set;for(let t=e.prototype;t;t=s(t))Object.getOwnPropertyNames(t).forEach((e=>r.add(e)));const i=t=>{if(!t)return t;const n=Object.create(e.prototype);for(let e in t)if(!r.has(e))try{n[e]=t[e]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=i,this.hook("reading",i),e}defineClass(){return this.mapToClass((function(e){r(this,e)}))}add(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let s=e;return r&&n&&(s=xt(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[s]}))).then((e=>e.numFailures?Ae.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{_(e,r,t)}catch(e){}return t}))}update(e,r){if("object"!=typeof e||n(e))return this.where(":id").equals(e).modify(r);{const n=b(e,this.schema.primKey.keyPath);if(void 0===n)return ht(new X.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof r?t(r).forEach((t=>{_(e,t,r[t])})):r(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(r)}}put(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let s=e;return r&&n&&(s=xt(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"put",values:[s],keys:null!=t?[t]:null}))).then((e=>e.numFailures?Ae.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{_(e,r,t)}catch(e){}return t}))}delete(e){return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:[e]}))).then((e=>e.numFailures?Ae.reject(e.failures[0]):void 0))}clear(){return this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"deleteRange",range:wt}))).then((e=>e.numFailures?Ae.reject(e.failures[0]):void 0))}bulkGet(e){return this._trans("readonly",(t=>this.core.getMany({keys:e,trans:t}).then((e=>e.map((e=>this.hook.reading.fire(e)))))))}bulkAdd(e,t,n){const r=Array.isArray(t)?t:void 0,s=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new X.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");const o=e.length;let a=i&&n?e.map(xt(i)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:a,wantResults:s}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return s?t:n;throw new G(`${this.name}.bulkAdd(): ${e} of ${o} operations failed`,r)}))}))}bulkPut(e,t,n){const r=Array.isArray(t)?t:void 0,s=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new X.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");const o=e.length;let a=i&&n?e.map(xt(i)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:a,wantResults:s}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return s?t:n;throw new G(`${this.name}.bulkPut(): ${e} of ${o} operations failed`,r)}))}))}bulkUpdate(e){const t=this.core,n=e.map((e=>e.key)),r=e.map((e=>e.changes)),s=[];return this._trans("readwrite",(i=>t.getMany({trans:i,keys:n,cache:"clone"}).then((o=>{const a=[],u=[];e.forEach((({key:e,changes:t},n)=>{const r=o[n];if(r){for(const n of Object.keys(t)){const s=t[n];if(n===this.schema.primKey.keyPath){if(0!==Et(s,e))throw new X.Constraint("Cannot update primary key in bulkUpdate()")}else _(r,n,s)}s.push(n),a.push(e),u.push(r)}}));const l=a.length;return t.mutate({trans:i,type:"put",keys:a,values:u,updates:{keys:n,changeSpecs:r}}).then((({numFailures:e,failures:t})=>{if(0===e)return l;for(const e of Object.keys(t)){const n=s[Number(e)];if(null!=n){const r=t[e];delete t[e],t[n]=r}}throw new G(`${this.name}.bulkUpdate(): ${e} of ${l} operations failed`,t)}))}))))}bulkDelete(e){const t=e.length;return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:e}))).then((({numFailures:e,lastResult:n,failures:r})=>{if(0===e)return n;throw new G(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)}))}}function St(e){var r={},s=function(t,n){if(n){for(var s=arguments.length,i=new Array(s-1);--s;)i[s-1]=arguments[s];return r[t].subscribe.apply(null,i),e}if("string"==typeof t)return r[t]};s.addEventType=a;for(var i=1,o=arguments.length;i<o;++i)a(arguments[i]);return s;function a(e,t,n){if("object"==typeof e)return u(e);t||(t=ae),n||(n=ee);var i={subscribers:[],fire:n,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=t(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter((function(t){return t!==e})),i.fire=i.subscribers.reduce(t,n)}};return r[e]=s[e]=i,i}function u(e){t(e).forEach((function(t){var r=e[t];if(n(r))a(t,e[t][0],e[t][1]);else{if("asap"!==r)throw new X.InvalidArgument("Invalid event config");var s=a(t,te,(function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];s.subscribers.forEach((function(e){v((function(){e.apply(null,t)}))}))}))}}))}}function Ct(e,t){return c(t).from({prototype:e}),t}function At(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function jt(e,t){e.filter=_t(e.filter,t)}function Dt(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>_t(r(),t()):t,e.justLimit=n&&!r}function It(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new X.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Bt(e,t,n){const r=It(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function Tt(e,t,n,r){const s=e.replayFilter?_t(e.filter,e.replayFilter()):e.filter;if(e.or){const i={},a=(e,n,r)=>{if(!s||s(n,r,(e=>n.stop(e)),(e=>n.fail(e)))){var a=n.primaryKey,u=""+a;"[object ArrayBuffer]"===u&&(u=""+new Uint8Array(a)),o(i,u)||(i[u]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(a,n),Rt(Bt(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return Rt(Bt(e,r,n),_t(e.algorithm,s),t,!e.keysOnly&&e.valueMapper)}function Rt(e,t,n,r){var s=We(r?(e,t,s)=>n(r(e),t,s):n);return e.then((e=>{if(e)return e.start((()=>{var n=()=>e.continue();t&&!t(e,(e=>n=e),(t=>{e.stop(t),n=ee}),(t=>{e.fail(t),n=ee}))||s(e.value,e,(e=>n=e)),n()}))}))}class Ft{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,ht.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,ht.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=_t(t.algorithm,e)}_iterate(e,t){return Tt(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&r(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read((n=>Tt(t,e,n,t.table.core)))}count(e){return this._read((e=>{const t=this._ctx,n=t.table.core;if(At(t,!0))return n.count({trans:e,query:{index:It(t,n.schema),range:t.range}}).then((e=>Math.min(e,t.limit)));var r=0;return Tt(t,(()=>(++r,!1)),e,n).then((()=>r))})).then(e)}sortBy(e,t){const n=e.split(".").reverse(),r=n[0],s=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var o="next"===this._ctx.dir?1:-1;function a(e,t){var n=i(e,s),r=i(t,s);return n<r?-o:n>r?o:0}return this.toArray((function(e){return e.sort(a)})).then(t)}toArray(e){return this._read((e=>{var t=this._ctx;if("next"===t.dir&&At(t,!0)&&t.limit>0){const{valueMapper:n}=t,r=It(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then((({result:e})=>n?e.map(n):e))}{const n=[];return Tt(t,(e=>n.push(e)),e,t.table.core).then((()=>n))}}),e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,At(t)?Dt(t,(()=>{var t=e;return(e,n)=>0===t||(1===t?(--t,!1):(n((()=>{e.advance(t),t=0})),!1))})):Dt(t,(()=>{var t=e;return()=>--t<0}))),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Dt(this._ctx,(()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}}),!0),this}until(e,t){return jt(this._ctx,(function(n,r,s){return!e(n.value)||(r(s),t)})),this}first(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)}last(e){return this.reverse().first(e)}filter(e){var t,n;return jt(this._ctx,(function(t){return e(t.value)})),t=this._ctx,n=e,t.isMatch=_t(t.isMatch,n),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.key,n)}))}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.primaryKey,n)}))}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.key)})).then((function(){return n})).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&At(t,!0)&&t.limit>0)return this._read((e=>{var n=It(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})})).then((({result:e})=>e)).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.primaryKey)})).then((function(){return n})).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys((function(e){return e[0]})).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return jt(this._ctx,(function(e){var t=e.primaryKey.toString(),r=o(n,t);return n[t]=!0,!r})),this}modify(e){var n=this._ctx;return this._write((r=>{var s;if("function"==typeof e)s=e;else{var i=t(e),o=i.length;s=function(t){for(var n=!1,r=0;r<o;++r){var s=i[r],a=e[s];b(t,s)!==a&&(_(t,s,a),n=!0)}return n}}const a=n.table.core,{outbound:u,extractKey:l}=a.schema.primaryKey,c=this.db._options.modifyChunkSize||200,h=[];let d=0;const f=[],p=(e,n)=>{const{failures:r,numFailures:s}=n;d+=e-s;for(let e of t(r))h.push(r[e])};return this.clone().primaryKeys().then((t=>{const i=o=>{const h=Math.min(c,t.length-o);return a.getMany({trans:r,keys:t.slice(o,o+h),cache:"immutable"}).then((d=>{const f=[],y=[],m=u?[]:null,v=[];for(let e=0;e<h;++e){const n=d[e],r={value:O(n),primKey:t[o+e]};!1!==s.call(r,r.value,r)&&(null==r.value?v.push(t[o+e]):u||0===Et(l(n),l(r.value))?(y.push(r.value),u&&m.push(t[o+e])):(v.push(t[o+e]),f.push(r.value)))}const g=At(n)&&n.limit===1/0&&("function"!=typeof e||e===Mt)&&{index:n.index,range:n.range};return Promise.resolve(f.length>0&&a.mutate({trans:r,type:"add",values:f}).then((e=>{for(let t in e.failures)v.splice(parseInt(t),1);p(f.length,e)}))).then((()=>(y.length>0||g&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:m,values:y,criteria:g,changeSpec:"function"!=typeof e&&e}).then((e=>p(y.length,e))))).then((()=>(v.length>0||g&&e===Mt)&&a.mutate({trans:r,type:"delete",keys:v,criteria:g}).then((e=>p(v.length,e))))).then((()=>t.length>o+h&&i(o+c)))}))};return i(0).then((()=>{if(h.length>0)throw new z("Error modifying one or more objects",h,d,f);return t.length}))}))}))}delete(){var e=this._ctx,t=e.range;return At(e)&&(e.isPrimKey&&!gt||3===t.type)?this._write((n=>{const{primaryKey:r}=e.table.core.schema,s=t;return e.table.core.count({trans:n,query:{index:r,range:s}}).then((t=>e.table.core.mutate({trans:n,type:"deleteRange",range:s}).then((({failures:e,lastResult:n,results:r,numFailures:s})=>{if(s)throw new z("Could not delete some values",Object.keys(e).map((t=>e[t])),t-s);return t-s}))))})):this.modify(Mt)}}const Mt=(e,t)=>t.value=null;function Nt(e,t){return e<t?-1:e===t?0:1}function qt(e,t){return e>t?-1:e===t?0:1}function $t(e,t,n){var r=e instanceof zt?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function Ut(e){return new e.Collection(e,(()=>Yt(""))).limit(0)}function Lt(e,t,n,r,s,i){for(var o=Math.min(e.length,r.length),a=-1,u=0;u<o;++u){var l=t[u];if(l!==r[u])return s(e[u],n[u])<0?e.substr(0,u)+n[u]+n.substr(u+1):s(e[u],r[u])<0?e.substr(0,u)+r[u]+n.substr(u+1):a>=0?e.substr(0,a)+t[a]+n.substr(a+1):null;s(e[u],l)<0&&(a=u)}return o<r.length&&"next"===i?e+n.substr(e.length):o<e.length&&"prev"===i?e.substr(0,n.length):a<0?null:e.substr(0,a)+r[a]+n.substr(a+1)}function Vt(e,t,n,r){var s,i,o,a,u,l,c,h=n.length;if(!n.every((e=>"string"==typeof e)))return $t(e,"String expected.");function d(e){s=function(e){return"next"===e?e=>e.toUpperCase():e=>e.toLowerCase()}(e),i=function(e){return"next"===e?e=>e.toLowerCase():e=>e.toUpperCase()}(e),o="next"===e?Nt:qt;var t=n.map((function(e){return{lower:i(e),upper:s(e)}})).sort((function(e,t){return o(e.lower,t.lower)}));a=t.map((function(e){return e.upper})),u=t.map((function(e){return e.lower})),l=e,c="next"===e?"":r}d("next");var f=new e.Collection(e,(()=>Wt(a[0],u[h-1]+r)));f._ondirectionchange=function(e){d(e)};var p=0;return f._addAlgorithm((function(e,n,r){var s=e.key;if("string"!=typeof s)return!1;var d=i(s);if(t(d,u,p))return!0;for(var f=null,y=p;y<h;++y){var m=Lt(s,d,a[y],u[y],o,l);null===m&&null===f?p=y+1:(null===f||o(f,m)>0)&&(f=m)}return n(null!==f?function(){e.continue(f+c)}:r),!1})),f}function Wt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Yt(e){return{type:1,lower:e,upper:e}}class zt{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Ut(this):new this.Collection(this,(()=>Wt(e,t,!n,!r)))}catch(e){return $t(this,pt)}}equals(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Yt(e)))}above(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(e,void 0,!0)))}aboveOrEqual(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(e,void 0,!1)))}below(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(void 0,e,!1,!0)))}belowOrEqual(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(void 0,e)))}startsWith(e){return"string"!=typeof e?$t(this,"String expected."):this.between(e,e+ft,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):Vt(this,((e,t)=>0===e.indexOf(t[0])),[e],ft)}equalsIgnoreCase(e){return Vt(this,((e,t)=>e===t[0]),[e],"")}anyOfIgnoreCase(){var e=B.apply(I,arguments);return 0===e.length?Ut(this):Vt(this,((e,t)=>-1!==t.indexOf(e)),e,"")}startsWithAnyOfIgnoreCase(){var e=B.apply(I,arguments);return 0===e.length?Ut(this):Vt(this,((e,t)=>t.some((t=>0===e.indexOf(t)))),e,ft)}anyOf(){const e=B.apply(I,arguments);let t=this._cmp;try{e.sort(t)}catch(e){return $t(this,pt)}if(0===e.length)return Ut(this);const n=new this.Collection(this,(()=>Wt(e[0],e[e.length-1])));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let r=0;return n._addAlgorithm(((n,s,i)=>{const o=n.key;for(;t(o,e[r])>0;)if(++r,r===e.length)return s(i),!1;return 0===t(o,e[r])||(s((()=>{n.continue(e[r])})),!1)})),n}notEqual(e){return this.inAnyRange([[-(1/0),e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=B.apply(I,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return $t(this,pt)}const t=e.reduce(((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-(1/0),t]]),null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){const n=this._cmp,r=this._ascending,s=this._descending,i=this._min,o=this._max;if(0===e.length)return Ut(this);if(!e.every((e=>void 0!==e[0]&&void 0!==e[1]&&r(e[0],e[1])<=0)))return $t(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",X.InvalidArgument);const a=!t||!1!==t.includeLowers,u=t&&!0===t.includeUppers;let l,c=r;function h(e,t){return c(e[0],t[0])}try{l=e.reduce((function(e,t){let r=0,s=e.length;for(;r<s;++r){const s=e[r];if(n(t[0],s[1])<0&&n(t[1],s[0])>0){s[0]=i(s[0],t[0]),s[1]=o(s[1],t[1]);break}}return r===s&&e.push(t),e}),[]),l.sort(h)}catch(e){return $t(this,pt)}let d=0;const f=u?e=>r(e,l[d][1])>0:e=>r(e,l[d][1])>=0,p=a?e=>s(e,l[d][0])>0:e=>s(e,l[d][0])>=0;let y=f;const m=new this.Collection(this,(()=>Wt(l[0][0],l[l.length-1][1],!a,!u)));return m._ondirectionchange=e=>{"next"===e?(y=f,c=r):(y=p,c=s),l.sort(h)},m._addAlgorithm(((e,t,n)=>{for(var s=e.key;y(s);)if(++d,d===l.length)return t(n),!1;return!!function(e){return!f(e)&&!p(e)}(s)||(0===this._cmp(s,l[d][1])||0===this._cmp(s,l[d][0])||t((()=>{c===r?e.continue(l[d][0]):e.continue(l[d][1])})),!1)})),m}startsWithAnyOf(){const e=B.apply(I,arguments);return e.every((e=>"string"==typeof e))?0===e.length?Ut(this):this.inAnyRange(e.map((e=>[e,e+ft]))):$t(this,"startsWithAnyOf() only works with strings")}}function Gt(e){return We((function(t){return Ht(t),e(t.target.error),!1}))}function Ht(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const Qt=St(null,"storagemutated");class Xt{_lock(){return m(!Ke.global),++this._reculock,1!==this._reculock||Ke.global||(Ke.lockOwnerFor=this),this}_unlock(){if(m(!Ke.global),0==--this._reculock)for(Ke.global||(Ke.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{ot(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&Ke.lockOwnerFor!==this}create(e){if(!this.mode)return this;const t=this.db.idbdb,n=this.db._state.dbOpenError;if(m(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new X.DatabaseClosed(n);case"MissingAPIError":throw new X.MissingAPI(n.message,n);default:throw new X.OpenFailed(n)}if(!this.active)throw new X.TransactionInactive;return m(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=We((t=>{Ht(t),this._reject(e.error)})),e.onabort=We((t=>{Ht(t),this.active&&this._reject(new X.Abort(e.error)),this.active=!1,this.on("abort").fire(t)})),e.oncomplete=We((()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Qt.storagemutated.fire(e.mutatedParts)})),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return ht(new X.ReadOnly("Transaction is readonly"));if(!this.active)return ht(new X.TransactionInactive);if(this._locked())return new Ae(((r,s)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,s)},Ke])}));if(n)return Je((()=>{var e=new Ae(((e,n)=>{this._lock();const r=t(e,n,this);r&&r.then&&r.then(e,n)}));return e.finally((()=>this._unlock())),e._lib=!0,e}));var r=new Ae(((e,n)=>{var r=t(e,n,this);r&&r.then&&r.then(e,n)}));return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();const n=Ae.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then((()=>n));else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var s=t._waitingFor;return new Ae(((e,r)=>{n.then((n=>t._waitingQueue.push(We(e.bind(null,n)))),(e=>t._waitingQueue.push(We(r.bind(null,e))))).finally((()=>{t._waitingFor===s&&(t._waitingFor=null)}))}))}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new X.Abort))}table(e){const t=this._memoizedTables||(this._memoizedTables={});if(o(t,e))return t[e];const n=this.schema[e];if(!n)throw new X.NotFound("Table "+e+" not part of transaction");const r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function Jt(e,t,n,r,s,i,o){return{name:e,keyPath:t,unique:n,multi:r,auto:s,compound:i,src:(n&&!o?"&":"")+(r?"*":"")+(s?"++":"")+Zt(t)}}function Zt(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function en(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:g(n,(e=>[e.name,e]))}}let tn=e=>{try{return e.only([[]]),tn=()=>[[]],[[]]}catch(e){return tn=()=>ft,ft}};function nn(e){return null==e?()=>{}:"string"==typeof e?function(e){return 1===e.split(".").length?t=>t[e]:t=>b(t,e)}(e):t=>b(t,e)}function rn(e){return[].slice.call(e)}let sn=0;function on(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function an(e,t,r){function s(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:n,upper:r,lowerOpen:s,upperOpen:i}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!i):void 0===r?t.lowerBound(n,!!s):t.bound(n,r,!!s,!!i)}const{schema:i,hasGetAll:o}=function(e,t){const r=rn(e.objectStoreNames);return{schema:{name:e.name,tables:r.map((e=>t.objectStore(e))).map((e=>{const{keyPath:t,autoIncrement:r}=e,s=n(t),i=null==t,o={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:i,compound:s,keyPath:t,autoIncrement:r,unique:!0,extractKey:nn(t)},indexes:rn(e.indexNames).map((t=>e.index(t))).map((e=>{const{name:t,unique:r,multiEntry:s,keyPath:i}=e,a={name:t,compound:n(i),keyPath:i,unique:r,multiEntry:s,extractKey:nn(i)};return o[on(i)]=a,a})),getIndexByKeyPath:e=>o[on(e)]};return o[":id"]=a.primaryKey,null!=t&&(o[on(t)]=a.primaryKey),a}))},hasGetAll:r.length>0&&"getAll"in t.objectStore(r[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,r),a=i.tables.map((e=>function(e){const t=e.name;return{name:t,schema:e,mutate:function({trans:e,type:n,keys:r,values:i,range:o}){return new Promise(((a,u)=>{a=We(a);const l=e.objectStore(t),c=null==l.keyPath,h="put"===n||"add"===n;if(!h&&"delete"!==n&&"deleteRange"!==n)throw new Error("Invalid operation type: "+n);const{length:d}=r||i||{length:1};if(r&&i&&r.length!==i.length)throw new Error("Given keys array must have same length as given values array.");if(0===d)return a({numFailures:0,failures:{},results:[],lastResult:void 0});let f;const p=[],y=[];let m=0;const v=e=>{++m,Ht(e)};if("deleteRange"===n){if(4===o.type)return a({numFailures:m,failures:y,results:[],lastResult:void 0});3===o.type?p.push(f=l.clear()):p.push(f=l.delete(s(o)))}else{const[e,t]=h?c?[i,r]:[i,null]:[r,null];if(h)for(let r=0;r<d;++r)p.push(f=t&&void 0!==t[r]?l[n](e[r],t[r]):l[n](e[r])),f.onerror=v;else for(let t=0;t<d;++t)p.push(f=l[n](e[t])),f.onerror=v}const g=e=>{const t=e.target.result;p.forEach(((e,t)=>null!=e.error&&(y[t]=e.error))),a({numFailures:m,failures:y,results:"delete"===n?r:p.map((e=>e.result)),lastResult:t})};f.onerror=e=>{v(e),g(e)},f.onsuccess=g}))},getMany:({trans:e,keys:n})=>new Promise(((r,s)=>{r=We(r);const i=e.objectStore(t),o=n.length,a=new Array(o);let u,l=0,c=0;const h=e=>{const t=e.target;a[t._pos]=t.result,++c===l&&r(a)},d=Gt(s);for(let e=0;e<o;++e)null!=n[e]&&(u=i.get(n[e]),u._pos=e,u.onsuccess=h,u.onerror=d,++l);0===l&&r(a)})),get:({trans:e,key:n})=>new Promise(((r,s)=>{r=We(r);const i=e.objectStore(t).get(n);i.onsuccess=e=>r(e.target.result),i.onerror=Gt(s)})),query:function(e){return n=>new Promise(((r,i)=>{r=We(r);const{trans:o,values:a,limit:u,query:l}=n,c=u===1/0?void 0:u,{index:h,range:d}=l,f=o.objectStore(t),p=h.isPrimaryKey?f:f.index(h.name),y=s(d);if(0===u)return r({result:[]});if(e){const e=a?p.getAll(y,c):p.getAllKeys(y,c);e.onsuccess=e=>r({result:e.target.result}),e.onerror=Gt(i)}else{let e=0;const t=a||!("openKeyCursor"in p)?p.openCursor(y):p.openKeyCursor(y),n=[];t.onsuccess=s=>{const i=t.result;return i?(n.push(a?i.value:i.primaryKey),++e===u?r({result:n}):void i.continue()):r({result:n})},t.onerror=Gt(i)}}))}(o),openCursor:function({trans:e,values:n,query:r,reverse:i,unique:o}){return new Promise(((a,u)=>{a=We(a);const{index:l,range:c}=r,h=e.objectStore(t),d=l.isPrimaryKey?h:h.index(l.name),f=i?o?"prevunique":"prev":o?"nextunique":"next",p=n||!("openKeyCursor"in d)?d.openCursor(s(c),f):d.openKeyCursor(s(c),f);p.onerror=Gt(u),p.onsuccess=We((t=>{const n=p.result;if(!n)return void a(null);n.___id=++sn,n.done=!1;const r=n.continue.bind(n);let s=n.continuePrimaryKey;s&&(s=s.bind(n));const i=n.advance.bind(n),o=()=>{throw new Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw new Error("Cursor not started")},n.fail=We(u),n.next=function(){let e=1;return this.start((()=>e--?this.continue():this.stop())).then((()=>this))},n.start=e=>{const t=new Promise(((e,t)=>{e=We(e),p.onerror=Gt(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=o,e(t)}})),a=()=>{if(p.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw new Error("Cursor behind last entry")},n.stop()};return p.onsuccess=We((e=>{p.onsuccess=a,a()})),n.continue=r,n.continuePrimaryKey=s,n.advance=i,a(),t},a(n)}),u)}))},count({query:e,trans:n}){const{index:r,range:i}=e;return new Promise(((e,o)=>{const a=n.objectStore(t),u=r.isPrimaryKey?a:a.index(r.name),l=s(i),c=l?u.count(l):u.count();c.onsuccess=We((t=>e(t.target.result))),c.onerror=Gt(o)}))}}}(e))),u={};return a.forEach((e=>u[e.name]=e)),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!u[e])throw new Error(`Table '${e}' not found`);return u[e]},MIN_KEY:-1/0,MAX_KEY:tn(t),schema:i}}function un({_novip:e},t){const n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},s){const i=function(e,t){return t.reduce(((e,{create:t})=>({...e,...t(e)})),e)}(an(t,n,s),e.dbcore);return{dbcore:i}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach((t=>{const n=t.name;e.core.schema.tables.some((e=>e.name===n))&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))}))}function ln({_novip:e},t,n,r){n.forEach((n=>{const s=r[n];t.forEach((t=>{const r=d(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?l(t,n,{get(){return this.table(n)},set(e){u(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,s))}))}))}function cn({_novip:e},t){t.forEach((t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]}))}function hn(e,t){return e._cfg.version-t._cfg.version}function dn(e,n,r,s){const i=e._dbSchema,o=e._createTransaction("readwrite",e._storeNames,i);o.create(r),o._completion.catch(s);const a=o._reject.bind(o),u=Ke.transless||Ke;Je((()=>{Ke.trans=o,Ke.transless=u,0===n?(t(i).forEach((e=>{pn(r,e,i[e].primKey,i[e].indexes)})),un(e,r),Ae.follow((()=>e.on.populate.fire(o))).catch(a)):function({_novip:e},n,r,s){const i=[],o=e._versions;let a=e._dbSchema=mn(e,e.idbdb,s),u=!1;function l(){return i.length?Ae.resolve(i.shift()(r.idbtrans)).then(l):Ae.resolve()}return o.filter((e=>e._cfg.version>=n)).forEach((o=>{i.push((()=>{const i=a,l=o._cfg.dbschema;vn(e,i,s),vn(e,l,s),a=e._dbSchema=l;const c=fn(i,l);c.add.forEach((e=>{pn(s,e[0],e[1].primKey,e[1].indexes)})),c.change.forEach((e=>{if(e.recreate)throw new X.Upgrade("Not yet support for changing primary key");{const t=s.objectStore(e.name);e.add.forEach((e=>yn(t,e))),e.change.forEach((e=>{t.deleteIndex(e.name),yn(t,e)})),e.del.forEach((e=>t.deleteIndex(e)))}}));const h=o._cfg.contentUpgrade;if(h&&o._cfg.version>n){un(e,s),r._memoizedTables={},u=!0;let n=w(l);c.del.forEach((e=>{n[e]=i[e]})),cn(e,[e.Transaction.prototype]),ln(e,[e.Transaction.prototype],t(n),n),r.schema=n;const o=T(h);let a;o&&Ze();const d=Ae.follow((()=>{if(a=h(r),a&&o){var e=et.bind(null,null);a.then(e,e)}}));return a&&"function"==typeof a.then?Ae.resolve(a):d.then((()=>a))}})),i.push((t=>{if(!u||!vt){!function(e,t){[].slice.call(t.db.objectStoreNames).forEach((n=>null==e[n]&&t.db.deleteObjectStore(n)))}(o._cfg.dbschema,t)}cn(e,[e.Transaction.prototype]),ln(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema}))})),l().then((()=>{var e,n;n=s,t(e=a).forEach((t=>{n.db.objectStoreNames.contains(t)||pn(n,t,e[t].primKey,e[t].indexes)}))}))}(e,n,o,r).catch(a)}))}function fn(e,t){const n={del:[],add:[],change:[]};let r;for(r in e)t[r]||n.del.push(r);for(r in t){const s=e[r],i=t[r];if(s){const e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||s.primKey.auto!==i.primKey.auto&&!mt)e.recreate=!0,n.change.push(e);else{const t=s.idxByName,r=i.idxByName;let o;for(o in t)r[o]||e.del.push(o);for(o in r){const n=t[o],s=r[o];n?n.src!==s.src&&e.change.push(s):e.add.push(s)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}}else n.add.push([r,i])}return n}function pn(e,t,n,r){const s=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach((e=>yn(s,e))),s}function yn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function mn(e,t,n){const r={};return p(t.objectStoreNames,0).forEach((e=>{const t=n.objectStore(e);let s=t.keyPath;const i=Jt(Zt(s),s||"",!1,!1,!!t.autoIncrement,s&&"string"!=typeof s,!0),o=[];for(let e=0;e<t.indexNames.length;++e){const n=t.index(t.indexNames[e]);s=n.keyPath;var a=Jt(n.name,s,!!n.unique,!!n.multiEntry,!1,s&&"string"!=typeof s,!1);o.push(a)}r[e]=en(e,i,o)})),r}function vn({_novip:t},n,r){const s=r.db.objectStoreNames;for(let e=0;e<s.length;++e){const i=s[e],o=r.objectStore(i);t._hasGetAll="getAll"in o;for(let e=0;e<o.indexNames.length;++e){const t=o.indexNames[e],r=o.index(t).keyPath,s="string"==typeof r?r:"["+p(r).join("+")+"]";if(n[i]){const e=n[i].idxByName[s];e&&(e.name=t,delete n[i].idxByName[s],n[i].idxByName[t]=e)}}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&e.WorkerGlobalScope&&e instanceof e.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(t._hasGetAll=!1)}class gn{_parseStoresSpec(e,r){t(e).forEach((t=>{if(null!==e[t]){var s=e[t].split(",").map(((e,t)=>{const r=(e=e.trim()).replace(/([&*]|\+\+)/g,""),s=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return Jt(r,s||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),n(s),0===t)})),i=s.shift();if(i.multi)throw new X.Schema("Primary key cannot be multi-valued");s.forEach((e=>{if(e.auto)throw new X.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new X.Schema("Index must have a name and cannot be an empty string")})),r[t]=en(t,i,s)}}))}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?r(this._cfg.storesSource,e):e;const s=n._versions,i={};let o={};return s.forEach((e=>{r(i,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(i,o)})),n._dbSchema=o,cn(n,[n._allTables,n,n.Transaction.prototype]),ln(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],t(o),o),n._storeNames=t(o),this}upgrade(e){return this._cfg.contentUpgrade=ue(this._cfg.contentUpgrade||ee,e),this}}function bn(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Un("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function _n(e){return e&&"function"==typeof e.databases}function wn(e){return Je((function(){return Ke.letThrough=!0,e()}))}function xn(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise((function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()})).finally((function(){return clearInterval(e)})):Promise.resolve()}function kn(e){const n=e._state,{indexedDB:r}=e._deps;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then((()=>n.dbOpenError?ht(n.dbOpenError):e));R&&(n.openCanceller._stackHolder=q()),n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;const s=n.openCanceller;function i(){if(n.openCanceller!==s)throw new X.DatabaseClosed("db.open() was cancelled")}let o=n.dbReadyResolve,a=null,u=!1;return Ae.race([s,("undefined"==typeof navigator?Ae.resolve():xn()).then((()=>new Ae(((s,o)=>{if(i(),!r)throw new X.MissingAPI;const l=e.name,c=n.autoSchema?r.open(l):r.open(l,Math.round(10*e.verno));if(!c)throw new X.MissingAPI;c.onerror=Gt(o),c.onblocked=We(e._fireOnBlocked),c.onupgradeneeded=We((t=>{if(a=c.transaction,n.autoSchema&&!e._options.allowEmptyDB){c.onerror=Ht,a.abort(),c.result.close();const e=r.deleteDatabase(l);e.onsuccess=e.onerror=We((()=>{o(new X.NoSuchDatabase(`Database ${l} doesnt exist`))}))}else{a.onerror=Gt(o);var s=t.oldVersion>Math.pow(2,62)?0:t.oldVersion;u=s<1,e._novip.idbdb=c.result,dn(e,s/10,a,o)}}),o),c.onsuccess=We((()=>{a=null;const r=e._novip.idbdb=c.result,i=p(r.objectStoreNames);if(i.length>0)try{const s=r.transaction(1===(o=i).length?o[0]:o,"readonly");n.autoSchema?function({_novip:e},n,r){e.verno=n.version/10;const s=e._dbSchema=mn(0,n,r);e._storeNames=p(n.objectStoreNames,0),ln(e,[e._allTables],t(s),s)}(e,r,s):(vn(e,e._dbSchema,s),function(e,t){const n=fn(mn(0,e.idbdb,t),e._dbSchema);return!(n.add.length||n.change.some((e=>e.add.length||e.change.length)))}(e,s)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),un(e,s)}catch(e){}var o;yt.push(e),r.onversionchange=We((t=>{n.vcFired=!0,e.on("versionchange").fire(t)})),r.onclose=We((t=>{e.on("close").fire(t)})),u&&function({indexedDB:e,IDBKeyRange:t},n){!_n(e)&&"__dbnames"!==n&&bn(e,t).put({name:n}).catch(ee)}(e._deps,l),s()}),o)}))))]).then((()=>(i(),n.onReadyBeingFired=[],Ae.resolve(wn((()=>e.on.ready.fire(e.vip)))).then((function t(){if(n.onReadyBeingFired.length>0){let r=n.onReadyBeingFired.reduce(ue,ee);return n.onReadyBeingFired=[],Ae.resolve(wn((()=>r(e.vip)))).then(t)}}))))).finally((()=>{n.onReadyBeingFired=null,n.isBeingOpened=!1})).then((()=>e)).catch((t=>{n.dbOpenError=t;try{a&&a.abort()}catch(e){}return s===n.openCanceller&&e._close(),ht(t)})).finally((()=>{n.openComplete=!0,o()}))}function En(e){var t=t=>e.next(t),r=i(t),s=i((t=>e.throw(t)));function i(e){return t=>{var i=e(t),o=i.value;return i.done?o:o&&"function"==typeof o.then?o.then(r,s):n(o)?Promise.all(o).then(r,s):r(o)}}return i(t)()}function Pn(e,t,n){var r=arguments.length;if(r<2)throw new X.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];n=s.pop();var i=k(s);return[e,i,n]}function Kn(e,t,n,r,s){return Ae.resolve().then((()=>{const i=Ke.transless||Ke,o=e._createTransaction(t,n,e._dbSchema,r),a={trans:o,transless:i};if(r)o.idbtrans=r.idbtrans;else try{o.create(),e._state.PR1398_maxLoop=3}catch(r){return r.name===H.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>Kn(e,t,n,null,s)))):ht(r)}const u=T(s);let l;u&&Ze();const c=Ae.follow((()=>{if(l=s.call(o,o),l)if(u){var e=et.bind(null,null);l.then(e,e)}else"function"==typeof l.next&&"function"==typeof l.throw&&(l=En(l))}),a);return(l&&"function"==typeof l.then?Ae.resolve(l).then((e=>o.active?e:ht(new X.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn")))):c.then((()=>l))).then((e=>(r&&o._resolve(),o._completion.then((()=>e))))).catch((e=>(o._reject(e),ht(e))))}))}function On(e,t,r){const s=n(e)?e.slice():[e];for(let e=0;e<r;++e)s.push(t);return s}const Sn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const n=e.table(t),{schema:r}=n,s={},i=[];function o(e,t,n){const r=on(e),a=s[r]=s[r]||[],u=null==e?0:"string"==typeof e?1:e.length,l=t>0,c={...n,isVirtual:l,keyTail:t,keyLength:u,extractKey:nn(e),unique:!l&&n.unique};if(a.push(c),c.isPrimaryKey||i.push(c),u>1){o(2===u?e[0]:e.slice(0,u-1),t+1,n)}return a.sort(((e,t)=>e.keyTail-t.keyTail)),c}const a=o(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[a];for(const e of r.indexes)o(e.keyPath,0,e);function u(t){const n=t.query.index;return n.isVirtual?{...t,query:{index:n,range:(r=t.query.range,s=n.keyTail,{type:1===r.type?2:r.type,lower:On(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,s),lowerOpen:!0,upper:On(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,s),upperOpen:!0})}}:t;var r,s}const l={...n,schema:{...r,primaryKey:a,indexes:i,getIndexByKeyPath:function(e){const t=s[on(e)];return t&&t[0]}},count:e=>n.count(u(e)),query:e=>n.query(u(e)),openCursor(t){const{keyTail:r,isVirtual:s,keyLength:i}=t.query.index;if(!s)return n.openCursor(t);return n.openCursor(u(t)).then((n=>n&&function(n){const s=Object.create(n,{continue:{value:function(s){null!=s?n.continue(On(s,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,s){n.continuePrimaryKey(On(t,e.MAX_KEY,r),s)}},primaryKey:{get:()=>n.primaryKey},key:{get(){const e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>n.value}});return s}(n)))}};return l}}}};function Cn(e,n,r,s){return r=r||{},s=s||"",t(e).forEach((t=>{if(o(n,t)){var i=e[t],a=n[t];if("object"==typeof i&&"object"==typeof a&&i&&a){const e=A(i);e!==A(a)?r[s+t]=n[t]:"Object"===e?Cn(i,a,r,s+t+"."):i!==a&&(r[s+t]=n[t])}else i!==a&&(r[s+t]=n[t])}else r[s+t]=void 0})),t(n).forEach((t=>{o(e,t)||(r[s+t]=n[t])})),r}const An={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema,s={...n,mutate(e){const s=Ke.trans,{deleting:i,creating:a,updating:u}=s.table(t).hook;switch(e.type){case"add":if(a.fire===ee)break;return s._promise("readwrite",(()=>l(e)),!0);case"put":if(a.fire===ee&&u.fire===ee)break;return s._promise("readwrite",(()=>l(e)),!0);case"delete":if(i.fire===ee)break;return s._promise("readwrite",(()=>l(e)),!0);case"deleteRange":if(i.fire===ee)break;return s._promise("readwrite",(()=>function(e){return c(e.trans,e.range,1e4)}(e)),!0)}return n.mutate(e);function l(e){const t=Ke.trans,s=e.keys||function(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}(r,e);if(!s)throw new Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:s}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),function(e,t,n){return"add"===t.type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})}(n,e,s).then((l=>{const c=s.map(((n,s)=>{const c=l[s],h={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(h,n,c,t);else if("add"===e.type||void 0===c){const i=a.fire.call(h,n,e.values[s],t);null==n&&null!=i&&(n=i,e.keys[s]=n,r.outbound||_(e.values[s],r.keyPath,n))}else{const r=Cn(c,e.values[s]),i=u.fire.call(h,r,n,c,t);if(i){const t=e.values[s];Object.keys(i).forEach((e=>{o(t,e)?t[e]=i[e]:_(t,e,i[e])}))}}return h}));return n.mutate(e).then((({failures:t,results:n,numFailures:r,lastResult:i})=>{for(let r=0;r<s.length;++r){const i=n?n[r]:s[r],o=c[r];null==i?o.onerror&&o.onerror(t[r]):o.onsuccess&&o.onsuccess("put"===e.type&&l[r]?e.values[r]:i)}return{failures:t,results:n,numFailures:r,lastResult:i}})).catch((e=>(c.forEach((t=>t.onerror&&t.onerror(e))),Promise.reject(e))))}))}function c(e,t,s){return n.query({trans:e,values:!1,query:{index:r,range:t},limit:s}).then((({result:n})=>l({type:"delete",keys:n,trans:e}).then((r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<s?{failures:[],numFailures:0,lastResult:void 0}:c(e,{...t,lower:n[n.length-1],lowerOpen:!0},s)))))}}};return s}})};function jn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;const r=[];for(let s=0,i=0;s<t.keys.length&&i<e.length;++s)0===Et(t.keys[s],e[i])&&(r.push(n?O(t.values[s]):t.values[s]),++i);return r.length===e.length?r:null}catch(e){return null}}const Dn={stack:"dbcore",level:-1,create:e=>({table:t=>{const n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);const t=jn(e.keys,e.trans._cache,"clone"===e.cache);return t?Ae.resolve(t):n.getMany(e).then((t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?O(t):t},t)))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function In(e){return!("from"in e)}const Bn=function(e,t){if(!this){const t=new Bn;return e&&"d"in e&&r(t,e),t}r(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function Tn(e,t,n){const s=Et(t,n);if(isNaN(s))return;if(s>0)throw RangeError();if(In(e))return r(e,{from:t,to:n,d:1});const i=e.l,o=e.r;if(Et(n,e.from)<0)return i?Tn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Nn(e);if(Et(t,e.to)>0)return o?Tn(o,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Nn(e);Et(t,e.from)<0&&(e.from=t,e.l=null,e.d=o?o.d+1:1),Et(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const a=!e.r;i&&!e.l&&Rn(e,i),o&&a&&Rn(e,o)}function Rn(e,t){In(t)||function e(t,{from:n,to:r,l:s,r:i}){Tn(t,n,r),s&&e(t,s),i&&e(t,i)}(e,t)}function Fn(e,t){const n=Mn(t);let r=n.next();if(r.done)return!1;let s=r.value;const i=Mn(e);let o=i.next(s.from),a=o.value;for(;!r.done&&!o.done;){if(Et(a.from,s.to)<=0&&Et(a.to,s.from)>=0)return!0;Et(s.from,a.from)<0?s=(r=n.next(a.from)).value:a=(o=i.next(s.from)).value}return!1}function Mn(e){let t=In(e)?null:{s:0,n:e};return{next(e){const n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&Et(e,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||Et(e,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Nn(e){var t,n;const r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),s=r>1?"r":r<-1?"l":"";if(s){const t="r"===s?"l":"r",n={...e},r=e[s];e.from=r.from,e.to=r.to,e[s]=r[s],n[s]=r[t],e[t]=n,n.d=qn(n)}e.d=qn(e)}function qn({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}a(Bn.prototype,{add(e){return Rn(this,e),this},addKey(e){return Tn(this,e,e),this},addKeys(e){return e.forEach((e=>Tn(this,e,e))),this},[j](){return Mn(this)}});const $n={stack:"dbcore",level:0,create:e=>{const r=e.schema.name,s=new Bn(e.MIN_KEY,e.MAX_KEY);return{...e,table:i=>{const o=e.table(i),{schema:a}=o,{primaryKey:u}=a,{extractKey:l,outbound:c}=u,h={...o,mutate:e=>{const t=e.trans,u=t.mutatedParts||(t.mutatedParts={}),l=e=>{const t=`idb://${r}/${i}/${e}`;return u[t]||(u[t]=new Bn)},c=l(""),h=l(":dels"),{type:d}=e;let[f,p]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[];const y=e.trans._cache;return o.mutate(e).then((e=>{if(n(f)){"delete"!==d&&(f=e.results),c.addKeys(f);const t=jn(f,y);t||"add"===d||h.addKeys(f),(t||p)&&function(e,t,r,s){function i(t){const i=e(t.name||"");function o(e){return null!=e?t.extractKey(e):null}const a=e=>t.multiEntry&&n(e)?e.forEach((e=>i.addKey(e))):i.addKey(e);(r||s).forEach(((e,t)=>{const n=r&&o(r[t]),i=s&&o(s[t]);0!==Et(n,i)&&(null!=n&&a(n),null!=i&&a(i))}))}t.indexes.forEach(i)}(l,a,t,p)}else if(f){const e={from:f.lower,to:f.upper};h.add(e),c.add(e)}else c.add(s),h.add(s),a.indexes.forEach((e=>l(e.name).add(s)));return e}))}},d=({query:{index:t,range:n}})=>{var r,s;return[t,new Bn(null!==(r=n.lower)&&void 0!==r?r:e.MIN_KEY,null!==(s=n.upper)&&void 0!==s?s:e.MAX_KEY)]},f={get:e=>[u,new Bn(e.key)],getMany:e=>[u,(new Bn).addKeys(e.keys)],count:d,query:d,openCursor:d};return t(f).forEach((e=>{h[e]=function(t){const{subscr:n}=Ke;if(n){const a=e=>{const t=`idb://${r}/${i}/${e}`;return n[t]||(n[t]=new Bn)},u=a(""),h=a(":dels"),[d,p]=f[e](t);if(a(d.name||"").add(p),!d.isPrimaryKey){if("count"!==e){const n="query"===e&&c&&t.values&&o.query({...t,values:!1});return o[e].apply(this,arguments).then((r=>{if("query"===e){if(c&&t.values)return n.then((({result:e})=>(u.addKeys(e),r)));const e=t.values?r.result.map(l):r.result;t.values?u.addKeys(e):h.addKeys(e)}else if("openCursor"===e){const e=r,n=t.values;return e&&Object.create(e,{key:{get:()=>(h.addKey(e.primaryKey),e.key)},primaryKey:{get(){const t=e.primaryKey;return h.addKey(t),t}},value:{get:()=>(n&&u.addKey(e.primaryKey),e.value)}})}return r}))}h.add(s)}}return o[e].apply(this,arguments)}})),h}}}};class Un{constructor(e,t){this._middlewares={},this.verno=0;const n=Un.dependencies;this._options=t={addons:Un.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:r}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ee,dbReadyPromise:null,cancelOpen:ee,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new Ae((e=>{s.dbReadyResolve=e})),s.openCanceller=new Ae(((e,t)=>{s.cancelOpen=t})),this._state=s,this.name=e,this.on=St(this,"populate","blocked","versionchange","close",{ready:[ue,ee]}),this.on.ready.subscribe=y(this.on.ready.subscribe,(e=>(t,n)=>{Un.vip((()=>{const r=this._state;if(r.openComplete)r.dbOpenError||Ae.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);const r=this;n||e((function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)}))}}))})),this.Collection=(i=this,Ct(Ft.prototype,(function(e,t){this.db=i;let n=wt,r=null;if(t)try{n=t()}catch(e){r=e}const s=e._ctx,o=s.table,a=o.hook.reading.fire;this._ctx={table:o,index:s.index,isPrimKey:!s.index||o.schema.primKey.keyPath&&s.index===o.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:s.or,valueMapper:a!==te?a:null}}))),this.Table=function(e){return Ct(Ot.prototype,(function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:St(null,{creating:[se,ee],reading:[ne,te],updating:[oe,ee],deleting:[ie,ee]})}))}(this),this.Transaction=function(e){return Ct(Xt.prototype,(function(t,n,r,s,i){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=s,this.idbtrans=null,this.on=St(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new Ae(((e,t)=>{this._resolve=e,this._reject=t})),this._completion.then((()=>{this.active=!1,this.on.complete.fire()}),(e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),ht(e)}))}))}(this),this.Version=function(e){return Ct(gn.prototype,(function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}}))}(this),this.WhereClause=function(e){return Ct(zt.prototype,(function(t,n,r){if(this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r},this._cmp=this._ascending=Et,this._descending=(e,t)=>Et(t,e),this._max=(e,t)=>Et(e,t)>0?e:t,this._min=(e,t)=>Et(e,t)<0?e:t,this._IDBKeyRange=e._deps.IDBKeyRange,!this._IDBKeyRange)throw new X.MissingAPI}))}(this),this.on("versionchange",(e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()})),this.on("blocked",(e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)})),this._maxKey=tn(t.IDBKeyRange),this._createTransaction=(e,t,n,r)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),yt.filter((e=>e.name===this.name&&e!==this&&!e._state.vcFired)).map((t=>t.on("versionchange").fire(e)))},this.use(Sn),this.use(An),this.use($n),this.use(Dn),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach((e=>e(this)))}version(e){if(isNaN(e)||e<.1)throw new X.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new X.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const t=this._versions;var n=t.filter((t=>t._cfg.version===e))[0];return n||(n=new this.Version(e),t.push(n),t.sort(hn),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||Ke.letThrough||this._vip)?e():new Ae(((e,t)=>{if(this._state.openComplete)return t(new X.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new X.DatabaseClosed);this.open().catch(ee)}this._state.dbReadyPromise.then(e,t)})).then(e)}use({stack:e,create:t,level:n,name:r}){r&&this.unuse({stack:e,name:r});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:t,level:null==n?10:n,name:r}),s.sort(((e,t)=>e.level-t.level)),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter((e=>n?e.create!==n:!!t&&e.name!==t))),this}open(){return kn(this)}_close(){const e=this._state,t=yt.indexOf(this);if(t>=0&&yt.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new Ae((t=>{e.dbReadyResolve=t})),e.openCanceller=new Ae(((t,n)=>{e.cancelOpen=n}))}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new X.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,t=this._state;return new Ae(((n,r)=>{const s=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=We((()=>{!function({indexedDB:e,IDBKeyRange:t},n){!_n(e)&&"__dbnames"!==n&&bn(e,t).delete(n).catch(ee)}(this._deps,this.name),n()})),e.onerror=Gt(r),e.onblocked=this._fireOnBlocked};if(e)throw new X.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(s):s()}))}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){const e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return t(this._allTables).map((e=>this._allTables[e]))}transaction(){const e=Pn.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r=Ke.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);const s=-1!==e.indexOf("?");let i,o;e=e.replace("!","").replace("?","");try{if(o=t.map((e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t})),"r"==e||"readonly"===e)i="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new X.InvalidArgument("Invalid transaction mode: "+e);i="readwrite"}if(r){if("readonly"===r.mode&&"readwrite"===i){if(!s)throw new X.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&o.forEach((e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!s)throw new X.SubTransaction("Table "+e+" not included in parent transaction.");r=null}})),s&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,((t,n)=>{n(e)})):ht(e)}const a=Kn.bind(null,this,i,o,r,n);return r?r._promise(i,a,"lock"):Ke.trans?ot(Ke.transless,(()=>this._whenReady(a))):this._whenReady(a)}table(e){if(!o(this._allTables,e))throw new X.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Ln="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class Vn{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[Ln](){return this}}function Wn(e,n){return t(n).forEach((t=>{Rn(e[t]||(e[t]=new Bn),n[t])})),e}function Yn(e){return new Vn((n=>{const r=T(e);let s=!1,i={},o={};const a={get closed(){return s},unsubscribe:()=>{s=!0,Qt.storagemutated.unsubscribe(h)}};n.start&&n.start(a);let u=!1,l=!1;function c(){return t(o).some((e=>i[e]&&Fn(i[e],o[e])))}const h=e=>{Wn(i,e),c()&&d()},d=()=>{if(u||s)return;i={};const t={},f=function(t){r&&Ze();const n=()=>Je(e,{subscr:t,trans:null}),s=Ke.trans?ot(Ke.transless,n):n();return r&&s.then(et,et),s}(t);l||(Qt("storagemutated",h),l=!0),u=!0,Promise.resolve(f).then((e=>{u=!1,s||(c()?d():(i={},o=t,n.next&&n.next(e)))}),(e=>{["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||(u=!1,n.error&&n.error(e),a.unsubscribe())}))};return d(),a}))}let zn;try{zn={indexedDB:e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,IDBKeyRange:e.IDBKeyRange||e.webkitIDBKeyRange}}catch(e){zn={indexedDB:null,IDBKeyRange:null}}const Gn=Un;function Hn(e){let t=Qn;try{Qn=!0,Qt.storagemutated.fire(e)}finally{Qn=t}}a(Gn,{...Z,delete:e=>new Gn(e,{addons:[]}).delete(),exists:e=>new Gn(e,{addons:[]}).open().then((e=>(e.close(),!0))).catch("NoSuchDatabaseError",(()=>!1)),getDatabaseNames(e){try{return function({indexedDB:e,IDBKeyRange:t}){return _n(e)?Promise.resolve(e.databases()).then((e=>e.map((e=>e.name)).filter((e=>"__dbnames"!==e)))):bn(e,t).toCollection().primaryKeys()}(Gn.dependencies).then(e)}catch(e){return ht(new X.MissingAPI)}},defineClass:()=>function(e){r(this,e)},ignoreTransaction:e=>Ke.trans?ot(Ke.transless,e):e(),vip:wn,async:function(e){return function(){try{var t=En(e.apply(this,arguments));return t&&"function"==typeof t.then?t:Ae.resolve(t)}catch(e){return ht(e)}}},spawn:function(e,t,n){try{var r=En(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Ae.resolve(r)}catch(e){return ht(e)}},currentTransaction:{get:()=>Ke.trans||null},waitFor:function(e,t){const n=Ae.resolve("function"==typeof e?Gn.ignoreTransaction(e):e).timeout(t||6e4);return Ke.trans?Ke.trans.waitFor(n):n},Promise:Ae,debug:{get:()=>R,set:e=>{F(e,"dexie"===e?()=>!0:bt)}},derive:c,extend:r,props:a,override:y,Events:St,on:Qt,liveQuery:Yn,extendObservabilitySet:Wn,getByKeyPath:b,setByKeyPath:_,delByKeyPath:function(e,t){"string"==typeof t?_(e,t,void 0):"length"in t&&[].map.call(t,(function(t){_(e,t,void 0)}))},shallowClone:w,deepClone:O,getObjectDiff:Cn,cmp:Et,asap:v,minKey:-(1/0),addons:[],connections:yt,errnames:H,dependencies:zn,semVer:"4.0.1-alpha.7",version:"4.0.1-alpha.7".split(".").map((e=>parseInt(e))).reduce(((e,t,n)=>e+t/Math.pow(10,2*n)))}),Gn.maxKey=tn(Gn.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(Qt("storagemutated",(e=>{if(!Qn){let t;mt?(t=document.createEvent("CustomEvent"),t.initCustomEvent("x-storagemutated-1",!0,!0,e)):t=new CustomEvent("x-storagemutated-1",{detail:e}),Qn=!0,dispatchEvent(t),Qn=!1}})),addEventListener("x-storagemutated-1",(({detail:e})=>{Qn||Hn(e)})));let Qn=!1;if("undefined"!=typeof BroadcastChannel){const e=new BroadcastChannel("x-storagemutated-1");"function"==typeof e.unref&&e.unref(),Qt("storagemutated",(t=>{Qn||e.postMessage(t)})),e.onmessage=e=>{e.data&&Hn(e.data)}}else if("undefined"!=typeof self&&"undefined"!=typeof navigator){Qt("storagemutated",(e=>{try{Qn||("undefined"!=typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach((t=>t.postMessage({type:"x-storagemutated-1",changedParts:e}))))}catch(e){}})),"undefined"!=typeof addEventListener&&addEventListener("storage",(e=>{if("x-storagemutated-1"===e.key){const t=JSON.parse(e.newValue);t&&Hn(t.changedParts)}}));const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",(function({data:e}){e&&"x-storagemutated-1"===e.type&&Hn(e.changedParts)}))}Ae.rejectionMapper=function(e,t){if(!e||e instanceof W||e instanceof TypeError||e instanceof SyntaxError||!e.name||!J[e.name])return e;var n=new J[e.name](t||e.message,e);return"stack"in e&&l(n,"stack",{get:function(){return this.inner.stack}}),n},F(R,bt);export{Un as Dexie,kt as Entity,Bn as RangeSet,Et as cmp,Un as default,Yn as liveQuery,Rn as mergeRanges,Fn as rangesOverlap};
1
+ const e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,t=Object.keys,n=Array.isArray;function r(e,n){return"object"!=typeof n||t(n).forEach((function(t){e[t]=n[t]})),e}"undefined"==typeof Promise||e.Promise||(e.Promise=Promise);const s=Object.getPrototypeOf,i={}.hasOwnProperty;function o(e,t){return i.call(e,t)}function a(e,n){"function"==typeof n&&(n=n(s(e))),("undefined"==typeof Reflect?t:Reflect.ownKeys)(n).forEach((t=>{l(e,t,n[t])}))}const u=Object.defineProperty;function l(e,t,n,s){u(e,t,r(n&&o(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},s))}function c(e){return{from:function(t){return e.prototype=Object.create(t.prototype),l(e.prototype,"constructor",e),{extend:a.bind(null,e.prototype)}}}}const h=Object.getOwnPropertyDescriptor;function d(e,t){let n;return h(e,t)||(n=s(e))&&d(n,t)}const f=[].slice;function p(e,t,n){return f.call(e,t,n)}function y(e,t){return t(e)}function m(e){if(!e)throw new Error("Assertion Failed")}function v(t){e.setImmediate?setImmediate(t):setTimeout(t,0)}function g(e,t){return e.reduce(((e,n,r)=>{var s=t(n,r);return s&&(e[s[0]]=s[1]),e}),{})}function b(e,t){if(o(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,s=t.length;r<s;++r){var i=b(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var u=e[t.substr(0,a)];return void 0===u?void 0:b(u,t.substr(a+1))}}function _(e,t,r){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){m("string"!=typeof r&&"length"in r);for(var s=0,i=t.length;s<i;++s)_(e,t[s],r[s])}else{var a=t.indexOf(".");if(-1!==a){var u=t.substr(0,a),l=t.substr(a+1);if(""===l)void 0===r?n(e)&&!isNaN(parseInt(u))?e.splice(u,1):delete e[u]:e[u]=r;else{var c=e[u];c&&o(e,u)||(c=e[u]={}),_(c,l,r)}}else void 0===r?n(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=r}}function w(e){var t={};for(var n in e)o(e,n)&&(t[n]=e[n]);return t}const x=[].concat;function k(e){return x.apply([],e)}const E="Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(k([8,16,32,64].map((e=>["Int","Uint","Float"].map((t=>t+e+"Array")))))).filter((t=>e[t])),P=E.map((t=>e[t]));g(E,(e=>[e,!0]));let K=null;function O(e){K="undefined"!=typeof WeakMap&&new WeakMap;const t=S(e);return K=null,t}function S(e){if(!e||"object"!=typeof e)return e;let t=K&&K.get(e);if(t)return t;if(n(e)){t=[],K&&K.set(e,t);for(var r=0,i=e.length;r<i;++r)t.push(S(e[r]))}else if(P.indexOf(e.constructor)>=0)t=e;else{const n=s(e);for(var a in t=n===Object.prototype?{}:Object.create(n),K&&K.set(e,t),e)o(e,a)&&(t[a]=S(e[a]))}return t}const{toString:C}={};function A(e){return C.call(e).slice(8,-1)}const j="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",D="symbol"==typeof j?function(e){var t;return null!=e&&(t=e[j])&&t.apply(e)}:function(){return null},I={};function B(e){var t,r,s,i;if(1===arguments.length){if(n(e))return e.slice();if(this===I&&"string"==typeof e)return[e];if(i=D(e)){for(r=[];!(s=i.next()).done;)r.push(s.value);return r}if(null==e)return[e];if("number"==typeof(t=e.length)){for(r=new Array(t);t--;)r[t]=e[t];return r}return[e]}for(t=arguments.length,r=new Array(t);t--;)r[t]=arguments[t];return r}const T="undefined"!=typeof Symbol?e=>"AsyncFunction"===e[Symbol.toStringTag]:()=>!1;var R="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function F(e,t){R=e,M=t}var M=()=>!0;const N=!new Error("").stack;function q(){if(N)try{throw q.arguments,new Error}catch(e){return e}return new Error}function $(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(M).map((e=>"\n"+e)).join("")):""}var U=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],L=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(U),V={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 W(e,t){this._e=q(),this.name=e,this.message=t}function Y(e,t){return e+". Errors: "+Object.keys(t).map((e=>t[e].toString())).filter(((e,t,n)=>n.indexOf(e)===t)).join("\n")}function z(e,t,n,r){this._e=q(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=Y(e,t)}function G(e,t){this._e=q(),this.name="BulkError",this.failures=Object.keys(t).map((e=>t[e])),this.failuresByPos=t,this.message=Y(e,this.failures)}c(W).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+$(this._e,2))}},toString:function(){return this.name+": "+this.message}}),c(z).from(W),c(G).from(W);var H=L.reduce(((e,t)=>(e[t]=t+"Error",e)),{});const Q=W;var X=L.reduce(((e,t)=>{var n=t+"Error";function r(e,r){this._e=q(),this.name=n,e?"string"==typeof e?(this.message=`${e}${r?"\n "+r:""}`,this.inner=r||null):"object"==typeof e&&(this.message=`${e.name} ${e.message}`,this.inner=e):(this.message=V[t]||n,this.inner=null)}return c(r).from(Q),e[t]=r,e}),{});X.Syntax=SyntaxError,X.Type=TypeError,X.Range=RangeError;var J=U.reduce(((e,t)=>(e[t+"Error"]=X[t],e)),{});var Z=L.reduce(((e,t)=>(-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=X[t]),e)),{});function ee(){}function te(e){return e}function ne(e,t){return null==e||e===te?t:function(n){return t(e(n))}}function re(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function se(e,t){return e===ee?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?re(r,this.onsuccess):r),s&&(this.onerror=this.onerror?re(s,this.onerror):s),void 0!==i?i:n}}function ie(e,t){return e===ee?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?re(n,this.onsuccess):n),r&&(this.onerror=this.onerror?re(r,this.onerror):r)}}function oe(e,t){return e===ee?t:function(n){var s=e.apply(this,arguments);r(n,s);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?re(i,this.onsuccess):i),o&&(this.onerror=this.onerror?re(o,this.onerror):o),void 0===s?void 0===a?void 0:a:r(s,a)}}function ae(e,t){return e===ee?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ue(e,t){return e===ee?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,s=arguments.length,i=new Array(s);s--;)i[s]=arguments[s];return n.then((function(){return t.apply(r,i)}))}return t.apply(this,arguments)}}Z.ModifyError=z,Z.DexieError=W,Z.BulkError=G;var le={};const[ce,he,de]="undefined"==typeof Promise?[]:(()=>{let e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,s(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,s(t),e]})(),fe=he&&he.then,pe=ce&&ce.constructor,ye=!!de;var me=!1,ve=de?()=>{de.then(qe)}:e.setImmediate?setImmediate.bind(null,qe):e.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver((()=>{qe(),e=null})).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(qe,0)},ge=function(e,t){Oe.push([e,t]),_e&&(ve(),_e=!1)},be=!0,_e=!0,we=[],xe=[],ke=null,Ee=te,Pe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ct,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach((e=>{try{ct(e[0],e[1])}catch(e){}}))}},Ke=Pe,Oe=[],Se=0,Ce=[];function Ae(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ee,this._lib=!1;var t=this._PSD=Ke;if(R&&(this._stackHolder=q(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==le)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Be(this,this._value))}this._state=null,this._value=null,++t.ref,Ie(this,e)}const je={get:function(){var e=Ke,t=Qe;function n(n,r){var s=!e.global&&(e!==Ke||t!==Qe);const i=s&&!et();var o=new Ae(((t,o)=>{Re(this,new De(ut(n,e,s,i),ut(r,e,s,i),t,o,e))}));return R&&Ne(o,this),o}return n.prototype=le,n},set:function(e){l(this,"then",e&&e.prototype===le?je:{get:function(){return e},set:je.set})}};function De(e,t,n,r,s){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=s}function Ie(e,t){try{t((t=>{if(null===e._state){if(t===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&$e();t&&"function"==typeof t.then?Ie(e,((e,n)=>{t instanceof Ae?t._then(e,n):t.then(e,n)})):(e._state=!0,e._value=t,Te(e)),n&&Ue()}}),Be.bind(null,e))}catch(t){Be(e,t)}}function Be(e,t){if(xe.push(t),null===e._state){var n=e._lib&&$e();t=Ee(t),e._state=!1,e._value=t,R&&null!==t&&"object"==typeof t&&!t._promise&&function(e,t,n){try{e.apply(null,n)}catch(e){t&&t(e)}}((()=>{var n=d(t,"stack");t._promise=e,l(t,"stack",{get:()=>me?n&&(n.get?n.get.apply(t):n.value):e.stack})})),function(e){we.some((t=>t._value===e._value))||we.push(e)}(e),Te(e),n&&Ue()}}function Te(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Re(e,t[n]);var s=e._PSD;--s.ref||s.finalize(),0===Se&&(++Se,ge((()=>{0==--Se&&Le()}),[]))}function Re(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,ge(Fe,[n,e,t])}else e._listeners.push(t)}function Fe(e,t,n){try{ke=t;var r,s=t._value;t._state?r=e(s):(xe.length&&(xe=[]),r=e(s),-1===xe.indexOf(s)&&function(e){var t=we.length;for(;t;)if(we[--t]._value===e._value)return void we.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 Me(e,t,n){if(t.length===n)return t;var r="";if(!1===e._state){var s,i,o=e._value;null!=o?(s=o.name||"Error",i=o.message||o,r=$(o,0)):(s=o,i=""),t.push(s+(i?": "+i:"")+r)}return R&&((r=$(e._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),e._prev&&Me(e._prev,t,n)),t}function Ne(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function qe(){$e()&&Ue()}function $e(){var e=be;return be=!1,_e=!1,e}function Ue(){var e,t,n;do{for(;Oe.length>0;)for(e=Oe,Oe=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(Oe.length>0);be=!0,_e=!0}function Le(){var e=we;we=[],e.forEach((e=>{e._PSD.onunhandled.call(null,e._value,e)}));for(var t=Ce.slice(0),n=t.length;n;)t[--n]()}function Ve(e){return new Ae(le,!1,e)}function We(e,t){var n=Ke;return function(){var r=$e(),s=Ke;try{return st(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{st(s,!1),r&&Ue()}}}a(Ae.prototype,{then:je,_then:function(e,t){Re(this,new De(null,null,e,t,Ke))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,(e=>e instanceof t?n(e):Ve(e))):this.then(null,(e=>e&&e.name===t?n(e):Ve(e)))},finally:function(e){return this.then((t=>(e(),t)),(t=>(e(),Ve(t))))},stack:{get:function(){if(this._stack)return this._stack;try{me=!0;var e=Me(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{me=!1}}},timeout:function(e,t){return e<1/0?new Ae(((n,r)=>{var s=setTimeout((()=>r(new X.Timeout(t))),e);this.then(n,r).finally(clearTimeout.bind(null,s))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&l(Ae.prototype,Symbol.toStringTag,"Dexie.Promise"),Pe.env=it(),a(Ae,{all:function(){var e=B.apply(null,arguments).map(tt);return new Ae((function(t,n){0===e.length&&t([]);var r=e.length;e.forEach(((s,i)=>Ae.resolve(s).then((n=>{e[i]=n,--r||t(e)}),n)))}))},resolve:e=>{if(e instanceof Ae)return e;if(e&&"function"==typeof e.then)return new Ae(((t,n)=>{e.then(t,n)}));var t=new Ae(le,!0,e);return Ne(t,ke),t},reject:Ve,race:function(){var e=B.apply(null,arguments).map(tt);return new Ae(((t,n)=>{e.map((e=>Ae.resolve(e).then(t,n)))}))},PSD:{get:()=>Ke,set:e=>Ke=e},totalEchoes:{get:()=>Qe},newPSD:Je,usePSD:ot,scheduler:{get:()=>ge,set:e=>{ge=e}},rejectionMapper:{get:()=>Ee,set:e=>{Ee=e}},follow:(e,t)=>new Ae(((n,r)=>Je(((t,n)=>{var r=Ke;r.unhandleds=[],r.onunhandled=n,r.finalize=re((function(){!function(e){function t(){e(),Ce.splice(Ce.indexOf(t),1)}Ce.push(t),++Se,ge((()=>{0==--Se&&Le()}),[])}((()=>{0===this.unhandleds.length?t():n(this.unhandleds[0])}))}),r.finalize),e()}),t,n,r)))}),pe&&(pe.allSettled&&l(Ae,"allSettled",(function(){const e=B.apply(null,arguments).map(tt);return new Ae((t=>{0===e.length&&t([]);let n=e.length;const r=new Array(n);e.forEach(((e,s)=>Ae.resolve(e).then((e=>r[s]={status:"fulfilled",value:e}),(e=>r[s]={status:"rejected",reason:e})).then((()=>--n||t(r)))))}))})),pe.any&&"undefined"!=typeof AggregateError&&l(Ae,"any",(function(){const e=B.apply(null,arguments).map(tt);return new Ae(((t,n)=>{0===e.length&&n(new AggregateError([]));let r=e.length;const s=new Array(r);e.forEach(((e,i)=>Ae.resolve(e).then((e=>t(e)),(e=>{s[i]=e,--r||n(new AggregateError(s))}))))}))})));const Ye={awaits:0,echoes:0,id:0};var ze=0,Ge=[],He=0,Qe=0,Xe=0;function Je(e,t,n,s){var i=Ke,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++Xe;var a=Pe.env;o.env=ye?{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:lt(a.nthen,o),gthen:lt(a.gthen,o)}:{},t&&r(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=ot(o,e,n,s);return 0===o.ref&&o.finalize(),u}function Ze(){return Ye.id||(Ye.id=++ze),++Ye.awaits,Ye.echoes+=100,Ye.id}function et(){return!!Ye.awaits&&(0==--Ye.awaits&&(Ye.id=0),Ye.echoes=100*Ye.awaits,!0)}function tt(e){return Ye.echoes&&e&&e.constructor===pe?(Ze(),e.then((e=>(et(),e)),(e=>(et(),ht(e))))):e}function nt(e){++Qe,Ye.echoes&&0!=--Ye.echoes||(Ye.echoes=Ye.id=0),Ge.push(Ke),st(e,!0)}function rt(){var e=Ge[Ge.length-1];Ge.pop(),st(e,!1)}function st(t,n){var r=Ke;if((n?!Ye.echoes||He++&&t===Ke:!He||--He&&t===Ke)||at(n?nt.bind(null,t):rt),t!==Ke&&(Ke=t,r===Pe&&(Pe.env=it()),ye)){var s=Pe.env.Promise,i=t.env;he.then=i.nthen,s.prototype.then=i.gthen,(r.global||t.global)&&(Object.defineProperty(e,"Promise",i.PromiseProp),s.all=i.all,s.race=i.race,s.resolve=i.resolve,s.reject=i.reject,i.allSettled&&(s.allSettled=i.allSettled),i.any&&(s.any=i.any))}}function it(){var t=e.Promise;return ye?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(e,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:he.then,gthen:t.prototype.then}:{}}function ot(e,t,n,r,s){var i=Ke;try{return st(e,!0),t(n,r,s)}finally{st(i,!1)}}function at(e){fe.call(ce,e)}function ut(e,t,n,r){return"function"!=typeof e?e:function(){var s=Ke;n&&Ze(),st(t,!0);try{return e.apply(this,arguments)}finally{st(s,!1),r&&at(et)}}}function lt(e,t){return function(n,r){return e.call(this,ut(n,t),ut(r,t))}}-1===(""+fe).indexOf("[native code]")&&(Ze=et=ee);function ct(t,n){var s;try{s=n.onuncatched(t)}catch(e){}if(!1!==s)try{var i,o={promise:n,reason:t};if(e.document&&document.createEvent?((i=document.createEvent("Event")).initEvent("unhandledrejection",!0,!0),r(i,o)):e.CustomEvent&&r(i=new CustomEvent("unhandledrejection",{detail:o}),o),i&&e.dispatchEvent&&(dispatchEvent(i),!e.PromiseRejectionEvent&&e.onunhandledrejection))try{e.onunhandledrejection(i)}catch(e){}R&&i&&!i.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch(e){}}var ht=Ae.reject;function dt(e,t,n,r){if(e.idbdb&&(e._state.openComplete||Ke.letThrough||e._vip)){var s=e._createTransaction(t,n,e._dbSchema);try{s.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===H.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>dt(e,t,n,r)))):ht(s)}return s._promise(t,((e,t)=>Je((()=>(Ke.trans=s,r(e,t,s)))))).then((e=>s._completion.then((()=>e))))}if(e._state.openComplete)return ht(new X.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return ht(new X.DatabaseClosed);e.open().catch(ee)}return e._state.dbReadyPromise.then((()=>dt(e,t,n,r)))}const ft=String.fromCharCode(65535),pt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",yt=[],mt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),vt=mt,gt=mt,bt=e=>!/(dexie\.js|dexie\.min\.js)/.test(e);function _t(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const wt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function xt(e){return"string"!=typeof e||/\./.test(e)?e=>e:t=>(void 0===t[e]&&e in t&&delete(t=O(t))[e],t)}function kt(){throw X.Type()}function Et(e,t){try{const n=Pt(e),r=Pt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(e,t){const n=e.length,r=t.length,s=n<r?n:r;for(let n=0;n<s;++n)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return n===r?0:n<r?-1:1}(Kt(e),Kt(t));case"Array":return function(e,t){const n=e.length,r=t.length,s=n<r?n:r;for(let n=0;n<s;++n){const r=Et(e[n],t[n]);if(0!==r)return r}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function Pt(e){const t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";const n=A(e);return"ArrayBuffer"===n?"binary":n}function Kt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class Ot{_trans(e,t,n){const r=this._tx||Ke.trans,s=this.name;function i(e,n,r){if(!r.schema[s])throw new X.NotFound("Table "+s+" not part of transaction");return t(r.idbtrans,r)}const o=$e();try{return r&&r.db===this.db?r===Ke.trans?r._promise(e,i,n):Je((()=>r._promise(e,i,n)),{trans:r,transless:Ke.transless||Ke}):dt(this.db,e,[this.name],i)}finally{o&&Ue()}}get(e,t){return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",(t=>this.core.get({trans:t,key:e}).then((e=>this.hook.reading.fire(e))))).then(t)}where(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(n(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const r=t(e);if(1===r.length)return this.where(r[0]).equals(e[r[0]]);const s=this.schema.indexes.concat(this.schema.primKey).filter((e=>e.compound&&r.every((t=>e.keyPath.indexOf(t)>=0))&&e.keyPath.every((e=>r.indexOf(e)>=0))))[0];if(s&&this.db._maxKey!==ft)return this.where(s.name).equals(s.keyPath.map((t=>e[t])));!s&&R&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${r.join("+")}]`);const{idxByName:i}=this.schema,o=this.db._deps.indexedDB;function a(e,t){return 0===o.cmp(e,t)}const[u,l]=r.reduce((([t,r],s)=>{const o=i[s],u=e[s];return[t||o,t||!o?_t(r,o&&o.multi?e=>{const t=b(e,s);return n(t)&&t.some((e=>a(u,e)))}:e=>a(u,b(e,s))):r]}),[null,null]);return u?this.where(u.name).equals(e[u.keyPath]).filter(l):s?this.filter(l):this.where(r).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,n(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){const{db:t,name:n}=this;this.schema.mappedClass=e,e.prototype instanceof kt&&(e=class extends e{get db(){return t}table(){return n}});const r=new Set;for(let t=e.prototype;t;t=s(t))Object.getOwnPropertyNames(t).forEach((e=>r.add(e)));const i=t=>{if(!t)return t;const n=Object.create(e.prototype);for(let e in t)if(!r.has(e))try{n[e]=t[e]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=i,this.hook("reading",i),e}defineClass(){return this.mapToClass((function(e){r(this,e)}))}add(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let s=e;return r&&n&&(s=xt(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[s]}))).then((e=>e.numFailures?Ae.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{_(e,r,t)}catch(e){}return t}))}update(e,r){if("object"!=typeof e||n(e))return this.where(":id").equals(e).modify(r);{const n=b(e,this.schema.primKey.keyPath);if(void 0===n)return ht(new X.InvalidArgument("Given object does not contain its primary key"));try{"function"!=typeof r?t(r).forEach((t=>{_(e,t,r[t])})):r(e,{value:e,primKey:n})}catch(e){}return this.where(":id").equals(n).modify(r)}}put(e,t){const{auto:n,keyPath:r}=this.schema.primKey;let s=e;return r&&n&&(s=xt(r)(e)),this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"put",values:[s],keys:null!=t?[t]:null}))).then((e=>e.numFailures?Ae.reject(e.failures[0]):e.lastResult)).then((t=>{if(r)try{_(e,r,t)}catch(e){}return t}))}delete(e){return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:[e]}))).then((e=>e.numFailures?Ae.reject(e.failures[0]):void 0))}clear(){return this._trans("readwrite",(e=>this.core.mutate({trans:e,type:"deleteRange",range:wt}))).then((e=>e.numFailures?Ae.reject(e.failures[0]):void 0))}bulkGet(e){return this._trans("readonly",(t=>this.core.getMany({keys:e,trans:t}).then((e=>e.map((e=>this.hook.reading.fire(e)))))))}bulkAdd(e,t,n){const r=Array.isArray(t)?t:void 0,s=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new X.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");const o=e.length;let a=i&&n?e.map(xt(i)):e;return this.core.mutate({trans:t,type:"add",keys:r,values:a,wantResults:s}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return s?t:n;throw new G(`${this.name}.bulkAdd(): ${e} of ${o} operations failed`,r)}))}))}bulkPut(e,t,n){const r=Array.isArray(t)?t:void 0,s=(n=n||(r?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(t=>{const{auto:n,keyPath:i}=this.schema.primKey;if(i&&r)throw new X.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");const o=e.length;let a=i&&n?e.map(xt(i)):e;return this.core.mutate({trans:t,type:"put",keys:r,values:a,wantResults:s}).then((({numFailures:e,results:t,lastResult:n,failures:r})=>{if(0===e)return s?t:n;throw new G(`${this.name}.bulkPut(): ${e} of ${o} operations failed`,r)}))}))}bulkUpdate(e){const t=this.core,n=e.map((e=>e.key)),r=e.map((e=>e.changes)),s=[];return this._trans("readwrite",(i=>t.getMany({trans:i,keys:n,cache:"clone"}).then((o=>{const a=[],u=[];e.forEach((({key:e,changes:t},n)=>{const r=o[n];if(r){for(const n of Object.keys(t)){const s=t[n];if(n===this.schema.primKey.keyPath){if(0!==Et(s,e))throw new X.Constraint("Cannot update primary key in bulkUpdate()")}else _(r,n,s)}s.push(n),a.push(e),u.push(r)}}));const l=a.length;return t.mutate({trans:i,type:"put",keys:a,values:u,updates:{keys:n,changeSpecs:r}}).then((({numFailures:e,failures:t})=>{if(0===e)return l;for(const e of Object.keys(t)){const n=s[Number(e)];if(null!=n){const r=t[e];delete t[e],t[n]=r}}throw new G(`${this.name}.bulkUpdate(): ${e} of ${l} operations failed`,t)}))}))))}bulkDelete(e){const t=e.length;return this._trans("readwrite",(t=>this.core.mutate({trans:t,type:"delete",keys:e}))).then((({numFailures:e,lastResult:n,failures:r})=>{if(0===e)return n;throw new G(`${this.name}.bulkDelete(): ${e} of ${t} operations failed`,r)}))}}function St(e){var r={},s=function(t,n){if(n){for(var s=arguments.length,i=new Array(s-1);--s;)i[s-1]=arguments[s];return r[t].subscribe.apply(null,i),e}if("string"==typeof t)return r[t]};s.addEventType=a;for(var i=1,o=arguments.length;i<o;++i)a(arguments[i]);return s;function a(e,t,n){if("object"==typeof e)return u(e);t||(t=ae),n||(n=ee);var i={subscribers:[],fire:n,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=t(i.fire,e))},unsubscribe:function(e){i.subscribers=i.subscribers.filter((function(t){return t!==e})),i.fire=i.subscribers.reduce(t,n)}};return r[e]=s[e]=i,i}function u(e){t(e).forEach((function(t){var r=e[t];if(n(r))a(t,e[t][0],e[t][1]);else{if("asap"!==r)throw new X.InvalidArgument("Invalid event config");var s=a(t,te,(function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];s.subscribers.forEach((function(e){v((function(){e.apply(null,t)}))}))}))}}))}}function Ct(e,t){return c(t).from({prototype:e}),t}function At(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function jt(e,t){e.filter=_t(e.filter,t)}function Dt(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>_t(r(),t()):t,e.justLimit=n&&!r}function It(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new X.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Bt(e,t,n){const r=It(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function Tt(e,t,n,r){const s=e.replayFilter?_t(e.filter,e.replayFilter()):e.filter;if(e.or){const i={},a=(e,n,r)=>{if(!s||s(n,r,(e=>n.stop(e)),(e=>n.fail(e)))){var a=n.primaryKey,u=""+a;"[object ArrayBuffer]"===u&&(u=""+new Uint8Array(a)),o(i,u)||(i[u]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(a,n),Rt(Bt(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return Rt(Bt(e,r,n),_t(e.algorithm,s),t,!e.keysOnly&&e.valueMapper)}function Rt(e,t,n,r){var s=We(r?(e,t,s)=>n(r(e),t,s):n);return e.then((e=>{if(e)return e.start((()=>{var n=()=>e.continue();t&&!t(e,(e=>n=e),(t=>{e.stop(t),n=ee}),(t=>{e.fail(t),n=ee}))||s(e.value,e,(e=>n=e)),n()}))}))}class Ft{_read(e,t){var n=this._ctx;return n.error?n.table._trans(null,ht.bind(null,n.error)):n.table._trans("readonly",e).then(t)}_write(e){var t=this._ctx;return t.error?t.table._trans(null,ht.bind(null,t.error)):t.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var t=this._ctx;t.algorithm=_t(t.algorithm,e)}_iterate(e,t){return Tt(this._ctx,e,t,this._ctx.table.core)}clone(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&r(n,e),t._ctx=n,t}raw(){return this._ctx.valueMapper=null,this}each(e){var t=this._ctx;return this._read((n=>Tt(t,e,n,t.table.core)))}count(e){return this._read((e=>{const t=this._ctx,n=t.table.core;if(At(t,!0))return n.count({trans:e,query:{index:It(t,n.schema),range:t.range}}).then((e=>Math.min(e,t.limit)));var r=0;return Tt(t,(()=>(++r,!1)),e,n).then((()=>r))})).then(e)}sortBy(e,t){const n=e.split(".").reverse(),r=n[0],s=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var o="next"===this._ctx.dir?1:-1;function a(e,t){var n=i(e,s),r=i(t,s);return n<r?-o:n>r?o:0}return this.toArray((function(e){return e.sort(a)})).then(t)}toArray(e){return this._read((e=>{var t=this._ctx;if("next"===t.dir&&At(t,!0)&&t.limit>0){const{valueMapper:n}=t,r=It(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then((({result:e})=>n?e.map(n):e))}{const n=[];return Tt(t,(e=>n.push(e)),e,t.table.core).then((()=>n))}}),e)}offset(e){var t=this._ctx;return e<=0||(t.offset+=e,At(t)?Dt(t,(()=>{var t=e;return(e,n)=>0===t||(1===t?(--t,!1):(n((()=>{e.advance(t),t=0})),!1))})):Dt(t,(()=>{var t=e;return()=>--t<0}))),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Dt(this._ctx,(()=>{var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}}),!0),this}until(e,t){return jt(this._ctx,(function(n,r,s){return!e(n.value)||(r(s),t)})),this}first(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)}last(e){return this.reverse().first(e)}filter(e){var t,n;return jt(this._ctx,(function(t){return e(t.value)})),t=this._ctx,n=e,t.isMatch=_t(t.isMatch,n),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,this)}reverse(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.key,n)}))}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.primaryKey,n)}))}keys(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.key)})).then((function(){return n})).then(e)}primaryKeys(e){var t=this._ctx;if("next"===t.dir&&At(t,!0)&&t.limit>0)return this._read((e=>{var n=It(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})})).then((({result:e})=>e)).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.primaryKey)})).then((function(){return n})).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys((function(e){return e[0]})).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return jt(this._ctx,(function(e){var t=e.primaryKey.toString(),r=o(n,t);return n[t]=!0,!r})),this}modify(e){var n=this._ctx;return this._write((r=>{var s;if("function"==typeof e)s=e;else{var i=t(e),o=i.length;s=function(t){for(var n=!1,r=0;r<o;++r){var s=i[r],a=e[s];b(t,s)!==a&&(_(t,s,a),n=!0)}return n}}const a=n.table.core,{outbound:u,extractKey:l}=a.schema.primaryKey,c=this.db._options.modifyChunkSize||200,h=[];let d=0;const f=[],p=(e,n)=>{const{failures:r,numFailures:s}=n;d+=e-s;for(let e of t(r))h.push(r[e])};return this.clone().primaryKeys().then((t=>{const i=o=>{const h=Math.min(c,t.length-o);return a.getMany({trans:r,keys:t.slice(o,o+h),cache:"immutable"}).then((d=>{const f=[],y=[],m=u?[]:null,v=[];for(let e=0;e<h;++e){const n=d[e],r={value:O(n),primKey:t[o+e]};!1!==s.call(r,r.value,r)&&(null==r.value?v.push(t[o+e]):u||0===Et(l(n),l(r.value))?(y.push(r.value),u&&m.push(t[o+e])):(v.push(t[o+e]),f.push(r.value)))}const g=At(n)&&n.limit===1/0&&("function"!=typeof e||e===Mt)&&{index:n.index,range:n.range};return Promise.resolve(f.length>0&&a.mutate({trans:r,type:"add",values:f}).then((e=>{for(let t in e.failures)v.splice(parseInt(t),1);p(f.length,e)}))).then((()=>(y.length>0||g&&"object"==typeof e)&&a.mutate({trans:r,type:"put",keys:m,values:y,criteria:g,changeSpec:"function"!=typeof e&&e}).then((e=>p(y.length,e))))).then((()=>(v.length>0||g&&e===Mt)&&a.mutate({trans:r,type:"delete",keys:v,criteria:g}).then((e=>p(v.length,e))))).then((()=>t.length>o+h&&i(o+c)))}))};return i(0).then((()=>{if(h.length>0)throw new z("Error modifying one or more objects",h,d,f);return t.length}))}))}))}delete(){var e=this._ctx,t=e.range;return At(e)&&(e.isPrimKey&&!gt||3===t.type)?this._write((n=>{const{primaryKey:r}=e.table.core.schema,s=t;return e.table.core.count({trans:n,query:{index:r,range:s}}).then((t=>e.table.core.mutate({trans:n,type:"deleteRange",range:s}).then((({failures:e,lastResult:n,results:r,numFailures:s})=>{if(s)throw new z("Could not delete some values",Object.keys(e).map((t=>e[t])),t-s);return t-s}))))})):this.modify(Mt)}}const Mt=(e,t)=>t.value=null;function Nt(e,t){return e<t?-1:e===t?0:1}function qt(e,t){return e>t?-1:e===t?0:1}function $t(e,t,n){var r=e instanceof zt?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function Ut(e){return new e.Collection(e,(()=>Yt(""))).limit(0)}function Lt(e,t,n,r,s,i){for(var o=Math.min(e.length,r.length),a=-1,u=0;u<o;++u){var l=t[u];if(l!==r[u])return s(e[u],n[u])<0?e.substr(0,u)+n[u]+n.substr(u+1):s(e[u],r[u])<0?e.substr(0,u)+r[u]+n.substr(u+1):a>=0?e.substr(0,a)+t[a]+n.substr(a+1):null;s(e[u],l)<0&&(a=u)}return o<r.length&&"next"===i?e+n.substr(e.length):o<e.length&&"prev"===i?e.substr(0,n.length):a<0?null:e.substr(0,a)+r[a]+n.substr(a+1)}function Vt(e,t,n,r){var s,i,o,a,u,l,c,h=n.length;if(!n.every((e=>"string"==typeof e)))return $t(e,"String expected.");function d(e){s=function(e){return"next"===e?e=>e.toUpperCase():e=>e.toLowerCase()}(e),i=function(e){return"next"===e?e=>e.toLowerCase():e=>e.toUpperCase()}(e),o="next"===e?Nt:qt;var t=n.map((function(e){return{lower:i(e),upper:s(e)}})).sort((function(e,t){return o(e.lower,t.lower)}));a=t.map((function(e){return e.upper})),u=t.map((function(e){return e.lower})),l=e,c="next"===e?"":r}d("next");var f=new e.Collection(e,(()=>Wt(a[0],u[h-1]+r)));f._ondirectionchange=function(e){d(e)};var p=0;return f._addAlgorithm((function(e,n,r){var s=e.key;if("string"!=typeof s)return!1;var d=i(s);if(t(d,u,p))return!0;for(var f=null,y=p;y<h;++y){var m=Lt(s,d,a[y],u[y],o,l);null===m&&null===f?p=y+1:(null===f||o(f,m)>0)&&(f=m)}return n(null!==f?function(){e.continue(f+c)}:r),!1})),f}function Wt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Yt(e){return{type:1,lower:e,upper:e}}class zt{get Collection(){return this._ctx.table.db.Collection}between(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Ut(this):new this.Collection(this,(()=>Wt(e,t,!n,!r)))}catch(e){return $t(this,pt)}}equals(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Yt(e)))}above(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(e,void 0,!0)))}aboveOrEqual(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(e,void 0,!1)))}below(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(void 0,e,!1,!0)))}belowOrEqual(e){return null==e?$t(this,pt):new this.Collection(this,(()=>Wt(void 0,e)))}startsWith(e){return"string"!=typeof e?$t(this,"String expected."):this.between(e,e+ft,!0,!0)}startsWithIgnoreCase(e){return""===e?this.startsWith(e):Vt(this,((e,t)=>0===e.indexOf(t[0])),[e],ft)}equalsIgnoreCase(e){return Vt(this,((e,t)=>e===t[0]),[e],"")}anyOfIgnoreCase(){var e=B.apply(I,arguments);return 0===e.length?Ut(this):Vt(this,((e,t)=>-1!==t.indexOf(e)),e,"")}startsWithAnyOfIgnoreCase(){var e=B.apply(I,arguments);return 0===e.length?Ut(this):Vt(this,((e,t)=>t.some((t=>0===e.indexOf(t)))),e,ft)}anyOf(){const e=B.apply(I,arguments);let t=this._cmp;try{e.sort(t)}catch(e){return $t(this,pt)}if(0===e.length)return Ut(this);const n=new this.Collection(this,(()=>Wt(e[0],e[e.length-1])));n._ondirectionchange=n=>{t="next"===n?this._ascending:this._descending,e.sort(t)};let r=0;return n._addAlgorithm(((n,s,i)=>{const o=n.key;for(;t(o,e[r])>0;)if(++r,r===e.length)return s(i),!1;return 0===t(o,e[r])||(s((()=>{n.continue(e[r])})),!1)})),n}notEqual(e){return this.inAnyRange([[-(1/0),e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=B.apply(I,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return $t(this,pt)}const t=e.reduce(((e,t)=>e?e.concat([[e[e.length-1][1],t]]):[[-(1/0),t]]),null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,t){const n=this._cmp,r=this._ascending,s=this._descending,i=this._min,o=this._max;if(0===e.length)return Ut(this);if(!e.every((e=>void 0!==e[0]&&void 0!==e[1]&&r(e[0],e[1])<=0)))return $t(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",X.InvalidArgument);const a=!t||!1!==t.includeLowers,u=t&&!0===t.includeUppers;let l,c=r;function h(e,t){return c(e[0],t[0])}try{l=e.reduce((function(e,t){let r=0,s=e.length;for(;r<s;++r){const s=e[r];if(n(t[0],s[1])<0&&n(t[1],s[0])>0){s[0]=i(s[0],t[0]),s[1]=o(s[1],t[1]);break}}return r===s&&e.push(t),e}),[]),l.sort(h)}catch(e){return $t(this,pt)}let d=0;const f=u?e=>r(e,l[d][1])>0:e=>r(e,l[d][1])>=0,p=a?e=>s(e,l[d][0])>0:e=>s(e,l[d][0])>=0;let y=f;const m=new this.Collection(this,(()=>Wt(l[0][0],l[l.length-1][1],!a,!u)));return m._ondirectionchange=e=>{"next"===e?(y=f,c=r):(y=p,c=s),l.sort(h)},m._addAlgorithm(((e,t,n)=>{for(var s=e.key;y(s);)if(++d,d===l.length)return t(n),!1;return!!function(e){return!f(e)&&!p(e)}(s)||(0===this._cmp(s,l[d][1])||0===this._cmp(s,l[d][0])||t((()=>{c===r?e.continue(l[d][0]):e.continue(l[d][1])})),!1)})),m}startsWithAnyOf(){const e=B.apply(I,arguments);return e.every((e=>"string"==typeof e))?0===e.length?Ut(this):this.inAnyRange(e.map((e=>[e,e+ft]))):$t(this,"startsWithAnyOf() only works with strings")}}function Gt(e){return We((function(t){return Ht(t),e(t.target.error),!1}))}function Ht(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const Qt=St(null,"storagemutated");class Xt{_lock(){return m(!Ke.global),++this._reculock,1!==this._reculock||Ke.global||(Ke.lockOwnerFor=this),this}_unlock(){if(m(!Ke.global),0==--this._reculock)for(Ke.global||(Ke.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{ot(e[1],e[0])}catch(e){}}return this}_locked(){return this._reculock&&Ke.lockOwnerFor!==this}create(e){if(!this.mode)return this;const t=this.db.idbdb,n=this.db._state.dbOpenError;if(m(!this.idbtrans),!e&&!t)switch(n&&n.name){case"DatabaseClosedError":throw new X.DatabaseClosed(n);case"MissingAPIError":throw new X.MissingAPI(n.message,n);default:throw new X.OpenFailed(n)}if(!this.active)throw new X.TransactionInactive;return m(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):t.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=We((t=>{Ht(t),this._reject(e.error)})),e.onabort=We((t=>{Ht(t),this.active&&this._reject(new X.Abort(e.error)),this.active=!1,this.on("abort").fire(t)})),e.oncomplete=We((()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&Qt.storagemutated.fire(e.mutatedParts)})),this}_promise(e,t,n){if("readwrite"===e&&"readwrite"!==this.mode)return ht(new X.ReadOnly("Transaction is readonly"));if(!this.active)return ht(new X.TransactionInactive);if(this._locked())return new Ae(((r,s)=>{this._blockedFuncs.push([()=>{this._promise(e,t,n).then(r,s)},Ke])}));if(n)return Je((()=>{var e=new Ae(((e,n)=>{this._lock();const r=t(e,n,this);r&&r.then&&r.then(e,n)}));return e.finally((()=>this._unlock())),e._lib=!0,e}));var r=new Ae(((e,n)=>{var r=t(e,n,this);r&&r.then&&r.then(e,n)}));return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(e){var t=this._root();const n=Ae.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then((()=>n));else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var s=t._waitingFor;return new Ae(((e,r)=>{n.then((n=>t._waitingQueue.push(We(e.bind(null,n)))),(e=>t._waitingQueue.push(We(r.bind(null,e))))).finally((()=>{t._waitingFor===s&&(t._waitingFor=null)}))}))}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new X.Abort))}table(e){const t=this._memoizedTables||(this._memoizedTables={});if(o(t,e))return t[e];const n=this.schema[e];if(!n)throw new X.NotFound("Table "+e+" not part of transaction");const r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r}}function Jt(e,t,n,r,s,i,o){return{name:e,keyPath:t,unique:n,multi:r,auto:s,compound:i,src:(n&&!o?"&":"")+(r?"*":"")+(s?"++":"")+Zt(t)}}function Zt(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function en(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:g(n,(e=>[e.name,e]))}}let tn=e=>{try{return e.only([[]]),tn=()=>[[]],[[]]}catch(e){return tn=()=>ft,ft}};function nn(e){return null==e?()=>{}:"string"==typeof e?function(e){return 1===e.split(".").length?t=>t[e]:t=>b(t,e)}(e):t=>b(t,e)}function rn(e){return[].slice.call(e)}let sn=0;function on(e){return null==e?":id":"string"==typeof e?e:`[${e.join("+")}]`}function an(e,t,r){function s(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:n,upper:r,lowerOpen:s,upperOpen:i}=e;return void 0===n?void 0===r?null:t.upperBound(r,!!i):void 0===r?t.lowerBound(n,!!s):t.bound(n,r,!!s,!!i)}const{schema:i,hasGetAll:o}=function(e,t){const r=rn(e.objectStoreNames);return{schema:{name:e.name,tables:r.map((e=>t.objectStore(e))).map((e=>{const{keyPath:t,autoIncrement:r}=e,s=n(t),i=null==t,o={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:i,compound:s,keyPath:t,autoIncrement:r,unique:!0,extractKey:nn(t)},indexes:rn(e.indexNames).map((t=>e.index(t))).map((e=>{const{name:t,unique:r,multiEntry:s,keyPath:i}=e,a={name:t,compound:n(i),keyPath:i,unique:r,multiEntry:s,extractKey:nn(i)};return o[on(i)]=a,a})),getIndexByKeyPath:e=>o[on(e)]};return o[":id"]=a.primaryKey,null!=t&&(o[on(t)]=a.primaryKey),a}))},hasGetAll:r.length>0&&"getAll"in t.objectStore(r[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,r),a=i.tables.map((e=>function(e){const t=e.name;return{name:t,schema:e,mutate:function({trans:e,type:n,keys:r,values:i,range:o}){return new Promise(((a,u)=>{a=We(a);const l=e.objectStore(t),c=null==l.keyPath,h="put"===n||"add"===n;if(!h&&"delete"!==n&&"deleteRange"!==n)throw new Error("Invalid operation type: "+n);const{length:d}=r||i||{length:1};if(r&&i&&r.length!==i.length)throw new Error("Given keys array must have same length as given values array.");if(0===d)return a({numFailures:0,failures:{},results:[],lastResult:void 0});let f;const p=[],y=[];let m=0;const v=e=>{++m,Ht(e)};if("deleteRange"===n){if(4===o.type)return a({numFailures:m,failures:y,results:[],lastResult:void 0});3===o.type?p.push(f=l.clear()):p.push(f=l.delete(s(o)))}else{const[e,t]=h?c?[i,r]:[i,null]:[r,null];if(h)for(let r=0;r<d;++r)p.push(f=t&&void 0!==t[r]?l[n](e[r],t[r]):l[n](e[r])),f.onerror=v;else for(let t=0;t<d;++t)p.push(f=l[n](e[t])),f.onerror=v}const g=e=>{const t=e.target.result;p.forEach(((e,t)=>null!=e.error&&(y[t]=e.error))),a({numFailures:m,failures:y,results:"delete"===n?r:p.map((e=>e.result)),lastResult:t})};f.onerror=e=>{v(e),g(e)},f.onsuccess=g}))},getMany:({trans:e,keys:n})=>new Promise(((r,s)=>{r=We(r);const i=e.objectStore(t),o=n.length,a=new Array(o);let u,l=0,c=0;const h=e=>{const t=e.target;a[t._pos]=t.result,++c===l&&r(a)},d=Gt(s);for(let e=0;e<o;++e)null!=n[e]&&(u=i.get(n[e]),u._pos=e,u.onsuccess=h,u.onerror=d,++l);0===l&&r(a)})),get:({trans:e,key:n})=>new Promise(((r,s)=>{r=We(r);const i=e.objectStore(t).get(n);i.onsuccess=e=>r(e.target.result),i.onerror=Gt(s)})),query:function(e){return n=>new Promise(((r,i)=>{r=We(r);const{trans:o,values:a,limit:u,query:l}=n,c=u===1/0?void 0:u,{index:h,range:d}=l,f=o.objectStore(t),p=h.isPrimaryKey?f:f.index(h.name),y=s(d);if(0===u)return r({result:[]});if(e){const e=a?p.getAll(y,c):p.getAllKeys(y,c);e.onsuccess=e=>r({result:e.target.result}),e.onerror=Gt(i)}else{let e=0;const t=a||!("openKeyCursor"in p)?p.openCursor(y):p.openKeyCursor(y),n=[];t.onsuccess=s=>{const i=t.result;return i?(n.push(a?i.value:i.primaryKey),++e===u?r({result:n}):void i.continue()):r({result:n})},t.onerror=Gt(i)}}))}(o),openCursor:function({trans:e,values:n,query:r,reverse:i,unique:o}){return new Promise(((a,u)=>{a=We(a);const{index:l,range:c}=r,h=e.objectStore(t),d=l.isPrimaryKey?h:h.index(l.name),f=i?o?"prevunique":"prev":o?"nextunique":"next",p=n||!("openKeyCursor"in d)?d.openCursor(s(c),f):d.openKeyCursor(s(c),f);p.onerror=Gt(u),p.onsuccess=We((t=>{const n=p.result;if(!n)return void a(null);n.___id=++sn,n.done=!1;const r=n.continue.bind(n);let s=n.continuePrimaryKey;s&&(s=s.bind(n));const i=n.advance.bind(n),o=()=>{throw new Error("Cursor not stopped")};n.trans=e,n.stop=n.continue=n.continuePrimaryKey=n.advance=()=>{throw new Error("Cursor not started")},n.fail=We(u),n.next=function(){let e=1;return this.start((()=>e--?this.continue():this.stop())).then((()=>this))},n.start=e=>{const t=new Promise(((e,t)=>{e=We(e),p.onerror=Gt(t),n.fail=t,n.stop=t=>{n.stop=n.continue=n.continuePrimaryKey=n.advance=o,e(t)}})),a=()=>{if(p.result)try{e()}catch(e){n.fail(e)}else n.done=!0,n.start=()=>{throw new Error("Cursor behind last entry")},n.stop()};return p.onsuccess=We((e=>{p.onsuccess=a,a()})),n.continue=r,n.continuePrimaryKey=s,n.advance=i,a(),t},a(n)}),u)}))},count({query:e,trans:n}){const{index:r,range:i}=e;return new Promise(((e,o)=>{const a=n.objectStore(t),u=r.isPrimaryKey?a:a.index(r.name),l=s(i),c=l?u.count(l):u.count();c.onsuccess=We((t=>e(t.target.result))),c.onerror=Gt(o)}))}}}(e))),u={};return a.forEach((e=>u[e.name]=e)),{stack:"dbcore",transaction:e.transaction.bind(e),table(e){if(!u[e])throw new Error(`Table '${e}' not found`);return u[e]},MIN_KEY:-1/0,MAX_KEY:tn(t),schema:i}}function un({_novip:e},t){const n=t.db,r=function(e,t,{IDBKeyRange:n,indexedDB:r},s){const i=function(e,t){return t.reduce(((e,{create:t})=>({...e,...t(e)})),e)}(an(t,n,s),e.dbcore);return{dbcore:i}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach((t=>{const n=t.name;e.core.schema.tables.some((e=>e.name===n))&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))}))}function ln({_novip:e},t,n,r){n.forEach((n=>{const s=r[n];t.forEach((t=>{const r=d(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?l(t,n,{get(){return this.table(n)},set(e){u(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,s))}))}))}function cn({_novip:e},t){t.forEach((t=>{for(let n in t)t[n]instanceof e.Table&&delete t[n]}))}function hn(e,t){return e._cfg.version-t._cfg.version}function dn(e,n,r,s){const i=e._dbSchema,o=e._createTransaction("readwrite",e._storeNames,i);o.create(r),o._completion.catch(s);const a=o._reject.bind(o),u=Ke.transless||Ke;Je((()=>{Ke.trans=o,Ke.transless=u,0===n?(t(i).forEach((e=>{pn(r,e,i[e].primKey,i[e].indexes)})),un(e,r),Ae.follow((()=>e.on.populate.fire(o))).catch(a)):function({_novip:e},n,r,s){const i=[],o=e._versions;let a=e._dbSchema=mn(e,e.idbdb,s),u=!1;function l(){return i.length?Ae.resolve(i.shift()(r.idbtrans)).then(l):Ae.resolve()}return o.filter((e=>e._cfg.version>=n)).forEach((o=>{i.push((()=>{const i=a,l=o._cfg.dbschema;vn(e,i,s),vn(e,l,s),a=e._dbSchema=l;const c=fn(i,l);c.add.forEach((e=>{pn(s,e[0],e[1].primKey,e[1].indexes)})),c.change.forEach((e=>{if(e.recreate)throw new X.Upgrade("Not yet support for changing primary key");{const t=s.objectStore(e.name);e.add.forEach((e=>yn(t,e))),e.change.forEach((e=>{t.deleteIndex(e.name),yn(t,e)})),e.del.forEach((e=>t.deleteIndex(e)))}}));const h=o._cfg.contentUpgrade;if(h&&o._cfg.version>n){un(e,s),r._memoizedTables={},u=!0;let n=w(l);c.del.forEach((e=>{n[e]=i[e]})),cn(e,[e.Transaction.prototype]),ln(e,[e.Transaction.prototype],t(n),n),r.schema=n;const o=T(h);let a;o&&Ze();const d=Ae.follow((()=>{if(a=h(r),a&&o){var e=et.bind(null,null);a.then(e,e)}}));return a&&"function"==typeof a.then?Ae.resolve(a):d.then((()=>a))}})),i.push((t=>{if(!u||!vt){!function(e,t){[].slice.call(t.db.objectStoreNames).forEach((n=>null==e[n]&&t.db.deleteObjectStore(n)))}(o._cfg.dbschema,t)}cn(e,[e.Transaction.prototype]),ln(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),r.schema=e._dbSchema}))})),l().then((()=>{var e,n;n=s,t(e=a).forEach((t=>{n.db.objectStoreNames.contains(t)||pn(n,t,e[t].primKey,e[t].indexes)}))}))}(e,n,o,r).catch(a)}))}function fn(e,t){const n={del:[],add:[],change:[]};let r;for(r in e)t[r]||n.del.push(r);for(r in t){const s=e[r],i=t[r];if(s){const e={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||s.primKey.auto!==i.primKey.auto&&!mt)e.recreate=!0,n.change.push(e);else{const t=s.idxByName,r=i.idxByName;let o;for(o in t)r[o]||e.del.push(o);for(o in r){const n=t[o],s=r[o];n?n.src!==s.src&&e.change.push(s):e.add.push(s)}(e.del.length>0||e.add.length>0||e.change.length>0)&&n.change.push(e)}}else n.add.push([r,i])}return n}function pn(e,t,n,r){const s=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach((e=>yn(s,e))),s}function yn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function mn(e,t,n){const r={};return p(t.objectStoreNames,0).forEach((e=>{const t=n.objectStore(e);let s=t.keyPath;const i=Jt(Zt(s),s||"",!1,!1,!!t.autoIncrement,s&&"string"!=typeof s,!0),o=[];for(let e=0;e<t.indexNames.length;++e){const n=t.index(t.indexNames[e]);s=n.keyPath;var a=Jt(n.name,s,!!n.unique,!!n.multiEntry,!1,s&&"string"!=typeof s,!1);o.push(a)}r[e]=en(e,i,o)})),r}function vn({_novip:t},n,r){const s=r.db.objectStoreNames;for(let e=0;e<s.length;++e){const i=s[e],o=r.objectStore(i);t._hasGetAll="getAll"in o;for(let e=0;e<o.indexNames.length;++e){const t=o.indexNames[e],r=o.index(t).keyPath,s="string"==typeof r?r:"["+p(r).join("+")+"]";if(n[i]){const e=n[i].idxByName[s];e&&(e.name=t,delete n[i].idxByName[s],n[i].idxByName[t]=e)}}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&e.WorkerGlobalScope&&e instanceof e.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(t._hasGetAll=!1)}class gn{_parseStoresSpec(e,r){t(e).forEach((t=>{if(null!==e[t]){var s=e[t].split(",").map(((e,t)=>{const r=(e=e.trim()).replace(/([&*]|\+\+)/g,""),s=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return Jt(r,s||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),n(s),0===t)})),i=s.shift();if(i.multi)throw new X.Schema("Primary key cannot be multi-valued");s.forEach((e=>{if(e.auto)throw new X.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new X.Schema("Index must have a name and cannot be an empty string")})),r[t]=en(t,i,s)}}))}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?r(this._cfg.storesSource,e):e;const s=n._versions,i={};let o={};return s.forEach((e=>{r(i,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(i,o)})),n._dbSchema=o,cn(n,[n._allTables,n,n.Transaction.prototype]),ln(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],t(o),o),n._storeNames=t(o),this}upgrade(e){return this._cfg.contentUpgrade=ue(this._cfg.contentUpgrade||ee,e),this}}function bn(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Un("__dbnames",{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function _n(e){return e&&"function"==typeof e.databases}function wn(e){return Je((function(){return Ke.letThrough=!0,e()}))}function xn(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise((function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()})).finally((function(){return clearInterval(e)})):Promise.resolve()}function kn(e){const n=e._state,{indexedDB:r}=e._deps;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then((()=>n.dbOpenError?ht(n.dbOpenError):e));R&&(n.openCanceller._stackHolder=q()),n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;const s=n.openCanceller;function i(){if(n.openCanceller!==s)throw new X.DatabaseClosed("db.open() was cancelled")}let o=n.dbReadyResolve,a=null,u=!1;return Ae.race([s,("undefined"==typeof navigator?Ae.resolve():xn()).then((()=>new Ae(((s,o)=>{if(i(),!r)throw new X.MissingAPI;const l=e.name,c=n.autoSchema?r.open(l):r.open(l,Math.round(10*e.verno));if(!c)throw new X.MissingAPI;c.onerror=Gt(o),c.onblocked=We(e._fireOnBlocked),c.onupgradeneeded=We((t=>{if(a=c.transaction,n.autoSchema&&!e._options.allowEmptyDB){c.onerror=Ht,a.abort(),c.result.close();const e=r.deleteDatabase(l);e.onsuccess=e.onerror=We((()=>{o(new X.NoSuchDatabase(`Database ${l} doesnt exist`))}))}else{a.onerror=Gt(o);var s=t.oldVersion>Math.pow(2,62)?0:t.oldVersion;u=s<1,e._novip.idbdb=c.result,dn(e,s/10,a,o)}}),o),c.onsuccess=We((()=>{a=null;const r=e._novip.idbdb=c.result,i=p(r.objectStoreNames);if(i.length>0)try{const s=r.transaction(1===(o=i).length?o[0]:o,"readonly");n.autoSchema?function({_novip:e},n,r){e.verno=n.version/10;const s=e._dbSchema=mn(0,n,r);e._storeNames=p(n.objectStoreNames,0),ln(e,[e._allTables],t(s),s)}(e,r,s):(vn(e,e._dbSchema,s),function(e,t){const n=fn(mn(0,e.idbdb,t),e._dbSchema);return!(n.add.length||n.change.some((e=>e.add.length||e.change.length)))}(e,s)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),un(e,s)}catch(e){}var o;yt.push(e),r.onversionchange=We((t=>{n.vcFired=!0,e.on("versionchange").fire(t)})),r.onclose=We((t=>{e.on("close").fire(t)})),u&&function({indexedDB:e,IDBKeyRange:t},n){!_n(e)&&"__dbnames"!==n&&bn(e,t).put({name:n}).catch(ee)}(e._deps,l),s()}),o)}))))]).then((()=>(i(),n.onReadyBeingFired=[],Ae.resolve(wn((()=>e.on.ready.fire(e.vip)))).then((function t(){if(n.onReadyBeingFired.length>0){let r=n.onReadyBeingFired.reduce(ue,ee);return n.onReadyBeingFired=[],Ae.resolve(wn((()=>r(e.vip)))).then(t)}}))))).finally((()=>{n.onReadyBeingFired=null,n.isBeingOpened=!1})).then((()=>e)).catch((t=>{n.dbOpenError=t;try{a&&a.abort()}catch(e){}return s===n.openCanceller&&e._close(),ht(t)})).finally((()=>{n.openComplete=!0,o()}))}function En(e){var t=t=>e.next(t),r=i(t),s=i((t=>e.throw(t)));function i(e){return t=>{var i=e(t),o=i.value;return i.done?o:o&&"function"==typeof o.then?o.then(r,s):n(o)?Promise.all(o).then(r,s):r(o)}}return i(t)()}function Pn(e,t,n){var r=arguments.length;if(r<2)throw new X.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];n=s.pop();var i=k(s);return[e,i,n]}function Kn(e,t,n,r,s){return Ae.resolve().then((()=>{const i=Ke.transless||Ke,o=e._createTransaction(t,n,e._dbSchema,r),a={trans:o,transless:i};if(r)o.idbtrans=r.idbtrans;else try{o.create(),e._state.PR1398_maxLoop=3}catch(r){return r.name===H.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then((()=>Kn(e,t,n,null,s)))):ht(r)}const u=T(s);let l;u&&Ze();const c=Ae.follow((()=>{if(l=s.call(o,o),l)if(u){var e=et.bind(null,null);l.then(e,e)}else"function"==typeof l.next&&"function"==typeof l.throw&&(l=En(l))}),a);return(l&&"function"==typeof l.then?Ae.resolve(l).then((e=>o.active?e:ht(new X.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn")))):c.then((()=>l))).then((e=>(r&&o._resolve(),o._completion.then((()=>e))))).catch((e=>(o._reject(e),ht(e))))}))}function On(e,t,r){const s=n(e)?e.slice():[e];for(let e=0;e<r;++e)s.push(t);return s}const Sn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const n=e.table(t),{schema:r}=n,s={},i=[];function o(e,t,n){const r=on(e),a=s[r]=s[r]||[],u=null==e?0:"string"==typeof e?1:e.length,l=t>0,c={...n,isVirtual:l,keyTail:t,keyLength:u,extractKey:nn(e),unique:!l&&n.unique};if(a.push(c),c.isPrimaryKey||i.push(c),u>1){o(2===u?e[0]:e.slice(0,u-1),t+1,n)}return a.sort(((e,t)=>e.keyTail-t.keyTail)),c}const a=o(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[a];for(const e of r.indexes)o(e.keyPath,0,e);function u(t){const n=t.query.index;return n.isVirtual?{...t,query:{index:n,range:(r=t.query.range,s=n.keyTail,{type:1===r.type?2:r.type,lower:On(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,s),lowerOpen:!0,upper:On(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,s),upperOpen:!0})}}:t;var r,s}const l={...n,schema:{...r,primaryKey:a,indexes:i,getIndexByKeyPath:function(e){const t=s[on(e)];return t&&t[0]}},count:e=>n.count(u(e)),query:e=>n.query(u(e)),openCursor(t){const{keyTail:r,isVirtual:s,keyLength:i}=t.query.index;if(!s)return n.openCursor(t);return n.openCursor(u(t)).then((n=>n&&function(n){const s=Object.create(n,{continue:{value:function(s){null!=s?n.continue(On(s,t.reverse?e.MAX_KEY:e.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value(t,s){n.continuePrimaryKey(On(t,e.MAX_KEY,r),s)}},primaryKey:{get:()=>n.primaryKey},key:{get(){const e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:()=>n.value}});return s}(n)))}};return l}}}};function Cn(e,n,r,s){return r=r||{},s=s||"",t(e).forEach((t=>{if(o(n,t)){var i=e[t],a=n[t];if("object"==typeof i&&"object"==typeof a&&i&&a){const e=A(i);e!==A(a)?r[s+t]=n[t]:"Object"===e?Cn(i,a,r,s+t+"."):i!==a&&(r[s+t]=n[t])}else i!==a&&(r[s+t]=n[t])}else r[s+t]=void 0})),t(n).forEach((t=>{o(e,t)||(r[s+t]=n[t])})),r}const An={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema,s={...n,mutate(e){const s=Ke.trans,{deleting:i,creating:a,updating:u}=s.table(t).hook;switch(e.type){case"add":if(a.fire===ee)break;return s._promise("readwrite",(()=>l(e)),!0);case"put":if(a.fire===ee&&u.fire===ee)break;return s._promise("readwrite",(()=>l(e)),!0);case"delete":if(i.fire===ee)break;return s._promise("readwrite",(()=>l(e)),!0);case"deleteRange":if(i.fire===ee)break;return s._promise("readwrite",(()=>function(e){return c(e.trans,e.range,1e4)}(e)),!0)}return n.mutate(e);function l(e){const t=Ke.trans,s=e.keys||function(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}(r,e);if(!s)throw new Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?{...e,keys:s}:{...e}).type&&(e.values=[...e.values]),e.keys&&(e.keys=[...e.keys]),function(e,t,n){return"add"===t.type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})}(n,e,s).then((l=>{const c=s.map(((n,s)=>{const c=l[s],h={onerror:null,onsuccess:null};if("delete"===e.type)i.fire.call(h,n,c,t);else if("add"===e.type||void 0===c){const i=a.fire.call(h,n,e.values[s],t);null==n&&null!=i&&(n=i,e.keys[s]=n,r.outbound||_(e.values[s],r.keyPath,n))}else{const r=Cn(c,e.values[s]),i=u.fire.call(h,r,n,c,t);if(i){const t=e.values[s];Object.keys(i).forEach((e=>{o(t,e)?t[e]=i[e]:_(t,e,i[e])}))}}return h}));return n.mutate(e).then((({failures:t,results:n,numFailures:r,lastResult:i})=>{for(let r=0;r<s.length;++r){const i=n?n[r]:s[r],o=c[r];null==i?o.onerror&&o.onerror(t[r]):o.onsuccess&&o.onsuccess("put"===e.type&&l[r]?e.values[r]:i)}return{failures:t,results:n,numFailures:r,lastResult:i}})).catch((e=>(c.forEach((t=>t.onerror&&t.onerror(e))),Promise.reject(e))))}))}function c(e,t,s){return n.query({trans:e,values:!1,query:{index:r,range:t},limit:s}).then((({result:n})=>l({type:"delete",keys:n,trans:e}).then((r=>r.numFailures>0?Promise.reject(r.failures[0]):n.length<s?{failures:[],numFailures:0,lastResult:void 0}:c(e,{...t,lower:n[n.length-1],lowerOpen:!0},s)))))}}};return s}})};function jn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;const r=[];for(let s=0,i=0;s<t.keys.length&&i<e.length;++s)0===Et(t.keys[s],e[i])&&(r.push(n?O(t.values[s]):t.values[s]),++i);return r.length===e.length?r:null}catch(e){return null}}const Dn={stack:"dbcore",level:-1,create:e=>({table:t=>{const n=e.table(t);return{...n,getMany:e=>{if(!e.cache)return n.getMany(e);const t=jn(e.keys,e.trans._cache,"clone"===e.cache);return t?Ae.resolve(t):n.getMany(e).then((t=>(e.trans._cache={keys:e.keys,values:"clone"===e.cache?O(t):t},t)))},mutate:e=>("add"!==e.type&&(e.trans._cache=null),n.mutate(e))}}})};function In(e){return!("from"in e)}const Bn=function(e,t){if(!this){const t=new Bn;return e&&"d"in e&&r(t,e),t}r(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function Tn(e,t,n){const s=Et(t,n);if(isNaN(s))return;if(s>0)throw RangeError();if(In(e))return r(e,{from:t,to:n,d:1});const i=e.l,o=e.r;if(Et(n,e.from)<0)return i?Tn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Nn(e);if(Et(t,e.to)>0)return o?Tn(o,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Nn(e);Et(t,e.from)<0&&(e.from=t,e.l=null,e.d=o?o.d+1:1),Et(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const a=!e.r;i&&!e.l&&Rn(e,i),o&&a&&Rn(e,o)}function Rn(e,t){In(t)||function e(t,{from:n,to:r,l:s,r:i}){Tn(t,n,r),s&&e(t,s),i&&e(t,i)}(e,t)}function Fn(e,t){const n=Mn(t);let r=n.next();if(r.done)return!1;let s=r.value;const i=Mn(e);let o=i.next(s.from),a=o.value;for(;!r.done&&!o.done;){if(Et(a.from,s.to)<=0&&Et(a.to,s.from)>=0)return!0;Et(s.from,a.from)<0?s=(r=n.next(a.from)).value:a=(o=i.next(s.from)).value}return!1}function Mn(e){let t=In(e)?null:{s:0,n:e};return{next(e){const n=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&Et(e,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!n||Et(e,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Nn(e){var t,n;const r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),s=r>1?"r":r<-1?"l":"";if(s){const t="r"===s?"l":"r",n={...e},r=e[s];e.from=r.from,e.to=r.to,e[s]=r[s],n[s]=r[t],e[t]=n,n.d=qn(n)}e.d=qn(e)}function qn({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}a(Bn.prototype,{add(e){return Rn(this,e),this},addKey(e){return Tn(this,e,e),this},addKeys(e){return e.forEach((e=>Tn(this,e,e))),this},[j](){return Mn(this)}});const $n={stack:"dbcore",level:0,create:e=>{const r=e.schema.name,s=new Bn(e.MIN_KEY,e.MAX_KEY);return{...e,table:i=>{const o=e.table(i),{schema:a}=o,{primaryKey:u}=a,{extractKey:l,outbound:c}=u,h={...o,mutate:e=>{const t=e.trans,u=t.mutatedParts||(t.mutatedParts={}),l=e=>{const t=`idb://${r}/${i}/${e}`;return u[t]||(u[t]=new Bn)},c=l(""),h=l(":dels"),{type:d}=e;let[f,p]="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[[],e.values]:[];const y=e.trans._cache;return o.mutate(e).then((e=>{if(n(f)){"delete"!==d&&(f=e.results),c.addKeys(f);const t=jn(f,y);t||"add"===d||h.addKeys(f),(t||p)&&function(e,t,r,s){function i(t){const i=e(t.name||"");function o(e){return null!=e?t.extractKey(e):null}const a=e=>t.multiEntry&&n(e)?e.forEach((e=>i.addKey(e))):i.addKey(e);(r||s).forEach(((e,t)=>{const n=r&&o(r[t]),i=s&&o(s[t]);0!==Et(n,i)&&(null!=n&&a(n),null!=i&&a(i))}))}t.indexes.forEach(i)}(l,a,t,p)}else if(f){const e={from:f.lower,to:f.upper};h.add(e),c.add(e)}else c.add(s),h.add(s),a.indexes.forEach((e=>l(e.name).add(s)));return e}))}},d=({query:{index:t,range:n}})=>{var r,s;return[t,new Bn(null!==(r=n.lower)&&void 0!==r?r:e.MIN_KEY,null!==(s=n.upper)&&void 0!==s?s:e.MAX_KEY)]},f={get:e=>[u,new Bn(e.key)],getMany:e=>[u,(new Bn).addKeys(e.keys)],count:d,query:d,openCursor:d};return t(f).forEach((e=>{h[e]=function(t){const{subscr:n}=Ke;if(n){const a=e=>{const t=`idb://${r}/${i}/${e}`;return n[t]||(n[t]=new Bn)},u=a(""),h=a(":dels"),[d,p]=f[e](t);if(a(d.name||"").add(p),!d.isPrimaryKey){if("count"!==e){const n="query"===e&&c&&t.values&&o.query({...t,values:!1});return o[e].apply(this,arguments).then((r=>{if("query"===e){if(c&&t.values)return n.then((({result:e})=>(u.addKeys(e),r)));const e=t.values?r.result.map(l):r.result;t.values?u.addKeys(e):h.addKeys(e)}else if("openCursor"===e){const e=r,n=t.values;return e&&Object.create(e,{key:{get:()=>(h.addKey(e.primaryKey),e.key)},primaryKey:{get(){const t=e.primaryKey;return h.addKey(t),t}},value:{get:()=>(n&&u.addKey(e.primaryKey),e.value)}})}return r}))}h.add(s)}}return o[e].apply(this,arguments)}})),h}}}};class Un{constructor(e,t){this._middlewares={},this.verno=0;const n=Un.dependencies;this._options=t={addons:Un.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,...t},this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};const{addons:r}=t;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ee,dbReadyPromise:null,cancelOpen:ee,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var i;s.dbReadyPromise=new Ae((e=>{s.dbReadyResolve=e})),s.openCanceller=new Ae(((e,t)=>{s.cancelOpen=t})),this._state=s,this.name=e,this.on=St(this,"populate","blocked","versionchange","close",{ready:[ue,ee]}),this.on.ready.subscribe=y(this.on.ready.subscribe,(e=>(t,n)=>{Un.vip((()=>{const r=this._state;if(r.openComplete)r.dbOpenError||Ae.resolve().then(t),n&&e(t);else if(r.onReadyBeingFired)r.onReadyBeingFired.push(t),n&&e(t);else{e(t);const r=this;n||e((function e(){r.on.ready.unsubscribe(t),r.on.ready.unsubscribe(e)}))}}))})),this.Collection=(i=this,Ct(Ft.prototype,(function(e,t){this.db=i;let n=wt,r=null;if(t)try{n=t()}catch(e){r=e}const s=e._ctx,o=s.table,a=o.hook.reading.fire;this._ctx={table:o,index:s.index,isPrimKey:!s.index||o.schema.primKey.keyPath&&s.index===o.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:s.or,valueMapper:a!==te?a:null}}))),this.Table=function(e){return Ct(Ot.prototype,(function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:St(null,{creating:[se,ee],reading:[ne,te],updating:[oe,ee],deleting:[ie,ee]})}))}(this),this.Transaction=function(e){return Ct(Xt.prototype,(function(t,n,r,s,i){this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=s,this.idbtrans=null,this.on=St(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new Ae(((e,t)=>{this._resolve=e,this._reject=t})),this._completion.then((()=>{this.active=!1,this.on.complete.fire()}),(e=>{var t=this.active;return this.active=!1,this.on.error.fire(e),this.parent?this.parent._reject(e):t&&this.idbtrans&&this.idbtrans.abort(),ht(e)}))}))}(this),this.Version=function(e){return Ct(gn.prototype,(function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}}))}(this),this.WhereClause=function(e){return Ct(zt.prototype,(function(t,n,r){if(this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r},this._cmp=this._ascending=Et,this._descending=(e,t)=>Et(t,e),this._max=(e,t)=>Et(e,t)>0?e:t,this._min=(e,t)=>Et(e,t)<0?e:t,this._IDBKeyRange=e._deps.IDBKeyRange,!this._IDBKeyRange)throw new X.MissingAPI}))}(this),this.on("versionchange",(e=>{e.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()})),this.on("blocked",(e=>{!e.newVersion||e.newVersion<e.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${e.oldVersion/10}`)})),this._maxKey=tn(t.IDBKeyRange),this._createTransaction=(e,t,n,r)=>new this.Transaction(e,t,n,this._options.chromeTransactionDurability,r),this._fireOnBlocked=e=>{this.on("blocked").fire(e),yt.filter((e=>e.name===this.name&&e!==this&&!e._state.vcFired)).map((t=>t.on("versionchange").fire(e)))},this.use(Sn),this.use(An),this.use($n),this.use(Dn),this.vip=Object.create(this,{_vip:{value:!0}}),r.forEach((e=>e(this)))}version(e){if(isNaN(e)||e<.1)throw new X.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new X.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const t=this._versions;var n=t.filter((t=>t._cfg.version===e))[0];return n||(n=new this.Version(e),t.push(n),t.sort(hn),n.stores({}),this._state.autoSchema=!1,n)}_whenReady(e){return this.idbdb&&(this._state.openComplete||Ke.letThrough||this._vip)?e():new Ae(((e,t)=>{if(this._state.openComplete)return t(new X.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void t(new X.DatabaseClosed);this.open().catch(ee)}this._state.dbReadyPromise.then(e,t)})).then(e)}use({stack:e,create:t,level:n,name:r}){r&&this.unuse({stack:e,name:r});const s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:t,level:null==n?10:n,name:r}),s.sort(((e,t)=>e.level-t.level)),this}unuse({stack:e,name:t,create:n}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter((e=>n?e.create!==n:!!t&&e.name!==t))),this}open(){return kn(this)}_close(){const e=this._state,t=yt.indexOf(this);if(t>=0&&yt.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new Ae((t=>{e.dbReadyResolve=t})),e.openCanceller=new Ae(((t,n)=>{e.cancelOpen=n}))}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new X.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,t=this._state;return new Ae(((n,r)=>{const s=()=>{this.close();var e=this._deps.indexedDB.deleteDatabase(this.name);e.onsuccess=We((()=>{!function({indexedDB:e,IDBKeyRange:t},n){!_n(e)&&"__dbnames"!==n&&bn(e,t).delete(n).catch(ee)}(this._deps,this.name),n()})),e.onerror=Gt(r),e.onblocked=this._fireOnBlocked};if(e)throw new X.InvalidArgument("Arguments not allowed in db.delete()");t.isBeingOpened?t.dbReadyPromise.then(s):s()}))}backendDB(){return this.idbdb}isOpen(){return null!==this.idbdb}hasBeenClosed(){const e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name}hasFailed(){return null!==this._state.dbOpenError}dynamicallyOpened(){return this._state.autoSchema}get tables(){return t(this._allTables).map((e=>this._allTables[e]))}transaction(){const e=Pn.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,t,n){let r=Ke.trans;r&&r.db===this&&-1===e.indexOf("!")||(r=null);const s=-1!==e.indexOf("?");let i,o;e=e.replace("!","").replace("?","");try{if(o=t.map((e=>{var t=e instanceof this.Table?e.name:e;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t})),"r"==e||"readonly"===e)i="readonly";else{if("rw"!=e&&"readwrite"!=e)throw new X.InvalidArgument("Invalid transaction mode: "+e);i="readwrite"}if(r){if("readonly"===r.mode&&"readwrite"===i){if(!s)throw new X.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");r=null}r&&o.forEach((e=>{if(r&&-1===r.storeNames.indexOf(e)){if(!s)throw new X.SubTransaction("Table "+e+" not included in parent transaction.");r=null}})),s&&r&&!r.active&&(r=null)}}catch(e){return r?r._promise(null,((t,n)=>{n(e)})):ht(e)}const a=Kn.bind(null,this,i,o,r,n);return r?r._promise(i,a,"lock"):Ke.trans?ot(Ke.transless,(()=>this._whenReady(a))):this._whenReady(a)}table(e){if(!o(this._allTables,e))throw new X.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const Ln="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";class Vn{constructor(e){this._subscribe=e}subscribe(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})}[Ln](){return this}}function Wn(e,n){return t(n).forEach((t=>{Rn(e[t]||(e[t]=new Bn),n[t])})),e}function Yn(e){return new Vn((n=>{const r=T(e);let s=!1,i={},o={};const a={get closed(){return s},unsubscribe:()=>{s=!0,Qt.storagemutated.unsubscribe(h)}};n.start&&n.start(a);let u=!1,l=!1;function c(){return t(o).some((e=>i[e]&&Fn(i[e],o[e])))}const h=e=>{Wn(i,e),c()&&d()},d=()=>{if(u||s)return;i={};const t={},f=function(t){r&&Ze();const n=()=>Je(e,{subscr:t,trans:null}),s=Ke.trans?ot(Ke.transless,n):n();return r&&s.then(et,et),s}(t);l||(Qt("storagemutated",h),l=!0),u=!0,Promise.resolve(f).then((e=>{u=!1,s||(c()?d():(i={},o=t,n.next&&n.next(e)))}),(e=>{["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||(u=!1,n.error&&n.error(e),a.unsubscribe())}))};return d(),a}))}let zn;try{zn={indexedDB:e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB,IDBKeyRange:e.IDBKeyRange||e.webkitIDBKeyRange}}catch(e){zn={indexedDB:null,IDBKeyRange:null}}const Gn=Un;function Hn(e){let t=Qn;try{Qn=!0,Qt.storagemutated.fire(e)}finally{Qn=t}}a(Gn,{...Z,delete:e=>new Gn(e,{addons:[]}).delete(),exists:e=>new Gn(e,{addons:[]}).open().then((e=>(e.close(),!0))).catch("NoSuchDatabaseError",(()=>!1)),getDatabaseNames(e){try{return function({indexedDB:e,IDBKeyRange:t}){return _n(e)?Promise.resolve(e.databases()).then((e=>e.map((e=>e.name)).filter((e=>"__dbnames"!==e)))):bn(e,t).toCollection().primaryKeys()}(Gn.dependencies).then(e)}catch(e){return ht(new X.MissingAPI)}},defineClass:()=>function(e){r(this,e)},ignoreTransaction:e=>Ke.trans?ot(Ke.transless,e):e(),vip:wn,async:function(e){return function(){try{var t=En(e.apply(this,arguments));return t&&"function"==typeof t.then?t:Ae.resolve(t)}catch(e){return ht(e)}}},spawn:function(e,t,n){try{var r=En(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Ae.resolve(r)}catch(e){return ht(e)}},currentTransaction:{get:()=>Ke.trans||null},waitFor:function(e,t){const n=Ae.resolve("function"==typeof e?Gn.ignoreTransaction(e):e).timeout(t||6e4);return Ke.trans?Ke.trans.waitFor(n):n},Promise:Ae,debug:{get:()=>R,set:e=>{F(e,"dexie"===e?()=>!0:bt)}},derive:c,extend:r,props:a,override:y,Events:St,on:Qt,liveQuery:Yn,extendObservabilitySet:Wn,getByKeyPath:b,setByKeyPath:_,delByKeyPath:function(e,t){"string"==typeof t?_(e,t,void 0):"length"in t&&[].map.call(t,(function(t){_(e,t,void 0)}))},shallowClone:w,deepClone:O,getObjectDiff:Cn,cmp:Et,asap:v,minKey:-(1/0),addons:[],connections:yt,errnames:H,dependencies:zn,semVer:"4.0.1-alpha.8",version:"4.0.1-alpha.8".split(".").map((e=>parseInt(e))).reduce(((e,t,n)=>e+t/Math.pow(10,2*n)))}),Gn.maxKey=tn(Gn.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(Qt("storagemutated",(e=>{if(!Qn){let t;mt?(t=document.createEvent("CustomEvent"),t.initCustomEvent("x-storagemutated-1",!0,!0,e)):t=new CustomEvent("x-storagemutated-1",{detail:e}),Qn=!0,dispatchEvent(t),Qn=!1}})),addEventListener("x-storagemutated-1",(({detail:e})=>{Qn||Hn(e)})));let Qn=!1;if("undefined"!=typeof BroadcastChannel){const e=new BroadcastChannel("x-storagemutated-1");"function"==typeof e.unref&&e.unref(),Qt("storagemutated",(t=>{Qn||e.postMessage(t)})),e.onmessage=e=>{e.data&&Hn(e.data)}}else if("undefined"!=typeof self&&"undefined"!=typeof navigator){Qt("storagemutated",(e=>{try{Qn||("undefined"!=typeof localStorage&&localStorage.setItem("x-storagemutated-1",JSON.stringify({trig:Math.random(),changedParts:e})),"object"==typeof self.clients&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach((t=>t.postMessage({type:"x-storagemutated-1",changedParts:e}))))}catch(e){}})),"undefined"!=typeof addEventListener&&addEventListener("storage",(e=>{if("x-storagemutated-1"===e.key){const t=JSON.parse(e.newValue);t&&Hn(t.changedParts)}}));const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",(function({data:e}){e&&"x-storagemutated-1"===e.type&&Hn(e.changedParts)}))}Ae.rejectionMapper=function(e,t){if(!e||e instanceof W||e instanceof TypeError||e instanceof SyntaxError||!e.name||!J[e.name])return e;var n=new J[e.name](t||e.message,e);return"stack"in e&&l(n,"stack",{get:function(){return this.inner.stack}}),n},F(R,bt);export{Un as Dexie,kt as Entity,Bn as RangeSet,Et as cmp,Un as default,Yn as liveQuery,Rn as mergeRanges,Fn as rangesOverlap};
2
+ //# sourceMappingURL=dexie.min.mjs.map
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-alpha.7, Wed Jan 25 2023
7
+ * Version 4.0.1-alpha.8, Fri Feb 17 2023
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1242,7 +1242,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1242
1242
  }
1243
1243
  }
1244
1244
 
1245
- const DEXIE_VERSION = '4.0.1-alpha.7';
1245
+ const DEXIE_VERSION = '4.0.1-alpha.8';
1246
1246
  const maxString = String.fromCharCode(65535);
1247
1247
  const minKey = -Infinity;
1248
1248
  const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexie",
3
- "version": "4.0.1-alpha.7",
3
+ "version": "4.0.1-alpha.8",
4
4
  "description": "A Minimalistic Wrapper for IndexedDB",
5
5
  "main": "dist/dexie.js",
6
6
  "module": "dist/dexie.mjs",
@@ -86,10 +86,10 @@
86
86
  "node tools/replaceVersionAndDate.js dist/dexie.d.ts",
87
87
  "# Minify the default ES5 UMD module",
88
88
  "cd dist",
89
- "uglifyjs dexie.js -m -c negate_iife=0 -o dexie.min.js --source-map",
89
+ "uglifyjs dexie.js -m -c negate_iife=0 -o dexie.min.js --source-map url=dexie.min.js.map",
90
90
  "# Minify modern bundle",
91
91
  "cd modern",
92
- "terser --comments false --compress --mangle --module --source-map -o dexie.min.mjs -- dexie.mjs"
92
+ "terser --comments false --compress --mangle --module --source-map url=dexie.min.mjs.map -o dexie.min.mjs -- dexie.mjs"
93
93
  ],
94
94
  "dev": [
95
95
  "# Build ES5 module and the tests",