@enjoys/react-api
Version:
3 lines • 125 kB
JavaScript
import {useEffect}from'react';var Na=Object.create;var ir=Object.defineProperty;var Fa=Object.getOwnPropertyDescriptor;var Va=Object.getOwnPropertyNames;var ja=Object.getPrototypeOf,Ua=Object.prototype.hasOwnProperty;var Xr=(c,u)=>()=>(c&&(u=c(c=0)),u);var qr=(c,u)=>()=>(u||c((u={exports:{}}).exports,u),u.exports),La=(c,u)=>{for(var f in u)ir(c,f,{get:u[f],enumerable:true});},Wa=(c,u,f,y)=>{if(u&&typeof u=="object"||typeof u=="function")for(let m of Va(u))!Ua.call(c,m)&&m!==f&&ir(c,m,{get:()=>u[m],enumerable:!(y=Fa(u,m))||y.enumerable});return c};var Jr=(c,u,f)=>(f=c!=null?Na(ja(c)):{},Wa(ir(f,"default",{value:c,enumerable:true}),c));var ti=qr((po,ei)=>{function nt(c,u){var f,y;if(typeof u=="function")y=u(c),y!==void 0&&(c=y);else if(Array.isArray(u))for(f=0;f<u.length;f++)y=u[f](c),y!==void 0&&(c=y);return c}function Ha(c,u){return c[0]==="-"&&Array.isArray(u)&&/^-\d+$/.test(c)?u.length+parseInt(c,10):c}function za(c){return /^\d+$/.test(c)}function un(c){return Object.prototype.toString.call(c)==="[object Object]"}function At(c){return Object(c)===c}function ln(c){return Object.keys(c).length===0}var $a=["__proto__","prototype","constructor"],Qa=function(c){return $a.indexOf(c)===-1};function cn(c,u){c.indexOf("[")>=0&&(c=c.replace(/\[/g,u).replace(/]/g,""));var f=c.split(u),y=f.filter(Qa);if(y.length!==f.length)throw Error("Refusing to update blacklisted property "+c);return f}var Zr=Object.prototype.hasOwnProperty;function J(c,u,f,y){if(!(this instanceof J))return new J(c,u,f,y);typeof u>"u"&&(u=false),typeof f>"u"&&(f=true),typeof y>"u"&&(y=true),this.separator=c||".",this.override=u,this.useArray=f,this.useBrackets=y,this.keepArray=false,this.cleanup=[];}var ht=new J(".",false,true,true);function _e(c){return function(){return ht[c].apply(ht,arguments)}}J.prototype._fill=function(c,u,f,y){var m=c.shift();if(c.length>0){if(u[m]=u[m]||(this.useArray&&za(c[0])?[]:{}),!At(u[m]))if(this.override)u[m]={};else {if(!(At(f)&&ln(f)))throw new Error("Trying to redefine `"+m+"` which is a "+typeof u[m]);return}this._fill(c,u[m],f,y);}else {if(!this.override&&At(u[m])&&!ln(u[m])){if(!(At(f)&&ln(f)))throw new Error("Trying to redefine non-empty obj['"+m+"']");return}u[m]=nt(f,y);}};J.prototype.object=function(c,u){var f=this;return Object.keys(c).forEach(function(y){var m=u===void 0?null:u[y],b=cn(y,f.separator).join(f.separator);b.indexOf(f.separator)!==-1?(f._fill(b.split(f.separator),c,c[y],m),delete c[y]):c[y]=nt(c[y],m);}),c};J.prototype.str=function(c,u,f,y){var m=cn(c,this.separator).join(this.separator);return c.indexOf(this.separator)!==-1?this._fill(m.split(this.separator),f,u,y):f[c]=nt(u,y),f};J.prototype.pick=function(c,u,f,y){var m,b,k,P,N;for(b=cn(c,this.separator),m=0;m<b.length;m++)if(P=Ha(b[m],u),u&&typeof u=="object"&&P in u){if(m===b.length-1)return f?(k=u[P],y&&Array.isArray(u)?u.splice(P,1):delete u[P],Array.isArray(u)&&(N=b.slice(0,-1).join("."),this.cleanup.indexOf(N)===-1&&this.cleanup.push(N)),k):u[P];u=u[P];}else return;return f&&Array.isArray(u)&&(u=u.filter(function(D){return D!==void 0})),u};J.prototype.delete=function(c,u){return this.remove(c,u,true)};J.prototype.remove=function(c,u,f){var y;if(this.cleanup=[],Array.isArray(c)){for(y=0;y<c.length;y++)this.pick(c[y],u,true,f);return f||this._cleanup(u),u}else return this.pick(c,u,true,f)};J.prototype._cleanup=function(c){var u,f,y,m;if(this.cleanup.length){for(f=0;f<this.cleanup.length;f++)y=this.cleanup[f].split("."),m=y.splice(0,-1).join("."),u=m?this.pick(m,c):c,u=u[y[0]].filter(function(b){return b!==void 0}),this.set(this.cleanup[f],u,c);this.cleanup=[];}};J.prototype.del=J.prototype.remove;J.prototype.move=function(c,u,f,y,m){return typeof y=="function"||Array.isArray(y)?this.set(u,nt(this.pick(c,f,true),y),f,m):(m=y,this.set(u,this.pick(c,f,true),f,m)),f};J.prototype.transfer=function(c,u,f,y,m,b){return typeof m=="function"||Array.isArray(m)?this.set(u,nt(this.pick(c,f,true),m),y,b):(b=m,this.set(u,this.pick(c,f,true),y,b)),y};J.prototype.copy=function(c,u,f,y,m,b){return typeof m=="function"||Array.isArray(m)?this.set(u,nt(JSON.parse(JSON.stringify(this.pick(c,f,false))),m),y,b):(b=m,this.set(u,this.pick(c,f,false),y,b)),y};J.prototype.set=function(c,u,f,y){var m,b,k,P;if(typeof u>"u")return f;for(k=cn(c,this.separator),m=0;m<k.length;m++){if(P=k[m],m===k.length-1)if(y&&un(u)&&un(f[P]))for(b in u)Zr.call(u,b)&&(f[P][b]=u[b]);else if(y&&Array.isArray(f[P])&&Array.isArray(u))for(var N=0;N<u.length;N++)f[k[m]].push(u[N]);else f[P]=u;else (!Zr.call(f,P)||!un(f[P])&&!Array.isArray(f[P]))&&(/^\d+$/.test(k[m+1])?f[P]=[]:f[P]={});f=f[P];}return f};J.prototype.transform=function(c,u,f){return u=u||{},f=f||{},Object.keys(c).forEach(function(y){this.set(c[y],this.pick(y,u),f);}.bind(this)),f};J.prototype.dot=function(c,u,f){u=u||{},f=f||[];var y=Array.isArray(c);return Object.keys(c).forEach(function(m){var b=y&&this.useBrackets?"["+m+"]":m;if(At(c[m])&&(un(c[m])&&!ln(c[m])||Array.isArray(c[m])&&!this.keepArray&&c[m].length!==0))if(y&&this.useBrackets){var k=f[f.length-1]||"";return this.dot(c[m],u,f.slice(0,-1).concat(k+b))}else return this.dot(c[m],u,f.concat(b));else y&&this.useBrackets?u[f.join(this.separator).concat("["+m+"]")]=c[m]:u[f.concat(b).join(this.separator)]=c[m];}.bind(this)),u};J.pick=_e("pick");J.move=_e("move");J.transfer=_e("transfer");J.transform=_e("transform");J.copy=_e("copy");J.object=_e("object");J.str=_e("str");J.set=_e("set");J.delete=_e("delete");J.del=J.remove=_e("remove");J.dot=_e("dot");["override","overwrite"].forEach(function(c){Object.defineProperty(J,c,{get:function(){return ht.override},set:function(u){ht.override=!!u;}});});["useArray","keepArray","useBrackets"].forEach(function(c){Object.defineProperty(J,c,{get:function(){return ht[c]},set:function(u){ht[c]=u;}});});J._process=nt;ei.exports=J;});var ni=qr((ar,or)=>{(function(c,u){typeof ar=="object"&&typeof or<"u"?or.exports=u():typeof define=="function"&&define.amd?define(u):(c=typeof globalThis<"u"?globalThis:c||self,c.Dexie=u());})(ar,function(){var c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r;}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i]);},c(e,t)};function u(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");c(e,t);function n(){this.constructor=e;}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n);}var f=function(){return f=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a]);}return t},f.apply(this,arguments)};function y(e,t,n){for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var m=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,b=Object.keys,k=Array.isArray;typeof Promise<"u"&&!m.Promise&&(m.Promise=Promise);function P(e,t){return typeof t!="object"||b(t).forEach(function(n){e[n]=t[n];}),e}var N=Object.getPrototypeOf,D={}.hasOwnProperty;function F(e,t){return D.call(e,t)}function A(e,t){typeof t=="function"&&(t=t(N(e))),(typeof Reflect>"u"?b:Reflect.ownKeys)(t).forEach(function(n){H(e,n,t[n]);});}var z=Object.defineProperty;function H(e,t,n,r){z(e,t,P(n&&F(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:true}:{value:n,configurable:true,writable:true},r));}function ee(e){return {from:function(t){return e.prototype=Object.create(t.prototype),H(e.prototype,"constructor",e),{extend:A.bind(null,e.prototype)}}}}var re=Object.getOwnPropertyDescriptor;function ie(e,t){var n=re(e,t),r;return n||(r=N(e))&&ie(r,t)}var de=[].slice;function Pe(e,t,n){return de.call(e,t,n)}function ge(e,t){return t(e)}function Ie(e){if(!e)throw new Error("Assertion Failed")}function dt(e){m.setImmediate?setImmediate(e):setTimeout(e,0);}function pt(e,t){return e.reduce(function(n,r,i){var a=t(r,i);return a&&(n[a[0]]=a[1]),n},{})}function be(e,t){if(typeof t=="string"&&F(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var n=[],r=0,i=t.length;r<i;++r){var a=be(e,t[r]);n.push(a);}return n}var o=t.indexOf(".");if(o!==-1){var s=e[t.substr(0,o)];return s==null?void 0:be(s,t.substr(o+1))}}function ce(e,t,n){if(!(!e||t===void 0)&&!("isFrozen"in Object&&Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){Ie(typeof n!="string"&&"length"in n);for(var r=0,i=t.length;r<i;++r)ce(e,t[r],n[r]);}else {var a=t.indexOf(".");if(a!==-1){var o=t.substr(0,a),s=t.substr(a+1);if(s==="")n===void 0?k(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n;else {var l=e[o];(!l||!F(e,o))&&(l=e[o]={}),ce(l,s,n);}}else n===void 0?k(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n;}}function ae(e,t){typeof t=="string"?ce(e,t,void 0):"length"in t&&[].map.call(t,function(n){ce(e,n,void 0);});}function te(e){var t={};for(var n in e)F(e,n)&&(t[n]=e[n]);return t}var ue=[].concat;function ve(e){return ue.apply([],e)}var pe="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(ve([8,16,32,64].map(function(e){return ["Int","Uint","Float"].map(function(t){return t+e+"Array"})}))).filter(function(e){return m[e]}),yt=new Set(pe.map(function(e){return m[e]}));function vt(e){var t={};for(var n in e)if(F(e,n)){var r=e[n];t[n]=!r||typeof r!="object"||yt.has(r.constructor)?r:vt(r);}return t}function Se(e){for(var t in e)if(F(e,t))return false;return true}var ze=null;function xe(e){ze=new WeakMap;var t=Ce(e);return ze=null,t}function Ce(e){if(!e||typeof e!="object")return e;var t=ze.get(e);if(t)return t;if(k(e)){t=[],ze.set(e,t);for(var n=0,r=e.length;n<r;++n)t.push(Ce(e[n]));}else if(yt.has(e.constructor))t=e;else {var i=N(e);t=i===Object.prototype?{}:Object.create(i),ze.set(e,t);for(var a in e)F(e,a)&&(t[a]=Ce(e[a]));}return t}var li={}.toString;function pn(e){return li.call(e).slice(8,-1)}var yn=typeof Symbol<"u"?Symbol.iterator:"@@iterator",ci=typeof yn=="symbol"?function(e){var t;return e!=null&&(t=e[yn])&&t.apply(e)}:function(){return null};function $e(e,t){var n=e.indexOf(t);return n>=0&&e.splice(n,1),n>=0}var rt={};function Re(e){var t,n,r,i;if(arguments.length===1){if(k(e))return e.slice();if(this===rt&&typeof e=="string")return [e];if(i=ci(e)){for(n=[];r=i.next(),!r.done;)n.push(r.value);return n}if(e==null)return [e];if(t=e.length,typeof t=="number"){for(n=new Array(t);t--;)n[t]=e[t];return n}return [e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var vn=typeof Symbol<"u"?function(e){return e[Symbol.toStringTag]==="AsyncFunction"}:function(){return false},fi=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],fr=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],mn=fi.concat(fr),hi={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 it(e,t){this.name=e,this.message=t;}ee(it).from(Error).extend({toString:function(){return this.name+": "+this.message}});function hr(e,t){return e+". Errors: "+Object.keys(t).map(function(n){return t[n].toString()}).filter(function(n,r,i){return i.indexOf(n)===r}).join(`
`)}function Ct(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=hr(e,t);}ee(Ct).from(it);function at(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(n){return t[n]}),this.failuresByPos=t,this.message=hr(e,this.failures);}ee(at).from(it);var gn=mn.reduce(function(e,t){return e[t]=t+"Error",e},{}),di=it,U=mn.reduce(function(e,t){var n=t+"Error";function r(i,a){this.name=n,i?typeof i=="string"?(this.message="".concat(i).concat(a?`
`+a:""),this.inner=a||null):typeof i=="object"&&(this.message="".concat(i.name," ").concat(i.message),this.inner=i):(this.message=hi[t]||n,this.inner=null);}return ee(r).from(di),e[t]=r,e},{});U.Syntax=SyntaxError,U.Type=TypeError,U.Range=RangeError;var dr=fr.reduce(function(e,t){return e[t+"Error"]=U[t],e},{});function pi(e,t){if(!e||e instanceof it||e instanceof TypeError||e instanceof SyntaxError||!e.name||!dr[e.name])return e;var n=new dr[e.name](t||e.message,e);return "stack"in e&&H(n,"stack",{get:function(){return this.inner.stack}}),n}var Bt=mn.reduce(function(e,t){return ["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=U[t]),e},{});Bt.ModifyError=Ct,Bt.DexieError=it,Bt.BulkError=at;function Z(){}function mt(e){return e}function yi(e,t){return e==null||e===mt?t:function(n){return t(e(n))}}function Qe(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments);}}function vi(e,t){return e===Z?t:function(){var n=e.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?Qe(r,this.onsuccess):r),i&&(this.onerror=this.onerror?Qe(i,this.onerror):i),a!==void 0?a:n}}function mi(e,t){return e===Z?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?Qe(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Qe(r,this.onerror):r);}}function gi(e,t){return e===Z?t:function(n){var r=e.apply(this,arguments);P(n,r);var i=this.onsuccess,a=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?Qe(i,this.onsuccess):i),a&&(this.onerror=this.onerror?Qe(a,this.onerror):a),r===void 0?o===void 0?void 0:o:P(r,o)}}function bi(e,t){return e===Z?t:function(){return t.apply(this,arguments)===false?false:e.apply(this,arguments)}}function bn(e,t){return e===Z?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,i=arguments.length,a=new Array(i);i--;)a[i]=arguments[i];return n.then(function(){return t.apply(r,a)})}return t.apply(this,arguments)}}var ke=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function pr(e,t){ke=e;}var gt={},yr=100,wn=typeof Promise>"u"?[]:function(){var e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return [e,N(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return [t,N(t),e]}(),vr=wn[0],mr=wn[1],wi=wn[2],Ti=mr&&mr.then,Ye=vr&&vr.constructor,Tn=!!wi;function _i(){queueMicrotask(ki);}var bt=function(e,t){wt.push([e,t]),Mt&&(_i(),Mt=false);},_n=true,Mt=true,Ge=[],Nt=[],xn=mt,Be={id:"global",global:true,ref:0,unhandleds:[],onunhandled:Z,pgp:false,env:{},finalize:Z},V=Be,wt=[],Xe=0,Ft=[];function C(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=false;var t=this._PSD=V;if(typeof e!="function"){if(e!==gt)throw new TypeError("Not a function");this._state=arguments[1],this._value=arguments[2],this._state===false&&Kn(this,this._value);return}this._state=null,this._value=null,++t.ref,br(this,e);}var kn={get:function(){var e=V,t=Lt;function n(r,i){var a=this,o=!e.global&&(e!==V||t!==Lt),s=o&&!Ne(),l=new C(function(h,v){On(a,new gr(_r(r,e,o,s),_r(i,e,o,s),h,v,e));});return this._consoleTask&&(l._consoleTask=this._consoleTask),l}return n.prototype=gt,n},set:function(e){H(this,"then",e&&e.prototype===gt?kn:{get:function(){return e},set:kn.set});}};A(C.prototype,{then:kn,_then:function(e,t){On(this,new gr(null,null,e,t,V));},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=arguments[0],n=arguments[1];return typeof t=="function"?this.then(null,function(r){return r instanceof t?n(r):Vt(r)}):this.then(null,function(r){return r&&r.name===t?n(r):Vt(r)})},finally:function(e){return this.then(function(t){return C.resolve(e()).then(function(){return t})},function(t){return C.resolve(e()).then(function(){return Vt(t)})})},timeout:function(e,t){var n=this;return e<1/0?new C(function(r,i){var a=setTimeout(function(){return i(new U.Timeout(t))},e);n.then(r,i).finally(clearTimeout.bind(null,a));}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&H(C.prototype,Symbol.toStringTag,"Dexie.Promise"),Be.env=Tr();function gr(e,t,n,r,i){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=r,this.psd=i;}A(C,{all:function(){var e=Re.apply(null,arguments).map(Wt);return new C(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach(function(i,a){return C.resolve(i).then(function(o){e[a]=o,--r||t(e);},n)});})},resolve:function(e){if(e instanceof C)return e;if(e&&typeof e.then=="function")return new C(function(n,r){e.then(n,r);});var t=new C(gt,true,e);return t},reject:Vt,race:function(){var e=Re.apply(null,arguments).map(Wt);return new C(function(t,n){e.map(function(r){return C.resolve(r).then(t,n)});})},PSD:{get:function(){return V},set:function(e){return V=e}},totalEchoes:{get:function(){return Lt}},newPSD:Me,usePSD:qe,scheduler:{get:function(){return bt},set:function(e){bt=e;}},rejectionMapper:{get:function(){return xn},set:function(e){xn=e;}},follow:function(e,t){return new C(function(n,r){return Me(function(i,a){var o=V;o.unhandleds=[],o.onunhandled=a,o.finalize=Qe(function(){var s=this;Ki(function(){s.unhandleds.length===0?i():a(s.unhandleds[0]);});},o.finalize),e();},t,n,r)})}}),Ye&&(Ye.allSettled&&H(C,"allSettled",function(){var e=Re.apply(null,arguments).map(Wt);return new C(function(t){e.length===0&&t([]);var n=e.length,r=new Array(n);e.forEach(function(i,a){return C.resolve(i).then(function(o){return r[a]={status:"fulfilled",value:o}},function(o){return r[a]={status:"rejected",reason:o}}).then(function(){return --n||t(r)})});})}),Ye.any&&typeof AggregateError<"u"&&H(C,"any",function(){var e=Re.apply(null,arguments).map(Wt);return new C(function(t,n){e.length===0&&n(new AggregateError([]));var r=e.length,i=new Array(r);e.forEach(function(a,o){return C.resolve(a).then(function(s){return t(s)},function(s){i[o]=s,--r||n(new AggregateError(i));})});})}),Ye.withResolvers&&(C.withResolvers=Ye.withResolvers));function br(e,t){try{t(function(n){if(e._state===null){if(n===e)throw new TypeError("A promise cannot be resolved with itself.");var r=e._lib&&ot();n&&typeof n.then=="function"?br(e,function(i,a){n instanceof C?n._then(i,a):n.then(i,a);}):(e._state=!0,e._value=n,wr(e)),r&&st();}},Kn.bind(null,e));}catch(n){Kn(e,n);}}function Kn(e,t){if(Nt.push(t),e._state===null){var n=e._lib&&ot();t=xn(t),e._state=false,e._value=t,Oi(e),wr(e),n&&st();}}function wr(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)On(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),Xe===0&&(++Xe,bt(function(){--Xe===0&&En();},[]));}function On(e,t){if(e._state===null){e._listeners.push(t);return}var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return (e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Xe,bt(xi,[n,e,t]);}function xi(e,t,n){try{var r,i=t._value;!t._state&&Nt.length&&(Nt=[]),r=ke&&t._consoleTask?t._consoleTask.run(function(){return e(i)}):e(i),!t._state&&Nt.indexOf(i)===-1&&Ei(t),n.resolve(r);}catch(a){n.reject(a);}finally{--Xe===0&&En(),--n.psd.ref||n.psd.finalize();}}function ki(){qe(Be,function(){ot()&&st();});}function ot(){var e=_n;return _n=false,Mt=false,e}function st(){var e,t,n;do for(;wt.length>0;)for(e=wt,wt=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1]);}while(wt.length>0);_n=true,Mt=true;}function En(){var e=Ge;Ge=[],e.forEach(function(r){r._PSD.onunhandled.call(null,r._value,r);});for(var t=Ft.slice(0),n=t.length;n;)t[--n]();}function Ki(e){function t(){e(),Ft.splice(Ft.indexOf(t),1);}Ft.push(t),++Xe,bt(function(){--Xe===0&&En();},[]);}function Oi(e){Ge.some(function(t){return t._value===e._value})||Ge.push(e);}function Ei(e){for(var t=Ge.length;t;)if(Ge[--t]._value===e._value){Ge.splice(t,1);return}}function Vt(e){return new C(gt,false,e)}function ne(e,t){var n=V;return function(){var r=ot(),i=V;try{return Fe(n,!0),e.apply(this,arguments)}catch(a){t&&t(a);}finally{Fe(i,false),r&&st();}}}var le={awaits:0,echoes:0,id:0},Pi=0,jt=[],Ut=0,Lt=0,Si=0;function Me(e,t,n,r){var i=V,a=Object.create(i);a.parent=i,a.ref=0,a.global=false,a.id=++Si,Be.env,a.env=Tn?{Promise:C,PromiseProp:{value:C,configurable:true,writable:true},all:C.all,race:C.race,allSettled:C.allSettled,any:C.any,resolve:C.resolve,reject:C.reject}:{},t&&P(a,t),++i.ref,a.finalize=function(){--this.parent.ref||this.parent.finalize();};var o=qe(a,e,n,r);return a.ref===0&&a.finalize(),o}function ut(){return le.id||(le.id=++Pi),++le.awaits,le.echoes+=yr,le.id}function Ne(){return le.awaits?(--le.awaits===0&&(le.id=0),le.echoes=le.awaits*yr,true):false}(""+Ti).indexOf("[native code]")===-1&&(ut=Ne=Z);function Wt(e){return le.echoes&&e&&e.constructor===Ye?(ut(),e.then(function(t){return Ne(),t},function(t){return Ne(),se(t)})):e}function Ri(e){++Lt,(!le.echoes||--le.echoes===0)&&(le.echoes=le.awaits=le.id=0),jt.push(V),Fe(e,true);}function Ai(){var e=jt[jt.length-1];jt.pop(),Fe(e,false);}function Fe(e,t){var n=V;if((t?le.echoes&&(!Ut++||e!==V):Ut&&(!--Ut||e!==V))&&queueMicrotask(t?Ri.bind(null,e):Ai),e!==V&&(V=e,n===Be&&(Be.env=Tr()),Tn)){var r=Be.env.Promise,i=e.env;(n.global||e.global)&&(Object.defineProperty(m,"Promise",i.PromiseProp),r.all=i.all,r.race=i.race,r.resolve=i.resolve,r.reject=i.reject,i.allSettled&&(r.allSettled=i.allSettled),i.any&&(r.any=i.any));}}function Tr(){var e=m.Promise;return Tn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(m,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function qe(e,t,n,r,i){var a=V;try{return Fe(e,!0),t(n,r,i)}finally{Fe(a,false);}}function _r(e,t,n,r){return typeof e!="function"?e:function(){var i=V;n&&ut(),Fe(t,true);try{return e.apply(this,arguments)}finally{Fe(i,false),r&&queueMicrotask(Ne);}}}function Pn(e){Promise===Ye&&le.echoes===0?Ut===0?e():enqueueNativeMicroTask(e):setTimeout(e,0);}var se=C.reject;function Sn(e,t,n,r){if(!e.idbdb||!e._state.openComplete&&!V.letThrough&&!e._vip){if(e._state.openComplete)return se(new U.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._state.autoOpen)return se(new U.DatabaseClosed);e.open().catch(Z);}return e._state.dbReadyPromise.then(function(){return Sn(e,t,n,r)})}else {var i=e._createTransaction(t,n,e._dbSchema);try{i.create(),e._state.PR1398_maxLoop=3;}catch(a){return a.name===gn.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e.close({disableAutoOpen:false}),e.open().then(function(){return Sn(e,t,n,r)})):se(a)}return i._promise(t,function(a,o){return Me(function(){return V.trans=i,r(a,o,i)})}).then(function(a){if(t==="readwrite")try{i.idbtrans.commit();}catch{}return t==="readonly"?a:i._completion.then(function(){return a})})}}var xr="4.0.11",Je="\uFFFF",Rn=-1/0,Ae="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",kr="String expected.",lt=[],Ht="__dbnames",An="readonly",Dn="readwrite";function Ze(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Kr={type:3,lower:-1/0,lowerOpen:false,upper:[[]],upperOpen:false};function zt(e){return typeof e=="string"&&!/\./.test(e)?function(t){return t[e]===void 0&&e in t&&(t=xe(t),delete t[e]),t}:function(t){return t}}function Or(){throw U.Type()}function X(e,t){try{var n=Er(e),r=Er(t);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case "number":case "Date":case "string":return e>t?1:e<t?-1:0;case "binary":return Ii(Pr(e),Pr(t));case "Array":return Di(e,t)}}catch{}return NaN}function Di(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,a=0;a<i;++a){var o=X(e[a],t[a]);if(o!==0)return o}return n===r?0:n<r?-1:1}function Ii(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,a=0;a<i;++a)if(e[a]!==t[a])return e[a]<t[a]?-1:1;return n===r?0:n<r?-1:1}function Er(e){var t=typeof e;if(t!=="object")return t;if(ArrayBuffer.isView(e))return "binary";var n=pn(e);return n==="ArrayBuffer"?"binary":n}function Pr(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Sr=function(){function e(){}return e.prototype._trans=function(t,n,r){var i=this._tx||V.trans,a=this.name,o=ke&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(t==="readonly"?"read":"write"," ").concat(this.name));function s(v,d,T){if(!T.schema[a])throw new U.NotFound("Table "+a+" not part of transaction");return n(T.idbtrans,T)}var l=ot();try{var h=i&&i.db._novip===this.db._novip?i===V.trans?i._promise(t,s,r):Me(function(){return i._promise(t,s,r)},{trans:i,transless:V.transless||V}):Sn(this.db,t,[this.name],s);return o&&(h._consoleTask=o,h=h.catch(function(v){return console.trace(v),se(v)})),h}finally{l&&st();}},e.prototype.get=function(t,n){var r=this;return t&&t.constructor===Object?this.where(t).first(n):t==null?se(new U.Type("Invalid argument to Table.get()")):this._trans("readonly",function(i){return r.core.get({trans:i,key:t}).then(function(a){return r.hook.reading.fire(a)})}).then(n)},e.prototype.where=function(t){if(typeof t=="string")return new this.db.WhereClause(this,t);if(k(t))return new this.db.WhereClause(this,"[".concat(t.join("+"),"]"));var n=b(t);if(n.length===1)return this.where(n[0]).equals(t[n[0]]);var r=this.schema.indexes.concat(this.schema.primKey).filter(function(v){if(v.compound&&n.every(function(T){return v.keyPath.indexOf(T)>=0})){for(var d=0;d<n.length;++d)if(n.indexOf(v.keyPath[d])===-1)return false;return true}return false}).sort(function(v,d){return v.keyPath.length-d.keyPath.length})[0];if(r&&this.db._maxKey!==Je){var i=r.keyPath.slice(0,n.length);return this.where(i).equals(i.map(function(v){return t[v]}))}!r&&ke&&console.warn("The query ".concat(JSON.stringify(t)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(n.join("+"),"]"));var a=this.schema.idxByName;function o(v,d){return X(v,d)===0}var s=n.reduce(function(v,d){var T=v[0],S=v[1],p=a[d],g=t[d];return [T||p,T||!p?Ze(S,p&&p.multi?function(w){var O=be(w,d);return k(O)&&O.some(function(x){return o(g,x)})}:function(w){return o(g,be(w,d))}):S]},[null,null]),l=s[0],h=s[1];return l?this.where(l.name).equals(t[l.keyPath]).filter(h):r?this.filter(h):this.where(n).equals("")},e.prototype.filter=function(t){return this.toCollection().and(t)},e.prototype.count=function(t){return this.toCollection().count(t)},e.prototype.offset=function(t){return this.toCollection().offset(t)},e.prototype.limit=function(t){return this.toCollection().limit(t)},e.prototype.each=function(t){return this.toCollection().each(t)},e.prototype.toArray=function(t){return this.toCollection().toArray(t)},e.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},e.prototype.orderBy=function(t){return new this.db.Collection(new this.db.WhereClause(this,k(t)?"[".concat(t.join("+"),"]"):t))},e.prototype.reverse=function(){return this.toCollection().reverse()},e.prototype.mapToClass=function(t){var n=this,r=n.db,i=n.name;this.schema.mappedClass=t,t.prototype instanceof Or&&(t=function(l){u(h,l);function h(){return l!==null&&l.apply(this,arguments)||this}return Object.defineProperty(h.prototype,"db",{get:function(){return r},enumerable:false,configurable:true}),h.prototype.table=function(){return i},h}(t));for(var a=new Set,o=t.prototype;o;o=N(o))Object.getOwnPropertyNames(o).forEach(function(l){return a.add(l)});var s=function(l){if(!l)return l;var h=Object.create(t.prototype);for(var v in l)if(!a.has(v))try{h[v]=l[v];}catch{}return h};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=s,this.hook("reading",s),t},e.prototype.defineClass=function(){function t(n){P(this,n);}return this.mapToClass(t)},e.prototype.add=function(t,n){var r=this,i=this.schema.primKey,a=i.auto,o=i.keyPath,s=t;return o&&a&&(s=zt(o)(t)),this._trans("readwrite",function(l){return r.core.mutate({trans:l,type:"add",keys:n!=null?[n]:null,values:[s]})}).then(function(l){return l.numFailures?C.reject(l.failures[0]):l.lastResult}).then(function(l){if(o)try{ce(t,o,l);}catch{}return l})},e.prototype.update=function(t,n){if(typeof t=="object"&&!k(t)){var r=be(t,this.schema.primKey.keyPath);return r===void 0?se(new U.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(r).modify(n)}else return this.where(":id").equals(t).modify(n)},e.prototype.put=function(t,n){var r=this,i=this.schema.primKey,a=i.auto,o=i.keyPath,s=t;return o&&a&&(s=zt(o)(t)),this._trans("readwrite",function(l){return r.core.mutate({trans:l,type:"put",values:[s],keys:n!=null?[n]:null})}).then(function(l){return l.numFailures?C.reject(l.failures[0]):l.lastResult}).then(function(l){if(o)try{ce(t,o,l);}catch{}return l})},e.prototype.delete=function(t){var n=this;return this._trans("readwrite",function(r){return n.core.mutate({trans:r,type:"delete",keys:[t]})}).then(function(r){return r.numFailures?C.reject(r.failures[0]):void 0})},e.prototype.clear=function(){var t=this;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"deleteRange",range:Kr})}).then(function(n){return n.numFailures?C.reject(n.failures[0]):void 0})},e.prototype.bulkGet=function(t){var n=this;return this._trans("readonly",function(r){return n.core.getMany({keys:t,trans:r}).then(function(i){return i.map(function(a){return n.hook.reading.fire(a)})})})},e.prototype.bulkAdd=function(t,n,r){var i=this,a=Array.isArray(n)?n:void 0;r=r||(a?void 0:n);var o=r?r.allKeys:void 0;return this._trans("readwrite",function(s){var l=i.schema.primKey,h=l.auto,v=l.keyPath;if(v&&a)throw new U.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==t.length)throw new U.InvalidArgument("Arguments objects and keys must have the same length");var d=t.length,T=v&&h?t.map(zt(v)):t;return i.core.mutate({trans:s,type:"add",keys:a,values:T,wantResults:o}).then(function(S){var p=S.numFailures,g=S.results,w=S.lastResult,O=S.failures,x=o?g:w;if(p===0)return x;throw new at("".concat(i.name,".bulkAdd(): ").concat(p," of ").concat(d," operations failed"),O)})})},e.prototype.bulkPut=function(t,n,r){var i=this,a=Array.isArray(n)?n:void 0;r=r||(a?void 0:n);var o=r?r.allKeys:void 0;return this._trans("readwrite",function(s){var l=i.schema.primKey,h=l.auto,v=l.keyPath;if(v&&a)throw new U.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==t.length)throw new U.InvalidArgument("Arguments objects and keys must have the same length");var d=t.length,T=v&&h?t.map(zt(v)):t;return i.core.mutate({trans:s,type:"put",keys:a,values:T,wantResults:o}).then(function(S){var p=S.numFailures,g=S.results,w=S.lastResult,O=S.failures,x=o?g:w;if(p===0)return x;throw new at("".concat(i.name,".bulkPut(): ").concat(p," of ").concat(d," operations failed"),O)})})},e.prototype.bulkUpdate=function(t){var n=this,r=this.core,i=t.map(function(s){return s.key}),a=t.map(function(s){return s.changes}),o=[];return this._trans("readwrite",function(s){return r.getMany({trans:s,keys:i,cache:"clone"}).then(function(l){var h=[],v=[];t.forEach(function(T,S){var p=T.key,g=T.changes,w=l[S];if(w){for(var O=0,x=Object.keys(g);O<x.length;O++){var K=x[O],E=g[K];if(K===n.schema.primKey.keyPath){if(X(E,p)!==0)throw new U.Constraint("Cannot update primary key in bulkUpdate()")}else ce(w,K,E);}o.push(S),h.push(p),v.push(w);}});var d=h.length;return r.mutate({trans:s,type:"put",keys:h,values:v,updates:{keys:i,changeSpecs:a}}).then(function(T){var S=T.numFailures,p=T.failures;if(S===0)return d;for(var g=0,w=Object.keys(p);g<w.length;g++){var O=w[g],x=o[Number(O)];if(x!=null){var K=p[O];delete p[O],p[x]=K;}}throw new at("".concat(n.name,".bulkUpdate(): ").concat(S," of ").concat(d," operations failed"),p)})})})},e.prototype.bulkDelete=function(t){var n=this,r=t.length;return this._trans("readwrite",function(i){return n.core.mutate({trans:i,type:"delete",keys:t})}).then(function(i){var a=i.numFailures,o=i.lastResult,s=i.failures;if(a===0)return o;throw new at("".concat(n.name,".bulkDelete(): ").concat(a," of ").concat(r," operations failed"),s)})},e}();function Tt(e){var t={},n=function(s,l){if(l){for(var h=arguments.length,v=new Array(h-1);--h;)v[h-1]=arguments[h];return t[s].subscribe.apply(null,v),e}else if(typeof s=="string")return t[s]};n.addEventType=a;for(var r=1,i=arguments.length;r<i;++r)a(arguments[r]);return n;function a(s,l,h){if(typeof s=="object")return o(s);l||(l=bi),h||(h=Z);var v={subscribers:[],fire:h,subscribe:function(d){v.subscribers.indexOf(d)===-1&&(v.subscribers.push(d),v.fire=l(v.fire,d));},unsubscribe:function(d){v.subscribers=v.subscribers.filter(function(T){return T!==d}),v.fire=v.subscribers.reduce(l,h);}};return t[s]=n[s]=v,v}function o(s){b(s).forEach(function(l){var h=s[l];if(k(h))a(l,s[l][0],s[l][1]);else if(h==="asap")var v=a(l,mt,function(){for(var T=arguments.length,S=new Array(T);T--;)S[T]=arguments[T];v.subscribers.forEach(function(p){dt(function(){p.apply(null,S);});});});else throw new U.InvalidArgument("Invalid event config")});}}function _t(e,t){return ee(t).from({prototype:e}),t}function Ci(e){return _t(Sr.prototype,function(n,r,i){this.db=e,this._tx=i,this.name=n,this.schema=r,this.hook=e._allTables[n]?e._allTables[n].hook:Tt(null,{creating:[vi,Z],reading:[yi,mt],updating:[gi,Z],deleting:[mi,Z]});})}function ct(e,t){return !(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function In(e,t){e.filter=Ze(e.filter,t);}function Cn(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return Ze(r(),t())}:t,e.justLimit=n&&!r;}function Bi(e,t){e.isMatch=Ze(e.isMatch,t);}function $t(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new U.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Rr(e,t,n){var r=$t(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:r,range:e.range}})}function Qt(e,t,n,r){var i=e.replayFilter?Ze(e.filter,e.replayFilter()):e.filter;if(e.or){var a={},o=function(s,l,h){if(!i||i(l,h,function(T){return l.stop(T)},function(T){return l.fail(T)})){var v=l.primaryKey,d=""+v;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(v)),F(a,d)||(a[d]=true,t(s,l,h));}};return Promise.all([e.or._iterate(o,n),Ar(Rr(e,r,n),e.algorithm,o,!e.keysOnly&&e.valueMapper)])}else return Ar(Rr(e,r,n),Ze(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function Ar(e,t,n,r){var i=r?function(o,s,l){return n(r(o),s,l)}:n,a=ne(i);return e.then(function(o){if(o)return o.start(function(){var s=function(){return o.continue()};(!t||t(o,function(l){return s=l},function(l){o.stop(l),s=Z;},function(l){o.fail(l),s=Z;}))&&a(o.value,o,function(l){return s=l}),s();})})}var xt=function(){function e(t){this["@@propmod"]=t;}return e.prototype.execute=function(t){var n,r=this["@@propmod"];if(r.add!==void 0){var i=r.add;if(k(i))return y(y([],k(t)?t:[],true),i).sort();if(typeof i=="number")return (Number(t)||0)+i;if(typeof i=="bigint")try{return BigInt(t)+i}catch{return BigInt(0)+i}throw new TypeError("Invalid term ".concat(i))}if(r.remove!==void 0){var a=r.remove;if(k(a))return k(t)?t.filter(function(s){return !a.includes(s)}).sort():[];if(typeof a=="number")return Number(t)-a;if(typeof a=="bigint")try{return BigInt(t)-a}catch{return BigInt(0)-a}throw new TypeError("Invalid subtrahend ".concat(a))}var o=(n=r.replacePrefix)===null||n===void 0?void 0:n[0];return o&&typeof t=="string"&&t.startsWith(o)?r.replacePrefix[1]+t.substring(o.length):t},e}(),Mi=function(){function e(){}return e.prototype._read=function(t,n){var r=this._ctx;return r.error?r.table._trans(null,se.bind(null,r.error)):r.table._trans("readonly",t).then(n)},e.prototype._write=function(t){var n=this._ctx;return n.error?n.table._trans(null,se.bind(null,n.error)):n.table._trans("readwrite",t,"locked")},e.prototype._addAlgorithm=function(t){var n=this._ctx;n.algorithm=Ze(n.algorithm,t);},e.prototype._iterate=function(t,n){return Qt(this._ctx,t,n,this._ctx.table.core)},e.prototype.clone=function(t){var n=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&P(r,t),n._ctx=r,n},e.prototype.raw=function(){return this._ctx.valueMapper=null,this},e.prototype.each=function(t){var n=this._ctx;return this._read(function(r){return Qt(n,t,r,n.table.core)})},e.prototype.count=function(t){var n=this;return this._read(function(r){var i=n._ctx,a=i.table.core;if(ct(i,true))return a.count({trans:r,query:{index:$t(i,a.schema),range:i.range}}).then(function(s){return Math.min(s,i.limit)});var o=0;return Qt(i,function(){return ++o,false},r,a).then(function(){return o})}).then(t)},e.prototype.sortBy=function(t,n){var r=t.split(".").reverse(),i=r[0],a=r.length-1;function o(h,v){return v?o(h[r[v]],v-1):h[i]}var s=this._ctx.dir==="next"?1:-1;function l(h,v){var d=o(h,a),T=o(v,a);return X(d,T)*s}return this.toArray(function(h){return h.sort(l)}).then(n)},e.prototype.toArray=function(t){var n=this;return this._read(function(r){var i=n._ctx;if(i.dir==="next"&&ct(i,true)&&i.limit>0){var a=i.valueMapper,o=$t(i,i.table.core.schema);return i.table.core.query({trans:r,limit:i.limit,values:true,query:{index:o,range:i.range}}).then(function(l){var h=l.result;return a?h.map(a):h})}else {var s=[];return Qt(i,function(l){return s.push(l)},r,i.table.core).then(function(){return s})}},t)},e.prototype.offset=function(t){var n=this._ctx;return t<=0?this:(n.offset+=t,ct(n)?Cn(n,function(){var r=t;return function(i,a){return r===0?true:r===1?(--r,false):(a(function(){i.advance(r),r=0;}),false)}}):Cn(n,function(){var r=t;return function(){return --r<0}}),this)},e.prototype.limit=function(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Cn(this._ctx,function(){var n=t;return function(r,i,a){return --n<=0&&i(a),n>=0}},true),this},e.prototype.until=function(t,n){return In(this._ctx,function(r,i,a){return t(r.value)?(i(a),n):true}),this},e.prototype.first=function(t){return this.limit(1).toArray(function(n){return n[0]}).then(t)},e.prototype.last=function(t){return this.reverse().first(t)},e.prototype.filter=function(t){return In(this._ctx,function(n){return t(n.value)}),Bi(this._ctx,t),this},e.prototype.and=function(t){return this.filter(t)},e.prototype.or=function(t){return new this.db.WhereClause(this._ctx.table,t,this)},e.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},e.prototype.desc=function(){return this.reverse()},e.prototype.eachKey=function(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,i){t(i.key,i);})},e.prototype.eachUniqueKey=function(t){return this._ctx.unique="unique",this.eachKey(t)},e.prototype.eachPrimaryKey=function(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,i){t(i.primaryKey,i);})},e.prototype.keys=function(t){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(i,a){r.push(a.key);}).then(function(){return r}).then(t)},e.prototype.primaryKeys=function(t){var n=this._ctx;if(n.dir==="next"&&ct(n,true)&&n.limit>0)return this._read(function(i){var a=$t(n,n.table.core.schema);return n.table.core.query({trans:i,values:false,limit:n.limit,query:{index:a,range:n.range}})}).then(function(i){var a=i.result;return a}).then(t);n.keysOnly=!n.isMatch;var r=[];return this.each(function(i,a){r.push(a.primaryKey);}).then(function(){return r}).then(t)},e.prototype.uniqueKeys=function(t){return this._ctx.unique="unique",this.keys(t)},e.prototype.firstKey=function(t){return this.limit(1).keys(function(n){return n[0]}).then(t)},e.prototype.lastKey=function(t){return this.reverse().firstKey(t)},e.prototype.distinct=function(){var t=this._ctx,n=t.index&&t.table.schema.idxByName[t.index];if(!n||!n.multi)return this;var r={};return In(this._ctx,function(i){var a=i.primaryKey.toString(),o=F(r,a);return r[a]=true,!o}),this},e.prototype.modify=function(t){var n=this,r=this._ctx;return this._write(function(i){var a;if(typeof t=="function")a=t;else {var o=b(t),s=o.length;a=function(x){for(var K=false,E=0;E<s;++E){var _=o[E],R=t[_],B=be(x,_);R instanceof xt?(ce(x,_,R.execute(B)),K=true):B!==R&&(ce(x,_,R),K=true);}return K};}var l=r.table.core,h=l.schema.primaryKey,v=h.outbound,d=h.extractKey,T=200,S=n.db._options.modifyChunkSize;S&&(typeof S=="object"?T=S[l.name]||S["*"]||200:T=S);var p=[],g=0,w=[],O=function(x,K){var E=K.failures,_=K.numFailures;g+=x-_;for(var R=0,B=b(E);R<B.length;R++){var I=B[R];p.push(E[I]);}};return n.clone().primaryKeys().then(function(x){var K=ct(r)&&r.limit===1/0&&(typeof t!="function"||t===Bn)&&{index:r.index,range:r.range},E=function(_){var R=Math.min(T,x.length-_);return l.getMany({trans:i,keys:x.slice(_,_+R),cache:"immutable"}).then(function(B){for(var I=[],L=[],Q=v?[]:null,M=[],$=0;$<R;++$){var W=B[$],q={value:xe(W),primKey:x[_+$]};a.call(q,q.value,q)!==false&&(q.value==null?M.push(x[_+$]):!v&&X(d(W),d(q.value))!==0?(M.push(x[_+$]),I.push(q.value)):(L.push(q.value),v&&Q.push(x[_+$])));}return Promise.resolve(I.length>0&&l.mutate({trans:i,type:"add",values:I}).then(function(j){for(var oe in j.failures)M.splice(parseInt(oe),1);O(I.length,j);})).then(function(){return (L.length>0||K&&typeof t=="object")&&l.mutate({trans:i,type:"put",keys:Q,values:L,criteria:K,changeSpec:typeof t!="function"&&t,isAdditionalChunk:_>0}).then(function(j){return O(L.length,j)})}).then(function(){return (M.length>0||K&&t===Bn)&&l.mutate({trans:i,type:"delete",keys:M,criteria:K,isAdditionalChunk:_>0}).then(function(j){return O(M.length,j)})}).then(function(){return x.length>_+R&&E(_+T)})})};return E(0).then(function(){if(p.length>0)throw new Ct("Error modifying one or more objects",p,g,w);return x.length})})})},e.prototype.delete=function(){var t=this._ctx,n=t.range;return ct(t)&&(t.isPrimKey||n.type===3)?this._write(function(r){var i=t.table.core.schema.primaryKey,a=n;return t.table.core.count({trans:r,query:{index:i,range:a}}).then(function(o){return t.table.core.mutate({trans:r,type:"deleteRange",range:a}).then(function(s){var l=s.failures;s.lastResult,s.results;var h=s.numFailures;if(h)throw new Ct("Could not delete some values",Object.keys(l).map(function(v){return l[v]}),o-h);return o-h})})}):this.modify(Bn)},e}(),Bn=function(e,t){return t.value=null};function Ni(e){return _t(Mi.prototype,function(n,r){this.db=e;var i=Kr,a=null;if(r)try{i=r();}catch(h){a=h;}var o=n._ctx,s=o.table,l=s.hook.reading.fire;this._ctx={table:s,index:o.index,isPrimKey:!o.index||s.schema.primKey.keyPath&&o.index===s.schema.primKey.name,range:i,keysOnly:false,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:true,isMatch:null,offset:0,limit:1/0,error:a,or:o.or,valueMapper:l!==mt?l:null};})}function Fi(e,t){return e<t?-1:e===t?0:1}function Vi(e,t){return e>t?-1:e===t?0:1}function me(e,t,n){var r=e instanceof Ir?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function ft(e){return new e.Collection(e,function(){return Dr("")}).limit(0)}function ji(e){return e==="next"?function(t){return t.toUpperCase()}:function(t){return t.toLowerCase()}}function Ui(e){return e==="next"?function(t){return t.toLowerCase()}:function(t){return t.toUpperCase()}}function Li(e,t,n,r,i,a){for(var o=Math.min(e.length,r.length),s=-1,l=0;l<o;++l){var h=t[l];if(h!==r[l])return i(e[l],n[l])<0?e.substr(0,l)+n[l]+n.substr(l+1):i(e[l],r[l])<0?e.substr(0,l)+r[l]+n.substr(l+1):s>=0?e.substr(0,s)+t[s]+n.substr(s+1):null;i(e[l],h)<0&&(s=l);}return o<r.length&&a==="next"?e+n.substr(e.length):o<e.length&&a==="prev"?e.substr(0,n.length):s<0?null:e.substr(0,s)+r[s]+n.substr(s+1)}function Yt(e,t,n,r){var i,a,o,s,l,h,v,d=n.length;if(!n.every(function(g){return typeof g=="string"}))return me(e,kr);function T(g){i=ji(g),a=Ui(g),o=g==="next"?Fi:Vi;var w=n.map(function(O){return {lower:a(O),upper:i(O)}}).sort(function(O,x){return o(O.lower,x.lower)});s=w.map(function(O){return O.upper}),l=w.map(function(O){return O.lower}),h=g,v=g==="next"?"":r;}T("next");var S=new e.Collection(e,function(){return Ve(s[0],l[d-1]+r)});S._ondirectionchange=function(g){T(g);};var p=0;return S._addAlgorithm(function(g,w,O){var x=g.key;if(typeof x!="string")return false;var K=a(x);if(t(K,l,p))return true;for(var E=null,_=p;_<d;++_){var R=Li(x,K,s[_],l[_],o,h);R===null&&E===null?p=_+1:(E===null||o(E,R)>0)&&(E=R);}return w(E!==null?function(){g.continue(E+v);}:O),false}),S}function Ve(e,t,n,r){return {type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Dr(e){return {type:1,lower:e,upper:e}}var Ir=function(){function e(){}return Object.defineProperty(e.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:false,configurable:true}),e.prototype.between=function(t,n,r,i){r=r!==false,i=i===true;try{return this._cmp(t,n)>0||this._cmp(t,n)===0&&(r||i)&&!(r&&i)?ft(this):new this.Collection(this,function(){return Ve(t,n,!r,!i)})}catch{return me(this,Ae)}},e.prototype.equals=function(t){return t==null?me(this,Ae):new this.Collection(this,function(){return Dr(t)})},e.prototype.above=function(t){return t==null?me(this,Ae):new this.Collection(this,function(){return Ve(t,void 0,true)})},e.prototype.aboveOrEqual=function(t){return t==null?me(this,Ae):new this.Collection(this,function(){return Ve(t,void 0,false)})},e.prototype.below=function(t){return t==null?me(this,Ae):new this.Collection(this,function(){return Ve(void 0,t,false,true)})},e.prototype.belowOrEqual=function(t){return t==null?me(this,Ae):new this.Collection(this,function(){return Ve(void 0,t)})},e.prototype.startsWith=function(t){return typeof t!="string"?me(this,kr):this.between(t,t+Je,true,true)},e.prototype.startsWithIgnoreCase=function(t){return t===""?this.startsWith(t):Yt(this,function(n,r){return n.indexOf(r[0])===0},[t],Je)},e.prototype.equalsIgnoreCase=function(t){return Yt(this,function(n,r){return n===r[0]},[t],"")},e.prototype.anyOfIgnoreCase=function(){var t=Re.apply(rt,arguments);return t.length===0?ft(this):Yt(this,function(n,r){return r.indexOf(n)!==-1},t,"")},e.prototype.startsWithAnyOfIgnoreCase=function(){var t=Re.apply(rt,arguments);return t.length===0?ft(this):Yt(this,function(n,r){return r.some(function(i){return n.indexOf(i)===0})},t,Je)},e.prototype.anyOf=function(){var t=this,n=Re.apply(rt,arguments),r=this._cmp;try{n.sort(r);}catch{return me(this,Ae)}if(n.length===0)return ft(this);var i=new this.Collection(this,function(){return Ve(n[0],n[n.length-1])});i._ondirectionchange=function(o){r=o==="next"?t._ascending:t._descending,n.sort(r);};var a=0;return i._addAlgorithm(function(o,s,l){for(var h=o.key;r(h,n[a])>0;)if(++a,a===n.length)return s(l),false;return r(h,n[a])===0?true:(s(function(){o.continue(n[a]);}),false)}),i},e.prototype.notEqual=function(t){return this.inAnyRange([[Rn,t],[t,this.db._maxKey]],{includeLowers:false,includeUppers:false})},e.prototype.noneOf=function(){var t=Re.apply(rt,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending);}catch{return me(this,Ae)}var n=t.reduce(function(r,i){return r?r.concat([[r[r.length-1][1],i]]):[[Rn,i]]},null);return n.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:false,includeUppers:false})},e.prototype.inAnyRange=function(t,n){var r=this,i=this._cmp,a=this._ascending,o=this._descending,s=this._min,l=this._max;if(t.length===0)return ft(this);if(!t.every(function(_){return _[0]!==void 0&&_[1]!==void 0&&a(_[0],_[1])<=0}))return me(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",U.InvalidArgument);var h=!n||n.includeLowers!==false,v=n&&n.includeUppers===true;function d(_,R){for(var B=0,I=_.length;B<I;++B){var L=_[B];if(i(R[0],L[1])<0&&i(R[1],L[0])>0){L[0]=s(L[0],R[0]),L[1]=l(L[1],R[1]);break}}return B===I&&_.push(R),_}var T=a;function S(_,R){return T(_[0],R[0])}var p;try{p=t.reduce(d,[]),p.sort(S);}catch{return me(this,Ae)}var g=0,w=v?function(_){return a(_,p[g][1])>0}:function(_){return a(_,p[g][1])>=0},O=h?function(_){return o(_,p[g][0])>0}:function(_){return o(_,p[g][0])>=0};function x(_){return !w(_)&&!O(_)}var K=w,E=new this.Collection(this,function(){return Ve(p[0][0],p[p.length-1][1],!h,!v)});return E._ondirectionchange=function(_){_==="next"?(K=w,T=a):(K=O,T=o),p.sort(S);},E._addAlgorithm(function(_,R,B){for(var I=_.key;K(I);)if(++g,g===p.length)return R(B),false;return x(I)?true:(r._cmp(I,p[g][1])===0||r._cmp(I,p[g][0])===0||R(function(){T===a?_.continue(p[g][0]):_.continue(p[g][1]);}),false)}),E},e.prototype.startsWithAnyOf=function(){var t=Re.apply(rt,arguments);return t.every(function(n){return typeof n=="string"})?t.length===0?ft(this):this.inAnyRange(t.map(function(n){return [n,n+Je]})):me(this,"startsWithAnyOf() only works with strings")},e}();function Wi(e){return _t(Ir.prototype,function(n,r,i){if(this.db=e,this._ctx={table:n,index:r===":id"?null:r,or:i},this._cmp=this._ascending=X,this._descending=function(a,o){return X(o,a)},this._max=function(a,o){return X(a,o)>0?a:o},this._min=function(a,o){return X(a,o)<0?a:o},this._IDBKeyRange=e._deps.IDBKeyRange,!this._IDBKeyRange)throw new U.MissingAPI})}function Ke(e){return ne(function(t){return kt(t),e(t.target.error),false})}function kt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault();}var Kt="storagemutated",Mn="x-storagemutated-1",je