dexie 3.0.0 → 3.0.1

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