UNPKG

bimplus-renderer

Version:

bim+ renderer

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