import{c as dr,g as ti}from"./maplibregl-BrB-zi1i.js";var vr={exports:{}};(function(mr,ii){(function(Fn,A){mr.exports=A()})(dr,function(){var Fn=function(e,n){return(Fn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])})(e,n)},A=function(){return(A=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var i in n=arguments[t])Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i]);return e}).apply(this,arguments)};function sn(e,n,t){for(var r,i=0,o=n.length;i<o;i++)!r&&i in n||((r=r||Array.prototype.slice.call(n,0,i))[i]=n[i]);return e.concat(r||Array.prototype.slice.call(n))}var Y=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:dr,z=Object.keys,L=Array.isArray;function Z(e,n){return typeof n!="object"||z(n).forEach(function(t){e[t]=n[t]}),e}typeof Promise>"u"||Y.Promise||(Y.Promise=Promise);var Ce=Object.getPrototypeOf,gr={}.hasOwnProperty;function J(e,n){return gr.call(e,n)}function De(e,n){typeof n=="function"&&(n=n(Ce(e))),(typeof Reflect>"u"?z:Reflect.ownKeys)(n).forEach(function(t){he(e,t,n[t])})}var Et=Object.defineProperty;function he(e,n,t,r){Et(e,n,Z(t&&J(t,"get")&&typeof t.get=="function"?{get:t.get,set:t.set,configurable:!0}:{value:t,configurable:!0,writable:!0},r))}function Te(e){return{from:function(n){return e.prototype=Object.create(n.prototype),he(e.prototype,"constructor",e),{extend:De.bind(null,e.prototype)}}}}var br=Object.getOwnPropertyDescriptor,wr=[].slice;function cn(e,n,t){return wr.call(e,n,t)}function Kt(e,n){return n(e)}function ze(e){if(!e)throw new Error("Assertion Failed")}function St(e){Y.setImmediate?setImmediate(e):setTimeout(e,0)}function ue(e,n){if(typeof n=="string"&&J(e,n))return e[n];if(!n)return e;if(typeof n!="string"){for(var t=[],r=0,i=n.length;r<i;++r){var o=ue(e,n[r]);t.push(o)}return t}var a=n.indexOf(".");if(a!==-1){var u=e[n.substr(0,a)];return u==null?void 0:ue(u,n.substr(a+1))}}function ee(e,n,t){if(e&&n!==void 0&&!("isFrozen"in Object&&Object.isFrozen(e)))if(typeof n!="string"&&"length"in n){ze(typeof t!="string"&&"length"in t);for(var r=0,i=n.length;r<i;++r)ee(e,n[r],t[r])}else{var o,a,u=n.indexOf(".");u!==-1?(o=n.substr(0,u),(a=n.substr(u+1))===""?t===void 0?L(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=t:ee(u=!(u=e[o])||!J(e,o)?e[o]={}:u,a,t)):t===void 0?L(e)&&!isNaN(parseInt(n))?e.splice(n,1):delete e[n]:e[n]=t}}function jt(e){var n,t={};for(n in e)J(e,n)&&(t[n]=e[n]);return t}var _r=[].concat;function At(e){return _r.apply([],e)}var le="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(At([8,16,32,64].map(function(e){return["Int","Uint","Float"].map(function(n){return n+e+"Array"})}))).filter(function(e){return Y[e]}),Ct=new Set(le.map(function(e){return Y[e]})),We=null;function we(e){return We=new WeakMap,e=function n(t){if(!t||typeof t!="object")return t;var r=We.get(t);if(r)return r;if(L(t)){r=[],We.set(t,r);for(var i=0,o=t.length;i<o;++i)r.push(n(t[i]))}else if(Ct.has(t.constructor))r=t;else{var a,u=Ce(t);for(a in r=u===Object.prototype?{}:Object.create(u),We.set(t,r),t)J(t,a)&&(r[a]=n(t[a]))}return r}(e),We=null,e}var xr={}.toString;function Mn(e){return xr.call(e).slice(8,-1)}var Nn=typeof Symbol<"u"?Symbol.iterator:"@@iterator",kr=typeof Nn=="symbol"?function(e){var n;return e!=null&&(n=e[Nn])&&n.apply(e)}:function(){return null};function _e(e,n){return n=e.indexOf(n),0<=n&&e.splice(n,1),0<=n}var qe={};function se(e){var n,t,r,i;if(arguments.length===1){if(L(e))return e.slice();if(this===qe&&typeof e=="string")return[e];if(i=kr(e)){for(t=[];!(r=i.next()).done;)t.push(r.value);return t}if(e==null)return[e];if(typeof(n=e.length)!="number")return[e];for(t=new Array(n);n--;)t[n]=e[n];return t}for(n=arguments.length,t=new Array(n);n--;)t[n]=arguments[n];return t}var Ln=typeof Symbol<"u"?function(e){return e[Symbol.toStringTag]==="AsyncFunction"}:function(){return!1},Ge=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],te=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Ge),Or={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 Ie(e,n){this.name=e,this.message=n}function Dt(e,n){return e+". Errors: "+Object.keys(n).map(function(t){return n[t].toString()}).filter(function(t,r,i){return i.indexOf(t)===r}).join(`
`)}function ln(e,n,t,r){this.failures=n,this.failedKeys=r,this.successCount=t,this.message=Dt(e,n)}function Be(e,n){this.name="BulkError",this.failures=Object.keys(n).map(function(t){return n[t]}),this.failuresByPos=n,this.message=Dt(e,this.failures)}Te(Ie).from(Error).extend({toString:function(){return this.name+": "+this.message}}),Te(ln).from(Ie),Te(Be).from(Ie);var Un=te.reduce(function(e,n){return e[n]=n+"Error",e},{}),Pr=Ie,j=te.reduce(function(e,n){var t=n+"Error";function r(i,o){this.name=t,i?typeof i=="string"?(this.message="".concat(i).concat(o?`
 `+o:""),this.inner=o||null):typeof i=="object"&&(this.message="".concat(i.name," ").concat(i.message),this.inner=i):(this.message=Or[n]||t,this.inner=null)}return Te(r).from(Pr),e[n]=r,e},{});j.Syntax=SyntaxError,j.Type=TypeError,j.Range=RangeError;var Tt=Ge.reduce(function(e,n){return e[n+"Error"]=j[n],e},{}),fn=te.reduce(function(e,n){return["Syntax","Type","Range"].indexOf(n)===-1&&(e[n+"Error"]=j[n]),e},{});function F(){}function $e(e){return e}function Er(e,n){return e==null||e===$e?n:function(t){return n(e(t))}}function xe(e,n){return function(){e.apply(this,arguments),n.apply(this,arguments)}}function Kr(e,n){return e===F?n:function(){var t=e.apply(this,arguments);t!==void 0&&(arguments[0]=t);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=n.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?xe(r,this.onsuccess):r),i&&(this.onerror=this.onerror?xe(i,this.onerror):i),o!==void 0?o:t}}function Sr(e,n){return e===F?n:function(){e.apply(this,arguments);var t=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,n.apply(this,arguments),t&&(this.onsuccess=this.onsuccess?xe(t,this.onsuccess):t),r&&(this.onerror=this.onerror?xe(r,this.onerror):r)}}function jr(e,n){return e===F?n:function(t){var r=e.apply(this,arguments);Z(t,r);var i=this.onsuccess,o=this.onerror;return this.onsuccess=null,this.onerror=null,t=n.apply(this,arguments),i&&(this.onsuccess=this.onsuccess?xe(i,this.onsuccess):i),o&&(this.onerror=this.onerror?xe(o,this.onerror):o),r===void 0?t===void 0?void 0:t:Z(r,t)}}function Ar(e,n){return e===F?n:function(){return n.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function Vn(e,n){return e===F?n:function(){var t=e.apply(this,arguments);if(t&&typeof t.then=="function"){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return t.then(function(){return n.apply(r,o)})}return n.apply(this,arguments)}}fn.ModifyError=ln,fn.DexieError=Ie,fn.BulkError=Be;var ie=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function qt(e){ie=e}var Ye={},It=100,le=typeof Promise>"u"?[]:function(){var e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,Ce(e),e];var n=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[n,Ce(n),e]}(),Ge=le[0],te=le[1],le=le[2],te=te&&te.then,Qe=Ge&&Ge.constructor,zn=!!le,Xe=function(e,n){He.push([e,n]),hn&&(queueMicrotask(Dr),hn=!1)},Wn=!0,hn=!0,ke=[],dn=[],$n=$e,de={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:F,pgp:!1,env:{},finalize:F},S=de,He=[],Oe=0,pn=[];function K(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var n=this._PSD=S;if(typeof e!="function"){if(e!==Ye)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Gn(this,this._value))}this._state=null,this._value=null,++n.ref,function t(r,i){try{i(function(o){if(r._state===null){if(o===r)throw new TypeError("A promise cannot be resolved with itself.");var a=r._lib&&Re();o&&typeof o.then=="function"?t(r,function(u,f){o instanceof K?o._then(u,f):o.then(u,f)}):(r._state=!0,r._value=o,Rt(r)),a&&Fe()}},Gn.bind(null,r))}catch(o){Gn(r,o)}}(this,e)}var Yn={get:function(){var e=S,n=gn;function t(r,i){var o=this,a=!e.global&&(e!==S||n!==gn),u=a&&!ye(),f=new K(function(c,p){Qn(o,new Bt(Mt(r,e,a,u),Mt(i,e,a,u),c,p,e))});return this._consoleTask&&(f._consoleTask=this._consoleTask),f}return t.prototype=Ye,t},set:function(e){he(this,"then",e&&e.prototype===Ye?Yn:{get:function(){return e},set:Yn.set})}};function Bt(e,n,t,r,i){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof n=="function"?n:null,this.resolve=t,this.reject=r,this.psd=i}function Gn(e,n){var t,r;dn.push(n),e._state===null&&(t=e._lib&&Re(),n=$n(n),e._state=!1,e._value=n,r=e,ke.some(function(i){return i._value===r._value})||ke.push(r),Rt(e),t&&Fe())}function Rt(e){var n=e._listeners;e._listeners=[];for(var t=0,r=n.length;t<r;++t)Qn(e,n[t]);var i=e._PSD;--i.ref||i.finalize(),Oe===0&&(++Oe,Xe(function(){--Oe==0&&Xn()},[]))}function Qn(e,n){if(e._state!==null){var t=e._state?n.onFulfilled:n.onRejected;if(t===null)return(e._state?n.resolve:n.reject)(e._value);++n.psd.ref,++Oe,Xe(Cr,[t,e,n])}else e._listeners.push(n)}function Cr(e,n,t){try{var r,i=n._value;!n._state&&dn.length&&(dn=[]),r=ie&&n._consoleTask?n._consoleTask.run(function(){return e(i)}):e(i),n._state||dn.indexOf(i)!==-1||function(o){for(var a=ke.length;a;)if(ke[--a]._value===o._value)return ke.splice(a,1)}(n),t.resolve(r)}catch(o){t.reject(o)}finally{--Oe==0&&Xn(),--t.psd.ref||t.psd.finalize()}}function Dr(){Pe(de,function(){Re()&&Fe()})}function Re(){var e=Wn;return hn=Wn=!1,e}function Fe(){var e,n,t;do for(;0<He.length;)for(e=He,He=[],t=e.length,n=0;n<t;++n){var r=e[n];r[0].apply(null,r[1])}while(0<He.length);hn=Wn=!0}function Xn(){var e=ke;ke=[],e.forEach(function(r){r._PSD.onunhandled.call(null,r._value,r)});for(var n=pn.slice(0),t=n.length;t;)n[--t]()}function yn(e){return new K(Ye,!1,e)}function N(e,n){var t=S;return function(){var r=Re(),i=S;try{return ve(t,!0),e.apply(this,arguments)}catch(o){n&&n(o)}finally{ve(i,!1),r&&Fe()}}}De(K.prototype,{then:Yn,_then:function(e,n){Qn(this,new Bt(null,null,e,n,S))},catch:function(e){if(arguments.length===1)return this.then(null,e);var n=e,t=arguments[1];return typeof n=="function"?this.then(null,function(r){return(r instanceof n?t:yn)(r)}):this.then(null,function(r){return(r&&r.name===n?t:yn)(r)})},finally:function(e){return this.then(function(n){return K.resolve(e()).then(function(){return n})},function(n){return K.resolve(e()).then(function(){return yn(n)})})},timeout:function(e,n){var t=this;return e<1/0?new K(function(r,i){var o=setTimeout(function(){return i(new j.Timeout(n))},e);t.then(r,i).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&he(K.prototype,Symbol.toStringTag,"Dexie.Promise"),de.env=Ft(),De(K,{all:function(){var e=se.apply(null,arguments).map(bn);return new K(function(n,t){e.length===0&&n([]);var r=e.length;e.forEach(function(i,o){return K.resolve(i).then(function(a){e[o]=a,--r||n(e)},t)})})},resolve:function(e){return e instanceof K?e:e&&typeof e.then=="function"?new K(function(n,t){e.then(n,t)}):new K(Ye,!0,e)},reject:yn,race:function(){var e=se.apply(null,arguments).map(bn);return new K(function(n,t){e.map(function(r){return K.resolve(r).then(n,t)})})},PSD:{get:function(){return S},set:function(e){return S=e}},totalEchoes:{get:function(){return gn}},newPSD:pe,usePSD:Pe,scheduler:{get:function(){return Xe},set:function(e){Xe=e}},rejectionMapper:{get:function(){return $n},set:function(e){$n=e}},follow:function(e,n){return new K(function(t,r){return pe(function(i,o){var a=S;a.unhandleds=[],a.onunhandled=o,a.finalize=xe(function(){var u,f=this;u=function(){f.unhandleds.length===0?i():o(f.unhandleds[0])},pn.push(function c(){u(),pn.splice(pn.indexOf(c),1)}),++Oe,Xe(function(){--Oe==0&&Xn()},[])},a.finalize),e()},n,t,r)})}}),Qe&&(Qe.allSettled&&he(K,"allSettled",function(){var e=se.apply(null,arguments).map(bn);return new K(function(n){e.length===0&&n([]);var t=e.length,r=new Array(t);e.forEach(function(i,o){return K.resolve(i).then(function(a){return r[o]={status:"fulfilled",value:a}},function(a){return r[o]={status:"rejected",reason:a}}).then(function(){return--t||n(r)})})})}),Qe.any&&typeof AggregateError<"u"&&he(K,"any",function(){var e=se.apply(null,arguments).map(bn);return new K(function(n,t){e.length===0&&t(new AggregateError([]));var r=e.length,i=new Array(r);e.forEach(function(o,a){return K.resolve(o).then(function(u){return n(u)},function(u){i[a]=u,--r||t(new AggregateError(i))})})})}));var W={awaits:0,echoes:0,id:0},Tr=0,vn=[],mn=0,gn=0,qr=0;function pe(e,n,t,r){var i=S,o=Object.create(i);return o.parent=i,o.ref=0,o.global=!1,o.id=++qr,de.env,o.env=zn?{Promise:K,PromiseProp:{value:K,configurable:!0,writable:!0},all:K.all,race:K.race,allSettled:K.allSettled,any:K.any,resolve:K.resolve,reject:K.reject}:{},n&&Z(o,n),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()},r=Pe(o,e,t,r),o.ref===0&&o.finalize(),r}function Me(){return W.id||(W.id=++Tr),++W.awaits,W.echoes+=It,W.id}function ye(){return!!W.awaits&&(--W.awaits==0&&(W.id=0),W.echoes=W.awaits*It,!0)}function bn(e){return W.echoes&&e&&e.constructor===Qe?(Me(),e.then(function(n){return ye(),n},function(n){return ye(),U(n)})):e}function Ir(){var e=vn[vn.length-1];vn.pop(),ve(e,!1)}function ve(e,n){var t,r=S;(n?!W.echoes||mn++&&e===S:!mn||--mn&&e===S)||queueMicrotask(n?(function(i){++gn,W.echoes&&--W.echoes!=0||(W.echoes=W.awaits=W.id=0),vn.push(S),ve(i,!0)}).bind(null,e):Ir),e!==S&&(S=e,r===de&&(de.env=Ft()),zn&&(t=de.env.Promise,n=e.env,(r.global||e.global)&&(Object.defineProperty(Y,"Promise",n.PromiseProp),t.all=n.all,t.race=n.race,t.resolve=n.resolve,t.reject=n.reject,n.allSettled&&(t.allSettled=n.allSettled),n.any&&(t.any=n.any))))}function Ft(){var e=Y.Promise;return zn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(Y,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function Pe(e,n,t,r,i){var o=S;try{return ve(e,!0),n(t,r,i)}finally{ve(o,!1)}}function Mt(e,n,t,r){return typeof e!="function"?e:function(){var i=S;t&&Me(),ve(n,!0);try{return e.apply(this,arguments)}finally{ve(i,!1),r&&queueMicrotask(ye)}}}function Hn(e){Promise===Qe&&W.echoes===0?mn===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(""+te).indexOf("[native code]")===-1&&(Me=ye=F);var U=K.reject,Ee="￿",ce="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Nt="String expected.",Ne=[],wn="__dbnames",Jn="readonly",Zn="readwrite";function Ke(e,n){return e?n?function(){return e.apply(this,arguments)&&n.apply(this,arguments)}:e:n}var Lt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function _n(e){return typeof e!="string"||/\./.test(e)?function(n){return n}:function(n){return n[e]===void 0&&e in n&&delete(n=we(n))[e],n}}function Ut(){throw j.Type()}function B(e,n){try{var t=Vt(e),r=Vt(n);if(t!==r)return t==="Array"?1:r==="Array"?-1:t==="binary"?1:r==="binary"?-1:t==="string"?1:r==="string"?-1:t==="Date"?1:r!=="Date"?NaN:-1;switch(t){case"number":case"Date":case"string":return n<e?1:e<n?-1:0;case"binary":return function(i,o){for(var a=i.length,u=o.length,f=a<u?a:u,c=0;c<f;++c)if(i[c]!==o[c])return i[c]<o[c]?-1:1;return a===u?0:a<u?-1:1}(zt(e),zt(n));case"Array":return function(i,o){for(var a=i.length,u=o.length,f=a<u?a:u,c=0;c<f;++c){var p=B(i[c],o[c]);if(p!==0)return p}return a===u?0:a<u?-1:1}(e,n)}}catch{}return NaN}function Vt(e){var n=typeof e;return n!="object"?n:ArrayBuffer.isView(e)?"binary":(e=Mn(e),e==="ArrayBuffer"?"binary":e)}function zt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Wt=(M.prototype._trans=function(e,n,t){var r=this._tx||S.trans,i=this.name,o=ie&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(e==="readonly"?"read":"write"," ").concat(this.name));function a(c,p,s){if(!s.schema[i])throw new j.NotFound("Table "+i+" not part of transaction");return n(s.idbtrans,s)}var u=Re();try{var f=r&&r.db._novip===this.db._novip?r===S.trans?r._promise(e,a,t):pe(function(){return r._promise(e,a,t)},{trans:r,transless:S.transless||S}):function c(p,s,y,l){if(p.idbdb&&(p._state.openComplete||S.letThrough||p._vip)){var d=p._createTransaction(s,y,p._dbSchema);try{d.create(),p._state.PR1398_maxLoop=3}catch(v){return v.name===Un.InvalidState&&p.isOpen()&&0<--p._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),p.close({disableAutoOpen:!1}),p.open().then(function(){return c(p,s,y,l)})):U(v)}return d._promise(s,function(v,h){return pe(function(){return S.trans=d,l(v,h,d)})}).then(function(v){if(s==="readwrite")try{d.idbtrans.commit()}catch{}return s==="readonly"?v:d._completion.then(function(){return v})})}if(p._state.openComplete)return U(new j.DatabaseClosed(p._state.dbOpenError));if(!p._state.isBeingOpened){if(!p._state.autoOpen)return U(new j.DatabaseClosed);p.open().catch(F)}return p._state.dbReadyPromise.then(function(){return c(p,s,y,l)})}(this.db,e,[this.name],a);return o&&(f._consoleTask=o,f=f.catch(function(c){return console.trace(c),U(c)})),f}finally{u&&Fe()}},M.prototype.get=function(e,n){var t=this;return e&&e.constructor===Object?this.where(e).first(n):e==null?U(new j.Type("Invalid argument to Table.get()")):this._trans("readonly",function(r){return t.core.get({trans:r,key:e}).then(function(i){return t.hook.reading.fire(i)})}).then(n)},M.prototype.where=function(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(L(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var n=z(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);var t=this.schema.indexes.concat(this.schema.primKey).filter(function(f){if(f.compound&&n.every(function(p){return 0<=f.keyPath.indexOf(p)})){for(var c=0;c<n.length;++c)if(n.indexOf(f.keyPath[c])===-1)return!1;return!0}return!1}).sort(function(f,c){return f.keyPath.length-c.keyPath.length})[0];if(t&&this.db._maxKey!==Ee){var a=t.keyPath.slice(0,n.length);return this.where(a).equals(a.map(function(c){return e[c]}))}!t&&ie&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(n.join("+"),"]"));var r=this.schema.idxByName,i=this.db._deps.indexedDB;function o(f,c){return i.cmp(f,c)===0}var u=n.reduce(function(y,c){var p=y[0],s=y[1],y=r[c],l=e[c];return[p||y,p||!y?Ke(s,y&&y.multi?function(d){return d=ue(d,c),L(d)&&d.some(function(v){return o(l,v)})}:function(d){return o(l,ue(d,c))}):s]},[null,null]),a=u[0],u=u[1];return a?this.where(a.name).equals(e[a.keyPath]).filter(u):t?this.filter(u):this.where(n).equals("")},M.prototype.filter=function(e){return this.toCollection().and(e)},M.prototype.count=function(e){return this.toCollection().count(e)},M.prototype.offset=function(e){return this.toCollection().offset(e)},M.prototype.limit=function(e){return this.toCollection().limit(e)},M.prototype.each=function(e){return this.toCollection().each(e)},M.prototype.toArray=function(e){return this.toCollection().toArray(e)},M.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},M.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,L(e)?"[".concat(e.join("+"),"]"):e))},M.prototype.reverse=function(){return this.toCollection().reverse()},M.prototype.mapToClass=function(e){var n,t=this.db,r=this.name;function i(){return n!==null&&n.apply(this,arguments)||this}(this.schema.mappedClass=e).prototype instanceof Ut&&(function(f,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");function p(){this.constructor=f}Fn(f,c),f.prototype=c===null?Object.create(c):(p.prototype=c.prototype,new p)}(i,n=e),Object.defineProperty(i.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),i.prototype.table=function(){return r},e=i);for(var o=new Set,a=e.prototype;a;a=Ce(a))Object.getOwnPropertyNames(a).forEach(function(f){return o.add(f)});function u(f){if(!f)return f;var c,p=Object.create(e.prototype);for(c in f)if(!o.has(c))try{p[c]=f[c]}catch{}return p}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=u,this.hook("reading",u),e},M.prototype.defineClass=function(){return this.mapToClass(function(e){Z(this,e)})},M.prototype.add=function(e,n){var t=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,a=e;return o&&i&&(a=_n(o)(e)),this._trans("readwrite",function(u){return t.core.mutate({trans:u,type:"add",keys:n!=null?[n]:null,values:[a]})}).then(function(u){return u.numFailures?K.reject(u.failures[0]):u.lastResult}).then(function(u){if(o)try{ee(e,o,u)}catch{}return u})},M.prototype.update=function(e,n){return typeof e!="object"||L(e)?this.where(":id").equals(e).modify(n):(e=ue(e,this.schema.primKey.keyPath),e===void 0?U(new j.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(n))},M.prototype.put=function(e,n){var t=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,a=e;return o&&i&&(a=_n(o)(e)),this._trans("readwrite",function(u){return t.core.mutate({trans:u,type:"put",values:[a],keys:n!=null?[n]:null})}).then(function(u){return u.numFailures?K.reject(u.failures[0]):u.lastResult}).then(function(u){if(o)try{ee(e,o,u)}catch{}return u})},M.prototype.delete=function(e){var n=this;return this._trans("readwrite",function(t){return n.core.mutate({trans:t,type:"delete",keys:[e]})}).then(function(t){return t.numFailures?K.reject(t.failures[0]):void 0})},M.prototype.clear=function(){var e=this;return this._trans("readwrite",function(n){return e.core.mutate({trans:n,type:"deleteRange",range:Lt})}).then(function(n){return n.numFailures?K.reject(n.failures[0]):void 0})},M.prototype.bulkGet=function(e){var n=this;return this._trans("readonly",function(t){return n.core.getMany({keys:e,trans:t}).then(function(r){return r.map(function(i){return n.hook.reading.fire(i)})})})},M.prototype.bulkAdd=function(e,n,t){var r=this,i=Array.isArray(n)?n:void 0,o=(t=t||(i?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",function(a){var c=r.schema.primKey,u=c.auto,c=c.keyPath;if(c&&i)throw new j.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new j.InvalidArgument("Arguments objects and keys must have the same length");var f=e.length,c=c&&u?e.map(_n(c)):e;return r.core.mutate({trans:a,type:"add",keys:i,values:c,wantResults:o}).then(function(d){var s=d.numFailures,y=d.results,l=d.lastResult,d=d.failures;if(s===0)return o?y:l;throw new Be("".concat(r.name,".bulkAdd(): ").concat(s," of ").concat(f," operations failed"),d)})})},M.prototype.bulkPut=function(e,n,t){var r=this,i=Array.isArray(n)?n:void 0,o=(t=t||(i?void 0:n))?t.allKeys:void 0;return this._trans("readwrite",function(a){var c=r.schema.primKey,u=c.auto,c=c.keyPath;if(c&&i)throw new j.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new j.InvalidArgument("Arguments objects and keys must have the same length");var f=e.length,c=c&&u?e.map(_n(c)):e;return r.core.mutate({trans:a,type:"put",keys:i,values:c,wantResults:o}).then(function(d){var s=d.numFailures,y=d.results,l=d.lastResult,d=d.failures;if(s===0)return o?y:l;throw new Be("".concat(r.name,".bulkPut(): ").concat(s," of ").concat(f," operations failed"),d)})})},M.prototype.bulkUpdate=function(e){var n=this,t=this.core,r=e.map(function(a){return a.key}),i=e.map(function(a){return a.changes}),o=[];return this._trans("readwrite",function(a){return t.getMany({trans:a,keys:r,cache:"clone"}).then(function(u){var f=[],c=[];e.forEach(function(s,y){var l=s.key,d=s.changes,v=u[y];if(v){for(var h=0,m=Object.keys(d);h<m.length;h++){var g=m[h],b=d[g];if(g===n.schema.primKey.keyPath){if(B(b,l)!==0)throw new j.Constraint("Cannot update primary key in bulkUpdate()")}else ee(v,g,b)}o.push(y),f.push(l),c.push(v)}});var p=f.length;return t.mutate({trans:a,type:"put",keys:f,values:c,updates:{keys:r,changeSpecs:i}}).then(function(s){var y=s.numFailures,l=s.failures;if(y===0)return p;for(var d=0,v=Object.keys(l);d<v.length;d++){var h,m=v[d],g=o[Number(m)];g!=null&&(h=l[m],delete l[m],l[g]=h)}throw new Be("".concat(n.name,".bulkUpdate(): ").concat(y," of ").concat(p," operations failed"),l)})})})},M.prototype.bulkDelete=function(e){var n=this,t=e.length;return this._trans("readwrite",function(r){return n.core.mutate({trans:r,type:"delete",keys:e})}).then(function(a){var i=a.numFailures,o=a.lastResult,a=a.failures;if(i===0)return o;throw new Be("".concat(n.name,".bulkDelete(): ").concat(i," of ").concat(t," operations failed"),a)})},M);function M(){}function Je(e){function n(a,u){if(u){for(var f=arguments.length,c=new Array(f-1);--f;)c[f-1]=arguments[f];return t[a].subscribe.apply(null,c),e}if(typeof a=="string")return t[a]}var t={};n.addEventType=o;for(var r=1,i=arguments.length;r<i;++r)o(arguments[r]);return n;function o(a,u,f){if(typeof a!="object"){var c;u=u||Ar;var p={subscribers:[],fire:f=f||F,subscribe:function(s){p.subscribers.indexOf(s)===-1&&(p.subscribers.push(s),p.fire=u(p.fire,s))},unsubscribe:function(s){p.subscribers=p.subscribers.filter(function(y){return y!==s}),p.fire=p.subscribers.reduce(u,f)}};return t[a]=n[a]=p}z(c=a).forEach(function(s){var y=c[s];if(L(y))o(s,c[s][0],c[s][1]);else{if(y!=="asap")throw new j.InvalidArgument("Invalid event config");var l=o(s,$e,function(){for(var d=arguments.length,v=new Array(d);d--;)v[d]=arguments[d];l.subscribers.forEach(function(h){St(function(){h.apply(null,v)})})})}})}}function Ze(e,n){return Te(n).from({prototype:e}),n}function Le(e,n){return!(e.filter||e.algorithm||e.or)&&(n?e.justLimit:!e.replayFilter)}function et(e,n){e.filter=Ke(e.filter,n)}function nt(e,n,t){var r=e.replayFilter;e.replayFilter=r?function(){return Ke(r(),n())}:n,e.justLimit=t&&!r}function xn(e,n){if(e.isPrimKey)return n.primaryKey;var t=n.getIndexByKeyPath(e.index);if(!t)throw new j.Schema("KeyPath "+e.index+" on object store "+n.name+" is not indexed");return t}function $t(e,n,t){var r=xn(e,n.schema);return n.openCursor({trans:t,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:r,range:e.range}})}function kn(e,n,t,r){var i=e.replayFilter?Ke(e.filter,e.replayFilter()):e.filter;if(e.or){var o={},a=function(u,f,c){var p,s;i&&!i(f,c,function(y){return f.stop(y)},function(y){return f.fail(y)})||((s=""+(p=f.primaryKey))=="[object ArrayBuffer]"&&(s=""+new Uint8Array(p)),J(o,s)||(o[s]=!0,n(u,f,c)))};return Promise.all([e.or._iterate(a,t),Yt($t(e,r,t),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return Yt($t(e,r,t),Ke(e.algorithm,i),n,!e.keysOnly&&e.valueMapper)}function Yt(e,n,t,r){var i=N(r?function(o,a,u){return t(r(o),a,u)}:t);return e.then(function(o){if(o)return o.start(function(){var a=function(){return o.continue()};n&&!n(o,function(u){return a=u},function(u){o.stop(u),a=F},function(u){o.fail(u),a=F})||i(o.value,o,function(u){return a=u}),a()})})}var le=Symbol(),en=(Gt.prototype.execute=function(e){if(this.add!==void 0){var n=this.add;if(L(n))return sn(sn([],L(e)?e:[],!0),n).sort();if(typeof n=="number")return(Number(e)||0)+n;if(typeof n=="bigint")try{return BigInt(e)+n}catch{return BigInt(0)+n}throw new TypeError("Invalid term ".concat(n))}if(this.remove!==void 0){var t=this.remove;if(L(t))return L(e)?e.filter(function(r){return!t.includes(r)}).sort():[];if(typeof t=="number")return Number(e)-t;if(typeof t=="bigint")try{return BigInt(e)-t}catch{return BigInt(0)-t}throw new TypeError("Invalid subtrahend ".concat(t))}return n=(n=this.replacePrefix)===null||n===void 0?void 0:n[0],n&&typeof e=="string"&&e.startsWith(n)?this.replacePrefix[1]+e.substring(n.length):e},Gt);function Gt(e){Object.assign(this,e)}var Br=(R.prototype._read=function(e,n){var t=this._ctx;return t.error?t.table._trans(null,U.bind(null,t.error)):t.table._trans("readonly",e).then(n)},R.prototype._write=function(e){var n=this._ctx;return n.error?n.table._trans(null,U.bind(null,n.error)):n.table._trans("readwrite",e,"locked")},R.prototype._addAlgorithm=function(e){var n=this._ctx;n.algorithm=Ke(n.algorithm,e)},R.prototype._iterate=function(e,n){return kn(this._ctx,e,n,this._ctx.table.core)},R.prototype.clone=function(e){var n=Object.create(this.constructor.prototype),t=Object.create(this._ctx);return e&&Z(t,e),n._ctx=t,n},R.prototype.raw=function(){return this._ctx.valueMapper=null,this},R.prototype.each=function(e){var n=this._ctx;return this._read(function(t){return kn(n,e,t,n.table.core)})},R.prototype.count=function(e){var n=this;return this._read(function(t){var r=n._ctx,i=r.table.core;if(Le(r,!0))return i.count({trans:t,query:{index:xn(r,i.schema),range:r.range}}).then(function(a){return Math.min(a,r.limit)});var o=0;return kn(r,function(){return++o,!1},t,i).then(function(){return o})}).then(e)},R.prototype.sortBy=function(e,n){var t=e.split(".").reverse(),r=t[0],i=t.length-1;function o(f,c){return c?o(f[t[c]],c-1):f[r]}var a=this._ctx.dir==="next"?1:-1;function u(f,c){return f=o(f,i),c=o(c,i),f<c?-a:c<f?a:0}return this.toArray(function(f){return f.sort(u)}).then(n)},R.prototype.toArray=function(e){var n=this;return this._read(function(t){var r=n._ctx;if(r.dir==="next"&&Le(r,!0)&&0<r.limit){var i=r.valueMapper,o=xn(r,r.table.core.schema);return r.table.core.query({trans:t,limit:r.limit,values:!0,query:{index:o,range:r.range}}).then(function(u){return u=u.result,i?u.map(i):u})}var a=[];return kn(r,function(u){return a.push(u)},t,r.table.core).then(function(){return a})},e)},R.prototype.offset=function(e){var n=this._ctx;return e<=0||(n.offset+=e,Le(n)?nt(n,function(){var t=e;return function(r,i){return t===0||(t===1?--t:i(function(){r.advance(t),t=0}),!1)}}):nt(n,function(){var t=e;return function(){return--t<0}})),this},R.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),nt(this._ctx,function(){var n=e;return function(t,r,i){return--n<=0&&r(i),0<=n}},!0),this},R.prototype.until=function(e,n){return et(this._ctx,function(t,r,i){return!e(t.value)||(r(i),n)}),this},R.prototype.first=function(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)},R.prototype.last=function(e){return this.reverse().first(e)},R.prototype.filter=function(e){var n;return et(this._ctx,function(t){return e(t.value)}),(n=this._ctx).isMatch=Ke(n.isMatch,e),this},R.prototype.and=function(e){return this.filter(e)},R.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},R.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},R.prototype.desc=function(){return this.reverse()},R.prototype.eachKey=function(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(t,r){e(r.key,r)})},R.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},R.prototype.eachPrimaryKey=function(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(t,r){e(r.primaryKey,r)})},R.prototype.keys=function(e){var n=this._ctx;n.keysOnly=!n.isMatch;var t=[];return this.each(function(r,i){t.push(i.key)}).then(function(){return t}).then(e)},R.prototype.primaryKeys=function(e){var n=this._ctx;if(n.dir==="next"&&Le(n,!0)&&0<n.limit)return this._read(function(r){var i=xn(n,n.table.core.schema);return n.table.core.query({trans:r,values:!1,limit:n.limit,query:{index:i,range:n.range}})}).then(function(r){return r.result}).then(e);n.keysOnly=!n.isMatch;var t=[];return this.each(function(r,i){t.push(i.primaryKey)}).then(function(){return t}).then(e)},R.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},R.prototype.firstKey=function(e){return this.limit(1).keys(function(n){return n[0]}).then(e)},R.prototype.lastKey=function(e){return this.reverse().firstKey(e)},R.prototype.distinct=function(){var e=this._ctx,e=e.index&&e.table.schema.idxByName[e.index];if(!e||!e.multi)return this;var n={};return et(this._ctx,function(i){var r=i.primaryKey.toString(),i=J(n,r);return n[r]=!0,!i}),this},R.prototype.modify=function(e){var n=this,t=this._ctx;return this._write(function(r){var i,o,a;a=typeof e=="function"?e:(i=z(e),o=i.length,function(h){for(var m=!1,g=0;g<o;++g){var b=i[g],w=e[b],x=ue(h,b);w instanceof en?(ee(h,b,w.execute(x)),m=!0):x!==w&&(ee(h,b,w),m=!0)}return m});function u(h,b){var g=b.failures,b=b.numFailures;d+=h-b;for(var w=0,x=z(g);w<x.length;w++){var P=x[w];l.push(g[P])}}var f=t.table.core,c=f.schema.primaryKey,p=c.outbound,s=c.extractKey,y=n.db._options.modifyChunkSize||200,l=[],d=0,v=[];return n.clone().primaryKeys().then(function(h){function m(b){var w=Math.min(y,h.length-b);return f.getMany({trans:r,keys:h.slice(b,b+w),cache:"immutable"}).then(function(x){for(var P=[],k=[],O=p?[]:null,E=[],_=0;_<w;++_){var C=x[_],D={value:we(C),primKey:h[b+_]};a.call(D,D.value,D)!==!1&&(D.value==null?E.push(h[b+_]):p||B(s(C),s(D.value))===0?(k.push(D.value),p&&O.push(h[b+_])):(E.push(h[b+_]),P.push(D.value)))}return Promise.resolve(0<P.length&&f.mutate({trans:r,type:"add",values:P}).then(function(I){for(var T in I.failures)E.splice(parseInt(T),1);u(P.length,I)})).then(function(){return(0<k.length||g&&typeof e=="object")&&f.mutate({trans:r,type:"put",keys:O,values:k,criteria:g,changeSpec:typeof e!="function"&&e,isAdditionalChunk:0<b}).then(function(I){return u(k.length,I)})}).then(function(){return(0<E.length||g&&e===tt)&&f.mutate({trans:r,type:"delete",keys:E,criteria:g,isAdditionalChunk:0<b}).then(function(I){return u(E.length,I)})}).then(function(){return h.length>b+w&&m(b+y)})})}var g=Le(t)&&t.limit===1/0&&(typeof e!="function"||e===tt)&&{index:t.index,range:t.range};return m(0).then(function(){if(0<l.length)throw new ln("Error modifying one or more objects",l,d,v);return h.length})})})},R.prototype.delete=function(){var e=this._ctx,n=e.range;return Le(e)&&(e.isPrimKey||n.type===3)?this._write(function(t){var r=e.table.core.schema.primaryKey,i=n;return e.table.core.count({trans:t,query:{index:r,range:i}}).then(function(o){return e.table.core.mutate({trans:t,type:"deleteRange",range:i}).then(function(a){var u=a.failures;if(a.lastResult,a.results,a=a.numFailures,a)throw new ln("Could not delete some values",Object.keys(u).map(function(f){return u[f]}),o-a);return o-a})})}):this.modify(tt)},R);function R(){}var tt=function(e,n){return n.value=null};function Rr(e,n){return e<n?-1:e===n?0:1}function Fr(e,n){return n<e?-1:e===n?0:1}function ne(e,n,t){return e=e instanceof Xt?new e.Collection(e):e,e._ctx.error=new(t||TypeError)(n),e}function Ue(e){return new e.Collection(e,function(){return Qt("")}).limit(0)}function On(e,n,t,r){var i,o,a,u,f,c,p,s=t.length;if(!t.every(function(d){return typeof d=="string"}))return ne(e,Nt);function y(d){i=d==="next"?function(h){return h.toUpperCase()}:function(h){return h.toLowerCase()},o=d==="next"?function(h){return h.toLowerCase()}:function(h){return h.toUpperCase()},a=d==="next"?Rr:Fr;var v=t.map(function(h){return{lower:o(h),upper:i(h)}}).sort(function(h,m){return a(h.lower,m.lower)});u=v.map(function(h){return h.upper}),f=v.map(function(h){return h.lower}),p=(c=d)==="next"?"":r}y("next"),e=new e.Collection(e,function(){return me(u[0],f[s-1]+r)}),e._ondirectionchange=function(d){y(d)};var l=0;return e._addAlgorithm(function(d,v,h){var m=d.key;if(typeof m!="string")return!1;var g=o(m);if(n(g,f,l))return!0;for(var b=null,w=l;w<s;++w){var x=function(P,k,O,E,_,C){for(var D=Math.min(P.length,E.length),I=-1,T=0;T<D;++T){var re=k[T];if(re!==E[T])return _(P[T],O[T])<0?P.substr(0,T)+O[T]+O.substr(T+1):_(P[T],E[T])<0?P.substr(0,T)+E[T]+O.substr(T+1):0<=I?P.substr(0,I)+k[I]+O.substr(I+1):null;_(P[T],re)<0&&(I=T)}return D<E.length&&C==="next"?P+O.substr(P.length):D<P.length&&C==="prev"?P.substr(0,O.length):I<0?null:P.substr(0,I)+E[I]+O.substr(I+1)}(m,g,u[w],f[w],a,c);x===null&&b===null?l=w+1:(b===null||0<a(b,x))&&(b=x)}return v(b!==null?function(){d.continue(b+p)}:h),!1}),e}function me(e,n,t,r){return{type:2,lower:e,upper:n,lowerOpen:t,upperOpen:r}}function Qt(e){return{type:1,lower:e,upper:e}}var Xt=(Object.defineProperty($.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),$.prototype.between=function(e,n,t,r){t=t!==!1,r=r===!0;try{return 0<this._cmp(e,n)||this._cmp(e,n)===0&&(t||r)&&(!t||!r)?Ue(this):new this.Collection(this,function(){return me(e,n,!t,!r)})}catch{return ne(this,ce)}},$.prototype.equals=function(e){return e==null?ne(this,ce):new this.Collection(this,function(){return Qt(e)})},$.prototype.above=function(e){return e==null?ne(this,ce):new this.Collection(this,function(){return me(e,void 0,!0)})},$.prototype.aboveOrEqual=function(e){return e==null?ne(this,ce):new this.Collection(this,function(){return me(e,void 0,!1)})},$.prototype.below=function(e){return e==null?ne(this,ce):new this.Collection(this,function(){return me(void 0,e,!1,!0)})},$.prototype.belowOrEqual=function(e){return e==null?ne(this,ce):new this.Collection(this,function(){return me(void 0,e)})},$.prototype.startsWith=function(e){return typeof e!="string"?ne(this,Nt):this.between(e,e+Ee,!0,!0)},$.prototype.startsWithIgnoreCase=function(e){return e===""?this.startsWith(e):On(this,function(n,t){return n.indexOf(t[0])===0},[e],Ee)},$.prototype.equalsIgnoreCase=function(e){return On(this,function(n,t){return n===t[0]},[e],"")},$.prototype.anyOfIgnoreCase=function(){var e=se.apply(qe,arguments);return e.length===0?Ue(this):On(this,function(n,t){return t.indexOf(n)!==-1},e,"")},$.prototype.startsWithAnyOfIgnoreCase=function(){var e=se.apply(qe,arguments);return e.length===0?Ue(this):On(this,function(n,t){return t.some(function(r){return n.indexOf(r)===0})},e,Ee)},$.prototype.anyOf=function(){var e=this,n=se.apply(qe,arguments),t=this._cmp;try{n.sort(t)}catch{return ne(this,ce)}if(n.length===0)return Ue(this);var r=new this.Collection(this,function(){return me(n[0],n[n.length-1])});r._ondirectionchange=function(o){t=o==="next"?e._ascending:e._descending,n.sort(t)};var i=0;return r._addAlgorithm(function(o,a,u){for(var f=o.key;0<t(f,n[i]);)if(++i===n.length)return a(u),!1;return t(f,n[i])===0||(a(function(){o.continue(n[i])}),!1)}),r},$.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},$.prototype.noneOf=function(){var e=se.apply(qe,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return ne(this,ce)}var n=e.reduce(function(t,r){return t?t.concat([[t[t.length-1][1],r]]):[[-1/0,r]]},null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})},$.prototype.inAnyRange=function(m,n){var t=this,r=this._cmp,i=this._ascending,o=this._descending,a=this._min,u=this._max;if(m.length===0)return Ue(this);if(!m.every(function(g){return g[0]!==void 0&&g[1]!==void 0&&i(g[0],g[1])<=0}))return ne(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",j.InvalidArgument);var f=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0,p,s=i;function y(g,b){return s(g[0],b[0])}try{(p=m.reduce(function(g,b){for(var w=0,x=g.length;w<x;++w){var P=g[w];if(r(b[0],P[1])<0&&0<r(b[1],P[0])){P[0]=a(P[0],b[0]),P[1]=u(P[1],b[1]);break}}return w===x&&g.push(b),g},[])).sort(y)}catch{return ne(this,ce)}var l=0,d=c?function(g){return 0<i(g,p[l][1])}:function(g){return 0<=i(g,p[l][1])},v=f?function(g){return 0<o(g,p[l][0])}:function(g){return 0<=o(g,p[l][0])},h=d,m=new this.Collection(this,function(){return me(p[0][0],p[p.length-1][1],!f,!c)});return m._ondirectionchange=function(g){s=g==="next"?(h=d,i):(h=v,o),p.sort(y)},m._addAlgorithm(function(g,b,w){for(var x,P=g.key;h(P);)if(++l===p.length)return b(w),!1;return!d(x=P)&&!v(x)||(t._cmp(P,p[l][1])===0||t._cmp(P,p[l][0])===0||b(function(){s===i?g.continue(p[l][0]):g.continue(p[l][1])}),!1)}),m},$.prototype.startsWithAnyOf=function(){var e=se.apply(qe,arguments);return e.every(function(n){return typeof n=="string"})?e.length===0?Ue(this):this.inAnyRange(e.map(function(n){return[n,n+Ee]})):ne(this,"startsWithAnyOf() only works with strings")},$);function $(){}function oe(e){return N(function(n){return nn(n),e(n.target.error),!1})}function nn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var tn="storagemutated",rt="x-storagemutated-1",ge=Je(null,tn),Mr=(ae.prototype._lock=function(){return ze(!S.global),++this._reculock,this._reculock!==1||S.global||(S.lockOwnerFor=this),this},ae.prototype._unlock=function(){if(ze(!S.global),--this._reculock==0)for(S.global||(S.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{Pe(e[1],e[0])}catch{}}return this},ae.prototype._locked=function(){return this._reculock&&S.lockOwnerFor!==this},ae.prototype.create=function(e){var n=this;if(!this.mode)return this;var t=this.db.idbdb,r=this.db._state.dbOpenError;if(ze(!this.idbtrans),!e&&!t)switch(r&&r.name){case"DatabaseClosedError":throw new j.DatabaseClosed(r);case"MissingAPIError":throw new j.MissingAPI(r.message,r);default:throw new j.OpenFailed(r)}if(!this.active)throw new j.TransactionInactive;return ze(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||t).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=N(function(i){nn(i),n._reject(e.error)}),e.onabort=N(function(i){nn(i),n.active&&n._reject(new j.Abort(e.error)),n.active=!1,n.on("abort").fire(i)}),e.oncomplete=N(function(){n.active=!1,n._resolve(),"mutatedParts"in e&&ge.storagemutated.fire(e.mutatedParts)}),this},ae.prototype._promise=function(e,n,t){var r=this;if(e==="readwrite"&&this.mode!=="readwrite")return U(new j.ReadOnly("Transaction is readonly"));if(!this.active)return U(new j.TransactionInactive);if(this._locked())return new K(function(o,a){r._blockedFuncs.push([function(){r._promise(e,n,t).then(o,a)},S])});if(t)return pe(function(){var o=new K(function(a,u){r._lock();var f=n(a,u,r);f&&f.then&&f.then(a,u)});return o.finally(function(){return r._unlock()}),o._lib=!0,o});var i=new K(function(o,a){var u=n(o,a,r);u&&u.then&&u.then(o,a)});return i._lib=!0,i},ae.prototype._root=function(){return this.parent?this.parent._root():this},ae.prototype.waitFor=function(e){var n,t=this._root(),r=K.resolve(e);t._waitingFor?t._waitingFor=t._waitingFor.then(function(){return r}):(t._waitingFor=r,t._waitingQueue=[],n=t.idbtrans.objectStore(t.storeNames[0]),function o(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(n.get(-1/0).onsuccess=o)}());var i=t._waitingFor;return new K(function(o,a){r.then(function(u){return t._waitingQueue.push(N(o.bind(null,u)))},function(u){return t._waitingQueue.push(N(a.bind(null,u)))}).finally(function(){t._waitingFor===i&&(t._waitingFor=null)})})},ae.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new j.Abort))},ae.prototype.table=function(e){var n=this._memoizedTables||(this._memoizedTables={});if(J(n,e))return n[e];var t=this.schema[e];if(!t)throw new j.NotFound("Table "+e+" not part of transaction");return t=new this.db.Table(e,t,this),t.core=this.db.core.table(e),n[e]=t},ae);function ae(){}function it(e,n,t,r,i,o,a){return{name:e,keyPath:n,unique:t,multi:r,auto:i,compound:o,src:(t&&!a?"&":"")+(r?"*":"")+(i?"++":"")+Ht(n)}}function Ht(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function ot(e,n,t){return{name:e,primKey:n,indexes:t,mappedClass:null,idxByName:(r=function(i){return[i.name,i]},t.reduce(function(i,o,a){return a=r(o,a),a&&(i[a[0]]=a[1]),i},{}))};var r}var rn=function(e){try{return e.only([[]]),rn=function(){return[[]]},[[]]}catch{return rn=function(){return Ee},Ee}};function at(e){return e==null?function(){}:typeof e=="string"?(n=e).split(".").length===1?function(t){return t[n]}:function(t){return ue(t,n)}:function(t){return ue(t,e)};var n}function Jt(e){return[].slice.call(e)}var Nr=0;function on(e){return e==null?":id":typeof e=="string"?e:"[".concat(e.join("+"),"]")}function Lr(e,n,f){function r(h){if(h.type===3)return null;if(h.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var l=h.lower,d=h.upper,v=h.lowerOpen,h=h.upperOpen;return l===void 0?d===void 0?null:n.upperBound(d,!!h):d===void 0?n.lowerBound(l,!!v):n.bound(l,d,!!v,!!h)}function i(y){var l,d=y.name;return{name:d,schema:y,mutate:function(v){var h=v.trans,m=v.type,g=v.keys,b=v.values,w=v.range;return new Promise(function(x,P){x=N(x);var k=h.objectStore(d),O=k.keyPath==null,E=m==="put"||m==="add";if(!E&&m!=="delete"&&m!=="deleteRange")throw new Error("Invalid operation type: "+m);var _,C=(g||b||{length:1}).length;if(g&&b&&g.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(C===0)return x({numFailures:0,failures:{},results:[],lastResult:void 0});function D(H){++re,nn(H)}var I=[],T=[],re=0;if(m==="deleteRange"){if(w.type===4)return x({numFailures:re,failures:T,results:[],lastResult:void 0});w.type===3?I.push(_=k.clear()):I.push(_=k.delete(r(w)))}else{var O=E?O?[b,g]:[b,null]:[g,null],q=O[0],G=O[1];if(E)for(var Q=0;Q<C;++Q)I.push(_=G&&G[Q]!==void 0?k[m](q[Q],G[Q]):k[m](q[Q])),_.onerror=D;else for(Q=0;Q<C;++Q)I.push(_=k[m](q[Q])),_.onerror=D}function Rn(H){H=H.target.result,I.forEach(function(Ae,Ot){return Ae.error!=null&&(T[Ot]=Ae.error)}),x({numFailures:re,failures:T,results:m==="delete"?g:I.map(function(Ae){return Ae.result}),lastResult:H})}_.onerror=function(H){D(H),Rn(H)},_.onsuccess=Rn})},getMany:function(v){var h=v.trans,m=v.keys;return new Promise(function(g,b){g=N(g);for(var w,x=h.objectStore(d),P=m.length,k=new Array(P),O=0,E=0,_=function(I){I=I.target,k[I._pos]=I.result,++E===O&&g(k)},C=oe(b),D=0;D<P;++D)m[D]!=null&&((w=x.get(m[D]))._pos=D,w.onsuccess=_,w.onerror=C,++O);O===0&&g(k)})},get:function(v){var h=v.trans,m=v.key;return new Promise(function(g,b){g=N(g);var w=h.objectStore(d).get(m);w.onsuccess=function(x){return g(x.target.result)},w.onerror=oe(b)})},query:(l=c,function(v){return new Promise(function(h,m){h=N(h);var g,b,w,O=v.trans,x=v.values,P=v.limit,_=v.query,k=P===1/0?void 0:P,E=_.index,_=_.range,O=O.objectStore(d),E=E.isPrimaryKey?O:O.index(E.name),_=r(_);if(P===0)return h({result:[]});l?((k=x?E.getAll(_,k):E.getAllKeys(_,k)).onsuccess=function(C){return h({result:C.target.result})},k.onerror=oe(m)):(g=0,b=!x&&"openKeyCursor"in E?E.openKeyCursor(_):E.openCursor(_),w=[],b.onsuccess=function(C){var D=b.result;return D?(w.push(x?D.value:D.primaryKey),++g===P?h({result:w}):void D.continue()):h({result:w})},b.onerror=oe(m))})}),openCursor:function(v){var h=v.trans,m=v.values,g=v.query,b=v.reverse,w=v.unique;return new Promise(function(x,P){x=N(x);var E=g.index,k=g.range,O=h.objectStore(d),O=E.isPrimaryKey?O:O.index(E.name),E=b?w?"prevunique":"prev":w?"nextunique":"next",_=!m&&"openKeyCursor"in O?O.openKeyCursor(r(k),E):O.openCursor(r(k),E);_.onerror=oe(P),_.onsuccess=N(function(C){var D,I,T,re,q=_.result;q?(q.___id=++Nr,q.done=!1,D=q.continue.bind(q),I=(I=q.continuePrimaryKey)&&I.bind(q),T=q.advance.bind(q),re=function(){throw new Error("Cursor not stopped")},q.trans=h,q.stop=q.continue=q.continuePrimaryKey=q.advance=function(){throw new Error("Cursor not started")},q.fail=N(P),q.next=function(){var G=this,Q=1;return this.start(function(){return Q--?G.continue():G.stop()}).then(function(){return G})},q.start=function(G){function Q(){if(_.result)try{G()}catch(H){q.fail(H)}else q.done=!0,q.start=function(){throw new Error("Cursor behind last entry")},q.stop()}var Rn=new Promise(function(H,Ae){H=N(H),_.onerror=oe(Ae),q.fail=Ae,q.stop=function(Ot){q.stop=q.continue=q.continuePrimaryKey=q.advance=re,H(Ot)}});return _.onsuccess=N(function(H){_.onsuccess=Q,Q()}),q.continue=D,q.continuePrimaryKey=I,q.advance=T,Q(),Rn},x(q)):x(null)},P)})},count:function(v){var h=v.query,m=v.trans,g=h.index,b=h.range;return new Promise(function(w,x){var P=m.objectStore(d),k=g.isPrimaryKey?P:P.index(g.name),P=r(b),k=P?k.count(P):k.count();k.onsuccess=N(function(O){return w(O.target.result)}),k.onerror=oe(x)})}}}var o,a,u,p=(a=f,u=Jt((o=e).objectStoreNames),{schema:{name:o.name,tables:u.map(function(y){return a.objectStore(y)}).map(function(y){var l=y.keyPath,h=y.autoIncrement,d=L(l),v={},h={name:y.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:l==null,compound:d,keyPath:l,autoIncrement:h,unique:!0,extractKey:at(l)},indexes:Jt(y.indexNames).map(function(m){return y.index(m)}).map(function(w){var g=w.name,b=w.unique,x=w.multiEntry,w=w.keyPath,x={name:g,compound:L(w),keyPath:w,unique:b,multiEntry:x,extractKey:at(w)};return v[on(w)]=x}),getIndexByKeyPath:function(m){return v[on(m)]}};return v[":id"]=h.primaryKey,l!=null&&(v[on(l)]=h.primaryKey),h})},hasGetAll:0<u.length&&"getAll"in a.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),f=p.schema,c=p.hasGetAll,p=f.tables.map(i),s={};return p.forEach(function(y){return s[y.name]=y}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(y){if(!s[y])throw new Error("Table '".concat(y,"' not found"));return s[y]},MIN_KEY:-1/0,MAX_KEY:rn(n),schema:f}}function Ur(e,n,t,r){var i=t.IDBKeyRange;return t.indexedDB,{dbcore:(r=Lr(n,i,r),e.dbcore.reduce(function(o,a){return a=a.create,A(A({},o),a(o))},r))}}function Pn(e,r){var t=r.db,r=Ur(e._middlewares,t,e._deps,r);e.core=r.dbcore,e.tables.forEach(function(i){var o=i.name;e.core.schema.tables.some(function(a){return a.name===o})&&(i.core=e.core.table(o),e[o]instanceof e.Table&&(e[o].core=i.core))})}function En(e,n,t,r){t.forEach(function(i){var o=r[i];n.forEach(function(a){var u=function f(c,p){return br(c,p)||(c=Ce(c))&&f(c,p)}(a,i);(!u||"value"in u&&u.value===void 0)&&(a===e.Transaction.prototype||a instanceof e.Transaction?he(a,i,{get:function(){return this.table(i)},set:function(f){Et(this,i,{value:f,writable:!0,configurable:!0,enumerable:!0})}}):a[i]=new e.Table(i,o))})})}function ut(e,n){n.forEach(function(t){for(var r in t)t[r]instanceof e.Table&&delete t[r]})}function Vr(e,n){return e._cfg.version-n._cfg.version}function zr(e,n,t,r){var i=e._dbSchema;t.objectStoreNames.contains("$meta")&&!i.$meta&&(i.$meta=ot("$meta",er("")[0],[]),e._storeNames.push("$meta"));var o=e._createTransaction("readwrite",e._storeNames,i);o.create(t),o._completion.catch(r);var a=o._reject.bind(o),u=S.transless||S;pe(function(){return S.trans=o,S.transless=u,n!==0?(Pn(e,t),c=n,((f=o).storeNames.includes("$meta")?f.table("$meta").get("version").then(function(p){return p??c}):K.resolve(c)).then(function(p){return y=p,l=o,d=t,v=[],p=(s=e)._versions,h=s._dbSchema=Sn(0,s.idbdb,d),(p=p.filter(function(m){return m._cfg.version>=y})).length!==0?(p.forEach(function(m){v.push(function(){var g=h,b=m._cfg.dbschema;jn(s,g,d),jn(s,b,d),h=s._dbSchema=b;var w=st(g,b);w.add.forEach(function(E){ct(d,E[0],E[1].primKey,E[1].indexes)}),w.change.forEach(function(E){if(E.recreate)throw new j.Upgrade("Not yet support for changing primary key");var _=d.objectStore(E.name);E.add.forEach(function(C){return Kn(_,C)}),E.change.forEach(function(C){_.deleteIndex(C.name),Kn(_,C)}),E.del.forEach(function(C){return _.deleteIndex(C)})});var x=m._cfg.contentUpgrade;if(x&&m._cfg.version>y){Pn(s,d),l._memoizedTables={};var P=jt(b);w.del.forEach(function(E){P[E]=g[E]}),ut(s,[s.Transaction.prototype]),En(s,[s.Transaction.prototype],z(P),P),l.schema=P;var k,O=Ln(x);return O&&Me(),w=K.follow(function(){var E;(k=x(l))&&O&&(E=ye.bind(null,null),k.then(E,E))}),k&&typeof k.then=="function"?K.resolve(k):w.then(function(){return k})}}),v.push(function(g){var b,w,x=m._cfg.dbschema;b=x,w=g,[].slice.call(w.db.objectStoreNames).forEach(function(P){return b[P]==null&&w.db.deleteObjectStore(P)}),ut(s,[s.Transaction.prototype]),En(s,[s.Transaction.prototype],s._storeNames,s._dbSchema),l.schema=s._dbSchema}),v.push(function(g){s.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(s.idbdb.version/10)===m._cfg.version?(s.idbdb.deleteObjectStore("$meta"),delete s._dbSchema.$meta,s._storeNames=s._storeNames.filter(function(b){return b!=="$meta"})):g.objectStore("$meta").put(m._cfg.version,"version"))})}),function m(){return v.length?K.resolve(v.shift()(l.idbtrans)).then(m):K.resolve()}().then(function(){Zt(h,d)})):K.resolve();var s,y,l,d,v,h}).catch(a)):(z(i).forEach(function(p){ct(t,p,i[p].primKey,i[p].indexes)}),Pn(e,t),void K.follow(function(){return e.on.populate.fire(o)}).catch(a));var f,c})}function Wr(e,n){Zt(e._dbSchema,n),n.db.version%10!=0||n.objectStoreNames.contains("$meta")||n.db.createObjectStore("$meta").add(Math.ceil(n.db.version/10-1),"version");var t=Sn(0,e.idbdb,n);jn(e,e._dbSchema,n);for(var r=0,i=st(t,e._dbSchema).change;r<i.length;r++){var o=function(a){if(a.change.length||a.recreate)return console.warn("Unable to patch indexes of table ".concat(a.name," because it has changes on the type of index or primary key.")),{value:void 0};var u=n.objectStore(a.name);a.add.forEach(function(f){ie&&console.debug("Dexie upgrade patch: Creating missing index ".concat(a.name,".").concat(f.src)),Kn(u,f)})}(i[r]);if(typeof o=="object")return o.value}}function st(e,n){var t,r={del:[],add:[],change:[]};for(t in e)n[t]||r.del.push(t);for(t in n){var i=e[t],o=n[t];if(i){var a={name:t,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||i.primKey.auto!==o.primKey.auto)a.recreate=!0,r.change.push(a);else{var u=i.idxByName,f=o.idxByName,c=void 0;for(c in u)f[c]||a.del.push(c);for(c in f){var p=u[c],s=f[c];p?p.src!==s.src&&a.change.push(s):a.add.push(s)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([t,o])}return r}function ct(e,n,t,r){var i=e.db.createObjectStore(n,t.keyPath?{keyPath:t.keyPath,autoIncrement:t.auto}:{autoIncrement:t.auto});return r.forEach(function(o){return Kn(i,o)}),i}function Zt(e,n){z(e).forEach(function(t){n.db.objectStoreNames.contains(t)||(ie&&console.debug("Dexie: Creating missing table",t),ct(n,t,e[t].primKey,e[t].indexes))})}function Kn(e,n){e.createIndex(n.name,n.keyPath,{unique:n.unique,multiEntry:n.multi})}function Sn(e,n,t){var r={};return cn(n.objectStoreNames,0).forEach(function(i){for(var o=t.objectStore(i),a=it(Ht(c=o.keyPath),c||"",!0,!1,!!o.autoIncrement,c&&typeof c!="string",!0),u=[],f=0;f<o.indexNames.length;++f){var p=o.index(o.indexNames[f]),c=p.keyPath,p=it(p.name,c,!!p.unique,!!p.multiEntry,!1,c&&typeof c!="string",!1);u.push(p)}r[i]=ot(i,a,u)}),r}function jn(e,n,t){for(var r=t.db.objectStoreNames,i=0;i<r.length;++i){var o=r[i],a=t.objectStore(o);e._hasGetAll="getAll"in a;for(var u=0;u<a.indexNames.length;++u){var f=a.indexNames[u],c=a.index(f).keyPath,p=typeof c=="string"?c:"["+cn(c).join("+")+"]";!n[o]||(c=n[o].idxByName[p])&&(c.name=f,delete n[o].idxByName[p],n[o].idxByName[f]=c)}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&Y.WorkerGlobalScope&&Y instanceof Y.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function er(e){return e.split(",").map(function(n,t){var r=(n=n.trim()).replace(/([&*]|\+\+)/g,""),i=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return it(r,i||null,/\&/.test(n),/\*/.test(n),/\+\+/.test(n),L(i),t===0)})}var $r=(An.prototype._parseStoresSpec=function(e,n){z(e).forEach(function(t){if(e[t]!==null){var r=er(e[t]),i=r.shift();if(i.unique=!0,i.multi)throw new j.Schema("Primary key cannot be multi-valued");r.forEach(function(o){if(o.auto)throw new j.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new j.Schema("Index must have a name and cannot be an empty string")}),n[t]=ot(t,i,r)}})},An.prototype.stores=function(t){var n=this.db;this._cfg.storesSource=this._cfg.storesSource?Z(this._cfg.storesSource,t):t;var t=n._versions,r={},i={};return t.forEach(function(o){Z(r,o._cfg.storesSource),i=o._cfg.dbschema={},o._parseStoresSpec(r,i)}),n._dbSchema=i,ut(n,[n._allTables,n,n.Transaction.prototype]),En(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],z(i),i),n._storeNames=z(i),this},An.prototype.upgrade=function(e){return this._cfg.contentUpgrade=Vn(this._cfg.contentUpgrade||F,e),this},An);function An(){}function lt(e,n){var t=e._dbNamesDB;return t||(t=e._dbNamesDB=new fe(wn,{addons:[],indexedDB:e,IDBKeyRange:n})).version(1).stores({dbnames:"name"}),t.table("dbnames")}function ft(e){return e&&typeof e.databases=="function"}function ht(e){return pe(function(){return S.letThrough=!0,e()})}function dt(e){return!("from"in e)}var X=function(e,n){if(!this){var t=new X;return e&&"d"in e&&Z(t,e),t}Z(this,arguments.length?{d:1,from:e,to:1<arguments.length?n:e}:{d:0})};function an(e,n,t){var r=B(n,t);if(!isNaN(r)){if(0<r)throw RangeError();if(dt(e))return Z(e,{from:n,to:t,d:1});var i=e.l,r=e.r;if(B(t,e.from)<0)return i?an(i,n,t):e.l={from:n,to:t,d:1,l:null,r:null},tr(e);if(0<B(n,e.to))return r?an(r,n,t):e.r={from:n,to:t,d:1,l:null,r:null},tr(e);B(n,e.from)<0&&(e.from=n,e.l=null,e.d=r?r.d+1:1),0<B(t,e.to)&&(e.to=t,e.r=null,e.d=e.l?e.l.d+1:1),t=!e.r,i&&!e.l&&un(e,i),r&&t&&un(e,r)}}function un(e,n){dt(n)||function t(r,f){var o=f.from,a=f.to,u=f.l,f=f.r;an(r,o,a),u&&t(r,u),f&&t(r,f)}(e,n)}function nr(e,n){var t=Cn(n),r=t.next();if(r.done)return!1;for(var i=r.value,o=Cn(e),a=o.next(i.from),u=a.value;!r.done&&!a.done;){if(B(u.from,i.to)<=0&&0<=B(u.to,i.from))return!0;B(i.from,u.from)<0?i=(r=t.next(u.from)).value:u=(a=o.next(i.from)).value}return!1}function Cn(e){var n=dt(e)?null:{s:0,n:e};return{next:function(t){for(var r=0<arguments.length;n;)switch(n.s){case 0:if(n.s=1,r)for(;n.n.l&&B(t,n.n.from)<0;)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!r||B(t,n.n.to)<=0)return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function tr(e){var n,t,r=(((n=e.r)===null||n===void 0?void 0:n.d)||0)-(((t=e.l)===null||t===void 0?void 0:t.d)||0),i=1<r?"r":r<-1?"l":"";i&&(n=i=="r"?"l":"r",t=A({},e),r=e[i],e.from=r.from,e.to=r.to,e[i]=r[i],t[i]=r[n],(e[n]=t).d=rr(t)),e.d=rr(e)}function rr(t){var n=t.r,t=t.l;return(n?t?Math.max(n.d,t.d):n.d:t?t.d:0)+1}function Dn(e,n){return z(n).forEach(function(t){e[t]?un(e[t],n[t]):e[t]=function r(i){var o,a,u={};for(o in i)J(i,o)&&(a=i[o],u[o]=!a||typeof a!="object"||Ct.has(a.constructor)?a:r(a));return u}(n[t])}),e}function pt(e,n){return e.all||n.all||Object.keys(e).some(function(t){return n[t]&&nr(n[t],e[t])})}De(X.prototype,((te={add:function(e){return un(this,e),this},addKey:function(e){return an(this,e,e),this},addKeys:function(e){var n=this;return e.forEach(function(t){return an(n,t,t)}),this},hasKey:function(e){var n=Cn(this).next(e).value;return n&&B(n.from,e)<=0&&0<=B(n.to,e)}})[Nn]=function(){return Cn(this)},te));var Se={},yt={},vt=!1;function Tn(e){Dn(yt,e),vt||(vt=!0,setTimeout(function(){vt=!1,mt(yt,!(yt={}))},0))}function mt(e,n){n===void 0&&(n=!1);var t=new Set;if(e.all)for(var r=0,i=Object.values(Se);r<i.length;r++)ir(a=i[r],e,t,n);else for(var o in e){var a,u=/^idb\:\/\/(.*)\/(.*)\//.exec(o);u&&(o=u[1],u=u[2],(a=Se["idb://".concat(o,"/").concat(u)])&&ir(a,e,t,n))}t.forEach(function(f){return f()})}function ir(e,n,t,r){for(var i=[],o=0,a=Object.entries(e.queries.query);o<a.length;o++){for(var u=a[o],f=u[0],c=[],p=0,s=u[1];p<s.length;p++){var y=s[p];pt(n,y.obsSet)?y.subscribers.forEach(function(h){return t.add(h)}):r&&c.push(y)}r&&i.push([f,c])}if(r)for(var l=0,d=i;l<d.length;l++){var v=d[l],f=v[0],c=v[1];e.queries.query[f]=c}}function Yr(e){var n=e._state,t=e._deps.indexedDB;if(n.isBeingOpened||e.idbdb)return n.dbReadyPromise.then(function(){return n.dbOpenError?U(n.dbOpenError):e});n.isBeingOpened=!0,n.dbOpenError=null,n.openComplete=!1;var r=n.openCanceller,i=Math.round(10*e.verno),o=!1;function a(){if(n.openCanceller!==r)throw new j.DatabaseClosed("db.open() was cancelled")}function u(){return new K(function(y,l){if(a(),!t)throw new j.MissingAPI;var d=e.name,v=n.autoSchema||!i?t.open(d):t.open(d,i);if(!v)throw new j.MissingAPI;v.onerror=oe(l),v.onblocked=N(e._fireOnBlocked),v.onupgradeneeded=N(function(h){var m;p=v.transaction,n.autoSchema&&!e._options.allowEmptyDB?(v.onerror=nn,p.abort(),v.result.close(),(m=t.deleteDatabase(d)).onsuccess=m.onerror=N(function(){l(new j.NoSuchDatabase("Database ".concat(d," doesnt exist")))})):(p.onerror=oe(l),h=h.oldVersion>Math.pow(2,62)?0:h.oldVersion,s=h<1,e.idbdb=v.result,o&&Wr(e,p),zr(e,h/10,p,l))},l),v.onsuccess=N(function(){p=null;var h,m,g,b,w,x=e.idbdb=v.result,P=cn(x.objectStoreNames);if(0<P.length)try{var k=x.transaction((b=P).length===1?b[0]:b,"readonly");if(n.autoSchema)m=x,g=k,(h=e).verno=m.version/10,g=h._dbSchema=Sn(0,m,g),h._storeNames=cn(m.objectStoreNames,0),En(h,[h._allTables],z(g),g);else if(jn(e,e._dbSchema,k),((w=st(Sn(0,(w=e).idbdb,k),w._dbSchema)).add.length||w.change.some(function(O){return O.add.length||O.change.length}))&&!o)return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."),x.close(),i=x.version+1,o=!0,y(u());Pn(e,k)}catch{}Ne.push(e),x.onversionchange=N(function(O){n.vcFired=!0,e.on("versionchange").fire(O)}),x.onclose=N(function(O){e.on("close").fire(O)}),s&&(w=e._deps,k=d,x=w.indexedDB,w=w.IDBKeyRange,ft(x)||k===wn||lt(x,w).put({name:k}).catch(F)),y()},l)}).catch(function(y){switch(y==null?void 0:y.name){case"UnknownError":if(0<n.PR1398_maxLoop)return n.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),u();break;case"VersionError":if(0<i)return i=0,u()}return K.reject(y)})}var f,c=n.dbReadyResolve,p=null,s=!1;return K.race([r,(typeof navigator>"u"?K.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(y){function l(){return indexedDB.databases().finally(y)}f=setInterval(l,100),l()}).finally(function(){return clearInterval(f)}):Promise.resolve()).then(u)]).then(function(){return a(),n.onReadyBeingFired=[],K.resolve(ht(function(){return e.on.ready.fire(e.vip)})).then(function y(){if(0<n.onReadyBeingFired.length){var l=n.onReadyBeingFired.reduce(Vn,F);return n.onReadyBeingFired=[],K.resolve(ht(function(){return l(e.vip)})).then(y)}})}).finally(function(){n.openCanceller===r&&(n.onReadyBeingFired=null,n.isBeingOpened=!1)}).catch(function(y){n.dbOpenError=y;try{p&&p.abort()}catch{}return r===n.openCanceller&&e._close(),U(y)}).finally(function(){n.openComplete=!0,c()}).then(function(){var y;return s&&(y={},e.tables.forEach(function(l){l.schema.indexes.forEach(function(d){d.name&&(y["idb://".concat(e.name,"/").concat(l.name,"/").concat(d.name)]=new X(-1/0,[[[]]]))}),y["idb://".concat(e.name,"/").concat(l.name,"/")]=y["idb://".concat(e.name,"/").concat(l.name,"/:dels")]=new X(-1/0,[[[]]])}),ge(tn).fire(y),mt(y,!0)),e})}function gt(e){function n(o){return e.next(o)}var t=i(n),r=i(function(o){return e.throw(o)});function i(o){return function(f){var u=o(f),f=u.value;return u.done?f:f&&typeof f.then=="function"?f.then(t,r):L(f)?Promise.all(f).then(t,r):t(f)}}return i(n)()}function qn(e,n,t){for(var r=L(e)?e.slice():[e],i=0;i<t;++i)r.push(n);return r}var Gr={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return A(A({},e),{table:function(n){var t=e.table(n),r=t.schema,i={},o=[];function a(s,y,l){var d=on(s),v=i[d]=i[d]||[],h=s==null?0:typeof s=="string"?1:s.length,m=0<y,m=A(A({},l),{name:m?"".concat(d,"(virtual-from:").concat(l.name,")"):l.name,lowLevelIndex:l,isVirtual:m,keyTail:y,keyLength:h,extractKey:at(s),unique:!m&&l.unique});return v.push(m),m.isPrimaryKey||o.push(m),1<h&&a(h===2?s[0]:s.slice(0,h-1),y+1,l),v.sort(function(g,b){return g.keyTail-b.keyTail}),m}n=a(r.primaryKey.keyPath,0,r.primaryKey),i[":id"]=[n];for(var u=0,f=r.indexes;u<f.length;u++){var c=f[u];a(c.keyPath,0,c)}function p(s){var y,l=s.query.index;return l.isVirtual?A(A({},s),{query:{index:l.lowLevelIndex,range:(y=s.query.range,l=l.keyTail,{type:y.type===1?2:y.type,lower:qn(y.lower,y.lowerOpen?e.MAX_KEY:e.MIN_KEY,l),lowerOpen:!0,upper:qn(y.upper,y.upperOpen?e.MIN_KEY:e.MAX_KEY,l),upperOpen:!0})}}):s}return A(A({},t),{schema:A(A({},r),{primaryKey:n,indexes:o,getIndexByKeyPath:function(s){return(s=i[on(s)])&&s[0]}}),count:function(s){return t.count(p(s))},query:function(s){return t.query(p(s))},openCursor:function(s){var y=s.query.index,l=y.keyTail,d=y.isVirtual,v=y.keyLength;return d?t.openCursor(p(s)).then(function(m){return m&&h(m)}):t.openCursor(s);function h(m){return Object.create(m,{continue:{value:function(g){g!=null?m.continue(qn(g,s.reverse?e.MAX_KEY:e.MIN_KEY,l)):s.unique?m.continue(m.key.slice(0,v).concat(s.reverse?e.MIN_KEY:e.MAX_KEY,l)):m.continue()}},continuePrimaryKey:{value:function(g,b){m.continuePrimaryKey(qn(g,e.MAX_KEY,l),b)}},primaryKey:{get:function(){return m.primaryKey}},key:{get:function(){var g=m.key;return v===1?g[0]:g.slice(0,v)}},value:{get:function(){return m.value}}})}}})}})}};function bt(e,n,t,r){return t=t||{},r=r||"",z(e).forEach(function(i){var o,a,u;J(n,i)?(o=e[i],a=n[i],typeof o=="object"&&typeof a=="object"&&o&&a?(u=Mn(o))!==Mn(a)?t[r+i]=n[i]:u==="Object"?bt(o,a,t,r+i+"."):o!==a&&(t[r+i]=n[i]):o!==a&&(t[r+i]=n[i])):t[r+i]=void 0}),z(n).forEach(function(i){J(e,i)||(t[r+i]=n[i])}),t}function wt(e,n){return n.type==="delete"?n.keys:n.keys||n.values.map(e.extractKey)}var Qr={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return A(A({},e),{table:function(n){var t=e.table(n),r=t.schema.primaryKey;return A(A({},t),{mutate:function(i){var o=S.trans,a=o.table(n).hook,u=a.deleting,f=a.creating,c=a.updating;switch(i.type){case"add":if(f.fire===F)break;return o._promise("readwrite",function(){return p(i)},!0);case"put":if(f.fire===F&&c.fire===F)break;return o._promise("readwrite",function(){return p(i)},!0);case"delete":if(u.fire===F)break;return o._promise("readwrite",function(){return p(i)},!0);case"deleteRange":if(u.fire===F)break;return o._promise("readwrite",function(){return function s(y,l,d){return t.query({trans:y,values:!1,query:{index:r,range:l},limit:d}).then(function(v){var h=v.result;return p({type:"delete",keys:h,trans:y}).then(function(m){return 0<m.numFailures?Promise.reject(m.failures[0]):h.length<d?{failures:[],numFailures:0,lastResult:void 0}:s(y,A(A({},l),{lower:h[h.length-1],lowerOpen:!0}),d)})})}(i.trans,i.range,1e4)},!0)}return t.mutate(i);function p(s){var y,l,d,v=S.trans,h=s.keys||wt(r,s);if(!h)throw new Error("Keys missing");return(s=s.type==="add"||s.type==="put"?A(A({},s),{keys:h}):A({},s)).type!=="delete"&&(s.values=sn([],s.values)),s.keys&&(s.keys=sn([],s.keys)),y=t,d=h,((l=s).type==="add"?Promise.resolve([]):y.getMany({trans:l.trans,keys:d,cache:"immutable"})).then(function(m){var g=h.map(function(b,w){var x,P,k,O=m[w],E={onerror:null,onsuccess:null};return s.type==="delete"?u.fire.call(E,b,O,v):s.type==="add"||O===void 0?(x=f.fire.call(E,b,s.values[w],v),b==null&&x!=null&&(s.keys[w]=b=x,r.outbound||ee(s.values[w],r.keyPath,b))):(x=bt(O,s.values[w]),(P=c.fire.call(E,x,b,O,v))&&(k=s.values[w],Object.keys(P).forEach(function(_){J(k,_)?k[_]=P[_]:ee(k,_,P[_])}))),E});return t.mutate(s).then(function(b){for(var w=b.failures,x=b.results,P=b.numFailures,b=b.lastResult,k=0;k<h.length;++k){var O=(x||h)[k],E=g[k];O==null?E.onerror&&E.onerror(w[k]):E.onsuccess&&E.onsuccess(s.type==="put"&&m[k]?s.values[k]:O)}return{failures:w,results:x,numFailures:P,lastResult:b}}).catch(function(b){return g.forEach(function(w){return w.onerror&&w.onerror(b)}),Promise.reject(b)})})}}})}})}};function or(e,n,t){try{if(!n||n.keys.length<e.length)return null;for(var r=[],i=0,o=0;i<n.keys.length&&o<e.length;++i)B(n.keys[i],e[o])===0&&(r.push(t?we(n.values[i]):n.values[i]),++o);return r.length===e.length?r:null}catch{return null}}var Xr={stack:"dbcore",level:-1,create:function(e){return{table:function(n){var t=e.table(n);return A(A({},t),{getMany:function(r){if(!r.cache)return t.getMany(r);var i=or(r.keys,r.trans._cache,r.cache==="clone");return i?K.resolve(i):t.getMany(r).then(function(o){return r.trans._cache={keys:r.keys,values:r.cache==="clone"?we(o):o},o})},mutate:function(r){return r.type!=="add"&&(r.trans._cache=null),t.mutate(r)}})}}}};function ar(e,n){return e.trans.mode==="readonly"&&!!e.subscr&&!e.trans.explicit&&e.trans.db._options.cache!=="disabled"&&!n.schema.primaryKey.outbound}function ur(e,n){switch(e){case"query":return n.values&&!n.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Hr={stack:"dbcore",level:0,name:"Observability",create:function(e){var n=e.schema.name,t=new X(e.MIN_KEY,e.MAX_KEY);return A(A({},e),{transaction:function(r,i,o){if(S.subscr&&i!=="readonly")throw new j.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(S.querier));return e.transaction(r,i,o)},table:function(r){var i=e.table(r),o=i.schema,a=o.primaryKey,s=o.indexes,u=a.extractKey,f=a.outbound,c=a.autoIncrement&&s.filter(function(l){return l.compound&&l.keyPath.includes(a.keyPath)}),p=A(A({},i),{mutate:function(l){function d(_){return _="idb://".concat(n,"/").concat(r,"/").concat(_),b[_]||(b[_]=new X)}var v,h,m,g=l.trans,b=l.mutatedParts||(l.mutatedParts={}),w=d(""),x=d(":dels"),P=l.type,E=l.type==="deleteRange"?[l.range]:l.type==="delete"?[l.keys]:l.values.length<50?[wt(a,l).filter(function(_){return _}),l.values]:[],k=E[0],O=E[1],E=l.trans._cache;return L(k)?(w.addKeys(k),(E=P==="delete"||k.length===O.length?or(k,E):null)||x.addKeys(k),(E||O)&&(v=d,h=E,m=O,o.indexes.forEach(function(_){var C=v(_.name||"");function D(T){return T!=null?_.extractKey(T):null}function I(T){return _.multiEntry&&L(T)?T.forEach(function(re){return C.addKey(re)}):C.addKey(T)}(h||m).forEach(function(T,G){var q=h&&D(h[G]),G=m&&D(m[G]);B(q,G)!==0&&(q!=null&&I(q),G!=null&&I(G))})}))):k?(O={from:k.lower,to:k.upper},x.add(O),w.add(O)):(w.add(t),x.add(t),o.indexes.forEach(function(_){return d(_.name).add(t)})),i.mutate(l).then(function(_){return!k||l.type!=="add"&&l.type!=="put"||(w.addKeys(_.results),c&&c.forEach(function(C){var D=l.values.map(function(T){return C.extractKey(T)}),I=C.keyPath.findIndex(function(T){return T===a.keyPath});_.results.forEach(function(T){return D[I]=T}),d(C.name).addKeys(D)})),g.mutatedParts=Dn(g.mutatedParts||{},b),_})}}),s=function(d){var v=d.query,d=v.index,v=v.range;return[d,new X((d=v.lower)!==null&&d!==void 0?d:e.MIN_KEY,(v=v.upper)!==null&&v!==void 0?v:e.MAX_KEY)]},y={get:function(l){return[a,new X(l.key)]},getMany:function(l){return[a,new X().addKeys(l.keys)]},count:s,query:s,openCursor:s};return z(y).forEach(function(l){p[l]=function(d){var v=S.subscr,h=!!v,m=ar(S,i)&&ur(l,d)?d.obsSet={}:v;if(h){var g=function(O){return O="idb://".concat(n,"/").concat(r,"/").concat(O),m[O]||(m[O]=new X)},b=g(""),w=g(":dels"),v=y[l](d),h=v[0],v=v[1];if((l==="query"&&h.isPrimaryKey&&!d.values?w:g(h.name||"")).add(v),!h.isPrimaryKey){if(l!=="count"){var x=l==="query"&&f&&d.values&&i.query(A(A({},d),{values:!1}));return i[l].apply(this,arguments).then(function(O){if(l==="query"){if(f&&d.values)return x.then(function(D){return D=D.result,b.addKeys(D),O});var E=d.values?O.result.map(u):O.result;(d.values?b:w).addKeys(E)}else if(l==="openCursor"){var _=O,C=d.values;return _&&Object.create(_,{key:{get:function(){return w.addKey(_.primaryKey),_.key}},primaryKey:{get:function(){var D=_.primaryKey;return w.addKey(D),D}},value:{get:function(){return C&&b.addKey(_.primaryKey),_.value}}})}return O})}w.add(t)}}return i[l].apply(this,arguments)}}),p}})}};function sr(e,n,t){if(t.numFailures===0)return n;if(n.type==="deleteRange")return null;var r=n.keys?n.keys.length:"values"in n&&n.values?n.values.length:1;return t.numFailures===r?null:(n=A({},n),L(n.keys)&&(n.keys=n.keys.filter(function(i,o){return!(o in t.failures)})),"values"in n&&L(n.values)&&(n.values=n.values.filter(function(i,o){return!(o in t.failures)})),n)}function _t(e,n){return t=e,((r=n).lower===void 0||(r.lowerOpen?0<B(t,r.lower):0<=B(t,r.lower)))&&(e=e,(n=n).upper===void 0||(n.upperOpen?B(e,n.upper)<0:B(e,n.upper)<=0));var t,r}function cr(e,n,y,r,i,o){if(!y||y.length===0)return e;var a=n.query.index,u=a.multiEntry,f=n.query.range,c=r.schema.primaryKey.extractKey,p=a.extractKey,s=(a.lowLevelIndex||a).extractKey,y=y.reduce(function(l,d){var v=l,h=[];if(d.type==="add"||d.type==="put")for(var m=new X,g=d.values.length-1;0<=g;--g){var b,w=d.values[g],x=c(w);m.hasKey(x)||(b=p(w),(u&&L(b)?b.some(function(E){return _t(E,f)}):_t(b,f))&&(m.addKey(x),h.push(w)))}switch(d.type){case"add":v=l.concat(n.values?h:h.map(function(_){return c(_)}));break;case"put":var P=new X().addKeys(d.values.map(function(_){return c(_)})),v=l.filter(function(_){return!P.hasKey(n.values?c(_):_)}).concat(n.values?h:h.map(function(_){return c(_)}));break;case"delete":var k=new X().addKeys(d.keys);v=l.filter(function(_){return!k.hasKey(n.values?c(_):_)});break;case"deleteRange":var O=d.range;v=l.filter(function(_){return!_t(c(_),O)})}return v},e);return y===e?e:(y.sort(function(l,d){return B(s(l),s(d))||B(c(l),c(d))}),n.limit&&n.limit<1/0&&(y.length>n.limit?y.length=n.limit:e.length===n.limit&&y.length<n.limit&&(i.dirty=!0)),o?Object.freeze(y):y)}function lr(e,n){return B(e.lower,n.lower)===0&&B(e.upper,n.upper)===0&&!!e.lowerOpen==!!n.lowerOpen&&!!e.upperOpen==!!n.upperOpen}function Jr(e,n){return function(t,r,i,o){if(t===void 0)return r!==void 0?-1:0;if(r===void 0)return 1;if((r=B(t,r))===0){if(i&&o)return 0;if(i)return 1;if(o)return-1}return r}(e.lower,n.lower,e.lowerOpen,n.lowerOpen)<=0&&0<=function(t,r,i,o){if(t===void 0)return r!==void 0?1:0;if(r===void 0)return-1;if((r=B(t,r))===0){if(i&&o)return 0;if(i)return-1;if(o)return 1}return r}(e.upper,n.upper,e.upperOpen,n.upperOpen)}function Zr(e,n,t,r){e.subscribers.add(t),r.addEventListener("abort",function(){var i,o;e.subscribers.delete(t),e.subscribers.size===0&&(i=e,o=n,setTimeout(function(){i.subscribers.size===0&&_e(o,i)},3e3))})}var ei={stack:"dbcore",level:0,name:"Cache",create:function(e){var n=e.schema.name;return A(A({},e),{transaction:function(t,r,i){var o,a,u=e.transaction(t,r,i);return r==="readwrite"&&(a=(o=new AbortController).signal,i=function(f){return function(){if(o.abort(),r==="readwrite"){for(var c=new Set,p=0,s=t;p<s.length;p++){var y=s[p],l=Se["idb://".concat(n,"/").concat(y)];if(l){var d=e.table(y),v=l.optimisticOps.filter(function(C){return C.trans===u});if(u._explicit&&f&&u.mutatedParts)for(var h=0,m=Object.values(l.queries.query);h<m.length;h++)for(var g=0,b=(P=m[h]).slice();g<b.length;g++)pt((k=b[g]).obsSet,u.mutatedParts)&&(_e(P,k),k.subscribers.forEach(function(C){return c.add(C)}));else if(0<v.length){l.optimisticOps=l.optimisticOps.filter(function(C){return C.trans!==u});for(var w=0,x=Object.values(l.queries.query);w<x.length;w++)for(var P,k,O,E=0,_=(P=x[w]).slice();E<_.length;E++)(k=_[E]).res!=null&&u.mutatedParts&&(f&&!k.dirty?(O=Object.isFrozen(k.res),O=cr(k.res,k.req,v,d,k,O),k.dirty?(_e(P,k),k.subscribers.forEach(function(C){return c.add(C)})):O!==k.res&&(k.res=O,k.promise=K.resolve({result:O}))):(k.dirty&&_e(P,k),k.subscribers.forEach(function(C){return c.add(C)})))}}}c.forEach(function(C){return C()})}}},u.addEventListener("abort",i(!1),{signal:a}),u.addEventListener("error",i(!1),{signal:a}),u.addEventListener("complete",i(!0),{signal:a})),u},table:function(t){var r=e.table(t),i=r.schema.primaryKey;return A(A({},r),{mutate:function(o){var a=S.trans;if(i.outbound||a.db._options.cache==="disabled"||a.explicit)return r.mutate(o);var u=Se["idb://".concat(n,"/").concat(t)];return u?(a=r.mutate(o),o.type!=="add"&&o.type!=="put"||!(50<=o.values.length||wt(i,o).some(function(f){return f==null}))?(u.optimisticOps.push(o),o.mutatedParts&&Tn(o.mutatedParts),a.then(function(f){0<f.numFailures&&(_e(u.optimisticOps,o),(f=sr(0,o,f))&&u.optimisticOps.push(f),o.mutatedParts&&Tn(o.mutatedParts))}),a.catch(function(){_e(u.optimisticOps,o),o.mutatedParts&&Tn(o.mutatedParts)})):a.then(function(f){var c=sr(0,A(A({},o),{values:o.values.map(function(l,s){var y,l=(y=i.keyPath)!==null&&y!==void 0&&y.includes(".")?we(l):A({},l);return ee(l,i.keyPath,f.results[s]),l})}),f);u.optimisticOps.push(c),queueMicrotask(function(){return o.mutatedParts&&Tn(o.mutatedParts)})}),a):r.mutate(o)},query:function(o){if(!ar(S,r)||!ur("query",o))return r.query(o);var a=((c=S.trans)===null||c===void 0?void 0:c.db._options.cache)==="immutable",s=S,u=s.requery,f=s.signal,c=function(d,v,h,m){var g=Se["idb://".concat(d,"/").concat(v)];if(!g)return[];if(!(v=g.queries[h]))return[null,!1,g,null];var b=v[(m.query?m.query.index.name:null)||""];if(!b)return[null,!1,g,null];switch(h){case"query":var w=b.find(function(x){return x.req.limit===m.limit&&x.req.values===m.values&&lr(x.req.query.range,m.query.range)});return w?[w,!0,g,b]:[b.find(function(x){return("limit"in x.req?x.req.limit:1/0)>=m.limit&&(!m.values||x.req.values)&&Jr(x.req.query.range,m.query.range)}),!1,g,b];case"count":return w=b.find(function(x){return lr(x.req.query.range,m.query.range)}),[w,!!w,g,b]}}(n,t,"query",o),p=c[0],s=c[1],y=c[2],l=c[3];return p&&s?p.obsSet=o.obsSet:(s=r.query(o).then(function(d){var v=d.result;if(p&&(p.res=v),a){for(var h=0,m=v.length;h<m;++h)Object.freeze(v[h]);Object.freeze(v)}else d.result=we(v);return d}).catch(function(d){return l&&p&&_e(l,p),Promise.reject(d)}),p={obsSet:o.obsSet,promise:s,subscribers:new Set,type:"query",req:o,dirty:!1},l?l.push(p):(l=[p],(y=y||(Se["idb://".concat(n,"/").concat(t)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[o.query.index.name||""]=l)),Zr(p,l,u,f),p.promise.then(function(d){return{result:cr(d.result,o,y==null?void 0:y.optimisticOps,r,p,a)}})}})}})}};function In(e,n){return new Proxy(e,{get:function(t,r,i){return r==="db"?n:Reflect.get(t,r,i)}})}var fe=(V.prototype.version=function(e){if(isNaN(e)||e<.1)throw new j.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new j.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);var n=this._versions,t=n.filter(function(r){return r._cfg.version===e})[0];return t||(t=new this.Version(e),n.push(t),n.sort(Vr),t.stores({}),this._state.autoSchema=!1,t)},V.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||S.letThrough||this._vip)?e():new K(function(t,r){if(n._state.openComplete)return r(new j.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._state.autoOpen)return void r(new j.DatabaseClosed);n.open().catch(F)}n._state.dbReadyPromise.then(t,r)}).then(e)},V.prototype.use=function(e){var n=e.stack,t=e.create,r=e.level,i=e.name;return i&&this.unuse({stack:n,name:i}),e=this._middlewares[n]||(this._middlewares[n]=[]),e.push({stack:n,create:t,level:r??10,name:i}),e.sort(function(o,a){return o.level-a.level}),this},V.prototype.unuse=function(e){var n=e.stack,t=e.name,r=e.create;return n&&this._middlewares[n]&&(this._middlewares[n]=this._middlewares[n].filter(function(i){return r?i.create!==r:!!t&&i.name!==t})),this},V.prototype.open=function(){var e=this;return Pe(de,function(){return Yr(e)})},V.prototype._close=function(){var e=this._state,n=Ne.indexOf(this);if(0<=n&&Ne.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new K(function(t){e.dbReadyResolve=t}),e.openCanceller=new K(function(t,r){e.cancelOpen=r}))},V.prototype.close=function(t){var n=(t===void 0?{disableAutoOpen:!0}:t).disableAutoOpen,t=this._state;n?(t.isBeingOpened&&t.cancelOpen(new j.DatabaseClosed),this._close(),t.autoOpen=!1,t.dbOpenError=new j.DatabaseClosed):(this._close(),t.autoOpen=this._options.autoOpen||t.isBeingOpened,t.openComplete=!1,t.dbOpenError=null)},V.prototype.delete=function(e){var n=this;e===void 0&&(e={disableAutoOpen:!0});var t=0<arguments.length&&typeof arguments[0]!="object",r=this._state;return new K(function(i,o){function a(){n.close(e);var u=n._deps.indexedDB.deleteDatabase(n.name);u.onsuccess=N(function(){var f,c,p;f=n._deps,c=n.name,p=f.indexedDB,f=f.IDBKeyRange,ft(p)||c===wn||lt(p,f).delete(c).catch(F),i()}),u.onerror=oe(o),u.onblocked=n._fireOnBlocked}if(t)throw new j.InvalidArgument("Invalid closeOptions argument to db.delete()");r.isBeingOpened?r.dbReadyPromise.then(a):a()})},V.prototype.backendDB=function(){return this.idbdb},V.prototype.isOpen=function(){return this.idbdb!==null},V.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"},V.prototype.hasFailed=function(){return this._state.dbOpenError!==null},V.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(V.prototype,"tables",{get:function(){var e=this;return z(this._allTables).map(function(n){return e._allTables[n]})},enumerable:!1,configurable:!0}),V.prototype.transaction=function(){var e=(function(n,t,r){var i=arguments.length;if(i<2)throw new j.InvalidArgument("Too few arguments");for(var o=new Array(i-1);--i;)o[i-1]=arguments[i];return r=o.pop(),[n,At(o),r]}).apply(this,arguments);return this._transaction.apply(this,e)},V.prototype._transaction=function(e,n,t){var r=this,i=S.trans;i&&i.db===this&&e.indexOf("!")===-1||(i=null);var o,a,u=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");try{if(a=n.map(function(c){if(c=c instanceof r.Table?c.name:c,typeof c!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return c}),e=="r"||e===Jn)o=Jn;else{if(e!="rw"&&e!=Zn)throw new j.InvalidArgument("Invalid transaction mode: "+e);o=Zn}if(i){if(i.mode===Jn&&o===Zn){if(!u)throw new j.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&a.forEach(function(c){if(i&&i.storeNames.indexOf(c)===-1){if(!u)throw new j.SubTransaction("Table "+c+" not included in parent transaction.");i=null}}),u&&i&&!i.active&&(i=null)}}catch(c){return i?i._promise(null,function(p,s){s(c)}):U(c)}var f=(function c(p,s,y,l,d){return K.resolve().then(function(){var v=S.transless||S,h=p._createTransaction(s,y,p._dbSchema,l);if(h.explicit=!0,v={trans:h,transless:v},l)h.idbtrans=l.idbtrans;else try{h.create(),h.idbtrans._explicit=!0,p._state.PR1398_maxLoop=3}catch(b){return b.name===Un.InvalidState&&p.isOpen()&&0<--p._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),p.close({disableAutoOpen:!1}),p.open().then(function(){return c(p,s,y,null,d)})):U(b)}var m,g=Ln(d);return g&&Me(),v=K.follow(function(){var b;(m=d.call(h,h))&&(g?(b=ye.bind(null,null),m.then(b,b)):typeof m.next=="function"&&typeof m.throw=="function"&&(m=gt(m)))},v),(m&&typeof m.then=="function"?K.resolve(m).then(function(b){return h.active?b:U(new j.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):v.then(function(){return m})).then(function(b){return l&&h._resolve(),h._completion.then(function(){return b})}).catch(function(b){return h._reject(b),U(b)})})}).bind(null,this,o,a,i,t);return i?i._promise(o,f,"lock"):S.trans?Pe(S.transless,function(){return r._whenReady(f)}):this._whenReady(f)},V.prototype.table=function(e){if(!J(this._allTables,e))throw new j.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},V);function V(e,n){var t=this;this._middlewares={},this.verno=0;var r=V.dependencies;this._options=n=A({addons:V.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,cache:"cloned"},n),this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},r=n.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var i,o,a,u,f,c={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:F,dbReadyPromise:null,cancelOpen:F,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:n.autoOpen};c.dbReadyPromise=new K(function(s){c.dbReadyResolve=s}),c.openCanceller=new K(function(s,y){c.cancelOpen=y}),this._state=c,this.name=e,this.on=Je(this,"populate","blocked","versionchange","close",{ready:[Vn,F]}),this.on.ready.subscribe=Kt(this.on.ready.subscribe,function(s){return function(y,l){V.vip(function(){var d,v=t._state;v.openComplete?(v.dbOpenError||K.resolve().then(y),l&&s(y)):v.onReadyBeingFired?(v.onReadyBeingFired.push(y),l&&s(y)):(s(y),d=t,l||s(function h(){d.on.ready.unsubscribe(y),d.on.ready.unsubscribe(h)}))})}}),this.Collection=(i=this,Ze(Br.prototype,function(m,h){this.db=i;var l=Lt,d=null;if(h)try{l=h()}catch(g){d=g}var v=m._ctx,h=v.table,m=h.hook.reading.fire;this._ctx={table:h,index:v.index,isPrimKey:!v.index||h.schema.primKey.keyPath&&v.index===h.schema.primKey.name,range:l,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:d,or:v.or,valueMapper:m!==$e?m:null}})),this.Table=(o=this,Ze(Wt.prototype,function(s,y,l){this.db=o,this._tx=l,this.name=s,this.schema=y,this.hook=o._allTables[s]?o._allTables[s].hook:Je(null,{creating:[Kr,F],reading:[Er,$e],updating:[jr,F],deleting:[Sr,F]})})),this.Transaction=(a=this,Ze(Mr.prototype,function(s,y,l,d,v){var h=this;this.db=a,this.mode=s,this.storeNames=y,this.schema=l,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=Je(this,"complete","error","abort"),this.parent=v||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new K(function(m,g){h._resolve=m,h._reject=g}),this._completion.then(function(){h.active=!1,h.on.complete.fire()},function(m){var g=h.active;return h.active=!1,h.on.error.fire(m),h.parent?h.parent._reject(m):g&&h.idbtrans&&h.idbtrans.abort(),U(m)})})),this.Version=(u=this,Ze($r.prototype,function(s){this.db=u,this._cfg={version:s,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(f=this,Ze(Xt.prototype,function(s,y,l){if(this.db=f,this._ctx={table:s,index:y===":id"?null:y,or:l},this._cmp=this._ascending=B,this._descending=function(d,v){return B(v,d)},this._max=function(d,v){return 0<B(d,v)?d:v},this._min=function(d,v){return B(d,v)<0?d:v},this._IDBKeyRange=f._deps.IDBKeyRange,!this._IDBKeyRange)throw new j.MissingAPI})),this.on("versionchange",function(s){0<s.newVersion?console.warn("Another connection wants to upgrade database '".concat(t.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(t.name,"'. Closing db now to resume the delete request.")),t.close({disableAutoOpen:!1})}),this.on("blocked",function(s){!s.newVersion||s.newVersion<s.oldVersion?console.warn("Dexie.delete('".concat(t.name,"') was blocked")):console.warn("Upgrade '".concat(t.name,"' blocked by other connection holding version ").concat(s.oldVersion/10))}),this._maxKey=rn(n.IDBKeyRange),this._createTransaction=function(s,y,l,d){return new t.Transaction(s,y,l,t._options.chromeTransactionDurability,d)},this._fireOnBlocked=function(s){t.on("blocked").fire(s),Ne.filter(function(y){return y.name===t.name&&y!==t&&!y._state.vcFired}).map(function(y){return y.on("versionchange").fire(s)})},this.use(Xr),this.use(ei),this.use(Hr),this.use(Gr),this.use(Qr);var p=new Proxy(this,{get:function(s,y,l){if(y==="_vip")return!0;if(y==="table")return function(v){return In(t.table(v),p)};var d=Reflect.get(s,y,l);return d instanceof Wt?In(d,p):y==="tables"?d.map(function(v){return In(v,p)}):y==="_createTransaction"?function(){return In(d.apply(this,arguments),p)}:d}});this.vip=p,r.forEach(function(s){return s(t)})}var Bn,te=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",ni=(xt.prototype.subscribe=function(e,n,t){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:t})},xt.prototype[te]=function(){return this},xt);function xt(e){this._subscribe=e}try{Bn={indexedDB:Y.indexedDB||Y.mozIndexedDB||Y.webkitIndexedDB||Y.msIndexedDB,IDBKeyRange:Y.IDBKeyRange||Y.webkitIDBKeyRange}}catch{Bn={indexedDB:null,IDBKeyRange:null}}function fr(e){var n,t=!1,r=new ni(function(i){var o=Ln(e),a,u=!1,f={},c={},p={get closed(){return u},unsubscribe:function(){u||(u=!0,a&&a.abort(),s&&ge.storagemutated.unsubscribe(l))}};i.start&&i.start(p);var s=!1,y=function(){return Hn(d)},l=function(v){Dn(f,v),pt(c,f)&&y()},d=function(){var v,h,m;!u&&Bn.indexedDB&&(f={},v={},a&&a.abort(),a=new AbortController,m=function(g){var b=Re();try{o&&Me();var w=pe(e,g);return w=o?w.finally(ye):w}finally{b&&Fe()}}(h={subscr:v,signal:a.signal,requery:y,querier:e,trans:null}),Promise.resolve(m).then(function(g){t=!0,n=g,u||h.signal.aborted||(f={},function(b){for(var w in b)if(J(b,w))return;return 1}(c=v)||s||(ge(tn,l),s=!0),Hn(function(){return!u&&i.next&&i.next(g)}))},function(g){t=!1,["DatabaseClosedError","AbortError"].includes(g==null?void 0:g.name)||u||Hn(function(){u||i.error&&i.error(g)})}))};return setTimeout(y,0),p});return r.hasValue=function(){return t},r.getValue=function(){return n},r}var je=fe;function kt(e){var n=be;try{be=!0,ge.storagemutated.fire(e),mt(e,!0)}finally{be=n}}De(je,A(A({},fn),{delete:function(e){return new je(e,{addons:[]}).delete()},exists:function(e){return new je(e,{addons:[]}).open().then(function(n){return n.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return n=je.dependencies,t=n.indexedDB,n=n.IDBKeyRange,(ft(t)?Promise.resolve(t.databases()).then(function(r){return r.map(function(i){return i.name}).filter(function(i){return i!==wn})}):lt(t,n).toCollection().primaryKeys()).then(e)}catch{return U(new j.MissingAPI)}var n,t},defineClass:function(){return function(e){Z(this,e)}},ignoreTransaction:function(e){return S.trans?Pe(S.transless,e):e()},vip:ht,async:function(e){return function(){try{var n=gt(e.apply(this,arguments));return n&&typeof n.then=="function"?n:K.resolve(n)}catch(t){return U(t)}}},spawn:function(e,n,t){try{var r=gt(e.apply(t,n||[]));return r&&typeof r.then=="function"?r:K.resolve(r)}catch(i){return U(i)}},currentTransaction:{get:function(){return S.trans||null}},waitFor:function(e,n){return n=K.resolve(typeof e=="function"?je.ignoreTransaction(e):e).timeout(n||6e4),S.trans?S.trans.waitFor(n):n},Promise:K,debug:{get:function(){return ie},set:function(e){qt(e)}},derive:Te,extend:Z,props:De,override:Kt,Events:Je,on:ge,liveQuery:fr,extendObservabilitySet:Dn,getByKeyPath:ue,setByKeyPath:ee,delByKeyPath:function(e,n){typeof n=="string"?ee(e,n,void 0):"length"in n&&[].map.call(n,function(t){ee(e,t,void 0)})},shallowClone:jt,deepClone:we,getObjectDiff:bt,cmp:B,asap:St,minKey:-1/0,addons:[],connections:Ne,errnames:Un,dependencies:Bn,cache:Se,semVer:"4.0.8",version:"4.0.8".split(".").map(function(e){return parseInt(e)}).reduce(function(e,n,t){return e+n/Math.pow(10,2*t)})})),je.maxKey=rn(je.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(ge(tn,function(e){be||(e=new CustomEvent(rt,{detail:e}),be=!0,dispatchEvent(e),be=!1)}),addEventListener(rt,function(e){e=e.detail,be||kt(e)}));var Ve,be=!1,hr=function(){};return typeof BroadcastChannel<"u"&&((hr=function(){(Ve=new BroadcastChannel(rt)).onmessage=function(e){return e.data&&kt(e.data)}})(),typeof Ve.unref=="function"&&Ve.unref(),ge(tn,function(e){be||Ve.postMessage(e)})),typeof addEventListener<"u"&&(addEventListener("pagehide",function(e){if(!fe.disableBfCache&&e.persisted){ie&&console.debug("Dexie: handling persisted pagehide"),Ve!=null&&Ve.close();for(var n=0,t=Ne;n<t.length;n++)t[n].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(e){!fe.disableBfCache&&e.persisted&&(ie&&console.debug("Dexie: handling persisted pageshow"),hr(),kt({all:new X(-1/0,[[]])}))})),K.rejectionMapper=function(e,n){return!e||e instanceof Ie||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Tt[e.name]?e:(n=new Tt[e.name](n||e.message,e),"stack"in e&&he(n,"stack",{get:function(){return this.inner.stack}}),n)},qt(ie),A(fe,Object.freeze({__proto__:null,Dexie:fe,liveQuery:fr,Entity:Ut,cmp:B,PropModSymbol:le,PropModification:en,replacePrefix:function(e,n){return new en({replacePrefix:[e,n]})},add:function(e){return new en({add:e})},remove:function(e){return new en({remove:e})},default:fe,RangeSet:X,mergeRanges:un,rangesOverlap:nr}),{default:fe}),fe})})(vr);var ri=vr.exports;const Pt=ti(ri),pr=Symbol.for("Dexie"),yr=globalThis[pr]||(globalThis[pr]=Pt);if(Pt.semVer!==yr.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${Pt.semVer} and ${yr.semVer}`);export{yr as D};
