bimplus-websdk
Version:
bim+ websdk
2 lines • 181 kB
JavaScript
/*! For license information please see bimplus-websdk.js.LICENSE.txt */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.add=t():e.add=t()}(self,(()=>(()=>{var e={744:function(e,t,n){e.exports=function(){"use strict";var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)},t=function(){return(t=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 r(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||((r=r||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:n.g,o=Object.keys,s=Array.isArray;function u(e,t){return"object"!=typeof t||o(t).forEach((function(n){e[n]=t[n]})),e}"undefined"==typeof Promise||i.Promise||(i.Promise=Promise);var a=Object.getPrototypeOf,c={}.hasOwnProperty;function l(e,t){return c.call(e,t)}function f(e,t){"function"==typeof t&&(t=t(a(e))),("undefined"==typeof Reflect?o:Reflect.ownKeys)(t).forEach((function(n){h(e,n,t[n])}))}var p=Object.defineProperty;function h(e,t,n,r){p(e,t,u(n&&l(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function d(e){return{from:function(t){return e.prototype=Object.create(t.prototype),h(e.prototype,"constructor",e),{extend:f.bind(null,e.prototype)}}}}var g=Object.getOwnPropertyDescriptor,m=[].slice;function y(e,t,n){return m.call(e,t,n)}function v(e,t){return t(e)}function b(e){if(!e)throw new Error("Assertion Failed")}function w(e){i.setImmediate?setImmediate(e):setTimeout(e,0)}function T(e,t){if("string"==typeof t&&l(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=T(e,t[r]);n.push(o)}return n}var s=t.indexOf(".");if(-1!==s){var u=e[t.substr(0,s)];return null==u?void 0:T(u,t.substr(s+1))}}function A(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){b("string"!=typeof n&&"length"in n);for(var r=0,i=t.length;r<i;++r)A(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?s(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n:A(a=(a=e[o])&&l(e,o)?a:e[o]={},u,n)):void 0===n?s(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function q(e){var t,n={};for(t in e)l(e,t)&&(n[t]=e[t]);return n}var _=[].concat;function U(e){return _.apply([],e)}var k="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(U([8,16,32,64].map((function(e){return["Int","Uint","Float"].map((function(t){return t+e+"Array"}))})))).filter((function(e){return i[e]})),x=new Set(k.map((function(e){return i[e]}))),j=null;function S(e){return j=new WeakMap,e=function e(t){if(!t||"object"!=typeof t)return t;var n=j.get(t);if(n)return n;if(s(t)){n=[],j.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(x.has(t.constructor))n=t;else{var o,u=a(t);for(o in n=u===Object.prototype?{}:Object.create(u),j.set(t,n),t)l(t,o)&&(n[o]=e(t[o]))}return n}(e),j=null,e}var P={}.toString;function E(e){return P.call(e).slice(8,-1)}var O="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",D="symbol"==typeof O?function(e){var t;return null!=e&&(t=e[O])&&t.apply(e)}:function(){return null};function C(e,t){return 0<=(t=e.indexOf(t))&&e.splice(t,1),0<=t}var I={};function R(e){var t,n,r,i;if(1===arguments.length){if(s(e))return e.slice();if(this===I&&"string"==typeof e)return[e];if(i=D(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var B="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},K=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(ae=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"]),N={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function L(e,t){this.name=e,this.message=t}function M(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 F(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=M(e,t)}function G(e,t){this.name="BulkError",this.failures=Object.keys(t).map((function(e){return t[e]})),this.failuresByPos=t,this.message=M(e,this.failures)}d(L).from(Error).extend({toString:function(){return this.name+": "+this.message}}),d(F).from(L),d(G).from(L);var z=K.reduce((function(e,t){return e[t]=t+"Error",e}),{}),W=L,H=K.reduce((function(e,t){var n=t+"Error";function r(e,r){this.name=n,e?"string"==typeof e?(this.message="".concat(e).concat(r?"\n "+r:""),this.inner=r||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=N[t]||n,this.inner=null)}return d(r).from(W),e[t]=r,e}),{});H.Syntax=SyntaxError,H.Type=TypeError,H.Range=RangeError;var V=ae.reduce((function(e,t){return e[t+"Error"]=H[t],e}),{}),$=K.reduce((function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=H[t]),e}),{});function Q(){}function J(e){return e}function X(e,t){return null==e||e===J?t:function(n){return t(e(n))}}function Y(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function Z(e,t){return e===Q?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?Y(r,this.onsuccess):r),i&&(this.onerror=this.onerror?Y(i,this.onerror):i),void 0!==o?o:n}}function ee(e,t){return e===Q?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?Y(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Y(r,this.onerror):r)}}function te(e,t){return e===Q?t:function(n){var r=e.apply(this,arguments);u(n,r);var i=this.onsuccess,o=this.onerror;return this.onsuccess=null,this.onerror=null,n=t.apply(this,arguments),i&&(this.onsuccess=this.onsuccess?Y(i,this.onsuccess):i),o&&(this.onerror=this.onerror?Y(o,this.onerror):o),void 0===r?void 0===n?void 0:n:u(r,n)}}function ne(e,t){return e===Q?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function re(e,t){return e===Q?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return n.then((function(){return t.apply(r,o)}))}return t.apply(this,arguments)}}$.ModifyError=F,$.DexieError=L,$.BulkError=G;var ie="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function oe(e){ie=e}var se={},ue=100,ae=(k="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,a(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,a(t),e]}(),k[0]),ce=(K=k[1],k=k[2],K=K&&K.then,ae&&ae.constructor),le=!!k,fe=function(e,t){be.push([e,t]),he&&(queueMicrotask(Se),he=!1)},pe=!0,he=!0,de=[],ge=[],me=J,ye={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Q,pgp:!1,env:{},finalize:Q},ve=ye,be=[],we=0,Te=[];function Ae(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=ve;if("function"!=typeof e){if(e!==se)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Ue(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n((function(n){if(null===t._state){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&Pe();n&&"function"==typeof n.then?e(t,(function(e,t){n instanceof Ae?n._then(e,t):n.then(e,t)})):(t._state=!0,t._value=n,ke(t)),r&&Ee()}}),Ue.bind(null,t))}catch(n){Ue(t,n)}}(this,e)}var qe={get:function(){var e=ve,t=Ne;function n(n,r){var i=this,o=!e.global&&(e!==ve||t!==Ne),s=o&&!Ge(),u=new Ae((function(t,u){xe(i,new _e(Qe(n,e,o,s),Qe(r,e,o,s),t,u,e))}));return this._consoleTask&&(u._consoleTask=this._consoleTask),u}return n.prototype=se,n},set:function(e){h(this,"then",e&&e.prototype===se?qe:{get:function(){return e},set:qe.set})}};function _e(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 Ue(e,t){var n,r;ge.push(t),null===e._state&&(n=e._lib&&Pe(),t=me(t),e._state=!1,e._value=t,r=e,de.some((function(e){return e._value===r._value}))||de.push(r),ke(e),n&&Ee())}function ke(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)xe(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===we&&(++we,fe((function(){0==--we&&Oe()}),[]))}function xe(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,++we,fe(je,[n,e,t])}else e._listeners.push(t)}function je(e,t,n){try{var r,i=t._value;!t._state&&ge.length&&(ge=[]),r=ie&&t._consoleTask?t._consoleTask.run((function(){return e(i)})):e(i),t._state||-1!==ge.indexOf(i)||function(e){for(var t=de.length;t;)if(de[--t]._value===e._value)return de.splice(t,1)}(t),n.resolve(r)}catch(e){n.reject(e)}finally{0==--we&&Oe(),--n.psd.ref||n.psd.finalize()}}function Se(){$e(ye,(function(){Pe()&&Ee()}))}function Pe(){var e=pe;return he=pe=!1,e}function Ee(){var e,t,n;do{for(;0<be.length;)for(e=be,be=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<be.length);he=pe=!0}function Oe(){var e=de;de=[],e.forEach((function(e){e._PSD.onunhandled.call(null,e._value,e)}));for(var t=Te.slice(0),n=t.length;n;)t[--n]()}function De(e){return new Ae(se,!1,e)}function Ce(e,t){var n=ve;return function(){var r=Pe(),i=ve;try{return He(n,!0),e.apply(this,arguments)}catch(r){t&&t(r)}finally{He(i,!1),r&&Ee()}}}f(Ae.prototype,{then:qe,_then:function(e,t){xe(this,new _e(null,null,e,t,ve))},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:De)(e)})):this.then(null,(function(e){return(e&&e.name===t?n:De)(e)}))},finally:function(e){return this.then((function(t){return Ae.resolve(e()).then((function(){return t}))}),(function(t){return Ae.resolve(e()).then((function(){return De(t)}))}))},timeout:function(e,t){var n=this;return e<1/0?new Ae((function(r,i){var o=setTimeout((function(){return i(new H.Timeout(t))}),e);n.then(r,i).finally(clearTimeout.bind(null,o))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&h(Ae.prototype,Symbol.toStringTag,"Dexie.Promise"),ye.env=Ve(),f(Ae,{all:function(){var e=R.apply(null,arguments).map(ze);return new Ae((function(t,n){0===e.length&&t([]);var r=e.length;e.forEach((function(i,o){return Ae.resolve(i).then((function(n){e[o]=n,--r||t(e)}),n)}))}))},resolve:function(e){return e instanceof Ae?e:e&&"function"==typeof e.then?new Ae((function(t,n){e.then(t,n)})):new Ae(se,!0,e)},reject:De,race:function(){var e=R.apply(null,arguments).map(ze);return new Ae((function(t,n){e.map((function(e){return Ae.resolve(e).then(t,n)}))}))},PSD:{get:function(){return ve},set:function(e){return ve=e}},totalEchoes:{get:function(){return Ne}},newPSD:Me,usePSD:$e,scheduler:{get:function(){return fe},set:function(e){fe=e}},rejectionMapper:{get:function(){return me},set:function(e){me=e}},follow:function(e,t){return new Ae((function(n,r){return Me((function(t,n){var r=ve;r.unhandleds=[],r.onunhandled=n,r.finalize=Y((function(){var e,r=this;e=function(){0===r.unhandleds.length?t():n(r.unhandleds[0])},Te.push((function t(){e(),Te.splice(Te.indexOf(t),1)})),++we,fe((function(){0==--we&&Oe()}),[])}),r.finalize),e()}),t,n,r)}))}}),ce&&(ce.allSettled&&h(Ae,"allSettled",(function(){var e=R.apply(null,arguments).map(ze);return new Ae((function(t){0===e.length&&t([]);var n=e.length,r=new Array(n);e.forEach((function(e,i){return Ae.resolve(e).then((function(e){return r[i]={status:"fulfilled",value:e}}),(function(e){return r[i]={status:"rejected",reason:e}})).then((function(){return--n||t(r)}))}))}))})),ce.any&&"undefined"!=typeof AggregateError&&h(Ae,"any",(function(){var e=R.apply(null,arguments).map(ze);return new Ae((function(t,n){0===e.length&&n(new AggregateError([]));var r=e.length,i=new Array(r);e.forEach((function(e,o){return Ae.resolve(e).then((function(e){return t(e)}),(function(e){i[o]=e,--r||n(new AggregateError(i))}))}))}))})),ce.withResolvers&&(Ae.withResolvers=ce.withResolvers));var Ie={awaits:0,echoes:0,id:0},Re=0,Be=[],Ke=0,Ne=0,Le=0;function Me(e,t,n,r){var i=ve,o=Object.create(i);return o.parent=i,o.ref=0,o.global=!1,o.id=++Le,ye.env,o.env=le?{Promise:Ae,PromiseProp:{value:Ae,configurable:!0,writable:!0},all:Ae.all,race:Ae.race,allSettled:Ae.allSettled,any:Ae.any,resolve:Ae.resolve,reject:Ae.reject}:{},t&&u(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()},r=$e(o,e,n,r),0===o.ref&&o.finalize(),r}function Fe(){return Ie.id||(Ie.id=++Re),++Ie.awaits,Ie.echoes+=ue,Ie.id}function Ge(){return!!Ie.awaits&&(0==--Ie.awaits&&(Ie.id=0),Ie.echoes=Ie.awaits*ue,!0)}function ze(e){return Ie.echoes&&e&&e.constructor===ce?(Fe(),e.then((function(e){return Ge(),e}),(function(e){return Ge(),Xe(e)}))):e}function We(){var e=Be[Be.length-1];Be.pop(),He(e,!1)}function He(e,t){var n,r=ve;(t?!Ie.echoes||Ke++&&e===ve:!Ke||--Ke&&e===ve)||queueMicrotask(t?function(e){++Ne,Ie.echoes&&0!=--Ie.echoes||(Ie.echoes=Ie.awaits=Ie.id=0),Be.push(ve),He(e,!0)}.bind(null,e):We),e!==ve&&(ve=e,r===ye&&(ye.env=Ve()),le&&(n=ye.env.Promise,t=e.env,(r.global||e.global)&&(Object.defineProperty(i,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function Ve(){var e=i.Promise;return le?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(i,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function $e(e,t,n,r,i){var o=ve;try{return He(e,!0),t(n,r,i)}finally{He(o,!1)}}function Qe(e,t,n,r){return"function"!=typeof e?e:function(){var i=ve;n&&Fe(),He(t,!0);try{return e.apply(this,arguments)}finally{He(i,!1),r&&queueMicrotask(Ge)}}}function Je(e){Promise===ce&&0===Ie.echoes?0===Ke?e():enqueueNativeMicroTask(e):setTimeout(e,0)}-1===(""+K).indexOf("[native code]")&&(Fe=Ge=Q);var Xe=Ae.reject,Ye=String.fromCharCode(65535),Ze="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",et="String expected.",tt=[],nt="__dbnames",rt="readonly",it="readwrite";function ot(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var st={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function ut(e){return"string"!=typeof e||/\./.test(e)?function(e){return e}:function(t){return void 0===t[e]&&e in t&&delete(t=S(t))[e],t}}function at(){throw H.Type()}function ct(e,t){try{var n=lt(e),r=lt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o)if(e[o]!==t[o])return e[o]<t[o]?-1:1;return n===r?0:n<r?-1:1}(ft(e),ft(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o){var s=ct(e[o],t[o]);if(0!==s)return s}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function lt(e){var t=typeof e;return"object"!=t?t:ArrayBuffer.isView(e)||"ArrayBuffer"===(e=E(e))?"binary":e}function ft(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var pt=(ht.prototype._trans=function(e,t,n){var r=this._tx||ve.trans,i=this.name,o=ie&&"undefined"!=typeof console&&console.createTask&&console.createTask("Dexie: ".concat("readonly"===e?"read":"write"," ").concat(this.name));function s(e,n,r){if(!r.schema[i])throw new H.NotFound("Table "+i+" not part of transaction");return t(r.idbtrans,r)}var u=Pe();try{var a=r&&r.db._novip===this.db._novip?r===ve.trans?r._promise(e,s,n):Me((function(){return r._promise(e,s,n)}),{trans:r,transless:ve.transless||ve}):function e(t,n,r,i){if(t.idbdb&&(t._state.openComplete||ve.letThrough||t._vip)){var o=t._createTransaction(n,r,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(o){return o.name===z.InvalidState&&t.isOpen()&&0<--t._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),t.close({disableAutoOpen:!1}),t.open().then((function(){return e(t,n,r,i)}))):Xe(o)}return o._promise(n,(function(e,t){return Me((function(){return ve.trans=o,i(e,t,o)}))})).then((function(e){if("readwrite"===n)try{o.idbtrans.commit()}catch(e){}return"readonly"===n?e:o._completion.then((function(){return e}))}))}if(t._state.openComplete)return Xe(new H.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return Xe(new H.DatabaseClosed);t.open().catch(Q)}return t._state.dbReadyPromise.then((function(){return e(t,n,r,i)}))}(this.db,e,[this.name],s);return o&&(a._consoleTask=o,a=a.catch((function(e){return console.trace(e),Xe(e)}))),a}finally{u&&Ee()}},ht.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):null==e?Xe(new H.Type("Invalid argument to Table.get()")):this._trans("readonly",(function(t){return n.core.get({trans:t,key:e}).then((function(e){return n.hook.reading.fire(e)}))})).then(t)},ht.prototype.where=function(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(s(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=o(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter((function(e){if(e.compound&&t.every((function(t){return 0<=e.keyPath.indexOf(t)}))){for(var n=0;n<t.length;++n)if(-1===t.indexOf(e.keyPath[n]))return!1;return!0}return!1})).sort((function(e,t){return e.keyPath.length-t.keyPath.length}))[0];if(n&&this.db._maxKey!==Ye){var r=n.keyPath.slice(0,t.length);return this.where(r).equals(r.map((function(t){return e[t]})))}!n&&ie&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(t.join("+"),"]"));var i=this.schema.idxByName;function u(e,t){return 0===ct(e,t)}var a=t.reduce((function(t,n){var r=t[0],o=t[1],a=(t=i[n],e[n]);return[r||t,r||!t?ot(o,t&&t.multi?function(e){return e=T(e,n),s(e)&&e.some((function(e){return u(a,e)}))}:function(e){return u(a,T(e,n))}):o]}),[null,null]);return r=a[0],a=a[1],r?this.where(r.name).equals(e[r.keyPath]).filter(a):n?this.filter(a):this.where(t).equals("")},ht.prototype.filter=function(e){return this.toCollection().and(e)},ht.prototype.count=function(e){return this.toCollection().count(e)},ht.prototype.offset=function(e){return this.toCollection().offset(e)},ht.prototype.limit=function(e){return this.toCollection().limit(e)},ht.prototype.each=function(e){return this.toCollection().each(e)},ht.prototype.toArray=function(e){return this.toCollection().toArray(e)},ht.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},ht.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,s(e)?"[".concat(e.join("+"),"]"):e))},ht.prototype.reverse=function(){return this.toCollection().reverse()},ht.prototype.mapToClass=function(t){var n,r=this.db,i=this.name;function o(){return null!==n&&n.apply(this,arguments)||this}(this.schema.mappedClass=t).prototype instanceof at&&(function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,n=t),Object.defineProperty(o.prototype,"db",{get:function(){return r},enumerable:!1,configurable:!0}),o.prototype.table=function(){return i},t=o);for(var s=new Set,u=t.prototype;u;u=a(u))Object.getOwnPropertyNames(u).forEach((function(e){return s.add(e)}));function c(e){if(!e)return e;var n,r=Object.create(t.prototype);for(n in e)if(!s.has(n))try{r[n]=e[n]}catch(e){}return r}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=c,this.hook("reading",c),t},ht.prototype.defineClass=function(){return this.mapToClass((function(e){u(this,e)}))},ht.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,s=e;return o&&i&&(s=ut(o)(e)),this._trans("readwrite",(function(e){return n.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[s]})})).then((function(e){return e.numFailures?Ae.reject(e.failures[0]):e.lastResult})).then((function(t){if(o)try{A(e,o,t)}catch(t){}return t}))},ht.prototype.update=function(e,t){return"object"!=typeof e||s(e)?this.where(":id").equals(e).modify(t):void 0===(e=T(e,this.schema.primKey.keyPath))?Xe(new H.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)},ht.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,s=e;return o&&i&&(s=ut(o)(e)),this._trans("readwrite",(function(e){return n.core.mutate({trans:e,type:"put",values:[s],keys:null!=t?[t]:null})})).then((function(e){return e.numFailures?Ae.reject(e.failures[0]):e.lastResult})).then((function(t){if(o)try{A(e,o,t)}catch(t){}return t}))},ht.prototype.delete=function(e){var t=this;return this._trans("readwrite",(function(n){return t.core.mutate({trans:n,type:"delete",keys:[e]})})).then((function(e){return e.numFailures?Ae.reject(e.failures[0]):void 0}))},ht.prototype.clear=function(){var e=this;return this._trans("readwrite",(function(t){return e.core.mutate({trans:t,type:"deleteRange",range:st})})).then((function(e){return e.numFailures?Ae.reject(e.failures[0]):void 0}))},ht.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",(function(n){return t.core.getMany({keys:e,trans:n}).then((function(e){return e.map((function(e){return t.hook.reading.fire(e)}))}))}))},ht.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(function(t){var n=(u=r.schema.primKey).auto;if((u=u.keyPath)&&i)throw new H.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new H.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length,u=u&&n?e.map(ut(u)):e;return r.core.mutate({trans:t,type:"add",keys:i,values:u,wantResults:o}).then((function(e){var t=e.numFailures,n=e.results,i=e.lastResult;if(e=e.failures,0===t)return o?n:i;throw new G("".concat(r.name,".bulkAdd(): ").concat(t," of ").concat(s," operations failed"),e)}))}))},ht.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(function(t){var n=(u=r.schema.primKey).auto;if((u=u.keyPath)&&i)throw new H.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new H.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length,u=u&&n?e.map(ut(u)):e;return r.core.mutate({trans:t,type:"put",keys:i,values:u,wantResults:o}).then((function(e){var t=e.numFailures,n=e.results,i=e.lastResult;if(e=e.failures,0===t)return o?n:i;throw new G("".concat(r.name,".bulkPut(): ").concat(t," of ").concat(s," operations failed"),e)}))}))},ht.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map((function(e){return e.key})),i=e.map((function(e){return e.changes})),o=[];return this._trans("readwrite",(function(s){return n.getMany({trans:s,keys:r,cache:"clone"}).then((function(u){var a=[],c=[];e.forEach((function(e,n){var r=e.key,i=e.changes,s=u[n];if(s){for(var l=0,f=Object.keys(i);l<f.length;l++){var p=f[l],h=i[p];if(p===t.schema.primKey.keyPath){if(0!==ct(h,r))throw new H.Constraint("Cannot update primary key in bulkUpdate()")}else A(s,p,h)}o.push(n),a.push(r),c.push(s)}}));var l=a.length;return n.mutate({trans:s,type:"put",keys:a,values:c,updates:{keys:r,changeSpecs:i}}).then((function(e){var n=e.numFailures,r=e.failures;if(0===n)return l;for(var i=0,s=Object.keys(r);i<s.length;i++){var u,a=s[i],c=o[Number(a)];null!=c&&(u=r[a],delete r[a],r[c]=u)}throw new G("".concat(t.name,".bulkUpdate(): ").concat(n," of ").concat(l," operations failed"),r)}))}))}))},ht.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",(function(n){return t.core.mutate({trans:n,type:"delete",keys:e})})).then((function(e){var r=e.numFailures,i=e.lastResult;if(e=e.failures,0===r)return i;throw new G("".concat(t.name,".bulkDelete(): ").concat(r," of ").concat(n," operations failed"),e)}))},ht);function ht(){}function dt(e){function t(t,r){if(r){for(var i=arguments.length,o=new Array(i-1);--i;)o[i-1]=arguments[i];return n[t].subscribe.apply(null,o),e}if("string"==typeof t)return n[t]}var n={};t.addEventType=u;for(var r=1,i=arguments.length;r<i;++r)u(arguments[r]);return t;function u(e,r,i){if("object"!=typeof e){var a;r=r||ne;var c={subscribers:[],fire:i=i||Q,subscribe:function(e){-1===c.subscribers.indexOf(e)&&(c.subscribers.push(e),c.fire=r(c.fire,e))},unsubscribe:function(e){c.subscribers=c.subscribers.filter((function(t){return t!==e})),c.fire=c.subscribers.reduce(r,i)}};return n[e]=t[e]=c}o(a=e).forEach((function(e){var t=a[e];if(s(t))u(e,a[e][0],a[e][1]);else{if("asap"!==t)throw new H.InvalidArgument("Invalid event config");var n=u(e,J,(function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach((function(e){w((function(){e.apply(null,t)}))}))}))}}))}}function gt(e,t){return d(t).from({prototype:e}),t}function mt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function yt(e,t){e.filter=ot(e.filter,t)}function vt(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 H.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function wt(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 Tt(e,t,n,r){var i=e.replayFilter?ot(e.filter,e.replayFilter()):e.filter;if(e.or){var o={},s=function(e,n,r){var s,u;i&&!i(n,r,(function(e){return n.stop(e)}),(function(e){return n.fail(e)}))||("[object ArrayBuffer]"==(u=""+(s=n.primaryKey))&&(u=""+new Uint8Array(s)),l(o,u)||(o[u]=!0,t(e,n,r)))};return Promise.all([e.or._iterate(s,n),At(wt(e,r,n),e.algorithm,s,!e.keysOnly&&e.valueMapper)])}return At(wt(e,r,n),ot(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function At(e,t,n,r){var i=Ce(r?function(e,t,i){return n(r(e),t,i)}:n);return e.then((function(e){if(e)return e.start((function(){var n=function(){return e.continue()};t&&!t(e,(function(e){return n=e}),(function(t){e.stop(t),n=Q}),(function(t){e.fail(t),n=Q}))||i(e.value,e,(function(e){return n=e})),n()}))}))}var qt=(_t.prototype.execute=function(e){var t=this["@@propmod"];if(void 0!==t.add){var n=t.add;if(s(n))return r(r([],s(e)?e:[],!0),n,!0).sort();if("number"==typeof n)return(Number(e)||0)+n;if("bigint"==typeof n)try{return BigInt(e)+n}catch(e){return BigInt(0)+n}throw new TypeError("Invalid term ".concat(n))}if(void 0!==t.remove){var i=t.remove;if(s(i))return s(e)?e.filter((function(e){return!i.includes(e)})).sort():[];if("number"==typeof i)return Number(e)-i;if("bigint"==typeof i)try{return BigInt(e)-i}catch(e){return BigInt(0)-i}throw new TypeError("Invalid subtrahend ".concat(i))}return(n=null===(n=t.replacePrefix)||void 0===n?void 0:n[0])&&"string"==typeof e&&e.startsWith(n)?t.replacePrefix[1]+e.substring(n.length):e},_t);function _t(e){this["@@propmod"]=e}var Ut=(kt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,Xe.bind(null,n.error)):n.table._trans("readonly",e).then(t)},kt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,Xe.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},kt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=ot(t.algorithm,e)},kt.prototype._iterate=function(e,t){return Tt(this._ctx,e,t,this._ctx.table.core)},kt.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&u(n,e),t._ctx=n,t},kt.prototype.raw=function(){return this._ctx.valueMapper=null,this},kt.prototype.each=function(e){var t=this._ctx;return this._read((function(n){return Tt(t,e,n,t.table.core)}))},kt.prototype.count=function(e){var t=this;return this._read((function(e){var n=t._ctx,r=n.table.core;if(mt(n,!0))return r.count({trans:e,query:{index:bt(n,r.schema),range:n.range}}).then((function(e){return Math.min(e,n.limit)}));var i=0;return Tt(n,(function(){return++i,!1}),e,r).then((function(){return i}))})).then(e)},kt.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 s="next"===this._ctx.dir?1:-1;function u(e,t){return ct(o(e,i),o(t,i))*s}return this.toArray((function(e){return e.sort(u)})).then(t)},kt.prototype.toArray=function(e){var t=this;return this._read((function(e){var n=t._ctx;if("next"===n.dir&&mt(n,!0)&&0<n.limit){var r=n.valueMapper,i=bt(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then((function(e){return e=e.result,r?e.map(r):e}))}var o=[];return Tt(n,(function(e){return o.push(e)}),e,n.table.core).then((function(){return o}))}),e)},kt.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,mt(t)?vt(t,(function(){var t=e;return function(e,n){return 0===t||(1===t?--t:n((function(){e.advance(t),t=0})),!1)}})):vt(t,(function(){var t=e;return function(){return--t<0}}))),this},kt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),vt(this._ctx,(function(){var t=e;return function(e,n,r){return--t<=0&&n(r),0<=t}}),!0),this},kt.prototype.until=function(e,t){return yt(this._ctx,(function(n,r,i){return!e(n.value)||(r(i),t)})),this},kt.prototype.first=function(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)},kt.prototype.last=function(e){return this.reverse().first(e)},kt.prototype.filter=function(e){var t;return yt(this._ctx,(function(t){return e(t.value)})),(t=this._ctx).isMatch=ot(t.isMatch,e),this},kt.prototype.and=function(e){return this.filter(e)},kt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},kt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},kt.prototype.desc=function(){return this.reverse()},kt.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.key,n)}))},kt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},kt.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.primaryKey,n)}))},kt.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)},kt.prototype.primaryKeys=function(e){var t=this._ctx;if("next"===t.dir&&mt(t,!0)&&0<t.limit)return this._read((function(e){var n=bt(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})})).then((function(e){return e.result})).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.primaryKey)})).then((function(){return n})).then(e)},kt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},kt.prototype.firstKey=function(e){return this.limit(1).keys((function(e){return e[0]})).then(e)},kt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},kt.prototype.distinct=function(){var e;if(!(e=(e=this._ctx).index&&e.table.schema.idxByName[e.index])||!e.multi)return this;var t={};return yt(this._ctx,(function(e){var n=e.primaryKey.toString();return e=l(t,n),t[n]=!0,!e})),this},kt.prototype.modify=function(e){var t=this,n=this._ctx;return this._write((function(r){var i,s,u;u="function"==typeof e?e:(i=o(e),s=i.length,function(t){for(var n=!1,r=0;r<s;++r){var o=i[r],u=e[o],a=T(t,o);u instanceof qt?(A(t,o,u.execute(a)),n=!0):a!==u&&(A(t,o,u),n=!0)}return n});var a,c=n.table.core,l=(a=c.schema.primaryKey).outbound,f=a.extractKey,p=200;function h(e,t){var n=t.failures;t=t.numFailures,g+=e-t;for(var r=0,i=o(n);r<i.length;r++){var s=i[r];d.push(n[s])}}(a=t.db._options.modifyChunkSize)&&(p="object"==typeof a?a[c.name]||a["*"]||200:a);var d=[],g=0,m=[];return t.clone().primaryKeys().then((function(t){function i(n){var s=Math.min(p,t.length-n);return c.getMany({trans:r,keys:t.slice(n,n+s),cache:"immutable"}).then((function(a){for(var d=[],g=[],m=l?[]:null,y=[],v=0;v<s;++v){var b=a[v],w={value:S(b),primKey:t[n+v]};!1!==u.call(w,w.value,w)&&(null==w.value?y.push(t[n+v]):l||0===ct(f(b),f(w.value))?(g.push(w.value),l&&m.push(t[n+v])):(y.push(t[n+v]),d.push(w.value)))}return Promise.resolve(0<d.length&&c.mutate({trans:r,type:"add",values:d}).then((function(e){for(var t in e.failures)y.splice(parseInt(t),1);h(d.length,e)}))).then((function(){return(0<g.length||o&&"object"==typeof e)&&c.mutate({trans:r,type:"put",keys:m,values:g,criteria:o,changeSpec:"function"!=typeof e&&e,isAdditionalChunk:0<n}).then((function(e){return h(g.length,e)}))})).then((function(){return(0<y.length||o&&e===xt)&&c.mutate({trans:r,type:"delete",keys:y,criteria:o,isAdditionalChunk:0<n}).then((function(e){return h(y.length,e)}))})).then((function(){return t.length>n+s&&i(n+p)}))}))}var o=mt(n)&&n.limit===1/0&&("function"!=typeof e||e===xt)&&{index:n.index,range:n.range};return i(0).then((function(){if(0<d.length)throw new F("Error modifying one or more objects",d,g,m);return t.length}))}))}))},kt.prototype.delete=function(){var e=this._ctx,t=e.range;return mt(e)&&(e.isPrimKey||3===t.type)?this._write((function(n){var r=e.table.core.schema.primaryKey,i=t;return e.table.core.count({trans:n,query:{index:r,range:i}}).then((function(t){return e.table.core.mutate({trans:n,type:"deleteRange",range:i}).then((function(e){var n=e.failures;if(e.lastResult,e.results,e=e.numFailures)throw new F("Could not delete some values",Object.keys(n).map((function(e){return n[e]})),t-e);return t-e}))}))})):this.modify(xt)},kt);function kt(){}var xt=function(e,t){return t.value=null};function jt(e,t){return e<t?-1:e===t?0:1}function St(e,t){return t<e?-1:e===t?0:1}function Pt(e,t,n){return(e=e instanceof It?new e.Collection(e):e)._ctx.error=new(n||TypeError)(t),e}function Et(e){return new e.Collection(e,(function(){return Ct("")})).limit(0)}function Ot(e,t,n,r){var i,o,s,u,a,c,l,f=n.length;if(!n.every((function(e){return"string"==typeof e})))return Pt(e,et);function p(e){i="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},o="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},s="next"===e?jt:St;var t=n.map((function(e){return{lower:o(e),upper:i(e)}})).sort((function(e,t){return s(e.lower,t.lower)}));u=t.map((function(e){return e.upper})),a=t.map((function(e){return e.lower})),l="next"===(c=e)?"":r}p("next"),(e=new e.Collection(e,(function(){return Dt(u[0],a[f-1]+r)})))._ondirectionchange=function(e){p(e)};var h=0;return e._addAlgorithm((function(e,n,r){var i=e.key;if("string"!=typeof i)return!1;var p=o(i);if(t(p,a,h))return!0;for(var d=null,g=h;g<f;++g){var m=function(e,t,n,r,i,o){for(var s=Math.min(e.length,r.length),u=-1,a=0;a<s;++a){var c=t[a];if(c!==r[a])return i(e[a],n[a])<0?e.substr(0,a)+n[a]+n.substr(a+1):i(e[a],r[a])<0?e.substr(0,a)+r[a]+n.substr(a+1):0<=u?e.substr(0,u)+t[u]+n.substr(u+1):null;i(e[a],c)<0&&(u=a)}return s<r.length&&"next"===o?e+n.substr(e.length):s<e.length&&"prev"===o?e.substr(0,n.length):u<0?null:e.substr(0,u)+r[u]+n.substr(u+1)}(i,p,u[g],a[g],s,c);null===m&&null===d?h=g+1:(null===d||0<s(d,m))&&(d=m)}return n(null!==d?function(){e.continue(d+l)}:r),!1})),e}function Dt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Ct(e){return{type:1,lower:e,upper:e}}var It=(Object.defineProperty(Rt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Rt.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)?Et(this):new this.Collection(this,(function(){return Dt(e,t,!n,!r)}))}catch(e){return Pt(this,Ze)}},Rt.prototype.equals=function(e){return null==e?Pt(this,Ze):new this.Collection(this,(function(){return Ct(e)}))},Rt.prototype.above=function(e){return null==e?Pt(this,Ze):new this.Collection(this,(function(){return Dt(e,void 0,!0)}))},Rt.prototype.aboveOrEqual=function(e){return null==e?Pt(this,Ze):new this.Collection(this,(function(){return Dt(e,void 0,!1)}))},Rt.prototype.below=function(e){return null==e?Pt(this,Ze):new this.Collection(this,(function(){return Dt(void 0,e,!1,!0)}))},Rt.prototype.belowOrEqual=function(e){return null==e?Pt(this,Ze):new this.Collection(this,(function(){return Dt(void 0,e)}))},Rt.prototype.startsWith=function(e){return"string"!=typeof e?Pt(this,et):this.between(e,e+Ye,!0,!0)},Rt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Ot(this,(function(e,t){return 0===e.indexOf(t[0])}),[e],Ye)},Rt.prototype.equalsIgnoreCase=function(e){return Ot(this,(function(e,t){return e===t[0]}),[e],"")},Rt.prototype.anyOfIgnoreCase=function(){var e=R.apply(I,arguments);return 0===e.length?Et(this):Ot(this,(function(e,t){return-1!==t.indexOf(e)}),e,"")},Rt.prototype.startsWithAnyOfIgnoreCase=function(){var e=R.apply(I,arguments);return 0===e.length?Et(this):Ot(this,(function(e,t){return t.some((function(t){return 0===e.indexOf(t)}))}),e,Ye)},Rt.prototype.anyOf=function(){var e=this,t=R.apply(I,arguments),n=this._cmp;try{t.sort(n)}catch(r){return Pt(this,Ze)}if(0===t.length)return Et(this);var r=new this.Collection(this,(function(){return Dt(t[0],t[t.length-1])}));r._ondirectionchange=function(r){n="next"===r?e._ascending:e._descending,t.sort(n)};var i=0;return r._addAlgorithm((function(e,r,o){for(var s=e.key;0<n(s,t[i]);)if(++i===t.length)return r(o),!1;return 0===n(s,t[i])||(r((function(){e.continue(t[i])})),!1)})),r},Rt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Rt.prototype.noneOf=function(){var e=R.apply(I,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Pt(this,Ze)}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})},Rt.prototype.inAnyRange=function(e,t){var n=this,r=this._cmp,i=this._ascending,o=this._descending,s=this._min,u=this._max;if(0===e.length)return Et(this);if(!e.every((function(e){return void 0!==e[0]&&void 0!==e[1]&&i(e[0],e[1])<=0})))return Pt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",H.InvalidArgument);var a,c=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,f=i;function p(e,t){return f(e[0],t[0])}try{(a=e.reduce((function(e,t){for(var n=0,i=e.length;n<i;++n){var o=e[n];if(r(t[0],o[1])<0&&0<r(t[1],o[0])){o[0]=s(o[0],t[0]),o[1]=u(o[1],t[1]);break}}return n===i&&e.push(t),e}),[])).sort(p)}catch(e){return Pt(this,Ze)}var h=0,d=l?function(e){return 0<i(e,a[h][1])}:function(e){return 0<=i(e,a[h][1])},g=c?function(e){return 0<o(e,a[h][0])}:function(e){return 0<=o(e,a[h][0])},m=d;return(e=new this.Collection(this,(function(){return Dt(a[0][0],a[a.length-1][1],!c,!l)})))._ondirectionchange=function(e){f="next"===e?(m=d,i):(m=g,o),a.sort(p)},e._addAlgorithm((function(e,t,r){for(var o,s=e.key;m(s);)if(++h===a.length)return t(r),!1;return!d(o=s)&&!g(o)||(0===n._cmp(s,a[h][1])||0===n._cmp(s,a[h][0])||t((function(){f===i?e.continue(a[h][0]):e.continue(a[h][1])})),!1)})),e},Rt.prototype.startsWithAnyOf=function(){var e=R.apply(I,arguments);return e.every((function(e){return"string"==typeof e}))?0===e.length?Et(this):this.inAnyRange(e.map((function(e){return[e,e+Ye]}))):Pt(this,"startsWithAnyOf() only works with strings")},Rt);function Rt(){}function Bt(e){return Ce((function(t){return Kt(t),e(t.target.error),!1}))}function Kt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Nt="storagemutated",Lt="x-storagemutated-1",Mt=dt(null,Nt),Ft=(Gt.prototype._lock=function(){return b(!ve.global),++this._reculock,1!==this._reculock||ve.global||(ve.lockOwnerFor=this),this},Gt.prototype._unlock=function(){if(b(!ve.global),0==--this._reculock)for(ve.global||(ve.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{$e(e[1],e[0])}catch(e){}}return this},Gt.prototype._locked=function(){return this._reculock&&ve.lockOwnerFor!==this},Gt.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if(b(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new H.DatabaseClosed(r);case"MissingAPIError":throw new H.MissingAPI(r.message,r);default:throw new H.OpenFailed(r)}if(!this.active)throw new H.TransactionInactive;return b(null===this._completion._state),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Ce((function(n){Kt(n),t._reject(e.error)})),e.onabort=Ce((function(n){Kt(n),t.active&&t._reject(new H.Abort(e.error)),t.active=!1,t.on("abort").fire(n)})),e.oncomplete=Ce((function(){t.active=!1,t._resolve(),"mutatedParts"in e&&Mt.storagemutated.fire(e.mutatedParts)})),this},Gt.prototype._promise=function(e,t,n){var r=this;if("readwrite"===e&&"readwrite"!==this.mode)return Xe(new H.ReadOnly("Transaction is readonly"));if(!this.active)return Xe(new H.TransactionInactive);if(this._locked())return new Ae((function(i,o){r._blockedFuncs.push([function(){r._promise(e,t,n).then(i,o)},ve])}));if(n)return Me((function(){var e=new Ae((function(e,n){r._lock();var i=t(e,n,r);i&&i.then&&i.then(e,n)}));return e.finally((function(){return r._unlock()})),e._lib=!0,e}));var i=new Ae((function(e,n){var i=t(e,n,r);i&&i.then&&i.then(e,n)}));return i._lib=!0,i},Gt.prototype._root=function(){return this.parent?this.parent._root():this},Gt.prototype.waitFor=function(e){var t,n=this._root(),r=Ae.resolve(e);n._waitingFor?n._waitingFor=n._waitingFor.then((function(){return r})):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=e)}());var i=n._waitingFor;return new Ae((function(e,t){r.then((function(t){return n._waitingQueue.push(Ce(e.bind(null,t)))}),(function(e){return n._waitingQueue.push(Ce(t.bind(null,e)))})).finally((function(){n._waitingFor===i&&(n._waitingFor=null)}))}))},Gt.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new H.Abort))},Gt.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(l(t,e))return t[e];var n=this.schema[e];if(!n)throw new H.NotFound("Table "+e+" not part of transaction");return(n=new this.db.Table(e,n,this)).core=this.db.core.table(e),t[e]=n},Gt);function Gt(){}function zt(e,t,n,r,i,o,s){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:o,src:(n&&!s?"&":"")+(r?"*":"")+(i?"++":"")+Wt(t)}}function Wt(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function Ht(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(e){return[e.name,e]},n.reduce((function(e,t,n){return(n=r(t,n))&&(e[n[0]]=n[1]),e}),{}))};var r}var Vt=function(e){try{return e.only([[]]),Vt=function(){return[[]]},[[]]}catch(e){return Vt=function(){return Ye},Ye}};function $t(e){return null==e?function(){}:"string"==typeof e?1===(t=e).split(".").length?function(e){return e[t]}:function(e){return T(e,t)}:function(t){return T(t,e)};var t}function Qt(e){return[].slice.call(e)}var Jt=0;function Xt(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function Yt(e,t,n){function r(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var n=e.lower,r=e.upper,i=e.lowerOpen;return e=e.upperOpen,void 0===n?void 0===r?null:t.upperBound(r,!!e):void 0===r?t.lowerBound(n,!!i):t.bound(n,r,!!i,!!e)}function i(e){var t,n=e.name;return{name:n,schema:e,mutate:function(e){var t=e.trans,i=e.type,o=e.keys,s=e.values,u=e.range;return new Promise((function(e,a){e=Ce(e);var c=t.objectStore(n),l=null==c.keyPath,f="put"===i||"add"===i;if(!f&&"delete"!==i&&"deleteRange"!==i)throw new Error("Invalid operation type: "+i);var p,h=(o||s||{length:1}).length;if(o&&s&&o.length!==s.length)throw new Error("Given keys array must have same length as given values array.");if(0===h)return e({numFailures:0,failures:{},results:[],lastResult:void 0});function d(e){++y,Kt(e)}var g=[],m=[],y=0;if("deleteRange"===i){if(4===u.type)return e({numFailures:y,failures:m,results:[],lastResult:void 0});3===u.type?g.push(p=c.clear()):g.push(p=c.delete(r(u)))}else{var v=(l=f?l?[s,o]:[s,null]:[o,null])[0],b=l[1];if(f)for(var w=0;w<h;++w)g.push(p=b&&void 0!==b[w]?c[i](v[w],b[w]):c[i](v[w])),p.onerror=d;else for(w=0;w<h;++w)g.push(p=c[i](v[w])),p.onerror=d}function T(t){t=t.target.result,g.forEach((function(e,t){return null!=e.error&&(m[t]=e.error)})),e({numFailures:y,failures:m,results:"delete"===i?o:g.map((function(e){return e.result})),lastResult:t})}p.onerror=function(e){d(e),T(e)},p.onsuccess=T}))},getMany:function(e){var t=e.trans,r=e.keys;return new Promise((function(e,i){e=Ce(e);for(var o,s=t.objectStore(n),u=r.length,a=new Array(u),c=0,l=0,f=function(t){t=t.target,a[t._pos]=t.result,++l===c&&e(a)},p=Bt(i),h=0;h<u;++h)null!=r[h]&&((o=s.get(r[h]))._pos=h,o.onsuccess=f,o.onerror=p,++c);0===c&&e(a)}))},get:function(e){var t=e.trans,r=e.key;return new Promise((function(e,i){e=Ce(e);var o=t.objectStore(n).get(r);o.onsuccess=function(t){return e(t.target.result)},o.onerror=Bt(i)}))},query:(t=l,function(e){return new Promise((function(i,o){i=Ce(i);var s,u,a,c=e.trans,l=e.values,f=e.limit,p=e.query,h=f===1/0?void 0:f,d=p.index;if(p=p.range,c=c.objectStore(n),d=d.isPrimaryKey?c:c.index(d.name),p=r(p),0===f)return i({result:[]});t?((h=l?d.getAll(p,h):d.getAllKeys(p,h)).onsuccess=function(e){return i({result:e.target.result})},h.onerror=Bt(o)):(s=0,u=!l&&"openKeyCursor"in d?d.openKeyCursor(p):d.openCursor(p),a=[],u.onsuccess=function(e){var t=u.result;return t?(a.push(l?t.value:t.primaryKey),++s===f?i({result:a}):void t.continue()):i({result:a})},u.onerror=Bt(o))}))}),openCursor:function(e){var t=e.trans,i=e.values,o=e.query,s=e.reverse,u=e.unique;return new Promise((function(e,a){e=Ce(e);var c=o.index,l=o.range,f=t.objectStore(n),p=(f=c.isPrimaryKey?f:f.index(c.name),c=s?u?"prevunique":"prev":u?"nextunique":"next",!i&&"openKeyCursor"in f?f.openKeyCursor(r(l),c):f.openCursor(r(l),c));p.onerror=Bt(a),p.onsuccess=Ce((function(n){var r,i,o,s,u=p.result;u?(u.___id=++Jt,u.done=!1,r=u.continue.bind(u),i=(i=u.continuePrimaryKey)&&i.bind(u),o=u.advance.bind(u),s=function(){throw new Error("Cursor not stopped")},u.trans=t,u.stop=u.continue=u.continuePrimaryKey=u.advance=function(){throw new Error("Cursor not started")},u.fail=Ce(a),u.next=function(){var e=this,t=1;return this.start((function(){return t--?e.continue():e.stop()})).then((function(){return e}))},u.start=function(e){function t(){if(p.result)try{e()}catch(e){u.fail(e)}else u.done=!0,u.start=function(){throw new Error("Cursor behind last entry")},u.stop()}var n=new Promise((function(e,t){e=Ce(e),p.onerror=Bt(t),u.fail=t,u.stop=function(t){u.stop=u.continue=u.continuePrimaryKey=u.advance=s,e(t)}}));return p.onsuccess=Ce((function(e){p.onsuccess=t,t()})),u.continue=r,u.continuePrimaryKey=i,u.advance=o,t(),n},e(u)):e(null)}),a)}))},count:function(e){var t=e.query,i=e.trans,o=t.index,s=t.range;return new Promise((function(e,t){var u=i.objectStore(n),a=o.isPrimaryKey?u:u.index(o.name);(a=(u=r(s))?a.count(u):a.count()).onsuccess=Ce((function(t){return e(t.target.result)})),a.onerror=Bt(t)}))}}}var o,u,a,c=(u=n,a=Qt((o=e).objectStoreNames),{schema:{name:o.name,tables:a.map((function(e){return u.objectStore(e)})).map((func