this.BX=this.BX||{};(function(e){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var n=function e(){n=Object.assign||function e(n){for(var t,r=1,i=arguments.length;r=0){n=e}else{var i=u(e);n=i===Object.prototype?{}:Object.create(i);j&&j.set(e,n);for(var o in e){if(c(e,o)){n[o]=D(e[o])}}}return n}var B={}.toString;function T(e){return B.call(e).slice(8,-1)}var R=typeof Symbol!=="undefined"?Symbol.iterator:"@@iterator";var F=babelHelpers["typeof"](R)==="symbol"?function(e){var n;return e!=null&&(n=e[R])&&n.apply(e)}:function(){return null};var M={};function N(e){var n,t,r,i;if(arguments.length===1){if(a(e))return e.slice();if(this===M&&typeof e==="string")return[e];if(i=F(e)){t=[];while(r=i.next(),!r.done){t.push(r.value)}return t}if(e==null)return[e];n=e.length;if(typeof n==="number"){t=new Array(n);while(n--){t[n]=e[n]}return t}return[e]}n=arguments.length;t=new Array(n);while(n--){t[n]=arguments[n]}return t}var q=typeof Symbol!=="undefined"?function(e){return e[Symbol.toStringTag]==="AsyncFunction"}:function(){return false};var U=typeof location!=="undefined"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function H(e,n){U=e;L=n}var L=function e(){return true};var V=!new Error("").stack;function W(){if(V)try{throw new Error}catch(e){return e}return new Error}function Y(e,n){var t=e.stack;if(!t)return"";n=n||0;if(t.indexOf(e.name)===0)n+=(e.name+e.message).split("\n").length;return t.split("\n").slice(n).filter(L).map((function(e){return"\n"+e})).join("")}var z=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"];var X=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"];var G=z.concat(X);var Q={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 J(e,n){this._e=W();this.name=e;this.message=n}d(J).from(Error).extend({stack:{get:function e(){return this._stack||(this._stack=this.name+": "+this.message+Y(this._e,2))}},toString:function e(){return this.name+": "+this.message}});function $(e,n){return e+". Errors: "+Object.keys(n).map((function(e){return n[e].toString()})).filter((function(e,n,t){return t.indexOf(e)===n})).join("\n")}function Z(e,n,t,r){this._e=W();this.failures=n;this.failedKeys=r;this.successCount=t;this.message=$(e,n)}d(Z).from(J);function ee(e,n){this._e=W();this.name="BulkError";this.failures=Object.keys(n).map((function(e){return n[e]}));this.failuresByPos=n;this.message=$(e,n)}d(ee).from(J);var ne=G.reduce((function(e,n){return e[n]=n+"Error",e}),{});var te=J;var re=G.reduce((function(e,n){var t=n+"Error";function r(e,r){this._e=W();this.name=t;if(!e){this.message=Q[n]||t;this.inner=null}else if(typeof e==="string"){this.message=""+e+(!r?"":"\n "+r);this.inner=r||null}else if(babelHelpers["typeof"](e)==="object"){this.message=e.name+" "+e.message;this.inner=e}}d(r).from(te);e[n]=r;return e}),{});re.Syntax=SyntaxError;re.Type=TypeError;re.Range=RangeError;var ie=X.reduce((function(e,n){e[n+"Error"]=re[n];return e}),{});function ae(e,n){if(!e||e instanceof J||e instanceof TypeError||e instanceof SyntaxError||!e.name||!ie[e.name])return e;var t=new ie[e.name](n||e.message,e);if("stack"in e){h(t,"stack",{get:function e(){return this.inner.stack}})}return t}var oe=G.reduce((function(e,n){if(["Syntax","Type","Range"].indexOf(n)===-1)e[n+"Error"]=re[n];return e}),{});oe.ModifyError=Z;oe.DexieError=J;oe.BulkError=ee;function ue(){}function se(e){return e}function ce(e,n){if(e==null||e===se)return n;return function(t){return n(e(t))}}function fe(e,n){return function(){e.apply(this,arguments);n.apply(this,arguments)}}function le(e,n){if(e===ue)return n;return function(){var t=e.apply(this,arguments);if(t!==undefined)arguments[0]=t;var r=this.onsuccess,i=this.onerror;this.onsuccess=null;this.onerror=null;var a=n.apply(this,arguments);if(r)this.onsuccess=this.onsuccess?fe(r,this.onsuccess):r;if(i)this.onerror=this.onerror?fe(i,this.onerror):i;return a!==undefined?a:t}}function he(e,n){if(e===ue)return n;return function(){e.apply(this,arguments);var t=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null;n.apply(this,arguments);if(t)this.onsuccess=this.onsuccess?fe(t,this.onsuccess):t;if(r)this.onerror=this.onerror?fe(r,this.onerror):r}}function de(e,n){if(e===ue)return n;return function(t){var r=e.apply(this,arguments);o(t,r);var i=this.onsuccess,a=this.onerror;this.onsuccess=null;this.onerror=null;var u=n.apply(this,arguments);if(i)this.onsuccess=this.onsuccess?fe(i,this.onsuccess):i;if(a)this.onerror=this.onerror?fe(a,this.onerror):a;return r===undefined?u===undefined?undefined:u:o(r,u)}}function ve(e,n){if(e===ue)return n;return function(){if(n.apply(this,arguments)===false)return false;return e.apply(this,arguments)}}function pe(e,n){if(e===ue)return n;return function(){var t=e.apply(this,arguments);if(t&&typeof t.then==="function"){var r=this,i=arguments.length,a=new Array(i);while(i--){a[i]=arguments[i]}return t.then((function(){return n.apply(r,a)}))}return n.apply(this,arguments)}}var ye={};var me=100,be=20,ge=100,we=typeof Promise==="undefined"?[]:function(){var e=Promise.resolve();if(typeof crypto==="undefined"||!crypto.subtle)return[e,u(e),e];var n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,u(n),e]}(),_e=we[0],xe=we[1],ke=we[2],Ee=xe&&xe.then;var Pe=_e&&_e.constructor;var Ke=!!ke;var Oe=false;var Se=ke?function(){ke.then(Je)}:r.setImmediate?setImmediate.bind(null,Je):r.MutationObserver?function(){var e=document.createElement("div");new MutationObserver((function(){Je();e=null})).observe(e,{attributes:true});e.setAttribute("i","1")}:function(){setTimeout(Je,0)};var Ae=function e(n,t){Me.push([n,t]);if(je){Se();je=false}};var Ce=true,je=true,Ie=[],De=[],Be=null,Te=se;var Re={id:"global",global:true,ref:0,unhandleds:[],onunhandled:Kn,pgp:false,env:{},finalize:function e(){this.unhandleds.forEach((function(e){try{Kn(e[0],e[1])}catch(e){}}))}};var Fe=Re;var Me=[];var Ne=0;var qe=[];function Ue(e){if(babelHelpers["typeof"](this)!=="object")throw new TypeError("Promises must be constructed via new");this._listeners=[];this.onuncatched=ue;this._lib=false;var n=this._PSD=Fe;if(U){this._stackHolder=W();this._prev=null;this._numPrev=0}if(typeof e!=="function"){if(e!==ye)throw new TypeError("Not a function");this._state=arguments[1];this._value=arguments[2];if(this._state===false)We(this,this._value);return}this._state=null;this._value=null;++n.ref;Ve(this,e)}var He={get:function e(){var n=Fe,t=ln;function r(e,r){var i=this;var a=!n.global&&(n!==Fe||t!==ln);var o=a&&!pn();var u=new Ue((function(t,u){ze(i,new Le(kn(e,n,a,o),kn(r,n,a,o),t,u,n))}));U&&Qe(u,this);return u}r.prototype=ye;return r},set:function e(n){h(this,"then",n&&n.prototype===ye?He:{get:function e(){return n},set:He.set})}};f(Ue.prototype,{then:He,_then:function e(n,t){ze(this,new Le(null,null,n,t,Fe))},catch:function e(n){if(arguments.length===1)return this.then(null,n);var t=arguments[0],r=arguments[1];return typeof t==="function"?this.then(null,(function(e){return e instanceof t?r(e):an(e)})):this.then(null,(function(e){return e&&e.name===t?r(e):an(e)}))},finally:function e(n){return this.then((function(e){n();return e}),(function(e){n();return an(e)}))},stack:{get:function e(){if(this._stack)return this._stack;try{Oe=true;var n=Ge(this,[],be);var t=n.join("\nFrom previous: ");if(this._state!==null)this._stack=t;return t}finally{Oe=false}}},timeout:function e(n,t){var r=this;return n0){e=Me;Me=[];t=e.length;for(n=0;n0);Ce=true;je=true}function en(){var e=Ie;Ie=[];e.forEach((function(e){e._PSD.onunhandled.call(null,e._value,e)}));var n=qe.slice(0);var t=n.length;while(t){n[--t]()}}function nn(e){function n(){e();qe.splice(qe.indexOf(n),1)}qe.push(n);++Ne;Ae((function(){if(--Ne===0)en()}),[])}function tn(e){if(!Ie.some((function(n){return n._value===e._value})))Ie.push(e)}function rn(e){var n=Ie.length;while(n){if(Ie[--n]._value===e._value){Ie.splice(n,1);return}}}function an(e){return new Ue(ye,false,e)}function on(e,n){var t=Fe;return function(){var r=$e(),i=Fe;try{gn(t,true);return e.apply(this,arguments)}catch(e){n&&n(e)}finally{gn(i,false);if(r)Ze()}}}var un={awaits:0,echoes:0,id:0};var sn=0;var cn=[];var fn=0;var ln=0;var hn=0;function dn(e,n,t,r){var i=Fe,a=Object.create(i);a.parent=i;a.ref=0;a.global=false;a.id=++hn;var u=Re.env;a.env=Ke?{Promise:Ue,PromiseProp:{value:Ue,configurable:true,writable:true},all:Ue.all,race:Ue.race,allSettled:Ue.allSettled,any:Ue.any,resolve:Ue.resolve,reject:Ue.reject,nthen:En(u.nthen,a),gthen:En(u.gthen,a)}:{};if(n)o(a,n);++i.ref;a.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=_n(a,e,t,r);if(a.ref===0)a.finalize();return s}function vn(){if(!un.id)un.id=++sn;++un.awaits;un.echoes+=ge;return un.id}function pn(){if(!un.awaits)return false;if(--un.awaits===0)un.id=0;un.echoes=un.awaits*ge;return true}if((""+Ee).indexOf("[native code]")===-1){vn=pn=ue}function yn(e){if(un.echoes&&e&&e.constructor===Pe){vn();return e.then((function(e){pn();return e}),(function(e){pn();return On(e)}))}return e}function mn(e){++ln;if(!un.echoes||--un.echoes===0){un.echoes=un.id=0}cn.push(Fe);gn(e,true)}function bn(){var e=cn[cn.length-1];cn.pop();gn(e,false)}function gn(e,n){var t=Fe;if(n?un.echoes&&(!fn++||e!==Fe):fn&&(!--fn||e!==Fe)){xn(n?mn.bind(null,e):bn)}if(e===Fe)return;Fe=e;if(t===Re)Re.env=wn();if(Ke){var i=Re.env.Promise;var a=e.env;xe.then=a.nthen;i.prototype.then=a.gthen;if(t.global||e.global){Object.defineProperty(r,"Promise",a.PromiseProp);i.all=a.all;i.race=a.race;i.resolve=a.resolve;i.reject=a.reject;if(a.allSettled)i.allSettled=a.allSettled;if(a.any)i.any=a.any}}}function wn(){var e=r.Promise||Promise;return Ke?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(r,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:xe.then,gthen:e.prototype.then}:{}}function _n(e,n,t,r,i){var a=Fe;try{gn(e,true);return n(t,r,i)}finally{gn(a,false)}}function xn(e){Ee.call(_e,e)}function kn(e,n,t,r){return typeof e!=="function"?e:function(){var i=Fe;if(t)vn();gn(n,true);try{return e.apply(this,arguments)}finally{gn(i,false);if(r)xn(pn)}}}function En(e,n){return function(t,r){return e.call(this,kn(t,n),kn(r,n))}}var Pn="unhandledrejection";function Kn(e,n){var t;try{t=n.onuncatched(e)}catch(e){}if(t!==false)try{var i,a={promise:n,reason:e};if(r.document&&document.createEvent){i=document.createEvent("Event");i.initEvent(Pn,true,true);o(i,a)}else if(r.CustomEvent){i=new CustomEvent(Pn,{detail:a});o(i,a)}if(i&&r.dispatchEvent){dispatchEvent(i);if(!r.PromiseRejectionEvent&&r.onunhandledrejection)try{r.onunhandledrejection(i)}catch(e){}}if(U&&i&&!i.defaultPrevented){console.warn("Unhandled rejection: "+(e.stack||e))}}catch(e){}}var On=Ue.reject;function Sn(e,n,t,r){if(!e.idbdb||!e._state.openComplete&&!Fe.letThrough&&!e._vip){if(e._state.openComplete){return On(new re.DatabaseClosed(e._state.dbOpenError))}if(!e._state.isBeingOpened){if(!e._options.autoOpen)return On(new re.DatabaseClosed);e.open()["catch"](ue)}return e._state.dbReadyPromise.then((function(){return Sn(e,n,t,r)}))}else{var i=e._createTransaction(n,t,e._dbSchema);try{i.create();e._state.PR1398_maxLoop=3}catch(i){if(i.name===ne.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0){console.warn("Dexie: Need to reopen db");e._close();return e.open().then((function(){return Sn(e,n,t,r)}))}return On(i)}return i._promise(n,(function(e,n){return dn((function(){Fe.trans=i;return r(e,n,i)}))})).then((function(e){return i._completion.then((function(){return e}))}))}}var An="3.2.2";var Cn=String.fromCharCode(65535);var jn=-Infinity;var In="Invalid key provided. Keys must be of type string, number, Date or Array.";var Dn="String expected.";var Bn=[];var Tn=typeof navigator!=="undefined"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent);var Rn=Tn;var Fn=Tn;var Mn=function e(n){return!/(dexie\.js|dexie\.min\.js)/.test(n)};var Nn="__dbnames";var qn="readonly";var Un="readwrite";function Hn(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}var Ln={type:3,lower:-Infinity,lowerOpen:false,upper:[[]],upperOpen:false};function Vn(e){return typeof e==="string"&&!/\./.test(e)?function(n){if(n[e]===undefined&&e in n){n=I(n);delete n[e]}return n}:function(e){return e}}var Wn=function(){function e(){}e.prototype._trans=function(e,n,t){var r=this._tx||Fe.trans;var i=this.name;function a(e,t,r){if(!r.schema[i])throw new re.NotFound("Table "+i+" not part of transaction");return n(r.idbtrans,r)}var o=$e();try{return r&&r.db===this.db?r===Fe.trans?r._promise(e,a,t):dn((function(){return r._promise(e,a,t)}),{trans:r,transless:Fe.transless||Fe}):Sn(this.db,e,[this.name],a)}finally{if(o)Ze()}};e.prototype.get=function(e,n){var t=this;if(e&&e.constructor===Object)return this.where(e).first(n);return this._trans("readonly",(function(n){return t.core.get({trans:n,key:e}).then((function(e){return t.hook.reading.fire(e)}))})).then(n)};e.prototype.where=function(e){if(typeof e==="string")return new this.db.WhereClause(this,e);if(a(e))return new this.db.WhereClause(this,"["+e.join("+")+"]");var n=i(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);var t=this.schema.indexes.concat(this.schema.primKey).filter((function(e){return e.compound&&n.every((function(n){return e.keyPath.indexOf(n)>=0}))&&e.keyPath.every((function(e){return n.indexOf(e)>=0}))}))[0];if(t&&this.db._maxKey!==Cn)return this.where(t.name).equals(t.keyPath.map((function(n){return e[n]})));if(!t&&U)console.warn("The query "+JSON.stringify(e)+" on "+this.name+" would benefit of a "+("compound index ["+n.join("+")+"]"));var r=this.schema.idxByName;var o=this.db._deps.indexedDB;function u(e,n){try{return o.cmp(e,n)===0}catch(e){return false}}var s=n.reduce((function(n,t){var i=n[0],o=n[1];var s=r[t];var c=e[t];return[i||s,i||!s?Hn(o,s&&s.multi?function(e){var n=k(e,t);return a(n)&&n.some((function(e){return u(c,e)}))}:function(e){return u(c,k(e,t))}):o]}),[null,null]),c=s[0],f=s[1];return c?this.where(c.name).equals(e[c.keyPath]).filter(f):t?this.filter(f):this.where(n).equals("")};e.prototype.filter=function(e){return this.toCollection().and(e)};e.prototype.count=function(e){return this.toCollection().count(e)};e.prototype.offset=function(e){return this.toCollection().offset(e)};e.prototype.limit=function(e){return this.toCollection().limit(e)};e.prototype.each=function(e){return this.toCollection().each(e)};e.prototype.toArray=function(e){return this.toCollection().toArray(e)};e.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))};e.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,a(e)?"["+e.join("+")+"]":e))};e.prototype.reverse=function(){return this.toCollection().reverse()};e.prototype.mapToClass=function(e){this.schema.mappedClass=e;var n=function n(t){if(!t)return t;var r=Object.create(e.prototype);for(var i in t){if(c(t,i))try{r[i]=t[i]}catch(e){}}return r};if(this.schema.readHook){this.hook.reading.unsubscribe(this.schema.readHook)}this.schema.readHook=n;this.hook("reading",n);return e};e.prototype.defineClass=function(){function e(e){o(this,e)}return this.mapToClass(e)};e.prototype.add=function(e,n){var t=this;var r=this.schema.primKey,i=r.auto,a=r.keyPath;var o=e;if(a&&i){o=Vn(a)(e)}return this._trans("readwrite",(function(e){return t.core.mutate({trans:e,type:"add",keys:n!=null?[n]:null,values:[o]})})).then((function(e){return e.numFailures?Ue.reject(e.failures[0]):e.lastResult})).then((function(n){if(a){try{E(e,a,n)}catch(e){}}return n}))};e.prototype.update=function(e,n){if(babelHelpers["typeof"](e)==="object"&&!a(e)){var t=k(e,this.schema.primKey.keyPath);if(t===undefined)return On(new re.InvalidArgument("Given object does not contain its primary key"));try{if(typeof n!=="function"){i(n).forEach((function(t){E(e,t,n[t])}))}else{n(e,{value:e,primKey:t})}}catch(e){}return this.where(":id").equals(t).modify(n)}else{return this.where(":id").equals(e).modify(n)}};e.prototype.put=function(e,n){var t=this;var r=this.schema.primKey,i=r.auto,a=r.keyPath;var o=e;if(a&&i){o=Vn(a)(e)}return this._trans("readwrite",(function(e){return t.core.mutate({trans:e,type:"put",values:[o],keys:n!=null?[n]:null})})).then((function(e){return e.numFailures?Ue.reject(e.failures[0]):e.lastResult})).then((function(n){if(a){try{E(e,a,n)}catch(e){}}return n}))};e.prototype["delete"]=function(e){var n=this;return this._trans("readwrite",(function(t){return n.core.mutate({trans:t,type:"delete",keys:[e]})})).then((function(e){return e.numFailures?Ue.reject(e.failures[0]):undefined}))};e.prototype.clear=function(){var e=this;return this._trans("readwrite",(function(n){return e.core.mutate({trans:n,type:"deleteRange",range:Ln})})).then((function(e){return e.numFailures?Ue.reject(e.failures[0]):undefined}))};e.prototype.bulkGet=function(e){var n=this;return this._trans("readonly",(function(t){return n.core.getMany({keys:e,trans:t}).then((function(e){return e.map((function(e){return n.hook.reading.fire(e)}))}))}))};e.prototype.bulkAdd=function(e,n,t){var r=this;var i=Array.isArray(n)?n:undefined;t=t||(i?undefined:n);var a=t?t.allKeys:undefined;return this._trans("readwrite",(function(n){var t=r.schema.primKey,o=t.auto,u=t.keyPath;if(u&&i)throw new re.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new re.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length;var c=u&&o?e.map(Vn(u)):e;return r.core.mutate({trans:n,type:"add",keys:i,values:c,wantResults:a}).then((function(e){var n=e.numFailures,t=e.results,i=e.lastResult,o=e.failures;var u=a?t:i;if(n===0)return u;throw new ee(r.name+".bulkAdd(): "+n+" of "+s+" operations failed",o)}))}))};e.prototype.bulkPut=function(e,n,t){var r=this;var i=Array.isArray(n)?n:undefined;t=t||(i?undefined:n);var a=t?t.allKeys:undefined;return this._trans("readwrite",(function(n){var t=r.schema.primKey,o=t.auto,u=t.keyPath;if(u&&i)throw new re.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new re.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length;var c=u&&o?e.map(Vn(u)):e;return r.core.mutate({trans:n,type:"put",keys:i,values:c,wantResults:a}).then((function(e){var n=e.numFailures,t=e.results,i=e.lastResult,o=e.failures;var u=a?t:i;if(n===0)return u;throw new ee(r.name+".bulkPut(): "+n+" of "+s+" operations failed",o)}))}))};e.prototype.bulkDelete=function(e){var n=this;var t=e.length;return this._trans("readwrite",(function(t){return n.core.mutate({trans:t,type:"delete",keys:e})})).then((function(e){var r=e.numFailures,i=e.lastResult,a=e.failures;if(r===0)return i;throw new ee(n.name+".bulkDelete(): "+r+" of "+t+" operations failed",a)}))};return e}();function Yn(e){var n={};var t=function t(r,i){if(i){var a=arguments.length,o=new Array(a-1);while(--a){o[a-1]=arguments[a]}n[r].subscribe.apply(null,o);return e}else if(typeof r==="string"){return n[r]}};t.addEventType=u;for(var r=1,o=arguments.length;rn?1:er?o:0}return this.toArray((function(e){return e.sort(u)})).then(n)};e.prototype.toArray=function(e){var n=this;return this._read((function(e){var t=n._ctx;if(t.dir==="next"&&Gn(t,true)&&t.limit>0){var r=t.valueMapper;var i=Zn(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:true,query:{index:i,range:t.range}}).then((function(e){var n=e.result;return r?n.map(r):n}))}else{var a=[];return nt(t,(function(e){return a.push(e)}),e,t.table.core).then((function(){return a}))}}),e)};e.prototype.offset=function(e){var n=this._ctx;if(e<=0)return this;n.offset+=e;if(Gn(n)){Jn(n,(function(){var n=e;return function(e,t){if(n===0)return true;if(n===1){--n;return false}t((function(){e.advance(n);n=0}));return false}}))}else{Jn(n,(function(){var n=e;return function(){return--n<0}}))}return this};e.prototype.limit=function(e){this._ctx.limit=Math.min(this._ctx.limit,e);Jn(this._ctx,(function(){var n=e;return function(e,t,r){if(--n<=0)t(r);return n>=0}}),true);return this};e.prototype.until=function(e,n){Qn(this._ctx,(function(t,r,i){if(e(t.value)){r(i);return n}else{return true}}));return this};e.prototype.first=function(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)};e.prototype.last=function(e){return this.reverse().first(e)};e.prototype.filter=function(e){Qn(this._ctx,(function(n){return e(n.value)}));$n(this._ctx,e);return this};e.prototype.and=function(e){return this.filter(e)};e.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)};e.prototype.reverse=function(){this._ctx.dir=this._ctx.dir==="prev"?"next":"prev";if(this._ondirectionchange)this._ondirectionchange(this._ctx.dir);return this};e.prototype.desc=function(){return this.reverse()};e.prototype.eachKey=function(e){var n=this._ctx;n.keysOnly=!n.isMatch;return this.each((function(n,t){e(t.key,t)}))};e.prototype.eachUniqueKey=function(e){this._ctx.unique="unique";return this.eachKey(e)};e.prototype.eachPrimaryKey=function(e){var n=this._ctx;n.keysOnly=!n.isMatch;return this.each((function(n,t){e(t.primaryKey,t)}))};e.prototype.keys=function(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each((function(e,n){t.push(n.key)})).then((function(){return t})).then(e)};e.prototype.primaryKeys=function(e){var n=this._ctx;if(n.dir==="next"&&Gn(n,true)&&n.limit>0){return this._read((function(e){var t=Zn(n,n.table.core.schema);return n.table.core.query({trans:e,values:false,limit:n.limit,query:{index:t,range:n.range}})})).then((function(e){var n=e.result;return n})).then(e)}n.keysOnly=!n.isMatch;var t=[];return this.each((function(e,n){t.push(n.primaryKey)})).then((function(){return t})).then(e)};e.prototype.uniqueKeys=function(e){this._ctx.unique="unique";return this.keys(e)};e.prototype.firstKey=function(e){return this.limit(1).keys((function(e){return e[0]})).then(e)};e.prototype.lastKey=function(e){return this.reverse().firstKey(e)};e.prototype.distinct=function(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var t={};Qn(this._ctx,(function(e){var n=e.primaryKey.toString();var r=c(t,n);t[n]=true;return!r}));return this};e.prototype.modify=function(e){var n=this;var t=this._ctx;return this._write((function(r){var a;if(typeof e==="function"){a=e}else{var o=i(e);var u=o.length;a=function n(t){var r=false;for(var i=0;i0&&s.mutate({trans:r,type:"add",values:d}).then((function(e){for(var n in e.failures){m.splice(parseInt(n),1)}y(d.length,e)}))).then((function(){return(v.length>0||_&&babelHelpers["typeof"](e)==="object")&&s.mutate({trans:r,type:"put",keys:p,values:v,criteria:_,changeSpec:typeof e!=="function"&&e}).then((function(e){return y(v.length,e)}))})).then((function(){return(m.length>0||_&&e===ct)&&s.mutate({trans:r,type:"delete",keys:m,criteria:_}).then((function(e){return y(m.length,e)}))})).then((function(){return n.length>o+u&&i(o+h)}))}))};return i(0).then((function(){if(d.length>0)throw new Z("Error modifying one or more objects",d,v,p);return n.length}))}))}))};e.prototype["delete"]=function(){var e=this._ctx,n=e.range;if(Gn(e)&&(e.isPrimKey&&!Fn||n.type===3)){return this._write((function(t){var r=e.table.core.schema.primaryKey;var i=n;return e.table.core.count({trans:t,query:{index:r,range:i}}).then((function(n){return e.table.core.mutate({trans:t,type:"deleteRange",range:i}).then((function(e){var t=e.failures;e.lastResult;e.results;var r=e.numFailures;if(r)throw new Z("Could not delete some values",Object.keys(t).map((function(e){return t[e]})),n-r);return n-r}))}))}))}return this.modify(ct)};return e}();var ct=function e(n,t){return t.value=null};function ft(e){return zn(st.prototype,(function n(t,r){this.db=e;var i=Ln,a=null;if(r)try{i=r()}catch(e){a=e}var o=t._ctx;var u=o.table;var s=u.hook.reading.fire;this._ctx={table:u,index:o.index,isPrimKey:!o.index||u.schema.primKey.keyPath&&o.index===u.schema.primKey.name,range:i,keysOnly:false,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:true,isMatch:null,offset:0,limit:Infinity,error:a,or:o.or,valueMapper:s!==se?s:null}}))}function lt(e,n){return en?-1:e===n?0:1}function dt(e,n,t){var r=e instanceof _t?new e.Collection(e):e;r._ctx.error=t?new t(n):new TypeError(n);return r}function vt(e){return new e.Collection(e,(function(){return wt("")})).limit(0)}function pt(e){return e==="next"?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()}}function yt(e){return e==="next"?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()}}function mt(e,n,t,r,i,a){var o=Math.min(e.length,r.length);var u=-1;for(var s=0;s=0)return e.substr(0,u)+n[u]+t.substr(u+1);return null}if(i(e[s],c)<0)u=s}if(o0){d=y}}if(d!==null){t((function(){e["continue"](d+f)}))}else{t(r)}return false}}));return d}function gt(e,n,t,r){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:r}}function wt(e){return{type:1,lower:e,upper:e}}var _t=function(){function e(){}Object.defineProperty(e.prototype,"Collection",{get:function e(){return this._ctx.table.db.Collection},enumerable:false,configurable:true});e.prototype.between=function(e,n,t,r){t=t!==false;r=r===true;try{if(this._cmp(e,n)>0||this._cmp(e,n)===0&&(t||r)&&!(t&&r))return vt(this);return new this.Collection(this,(function(){return gt(e,n,!t,!r)}))}catch(e){return dt(this,In)}};e.prototype.equals=function(e){if(e==null)return dt(this,In);return new this.Collection(this,(function(){return wt(e)}))};e.prototype.above=function(e){if(e==null)return dt(this,In);return new this.Collection(this,(function(){return gt(e,undefined,true)}))};e.prototype.aboveOrEqual=function(e){if(e==null)return dt(this,In);return new this.Collection(this,(function(){return gt(e,undefined,false)}))};e.prototype.below=function(e){if(e==null)return dt(this,In);return new this.Collection(this,(function(){return gt(undefined,e,false,true)}))};e.prototype.belowOrEqual=function(e){if(e==null)return dt(this,In);return new this.Collection(this,(function(){return gt(undefined,e)}))};e.prototype.startsWith=function(e){if(typeof e!=="string")return dt(this,Dn);return this.between(e,e+Cn,true,true)};e.prototype.startsWithIgnoreCase=function(e){if(e==="")return this.startsWith(e);return bt(this,(function(e,n){return e.indexOf(n[0])===0}),[e],Cn)};e.prototype.equalsIgnoreCase=function(e){return bt(this,(function(e,n){return e===n[0]}),[e],"")};e.prototype.anyOfIgnoreCase=function(){var e=N.apply(M,arguments);if(e.length===0)return vt(this);return bt(this,(function(e,n){return n.indexOf(e)!==-1}),e,"")};e.prototype.startsWithAnyOfIgnoreCase=function(){var e=N.apply(M,arguments);if(e.length===0)return vt(this);return bt(this,(function(e,n){return n.some((function(n){return e.indexOf(n)===0}))}),e,Cn)};e.prototype.anyOf=function(){var e=this;var n=N.apply(M,arguments);var t=this._cmp;try{n.sort(t)}catch(e){return dt(this,In)}if(n.length===0)return vt(this);var r=new this.Collection(this,(function(){return gt(n[0],n[n.length-1])}));r._ondirectionchange=function(r){t=r==="next"?e._ascending:e._descending;n.sort(t)};var i=0;r._addAlgorithm((function(e,r,a){var o=e.key;while(t(o,n[i])>0){++i;if(i===n.length){r(a);return false}}if(t(o,n[i])===0){return true}else{r((function(){e["continue"](n[i])}));return false}}));return r};e.prototype.notEqual=function(e){return this.inAnyRange([[jn,e],[e,this.db._maxKey]],{includeLowers:false,includeUppers:false})};e.prototype.noneOf=function(){var e=N.apply(M,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return dt(this,In)}var n=e.reduce((function(e,n){return e?e.concat([[e[e.length-1][1],n]]):[[jn,n]]}),null);n.push([e[e.length-1],this.db._maxKey]);return this.inAnyRange(n,{includeLowers:false,includeUppers:false})};e.prototype.inAnyRange=function(e,n){var t=this;var r=this._cmp,i=this._ascending,a=this._descending,o=this._min,u=this._max;if(e.length===0)return vt(this);if(!e.every((function(e){return e[0]!==undefined&&e[1]!==undefined&&i(e[0],e[1])<=0}))){return dt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",re.InvalidArgument)}var s=!n||n.includeLowers!==false;var c=n&&n.includeUppers===true;function f(e,n){var t=0,i=e.length;for(;t0){a[0]=o(a[0],n[0]);a[1]=u(a[1],n[1]);break}}if(t===i)e.push(n);return e}var l=i;function h(e,n){return l(e[0],n[0])}var d;try{d=e.reduce(f,[]);d.sort(h)}catch(e){return dt(this,In)}var v=0;var p=c?function(e){return i(e,d[v][1])>0}:function(e){return i(e,d[v][1])>=0};var y=s?function(e){return a(e,d[v][0])>0}:function(e){return a(e,d[v][0])>=0};function m(e){return!p(e)&&!y(e)}var b=p;var g=new this.Collection(this,(function(){return gt(d[0][0],d[d.length-1][1],!s,!c)}));g._ondirectionchange=function(e){if(e==="next"){b=p;l=i}else{b=y;l=a}d.sort(h)};g._addAlgorithm((function(e,n,r){var a=e.key;while(b(a)){++v;if(v===d.length){n(r);return false}}if(m(a)){return true}else if(t._cmp(a,d[v][1])===0||t._cmp(a,d[v][0])===0){return false}else{n((function(){if(l===i)e["continue"](d[v][0]);else e["continue"](d[v][1])}));return false}}));return g};e.prototype.startsWithAnyOf=function(){var e=N.apply(M,arguments);if(!e.every((function(e){return typeof e==="string"}))){return dt(this,"startsWithAnyOf() only works with strings")}if(e.length===0)return vt(this);return this.inAnyRange(e.map((function(e){return[e,e+Cn]})))};return e}();function xt(e){return zn(_t.prototype,(function n(t,r,i){this.db=e;this._ctx={table:t,index:r===":id"?null:r,or:i};var a=e._deps.indexedDB;if(!a)throw new re.MissingAPI;this._cmp=this._ascending=a.cmp.bind(a);this._descending=function(e,n){return a.cmp(n,e)};this._max=function(e,n){return a.cmp(e,n)>0?e:n};this._min=function(e,n){return a.cmp(e,n)<0?e:n};this._IDBKeyRange=e._deps.IDBKeyRange}))}function kt(e){return on((function(n){Et(n);e(n.target.error);return false}))}function Et(e){if(e.stopPropagation)e.stopPropagation();if(e.preventDefault)e.preventDefault()}var Pt="storagemutated";var Kt="x-storagemutated-1";var Ot=Yn(null,Pt);var St=function(){function e(){}e.prototype._lock=function(){g(!Fe.global);++this._reculock;if(this._reculock===1&&!Fe.global)Fe.lockOwnerFor=this;return this};e.prototype._unlock=function(){g(!Fe.global);if(--this._reculock===0){if(!Fe.global)Fe.lockOwnerFor=null;while(this._blockedFuncs.length>0&&!this._locked()){var e=this._blockedFuncs.shift();try{_n(e[1],e[0])}catch(e){}}}return this};e.prototype._locked=function(){return this._reculock&&Fe.lockOwnerFor!==this};e.prototype.create=function(e){var n=this;if(!this.mode)return this;var t=this.db.idbdb;var r=this.db._state.dbOpenError;g(!this.idbtrans);if(!e&&!t){switch(r&&r.name){case"DatabaseClosedError":throw new re.DatabaseClosed(r);case"MissingAPIError":throw new re.MissingAPI(r.message,r);default:throw new re.OpenFailed(r)}}if(!this.active)throw new re.TransactionInactive;g(this._completion._state===null);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}));e.onerror=on((function(t){Et(t);n._reject(e.error)}));e.onabort=on((function(t){Et(t);n.active&&n._reject(new re.Abort(e.error));n.active=false;n.on("abort").fire(t)}));e.oncomplete=on((function(){n.active=false;n._resolve();if("mutatedParts"in e){Ot.storagemutated.fire(e["mutatedParts"])}}));return this};e.prototype._promise=function(e,n,t){var r=this;if(e==="readwrite"&&this.mode!=="readwrite")return On(new re.ReadOnly("Transaction is readonly"));if(!this.active)return On(new re.TransactionInactive);if(this._locked()){return new Ue((function(i,a){r._blockedFuncs.push([function(){r._promise(e,n,t).then(i,a)},Fe])}))}else if(t){return dn((function(){var e=new Ue((function(e,t){r._lock();var i=n(e,t,r);if(i&&i.then)i.then(e,t)}));e["finally"]((function(){return r._unlock()}));e._lib=true;return e}))}else{var i=new Ue((function(e,t){var i=n(e,t,r);if(i&&i.then)i.then(e,t)}));i._lib=true;return i}};e.prototype._root=function(){return this.parent?this.parent._root():this};e.prototype.waitFor=function(e){var n=this._root();var t=Ue.resolve(e);if(n._waitingFor){n._waitingFor=n._waitingFor.then((function(){return t}))}else{n._waitingFor=t;n._waitingQueue=[];var r=n.idbtrans.objectStore(n.storeNames[0]);(function e(){++n._spinCount;while(n._waitingQueue.length){n._waitingQueue.shift()()}if(n._waitingFor)r.get(-Infinity).onsuccess=e})()}var i=n._waitingFor;return new Ue((function(e,r){t.then((function(t){return n._waitingQueue.push(on(e.bind(null,t)))}),(function(e){return n._waitingQueue.push(on(r.bind(null,e)))}))["finally"]((function(){if(n._waitingFor===i){n._waitingFor=null}}))}))};e.prototype.abort=function(){if(this.active){this.active=false;if(this.idbtrans)this.idbtrans.abort();this._reject(new re.Abort)}};e.prototype.table=function(e){var n=this._memoizedTables||(this._memoizedTables={});if(c(n,e))return n[e];var t=this.schema[e];if(!t){throw new re.NotFound("Table "+e+" not part of transaction")}var r=new this.db.Table(e,t,this);r.core=this.db.core.table(e);n[e]=r;return r};return e}();function At(e){return zn(St.prototype,(function n(t,r,i,a,o){var u=this;this.db=e;this.mode=t;this.storeNames=r;this.schema=i;this.chromeTransactionDurability=a;this.idbtrans=null;this.on=Yn(this,"complete","error","abort");this.parent=o||null;this.active=true;this._reculock=0;this._blockedFuncs=[];this._resolve=null;this._reject=null;this._waitingFor=null;this._waitingQueue=null;this._spinCount=0;this._completion=new Ue((function(e,n){u._resolve=e;u._reject=n}));this._completion.then((function(){u.active=false;u.on.complete.fire()}),(function(e){var n=u.active;u.active=false;u.on.error.fire(e);u.parent?u.parent._reject(e):n&&u.idbtrans&&u.idbtrans.abort();return On(e)}))}))}function Ct(e,n,t,r,i,a,o){return{name:e,keyPath:n,unique:t,multi:r,auto:i,compound:a,src:(t&&!o?"&":"")+(r?"*":"")+(i?"++":"")+jt(n)}}function jt(e){return typeof e==="string"?e:e?"["+[].join.call(e,"+")+"]":""}function It(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:_(t,(function(e){return[e.name,e]}))}}function Dt(e){return e.length===1?e[0]:e}var Bt=function e(n){try{n.only([[]]);Bt=function e(){return[[]]};return[[]]}catch(e){Bt=function e(){return Cn};return Cn}};function Tt(e){if(e==null){return function(){return undefined}}else if(typeof e==="string"){return Rt(e)}else{return function(n){return k(n,e)}}}function Rt(e){var n=e.split(".");if(n.length===1){return function(n){return n[e]}}else{return function(n){return k(n,e)}}}function Ft(e){return[].slice.call(e)}var Mt=0;function Nt(e){return e==null?":id":typeof e==="string"?e:"["+e.join("+")+"]"}function qt(e,n,t){function r(e,n){var t=Ft(e.objectStoreNames);return{schema:{name:e.name,tables:t.map((function(e){return n.objectStore(e)})).map((function(e){var n=e.keyPath,t=e.autoIncrement;var r=a(n);var i=n==null;var o={};var u={name:e.name,primaryKey:{name:null,isPrimaryKey:true,outbound:i,compound:r,keyPath:n,autoIncrement:t,unique:true,extractKey:Tt(n)},indexes:Ft(e.indexNames).map((function(n){return e.index(n)})).map((function(e){var n=e.name,t=e.unique,r=e.multiEntry,i=e.keyPath;var u=a(i);var s={name:n,compound:u,keyPath:i,unique:t,multiEntry:r,extractKey:Tt(i)};o[Nt(i)]=s;return s})),getIndexByKeyPath:function e(n){return o[Nt(n)]}};o[":id"]=u.primaryKey;if(n!=null){o[Nt(n)]=u.primaryKey}return u}))},hasGetAll:t.length>0&&"getAll"in n.objectStore(t[0])&&!(typeof navigator!=="undefined"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}function i(e){if(e.type===3)return null;if(e.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,r=e.upper,i=e.lowerOpen,a=e.upperOpen;var o=t===undefined?r===undefined?null:n.upperBound(r,!!a):r===undefined?n.lowerBound(t,!!i):n.bound(t,r,!!i,!!a);return o}function o(e){var n=e.name;function t(e){var t=e.trans,r=e.type,a=e.keys,o=e.values,u=e.range;return new Promise((function(e,s){e=on(e);var c=t.objectStore(n);var f=c.keyPath==null;var l=r==="put"||r==="add";if(!l&&r!=="delete"&&r!=="deleteRange")throw new Error("Invalid operation type: "+r);var h=(a||o||{length:1}).length;if(a&&o&&a.length!==o.length){throw new Error("Given keys array must have same length as given values array.")}if(h===0)return e({numFailures:0,failures:{},results:[],lastResult:undefined});var d;var v=[];var p=[];var y=0;var m=function e(n){++y;Et(n)};if(r==="deleteRange"){if(u.type===4)return e({numFailures:y,failures:p,results:[],lastResult:undefined});if(u.type===3)v.push(d=c.clear());else v.push(d=c["delete"](i(u)))}else{var b=l?f?[o,a]:[o,null]:[a,null],g=b[0],w=b[1];if(l){for(var _=0;_=n}));f.forEach((function(e){o.push((function(){var o=s;var u=e._cfg.dbschema;rr(a,o,r);rr(a,u,r);s=a._dbSchema=u;var f=Gt(o,u);f.add.forEach((function(e){Qt(r,e[0],e[1].primKey,e[1].indexes)}));f.change.forEach((function(e){if(e.recreate){throw new re.Upgrade("Not yet support for changing primary key")}else{var n=r.objectStore(e.name);e.add.forEach((function(e){return Zt(n,e)}));e.change.forEach((function(e){n.deleteIndex(e.name);Zt(n,e)}));e.del.forEach((function(e){return n.deleteIndex(e)}))}}));var l=e._cfg.contentUpgrade;if(l&&e._cfg.version>n){Lt(a,r);t._memoizedTables={};c=true;var h=K(u);f.del.forEach((function(e){h[e]=o[e]}));Wt(a,[a.Transaction.prototype]);Vt(a,[a.Transaction.prototype],i(h),h);t.schema=h;var d=q(l);if(d){vn()}var v;var p=Ue.follow((function(){v=l(t);if(v){if(d){var e=pn.bind(null,null);v.then(e,e)}}}));return v&&typeof v.then==="function"?Ue.resolve(v):p.then((function(){return v}))}}));o.push((function(n){if(!c||!Rn){var r=e._cfg.dbschema;$t(r,n)}Wt(a,[a.Transaction.prototype]);Vt(a,[a.Transaction.prototype],a._storeNames,a._dbSchema);t.schema=a._dbSchema}))}));function l(){return o.length?Ue.resolve(o.shift()(t.idbtrans)).then(l):Ue.resolve()}return l().then((function(){Jt(s,r)}))}function Gt(e,n){var t={del:[],add:[],change:[]};var r;for(r in e){if(!n[r])t.del.push(r)}for(r in n){var i=e[r],a=n[r];if(!i){t.add.push([r,a])}else{var o={name:r,def:a,recreate:false,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!==""+(a.primKey.keyPath||"")||i.primKey.auto!==a.primKey.auto&&!Tn){o.recreate=true;t.change.push(o)}else{var u=i.idxByName;var s=a.idxByName;var c=void 0;for(c in u){if(!s[c])o.del.push(c)}for(c in s){var f=u[c],l=s[c];if(!f)o.add.push(l);else if(f.src!==l.src)o.change.push(l)}if(o.del.length>0||o.add.length>0||o.change.length>0){t.change.push(o)}}}}return t}function Qt(e,n,t,r){var i=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});r.forEach((function(e){return Zt(i,e)}));return i}function Jt(e,n){i(e).forEach((function(t){if(!n.db.objectStoreNames.contains(t)){Qt(n,t,e[t].primKey,e[t].indexes)}}))}function $t(e,n){[].slice.call(n.db.objectStoreNames).forEach((function(t){return e[t]==null&&n.db.deleteObjectStore(t)}))}function Zt(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function er(e,n,t){var r={};var i=m(n.objectStoreNames,0);i.forEach((function(e){var n=t.objectStore(e);var i=n.keyPath;var a=Ct(jt(i),i||"",false,false,!!n.autoIncrement,i&&typeof i!=="string",true);var o=[];for(var u=0;uMath.pow(2,62)?0:r.oldVersion;u=f<1;e._novip.idbdb=c.result;zt(e,f/10,o,a)}}),a);c.onsuccess=on((function(){o=null;var t=e._novip.idbdb=c.result;var i=m(t.objectStoreNames);if(i.length>0)try{var a=t.transaction(Dt(i),"readonly");if(n.autoSchema)nr(e,t,a);else{rr(e,e._dbSchema,a);if(!tr(e,a)){console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")}}Lt(e,a)}catch(e){}Bn.push(e);t.onversionchange=on((function(t){n.vcFired=true;e.on("versionchange").fire(t)}));t.onclose=on((function(n){e.on("close").fire(n)}));if(u)fr(e._deps,s);r()}),a)}))}))]).then((function(){i();n.onReadyBeingFired=[];return Ue.resolve(hr((function(){return e.on.ready.fire(e.vip)}))).then((function t(){if(n.onReadyBeingFired.length>0){var r=n.onReadyBeingFired.reduce(pe,ue);n.onReadyBeingFired=[];return Ue.resolve(hr((function(){return r(e.vip)}))).then(t)}}))}))["finally"]((function(){n.onReadyBeingFired=null;n.isBeingOpened=false})).then((function(){return e}))["catch"]((function(t){n.dbOpenError=t;try{o&&o.abort()}catch(e){}if(r===n.openCanceller){e._close()}return On(t)}))["finally"]((function(){n.openComplete=true;a()}))}function pr(e){var n=function n(t){return e.next(t)},t=function n(t){return e["throw"](t)},r=o(n),i=o(t);function o(e){return function(n){var t=e(n),o=t.value;return t.done?o:!o||typeof o.then!=="function"?a(o)?Promise.all(o).then(r,i):r(o):o.then(r,i)}}return o(n)()}function yr(e,n,t){var r=arguments.length;if(r<2)throw new re.InvalidArgument("Too few arguments");var i=new Array(r-1);while(--r){i[r-1]=arguments[r]}t=i.pop();var a=S(i);return[e,a,t]}function mr(e,n,t,r,i){return Ue.resolve().then((function(){var a=Fe.transless||Fe;var o=e._createTransaction(n,t,e._dbSchema,r);var u={trans:o,transless:a};if(r){o.idbtrans=r.idbtrans}else{try{o.create();e._state.PR1398_maxLoop=3}catch(r){if(r.name===ne.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0){console.warn("Dexie: Need to reopen db");e._close();return e.open().then((function(){return mr(e,n,t,null,i)}))}return On(r)}}var s=q(i);if(s){vn()}var c;var f=Ue.follow((function(){c=i.call(o,o);if(c){if(s){var e=pn.bind(null,null);c.then(e,e)}else if(typeof c.next==="function"&&typeof c["throw"]==="function"){c=pr(c)}}}),u);return(c&&typeof c.then==="function"?Ue.resolve(c).then((function(e){return o.active?e:On(new re.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))})):f.then((function(){return c}))).then((function(e){if(r)o._resolve();return o._completion.then((function(){return e}))}))["catch"]((function(e){o._reject(e);return On(e)}))}))}function br(e,n,t){var r=a(e)?e.slice():[e];for(var i=0;i0;var l=n(n({},r),{isVirtual:f,keyTail:t,keyLength:c,extractKey:Tt(e),unique:!f&&r.unique});s.push(l);if(!l.isPrimaryKey){o.push(l)}if(c>1){var h=c===2?e[0]:e.slice(0,c-1);u(h,t+1,r)}s.sort((function(e,n){return e.keyTail-n.keyTail}));return l}var s=u(i.primaryKey.keyPath,0,i.primaryKey);a[":id"]=[s];for(var c=0,f=i.indexes;c0)return Promise.reject(i.failures[0]);if(a.length1?t:n}:{d:0})}else{var r=new e;if(n&&"d"in n){o(r,n)}return r}};f(Ar.prototype,(Or={add:function e(n){jr(this,n);return this},addKey:function e(n){Cr(this,n,n);return this},addKeys:function e(n){var t=this;n.forEach((function(e){return Cr(t,e,e)}));return this}},Or[R]=function(){return Dr(this)},Or));function Cr(e,n,t){var r=rt(n,t);if(isNaN(r))return;if(r>0)throw RangeError();if(Sr(e))return o(e,{from:n,to:t,d:1});var i=e.l;var a=e.r;if(rt(t,e.from)<0){i?Cr(i,n,t):e.l={from:n,to:t,d:1,l:null,r:null};return Br(e)}if(rt(n,e.to)>0){a?Cr(a,n,t):e.r={from:n,to:t,d:1,l:null,r:null};return Br(e)}if(rt(n,e.from)<0){e.from=n;e.l=null;e.d=a?a.d+1:1}if(rt(t,e.to)>0){e.to=t;e.r=null;e.d=e.l?e.l.d+1:1}var u=!e.r;if(i&&!e.l){jr(e,i)}if(a&&u){jr(e,a)}}function jr(e,n){function t(e,n){var r=n.from,i=n.to,a=n.l,o=n.r;Cr(e,r,i);if(a)t(e,a);if(o)t(e,o)}if(!Sr(n))t(e,n)}function Ir(e,n){var t=Dr(n);var r=t.next();if(r.done)return false;var i=r.value;var a=Dr(e);var o=a.next(i.from);var u=o.value;while(!r.done&&!o.done){if(rt(u.from,i.to)<=0&&rt(u.to,i.from)>=0)return true;rt(i.from,u.from)<0?i=(r=t.next(u.from)).value:u=(o=a.next(i.from)).value}return false}function Dr(e){var n=Sr(e)?null:{s:0,n:e};return{next:function e(t){var r=arguments.length>0;while(n){switch(n.s){case 0:n.s=1;if(r){while(n.n.l&&rt(t,n.n.from)<0){n={up:n,n:n.n.l,s:1}}}else{while(n.n.l){n={up:n,n:n.n.l,s:1}}}case 1:n.s=2;if(!r||rt(t,n.n.to)<=0)return{value:n.n,done:false};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:true}}}}function Br(e){var t,r;var i=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((r=e.l)===null||r===void 0?void 0:r.d)||0);var a=i>1?"r":i<-1?"l":"";if(a){var o=a==="r"?"l":"r";var u=n({},e);var s=e[a];e.from=s.from;e.to=s.to;e[a]=s[a];u[a]=s[o];e[o]=u;u.d=Tr(u)}e.d=Tr(e)}function Tr(e){var n=e.r,t=e.l;return(n?t?Math.max(n.d,t.d):n.d:t?t.d:0)+1}var Rr={stack:"dbcore",level:0,create:function e(t){var r=t.schema.name;var o=new Ar(t.MIN_KEY,t.MAX_KEY);return n(n({},t),{table:function e(u){var e=t.table(u);var s=e.schema;var c=s.primaryKey;var f=c.extractKey,l=c.outbound;var h=n(n({},e),{mutate:function n(t){var i=t.trans;var c=i.mutatedParts||(i.mutatedParts={});var f=function e(n){var t="idb://"+r+"/"+u+"/"+n;return c[t]||(c[t]=new Ar)};var l=f("");var h=f(":dels");var d=t.type;var v=t.type==="deleteRange"?[t.range]:t.type==="delete"?[t.keys]:t.values.length<50?[[],t.values]:[],p=v[0],y=v[1];var m=t.trans["_cache"];return e.mutate(t).then((function(e){if(a(p)){if(d!=="delete")p=e.results;l.addKeys(p);var n=Pr(p,m);if(!n&&d!=="add"){h.addKeys(p)}if(n||y){Fr(f,s,n,y)}}else if(p){var t={from:p.lower,to:p.upper};h.add(t);l.add(t)}else{l.add(o);h.add(o);s.indexes.forEach((function(e){return f(e.name).add(o)}))}return e}))}});var d=function e(n){var r,i;var a=n.query,o=a.index,u=a.range;return[o,new Ar((r=u.lower)!==null&&r!==void 0?r:t.MIN_KEY,(i=u.upper)!==null&&i!==void 0?i:t.MAX_KEY)]};var v={get:function e(n){return[c,new Ar(n.key)]},getMany:function e(n){return[c,(new Ar).addKeys(n.keys)]},count:d,query:d,openCursor:d};i(v).forEach((function(t){h[t]=function(i){var a=Fe.subscr;if(a){var s=function e(n){var t="idb://"+r+"/"+u+"/"+n;return a[t]||(a[t]=new Ar)};var c=s("");var h=s(":dels");var d=v[t](i),p=d[0],y=d[1];s(p.name||"").add(y);if(!p.isPrimaryKey){if(t==="count"){h.add(o)}else{var m=t==="query"&&l&&i.values&&e.query(n(n({},i),{values:false}));return e[t].apply(this,arguments).then((function(e){if(t==="query"){if(l&&i.values){return m.then((function(n){var t=n.result;c.addKeys(t);return e}))}var n=i.values?e.result.map(f):e.result;if(i.values){c.addKeys(n)}else{h.addKeys(n)}}else if(t==="openCursor"){var r=e;var a=i.values;return r&&Object.create(r,{key:{get:function e(){h.addKey(r.primaryKey);return r.key}},primaryKey:{get:function e(){var n=r.primaryKey;h.addKey(n);return n}},value:{get:function e(){a&&c.addKey(r.primaryKey);return r.value}}})}return e}))}}}return e[t].apply(this,arguments)}}));return h}})}};function Fr(e,n,t,r){function i(n){var i=e(n.name||"");function o(e){return e!=null?n.extractKey(e):null}var u=function e(t){return n.multiEntry&&a(t)?t.forEach((function(e){return i.addKey(e)})):i.addKey(t)};(t||r).forEach((function(e,n){var i=t&&o(t[n]);var a=r&&o(r[n]);if(rt(i,a)!==0){if(i!=null)u(i);if(a!=null)u(a)}}))}n.indexes.forEach(i)}var Mr=function(){function e(t,r){var i=this;this._middlewares={};this.verno=0;var a=e.dependencies;this._options=r=n({addons:e.addons,autoOpen:true,indexedDB:a.indexedDB,IDBKeyRange:a.IDBKeyRange},r);this._deps={indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange};var o=r.addons;this._dbSchema={};this._versions=[];this._storeNames=[];this._allTables={};this.idbdb=null;this._novip=this;var u={dbOpenError:null,isBeingOpened:false,onReadyBeingFired:null,openComplete:false,dbReadyResolve:ue,dbReadyPromise:null,cancelOpen:ue,openCanceller:null,autoSchema:true,PR1398_maxLoop:3};u.dbReadyPromise=new Ue((function(e){u.dbReadyResolve=e}));u.openCanceller=new Ue((function(e,n){u.cancelOpen=n}));this._state=u;this.name=t;this.on=Yn(this,"populate","blocked","versionchange","close",{ready:[pe,ue]});this.on.ready.subscribe=b(this.on.ready.subscribe,(function(n){return function(t,r){e.vip((function(){var e=i._state;if(e.openComplete){if(!e.dbOpenError)Ue.resolve().then(t);if(r)n(t)}else if(e.onReadyBeingFired){e.onReadyBeingFired.push(t);if(r)n(t)}else{n(t);var a=i;if(!r)n((function e(){a.on.ready.unsubscribe(t);a.on.ready.unsubscribe(e)}))}}))}}));this.Collection=ft(this);this.Table=Xn(this);this.Transaction=At(this);this.Version=or(this);this.WhereClause=xt(this);this.on("versionchange",(function(e){if(e.newVersion>0)console.warn("Another connection wants to upgrade database '"+i.name+"'. Closing db now to resume the upgrade.");else console.warn("Another connection wants to delete database '"+i.name+"'. Closing db now to resume the delete request.");i.close()}));this.on("blocked",(function(e){if(!e.newVersion||e.newVersion=0)Bn.splice(n,1);if(this.idbdb){try{this.idbdb.close()}catch(e){}this._novip.idbdb=null}e.dbReadyPromise=new Ue((function(n){e.dbReadyResolve=n}));e.openCanceller=new Ue((function(n,t){e.cancelOpen=t}))};e.prototype.close=function(){this._close();var e=this._state;this._options.autoOpen=false;e.dbOpenError=new re.DatabaseClosed;if(e.isBeingOpened)e.cancelOpen(e.dbOpenError)};e.prototype["delete"]=function(){var e=this;var n=arguments.length>0;var t=this._state;return new Ue((function(r,i){var a=function n(){e.close();var t=e._deps.indexedDB.deleteDatabase(e.name);t.onsuccess=on((function(){lr(e._deps,e.name);r()}));t.onerror=kt(i);t.onblocked=e._fireOnBlocked};if(n)throw new re.InvalidArgument("Arguments not allowed in db.delete()");if(t.isBeingOpened){t.dbReadyPromise.then(a)}else{a()}}))};e.prototype.backendDB=function(){return this.idbdb};e.prototype.isOpen=function(){return this.idbdb!==null};e.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"};e.prototype.hasFailed=function(){return this._state.dbOpenError!==null};e.prototype.dynamicallyOpened=function(){return this._state.autoSchema};Object.defineProperty(e.prototype,"tables",{get:function e(){var n=this;return i(this._allTables).map((function(e){return n._allTables[e]}))},enumerable:false,configurable:true});e.prototype.transaction=function(){var e=yr.apply(this,arguments);return this._transaction.apply(this,e)};e.prototype._transaction=function(e,n,t){var r=this;var i=Fe.trans;if(!i||i.db!==this||e.indexOf("!")!==-1)i=null;var a=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");var o,u;try{u=n.map((function(e){var n=e instanceof r.Table?e.name:e;if(typeof n!=="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return n}));if(e=="r"||e===qn)o=qn;else if(e=="rw"||e==Un)o=Un;else throw new re.InvalidArgument("Invalid transaction mode: "+e);if(i){if(i.mode===qn&&o===Un){if(a){i=null}else throw new re.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY")}if(i){u.forEach((function(e){if(i&&i.storeNames.indexOf(e)===-1){if(a){i=null}else throw new re.SubTransaction("Table "+e+" not included in parent transaction.")}}))}if(a&&i&&!i.active){i=null}}}catch(e){return i?i._promise(null,(function(n,t){t(e)})):On(e)}var s=mr.bind(null,this,o,u,i,t);return i?i._promise(o,s,"lock"):Fe.trans?_n(Fe.transless,(function(){return r._whenReady(s)})):this._whenReady(s)};e.prototype.table=function(e){if(!c(this._allTables,e)){throw new re.InvalidTable("Table "+e+" does not exist")}return this._allTables[e]};return e}();var Nr=typeof Symbol!=="undefined"&&"observable"in Symbol?Symbol.observable:"@@observable";var qr=function(){function e(e){this._subscribe=e}e.prototype.subscribe=function(e,n,t){return this._subscribe(!e||typeof e==="function"?{next:e,error:n,complete:t}:e)};e.prototype[Nr]=function(){return this};return e}();function Ur(e,n){i(n).forEach((function(t){var r=e[t]||(e[t]=new Ar);jr(r,n[t])}));return e}function Hr(e){return new qr((function(n){var t=q(e);function r(n){if(t){vn()}var r=function t(){return dn(e,{subscr:n,trans:null})};var i=Fe.trans?_n(Fe.transless,r):r();if(t){i.then(pn,pn)}return i}var a=false;var o={};var u={};var s={get closed(){return a},unsubscribe:function e(){a=true;Ot.storagemutated.unsubscribe(h)}};n.start&&n.start(s);var c=false,f=false;function l(){return i(u).some((function(e){return o[e]&&Ir(o[e],u[e])}))}var h=function e(n){Ur(o,n);if(l()){d()}};var d=function e(){if(c||a)return;o={};var t={};var i=r(t);if(!f){Ot(Pt,h);f=true}c=true;Promise.resolve(i).then((function(r){c=false;if(a)return;if(l()){e()}else{o={};u=t;n.next&&n.next(r)}}),(function(e){c=false;n.error&&n.error(e);s.unsubscribe()}))};d();return s}))}var Lr;try{Lr={indexedDB:r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.msIndexedDB,IDBKeyRange:r.IDBKeyRange||r.webkitIDBKeyRange}}catch(e){Lr={indexedDB:null,IDBKeyRange:null}}var Vr=Mr;f(Vr,n(n({},oe),{delete:function e(n){var t=new Vr(n,{addons:[]});return t["delete"]()},exists:function e(n){return new Vr(n,{addons:[]}).open().then((function(e){e.close();return true}))["catch"]("NoSuchDatabaseError",(function(){return false}))},getDatabaseNames:function e(n){try{return cr(Vr.dependencies).then(n)}catch(e){return On(new re.MissingAPI)}},defineClass:function e(){function n(e){o(this,e)}return n},ignoreTransaction:function e(n){return Fe.trans?_n(Fe.transless,n):n()},vip:hr,async:function e(n){return function(){try{var e=pr(n.apply(this,arguments));if(!e||typeof e.then!=="function")return Ue.resolve(e);return e}catch(e){return On(e)}}},spawn:function e(n,t,r){try{var i=pr(n.apply(r,t||[]));if(!i||typeof i.then!=="function")return Ue.resolve(i);return i}catch(e){return On(e)}},currentTransaction:{get:function e(){return Fe.trans||null}},waitFor:function e(n,t){var r=Ue.resolve(typeof n==="function"?Vr.ignoreTransaction(n):n).timeout(t||6e4);return Fe.trans?Fe.trans.waitFor(r):r},Promise:Ue,debug:{get:function e(){return U},set:function e(n){H(n,n==="dexie"?function(){return true}:Mn)}},derive:d,extend:o,props:f,override:b,Events:Yn,on:Ot,liveQuery:Hr,extendObservabilitySet:Ur,getByKeyPath:k,setByKeyPath:E,delByKeyPath:P,shallowClone:K,deepClone:I,getObjectDiff:_r,cmp:rt,asap:w,minKey:jn,addons:[],connections:Bn,errnames:ne,dependencies:Lr,semVer:An,version:An.split(".").map((function(e){return parseInt(e)})).reduce((function(e,n,t){return e+n/Math.pow(10,t*2)}))}));Vr.maxKey=Bt(Vr.dependencies.IDBKeyRange);if(typeof dispatchEvent!=="undefined"&&typeof addEventListener!=="undefined"){Ot(Pt,(function(e){if(!Yr){var n;if(Tn){n=document.createEvent("CustomEvent");n.initCustomEvent(Kt,true,true,e)}else{n=new CustomEvent(Kt,{detail:e})}Yr=true;dispatchEvent(n);Yr=false}}));addEventListener(Kt,(function(e){var n=e.detail;if(!Yr){Wr(n)}}))}function Wr(e){var n=Yr;try{Yr=true;Ot.storagemutated.fire(e)}finally{Yr=n}}var Yr=false;if(typeof BroadcastChannel!=="undefined"){var zr=new BroadcastChannel(Kt);Ot(Pt,(function(e){if(!Yr){zr.postMessage(e)}}));zr.onmessage=function(e){if(e.data)Wr(e.data)}}else if(typeof self!=="undefined"&&typeof navigator!=="undefined"){Ot(Pt,(function(e){try{if(!Yr){if(typeof localStorage!=="undefined"){localStorage.setItem(Kt,JSON.stringify({trig:Math.random(),changedParts:e}))}if(babelHelpers["typeof"](self["clients"])==="object"){t([],self["clients"].matchAll({includeUncontrolled:true}),true).forEach((function(n){return n.postMessage({type:Kt,changedParts:e})}))}}}catch(e){}}));if(typeof addEventListener!=="undefined"){addEventListener("storage",(function(e){if(e.key===Kt){var n=JSON.parse(e.newValue);if(n)Wr(n.changedParts)}}))}var Xr=self.document&&navigator.serviceWorker;if(Xr){Xr.addEventListener("message",Gr)}}function Gr(e){var n=e.data;if(n&&n.type===Kt){Wr(n.changedParts)}}Ue.rejectionMapper=ae;H(U,Mn);window.BX.Dexie=Mr;e.Dexie=Mr;e.liveQuery=Hr;e.RangeSet=Ar;e.mergeRanges=jr;e.rangesOverlap=Ir})(this.BX.Dexie3=this.BX.Dexie3||{}); //# sourceMappingURL=dexie3.bundle.map.js