UNPKG

sync-client

Version:

Module which uses Dexie to save data and can later use a server to synchronize the data in the database with other devices

1 lines 130 kB
module.exports=function(n){function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var t={};return e.m=n,e.c=t,e.i=function(n){return n},e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:r})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="",e(e.s=135)}([function(n,e){var t=n.exports={version:"2.5.3"};"number"==typeof __e&&(__e=t)},function(n,e){var t=n.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)},function(n,e,t){var r=t(32)("wks"),o=t(22),i=t(1).Symbol,u="function"==typeof i;(n.exports=function(n){return r[n]||(r[n]=u&&i[n]||(u?i:o)("Symbol."+n))}).store=r},function(n,e,t){var r=t(1),o=t(0),i=t(10),u=t(9),a="prototype",s=function(n,e,t){var c,f,l,h=n&s.F,d=n&s.G,p=n&s.S,v=n&s.P,y=n&s.B,m=n&s.W,b=d?o:o[e]||(o[e]={}),g=b[a],_=d?r:p?r[e]:(r[e]||{})[a];d&&(t=e);for(c in t)(f=!h&&_&&void 0!==_[c])&&c in b||(l=f?_[c]:t[c],b[c]=d&&"function"!=typeof _[c]?t[c]:y&&f?i(l,r):m&&_[c]==l?function(n){var e=function(e,t,r){if(this instanceof n){switch(arguments.length){case 0:return new n;case 1:return new n(e);case 2:return new n(e,t)}return new n(e,t,r)}return n.apply(this,arguments)};return e[a]=n[a],e}(l):v&&"function"==typeof l?i(Function.call,l):l,v&&((b.virtual||(b.virtual={}))[c]=l,n&s.R&&g&&!g[c]&&u(g,c,l)))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,s.U=64,s.R=128,n.exports=s},function(n,e,t){var r=t(7);n.exports=function(n){if(!r(n))throw TypeError(n+" is not an object!");return n}},function(n,e,t){var r=t(4),o=t(44),i=t(35),u=Object.defineProperty;e.f=t(6)?Object.defineProperty:function(n,e,t){if(r(n),e=i(e,!0),r(t),o)try{return u(n,e,t)}catch(n){}if("get"in t||"set"in t)throw TypeError("Accessors not supported!");return"value"in t&&(n[e]=t.value),n}},function(n,e,t){n.exports=!t(11)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(n,e){n.exports=function(n){return"object"==typeof n?null!==n:"function"==typeof n}},function(n,e){var t={}.hasOwnProperty;n.exports=function(n,e){return t.call(n,e)}},function(n,e,t){var r=t(5),o=t(16);n.exports=t(6)?function(n,e,t){return r.f(n,e,o(1,t))}:function(n,e,t){return n[e]=t,n}},function(n,e,t){var r=t(18);n.exports=function(n,e,t){if(r(n),void 0===e)return n;switch(t){case 1:return function(t){return n.call(e,t)};case 2:return function(t,r){return n.call(e,t,r)};case 3:return function(t,r,o){return n.call(e,t,r,o)}}return function(){return n.apply(e,arguments)}}},function(n,e){n.exports=function(n){try{return!!n()}catch(n){return!0}}},function(n,e,t){var r=t(45),o=t(25);n.exports=function(n){return r(o(n))}},function(n,e){var t={}.toString;n.exports=function(n){return t.call(n).slice(8,-1)}},function(n,e){n.exports={}},function(n,e,t){var r=t(53),o=t(27);n.exports=Object.keys||function(n){return r(n,o)}},function(n,e){n.exports=function(n,e){return{enumerable:!(1&n),configurable:!(2&n),writable:!(4&n),value:e}}},function(n,e,t){var r=t(25);n.exports=function(n){return Object(r(n))}},function(n,e){n.exports=function(n){if("function"!=typeof n)throw TypeError(n+" is not a function!");return n}},function(n,e){n.exports=!0},function(n,e){e.f={}.propertyIsEnumerable},function(n,e,t){var r=t(5).f,o=t(8),i=t(2)("toStringTag");n.exports=function(n,e,t){n&&!o(n=t?n:n.prototype,i)&&r(n,i,{configurable:!0,value:e})}},function(n,e){var t=0,r=Math.random();n.exports=function(n){return"Symbol(".concat(void 0===n?"":n,")_",(++t+r).toString(36))}},function(n,e,t){"use strict";(function(n,t){function r(n,e){return"object"!=typeof e?n:(Dn(e).forEach(function(t){n[t]=e[t]}),n)}function o(n,e){return Kn.call(n,e)}function i(n,e){"function"==typeof e&&(e=e(Fn(n))),Dn(e).forEach(function(t){u(n,t,e[t])})}function u(n,e,t,i){Ln(n,e,r(t&&o(t,"get")&&"function"==typeof t.get?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},i))}function a(n){return{from:function(e){return n.prototype=Object.create(e.prototype),u(n.prototype,"constructor",n),{extend:i.bind(null,n.prototype)}}}}function s(n,e){var t,r=Un(n,e);return r||(t=Fn(n))&&s(t,e)}function c(n,e,t){return qn.call(n,e,t)}function f(n,e){return e(n)}function l(n){var e=setTimeout(n,1e3);clearTimeout(e)}function h(n){if(!n)throw new Error("Assertion Failed")}function d(n){Mn.setImmediate?t(n):setTimeout(n,0)}function p(n,e){return n.reduce(function(n,t,r){var o=e(t,r);return o&&(n[o[0]]=o[1]),n},{})}function v(n,e){return function(){try{n.apply(this,arguments)}catch(n){e(n)}}}function y(n,e,t){try{n.apply(null,t)}catch(n){e&&e(n)}}function m(n,e){if(o(n,e))return n[e];if(!e)return n;if("string"!=typeof e){for(var t=[],r=0,i=e.length;r<i;++r){var u=m(n,e[r]);t.push(u)}return t}var a=e.indexOf(".");if(-1!==a){var s=n[e.substr(0,a)];return void 0===s?void 0:m(s,e.substr(a+1))}}function b(n,e,t){if(n&&void 0!==e&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof e&&"length"in e){h("string"!=typeof t&&"length"in t);for(var r=0,o=e.length;r<o;++r)b(n,e[r],t[r])}else{var i=e.indexOf(".");if(-1!==i){var u=e.substr(0,i),a=e.substr(i+1);if(""===a)void 0===t?delete n[u]:n[u]=t;else{var s=n[u];s||(s=n[u]={}),b(s,a,t)}}else void 0===t?delete n[e]:n[e]=t}}function g(n,e){"string"==typeof e?b(n,e,void 0):"length"in e&&[].map.call(e,function(e){b(n,e,void 0)})}function _(n){var e={};for(var t in n)o(n,t)&&(e[t]=n[t]);return e}function w(n){return Hn.apply([],n)}function x(n){if(!n||"object"!=typeof n)return n;var e;if(Bn(n)){e=[];for(var t=0,r=n.length;t<r;++t)e.push(x(n[t]))}else if(Wn.indexOf(n.constructor)>=0)e=n;else{e=n.constructor?Object.create(n.constructor.prototype):{};for(var i in n)o(n,i)&&(e[i]=x(n[i]))}return e}function O(n,e,t,r){return t=t||{},r=r||"",Dn(n).forEach(function(i){if(o(e,i)){var u=n[i],a=e[i];"object"==typeof u&&"object"==typeof a&&u&&a&&""+u.constructor==""+a.constructor?O(u,a,t,r+i+"."):u!==a&&(t[r+i]=e[i])}else t[r+i]=void 0}),Dn(e).forEach(function(i){o(n,i)||(t[r+i]=e[i])}),t}function S(n){var e,t,r,o;if(1===arguments.length){if(Bn(n))return n.slice();if(this===zn&&"string"==typeof n)return[n];if(o=Vn(n)){for(t=[];r=o.next(),!r.done;)t.push(r.value);return t}if(null==n)return[n];if("number"==typeof(e=n.length)){for(t=new Array(e);e--;)t[e]=n[e];return t}return[n]}for(e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];return t}function k(n,e){Yn=n,Jn=e}function T(){if(Qn)try{throw T.arguments,new Error}catch(n){return n}return new Error}function E(n,e){var t=n.stack;return t?(e=e||0,0===t.indexOf(n.name)&&(e+=(n.name+n.message).split("\n").length),t.split("\n").slice(e).filter(Jn).map(function(n){return"\n"+n}).join("")):""}function j(n,e){return function(){return console.warn(n+" is deprecated. See https://github.com/dfahlander/Dexie.js/wiki/Deprecations. "+E(T(),1)),e.apply(this,arguments)}}function P(n,e){this._e=T(),this.name=n,this.message=e}function N(n,e){return n+". Errors: "+e.map(function(n){return n.toString()}).filter(function(n,e,t){return t.indexOf(n)===e}).join("\n")}function R(n,e,t,r){this._e=T(),this.failures=e,this.failedKeys=r,this.successCount=t}function C(n,e){this._e=T(),this.name="BulkError",this.failures=e,this.message=N(n,e)}function I(n,e){if(!n||n instanceof P||n instanceof TypeError||n instanceof SyntaxError||!n.name||!oe[n.name])return n;var t=new oe[n.name](e||n.message,n);return"stack"in n&&u(t,"stack",{get:function(){return this.inner.stack}}),t}function A(){}function D(n){return n}function B(n,e){return null==n||n===D?e:function(t){return e(n(t))}}function M(n,e){return function(){n.apply(this,arguments),e.apply(this,arguments)}}function F(n,e){return n===A?e:function(){var t=n.apply(this,arguments);void 0!==t&&(arguments[0]=t);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?M(r,this.onsuccess):r),o&&(this.onerror=this.onerror?M(o,this.onerror):o),void 0!==i?i:t}}function K(n,e){return n===A?e:function(){n.apply(this,arguments);var t=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?M(t,this.onsuccess):t),r&&(this.onerror=this.onerror?M(r,this.onerror):r)}}function L(n,e){return n===A?e:function(t){var o=n.apply(this,arguments);r(t,o);var i=this.onsuccess,u=this.onerror;this.onsuccess=null,this.onerror=null;var a=e.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?M(i,this.onsuccess):i),u&&(this.onerror=this.onerror?M(u,this.onerror):u),void 0===o?void 0===a?void 0:a:r(o,a)}}function U(n,e){return n===A?e:function(){return!1!==e.apply(this,arguments)&&n.apply(this,arguments)}}function q(n,e){return n===A?e:function(){var t=n.apply(this,arguments);if(t&&"function"==typeof t.then){for(var r=this,o=arguments.length,i=new Array(o);o--;)i[o]=arguments[o];return t.then(function(){return e.apply(r,i)})}return e.apply(this,arguments)}}function H(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=A,this._lib=!1;var e=this._PSD=Ee;if(Yn&&(this._stackHolder=T(),this._prev=null,this._numPrev=0),"function"!=typeof n){if(n!==ue)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&V(this,this._value))}this._state=null,this._value=null,++e.ref,G(this,n)}function W(n,e,t,r,o){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof e?e:null,this.resolve=t,this.reject=r,this.psd=o}function G(n,e){try{e(function(e){if(null===n._state){if(e===n)throw new TypeError("A promise cannot be resolved with itself.");var t=n._lib&&Z();e&&"function"==typeof e.then?G(n,function(n,t){e instanceof H?e._then(n,t):e.then(n,t)}):(n._state=!0,n._value=e,z(n)),t&&nn()}},V.bind(null,n))}catch(e){V(n,e)}}function V(n,e){if(Oe.push(e),null===n._state){var t=n._lib&&Z();e=ke(e),n._state=!1,n._value=e,Yn&&null!==e&&"object"==typeof e&&!e._promise&&y(function(){var t=s(e,"stack");e._promise=n,u(e,"stack",{get:function(){return me?t&&(t.get?t.get.apply(e):t.value):n.stack}})}),rn(n),z(n),t&&nn()}}function z(n){var e=n._listeners;n._listeners=[];for(var t=0,r=e.length;t<r;++t)Y(n,e[t]);var o=n._PSD;--o.ref||o.finalize(),0===Pe&&(++Pe,ge(function(){0==--Pe&&en()},[]))}function Y(n,e){if(null===n._state)return void n._listeners.push(e);var t=n._state?e.onFulfilled:e.onRejected;if(null===t)return(n._state?e.resolve:e.reject)(n._value);++e.psd.ref,++Pe,ge(J,[t,n,e])}function J(n,e,t){try{Se=e;var r,o=e._value;e._state?r=n(o):(Oe.length&&(Oe=[]),r=n(o),-1===Oe.indexOf(o)&&on(e)),t.resolve(r)}catch(n){t.reject(n)}finally{Se=null,0==--Pe&&en(),--t.psd.ref||t.psd.finalize()}}function Q(n,e,t){if(e.length===t)return e;var r="";if(!1===n._state){var o,i,u=n._value;null!=u?(o=u.name||"Error",i=u.message||u,r=E(u,0)):(o=u,i=""),e.push(o+(i?": "+i:"")+r)}return Yn&&(r=E(n._stackHolder,2),r&&-1===e.indexOf(r)&&e.push(r),n._prev&&Q(n._prev,e,t)),e}function $(n,e){var t=e?e._numPrev+1:0;t<ae&&(n._prev=e,n._numPrev=t)}function X(){Z()&&nn()}function Z(){var n=_e;return _e=!1,we=!1,n}function nn(){var n,e,t;do{for(;je.length>0;)for(n=je,je=[],t=n.length,e=0;e<t;++e){var r=n[e];r[0].apply(null,r[1])}}while(je.length>0);_e=!0,we=!0}function en(){var n=xe;xe=[],n.forEach(function(n){n._PSD.onunhandled.call(null,n._value,n)});for(var e=Ne.slice(0),t=e.length;t;)e[--t]()}function tn(n){function e(){n(),Ne.splice(Ne.indexOf(e),1)}Ne.push(e),++Pe,ge(function(){0==--Pe&&en()},[])}function rn(n){xe.some(function(e){return e._value===n._value})||xe.push(n)}function on(n){for(var e=xe.length;e;)if(xe[--e]._value===n._value)return void xe.splice(e,1)}function un(n){return new H(ue,!1,n)}function an(n,e){var t=Ee;return function(){var r=Z(),o=Ee;try{return pn(t,!0),n.apply(this,arguments)}catch(n){e&&e(n)}finally{pn(o,!1),r&&nn()}}}function sn(n,e,t,o){var i=Ee,u=Object.create(i);u.parent=i,u.ref=0,u.global=!1,u.id=++Me;var a=Te.env;u.env=ye?{Promise:H,PromiseProp:{value:H,configurable:!0,writable:!0},all:H.all,race:H.race,resolve:H.resolve,reject:H.reject,nthen:gn(a.nthen,u),gthen:gn(a.gthen,u)}:{},e&&r(u,e),++i.ref,u.finalize=function(){--this.parent.ref||this.parent.finalize()};var s=yn(u,n,t,o);return 0===u.ref&&u.finalize(),s}function cn(){return Ce.id||(Ce.id=++Ie),++Ce.awaits,Ce.echoes+=se,Ce.id}function fn(n){!Ce.awaits||n&&n!==Ce.id||(0==--Ce.awaits&&(Ce.id=0),Ce.echoes=Ce.awaits*se)}function ln(n){return Ce.echoes&&n&&n.constructor===pe?(cn(),n.then(function(n){return fn(),n},function(n){return fn(),Le(n)})):n}function hn(n){++Be,Ce.echoes&&0!=--Ce.echoes||(Ce.echoes=Ce.id=0),Ae.push(Ee),pn(n,!0)}function dn(){var n=Ae[Ae.length-1];Ae.pop(),pn(n,!1)}function pn(n,e){var t=Ee;if((e?!Ce.echoes||De++&&n===Ee:!De||--De&&n===Ee)||mn(e?hn.bind(null,n):dn),n!==Ee&&(Ee=n,t===Te&&(Te.env=vn()),ye)){var r=Te.env.Promise,o=n.env;le.then=o.nthen,r.prototype.then=o.gthen,(t.global||n.global)&&(Object.defineProperty(Mn,"Promise",o.PromiseProp),r.all=o.all,r.race=o.race,r.resolve=o.resolve,r.reject=o.reject)}}function vn(){var n=Mn.Promise;return ye?{Promise:n,PromiseProp:Object.getOwnPropertyDescriptor(Mn,"Promise"),all:n.all,race:n.race,resolve:n.resolve,reject:n.reject,nthen:le.then,gthen:n.prototype.then}:{}}function yn(n,e,t,r,o){var i=Ee;try{return pn(n,!0),e(t,r,o)}finally{pn(i,!1)}}function mn(n){de.call(fe,n)}function bn(n,e,t){return"function"!=typeof n?n:function(){var r=Ee;t&&cn(),pn(e,!0);try{return n.apply(this,arguments)}finally{pn(r,!1)}}}function gn(n,e){return function(t,r){return n.call(this,bn(t,e,!1),bn(r,e,!1))}}function _n(n,e){var t;try{t=e.onuncatched(n)}catch(n){}if(!1!==t)try{var o,i={promise:e,reason:n};if(Mn.document&&document.createEvent?(o=document.createEvent("Event"),o.initEvent(Fe,!0,!0),r(o,i)):Mn.CustomEvent&&(o=new CustomEvent(Fe,{detail:i}),r(o,i)),o&&Mn.dispatchEvent&&(dispatchEvent(o),!Mn.PromiseRejectionEvent&&Mn.onunhandledrejection))try{Mn.onunhandledrejection(o)}catch(n){}o.defaultPrevented||console.warn("Unhandled rejection: "+(n.stack||n))}catch(n){}}function wn(n){function e(n,e,i){if("object"==typeof n)return t(n);e||(e=U),i||(i=A);var u={subscribers:[],fire:i,subscribe:function(n){-1===u.subscribers.indexOf(n)&&(u.subscribers.push(n),u.fire=e(u.fire,n))},unsubscribe:function(n){u.subscribers=u.subscribers.filter(function(e){return e!==n}),u.fire=u.subscribers.reduce(e,i)}};return r[n]=o[n]=u,u}function t(n){Dn(n).forEach(function(t){var r=n[t];if(Bn(r))e(t,n[t][0],n[t][1]);else{if("asap"!==r)throw new re.InvalidArgument("Invalid event config");var o=e(t,D,function(){for(var n=arguments.length,e=new Array(n);n--;)e[n]=arguments[n];o.subscribers.forEach(function(n){d(function(){n.apply(null,e)})})})}})}var r={},o=function(e,t){if(t){for(var o=arguments.length,i=new Array(o-1);--o;)i[o-1]=arguments[o];return r[e].subscribe.apply(null,i),n}if("string"==typeof e)return r[e]};o.addEventType=e;for(var i=1,u=arguments.length;i<u;++i)e(arguments[i]);return o}function xn(n,e){function t(){te.on("versionchange",function(n){n.newVersion>0?console.warn("Another connection wants to upgrade database '"+te.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+te.name+"'. Closing db now to resume the delete request."),te.close()}),te.on("blocked",function(n){!n.newVersion||n.newVersion<n.oldVersion?console.warn("Dexie.delete('"+te.name+"') was blocked"):console.warn("Upgrade '"+te.name+"' blocked by other connection holding version "+n.oldVersion/10)})}function a(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function s(n,e,t){var r=te._createTransaction(ee,Gn,Hn);r.create(e),r._completion.catch(t);var o=r._reject.bind(r);sn(function(){Ee.trans=r,0===n?(Dn(Hn).forEach(function(n){k(e,n,Hn[n].primKey,Hn[n].indexes)}),H.follow(function(){return te.on.populate.fire(r)}).catch(o)):d(n,r,e).catch(o)})}function d(n,e,t){function r(){return o.length?H.resolve(o.shift()(e.idbtrans)).then(r):H.resolve()}var o=[],i=Wn.filter(function(e){return e._cfg.version===n})[0];if(!i)throw new re.Upgrade("Dexie specification of currently installed DB version is missing");Hn=te._dbSchema=i._cfg.dbschema;var u=!1;return Wn.filter(function(e){return e._cfg.version>n}).forEach(function(n){o.push(function(){var r=Hn,o=n._cfg.dbschema;vn(r,t),vn(o,t),Hn=te._dbSchema=o;var i=g(r,o);if(i.add.forEach(function(n){k(t,n[0],n[1].primKey,n[1].indexes)}),i.change.forEach(function(n){if(n.recreate)throw new re.Upgrade("Not yet support for changing primary key");var e=t.objectStore(n.name);n.add.forEach(function(n){N(e,n)}),n.change.forEach(function(n){e.deleteIndex(n.name),N(e,n)}),n.del.forEach(function(n){e.deleteIndex(n)})}),n._cfg.contentUpgrade)return u=!0,H.follow(function(){n._cfg.contentUpgrade(e)})}),o.push(function(e){u&&Je||P(n._cfg.dbschema,e)})}),r().then(function(){E(Hn,t)})}function g(n,e){var t={del:[],add:[],change:[]};for(var r in n)e[r]||t.del.push(r);for(r in e){var o=n[r],i=e[r];if(o){var u={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(o.primKey.src!==i.primKey.src)u.recreate=!0,t.change.push(u);else{var a=o.idxByName,s=i.idxByName;for(var c in a)s[c]||u.del.push(c);for(c in s){var f=a[c],l=s[c];f?f.src!==l.src&&u.change.push(l):u.add.push(l)}(u.del.length>0||u.add.length>0||u.change.length>0)&&t.change.push(u)}}else t.add.push([r,i])}return t}function k(n,e,t,r){var o=n.db.createObjectStore(e,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return r.forEach(function(n){N(o,n)}),o}function E(n,e){Dn(n).forEach(function(t){e.db.objectStoreNames.contains(t)||k(e,t,n[t].primKey,n[t].indexes)})}function P(n,e){for(var t=0;t<e.db.objectStoreNames.length;++t){var r=e.db.objectStoreNames[t];null==n[r]&&e.db.deleteObjectStore(r)}}function N(n,e){n.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function I(n,e,t){if(Zn||Ee.letThrough){var r=te._createTransaction(n,e,Hn);try{r.create()}catch(n){return Le(n)}return r._promise(n,function(n,e){return sn(function(){return Ee.trans=r,t(n,e,r)})}).then(function(n){return r._completion.then(function(){return n})})}if(!$n){if(!Ln)return Le(new re.DatabaseClosed);te.open().catch(A)}return oe.then(function(){return I(n,e,t)})}function M(n,e,t){var r=arguments.length;if(r<2)throw new re.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return t=o.pop(),[n,w(o),t]}function U(n,e,t){this.name=n,this.schema=e,this._tx=t,this.hook=Vn[n]?Vn[n].hook:wn(null,{creating:[F,A],reading:[B,D],updating:[L,A],deleting:[K,A]})}function W(n,e,t){return(t?jn:Tn)(function(t){n.push(t),e&&e()})}function G(n,e,t,r,o){return new H(function(i,u){var a=t.length,s=a-1;if(0===a)return i();if(r){var c,f=jn(u),l=kn(null);y(function(){for(var r=0;r<a;++r){c={onsuccess:null,onerror:null};var u=t[r];o.call(c,u[0],u[1],e);var h=n.delete(u[0]);h._hookCtx=c,h.onerror=f,h.onsuccess=r===s?kn(i):l}},function(n){throw c.onerror&&c.onerror(n),n})}else for(var h=0;h<a;++h){var d=n.delete(t[h]);d.onerror=Tn(u),h===s&&(d.onsuccess=an(function(){return i()}))}})}function V(n,e,t,r){var o=this;this.db=te,this.mode=n,this.storeNames=e,this.idbtrans=null,this.on=wn(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 H(function(n,e){o._resolve=n,o._reject=e}),this._completion.then(function(){o.active=!1,o.on.complete.fire()},function(n){var e=o.active;return o.active=!1,o.on.error.fire(n),o.parent?o.parent._reject(n):e&&o.idbtrans&&o.idbtrans.abort(),Le(n)})}function z(n,e,t){this._ctx={table:n,index:":id"===e?null:e,or:t}}function Y(n,e){var t=null,r=null;if(e)try{t=e()}catch(n){r=n}var o=n._ctx,i=o.table;this._ctx={table:i,index:o.index,isPrimKey:!o.index||i.schema.primKey.keyPath&&o.index===i.schema.primKey.name,range:t,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:i.hook.reading.fire}}function J(n,e){return!(n.filter||n.algorithm||n.or)&&(e?n.justLimit:!n.replayFilter)}function Q(n,e){return n._cfg.version-e._cfg.version}function $(n,e,t){e.forEach(function(e){var r=t[e];n.forEach(function(n){e in n||(n===V.prototype||n instanceof V?u(n,e,{get:function(){return this.table(e)}}):n[e]=new U(e,r))})})}function X(n){n.forEach(function(n){for(var e in n)n[e]instanceof U&&delete n[e]})}function Z(n,e,t,r,o,i){var u=i?function(n,e,r){return t(i(n),e,r)}:t,a=an(u,o);n.onerror||(n.onerror=Tn(o)),n.onsuccess=e?v(function(){var t=n.result;if(t){var i=function(){t.continue()};e(t,function(n){i=n},r,o)&&a(t.value,t,function(n){i=n}),i()}else r()},o):v(function(){var e=n.result;if(e){var t=function(){e.continue()};a(e.value,e,function(n){t=n}),t()}else r()},o)}function nn(n){var e=[];return n.split(",").forEach(function(n){n=n.trim();var t=n.replace(/([&*]|\+\+)/g,""),r=/^\[/.test(t)?t.match(/^\[(.*)\]$/)[1].split("+"):t;e.push(new Rn(t,r||null,/\&/.test(n),/\*/.test(n),/\+\+/.test(n),Bn(r),/\./.test(n)))}),e}function en(n,e){return Un.cmp(n,e)}function tn(n,e){return en(n,e)<0?n:e}function rn(n,e){return en(n,e)>0?n:e}function on(n,e){return Un.cmp(n,e)}function un(n,e){return Un.cmp(e,n)}function ln(n,e){return n<e?-1:n===e?0:1}function hn(n,e){return n>e?-1:n===e?0:1}function dn(n,e){return n?e?function(){return n.apply(this,arguments)&&e.apply(this,arguments)}:n:e}function pn(){if(te.verno=Jn.version/10,te._dbSchema=Hn={},Gn=c(Jn.objectStoreNames,0),0!==Gn.length){var n=Jn.transaction(In(Gn),"readonly");Gn.forEach(function(e){for(var t=n.objectStore(e),r=t.keyPath,o=r&&"string"==typeof r&&-1!==r.indexOf("."),i=new Rn(r,r||"",!1,!1,!!t.autoIncrement,r&&"string"!=typeof r,o),u=[],a=0;a<t.indexNames.length;++a){var s=t.index(t.indexNames[a]);r=s.keyPath,o=r&&"string"==typeof r&&-1!==r.indexOf(".");var c=new Rn(s.name,r,!!s.unique,!!s.multiEntry,!1,r&&"string"!=typeof r,o);u.push(c)}Hn[e]=new Cn(e,i,u,{})}),$([Vn],Dn(Hn),Hn)}}function vn(n,e){for(var t=e.db.objectStoreNames,r=0;r<t.length;++r){var o=t[r],i=e.objectStore(o);_n="getAll"in i;for(var u=0;u<i.indexNames.length;++u){var a=i.indexNames[u],s=i.index(a).keyPath,f="string"==typeof s?s:"["+c(s).join("+")+"]";if(n[o]){var l=n[o].idxByName[f];l&&(l.name=a)}}}/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&Mn.WorkerGlobalScope&&Mn instanceof Mn.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(_n=!1)}function mn(n){te.on("blocked").fire(n),ze.filter(function(n){return n.name===te.name&&n!==te&&!n._vcFired}).map(function(e){return e.on("versionchange").fire(n)})}var bn,gn,_n,On=xn.dependencies,Fn=r({addons:xn.addons,autoOpen:!0,indexedDB:On.indexedDB,IDBKeyRange:On.IDBKeyRange},e),Kn=Fn.addons,Ln=Fn.autoOpen,Un=Fn.indexedDB,qn=Fn.IDBKeyRange,Hn=this._dbSchema={},Wn=[],Gn=[],Vn={},Jn=null,Qn=null,$n=!1,Xn=null,Zn=!1,ne="readonly",ee="readwrite",te=this,oe=new H(function(n){bn=n}),ie=new H(function(n,e){gn=e}),ue=!0,ae=!!An(Un);this.version=function(n){if(Jn||$n)throw new re.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,n);var e=Wn.filter(function(e){return e._cfg.version===n})[0];return e||(e=new a(n),Wn.push(e),Wn.sort(Q),ue=!1,e)},r(a.prototype,{stores:function(n){this._cfg.storesSource=this._cfg.storesSource?r(this._cfg.storesSource,n):n;var e={};Wn.forEach(function(n){r(e,n._cfg.storesSource)});var t=this._cfg.dbschema={};return this._parseStoresSpec(e,t),Hn=te._dbSchema=t,X([Vn,te,V.prototype]),$([Vn,te,V.prototype,this._cfg.tables],Dn(t),t),Gn=Dn(t),this},upgrade:function(n){var e=this;return Xe(function(){n(te._createTransaction(ee,Dn(e._cfg.dbschema),e._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,e){Dn(n).forEach(function(t){if(null!==n[t]){var r={},o=nn(n[t]),i=o.shift();if(i.multi)throw new re.Schema("Primary key cannot be multi-valued");i.keyPath&&b(r,i.keyPath,i.auto?0:i.keyPath),o.forEach(function(n){if(n.auto)throw new re.Schema("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new re.Schema("Index must have a name and cannot be an empty string");b(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),e[t]=new Cn(t,i,o,r)}})}}),this._allTables=Vn,this._createTransaction=function(n,e,t,r){return new V(n,e,t,r)},this._whenReady=function(n){return Ze||Zn||Ee.letThrough?n():new H(function(n,e){if(!$n){if(!Ln)return void e(new re.DatabaseClosed);te.open().catch(A)}oe.then(n,e)}).then(n)},this.verno=0,this.open=function(){if($n||Jn)return oe.then(function(){return Qn?Le(Qn):te});Yn&&(ie._stackHolder=T()),$n=!0,Qn=null,Zn=!1;var e=bn,t=null;return H.race([ie,new H(function(e,r){if(l(function(){return e()}),!Un)throw new re.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=ue?Un.open(n):Un.open(n,Math.round(10*te.verno));if(!o)throw new re.MissingAPI("IndexedDB API not available");o.onerror=Tn(r),o.onblocked=an(mn),o.onupgradeneeded=an(function(e){if(t=o.transaction,ue&&!te._allowEmptyDB){o.onerror=Pn,t.abort(),o.result.close();var i=Un.deleteDatabase(n);i.onsuccess=i.onerror=an(function(){r(new re.NoSuchDatabase("Database "+n+" doesnt exist"))})}else{t.onerror=Tn(r);s((e.oldVersion>Math.pow(2,62)?0:e.oldVersion)/10,t,r,o)}},r),o.onsuccess=an(function(){if(t=null,Jn=o.result,ze.push(te),ue)pn();else if(Jn.objectStoreNames.length>0)try{vn(Hn,Jn.transaction(In(Jn.objectStoreNames),ne))}catch(n){}Jn.onversionchange=an(function(n){te._vcFired=!0,te.on("versionchange").fire(n)}),ae||"__dbnames"===n||Ke.dbnames.put({name:n}).catch(A),e()},r)})]).then(function(){return Xn=[],H.resolve(xn.vip(te.on.ready.fire)).then(function n(){if(Xn.length>0){var e=Xn.reduce(q,A);return Xn=[],H.resolve(xn.vip(e)).then(n)}})}).finally(function(){Xn=null}).then(function(){return $n=!1,te}).catch(function(n){try{t&&t.abort()}catch(n){}return $n=!1,te.close(),Qn=n,Le(Qn)}).finally(function(){Zn=!0,e()})},this.close=function(){var n=ze.indexOf(te);if(n>=0&&ze.splice(n,1),Jn){try{Jn.close()}catch(n){}Jn=null}Ln=!1,Qn=new re.DatabaseClosed,$n&&gn(Qn),oe=new H(function(n){bn=n}),ie=new H(function(n,e){gn=e})},this.delete=function(){var e=arguments.length>0;return new H(function(t,r){function o(){te.close();var e=Un.deleteDatabase(n);e.onsuccess=an(function(){ae||Ke.dbnames.delete(n).catch(A),t()}),e.onerror=Tn(r),e.onblocked=mn}if(e)throw new re.InvalidArgument("Arguments not allowed in db.delete()");$n?oe.then(o):o()})},this.backendDB=function(){return Jn},this.isOpen=function(){return null!==Jn},this.hasBeenClosed=function(){return Qn&&Qn instanceof re.DatabaseClosed},this.hasFailed=function(){return null!==Qn},this.dynamicallyOpened=function(){return ue},this.name=n,i(this,{tables:{get:function(){return Dn(Vn).map(function(n){return Vn[n]})}}}),this.on=wn(this,"populate","blocked","versionchange",{ready:[q,A]}),this.on.ready.subscribe=f(this.on.ready.subscribe,function(n){return function(e,t){xn.vip(function(){Zn?(Qn||H.resolve().then(e),t&&n(e)):Xn?(Xn.push(e),t&&n(e)):(n(e),t||n(function n(){te.on.ready.unsubscribe(e),te.on.ready.unsubscribe(n)}))})}}),Xe(function(){te.on("populate").fire(te._createTransaction(ee,Gn,Hn))}),this.transaction=function(){var n=M.apply(this,arguments);return this._transaction.apply(this,n)},this._transaction=function(n,e,t){function r(){return H.resolve().then(function(){var e=Ee.transless||Ee,r=te._createTransaction(n,u,Hn,o),i={trans:r,transless:e};o?r.idbtrans=o.idbtrans:r.create(),t.constructor===ve&&cn();var a,s=H.follow(function(){if(a=t.call(r,r))if(a.constructor===pe){var n=fn.bind(null,null);a.then(n,n)}else"function"==typeof a.next&&"function"==typeof a.throw&&(a=Nn(a))},i);return(a&&"function"==typeof a.then?H.resolve(a).then(function(n){return r.active?n:Le(new re.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):s.then(function(){return a})).then(function(n){return o&&r._resolve(),r._completion.then(function(){return n})}).catch(function(n){return r._reject(n),Le(n)})})}var o=Ee.trans;o&&o.db===te&&-1===n.indexOf("!")||(o=null);var i=-1!==n.indexOf("?");n=n.replace("!","").replace("?","");try{var u=e.map(function(n){var e=n instanceof U?n.name:n;if("string"!=typeof e)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e});if("r"==n||n==ne)n=ne;else{if("rw"!=n&&n!=ee)throw new re.InvalidArgument("Invalid transaction mode: "+n);n=ee}if(o){if(o.mode===ne&&n===ee){if(!i)throw new re.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&u.forEach(function(n){if(o&&-1===o.storeNames.indexOf(n)){if(!i)throw new re.SubTransaction("Table "+n+" not included in parent transaction.");o=null}}),i&&o&&!o.active&&(o=null)}}catch(n){return o?o._promise(null,function(e,t){t(n)}):Le(n)}return o?o._promise(n,r,"lock"):Ee.trans?yn(Ee.transless,function(){return te._whenReady(r)}):te._whenReady(r)},this.table=function(n){if(Ze&&ue)return new U(n);if(!o(Vn,n))throw new re.InvalidTable("Table "+n+" does not exist");return Vn[n]},i(U.prototype,{_trans:function(n,e,t){var r=this._tx||Ee.trans;return r&&r.db===te?r===Ee.trans?r._promise(n,e,t):sn(function(){return r._promise(n,e,t)},{trans:r,transless:Ee.transless||Ee}):I(n,[this.name],e)},_idbstore:function(n,e,t){function r(n,t,r){if(-1===r.storeNames.indexOf(o))throw new re.NotFound("Table"+o+" not part of transaction");return e(n,t,r.idbtrans.objectStore(o),r)}if(Ze)return new H(e);var o=this.name;return this._trans(n,r,t)},get:function(n,e){if(n&&n.constructor===Object)return this.where(n).first(e);var t=this;return this._idbstore(ne,function(e,r,o){Ze&&e(t.schema.instanceTemplate);var i=o.get(n);i.onerror=Tn(r),i.onsuccess=an(function(){e(t.hook.reading.fire(i.result))},r)}).then(e)},where:function(n){if("string"==typeof n)return new z(this,n);if(Bn(n))return new z(this,"["+n.join("+")+"]");var e=Dn(n);if(1===e.length)return this.where(e[0]).equals(n[e[0]]);var t=this.schema.indexes.concat(this.schema.primKey).filter(function(n){return n.compound&&e.every(function(e){return n.keyPath.indexOf(e)>=0})&&n.keyPath.every(function(n){return e.indexOf(n)>=0})})[0];if(t&&He!==qe)return this.where(t.name).equals(t.keyPath.map(function(e){return n[e]}));t||console.warn("The query "+JSON.stringify(n)+" on "+this.name+" would benefit of a compound index ["+e.join("+")+"]");var r=this.schema.idxByName,o=e.reduce(function(e,t){return[e[0]||r[t],e[0]||!r[t]?dn(e[1],function(e){return""+m(e,t)==""+n[t]}):e[1]]},[null,null]),i=o[0];return i?this.where(i.name).equals(n[i.keyPath]).filter(o[1]):t?this.filter(o[1]):this.where(e).equals("")},count:function(n){return this.toCollection().count(n)},offset:function(n){return this.toCollection().offset(n)},limit:function(n){return this.toCollection().limit(n)},reverse:function(){return this.toCollection().reverse()},filter:function(n){return this.toCollection().and(n)},each:function(n){return this.toCollection().each(n)},toArray:function(n){return this.toCollection().toArray(n)},orderBy:function(n){return new Y(new z(this,Bn(n)?"["+n.join("+")+"]":n))},toCollection:function(){return new Y(new z(this))},mapToClass:function(n,e){this.schema.mappedClass=n;var t=Object.create(n.prototype);e&&Sn(t,e),this.schema.instanceTemplate=t;var r=function(e){if(!e)return e;var t=Object.create(n.prototype);for(var r in e)if(o(e,r))try{t[r]=e[r]}catch(n){}return t};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=r,this.hook("reading",r),n},defineClass:function(n){return this.mapToClass(xn.defineClass(n),n)},bulkDelete:function(n){return this.hook.deleting.fire===A?this._idbstore(ee,function(e,t,r,o){e(G(r,o,n,!1,A))}):this.where(":id").anyOf(n).delete().then(function(){})},bulkPut:function(n,e){var t=this;return this._idbstore(ee,function(r,o,i){if(!i.keyPath&&!t.schema.primKey.auto&&!e)throw new re.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(i.keyPath&&e)throw new re.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(e&&e.length!==n.length)throw new re.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return r();var u,a,s=function(n){0===c.length?r(n):o(new C(t.name+".bulkPut(): "+c.length+" of "+f+" operations failed",c))},c=[],f=n.length,l=t;if(t.hook.creating.fire===A&&t.hook.updating.fire===A){a=W(c);for(var h=0,d=n.length;h<d;++h)u=e?i.put(n[h],e[h]):i.put(n[h]),u.onerror=a;u.onerror=W(c,s),u.onsuccess=En(s)}else{var v=e||i.keyPath&&n.map(function(n){return m(n,i.keyPath)}),y=v&&p(v,function(e,t){return null!=e&&[e,n[t]]});(v?l.where(":id").anyOf(v.filter(function(n){return null!=n})).modify(function(){this.value=y[this.primKey],y[this.primKey]=null}).catch(R,function(n){c=n.failures}).then(function(){for(var t=[],r=e&&[],o=v.length-1;o>=0;--o){var i=v[o];(null==i||y[i])&&(t.push(n[o]),e&&r.push(i),null!=i&&(y[i]=null))}return t.reverse(),e&&r.reverse(),l.bulkAdd(t,r)}).then(function(n){var e=v[v.length-1];return null!=e?e:n}):l.bulkAdd(n)).then(s).catch(C,function(n){c=c.concat(n.failures),s()}).catch(o)}},"locked")},bulkAdd:function(n,e){var t=this,r=this.hook.creating.fire;return this._idbstore(ee,function(o,i,u,a){function s(n){0===h.length?o(n):i(new C(t.name+".bulkAdd(): "+h.length+" of "+d+" operations failed",h))}if(!u.keyPath&&!t.schema.primKey.auto&&!e)throw new re.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(u.keyPath&&e)throw new re.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(e&&e.length!==n.length)throw new re.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return o();var c,f,l,h=[],d=n.length;if(r!==A){var p,v=u.keyPath;f=W(h,null,!0),l=kn(null),y(function(){for(var t=0,o=n.length;t<o;++t){p={onerror:null,onsuccess:null};var i=e&&e[t],s=n[t],h=e?i:v?m(s,v):void 0,d=r.call(p,h,s,a);null==h&&null!=d&&(v?(s=x(s),b(s,v,d)):i=d),c=null!=i?u.add(s,i):u.add(s),c._hookCtx=p,t<o-1&&(c.onerror=f,p.onsuccess&&(c.onsuccess=l))}},function(n){throw p.onerror&&p.onerror(n),n}),c.onerror=W(h,s,!0),c.onsuccess=kn(s)}else{f=W(h);for(var g=0,_=n.length;g<_;++g)c=e?u.add(n[g],e[g]):u.add(n[g]),c.onerror=f;c.onerror=W(h,s),c.onsuccess=En(s)}})},add:function(n,e){var t=this.hook.creating.fire;return this._idbstore(ee,function(r,o,i,u){var a={onsuccess:null,onerror:null};if(t!==A){var s=null!=e?e:i.keyPath?m(n,i.keyPath):void 0,c=t.call(a,s,n,u);null==s&&null!=c&&(i.keyPath?b(n,i.keyPath,c):e=c)}try{var f=null!=e?i.add(n,e):i.add(n);f._hookCtx=a,f.onerror=jn(o),f.onsuccess=kn(function(e){var t=i.keyPath;t&&b(n,t,e),r(e)})}catch(n){throw a.onerror&&a.onerror(n),n}})},put:function(n,e){var t=this,r=this.hook.creating.fire,o=this.hook.updating.fire;if(r!==A||o!==A){var i=this.schema.primKey.keyPath,u=void 0!==e?e:i&&m(n,i);return null==u?this.add(n):(n=x(n),this._trans(ee,function(){return t.where(":id").equals(u).modify(function(){this.value=n}).then(function(r){return 0===r?t.add(n,e):u})},"locked"))}return this._idbstore(ee,function(t,r,o){var i=void 0!==e?o.put(n,e):o.put(n);i.onerror=Tn(r),i.onsuccess=an(function(e){var r=o.keyPath;r&&b(n,r,e.target.result),t(i.result)})})},delete:function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n).delete():this._idbstore(ee,function(e,t,r){var o=r.delete(n);o.onerror=Tn(t),o.onsuccess=an(function(){e(o.result)})})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection().delete():this._idbstore(ee,function(n,e,t){var r=t.clear();r.onerror=Tn(e),r.onsuccess=an(function(){n(r.result)})})},update:function(n,e){if("object"!=typeof e||Bn(e))throw new re.InvalidArgument("Modifications must be an object.");if("object"!=typeof n||Bn(n))return this.where(":id").equals(n).modify(e);Dn(e).forEach(function(t){b(n,t,e[t])});var t=m(n,this.schema.primKey.keyPath);return void 0===t?Le(new re.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(t).modify(e)}}),i(V.prototype,{_lock:function(){return h(!Ee.global),++this._reculock,1!==this._reculock||Ee.global||(Ee.lockOwnerFor=this),this},_unlock:function(){if(h(!Ee.global),0==--this._reculock)for(Ee.global||(Ee.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{yn(n[1],n[0])}catch(n){}}return this},_locked:function(){return this._reculock&&Ee.lockOwnerFor!==this},create:function(n){var e=this;if(!this.mode)return this;if(h(!this.idbtrans),!n&&!Jn)switch(Qn&&Qn.name){case"DatabaseClosedError":throw new re.DatabaseClosed(Qn);case"MissingAPIError":throw new re.MissingAPI(Qn.message,Qn);default:throw new re.OpenFailed(Qn)}if(!this.active)throw new re.TransactionInactive;return h(null===this._completion._state),n=this.idbtrans=n||Jn.transaction(In(this.storeNames),this.mode),n.onerror=an(function(t){Pn(t),e._reject(n.error)}),n.onabort=an(function(t){Pn(t),e.active&&e._reject(new re.Abort(n.error)),e.active=!1,e.on("abort").fire(t)}),n.oncomplete=an(function(){e.active=!1,e._resolve()}),this},_promise:function(n,e,t){var r=this;if(n===ee&&this.mode!==ee)return Le(new re.ReadOnly("Transaction is readonly"));if(!this.active)return Le(new re.TransactionInactive);if(this._locked())return new H(function(o,i){r._blockedFuncs.push([function(){r._promise(n,e,t).then(o,i)},Ee])});if(t)return sn(function(){var n=new H(function(n,t){r._lock();var o=e(n,t,r);o&&o.then&&o.then(n,t)});return n.finally(function(){return r._unlock()}),n._lib=!0,n});var o=new H(function(n,t){var o=e(n,t,r);o&&o.then&&o.then(n,t)});return o._lib=!0,o},_root:function(){return this.parent?this.parent._root():this},waitFor:function(n){var e=this._root();if(n=H.resolve(n),e._waitingFor)e._waitingFor=e._waitingFor.then(function(){return n});else{e._waitingFor=n,e._waitingQueue=[];var t=e.idbtrans.objectStore(e.storeNames[0]);!function n(){for(++e._spinCount;e._waitingQueue.length;)e._waitingQueue.shift()();e._waitingFor&&(t.get(-1/0).onsuccess=n)}()}var r=e._waitingFor;return new H(function(t,o){n.then(function(n){return e._waitingQueue.push(an(t.bind(null,n)))},function(n){return e._waitingQueue.push(an(o.bind(null,n)))}).finally(function(){e._waitingFor===r&&(e._waitingFor=null)})})},abort:function(){this.active&&this._reject(new re.Abort),this.active=!1},tables:{get:j("Transaction.tables",function(){return Vn})},table:function(n){return new U(n,te.table(n).schema,this)}}),i(z.prototype,function(){function n(n,e,t){var r=n instanceof z?new Y(n):n;return r._ctx.error=t?new t(e):new TypeError(e),r}function e(n){return new Y(n,function(){return qn.only("")}).limit(0)}function t(n){return"next"===n?function(n){return n.toUpperCase()}:function(n){return n.toLowerCase()}}function r(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function o(n,e,t,r,o,i){for(var u=Math.min(n.length,r.length),a=-1,s=0;s<u;++s){var c=e[s];if(c!==r[s])return o(n[s],t[s])<0?n.substr(0,s)+t[s]+t.substr(s+1):o(n[s],r[s])<0?n.substr(0,s)+r[s]+t.substr(s+1):a>=0?n.substr(0,a)+e[a]+t.substr(a+1):null;o(n[s],c)<0&&(a=s)}return u<r.length&&"next"===i?n+t.substr(n.length):u<n.length&&"prev"===i?n.substr(0,t.length):a<0?null:n.substr(0,a)+r[a]+t.substr(a+1)}function i(e,i,u,a){function s(n){c=t(n),f=r(n),l="next"===n?ln:hn;var e=u.map(function(n){return{lower:f(n),upper:c(n)}}).sort(function(n,e){return l(n.lower,e.lower)});h=e.map(function(n){return n.upper}),d=e.map(function(n){return n.lower}),p=n,v="next"===n?"":a}var c,f,l,h,d,p,v,y=u.length;if(!u.every(function(n){return"string"==typeof n}))return n(e,Ve);s("next");var m=new Y(e,function(){return qn.bound(h[0],d[y-1]+a)});m._ondirectionchange=function(n){s(n)};var b=0;return m._addAlgorithm(function(n,e,t){var r=n.key;if("string"!=typeof r)return!1;var u=f(r);if(i(u,d,b))return!0;for(var a=null,s=b;s<y;++s){var c=o(r,u,h[s],d[s],l,p);null===c&&null===a?b=s+1:(null===a||l(a,c)>0)&&(a=c)}return e(null!==a?function(){n.continue(a+v)}:t),!1}),m}return{between:function(t,r,o,i){o=!1!==o,i=!0===i;try{return en(t,r)>0||0===en(t,r)&&(o||i)&&(!o||!i)?e(this):new Y(this,function(){return qn.bound(t,r,!o,!i)})}catch(e){return n(this,Ge)}},equals:function(n){return new Y(this,function(){return qn.only(n)})},above:function(n){return new Y(this,function(){return qn.lowerBound(n,!0)})},aboveOrEqual:function(n){return new Y(this,function(){return qn.lowerBound(n)})},below:function(n){return new Y(this,function(){return qn.upperBound(n,!0)})},belowOrEqual:function(n){return new Y(this,function(){return qn.upperBound(n)})},startsWith:function(e){return"string"!=typeof e?n(this,Ve):this.between(e,e+qe,!0,!0)},startsWithIgnoreCase:function(n){return""===n?this.startsWith(n):i(this,function(n,e){return 0===n.indexOf(e[0])},[n],qe)},equalsIgnoreCase:function(n){return i(this,function(n,e){return n===e[0]},[n],"")},anyOfIgnoreCase:function(){var n=S.apply(zn,arguments);return 0===n.length?e(this):i(this,function(n,e){return-1!==e.indexOf(n)},n,"")},startsWithAnyOfIgnoreCase:function(){var n=S.apply(zn,arguments);return 0===n.length?e(this):i(this,function(n,e){return e.some(function(e){return 0===n.indexOf(e)})},n,qe)},anyOf:function(){var t=S.apply(zn,arguments),r=on;try{t.sort(r)}catch(e){return n(this,Ge)}if(0===t.length)return e(this);var o=new Y(this,function(){return qn.bound(t[0],t[t.length-1])});o._ondirectionchange=function(n){r="next"===n?on:un,t.sort(r)};var i=0;return o._addAlgorithm(function(n,e,o){for(var u=n.key;r(u,t[i])>0;)if(++i===t.length)return e(o),!1;return 0===r(u,t[i])||(e(function(){n.continue(t[i])}),!1)}),o},notEqual:function(n){return this.inAnyRange([[We,n],[n,He]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var e=S.apply(zn,arguments);if(0===e.length)return new Y(this);try{e.sort(on)}catch(e){return n(this,Ge)}var t=e.reduce(function(n,e){return n?n.concat([[n[n.length-1][1],e]]):[[We,e]]},null);return t.push([e[e.length-1],He]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(t,r){function o(n,e){for(var t=0,r=n.length;t<r;++t){var o=n[t];if(en(e[0],o[1])<0&&en(e[1],o[0])>0){o[0]=tn(o[0],e[0]),o[1]=rn(o[1],e[1]);break}}return t===r&&n.push(e),n}function i(n,e){return f(n[0],e[0])}function u(n){return!h(n)&&!d(n)}if(0===t.length)return e(this);if(!t.every(function(n){return void 0!==n[0]&&void 0!==n[1]&&on(n[0],n[1])<=0}))return n(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",re.InvalidArgument);var a,s=!r||!1!==r.includeLowers,c=r&&!0===r.includeUppers,f=on;try{a=t.reduce(o,[]),a.sort(i)}catch(e){return n(this,Ge)}var l=0,h=c?function(n){return on(n,a[l][1])>0}:function(n){return on(n,a[l][1])>=0},d=s?function(n){return un(n,a[l][0])>0}:function(n){return un(n,a[l][0])>=0},p=h,v=new Y(this,function(){return qn.bound(a[0][0],a[a.length-1][1],!s,!c)});return v._ondirectionchange=function(n){"next"===n?(p=h,f=on):(p=d,f=un),a.sort(i)},v._addAlgorithm(function(n,e,t){for(var r=n.key;p(r);)if(++l===a.length)return e(t),!1;return!!u(r)||0!==en(r,a[l][1])&&0!==en(r,a[l][0])&&(e(function(){f===on?n.continue(a[l][0]):n.continue(a[l][1])}),!1)}),v},startsWithAnyOf:function(){var t=S.apply(zn,arguments);return t.every(function(n){return"string"==typeof n})?0===t.length?e(this):this.inAnyRange(t.map(function(n){return[n,n+qe]})):n(this,"startsWithAnyOf() only works with strings")}}}),i(Y.prototype,function(){function n(n,e){n.filter=dn(n.filter,e)}function e(n,e,t){var r=n.replayFilter;n.replayFilter=r?function(){return dn(r(),e())}:e,n.justLimit=t&&!r}function t(n,e){n.isMatch=dn(n.isMatch,e)}function i(n,e){if(n.isPrimKey)return e;var t=n.table.schema.idxByName[n.index];if(!t)throw new re.Schema("KeyPath "+n.index+" on object store "+e.name+" is not indexed");return e.index(t.name)}function u(n,e){var t=i(n,e);return n.keysOnly&&"openKeyCursor"in t?t.openKeyCursor(n.range||null,n.dir+n.unique):t.openCursor(n.range||null,n.dir+n.unique)}function a(n,e,t,r,i){var a=n.replayFilter?dn(n.filter,n.replayFilter()):n.filter;n.or?function(){function s(){2==++l&&t()}function c(n,t,i){if(!a||a(t,i,s,r)){var u=t.primaryKey,c=""+u;"[object ArrayBuffer]"===c&&(c=""+new Uint8Array(u)),o(f,c)||(f[c]=!0,e(n,t,i))}}var f={},l=0;n.or._iterate(c,s,r,i),Z(u(n,i),n.algorithm,c,s,r,!n.keysOnly&&n.valueMapper)}():Z(u(n,i),dn(n.algorithm,a),e,t,r,!n.keysOnly&&n.valueMapper)}function s(n){return n.table.schema.instanceTemplate}return{_read:function(n,e){var t=this._ctx;return t.error?t.table._trans(null,Le.bind(null,t.error)):t.table._idbstore(ne,n).then(e)},_write:function(n){var e=this._ctx;return e.error?e.table._trans(null,Le.bind(null,e.error)):e.table._idbstore(ee,n,"locked")},_addAlgorithm:function(n){var e=this._ctx;e.algorithm=dn(e.algorithm,n)},_iterate:function(n,e,t,r){return a(this._ctx,n,e,t,r)},clone:function(n){var e=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return n&&r(t,n),e._ctx=t,e},raw:function(){return this._ctx.valueMapper=null,this},each:function(n){var e=this._ctx;if(Ze){var t=s(e),r=e.table.schema.primKey.keyPath,o=m(t,e.index?e.table.schema.idxByName[e.index].keyPath:r),i=m(t,r);n(t,{key:o,primaryKey:i})}return this._read(function(t,r,o){a(e,n,t,r,o)})},count:function(n){if(Ze)return H.resolve(0).then(n);var e=this._ctx;if(J(e,!0))return this._read(function(n,t,r){var o=i(e,r),u=e.range?o.count(e.range):o.count();u.onerror=Tn(t),u.onsuccess=function(t){n(Math.min(t.target.result,e.limit))}},n);var t=0;return this._read(function(n,r,o){a(e,function(){return++t,!1},function(){n(t)},r,o)},n)},sortBy:function(n,e){function t(n,e){return e?t(n[o[e]],e-1):n[i]}function r(n,e){var r=t(n,u),o=t(e,u);return r<o?-a:r>o?a:0}var o=n.split(".").reverse(),i=o[0],u=o.length-1,a="next"===this._ctx.dir?1:-1;return this.toArray(function(n){return n.sort(r)}).then(e)},toArray:function(n){var e=this._ctx;return this._read(function(n,t,r){if(Ze&&n([s(e)]),_n&&"next"===e.dir&&J(e,!0)&&e.limit>0){var o=e.table.hook.reading.fire,u=i(e,r),c=e.limit<1/0?u.getAll(e.range,e.limit):u.getAll(e.range);c.onerror=Tn(t),c.onsuccess=En(o===D?n:function(e){try{n(e.map(o))}catch(n){t(n)}})}else{var f=[];a(e,function(n){f.push(n)},function(){n(f)},t,r)}},n)},offset:function(n){var t=this._ctx;return n<=0?this:(t.offset+=n,J(t)?e(t,function(){var e=n;return function(n,t){return 0===e||(1===e?(--e,!1):(t(function(){n.advance(e),e=0}),!1))}}):e(t,function(){var e=n;return function(){return--e<0}}),this)},limit:function(n){return this._ctx.limit=Math.min(this._ctx.limit,n),e(this._ctx,function(){var e=n;return function(n,t,r){return--e<=0&&t(r),e>=0}},!0),this},until:function(e,t){var r=this._ctx;return Ze&&e(s(r)),n(this._ctx,function(n,r,o){return!e(n.value)||(r(o),t)}),this},first:function(n){return this.limit(1).toArray(function(n){return n[0]}).then(n)},last:function(n){return this.reverse().first(n)},filter:function(e){return Ze&&e(s(this._ctx)),n(this._ctx,function(n){return e(n.value)}),t(this._ctx,e),this},and:function(n){return this.filter(n)},or:function(n){return new z(this._ctx.table,n,this)},reverse:function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},desc:function(){return this.reverse()},eachKey:function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},eachUniqueKey:function(n){return this._ctx.unique="unique",this.eachKey(n)},eachPrimaryKey:function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},keys:function(n){var e=this._ctx;e.keysOnly=!e.isMatch;var t=[];return this.each(function(n,e){t.push(e.key)}).then(function(){return t}).then(n)},primaryKeys:function(n){var e=this._ctx;if(_n&&"next"===e.dir&&J(e,!0)&&e.limit>0)return this._read(function(n,t,r){var o=i(e,r),u=e.limit<1/0?o.getAllKeys(e.range,e.limit):o.getAllKeys(e.range);u.onerror=Tn(t),u.onsuccess=En(n)}).then(n);e.keysOnly=!e.isMatch;var t=[];return this.each(function(n,e){t.push(e.primaryKey)}).then(function(){return t}).then(n)},uniqueKeys:function(n){return this._ctx.unique="unique",this.keys(n)},firstKey:function(n){return this.limit(1).keys(function(n){return n[0]}).then(n)},lastKey:function(n){return this.reverse().firstKey(n)},distinct:function(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var r={};return n(this._ctx,function(n){var e=n.primaryKey.toString(),t=o(r,e);return r[e]=!0,!t}),this},modify:function(n){var e=this,t=this._ctx,i=t.table.hook,u=i.updating.fire,a=i.deleting.fire;return Ze&&"function"==typeof n&&n.call({value:t.table.schema.instanceTemplate},t.table.schema.instanceTemplate),this._write(function(t,i,s,c){function f(n,e){function t(n){return T.push(n),E.push(r.primKey),h(),!0}j=e.primaryKey;var r={primKey:e.primaryKey,value:n,onsuccess:null,onerror:null};if(!1!==d.call(r,n,r)){var i=!o(r,"value");++w,y(function(){var n=i?e.delete():e.update(r.value);n._hookCtx=r,n.onerror=jn(t),n.onsuccess=kn(function(){++S,h()})},t)}else r.onsuccess&&r.onsuccess(r.value)}function l(n){return n&&(T.push(n),E.push(j)),i(new R("Error modifying one or more objects",T,S,E))}function h(){k&&S+T.length===w&&(T.length>0?l():t(S))}var d;if("function"==typeof n)d=u===A&&a===A?n:function(e){var t=x(e);if(!1===n.call(this,e,this))return!1;if(o(this,"value")){