@kbve/droid 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +5 -1
  3. package/assets/canvas-worker-DbsoY2Xv.js +5 -0
  4. package/assets/db-worker-CjXS52DQ.js +14 -0
  5. package/assets/ws-worker-FssAQgaD.js +5 -0
  6. package/comlink-CC72iIUO.js +253 -0
  7. package/droid.es.js +74 -12
  8. package/package.json +13 -3
  9. package/reference-Dk_1njEH.js +259 -0
  10. package/src/index.ts +21 -0
  11. package/src/lib/droid.spec.ts +26 -0
  12. package/src/lib/droid.ts +7 -0
  13. package/src/lib/mod/mod-manager.ts +73 -0
  14. package/src/lib/mod/mod-urls.ts +3 -0
  15. package/src/lib/mod/module/bento/mod-bento.worker.ts +128 -0
  16. package/src/lib/mod/module/phaser/mod-phaser.ts +0 -0
  17. package/src/lib/mod/module/supabase/mod-supabase.spec.ts +30 -0
  18. package/src/lib/mod/module/supabase/mod-supabase.worker.ts +59 -0
  19. package/src/lib/types/bento.ts +80 -0
  20. package/src/lib/types/discord.ts +40 -0
  21. package/src/lib/types/event-types.ts +35 -0
  22. package/src/lib/types/jedi.ts +66 -0
  23. package/src/lib/types/modules.ts +46 -0
  24. package/src/lib/types/panel-types.ts +18 -0
  25. package/src/lib/types/supabase-esm.d.ts +4 -0
  26. package/src/lib/workers/canvas-worker.ts +107 -0
  27. package/src/lib/workers/data.ts +215 -0
  28. package/src/lib/workers/db-worker.ts +203 -0
  29. package/src/lib/workers/events.ts +52 -0
  30. package/src/lib/workers/flexbuilder.ts +6 -0
  31. package/src/lib/workers/init.ts +40 -0
  32. package/src/lib/workers/main.ts +531 -0
  33. package/src/lib/workers/tools.ts +60 -0
  34. package/src/lib/workers/ws-worker.ts +73 -0
  35. package/src/setup-vitest.ts +2 -0
  36. package/src/types.d.ts +31 -0
  37. package/workers/main.js +1091 -0
  38. package/droid.cjs.js +0 -1
package/LICENSE ADDED
@@ -0,0 +1 @@
1
+ Please visit https://kbve.com/legal/ for the latest license information.
package/README.md CHANGED
@@ -26,4 +26,8 @@ Droid requires a few runtime dependencies to provide its full feature set:
26
26
  These dependencies are automatically installed when you add Droid to your project. If you plan to use Droid with specific frameworks or build tools, you may need to install related peer dependencies (such as React, Vue, or Angular) according to your project requirements.
27
27
 
28
28
  - Optional: TypeScript for type safety and better development experience
29
- - Optional: Framework-specific packages if integrating with React, Vue, Angular, etc.
29
+ - Optional: Framework-specific packages if integrating with React, Vue, Angular, etc.
30
+
31
+ ### Chores
32
+
33
+ Preparing to release next batch, trying to resolving the CDN issue, which might still be broken.
@@ -0,0 +1,5 @@
1
+ (function(){"use strict";/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */const S=Symbol("Comlink.proxy"),F=Symbol("Comlink.endpoint"),O=Symbol("Comlink.releaseProxy"),k=Symbol("Comlink.finalizer"),w=Symbol("Comlink.thrown"),p=t=>typeof t=="object"&&t!==null||typeof t=="function",z={canHandle:t=>p(t)&&t[S],serialize(t){const{port1:e,port2:r}=new MessageChannel;return M(t,e),[r,[r]]},deserialize(t){return t.start(),H(t)}},N={canHandle:t=>p(t)&&w in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},A=new Map([["proxy",z],["throw",N]]);function W(t,e){for(const r of t)if(e===r||r==="*"||r instanceof RegExp&&r.test(e))return!0;return!1}function M(t,e=globalThis,r=["*"]){e.addEventListener("message",function l(n){if(!n||!n.data)return;if(!W(r,n.origin)){console.warn(`Invalid origin '${n.origin}' for comlink proxy`);return}const{id:s,type:m,path:c}=Object.assign({path:[]},n.data),u=(n.data.argumentList||[]).map(h);let a;try{const o=c.slice(0,-1).reduce((i,y)=>i[y],t),f=c.reduce((i,y)=>i[y],t);switch(m){case"GET":a=f;break;case"SET":o[c.slice(-1)[0]]=h(n.data.value),a=!0;break;case"APPLY":a=f.apply(o,u);break;case"CONSTRUCT":{const i=new f(...u);a=$(i)}break;case"ENDPOINT":{const{port1:i,port2:y}=new MessageChannel;M(t,y),a=_(i,[i])}break;case"RELEASE":a=void 0;break;default:return}}catch(o){a={value:o,[w]:0}}Promise.resolve(a).catch(o=>({value:o,[w]:0})).then(o=>{const[f,i]=b(o);e.postMessage(Object.assign(Object.assign({},f),{id:s}),i),m==="RELEASE"&&(e.removeEventListener("message",l),P(e),k in t&&typeof t[k]=="function"&&t[k]())}).catch(o=>{const[f,i]=b({value:new TypeError("Unserializable return value"),[w]:0});e.postMessage(Object.assign(Object.assign({},f),{id:s}),i)})}),e.start&&e.start()}function D(t){return t.constructor.name==="MessagePort"}function P(t){D(t)&&t.close()}function H(t,e){const r=new Map;return t.addEventListener("message",function(n){const{data:s}=n;if(!s||!s.id)return;const m=r.get(s.id);if(m)try{m(s)}finally{r.delete(s.id)}}),C(t,r,[],e)}function d(t){if(t)throw new Error("Proxy has been released and is not useable")}function R(t){return g(t,new Map,{type:"RELEASE"}).then(()=>{P(t)})}const E=new WeakMap,x="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(E.get(t)||0)-1;E.set(t,e),e===0&&R(t)});function L(t,e){const r=(E.get(e)||0)+1;E.set(e,r),x&&x.register(t,e,t)}function U(t){x&&x.unregister(t)}function C(t,e,r=[],l=function(){}){let n=!1;const s=new Proxy(l,{get(m,c){if(d(n),c===O)return()=>{U(s),R(t),e.clear(),n=!0};if(c==="then"){if(r.length===0)return{then:()=>s};const u=g(t,e,{type:"GET",path:r.map(a=>a.toString())}).then(h);return u.then.bind(u)}return C(t,e,[...r,c])},set(m,c,u){d(n);const[a,o]=b(u);return g(t,e,{type:"SET",path:[...r,c].map(f=>f.toString()),value:a},o).then(h)},apply(m,c,u){d(n);const a=r[r.length-1];if(a===F)return g(t,e,{type:"ENDPOINT"}).then(h);if(a==="bind")return C(t,e,r.slice(0,-1));const[o,f]=v(u);return g(t,e,{type:"APPLY",path:r.map(i=>i.toString()),argumentList:o},f).then(h)},construct(m,c){d(n);const[u,a]=v(c);return g(t,e,{type:"CONSTRUCT",path:r.map(o=>o.toString()),argumentList:u},a).then(h)}});return L(s,t),s}function V(t){return Array.prototype.concat.apply([],t)}function v(t){const e=t.map(b);return[e.map(r=>r[0]),V(e.map(r=>r[1]))]}const T=new WeakMap;function _(t,e){return T.set(t,e),t}function $(t){return Object.assign(t,{[S]:!0})}function b(t){for(const[e,r]of A)if(r.canHandle(t)){const[l,n]=r.serialize(t);return[{type:"HANDLER",name:e,value:l},n]}return[{type:"RAW",value:t},T.get(t)||[]]}function h(t){switch(t.type){case"HANDLER":return A.get(t.name).deserialize(t.value);case"RAW":return t.value}}function g(t,e,r,l){return new Promise(n=>{const s=j();e.set(s,n),t.start&&t.start(),t.postMessage(Object.assign({id:s},r),l)})}function j(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}M({bindings:new Map,async bindCanvas(t,e,r="animated"){const l=e.getContext("2d");if(!l){console.error(`[CanvasWorker] Failed to get 2D context for panel ${t}`);return}console.log(`[CanvasWorker] Successfully bound canvas for panel ${t} with mode ${r}`),this.bindings.set(t,{ctx:l,canvas:e,panelId:t,mode:r}),this.startAnimation(t)},startAnimation(t){const e=this.bindings.get(t);if(e)switch(e.mode){case"static":this.drawStatic(e);break;case"animated":this.drawAnimated(e);break;case"dynamic":this.drawDynamic(e);break;default:console.warn(`[CanvasWorker] Unknown draw mode for panel ${t}`)}},drawStatic(t){t.ctx.fillStyle="gray",t.ctx.fillRect(0,0,t.canvas.width,t.canvas.height)},drawAnimated(t){let e=0;const r=()=>{e=(e+1)%360,t.ctx.fillStyle=`hsl(${e}, 100%, 50%)`,t.ctx.fillRect(0,0,t.canvas.width,t.canvas.height),t.animationFrame=requestAnimationFrame(r)};r()},drawDynamic(t){let e=0;const r=()=>{e+=.05,t.ctx.clearRect(0,0,t.canvas.width,t.canvas.height),t.ctx.beginPath(),t.ctx.arc(t.canvas.width/2+Math.sin(e)*50,t.canvas.height/2+Math.cos(e)*50,30,0,Math.PI*2),t.ctx.fillStyle="orange",t.ctx.fill(),t.animationFrame=requestAnimationFrame(r)};r()},async unbindCanvas(t){const e=this.bindings.get(t);e?.animationFrame&&cancelAnimationFrame(e.animationFrame),this.bindings.delete(t),console.log(`[CanvasWorker] Unbound canvas for panel ${t}`)}})})();
@@ -0,0 +1,14 @@
1
+ (function(){"use strict";/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */const Zn=Symbol("Comlink.proxy"),Zr=Symbol("Comlink.endpoint"),ei=Symbol("Comlink.releaseProxy"),an=Symbol("Comlink.finalizer"),_t=Symbol("Comlink.thrown"),er=s=>typeof s=="object"&&s!==null||typeof s=="function",ti={canHandle:s=>er(s)&&s[Zn],serialize(s){const{port1:_,port2:O}=new MessageChannel;return sn(s,_),[O,[O]]},deserialize(s){return s.start(),oi(s)}},ni={canHandle:s=>er(s)&&_t in s,serialize({value:s}){let _;return s instanceof Error?_={isError:!0,value:{message:s.message,name:s.name,stack:s.stack}}:_={isError:!1,value:s},[_,[]]},deserialize(s){throw s.isError?Object.assign(new Error(s.value.message),s.value):s.value}},tr=new Map([["proxy",ti],["throw",ni]]);function ri(s,_){for(const O of s)if(_===O||O==="*"||O instanceof RegExp&&O.test(_))return!0;return!1}function sn(s,_=globalThis,O=["*"]){_.addEventListener("message",function k(j){if(!j||!j.data)return;if(!ri(O,j.origin)){console.warn(`Invalid origin '${j.origin}' for comlink proxy`);return}const{id:N,type:F,path:B}=Object.assign({path:[]},j.data),V=(j.data.argumentList||[]).map(Ke);let Y;try{const Z=B.slice(0,-1).reduce((X,le)=>X[le],s),z=B.reduce((X,le)=>X[le],s);switch(F){case"GET":Y=z;break;case"SET":Z[B.slice(-1)[0]]=Ke(j.data.value),Y=!0;break;case"APPLY":Y=z.apply(Z,V);break;case"CONSTRUCT":{const X=new z(...V);Y=li(X)}break;case"ENDPOINT":{const{port1:X,port2:le}=new MessageChannel;sn(s,le),Y=ci(X,[X])}break;case"RELEASE":Y=void 0;break;default:return}}catch(Z){Y={value:Z,[_t]:0}}Promise.resolve(Y).catch(Z=>({value:Z,[_t]:0})).then(Z=>{const[z,X]=Et(Z);_.postMessage(Object.assign(Object.assign({},z),{id:N}),X),F==="RELEASE"&&(_.removeEventListener("message",k),nr(_),an in s&&typeof s[an]=="function"&&s[an]())}).catch(Z=>{const[z,X]=Et({value:new TypeError("Unserializable return value"),[_t]:0});_.postMessage(Object.assign(Object.assign({},z),{id:N}),X)})}),_.start&&_.start()}function ii(s){return s.constructor.name==="MessagePort"}function nr(s){ii(s)&&s.close()}function oi(s,_){const O=new Map;return s.addEventListener("message",function(j){const{data:N}=j;if(!N||!N.id)return;const F=O.get(N.id);if(F)try{F(N)}finally{O.delete(N.id)}}),un(s,O,[],_)}function xt(s){if(s)throw new Error("Proxy has been released and is not useable")}function rr(s){return $e(s,new Map,{type:"RELEASE"}).then(()=>{nr(s)})}const Ot=new WeakMap,kt="FinalizationRegistry"in globalThis&&new FinalizationRegistry(s=>{const _=(Ot.get(s)||0)-1;Ot.set(s,_),_===0&&rr(s)});function ai(s,_){const O=(Ot.get(_)||0)+1;Ot.set(_,O),kt&&kt.register(s,_,s)}function si(s){kt&&kt.unregister(s)}function un(s,_,O=[],k=function(){}){let j=!1;const N=new Proxy(k,{get(F,B){if(xt(j),B===ei)return()=>{si(N),rr(s),_.clear(),j=!0};if(B==="then"){if(O.length===0)return{then:()=>N};const V=$e(s,_,{type:"GET",path:O.map(Y=>Y.toString())}).then(Ke);return V.then.bind(V)}return un(s,_,[...O,B])},set(F,B,V){xt(j);const[Y,Z]=Et(V);return $e(s,_,{type:"SET",path:[...O,B].map(z=>z.toString()),value:Y},Z).then(Ke)},apply(F,B,V){xt(j);const Y=O[O.length-1];if(Y===Zr)return $e(s,_,{type:"ENDPOINT"}).then(Ke);if(Y==="bind")return un(s,_,O.slice(0,-1));const[Z,z]=ir(V);return $e(s,_,{type:"APPLY",path:O.map(X=>X.toString()),argumentList:Z},z).then(Ke)},construct(F,B){xt(j);const[V,Y]=ir(B);return $e(s,_,{type:"CONSTRUCT",path:O.map(Z=>Z.toString()),argumentList:V},Y).then(Ke)}});return ai(N,s),N}function ui(s){return Array.prototype.concat.apply([],s)}function ir(s){const _=s.map(Et);return[_.map(O=>O[0]),ui(_.map(O=>O[1]))]}const or=new WeakMap;function ci(s,_){return or.set(s,_),s}function li(s){return Object.assign(s,{[Zn]:!0})}function Et(s){for(const[_,O]of tr)if(O.canHandle(s)){const[k,j]=O.serialize(s);return[{type:"HANDLER",name:_,value:k},j]}return[{type:"RAW",value:s},or.get(s)||[]]}function Ke(s){switch(s.type){case"HANDLER":return tr.get(s.name).deserialize(s.value);case"RAW":return s.value}}function $e(s,_,O,k){return new Promise(j=>{const N=fi();_.set(N,j),s.start&&s.start(),s.postMessage(Object.assign({id:N},O),k)})}function fi(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var hi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function di(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Tt={exports:{}},pi=Tt.exports,ar;function yi(){return ar||(ar=1,function(s,_){(function(O,k){s.exports=k()})(pi,function(){var O=function(e,t){return(O=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])})(e,t)},k=function(){return(k=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function j(e,t,n){for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||((r=r||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var N=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:hi,F=Object.keys,B=Array.isArray;function V(e,t){return typeof t!="object"||F(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||N.Promise||(N.Promise=Promise);var Y=Object.getPrototypeOf,Z={}.hasOwnProperty;function z(e,t){return Z.call(e,t)}function X(e,t){typeof t=="function"&&(t=t(Y(e))),(typeof Reflect>"u"?F:Reflect.ownKeys)(t).forEach(function(n){ve(e,n,t[n])})}var le=Object.defineProperty;function ve(e,t,n,r){le(e,t,V(n&&z(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function Ye(e){return{from:function(t){return e.prototype=Object.create(t.prototype),ve(e.prototype,"constructor",e),{extend:X.bind(null,e.prototype)}}}}var Ci=Object.getOwnPropertyDescriptor,Ai=[].slice;function At(e,t,n){return Ai.call(e,t,n)}function dr(e,t){return t(e)}function ot(e){if(!e)throw new Error("Assertion Failed")}function pr(e){N.setImmediate?setImmediate(e):setTimeout(e,0)}function xe(e,t){if(typeof t=="string"&&z(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 o=xe(e,t[r]);n.push(o)}return n}var a=t.indexOf(".");if(a!==-1){var u=e[t.substr(0,a)];return u==null?void 0:xe(u,t.substr(a+1))}}function fe(e,t,n){if(e&&t!==void 0&&!("isFrozen"in Object&&Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){ot(typeof n!="string"&&"length"in n);for(var r=0,i=t.length;r<i;++r)fe(e,t[r],n[r])}else{var o,a,u=t.indexOf(".");u!==-1?(o=t.substr(0,u),(a=t.substr(u+1))===""?n===void 0?B(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n:fe(u=!(u=e[o])||!z(e,o)?e[o]={}:u,a,n)):n===void 0?B(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function yr(e){var t,n={};for(t in e)z(e,t)&&(n[t]=e[t]);return n}var Si=[].concat;function mr(e){return Si.apply([],e)}var Be="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(mr([8,16,32,64].map(function(e){return["Int","Uint","Float"].map(function(t){return t+e+"Array"})}))).filter(function(e){return N[e]}),vr=new Set(Be.map(function(e){return N[e]})),at=null;function Ne(e){return at=new WeakMap,e=function t(n){if(!n||typeof n!="object")return n;var r=at.get(n);if(r)return r;if(B(n)){r=[],at.set(n,r);for(var i=0,o=n.length;i<o;++i)r.push(t(n[i]))}else if(vr.has(n.constructor))r=n;else{var a,u=Y(n);for(a in r=u===Object.prototype?{}:Object.create(u),at.set(n,r),n)z(n,a)&&(r[a]=t(n[a]))}return r}(e),at=null,e}var Ri={}.toString;function dn(e){return Ri.call(e).slice(8,-1)}var pn=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Ki=typeof pn=="symbol"?function(e){var t;return e!=null&&(t=e[pn])&&t.apply(e)}:function(){return null};function De(e,t){return t=e.indexOf(t),0<=t&&e.splice(t,1),0<=t}var Ge={};function Oe(e){var t,n,r,i;if(arguments.length===1){if(B(e))return e.slice();if(this===Ge&&typeof e=="string")return[e];if(i=Ki(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(e==null)return[e];if(typeof(t=e.length)!="number")return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var yn=typeof Symbol<"u"?function(e){return e[Symbol.toStringTag]==="AsyncFunction"}:function(){return!1},ct=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],me=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(ct),Ni={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 Qe(e,t){this.name=e,this.message=t}function gr(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(`
6
+ `)}function St(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=gr(e,t)}function Xe(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(n){return t[n]}),this.failuresByPos=t,this.message=gr(e,this.failures)}Ye(Qe).from(Error).extend({toString:function(){return this.name+": "+this.message}}),Ye(St).from(Qe),Ye(Xe).from(Qe);var mn=me.reduce(function(e,t){return e[t]=t+"Error",e},{}),Di=Qe,D=me.reduce(function(e,t){var n=t+"Error";function r(i,o){this.name=n,i?typeof i=="string"?(this.message="".concat(i).concat(o?`
7
+ `+o:""),this.inner=o||null):typeof i=="object"&&(this.message="".concat(i.name," ").concat(i.message),this.inner=i):(this.message=Ni[t]||n,this.inner=null)}return Ye(r).from(Di),e[t]=r,e},{});D.Syntax=SyntaxError,D.Type=TypeError,D.Range=RangeError;var br=ct.reduce(function(e,t){return e[t+"Error"]=D[t],e},{}),Rt=me.reduce(function(e,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=D[t]),e},{});function G(){}function st(e){return e}function ji(e,t){return e==null||e===st?t:function(n){return t(e(n))}}function je(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function Bi(e,t){return e===G?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 o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?je(r,this.onsuccess):r),i&&(this.onerror=this.onerror?je(i,this.onerror):i),o!==void 0?o:n}}function Fi(e,t){return e===G?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?je(n,this.onsuccess):n),r&&(this.onerror=this.onerror?je(r,this.onerror):r)}}function qi(e,t){return e===G?t:function(n){var r=e.apply(this,arguments);V(n,r);var i=this.onsuccess,o=this.onerror;return this.onsuccess=null,this.onerror=null,n=t.apply(this,arguments),i&&(this.onsuccess=this.onsuccess?je(i,this.onsuccess):i),o&&(this.onerror=this.onerror?je(o,this.onerror):o),r===void 0?n===void 0?void 0:n:V(r,n)}}function Mi(e,t){return e===G?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function vn(e,t){return e===G?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return n.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}Rt.ModifyError=St,Rt.DexieError=Qe,Rt.BulkError=Xe;var ge=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function wr(e){ge=e}var ut={},_r=100,Be=typeof Promise>"u"?[]:function(){var e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,Y(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,Y(t),e]}(),ct=Be[0],me=Be[1],Be=Be[2],me=me&&me.then,Fe=ct&&ct.constructor,gn=!!Be,lt=function(e,t){ft.push([e,t]),Kt&&(queueMicrotask(Ui),Kt=!1)},bn=!0,Kt=!0,qe=[],Nt=[],wn=st,Te={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:G,pgp:!1,env:{},finalize:G},K=Te,ft=[],Me=0,Dt=[];function S(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=K;if(typeof e!="function"){if(e!==ut)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&xn(this,this._value))}this._state=null,this._value=null,++t.ref,function n(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&&Je();o&&typeof o.then=="function"?n(r,function(u,l){o instanceof S?o._then(u,l):o.then(u,l)}):(r._state=!0,r._value=o,Or(r)),a&&Ze()}},xn.bind(null,r))}catch(o){xn(r,o)}}(this,e)}var _n={get:function(){var e=K,t=qt;function n(r,i){var o=this,a=!e.global&&(e!==K||t!==qt),u=a&&!Pe(),l=new S(function(h,y){On(o,new xr(Er(r,e,a,u),Er(i,e,a,u),h,y,e))});return this._consoleTask&&(l._consoleTask=this._consoleTask),l}return n.prototype=ut,n},set:function(e){ve(this,"then",e&&e.prototype===ut?_n:{get:function(){return e},set:_n.set})}};function xr(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}function xn(e,t){var n,r;Nt.push(t),e._state===null&&(n=e._lib&&Je(),t=wn(t),e._state=!1,e._value=t,r=e,qe.some(function(i){return i._value===r._value})||qe.push(r),Or(e),n&&Ze())}function Or(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(),Me===0&&(++Me,lt(function(){--Me==0&&kn()},[]))}function On(e,t){if(e._state!==null){var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++Me,lt(Li,[n,e,t])}else e._listeners.push(t)}function Li(e,t,n){try{var r,i=t._value;!t._state&&Nt.length&&(Nt=[]),r=ge&&t._consoleTask?t._consoleTask.run(function(){return e(i)}):e(i),t._state||Nt.indexOf(i)!==-1||function(o){for(var a=qe.length;a;)if(qe[--a]._value===o._value)return qe.splice(a,1)}(t),n.resolve(r)}catch(o){n.reject(o)}finally{--Me==0&&kn(),--n.psd.ref||n.psd.finalize()}}function Ui(){Le(Te,function(){Je()&&Ze()})}function Je(){var e=bn;return Kt=bn=!1,e}function Ze(){var e,t,n;do for(;0<ft.length;)for(e=ft,ft=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(0<ft.length);Kt=bn=!0}function kn(){var e=qe;qe=[],e.forEach(function(r){r._PSD.onunhandled.call(null,r._value,r)});for(var t=Dt.slice(0),n=t.length;n;)t[--n]()}function jt(e){return new S(ut,!1,e)}function ee(e,t){var n=K;return function(){var r=Je(),i=K;try{return Ce(n,!0),e.apply(this,arguments)}catch(o){t&&t(o)}finally{Ce(i,!1),r&&Ze()}}}X(S.prototype,{then:_n,_then:function(e,t){On(this,new xr(null,null,e,t,K))},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=e,n=arguments[1];return typeof t=="function"?this.then(null,function(r){return(r instanceof t?n:jt)(r)}):this.then(null,function(r){return(r&&r.name===t?n:jt)(r)})},finally:function(e){return this.then(function(t){return S.resolve(e()).then(function(){return t})},function(t){return S.resolve(e()).then(function(){return jt(t)})})},timeout:function(e,t){var n=this;return e<1/0?new S(function(r,i){var o=setTimeout(function(){return i(new D.Timeout(t))},e);n.then(r,i).finally(clearTimeout.bind(null,o))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&ve(S.prototype,Symbol.toStringTag,"Dexie.Promise"),Te.env=kr(),X(S,{all:function(){var e=Oe.apply(null,arguments).map(Mt);return new S(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach(function(i,o){return S.resolve(i).then(function(a){e[o]=a,--r||t(e)},n)})})},resolve:function(e){return e instanceof S?e:e&&typeof e.then=="function"?new S(function(t,n){e.then(t,n)}):new S(ut,!0,e)},reject:jt,race:function(){var e=Oe.apply(null,arguments).map(Mt);return new S(function(t,n){e.map(function(r){return S.resolve(r).then(t,n)})})},PSD:{get:function(){return K},set:function(e){return K=e}},totalEchoes:{get:function(){return qt}},newPSD:Ie,usePSD:Le,scheduler:{get:function(){return lt},set:function(e){lt=e}},rejectionMapper:{get:function(){return wn},set:function(e){wn=e}},follow:function(e,t){return new S(function(n,r){return Ie(function(i,o){var a=K;a.unhandleds=[],a.onunhandled=o,a.finalize=je(function(){var u,l=this;u=function(){l.unhandleds.length===0?i():o(l.unhandleds[0])},Dt.push(function h(){u(),Dt.splice(Dt.indexOf(h),1)}),++Me,lt(function(){--Me==0&&kn()},[])},a.finalize),e()},t,n,r)})}}),Fe&&(Fe.allSettled&&ve(S,"allSettled",function(){var e=Oe.apply(null,arguments).map(Mt);return new S(function(t){e.length===0&&t([]);var n=e.length,r=new Array(n);e.forEach(function(i,o){return S.resolve(i).then(function(a){return r[o]={status:"fulfilled",value:a}},function(a){return r[o]={status:"rejected",reason:a}}).then(function(){return--n||t(r)})})})}),Fe.any&&typeof AggregateError<"u"&&ve(S,"any",function(){var e=Oe.apply(null,arguments).map(Mt);return new S(function(t,n){e.length===0&&n(new AggregateError([]));var r=e.length,i=new Array(r);e.forEach(function(o,a){return S.resolve(o).then(function(u){return t(u)},function(u){i[a]=u,--r||n(new AggregateError(i))})})})}),Fe.withResolvers&&(S.withResolvers=Fe.withResolvers));var re={awaits:0,echoes:0,id:0},Wi=0,Bt=[],Ft=0,qt=0,Vi=0;function Ie(e,t,n,r){var i=K,o=Object.create(i);return o.parent=i,o.ref=0,o.global=!1,o.id=++Vi,Te.env,o.env=gn?{Promise:S,PromiseProp:{value:S,configurable:!0,writable:!0},all:S.all,race:S.race,allSettled:S.allSettled,any:S.any,resolve:S.resolve,reject:S.reject}:{},t&&V(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()},r=Le(o,e,n,r),o.ref===0&&o.finalize(),r}function et(){return re.id||(re.id=++Wi),++re.awaits,re.echoes+=_r,re.id}function Pe(){return!!re.awaits&&(--re.awaits==0&&(re.id=0),re.echoes=re.awaits*_r,!0)}function Mt(e){return re.echoes&&e&&e.constructor===Fe?(et(),e.then(function(t){return Pe(),t},function(t){return Pe(),te(t)})):e}function Hi(){var e=Bt[Bt.length-1];Bt.pop(),Ce(e,!1)}function Ce(e,t){var n,r=K;(t?!re.echoes||Ft++&&e===K:!Ft||--Ft&&e===K)||queueMicrotask(t?function(i){++qt,re.echoes&&--re.echoes!=0||(re.echoes=re.awaits=re.id=0),Bt.push(K),Ce(i,!0)}.bind(null,e):Hi),e!==K&&(K=e,r===Te&&(Te.env=kr()),gn&&(n=Te.env.Promise,t=e.env,(r.global||e.global)&&(Object.defineProperty(N,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function kr(){var e=N.Promise;return gn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(N,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function Le(e,t,n,r,i){var o=K;try{return Ce(e,!0),t(n,r,i)}finally{Ce(o,!1)}}function Er(e,t,n,r){return typeof e!="function"?e:function(){var i=K;n&&et(),Ce(t,!0);try{return e.apply(this,arguments)}finally{Ce(i,!1),r&&queueMicrotask(Pe)}}}function En(e){Promise===Fe&&re.echoes===0?Ft===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(""+me).indexOf("[native code]")===-1&&(et=Pe=G);var te=S.reject,Ue="￿",ke="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Tr="String expected.",tt=[],Lt="__dbnames",Tn="readonly",In="readwrite";function We(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Ir={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ut(e){return typeof e!="string"||/\./.test(e)?function(t){return t}:function(t){return t[e]===void 0&&e in t&&delete(t=Ne(t))[e],t}}function Pr(){throw D.Type()}function H(e,t){try{var n=Cr(e),r=Cr(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 t<e?1:e<t?-1:0;case"binary":return function(i,o){for(var a=i.length,u=o.length,l=a<u?a:u,h=0;h<l;++h)if(i[h]!==o[h])return i[h]<o[h]?-1:1;return a===u?0:a<u?-1:1}(Ar(e),Ar(t));case"Array":return function(i,o){for(var a=i.length,u=o.length,l=a<u?a:u,h=0;h<l;++h){var y=H(i[h],o[h]);if(y!==0)return y}return a===u?0:a<u?-1:1}(e,t)}}catch{}return NaN}function Cr(e){var t=typeof e;return t!="object"?t:ArrayBuffer.isView(e)?"binary":(e=dn(e),e==="ArrayBuffer"?"binary":e)}function Ar(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Sr=(J.prototype._trans=function(e,t,n){var r=this._tx||K.trans,i=this.name,o=ge&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(e==="readonly"?"read":"write"," ").concat(this.name));function a(h,y,c){if(!c.schema[i])throw new D.NotFound("Table "+i+" not part of transaction");return t(c.idbtrans,c)}var u=Je();try{var l=r&&r.db._novip===this.db._novip?r===K.trans?r._promise(e,a,n):Ie(function(){return r._promise(e,a,n)},{trans:r,transless:K.transless||K}):function h(y,c,v,f){if(y.idbdb&&(y._state.openComplete||K.letThrough||y._vip)){var p=y._createTransaction(c,v,y._dbSchema);try{p.create(),y._state.PR1398_maxLoop=3}catch(m){return m.name===mn.InvalidState&&y.isOpen()&&0<--y._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),y.close({disableAutoOpen:!1}),y.open().then(function(){return h(y,c,v,f)})):te(m)}return p._promise(c,function(m,d){return Ie(function(){return K.trans=p,f(m,d,p)})}).then(function(m){if(c==="readwrite")try{p.idbtrans.commit()}catch{}return c==="readonly"?m:p._completion.then(function(){return m})})}if(y._state.openComplete)return te(new D.DatabaseClosed(y._state.dbOpenError));if(!y._state.isBeingOpened){if(!y._state.autoOpen)return te(new D.DatabaseClosed);y.open().catch(G)}return y._state.dbReadyPromise.then(function(){return h(y,c,v,f)})}(this.db,e,[this.name],a);return o&&(l._consoleTask=o,l=l.catch(function(h){return console.trace(h),te(h)})),l}finally{u&&Ze()}},J.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):e==null?te(new D.Type("Invalid argument to Table.get()")):this._trans("readonly",function(r){return n.core.get({trans:r,key:e}).then(function(i){return n.hook.reading.fire(i)})}).then(t)},J.prototype.where=function(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(B(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=F(e);if(t.length===1)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(u){if(u.compound&&t.every(function(h){return 0<=u.keyPath.indexOf(h)})){for(var l=0;l<t.length;++l)if(t.indexOf(u.keyPath[l])===-1)return!1;return!0}return!1}).sort(function(u,l){return u.keyPath.length-l.keyPath.length})[0];if(n&&this.db._maxKey!==Ue){var o=n.keyPath.slice(0,t.length);return this.where(o).equals(o.map(function(l){return e[l]}))}!n&&ge&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(t.join("+"),"]"));var r=this.schema.idxByName;function i(u,l){return H(u,l)===0}var a=t.reduce(function(c,l){var h=c[0],y=c[1],c=r[l],v=e[l];return[h||c,h||!c?We(y,c&&c.multi?function(f){return f=xe(f,l),B(f)&&f.some(function(p){return i(v,p)})}:function(f){return i(v,xe(f,l))}):y]},[null,null]),o=a[0],a=a[1];return o?this.where(o.name).equals(e[o.keyPath]).filter(a):n?this.filter(a):this.where(t).equals("")},J.prototype.filter=function(e){return this.toCollection().and(e)},J.prototype.count=function(e){return this.toCollection().count(e)},J.prototype.offset=function(e){return this.toCollection().offset(e)},J.prototype.limit=function(e){return this.toCollection().limit(e)},J.prototype.each=function(e){return this.toCollection().each(e)},J.prototype.toArray=function(e){return this.toCollection().toArray(e)},J.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},J.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,B(e)?"[".concat(e.join("+"),"]"):e))},J.prototype.reverse=function(){return this.toCollection().reverse()},J.prototype.mapToClass=function(e){var t,n=this.db,r=this.name;function i(){return t!==null&&t.apply(this,arguments)||this}(this.schema.mappedClass=e).prototype instanceof Pr&&(function(l,h){if(typeof h!="function"&&h!==null)throw new TypeError("Class extends value "+String(h)+" is not a constructor or null");function y(){this.constructor=l}O(l,h),l.prototype=h===null?Object.create(h):(y.prototype=h.prototype,new y)}(i,t=e),Object.defineProperty(i.prototype,"db",{get:function(){return n},enumerable:!1,configurable:!0}),i.prototype.table=function(){return r},e=i);for(var o=new Set,a=e.prototype;a;a=Y(a))Object.getOwnPropertyNames(a).forEach(function(l){return o.add(l)});function u(l){if(!l)return l;var h,y=Object.create(e.prototype);for(h in l)if(!o.has(h))try{y[h]=l[h]}catch{}return y}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=u,this.hook("reading",u),e},J.prototype.defineClass=function(){return this.mapToClass(function(e){V(this,e)})},J.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,a=e;return o&&i&&(a=Ut(o)(e)),this._trans("readwrite",function(u){return n.core.mutate({trans:u,type:"add",keys:t!=null?[t]:null,values:[a]})}).then(function(u){return u.numFailures?S.reject(u.failures[0]):u.lastResult}).then(function(u){if(o)try{fe(e,o,u)}catch{}return u})},J.prototype.update=function(e,t){return typeof e!="object"||B(e)?this.where(":id").equals(e).modify(t):(e=xe(e,this.schema.primKey.keyPath),e===void 0?te(new D.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t))},J.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,a=e;return o&&i&&(a=Ut(o)(e)),this._trans("readwrite",function(u){return n.core.mutate({trans:u,type:"put",values:[a],keys:t!=null?[t]:null})}).then(function(u){return u.numFailures?S.reject(u.failures[0]):u.lastResult}).then(function(u){if(o)try{fe(e,o,u)}catch{}return u})},J.prototype.delete=function(e){var t=this;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"delete",keys:[e]})}).then(function(n){return n.numFailures?S.reject(n.failures[0]):void 0})},J.prototype.clear=function(){var e=this;return this._trans("readwrite",function(t){return e.core.mutate({trans:t,type:"deleteRange",range:Ir})}).then(function(t){return t.numFailures?S.reject(t.failures[0]):void 0})},J.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",function(n){return t.core.getMany({keys:e,trans:n}).then(function(r){return r.map(function(i){return t.hook.reading.fire(i)})})})},J.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(a){var h=r.schema.primKey,u=h.auto,h=h.keyPath;if(h&&i)throw new D.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new D.InvalidArgument("Arguments objects and keys must have the same length");var l=e.length,h=h&&u?e.map(Ut(h)):e;return r.core.mutate({trans:a,type:"add",keys:i,values:h,wantResults:o}).then(function(p){var c=p.numFailures,v=p.results,f=p.lastResult,p=p.failures;if(c===0)return o?v:f;throw new Xe("".concat(r.name,".bulkAdd(): ").concat(c," of ").concat(l," operations failed"),p)})})},J.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(a){var h=r.schema.primKey,u=h.auto,h=h.keyPath;if(h&&i)throw new D.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new D.InvalidArgument("Arguments objects and keys must have the same length");var l=e.length,h=h&&u?e.map(Ut(h)):e;return r.core.mutate({trans:a,type:"put",keys:i,values:h,wantResults:o}).then(function(p){var c=p.numFailures,v=p.results,f=p.lastResult,p=p.failures;if(c===0)return o?v:f;throw new Xe("".concat(r.name,".bulkPut(): ").concat(c," of ").concat(l," operations failed"),p)})})},J.prototype.bulkUpdate=function(e){var t=this,n=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 n.getMany({trans:a,keys:r,cache:"clone"}).then(function(u){var l=[],h=[];e.forEach(function(c,v){var f=c.key,p=c.changes,m=u[v];if(m){for(var d=0,g=Object.keys(p);d<g.length;d++){var b=g[d],w=p[b];if(b===t.schema.primKey.keyPath){if(H(w,f)!==0)throw new D.Constraint("Cannot update primary key in bulkUpdate()")}else fe(m,b,w)}o.push(v),l.push(f),h.push(m)}});var y=l.length;return n.mutate({trans:a,type:"put",keys:l,values:h,updates:{keys:r,changeSpecs:i}}).then(function(c){var v=c.numFailures,f=c.failures;if(v===0)return y;for(var p=0,m=Object.keys(f);p<m.length;p++){var d,g=m[p],b=o[Number(g)];b!=null&&(d=f[g],delete f[g],f[b]=d)}throw new Xe("".concat(t.name,".bulkUpdate(): ").concat(v," of ").concat(y," operations failed"),f)})})})},J.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",function(r){return t.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 Xe("".concat(t.name,".bulkDelete(): ").concat(i," of ").concat(n," operations failed"),a)})},J);function J(){}function ht(e){function t(a,u){if(u){for(var l=arguments.length,h=new Array(l-1);--l;)h[l-1]=arguments[l];return n[a].subscribe.apply(null,h),e}if(typeof a=="string")return n[a]}var n={};t.addEventType=o;for(var r=1,i=arguments.length;r<i;++r)o(arguments[r]);return t;function o(a,u,l){if(typeof a!="object"){var h;u=u||Mi;var y={subscribers:[],fire:l=l||G,subscribe:function(c){y.subscribers.indexOf(c)===-1&&(y.subscribers.push(c),y.fire=u(y.fire,c))},unsubscribe:function(c){y.subscribers=y.subscribers.filter(function(v){return v!==c}),y.fire=y.subscribers.reduce(u,l)}};return n[a]=t[a]=y}F(h=a).forEach(function(c){var v=h[c];if(B(v))o(c,h[c][0],h[c][1]);else{if(v!=="asap")throw new D.InvalidArgument("Invalid event config");var f=o(c,st,function(){for(var p=arguments.length,m=new Array(p);p--;)m[p]=arguments[p];f.subscribers.forEach(function(d){pr(function(){d.apply(null,m)})})})}})}}function dt(e,t){return Ye(t).from({prototype:e}),t}function nt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Pn(e,t){e.filter=We(e.filter,t)}function Cn(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return We(r(),t())}:t,e.justLimit=n&&!r}function Wt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new D.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Rr(e,t,n){var r=Wt(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 Vt(e,t,n,r){var i=e.replayFilter?We(e.filter,e.replayFilter()):e.filter;if(e.or){var o={},a=function(u,l,h){var y,c;i&&!i(l,h,function(v){return l.stop(v)},function(v){return l.fail(v)})||((c=""+(y=l.primaryKey))=="[object ArrayBuffer]"&&(c=""+new Uint8Array(y)),z(o,c)||(o[c]=!0,t(u,l,h)))};return Promise.all([e.or._iterate(a,n),Kr(Rr(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return Kr(Rr(e,r,n),We(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function Kr(e,t,n,r){var i=ee(r?function(o,a,u){return n(r(o),a,u)}:n);return e.then(function(o){if(o)return o.start(function(){var a=function(){return o.continue()};t&&!t(o,function(u){return a=u},function(u){o.stop(u),a=G},function(u){o.fail(u),a=G})||i(o.value,o,function(u){return a=u}),a()})})}var pt=(Nr.prototype.execute=function(e){var t=this["@@propmod"];if(t.add!==void 0){var n=t.add;if(B(n))return j(j([],B(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(t.remove!==void 0){var r=t.remove;if(B(r))return B(e)?e.filter(function(i){return!r.includes(i)}).sort():[];if(typeof r=="number")return Number(e)-r;if(typeof r=="bigint")try{return BigInt(e)-r}catch{return BigInt(0)-r}throw new TypeError("Invalid subtrahend ".concat(r))}return n=(n=t.replacePrefix)===null||n===void 0?void 0:n[0],n&&typeof e=="string"&&e.startsWith(n)?t.replacePrefix[1]+e.substring(n.length):e},Nr);function Nr(e){this["@@propmod"]=e}var zi=($.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,te.bind(null,n.error)):n.table._trans("readonly",e).then(t)},$.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,te.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},$.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=We(t.algorithm,e)},$.prototype._iterate=function(e,t){return Vt(this._ctx,e,t,this._ctx.table.core)},$.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&V(n,e),t._ctx=n,t},$.prototype.raw=function(){return this._ctx.valueMapper=null,this},$.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return Vt(t,e,n,t.table.core)})},$.prototype.count=function(e){var t=this;return this._read(function(n){var r=t._ctx,i=r.table.core;if(nt(r,!0))return i.count({trans:n,query:{index:Wt(r,i.schema),range:r.range}}).then(function(a){return Math.min(a,r.limit)});var o=0;return Vt(r,function(){return++o,!1},n,i).then(function(){return o})}).then(e)},$.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],i=n.length-1;function o(l,h){return h?o(l[n[h]],h-1):l[r]}var a=this._ctx.dir==="next"?1:-1;function u(l,h){return H(o(l,i),o(h,i))*a}return this.toArray(function(l){return l.sort(u)}).then(t)},$.prototype.toArray=function(e){var t=this;return this._read(function(n){var r=t._ctx;if(r.dir==="next"&&nt(r,!0)&&0<r.limit){var i=r.valueMapper,o=Wt(r,r.table.core.schema);return r.table.core.query({trans:n,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 Vt(r,function(u){return a.push(u)},n,r.table.core).then(function(){return a})},e)},$.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,nt(t)?Cn(t,function(){var n=e;return function(r,i){return n===0||(n===1?--n:i(function(){r.advance(n),n=0}),!1)}}):Cn(t,function(){var n=e;return function(){return--n<0}})),this},$.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Cn(this._ctx,function(){var t=e;return function(n,r,i){return--t<=0&&r(i),0<=t}},!0),this},$.prototype.until=function(e,t){return Pn(this._ctx,function(n,r,i){return!e(n.value)||(r(i),t)}),this},$.prototype.first=function(e){return this.limit(1).toArray(function(t){return t[0]}).then(e)},$.prototype.last=function(e){return this.reverse().first(e)},$.prototype.filter=function(e){var t;return Pn(this._ctx,function(n){return e(n.value)}),(t=this._ctx).isMatch=We(t.isMatch,e),this},$.prototype.and=function(e){return this.filter(e)},$.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},$.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},$.prototype.desc=function(){return this.reverse()},$.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,r){e(r.key,r)})},$.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},$.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,r){e(r.primaryKey,r)})},$.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(r,i){n.push(i.key)}).then(function(){return n}).then(e)},$.prototype.primaryKeys=function(e){var t=this._ctx;if(t.dir==="next"&&nt(t,!0)&&0<t.limit)return this._read(function(r){var i=Wt(t,t.table.core.schema);return t.table.core.query({trans:r,values:!1,limit:t.limit,query:{index:i,range:t.range}})}).then(function(r){return r.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(r,i){n.push(i.primaryKey)}).then(function(){return n}).then(e)},$.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},$.prototype.firstKey=function(e){return this.limit(1).keys(function(t){return t[0]}).then(e)},$.prototype.lastKey=function(e){return this.reverse().firstKey(e)},$.prototype.distinct=function(){var e=this._ctx,e=e.index&&e.table.schema.idxByName[e.index];if(!e||!e.multi)return this;var t={};return Pn(this._ctx,function(i){var r=i.primaryKey.toString(),i=z(t,r);return t[r]=!0,!i}),this},$.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(r){var i,o,a;a=typeof e=="function"?e:(i=F(e),o=i.length,function(d){for(var g=!1,b=0;b<o;++b){var w=i[b],x=e[w],E=xe(d,w);x instanceof pt?(fe(d,w,x.execute(E)),g=!0):E!==x&&(fe(d,w,x),g=!0)}return g});var u=n.table.core,c=u.schema.primaryKey,l=c.outbound,h=c.extractKey,y=200,c=t.db._options.modifyChunkSize;c&&(y=typeof c=="object"?c[u.name]||c["*"]||200:c);function v(d,w){var b=w.failures,w=w.numFailures;p+=d-w;for(var x=0,E=F(b);x<E.length;x++){var C=E[x];f.push(b[C])}}var f=[],p=0,m=[];return t.clone().primaryKeys().then(function(d){function g(w){var x=Math.min(y,d.length-w);return u.getMany({trans:r,keys:d.slice(w,w+x),cache:"immutable"}).then(function(E){for(var C=[],T=[],I=l?[]:null,A=[],P=0;P<x;++P){var R=E[P],M={value:Ne(R),primKey:d[w+P]};a.call(M,M.value,M)!==!1&&(M.value==null?A.push(d[w+P]):l||H(h(R),h(M.value))===0?(T.push(M.value),l&&I.push(d[w+P])):(A.push(d[w+P]),C.push(M.value)))}return Promise.resolve(0<C.length&&u.mutate({trans:r,type:"add",values:C}).then(function(L){for(var U in L.failures)A.splice(parseInt(U),1);v(C.length,L)})).then(function(){return(0<T.length||b&&typeof e=="object")&&u.mutate({trans:r,type:"put",keys:I,values:T,criteria:b,changeSpec:typeof e!="function"&&e,isAdditionalChunk:0<w}).then(function(L){return v(T.length,L)})}).then(function(){return(0<A.length||b&&e===An)&&u.mutate({trans:r,type:"delete",keys:A,criteria:b,isAdditionalChunk:0<w}).then(function(L){return v(A.length,L)})}).then(function(){return d.length>w+x&&g(w+y)})})}var b=nt(n)&&n.limit===1/0&&(typeof e!="function"||e===An)&&{index:n.index,range:n.range};return g(0).then(function(){if(0<f.length)throw new St("Error modifying one or more objects",f,p,m);return d.length})})})},$.prototype.delete=function(){var e=this._ctx,t=e.range;return nt(e)&&(e.isPrimKey||t.type===3)?this._write(function(n){var r=e.table.core.schema.primaryKey,i=t;return e.table.core.count({trans:n,query:{index:r,range:i}}).then(function(o){return e.table.core.mutate({trans:n,type:"deleteRange",range:i}).then(function(a){var u=a.failures;if(a.lastResult,a.results,a=a.numFailures,a)throw new St("Could not delete some values",Object.keys(u).map(function(l){return u[l]}),o-a);return o-a})})}):this.modify(An)},$);function $(){}var An=function(e,t){return t.value=null};function $i(e,t){return e<t?-1:e===t?0:1}function Yi(e,t){return t<e?-1:e===t?0:1}function he(e,t,n){return e=e instanceof jr?new e.Collection(e):e,e._ctx.error=new(n||TypeError)(t),e}function rt(e){return new e.Collection(e,function(){return Dr("")}).limit(0)}function Ht(e,t,n,r){var i,o,a,u,l,h,y,c=n.length;if(!n.every(function(p){return typeof p=="string"}))return he(e,Tr);function v(p){i=p==="next"?function(d){return d.toUpperCase()}:function(d){return d.toLowerCase()},o=p==="next"?function(d){return d.toLowerCase()}:function(d){return d.toUpperCase()},a=p==="next"?$i:Yi;var m=n.map(function(d){return{lower:o(d),upper:i(d)}}).sort(function(d,g){return a(d.lower,g.lower)});u=m.map(function(d){return d.upper}),l=m.map(function(d){return d.lower}),y=(h=p)==="next"?"":r}v("next"),e=new e.Collection(e,function(){return Ae(u[0],l[c-1]+r)}),e._ondirectionchange=function(p){v(p)};var f=0;return e._addAlgorithm(function(p,m,d){var g=p.key;if(typeof g!="string")return!1;var b=o(g);if(t(b,l,f))return!0;for(var w=null,x=f;x<c;++x){var E=function(C,T,I,A,P,R){for(var M=Math.min(C.length,A.length),L=-1,U=0;U<M;++U){var de=T[U];if(de!==A[U])return P(C[U],I[U])<0?C.substr(0,U)+I[U]+I.substr(U+1):P(C[U],A[U])<0?C.substr(0,U)+A[U]+I.substr(U+1):0<=L?C.substr(0,L)+T[L]+I.substr(L+1):null;P(C[U],de)<0&&(L=U)}return M<A.length&&R==="next"?C+I.substr(C.length):M<C.length&&R==="prev"?C.substr(0,I.length):L<0?null:C.substr(0,L)+A[L]+I.substr(L+1)}(g,b,u[x],l[x],a,h);E===null&&w===null?f=x+1:(w===null||0<a(w,E))&&(w=E)}return m(w!==null?function(){p.continue(w+y)}:d),!1}),e}function Ae(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 jr=(Object.defineProperty(ie.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),ie.prototype.between=function(e,t,n,r){n=n!==!1,r=r===!0;try{return 0<this._cmp(e,t)||this._cmp(e,t)===0&&(n||r)&&(!n||!r)?rt(this):new this.Collection(this,function(){return Ae(e,t,!n,!r)})}catch{return he(this,ke)}},ie.prototype.equals=function(e){return e==null?he(this,ke):new this.Collection(this,function(){return Dr(e)})},ie.prototype.above=function(e){return e==null?he(this,ke):new this.Collection(this,function(){return Ae(e,void 0,!0)})},ie.prototype.aboveOrEqual=function(e){return e==null?he(this,ke):new this.Collection(this,function(){return Ae(e,void 0,!1)})},ie.prototype.below=function(e){return e==null?he(this,ke):new this.Collection(this,function(){return Ae(void 0,e,!1,!0)})},ie.prototype.belowOrEqual=function(e){return e==null?he(this,ke):new this.Collection(this,function(){return Ae(void 0,e)})},ie.prototype.startsWith=function(e){return typeof e!="string"?he(this,Tr):this.between(e,e+Ue,!0,!0)},ie.prototype.startsWithIgnoreCase=function(e){return e===""?this.startsWith(e):Ht(this,function(t,n){return t.indexOf(n[0])===0},[e],Ue)},ie.prototype.equalsIgnoreCase=function(e){return Ht(this,function(t,n){return t===n[0]},[e],"")},ie.prototype.anyOfIgnoreCase=function(){var e=Oe.apply(Ge,arguments);return e.length===0?rt(this):Ht(this,function(t,n){return n.indexOf(t)!==-1},e,"")},ie.prototype.startsWithAnyOfIgnoreCase=function(){var e=Oe.apply(Ge,arguments);return e.length===0?rt(this):Ht(this,function(t,n){return n.some(function(r){return t.indexOf(r)===0})},e,Ue)},ie.prototype.anyOf=function(){var e=this,t=Oe.apply(Ge,arguments),n=this._cmp;try{t.sort(n)}catch{return he(this,ke)}if(t.length===0)return rt(this);var r=new this.Collection(this,function(){return Ae(t[0],t[t.length-1])});r._ondirectionchange=function(o){n=o==="next"?e._ascending:e._descending,t.sort(n)};var i=0;return r._addAlgorithm(function(o,a,u){for(var l=o.key;0<n(l,t[i]);)if(++i===t.length)return a(u),!1;return n(l,t[i])===0||(a(function(){o.continue(t[i])}),!1)}),r},ie.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},ie.prototype.noneOf=function(){var e=Oe.apply(Ge,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return he(this,ke)}var t=e.reduce(function(n,r){return n?n.concat([[n[n.length-1][1],r]]):[[-1/0,r]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},ie.prototype.inAnyRange=function(g,t){var n=this,r=this._cmp,i=this._ascending,o=this._descending,a=this._min,u=this._max;if(g.length===0)return rt(this);if(!g.every(function(b){return b[0]!==void 0&&b[1]!==void 0&&i(b[0],b[1])<=0}))return he(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",D.InvalidArgument);var l=!t||t.includeLowers!==!1,h=t&&t.includeUppers===!0,y,c=i;function v(b,w){return c(b[0],w[0])}try{(y=g.reduce(function(b,w){for(var x=0,E=b.length;x<E;++x){var C=b[x];if(r(w[0],C[1])<0&&0<r(w[1],C[0])){C[0]=a(C[0],w[0]),C[1]=u(C[1],w[1]);break}}return x===E&&b.push(w),b},[])).sort(v)}catch{return he(this,ke)}var f=0,p=h?function(b){return 0<i(b,y[f][1])}:function(b){return 0<=i(b,y[f][1])},m=l?function(b){return 0<o(b,y[f][0])}:function(b){return 0<=o(b,y[f][0])},d=p,g=new this.Collection(this,function(){return Ae(y[0][0],y[y.length-1][1],!l,!h)});return g._ondirectionchange=function(b){c=b==="next"?(d=p,i):(d=m,o),y.sort(v)},g._addAlgorithm(function(b,w,x){for(var E,C=b.key;d(C);)if(++f===y.length)return w(x),!1;return!p(E=C)&&!m(E)||(n._cmp(C,y[f][1])===0||n._cmp(C,y[f][0])===0||w(function(){c===i?b.continue(y[f][0]):b.continue(y[f][1])}),!1)}),g},ie.prototype.startsWithAnyOf=function(){var e=Oe.apply(Ge,arguments);return e.every(function(t){return typeof t=="string"})?e.length===0?rt(this):this.inAnyRange(e.map(function(t){return[t,t+Ue]})):he(this,"startsWithAnyOf() only works with strings")},ie);function ie(){}function be(e){return ee(function(t){return yt(t),e(t.target.error),!1})}function yt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var mt="storagemutated",Sn="x-storagemutated-1",Se=ht(null,mt),Gi=(we.prototype._lock=function(){return ot(!K.global),++this._reculock,this._reculock!==1||K.global||(K.lockOwnerFor=this),this},we.prototype._unlock=function(){if(ot(!K.global),--this._reculock==0)for(K.global||(K.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{Le(e[1],e[0])}catch{}}return this},we.prototype._locked=function(){return this._reculock&&K.lockOwnerFor!==this},we.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if(ot(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new D.DatabaseClosed(r);case"MissingAPIError":throw new D.MissingAPI(r.message,r);default:throw new D.OpenFailed(r)}if(!this.active)throw new D.TransactionInactive;return ot(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=ee(function(i){yt(i),t._reject(e.error)}),e.onabort=ee(function(i){yt(i),t.active&&t._reject(new D.Abort(e.error)),t.active=!1,t.on("abort").fire(i)}),e.oncomplete=ee(function(){t.active=!1,t._resolve(),"mutatedParts"in e&&Se.storagemutated.fire(e.mutatedParts)}),this},we.prototype._promise=function(e,t,n){var r=this;if(e==="readwrite"&&this.mode!=="readwrite")return te(new D.ReadOnly("Transaction is readonly"));if(!this.active)return te(new D.TransactionInactive);if(this._locked())return new S(function(o,a){r._blockedFuncs.push([function(){r._promise(e,t,n).then(o,a)},K])});if(n)return Ie(function(){var o=new S(function(a,u){r._lock();var l=t(a,u,r);l&&l.then&&l.then(a,u)});return o.finally(function(){return r._unlock()}),o._lib=!0,o});var i=new S(function(o,a){var u=t(o,a,r);u&&u.then&&u.then(o,a)});return i._lib=!0,i},we.prototype._root=function(){return this.parent?this.parent._root():this},we.prototype.waitFor=function(e){var t,n=this._root(),r=S.resolve(e);n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return r}):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function o(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=o)}());var i=n._waitingFor;return new S(function(o,a){r.then(function(u){return n._waitingQueue.push(ee(o.bind(null,u)))},function(u){return n._waitingQueue.push(ee(a.bind(null,u)))}).finally(function(){n._waitingFor===i&&(n._waitingFor=null)})})},we.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new D.Abort))},we.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(z(t,e))return t[e];var n=this.schema[e];if(!n)throw new D.NotFound("Table "+e+" not part of transaction");return n=new this.db.Table(e,n,this),n.core=this.db.core.table(e),t[e]=n},we);function we(){}function Rn(e,t,n,r,i,o,a){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:o,src:(n&&!a?"&":"")+(r?"*":"")+(i?"++":"")+Br(t)}}function Br(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Kn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(i){return[i.name,i]},n.reduce(function(i,o,a){return a=r(o,a),a&&(i[a[0]]=a[1]),i},{}))};var r}var vt=function(e){try{return e.only([[]]),vt=function(){return[[]]},[[]]}catch{return vt=function(){return Ue},Ue}};function Nn(e){return e==null?function(){}:typeof e=="string"?(t=e).split(".").length===1?function(n){return n[t]}:function(n){return xe(n,t)}:function(n){return xe(n,e)};var t}function Fr(e){return[].slice.call(e)}var Qi=0;function gt(e){return e==null?":id":typeof e=="string"?e:"[".concat(e.join("+"),"]")}function Xi(e,t,l){function r(d){if(d.type===3)return null;if(d.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var f=d.lower,p=d.upper,m=d.lowerOpen,d=d.upperOpen;return f===void 0?p===void 0?null:t.upperBound(p,!!d):p===void 0?t.lowerBound(f,!!m):t.bound(f,p,!!m,!!d)}function i(v){var f,p=v.name;return{name:p,schema:v,mutate:function(m){var d=m.trans,g=m.type,b=m.keys,w=m.values,x=m.range;return new Promise(function(E,C){E=ee(E);var T=d.objectStore(p),I=T.keyPath==null,A=g==="put"||g==="add";if(!A&&g!=="delete"&&g!=="deleteRange")throw new Error("Invalid operation type: "+g);var P,R=(b||w||{length:1}).length;if(b&&w&&b.length!==w.length)throw new Error("Given keys array must have same length as given values array.");if(R===0)return E({numFailures:0,failures:{},results:[],lastResult:void 0});function M(ue){++de,yt(ue)}var L=[],U=[],de=0;if(g==="deleteRange"){if(x.type===4)return E({numFailures:de,failures:U,results:[],lastResult:void 0});x.type===3?L.push(P=T.clear()):L.push(P=T.delete(r(x)))}else{var I=A?I?[w,b]:[w,null]:[b,null],q=I[0],ae=I[1];if(A)for(var se=0;se<R;++se)L.push(P=ae&&ae[se]!==void 0?T[g](q[se],ae[se]):T[g](q[se])),P.onerror=M;else for(se=0;se<R;++se)L.push(P=T[g](q[se])),P.onerror=M}function on(ue){ue=ue.target.result,L.forEach(function(ze,Jn){return ze.error!=null&&(U[Jn]=ze.error)}),E({numFailures:de,failures:U,results:g==="delete"?b:L.map(function(ze){return ze.result}),lastResult:ue})}P.onerror=function(ue){M(ue),on(ue)},P.onsuccess=on})},getMany:function(m){var d=m.trans,g=m.keys;return new Promise(function(b,w){b=ee(b);for(var x,E=d.objectStore(p),C=g.length,T=new Array(C),I=0,A=0,P=function(L){L=L.target,T[L._pos]=L.result,++A===I&&b(T)},R=be(w),M=0;M<C;++M)g[M]!=null&&((x=E.get(g[M]))._pos=M,x.onsuccess=P,x.onerror=R,++I);I===0&&b(T)})},get:function(m){var d=m.trans,g=m.key;return new Promise(function(b,w){b=ee(b);var x=d.objectStore(p).get(g);x.onsuccess=function(E){return b(E.target.result)},x.onerror=be(w)})},query:(f=h,function(m){return new Promise(function(d,g){d=ee(d);var b,w,x,I=m.trans,E=m.values,C=m.limit,P=m.query,T=C===1/0?void 0:C,A=P.index,P=P.range,I=I.objectStore(p),A=A.isPrimaryKey?I:I.index(A.name),P=r(P);if(C===0)return d({result:[]});f?((T=E?A.getAll(P,T):A.getAllKeys(P,T)).onsuccess=function(R){return d({result:R.target.result})},T.onerror=be(g)):(b=0,w=!E&&"openKeyCursor"in A?A.openKeyCursor(P):A.openCursor(P),x=[],w.onsuccess=function(R){var M=w.result;return M?(x.push(E?M.value:M.primaryKey),++b===C?d({result:x}):void M.continue()):d({result:x})},w.onerror=be(g))})}),openCursor:function(m){var d=m.trans,g=m.values,b=m.query,w=m.reverse,x=m.unique;return new Promise(function(E,C){E=ee(E);var A=b.index,T=b.range,I=d.objectStore(p),I=A.isPrimaryKey?I:I.index(A.name),A=w?x?"prevunique":"prev":x?"nextunique":"next",P=!g&&"openKeyCursor"in I?I.openKeyCursor(r(T),A):I.openCursor(r(T),A);P.onerror=be(C),P.onsuccess=ee(function(R){var M,L,U,de,q=P.result;q?(q.___id=++Qi,q.done=!1,M=q.continue.bind(q),L=(L=q.continuePrimaryKey)&&L.bind(q),U=q.advance.bind(q),de=function(){throw new Error("Cursor not stopped")},q.trans=d,q.stop=q.continue=q.continuePrimaryKey=q.advance=function(){throw new Error("Cursor not started")},q.fail=ee(C),q.next=function(){var ae=this,se=1;return this.start(function(){return se--?ae.continue():ae.stop()}).then(function(){return ae})},q.start=function(ae){function se(){if(P.result)try{ae()}catch(ue){q.fail(ue)}else q.done=!0,q.start=function(){throw new Error("Cursor behind last entry")},q.stop()}var on=new Promise(function(ue,ze){ue=ee(ue),P.onerror=be(ze),q.fail=ze,q.stop=function(Jn){q.stop=q.continue=q.continuePrimaryKey=q.advance=de,ue(Jn)}});return P.onsuccess=ee(function(ue){P.onsuccess=se,se()}),q.continue=M,q.continuePrimaryKey=L,q.advance=U,se(),on},E(q)):E(null)},C)})},count:function(m){var d=m.query,g=m.trans,b=d.index,w=d.range;return new Promise(function(x,E){var C=g.objectStore(p),T=b.isPrimaryKey?C:C.index(b.name),C=r(w),T=C?T.count(C):T.count();T.onsuccess=ee(function(I){return x(I.target.result)}),T.onerror=be(E)})}}}var o,a,u,y=(a=l,u=Fr((o=e).objectStoreNames),{schema:{name:o.name,tables:u.map(function(v){return a.objectStore(v)}).map(function(v){var f=v.keyPath,d=v.autoIncrement,p=B(f),m={},d={name:v.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:f==null,compound:p,keyPath:f,autoIncrement:d,unique:!0,extractKey:Nn(f)},indexes:Fr(v.indexNames).map(function(g){return v.index(g)}).map(function(x){var b=x.name,w=x.unique,E=x.multiEntry,x=x.keyPath,E={name:b,compound:B(x),keyPath:x,unique:w,multiEntry:E,extractKey:Nn(x)};return m[gt(x)]=E}),getIndexByKeyPath:function(g){return m[gt(g)]}};return m[":id"]=d.primaryKey,f!=null&&(m[gt(f)]=d.primaryKey),d})},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)}),l=y.schema,h=y.hasGetAll,y=l.tables.map(i),c={};return y.forEach(function(v){return c[v.name]=v}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(v){if(!c[v])throw new Error("Table '".concat(v,"' not found"));return c[v]},MIN_KEY:-1/0,MAX_KEY:vt(t),schema:l}}function Ji(e,t,n,r){var i=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=Xi(t,i,r),e.dbcore.reduce(function(o,a){return a=a.create,k(k({},o),a(o))},r))}}function zt(e,r){var n=r.db,r=Ji(e._middlewares,n,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 $t(e,t,n,r){n.forEach(function(i){var o=r[i];t.forEach(function(a){var u=function l(h,y){return Ci(h,y)||(h=Y(h))&&l(h,y)}(a,i);(!u||"value"in u&&u.value===void 0)&&(a===e.Transaction.prototype||a instanceof e.Transaction?ve(a,i,{get:function(){return this.table(i)},set:function(l){le(this,i,{value:l,writable:!0,configurable:!0,enumerable:!0})}}):a[i]=new e.Table(i,o))})})}function Dn(e,t){t.forEach(function(n){for(var r in n)n[r]instanceof e.Table&&delete n[r]})}function Zi(e,t){return e._cfg.version-t._cfg.version}function eo(e,t,n,r){var i=e._dbSchema;n.objectStoreNames.contains("$meta")&&!i.$meta&&(i.$meta=Kn("$meta",Mr("")[0],[]),e._storeNames.push("$meta"));var o=e._createTransaction("readwrite",e._storeNames,i);o.create(n),o._completion.catch(r);var a=o._reject.bind(o),u=K.transless||K;Ie(function(){return K.trans=o,K.transless=u,t!==0?(zt(e,n),h=t,((l=o).storeNames.includes("$meta")?l.table("$meta").get("version").then(function(y){return y??h}):S.resolve(h)).then(function(y){return v=y,f=o,p=n,m=[],y=(c=e)._versions,d=c._dbSchema=Gt(0,c.idbdb,p),(y=y.filter(function(g){return g._cfg.version>=v})).length!==0?(y.forEach(function(g){m.push(function(){var b=d,w=g._cfg.dbschema;Qt(c,b,p),Qt(c,w,p),d=c._dbSchema=w;var x=jn(b,w);x.add.forEach(function(A){Bn(p,A[0],A[1].primKey,A[1].indexes)}),x.change.forEach(function(A){if(A.recreate)throw new D.Upgrade("Not yet support for changing primary key");var P=p.objectStore(A.name);A.add.forEach(function(R){return Yt(P,R)}),A.change.forEach(function(R){P.deleteIndex(R.name),Yt(P,R)}),A.del.forEach(function(R){return P.deleteIndex(R)})});var E=g._cfg.contentUpgrade;if(E&&g._cfg.version>v){zt(c,p),f._memoizedTables={};var C=yr(w);x.del.forEach(function(A){C[A]=b[A]}),Dn(c,[c.Transaction.prototype]),$t(c,[c.Transaction.prototype],F(C),C),f.schema=C;var T,I=yn(E);return I&&et(),x=S.follow(function(){var A;(T=E(f))&&I&&(A=Pe.bind(null,null),T.then(A,A))}),T&&typeof T.then=="function"?S.resolve(T):x.then(function(){return T})}}),m.push(function(b){var w,x,E=g._cfg.dbschema;w=E,x=b,[].slice.call(x.db.objectStoreNames).forEach(function(C){return w[C]==null&&x.db.deleteObjectStore(C)}),Dn(c,[c.Transaction.prototype]),$t(c,[c.Transaction.prototype],c._storeNames,c._dbSchema),f.schema=c._dbSchema}),m.push(function(b){c.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(c.idbdb.version/10)===g._cfg.version?(c.idbdb.deleteObjectStore("$meta"),delete c._dbSchema.$meta,c._storeNames=c._storeNames.filter(function(w){return w!=="$meta"})):b.objectStore("$meta").put(g._cfg.version,"version"))})}),function g(){return m.length?S.resolve(m.shift()(f.idbtrans)).then(g):S.resolve()}().then(function(){qr(d,p)})):S.resolve();var c,v,f,p,m,d}).catch(a)):(F(i).forEach(function(y){Bn(n,y,i[y].primKey,i[y].indexes)}),zt(e,n),void S.follow(function(){return e.on.populate.fire(o)}).catch(a));var l,h})}function to(e,t){qr(e._dbSchema,t),t.db.version%10!=0||t.objectStoreNames.contains("$meta")||t.db.createObjectStore("$meta").add(Math.ceil(t.db.version/10-1),"version");var n=Gt(0,e.idbdb,t);Qt(e,e._dbSchema,t);for(var r=0,i=jn(n,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=t.objectStore(a.name);a.add.forEach(function(l){ge&&console.debug("Dexie upgrade patch: Creating missing index ".concat(a.name,".").concat(l.src)),Yt(u,l)})}(i[r]);if(typeof o=="object")return o.value}}function jn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var i=e[n],o=t[n];if(i){var a={name:n,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,l=o.idxByName,h=void 0;for(h in u)l[h]||a.del.push(h);for(h in l){var y=u[h],c=l[h];y?y.src!==c.src&&a.change.push(c):a.add.push(c)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,o])}return r}function Bn(e,t,n,r){var i=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(o){return Yt(i,o)}),i}function qr(e,t){F(e).forEach(function(n){t.db.objectStoreNames.contains(n)||(ge&&console.debug("Dexie: Creating missing table",n),Bn(t,n,e[n].primKey,e[n].indexes))})}function Yt(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function Gt(e,t,n){var r={};return At(t.objectStoreNames,0).forEach(function(i){for(var o=n.objectStore(i),a=Rn(Br(h=o.keyPath),h||"",!0,!1,!!o.autoIncrement,h&&typeof h!="string",!0),u=[],l=0;l<o.indexNames.length;++l){var y=o.index(o.indexNames[l]),h=y.keyPath,y=Rn(y.name,h,!!y.unique,!!y.multiEntry,!1,h&&typeof h!="string",!1);u.push(y)}r[i]=Kn(i,a,u)}),r}function Qt(e,t,n){for(var r=n.db.objectStoreNames,i=0;i<r.length;++i){var o=r[i],a=n.objectStore(o);e._hasGetAll="getAll"in a;for(var u=0;u<a.indexNames.length;++u){var l=a.indexNames[u],h=a.index(l).keyPath,y=typeof h=="string"?h:"["+At(h).join("+")+"]";!t[o]||(h=t[o].idxByName[y])&&(h.name=l,delete t[o].idxByName[y],t[o].idxByName[l]=h)}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&N.WorkerGlobalScope&&N instanceof N.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function Mr(e){return e.split(",").map(function(t,n){var r=(t=t.trim()).replace(/([&*]|\+\+)/g,""),i=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return Rn(r,i||null,/\&/.test(t),/\*/.test(t),/\+\+/.test(t),B(i),n===0)})}var no=(Xt.prototype._parseStoresSpec=function(e,t){F(e).forEach(function(n){if(e[n]!==null){var r=Mr(e[n]),i=r.shift();if(i.unique=!0,i.multi)throw new D.Schema("Primary key cannot be multi-valued");r.forEach(function(o){if(o.auto)throw new D.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new D.Schema("Index must have a name and cannot be an empty string")}),t[n]=Kn(n,i,r)}})},Xt.prototype.stores=function(n){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?V(this._cfg.storesSource,n):n;var n=t._versions,r={},i={};return n.forEach(function(o){V(r,o._cfg.storesSource),i=o._cfg.dbschema={},o._parseStoresSpec(r,i)}),t._dbSchema=i,Dn(t,[t._allTables,t,t.Transaction.prototype]),$t(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],F(i),i),t._storeNames=F(i),this},Xt.prototype.upgrade=function(e){return this._cfg.contentUpgrade=vn(this._cfg.contentUpgrade||G,e),this},Xt);function Xt(){}function Fn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Ee(Lt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function qn(e){return e&&typeof e.databases=="function"}function Mn(e){return Ie(function(){return K.letThrough=!0,e()})}function Ln(e){return!("from"in e)}var oe=function(e,t){if(!this){var n=new oe;return e&&"d"in e&&V(n,e),n}V(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function bt(e,t,n){var r=H(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(Ln(e))return V(e,{from:t,to:n,d:1});var i=e.l,r=e.r;if(H(n,e.from)<0)return i?bt(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Ur(e);if(0<H(t,e.to))return r?bt(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Ur(e);H(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<H(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1),n=!e.r,i&&!e.l&&wt(e,i),r&&n&&wt(e,r)}}function wt(e,t){Ln(t)||function n(r,l){var o=l.from,a=l.to,u=l.l,l=l.r;bt(r,o,a),u&&n(r,u),l&&n(r,l)}(e,t)}function Lr(e,t){var n=Jt(t),r=n.next();if(r.done)return!1;for(var i=r.value,o=Jt(e),a=o.next(i.from),u=a.value;!r.done&&!a.done;){if(H(u.from,i.to)<=0&&0<=H(u.to,i.from))return!0;H(i.from,u.from)<0?i=(r=n.next(u.from)).value:u=(a=o.next(i.from)).value}return!1}function Jt(e){var t=Ln(e)?null:{s:0,n:e};return{next:function(n){for(var r=0<arguments.length;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&H(n,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||H(n,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Ur(e){var t,n,r=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((n=e.l)===null||n===void 0?void 0:n.d)||0),i=1<r?"r":r<-1?"l":"";i&&(t=i=="r"?"l":"r",n=k({},e),r=e[i],e.from=r.from,e.to=r.to,e[i]=r[i],n[i]=r[t],(e[t]=n).d=Wr(n)),e.d=Wr(e)}function Wr(n){var t=n.r,n=n.l;return(t?n?Math.max(t.d,n.d):t.d:n?n.d:0)+1}function Zt(e,t){return F(t).forEach(function(n){e[n]?wt(e[n],t[n]):e[n]=function r(i){var o,a,u={};for(o in i)z(i,o)&&(a=i[o],u[o]=!a||typeof a!="object"||vr.has(a.constructor)?a:r(a));return u}(t[n])}),e}function Un(e,t){return e.all||t.all||Object.keys(e).some(function(n){return t[n]&&Lr(t[n],e[n])})}X(oe.prototype,((me={add:function(e){return wt(this,e),this},addKey:function(e){return bt(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(n){return bt(t,n,n)}),this},hasKey:function(e){var t=Jt(this).next(e).value;return t&&H(t.from,e)<=0&&0<=H(t.to,e)}})[pn]=function(){return Jt(this)},me));var Ve={},Wn={},Vn=!1;function en(e){Zt(Wn,e),Vn||(Vn=!0,setTimeout(function(){Vn=!1,Hn(Wn,!(Wn={}))},0))}function Hn(e,t){t===void 0&&(t=!1);var n=new Set;if(e.all)for(var r=0,i=Object.values(Ve);r<i.length;r++)Vr(a=i[r],e,n,t);else for(var o in e){var a,u=/^idb\:\/\/(.*)\/(.*)\//.exec(o);u&&(o=u[1],u=u[2],(a=Ve["idb://".concat(o,"/").concat(u)])&&Vr(a,e,n,t))}n.forEach(function(l){return l()})}function Vr(e,t,n,r){for(var i=[],o=0,a=Object.entries(e.queries.query);o<a.length;o++){for(var u=a[o],l=u[0],h=[],y=0,c=u[1];y<c.length;y++){var v=c[y];Un(t,v.obsSet)?v.subscribers.forEach(function(d){return n.add(d)}):r&&h.push(v)}r&&i.push([l,h])}if(r)for(var f=0,p=i;f<p.length;f++){var m=p[f],l=m[0],h=m[1];e.queries.query[l]=h}}function ro(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(function(){return t.dbOpenError?te(t.dbOpenError):e});t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var r=t.openCanceller,i=Math.round(10*e.verno),o=!1;function a(){if(t.openCanceller!==r)throw new D.DatabaseClosed("db.open() was cancelled")}function u(){return new S(function(v,f){if(a(),!n)throw new D.MissingAPI;var p=e.name,m=t.autoSchema||!i?n.open(p):n.open(p,i);if(!m)throw new D.MissingAPI;m.onerror=be(f),m.onblocked=ee(e._fireOnBlocked),m.onupgradeneeded=ee(function(d){var g;y=m.transaction,t.autoSchema&&!e._options.allowEmptyDB?(m.onerror=yt,y.abort(),m.result.close(),(g=n.deleteDatabase(p)).onsuccess=g.onerror=ee(function(){f(new D.NoSuchDatabase("Database ".concat(p," doesnt exist")))})):(y.onerror=be(f),d=d.oldVersion>Math.pow(2,62)?0:d.oldVersion,c=d<1,e.idbdb=m.result,o&&to(e,y),eo(e,d/10,y,f))},f),m.onsuccess=ee(function(){y=null;var d,g,b,w,x,E=e.idbdb=m.result,C=At(E.objectStoreNames);if(0<C.length)try{var T=E.transaction((w=C).length===1?w[0]:w,"readonly");if(t.autoSchema)g=E,b=T,(d=e).verno=g.version/10,b=d._dbSchema=Gt(0,g,b),d._storeNames=At(g.objectStoreNames,0),$t(d,[d._allTables],F(b),b);else if(Qt(e,e._dbSchema,T),((x=jn(Gt(0,(x=e).idbdb,T),x._dbSchema)).add.length||x.change.some(function(I){return I.add.length||I.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."),E.close(),i=E.version+1,o=!0,v(u());zt(e,T)}catch{}tt.push(e),E.onversionchange=ee(function(I){t.vcFired=!0,e.on("versionchange").fire(I)}),E.onclose=ee(function(I){e.on("close").fire(I)}),c&&(x=e._deps,T=p,E=x.indexedDB,x=x.IDBKeyRange,qn(E)||T===Lt||Fn(E,x).put({name:T}).catch(G)),v()},f)}).catch(function(v){switch(v?.name){case"UnknownError":if(0<t.PR1398_maxLoop)return t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),u();break;case"VersionError":if(0<i)return i=0,u()}return S.reject(v)})}var l,h=t.dbReadyResolve,y=null,c=!1;return S.race([r,(typeof navigator>"u"?S.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(v){function f(){return indexedDB.databases().finally(v)}l=setInterval(f,100),f()}).finally(function(){return clearInterval(l)}):Promise.resolve()).then(u)]).then(function(){return a(),t.onReadyBeingFired=[],S.resolve(Mn(function(){return e.on.ready.fire(e.vip)})).then(function v(){if(0<t.onReadyBeingFired.length){var f=t.onReadyBeingFired.reduce(vn,G);return t.onReadyBeingFired=[],S.resolve(Mn(function(){return f(e.vip)})).then(v)}})}).finally(function(){t.openCanceller===r&&(t.onReadyBeingFired=null,t.isBeingOpened=!1)}).catch(function(v){t.dbOpenError=v;try{y&&y.abort()}catch{}return r===t.openCanceller&&e._close(),te(v)}).finally(function(){t.openComplete=!0,h()}).then(function(){var v;return c&&(v={},e.tables.forEach(function(f){f.schema.indexes.forEach(function(p){p.name&&(v["idb://".concat(e.name,"/").concat(f.name,"/").concat(p.name)]=new oe(-1/0,[[[]]]))}),v["idb://".concat(e.name,"/").concat(f.name,"/")]=v["idb://".concat(e.name,"/").concat(f.name,"/:dels")]=new oe(-1/0,[[[]]])}),Se(mt).fire(v),Hn(v,!0)),e})}function zn(e){function t(o){return e.next(o)}var n=i(t),r=i(function(o){return e.throw(o)});function i(o){return function(l){var u=o(l),l=u.value;return u.done?l:l&&typeof l.then=="function"?l.then(n,r):B(l)?Promise.all(l).then(n,r):n(l)}}return i(t)()}function tn(e,t,n){for(var r=B(e)?e.slice():[e],i=0;i<n;++i)r.push(t);return r}var io={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return k(k({},e),{table:function(t){var n=e.table(t),r=n.schema,i={},o=[];function a(c,v,f){var p=gt(c),m=i[p]=i[p]||[],d=c==null?0:typeof c=="string"?1:c.length,g=0<v,g=k(k({},f),{name:g?"".concat(p,"(virtual-from:").concat(f.name,")"):f.name,lowLevelIndex:f,isVirtual:g,keyTail:v,keyLength:d,extractKey:Nn(c),unique:!g&&f.unique});return m.push(g),g.isPrimaryKey||o.push(g),1<d&&a(d===2?c[0]:c.slice(0,d-1),v+1,f),m.sort(function(b,w){return b.keyTail-w.keyTail}),g}t=a(r.primaryKey.keyPath,0,r.primaryKey),i[":id"]=[t];for(var u=0,l=r.indexes;u<l.length;u++){var h=l[u];a(h.keyPath,0,h)}function y(c){var v,f=c.query.index;return f.isVirtual?k(k({},c),{query:{index:f.lowLevelIndex,range:(v=c.query.range,f=f.keyTail,{type:v.type===1?2:v.type,lower:tn(v.lower,v.lowerOpen?e.MAX_KEY:e.MIN_KEY,f),lowerOpen:!0,upper:tn(v.upper,v.upperOpen?e.MIN_KEY:e.MAX_KEY,f),upperOpen:!0})}}):c}return k(k({},n),{schema:k(k({},r),{primaryKey:t,indexes:o,getIndexByKeyPath:function(c){return(c=i[gt(c)])&&c[0]}}),count:function(c){return n.count(y(c))},query:function(c){return n.query(y(c))},openCursor:function(c){var v=c.query.index,f=v.keyTail,p=v.isVirtual,m=v.keyLength;return p?n.openCursor(y(c)).then(function(g){return g&&d(g)}):n.openCursor(c);function d(g){return Object.create(g,{continue:{value:function(b){b!=null?g.continue(tn(b,c.reverse?e.MAX_KEY:e.MIN_KEY,f)):c.unique?g.continue(g.key.slice(0,m).concat(c.reverse?e.MIN_KEY:e.MAX_KEY,f)):g.continue()}},continuePrimaryKey:{value:function(b,w){g.continuePrimaryKey(tn(b,e.MAX_KEY,f),w)}},primaryKey:{get:function(){return g.primaryKey}},key:{get:function(){var b=g.key;return m===1?b[0]:b.slice(0,m)}},value:{get:function(){return g.value}}})}}})}})}};function $n(e,t,n,r){return n=n||{},r=r||"",F(e).forEach(function(i){var o,a,u;z(t,i)?(o=e[i],a=t[i],typeof o=="object"&&typeof a=="object"&&o&&a?(u=dn(o))!==dn(a)?n[r+i]=t[i]:u==="Object"?$n(o,a,n,r+i+"."):o!==a&&(n[r+i]=t[i]):o!==a&&(n[r+i]=t[i])):n[r+i]=void 0}),F(t).forEach(function(i){z(e,i)||(n[r+i]=t[i])}),n}function Yn(e,t){return t.type==="delete"?t.keys:t.keys||t.values.map(e.extractKey)}var oo={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return k(k({},e),{table:function(t){var n=e.table(t),r=n.schema.primaryKey;return k(k({},n),{mutate:function(i){var o=K.trans,a=o.table(t).hook,u=a.deleting,l=a.creating,h=a.updating;switch(i.type){case"add":if(l.fire===G)break;return o._promise("readwrite",function(){return y(i)},!0);case"put":if(l.fire===G&&h.fire===G)break;return o._promise("readwrite",function(){return y(i)},!0);case"delete":if(u.fire===G)break;return o._promise("readwrite",function(){return y(i)},!0);case"deleteRange":if(u.fire===G)break;return o._promise("readwrite",function(){return function c(v,f,p){return n.query({trans:v,values:!1,query:{index:r,range:f},limit:p}).then(function(m){var d=m.result;return y({type:"delete",keys:d,trans:v}).then(function(g){return 0<g.numFailures?Promise.reject(g.failures[0]):d.length<p?{failures:[],numFailures:0,lastResult:void 0}:c(v,k(k({},f),{lower:d[d.length-1],lowerOpen:!0}),p)})})}(i.trans,i.range,1e4)},!0)}return n.mutate(i);function y(c){var v,f,p,m=K.trans,d=c.keys||Yn(r,c);if(!d)throw new Error("Keys missing");return(c=c.type==="add"||c.type==="put"?k(k({},c),{keys:d}):k({},c)).type!=="delete"&&(c.values=j([],c.values)),c.keys&&(c.keys=j([],c.keys)),v=n,p=d,((f=c).type==="add"?Promise.resolve([]):v.getMany({trans:f.trans,keys:p,cache:"immutable"})).then(function(g){var b=d.map(function(w,x){var E,C,T,I=g[x],A={onerror:null,onsuccess:null};return c.type==="delete"?u.fire.call(A,w,I,m):c.type==="add"||I===void 0?(E=l.fire.call(A,w,c.values[x],m),w==null&&E!=null&&(c.keys[x]=w=E,r.outbound||fe(c.values[x],r.keyPath,w))):(E=$n(I,c.values[x]),(C=h.fire.call(A,E,w,I,m))&&(T=c.values[x],Object.keys(C).forEach(function(P){z(T,P)?T[P]=C[P]:fe(T,P,C[P])}))),A});return n.mutate(c).then(function(w){for(var x=w.failures,E=w.results,C=w.numFailures,w=w.lastResult,T=0;T<d.length;++T){var I=(E||d)[T],A=b[T];I==null?A.onerror&&A.onerror(x[T]):A.onsuccess&&A.onsuccess(c.type==="put"&&g[T]?c.values[T]:I)}return{failures:x,results:E,numFailures:C,lastResult:w}}).catch(function(w){return b.forEach(function(x){return x.onerror&&x.onerror(w)}),Promise.reject(w)})})}}})}})}};function Hr(e,t,n){try{if(!t||t.keys.length<e.length)return null;for(var r=[],i=0,o=0;i<t.keys.length&&o<e.length;++i)H(t.keys[i],e[o])===0&&(r.push(n?Ne(t.values[i]):t.values[i]),++o);return r.length===e.length?r:null}catch{return null}}var ao={stack:"dbcore",level:-1,create:function(e){return{table:function(t){var n=e.table(t);return k(k({},n),{getMany:function(r){if(!r.cache)return n.getMany(r);var i=Hr(r.keys,r.trans._cache,r.cache==="clone");return i?S.resolve(i):n.getMany(r).then(function(o){return r.trans._cache={keys:r.keys,values:r.cache==="clone"?Ne(o):o},o})},mutate:function(r){return r.type!=="add"&&(r.trans._cache=null),n.mutate(r)}})}}}};function zr(e,t){return e.trans.mode==="readonly"&&!!e.subscr&&!e.trans.explicit&&e.trans.db._options.cache!=="disabled"&&!t.schema.primaryKey.outbound}function $r(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var so={stack:"dbcore",level:0,name:"Observability",create:function(e){var t=e.schema.name,n=new oe(e.MIN_KEY,e.MAX_KEY);return k(k({},e),{transaction:function(r,i,o){if(K.subscr&&i!=="readonly")throw new D.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(K.querier));return e.transaction(r,i,o)},table:function(r){var i=e.table(r),o=i.schema,a=o.primaryKey,c=o.indexes,u=a.extractKey,l=a.outbound,h=a.autoIncrement&&c.filter(function(f){return f.compound&&f.keyPath.includes(a.keyPath)}),y=k(k({},i),{mutate:function(f){function p(P){return P="idb://".concat(t,"/").concat(r,"/").concat(P),w[P]||(w[P]=new oe)}var m,d,g,b=f.trans,w=f.mutatedParts||(f.mutatedParts={}),x=p(""),E=p(":dels"),C=f.type,A=f.type==="deleteRange"?[f.range]:f.type==="delete"?[f.keys]:f.values.length<50?[Yn(a,f).filter(function(P){return P}),f.values]:[],T=A[0],I=A[1],A=f.trans._cache;return B(T)?(x.addKeys(T),(A=C==="delete"||T.length===I.length?Hr(T,A):null)||E.addKeys(T),(A||I)&&(m=p,d=A,g=I,o.indexes.forEach(function(P){var R=m(P.name||"");function M(U){return U!=null?P.extractKey(U):null}function L(U){return P.multiEntry&&B(U)?U.forEach(function(de){return R.addKey(de)}):R.addKey(U)}(d||g).forEach(function(U,ae){var q=d&&M(d[ae]),ae=g&&M(g[ae]);H(q,ae)!==0&&(q!=null&&L(q),ae!=null&&L(ae))})}))):T?(I={from:(I=T.lower)!==null&&I!==void 0?I:e.MIN_KEY,to:(I=T.upper)!==null&&I!==void 0?I:e.MAX_KEY},E.add(I),x.add(I)):(x.add(n),E.add(n),o.indexes.forEach(function(P){return p(P.name).add(n)})),i.mutate(f).then(function(P){return!T||f.type!=="add"&&f.type!=="put"||(x.addKeys(P.results),h&&h.forEach(function(R){for(var M=f.values.map(function(q){return R.extractKey(q)}),L=R.keyPath.findIndex(function(q){return q===a.keyPath}),U=0,de=P.results.length;U<de;++U)M[U][L]=P.results[U];p(R.name).addKeys(M)})),b.mutatedParts=Zt(b.mutatedParts||{},w),P})}}),c=function(p){var m=p.query,p=m.index,m=m.range;return[p,new oe((p=m.lower)!==null&&p!==void 0?p:e.MIN_KEY,(m=m.upper)!==null&&m!==void 0?m:e.MAX_KEY)]},v={get:function(f){return[a,new oe(f.key)]},getMany:function(f){return[a,new oe().addKeys(f.keys)]},count:c,query:c,openCursor:c};return F(v).forEach(function(f){y[f]=function(p){var m=K.subscr,d=!!m,g=zr(K,i)&&$r(f,p)?p.obsSet={}:m;if(d){var b=function(I){return I="idb://".concat(t,"/").concat(r,"/").concat(I),g[I]||(g[I]=new oe)},w=b(""),x=b(":dels"),m=v[f](p),d=m[0],m=m[1];if((f==="query"&&d.isPrimaryKey&&!p.values?x:b(d.name||"")).add(m),!d.isPrimaryKey){if(f!=="count"){var E=f==="query"&&l&&p.values&&i.query(k(k({},p),{values:!1}));return i[f].apply(this,arguments).then(function(I){if(f==="query"){if(l&&p.values)return E.then(function(M){return M=M.result,w.addKeys(M),I});var A=p.values?I.result.map(u):I.result;(p.values?w:x).addKeys(A)}else if(f==="openCursor"){var P=I,R=p.values;return P&&Object.create(P,{key:{get:function(){return x.addKey(P.primaryKey),P.key}},primaryKey:{get:function(){var M=P.primaryKey;return x.addKey(M),M}},value:{get:function(){return R&&w.addKey(P.primaryKey),P.value}}})}return I})}x.add(n)}}return i[f].apply(this,arguments)}}),y}})}};function Yr(e,t,n){if(n.numFailures===0)return t;if(t.type==="deleteRange")return null;var r=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1;return n.numFailures===r?null:(t=k({},t),B(t.keys)&&(t.keys=t.keys.filter(function(i,o){return!(o in n.failures)})),"values"in t&&B(t.values)&&(t.values=t.values.filter(function(i,o){return!(o in n.failures)})),t)}function Gn(e,t){return n=e,((r=t).lower===void 0||(r.lowerOpen?0<H(n,r.lower):0<=H(n,r.lower)))&&(e=e,(t=t).upper===void 0||(t.upperOpen?H(e,t.upper)<0:H(e,t.upper)<=0));var n,r}function Gr(e,t,v,r,i,o){if(!v||v.length===0)return e;var a=t.query.index,u=a.multiEntry,l=t.query.range,h=r.schema.primaryKey.extractKey,y=a.extractKey,c=(a.lowLevelIndex||a).extractKey,v=v.reduce(function(f,p){var m=f,d=[];if(p.type==="add"||p.type==="put")for(var g=new oe,b=p.values.length-1;0<=b;--b){var w,x=p.values[b],E=h(x);g.hasKey(E)||(w=y(x),(u&&B(w)?w.some(function(P){return Gn(P,l)}):Gn(w,l))&&(g.addKey(E),d.push(x)))}switch(p.type){case"add":var C=new oe().addKeys(t.values?f.map(function(R){return h(R)}):f),m=f.concat(t.values?d.filter(function(R){return R=h(R),!C.hasKey(R)&&(C.addKey(R),!0)}):d.map(function(R){return h(R)}).filter(function(R){return!C.hasKey(R)&&(C.addKey(R),!0)}));break;case"put":var T=new oe().addKeys(p.values.map(function(R){return h(R)}));m=f.filter(function(R){return!T.hasKey(t.values?h(R):R)}).concat(t.values?d:d.map(function(R){return h(R)}));break;case"delete":var I=new oe().addKeys(p.keys);m=f.filter(function(R){return!I.hasKey(t.values?h(R):R)});break;case"deleteRange":var A=p.range;m=f.filter(function(R){return!Gn(h(R),A)})}return m},e);return v===e?e:(v.sort(function(f,p){return H(c(f),c(p))||H(h(f),h(p))}),t.limit&&t.limit<1/0&&(v.length>t.limit?v.length=t.limit:e.length===t.limit&&v.length<t.limit&&(i.dirty=!0)),o?Object.freeze(v):v)}function Qr(e,t){return H(e.lower,t.lower)===0&&H(e.upper,t.upper)===0&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function uo(e,t){return function(n,r,i,o){if(n===void 0)return r!==void 0?-1:0;if(r===void 0)return 1;if((r=H(n,r))===0){if(i&&o)return 0;if(i)return 1;if(o)return-1}return r}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(n,r,i,o){if(n===void 0)return r!==void 0?1:0;if(r===void 0)return-1;if((r=H(n,r))===0){if(i&&o)return 0;if(i)return-1;if(o)return 1}return r}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function co(e,t,n,r){e.subscribers.add(n),r.addEventListener("abort",function(){var i,o;e.subscribers.delete(n),e.subscribers.size===0&&(i=e,o=t,setTimeout(function(){i.subscribers.size===0&&De(o,i)},3e3))})}var lo={stack:"dbcore",level:0,name:"Cache",create:function(e){var t=e.schema.name;return k(k({},e),{transaction:function(n,r,i){var o,a,u=e.transaction(n,r,i);return r==="readwrite"&&(a=(o=new AbortController).signal,i=function(l){return function(){if(o.abort(),r==="readwrite"){for(var h=new Set,y=0,c=n;y<c.length;y++){var v=c[y],f=Ve["idb://".concat(t,"/").concat(v)];if(f){var p=e.table(v),m=f.optimisticOps.filter(function(R){return R.trans===u});if(u._explicit&&l&&u.mutatedParts)for(var d=0,g=Object.values(f.queries.query);d<g.length;d++)for(var b=0,w=(C=g[d]).slice();b<w.length;b++)Un((T=w[b]).obsSet,u.mutatedParts)&&(De(C,T),T.subscribers.forEach(function(R){return h.add(R)}));else if(0<m.length){f.optimisticOps=f.optimisticOps.filter(function(R){return R.trans!==u});for(var x=0,E=Object.values(f.queries.query);x<E.length;x++)for(var C,T,I,A=0,P=(C=E[x]).slice();A<P.length;A++)(T=P[A]).res!=null&&u.mutatedParts&&(l&&!T.dirty?(I=Object.isFrozen(T.res),I=Gr(T.res,T.req,m,p,T,I),T.dirty?(De(C,T),T.subscribers.forEach(function(R){return h.add(R)})):I!==T.res&&(T.res=I,T.promise=S.resolve({result:I}))):(T.dirty&&De(C,T),T.subscribers.forEach(function(R){return h.add(R)})))}}}h.forEach(function(R){return R()})}}},u.addEventListener("abort",i(!1),{signal:a}),u.addEventListener("error",i(!1),{signal:a}),u.addEventListener("complete",i(!0),{signal:a})),u},table:function(n){var r=e.table(n),i=r.schema.primaryKey;return k(k({},r),{mutate:function(o){var a=K.trans;if(i.outbound||a.db._options.cache==="disabled"||a.explicit||a.idbtrans.mode!=="readwrite")return r.mutate(o);var u=Ve["idb://".concat(t,"/").concat(n)];return u?(a=r.mutate(o),o.type!=="add"&&o.type!=="put"||!(50<=o.values.length||Yn(i,o).some(function(l){return l==null}))?(u.optimisticOps.push(o),o.mutatedParts&&en(o.mutatedParts),a.then(function(l){0<l.numFailures&&(De(u.optimisticOps,o),(l=Yr(0,o,l))&&u.optimisticOps.push(l),o.mutatedParts&&en(o.mutatedParts))}),a.catch(function(){De(u.optimisticOps,o),o.mutatedParts&&en(o.mutatedParts)})):a.then(function(l){var h=Yr(0,k(k({},o),{values:o.values.map(function(y,c){var v;return l.failures[c]?y:(y=(v=i.keyPath)!==null&&v!==void 0&&v.includes(".")?Ne(y):k({},y),fe(y,i.keyPath,l.results[c]),y)})}),l);u.optimisticOps.push(h),queueMicrotask(function(){return o.mutatedParts&&en(o.mutatedParts)})}),a):r.mutate(o)},query:function(o){if(!zr(K,r)||!$r("query",o))return r.query(o);var a=((h=K.trans)===null||h===void 0?void 0:h.db._options.cache)==="immutable",c=K,u=c.requery,l=c.signal,h=function(p,m,d,g){var b=Ve["idb://".concat(p,"/").concat(m)];if(!b)return[];if(!(m=b.queries[d]))return[null,!1,b,null];var w=m[(g.query?g.query.index.name:null)||""];if(!w)return[null,!1,b,null];switch(d){case"query":var x=w.find(function(E){return E.req.limit===g.limit&&E.req.values===g.values&&Qr(E.req.query.range,g.query.range)});return x?[x,!0,b,w]:[w.find(function(E){return("limit"in E.req?E.req.limit:1/0)>=g.limit&&(!g.values||E.req.values)&&uo(E.req.query.range,g.query.range)}),!1,b,w];case"count":return x=w.find(function(E){return Qr(E.req.query.range,g.query.range)}),[x,!!x,b,w]}}(t,n,"query",o),y=h[0],c=h[1],v=h[2],f=h[3];return y&&c?y.obsSet=o.obsSet:(c=r.query(o).then(function(p){var m=p.result;if(y&&(y.res=m),a){for(var d=0,g=m.length;d<g;++d)Object.freeze(m[d]);Object.freeze(m)}else p.result=Ne(m);return p}).catch(function(p){return f&&y&&De(f,y),Promise.reject(p)}),y={obsSet:o.obsSet,promise:c,subscribers:new Set,type:"query",req:o,dirty:!1},f?f.push(y):(f=[y],(v=v||(Ve["idb://".concat(t,"/").concat(n)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[o.query.index.name||""]=f)),co(y,f,u,l),y.promise.then(function(p){return{result:Gr(p.result,o,v?.optimisticOps,r,y,a)}})}})}})}};function nn(e,t){return new Proxy(e,{get:function(n,r,i){return r==="db"?t:Reflect.get(n,r,i)}})}var Ee=(ne.prototype.version=function(e){if(isNaN(e)||e<.1)throw new D.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new D.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter(function(r){return r._cfg.version===e})[0];return n||(n=new this.Version(e),t.push(n),t.sort(Zi),n.stores({}),this._state.autoSchema=!1,n)},ne.prototype._whenReady=function(e){var t=this;return this.idbdb&&(this._state.openComplete||K.letThrough||this._vip)?e():new S(function(n,r){if(t._state.openComplete)return r(new D.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return void r(new D.DatabaseClosed);t.open().catch(G)}t._state.dbReadyPromise.then(n,r)}).then(e)},ne.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,i=e.name;return i&&this.unuse({stack:t,name:i}),e=this._middlewares[t]||(this._middlewares[t]=[]),e.push({stack:t,create:n,level:r??10,name:i}),e.sort(function(o,a){return o.level-a.level}),this},ne.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(i){return r?i.create!==r:!!n&&i.name!==n})),this},ne.prototype.open=function(){var e=this;return Le(Te,function(){return ro(e)})},ne.prototype._close=function(){var e=this._state,t=tt.indexOf(this);if(0<=t&&tt.splice(t,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new S(function(n){e.dbReadyResolve=n}),e.openCanceller=new S(function(n,r){e.cancelOpen=r}))},ne.prototype.close=function(n){var t=(n===void 0?{disableAutoOpen:!0}:n).disableAutoOpen,n=this._state;t?(n.isBeingOpened&&n.cancelOpen(new D.DatabaseClosed),this._close(),n.autoOpen=!1,n.dbOpenError=new D.DatabaseClosed):(this._close(),n.autoOpen=this._options.autoOpen||n.isBeingOpened,n.openComplete=!1,n.dbOpenError=null)},ne.prototype.delete=function(e){var t=this;e===void 0&&(e={disableAutoOpen:!0});var n=0<arguments.length&&typeof arguments[0]!="object",r=this._state;return new S(function(i,o){function a(){t.close(e);var u=t._deps.indexedDB.deleteDatabase(t.name);u.onsuccess=ee(function(){var l,h,y;l=t._deps,h=t.name,y=l.indexedDB,l=l.IDBKeyRange,qn(y)||h===Lt||Fn(y,l).delete(h).catch(G),i()}),u.onerror=be(o),u.onblocked=t._fireOnBlocked}if(n)throw new D.InvalidArgument("Invalid closeOptions argument to db.delete()");r.isBeingOpened?r.dbReadyPromise.then(a):a()})},ne.prototype.backendDB=function(){return this.idbdb},ne.prototype.isOpen=function(){return this.idbdb!==null},ne.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"},ne.prototype.hasFailed=function(){return this._state.dbOpenError!==null},ne.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(ne.prototype,"tables",{get:function(){var e=this;return F(this._allTables).map(function(t){return e._allTables[t]})},enumerable:!1,configurable:!0}),ne.prototype.transaction=function(){var e=function(t,n,r){var i=arguments.length;if(i<2)throw new D.InvalidArgument("Too few arguments");for(var o=new Array(i-1);--i;)o[i-1]=arguments[i];return r=o.pop(),[t,mr(o),r]}.apply(this,arguments);return this._transaction.apply(this,e)},ne.prototype._transaction=function(e,t,n){var r=this,i=K.trans;i&&i.db===this&&e.indexOf("!")===-1||(i=null);var o,a,u=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");try{if(a=t.map(function(h){if(h=h instanceof r.Table?h.name:h,typeof h!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return h}),e=="r"||e===Tn)o=Tn;else{if(e!="rw"&&e!=In)throw new D.InvalidArgument("Invalid transaction mode: "+e);o=In}if(i){if(i.mode===Tn&&o===In){if(!u)throw new D.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&a.forEach(function(h){if(i&&i.storeNames.indexOf(h)===-1){if(!u)throw new D.SubTransaction("Table "+h+" not included in parent transaction.");i=null}}),u&&i&&!i.active&&(i=null)}}catch(h){return i?i._promise(null,function(y,c){c(h)}):te(h)}var l=function h(y,c,v,f,p){return S.resolve().then(function(){var m=K.transless||K,d=y._createTransaction(c,v,y._dbSchema,f);if(d.explicit=!0,m={trans:d,transless:m},f)d.idbtrans=f.idbtrans;else try{d.create(),d.idbtrans._explicit=!0,y._state.PR1398_maxLoop=3}catch(w){return w.name===mn.InvalidState&&y.isOpen()&&0<--y._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),y.close({disableAutoOpen:!1}),y.open().then(function(){return h(y,c,v,null,p)})):te(w)}var g,b=yn(p);return b&&et(),m=S.follow(function(){var w;(g=p.call(d,d))&&(b?(w=Pe.bind(null,null),g.then(w,w)):typeof g.next=="function"&&typeof g.throw=="function"&&(g=zn(g)))},m),(g&&typeof g.then=="function"?S.resolve(g).then(function(w){return d.active?w:te(new D.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):m.then(function(){return g})).then(function(w){return f&&d._resolve(),d._completion.then(function(){return w})}).catch(function(w){return d._reject(w),te(w)})})}.bind(null,this,o,a,i,n);return i?i._promise(o,l,"lock"):K.trans?Le(K.transless,function(){return r._whenReady(l)}):this._whenReady(l)},ne.prototype.table=function(e){if(!z(this._allTables,e))throw new D.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},ne);function ne(e,t){var n=this;this._middlewares={},this.verno=0;var r=ne.dependencies;this._options=t=k({addons:ne.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,cache:"cloned"},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange},r=t.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var i,o,a,u,l,h={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:G,dbReadyPromise:null,cancelOpen:G,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:t.autoOpen};h.dbReadyPromise=new S(function(c){h.dbReadyResolve=c}),h.openCanceller=new S(function(c,v){h.cancelOpen=v}),this._state=h,this.name=e,this.on=ht(this,"populate","blocked","versionchange","close",{ready:[vn,G]}),this.on.ready.subscribe=dr(this.on.ready.subscribe,function(c){return function(v,f){ne.vip(function(){var p,m=n._state;m.openComplete?(m.dbOpenError||S.resolve().then(v),f&&c(v)):m.onReadyBeingFired?(m.onReadyBeingFired.push(v),f&&c(v)):(c(v),p=n,f||c(function d(){p.on.ready.unsubscribe(v),p.on.ready.unsubscribe(d)}))})}}),this.Collection=(i=this,dt(zi.prototype,function(g,d){this.db=i;var f=Ir,p=null;if(d)try{f=d()}catch(b){p=b}var m=g._ctx,d=m.table,g=d.hook.reading.fire;this._ctx={table:d,index:m.index,isPrimKey:!m.index||d.schema.primKey.keyPath&&m.index===d.schema.primKey.name,range:f,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:p,or:m.or,valueMapper:g!==st?g:null}})),this.Table=(o=this,dt(Sr.prototype,function(c,v,f){this.db=o,this._tx=f,this.name=c,this.schema=v,this.hook=o._allTables[c]?o._allTables[c].hook:ht(null,{creating:[Bi,G],reading:[ji,st],updating:[qi,G],deleting:[Fi,G]})})),this.Transaction=(a=this,dt(Gi.prototype,function(c,v,f,p,m){var d=this;this.db=a,this.mode=c,this.storeNames=v,this.schema=f,this.chromeTransactionDurability=p,this.idbtrans=null,this.on=ht(this,"complete","error","abort"),this.parent=m||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 S(function(g,b){d._resolve=g,d._reject=b}),this._completion.then(function(){d.active=!1,d.on.complete.fire()},function(g){var b=d.active;return d.active=!1,d.on.error.fire(g),d.parent?d.parent._reject(g):b&&d.idbtrans&&d.idbtrans.abort(),te(g)})})),this.Version=(u=this,dt(no.prototype,function(c){this.db=u,this._cfg={version:c,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(l=this,dt(jr.prototype,function(c,v,f){if(this.db=l,this._ctx={table:c,index:v===":id"?null:v,or:f},this._cmp=this._ascending=H,this._descending=function(p,m){return H(m,p)},this._max=function(p,m){return 0<H(p,m)?p:m},this._min=function(p,m){return H(p,m)<0?p:m},this._IDBKeyRange=l._deps.IDBKeyRange,!this._IDBKeyRange)throw new D.MissingAPI})),this.on("versionchange",function(c){0<c.newVersion?console.warn("Another connection wants to upgrade database '".concat(n.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(n.name,"'. Closing db now to resume the delete request.")),n.close({disableAutoOpen:!1})}),this.on("blocked",function(c){!c.newVersion||c.newVersion<c.oldVersion?console.warn("Dexie.delete('".concat(n.name,"') was blocked")):console.warn("Upgrade '".concat(n.name,"' blocked by other connection holding version ").concat(c.oldVersion/10))}),this._maxKey=vt(t.IDBKeyRange),this._createTransaction=function(c,v,f,p){return new n.Transaction(c,v,f,n._options.chromeTransactionDurability,p)},this._fireOnBlocked=function(c){n.on("blocked").fire(c),tt.filter(function(v){return v.name===n.name&&v!==n&&!v._state.vcFired}).map(function(v){return v.on("versionchange").fire(c)})},this.use(ao),this.use(lo),this.use(so),this.use(io),this.use(oo);var y=new Proxy(this,{get:function(c,v,f){if(v==="_vip")return!0;if(v==="table")return function(m){return nn(n.table(m),y)};var p=Reflect.get(c,v,f);return p instanceof Sr?nn(p,y):v==="tables"?p.map(function(m){return nn(m,y)}):v==="_createTransaction"?function(){return nn(p.apply(this,arguments),y)}:p}});this.vip=y,r.forEach(function(c){return c(n)})}var rn,me=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",fo=(Qn.prototype.subscribe=function(e,t,n){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:t,complete:n})},Qn.prototype[me]=function(){return this},Qn);function Qn(e){this._subscribe=e}try{rn={indexedDB:N.indexedDB||N.mozIndexedDB||N.webkitIndexedDB||N.msIndexedDB,IDBKeyRange:N.IDBKeyRange||N.webkitIDBKeyRange}}catch{rn={indexedDB:null,IDBKeyRange:null}}function Xr(e){var t,n=!1,r=new fo(function(i){var o=yn(e),a,u=!1,l={},h={},y={get closed(){return u},unsubscribe:function(){u||(u=!0,a&&a.abort(),c&&Se.storagemutated.unsubscribe(f))}};i.start&&i.start(y);var c=!1,v=function(){return En(p)},f=function(m){Zt(l,m),Un(h,l)&&v()},p=function(){var m,d,g;!u&&rn.indexedDB&&(l={},m={},a&&a.abort(),a=new AbortController,g=function(b){var w=Je();try{o&&et();var x=Ie(e,b);return x=o?x.finally(Pe):x}finally{w&&Ze()}}(d={subscr:m,signal:a.signal,requery:v,querier:e,trans:null}),Promise.resolve(g).then(function(b){n=!0,t=b,u||d.signal.aborted||(l={},function(w){for(var x in w)if(z(w,x))return;return 1}(h=m)||c||(Se(mt,f),c=!0),En(function(){return!u&&i.next&&i.next(b)}))},function(b){n=!1,["DatabaseClosedError","AbortError"].includes(b?.name)||u||En(function(){u||i.error&&i.error(b)})}))};return setTimeout(v,0),y});return r.hasValue=function(){return n},r.getValue=function(){return t},r}var He=Ee;function Xn(e){var t=Re;try{Re=!0,Se.storagemutated.fire(e),Hn(e,!0)}finally{Re=t}}X(He,k(k({},Rt),{delete:function(e){return new He(e,{addons:[]}).delete()},exists:function(e){return new He(e,{addons:[]}).open().then(function(t){return t.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=He.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(qn(n)?Promise.resolve(n.databases()).then(function(r){return r.map(function(i){return i.name}).filter(function(i){return i!==Lt})}):Fn(n,t).toCollection().primaryKeys()).then(e)}catch{return te(new D.MissingAPI)}var t,n},defineClass:function(){return function(e){V(this,e)}},ignoreTransaction:function(e){return K.trans?Le(K.transless,e):e()},vip:Mn,async:function(e){return function(){try{var t=zn(e.apply(this,arguments));return t&&typeof t.then=="function"?t:S.resolve(t)}catch(n){return te(n)}}},spawn:function(e,t,n){try{var r=zn(e.apply(n,t||[]));return r&&typeof r.then=="function"?r:S.resolve(r)}catch(i){return te(i)}},currentTransaction:{get:function(){return K.trans||null}},waitFor:function(e,t){return t=S.resolve(typeof e=="function"?He.ignoreTransaction(e):e).timeout(t||6e4),K.trans?K.trans.waitFor(t):t},Promise:S,debug:{get:function(){return ge},set:function(e){wr(e)}},derive:Ye,extend:V,props:X,override:dr,Events:ht,on:Se,liveQuery:Xr,extendObservabilitySet:Zt,getByKeyPath:xe,setByKeyPath:fe,delByKeyPath:function(e,t){typeof t=="string"?fe(e,t,void 0):"length"in t&&[].map.call(t,function(n){fe(e,n,void 0)})},shallowClone:yr,deepClone:Ne,getObjectDiff:$n,cmp:H,asap:pr,minKey:-1/0,addons:[],connections:tt,errnames:mn,dependencies:rn,cache:Ve,semVer:"4.0.11",version:"4.0.11".split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),He.maxKey=vt(He.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(Se(mt,function(e){Re||(e=new CustomEvent(Sn,{detail:e}),Re=!0,dispatchEvent(e),Re=!1)}),addEventListener(Sn,function(e){e=e.detail,Re||Xn(e)}));var it,Re=!1,Jr=function(){};return typeof BroadcastChannel<"u"&&((Jr=function(){(it=new BroadcastChannel(Sn)).onmessage=function(e){return e.data&&Xn(e.data)}})(),typeof it.unref=="function"&&it.unref(),Se(mt,function(e){Re||it.postMessage(e)})),typeof addEventListener<"u"&&(addEventListener("pagehide",function(e){if(!Ee.disableBfCache&&e.persisted){ge&&console.debug("Dexie: handling persisted pagehide"),it?.close();for(var t=0,n=tt;t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(e){!Ee.disableBfCache&&e.persisted&&(ge&&console.debug("Dexie: handling persisted pageshow"),Jr(),Xn({all:new oe(-1/0,[[]])}))})),S.rejectionMapper=function(e,t){return!e||e instanceof Qe||e instanceof TypeError||e instanceof SyntaxError||!e.name||!br[e.name]?e:(t=new br[e.name](t||e.message,e),"stack"in e&&ve(t,"stack",{get:function(){return this.inner.stack}}),t)},wr(ge),k(Ee,Object.freeze({__proto__:null,Dexie:Ee,liveQuery:Xr,Entity:Pr,cmp:H,PropModification:pt,replacePrefix:function(e,t){return new pt({replacePrefix:[e,t]})},add:function(e){return new pt({add:e})},remove:function(e){return new pt({remove:e})},default:Ee,RangeSet:oe,mergeRanges:wt,rangesOverlap:Lr}),{default:Ee}),Ee})}(Tt)),Tt.exports}var mi=yi(),cn=di(mi);const sr=Symbol.for("Dexie"),It=globalThis[sr]||(globalThis[sr]=cn);if(cn.semVer!==It.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${cn.semVer} and ${It.semVer}`);const{liveQuery:ho,mergeRanges:po,rangesOverlap:yo,RangeSet:mo,cmp:vo,Entity:go,PropModification:bo,replacePrefix:wo,add:_o,remove:xo}=It;var _e=(s=>(s[s.WIDTH8=0]="WIDTH8",s[s.WIDTH16=1]="WIDTH16",s[s.WIDTH32=2]="WIDTH32",s[s.WIDTH64=3]="WIDTH64",s))(_e||{});function ce(s){return s===1?_e.WIDTH8:s===2?_e.WIDTH16:s===4?_e.WIDTH32:_e.WIDTH64}function ur(s){return new TextDecoder().decode(s)}function vi(s){return new TextEncoder().encode(s)}var W=(s=>(s[s.NULL=0]="NULL",s[s.INT=1]="INT",s[s.UINT=2]="UINT",s[s.FLOAT=3]="FLOAT",s[s.KEY=4]="KEY",s[s.STRING=5]="STRING",s[s.INDIRECT_INT=6]="INDIRECT_INT",s[s.INDIRECT_UINT=7]="INDIRECT_UINT",s[s.INDIRECT_FLOAT=8]="INDIRECT_FLOAT",s[s.MAP=9]="MAP",s[s.VECTOR=10]="VECTOR",s[s.VECTOR_INT=11]="VECTOR_INT",s[s.VECTOR_UINT=12]="VECTOR_UINT",s[s.VECTOR_FLOAT=13]="VECTOR_FLOAT",s[s.VECTOR_KEY=14]="VECTOR_KEY",s[s.VECTOR_STRING_DEPRECATED=15]="VECTOR_STRING_DEPRECATED",s[s.VECTOR_INT2=16]="VECTOR_INT2",s[s.VECTOR_UINT2=17]="VECTOR_UINT2",s[s.VECTOR_FLOAT2=18]="VECTOR_FLOAT2",s[s.VECTOR_INT3=19]="VECTOR_INT3",s[s.VECTOR_UINT3=20]="VECTOR_UINT3",s[s.VECTOR_FLOAT3=21]="VECTOR_FLOAT3",s[s.VECTOR_INT4=22]="VECTOR_INT4",s[s.VECTOR_UINT4=23]="VECTOR_UINT4",s[s.VECTOR_FLOAT4=24]="VECTOR_FLOAT4",s[s.BLOB=25]="BLOB",s[s.BOOL=26]="BOOL",s[s.VECTOR_BOOL=36]="VECTOR_BOOL",s))(W||{});function gi(s){return s>=W.INT&&s<=W.FLOAT}function bi(s){return s>=W.INDIRECT_INT&&s<=W.INDIRECT_FLOAT}function cr(s){return s===W.VECTOR_BOOL||s>=W.VECTOR_INT&&s<=W.VECTOR_STRING_DEPRECATED}function ln(s){return s>=W.VECTOR_INT2&&s<=W.VECTOR_FLOAT4}function fn(s){return cr(s)||ln(s)||s===W.VECTOR}function wi(s){return s-W.VECTOR_INT+W.INT}function _i(s){return(s-W.VECTOR_INT2)%3+W.INT}function xi(s){return((s-W.VECTOR_INT2)/3>>0)+2}function lr(s,_){return _|s<<2}function hn(s,_,O){return O<2?O<1?s.getInt8(_):s.getInt16(_,!0):O<3?s.getInt32(_,!0):s.setBigInt64===void 0?BigInt(s.getUint32(_,!0))+(BigInt(s.getUint32(_+4,!0))<<BigInt(32)):s.getBigInt64(_,!0)}function pe(s,_,O){return O<2?O<1?s.getUint8(_):s.getUint16(_,!0):O<3?s.getUint32(_,!0):s.getBigUint64===void 0?BigInt(s.getUint32(_,!0))+(BigInt(s.getUint32(_+4,!0))<<BigInt(32)):s.getBigUint64(_,!0)}function fr(s,_,O){if(O<_e.WIDTH32)throw"Bad width: "+O;return O===_e.WIDTH32?s.getFloat32(_,!0):s.getFloat64(_,!0)}function ye(s,_,O){const k=pe(s,_,O);return _-k}function Oi(s,_,O,k,j,N){const F=vi(s),B=ye(_,O,k)-j*3,V=ce(j),Y=B-Number(pe(_,B,V)),Z=Number(pe(_,B+j,V));let z=0,X=N-1;for(;z<=X;){const le=X+z>>1,ve=ki(F,le,_,Y,Z);if(ve===0)return le;ve<0?X=le-1:z=le+1}return null}function ki(s,_,O,k,j){const N=k+_*j,F=N-Number(pe(O,N,ce(j)));for(let B=0;B<s.length;B++){const V=s[B]-O.getUint8(F+B);if(V!==0)return V}return O.getUint8(F+s.length)===0?0:-1}function Ei(s,_,O,k,j){const N=ye(_,O,k)-j*3,F=ce(j),B=N-Number(pe(_,N,F)),V=Number(pe(_,N+j,F)),Y=B+s*V,Z=Y-Number(pe(_,Y,ce(V)));let z=0;for(;_.getUint8(Z+z)!==0;)z++;return ur(new Uint8Array(_.buffer,Z,z))}function Ti(s){const _=s.byteLength;if(_<3)throw"Buffer needs to be bigger than 3";const O=new DataView(s),k=O.getUint8(_-1),j=O.getUint8(_-2),N=ce(k),F=_-k-2;return new Pt(O,F,N,j,"/")}function hr(s,_,O,k,j,N,F,B){const V=ye(O,k,j),Y=V+s*N,Z=O.getUint8(V+F*N+s);return new Pt(O,Y,ce(N),Z,`${B}/${_}`)}class Pt{constructor(_,O,k,j,N){this.dataView=_,this.offset=O,this.parentWidth=k,this.packedType=j,this.path=N,this._length=-1,this.byteWidth=1<<(j&3),this.valueType=j>>2}isNull(){return this.valueType===W.NULL}isNumber(){return gi(this.valueType)||bi(this.valueType)}isFloat(){return W.FLOAT===this.valueType||W.INDIRECT_FLOAT===this.valueType}isInt(){return this.isNumber()&&!this.isFloat()}isString(){return W.STRING===this.valueType||W.KEY===this.valueType}isBool(){return W.BOOL===this.valueType}isBlob(){return W.BLOB===this.valueType}isVector(){return fn(this.valueType)}isMap(){return W.MAP===this.valueType}boolValue(){return this.isBool()?hn(this.dataView,this.offset,this.parentWidth)>0:null}intValue(){return this.valueType===W.INT?hn(this.dataView,this.offset,this.parentWidth):this.valueType===W.UINT?pe(this.dataView,this.offset,this.parentWidth):this.valueType===W.INDIRECT_INT?hn(this.dataView,ye(this.dataView,this.offset,this.parentWidth),ce(this.byteWidth)):this.valueType===W.INDIRECT_UINT?pe(this.dataView,ye(this.dataView,this.offset,this.parentWidth),ce(this.byteWidth)):null}floatValue(){return this.valueType===W.FLOAT?fr(this.dataView,this.offset,this.parentWidth):this.valueType===W.INDIRECT_FLOAT?fr(this.dataView,ye(this.dataView,this.offset,this.parentWidth),ce(this.byteWidth)):null}numericValue(){return this.floatValue()||this.intValue()}stringValue(){if(this.valueType===W.STRING||this.valueType===W.KEY){const _=ye(this.dataView,this.offset,this.parentWidth);return ur(new Uint8Array(this.dataView.buffer,_,this.length()))}return null}blobValue(){if(this.isBlob()){const _=ye(this.dataView,this.offset,this.parentWidth);return new Uint8Array(this.dataView.buffer,_,this.length())}return null}get(_){const O=this.length();if(Number.isInteger(_)&&fn(this.valueType)){if(_>=O||_<0)throw`Key: [${_}] is not applicable on ${this.path} of ${this.valueType} length: ${O}`;const k=ye(this.dataView,this.offset,this.parentWidth),j=k+_*this.byteWidth;let N=this.dataView.getUint8(k+O*this.byteWidth+_);if(cr(this.valueType)){const F=wi(this.valueType);N=lr(F,_e.WIDTH8)}else if(ln(this.valueType)){const F=_i(this.valueType);N=lr(F,_e.WIDTH8)}return new Pt(this.dataView,j,ce(this.byteWidth),N,`${this.path}[${_}]`)}if(typeof _=="string"){const k=Oi(_,this.dataView,this.offset,this.parentWidth,this.byteWidth,O);if(k!==null)return hr(k,_,this.dataView,this.offset,this.parentWidth,this.byteWidth,O,this.path)}throw`Key [${_}] is not applicable on ${this.path} of ${this.valueType}`}length(){let _;if(this._length>-1)return this._length;if(ln(this.valueType))this._length=xi(this.valueType);else if(this.valueType===W.BLOB||this.valueType===W.MAP||fn(this.valueType))this._length=pe(this.dataView,ye(this.dataView,this.offset,this.parentWidth)-this.byteWidth,ce(this.byteWidth));else if(this.valueType===W.NULL)this._length=0;else if(this.valueType===W.STRING){const O=ye(this.dataView,this.offset,this.parentWidth);let k=this.byteWidth;for(_=pe(this.dataView,O-k,ce(this.byteWidth));this.dataView.getInt8(O+_)!==0;)k<<=1,_=pe(this.dataView,O-k,ce(this.byteWidth));this._length=_}else if(this.valueType===W.KEY){const O=ye(this.dataView,this.offset,this.parentWidth);for(_=1;this.dataView.getInt8(O+_)!==0;)_++;this._length=_}else this._length=1;return Number(this._length)}toObject(){const _=this.length();if(this.isVector()){const O=[];for(let k=0;k<_;k++)O.push(this.get(k).toObject());return O}if(this.isMap()){const O={};for(let k=0;k<_;k++){const j=Ei(k,this.dataView,this.offset,this.parentWidth,this.byteWidth);O[j]=hr(k,j,this.dataView,this.offset,this.parentWidth,this.byteWidth,_,this.path).toObject()}return O}return this.isNull()?null:this.isBool()?this.boolValue():this.isNumber()?this.numericValue():this.blobValue()||this.stringValue()}}class Ii extends It{settings;meta;i18n;htmlservers;servers;tags;profiles;ws_messages;constructor(){super("AppStorage"),this.version(3).stores({settings:"&id",meta:"&key",i18n:"&key",htmlservers:"&key",servers:"&server_id",tags:"&tag_id",profiles:"&profile_id",ws_messages:"&key"})}}const Q=new Ii;function Pi(s){return`
8
+ <div class="flex flex-col gap-2 p-2">
9
+ <img src="${s.logo}" alt="${s.name}" class="w-12 h-12 rounded-full" />
10
+ <h3 class="text-lg font-bold">${s.name}</h3>
11
+ <p class="text-sm opacity-70">${s.summary}</p>
12
+ <a href="${s.invite}" class="text-purple-400 underline text-xs">Join Join Join</a>
13
+ </div>
14
+ `.trim()}const Ct={async storeWsMessage(s,_){const O=Ti(_).toObject();await Q.ws_messages.put({key:s,message:O})},async getWsMessage(s){return(await Q.ws_messages.get(s))?.message??null},async getAllWsMessages(){return(await Q.ws_messages.toArray()).sort((_,O)=>{const k=Number(_.key.split(":")[1]);return Number(O.key.split(":")[1])-k})},async clearWsMessages(){await Q.ws_messages.clear()},async getTranslation(s){return(await Q.i18n.get(s))?.value??null},async getTranslations(s){const _={};for(const O of s){const k=await Q.i18n.get(O);k&&(_[O]=k.value)}return _},async putI18nBatch(s){const _=Object.entries(s).map(([O,k])=>({key:O,value:k}));await Q.i18n.bulkPut(_)},async loadI18nFromJSON(s="https://discord.sh/i18n/db.json"){const O=await(await fetch(s)).json();await Ct.putI18nBatch(O)},async getAllI18nKeys(){return await Q.i18n.toCollection().primaryKeys()},async loadServersFromJSON(s="https://discord.sh/data/servers.json"){const O=await(await fetch(s)).json(),k=Object.values(O);await Ct.putServers(k),await Ct.syncHtmlFromServers()},async syncHtmlFromServers(){const s=await Q.servers.toArray(),_=await Q.htmlservers.toCollection().primaryKeys(),O=[];for(const k of s)if(!_.includes(k.server_id)){const j=Pi(k);O.push({key:k.server_id,value:j})}O.length>0?(await Q.htmlservers.bulkPut(O),console.info(`[syncHtmlFromServers] Generated ${O.length} HTML cards.`)):console.info("[syncHtmlFromServers] All servers already have HTML cards.")},async dbSet(s,_){await Q.settings.put({id:s,value:_})},async dbGet(s){return(await Q.settings.get(s))?.value??null},async dbClear(){await Q.settings.clear()},async setVersion(s){await Q.meta.put({key:"version",value:s})},async getVersion(){return(await Q.meta.get("version"))?.value??null},async markSeeded(){await Q.meta.put({key:"db_seeded",value:!0})},async checkSeeded(){return(await Q.meta.get("db_seeded"))?.value===!0},async putServers(s){await Q.servers.bulkPut(s)},async getAllServers(){return await Q.servers.toArray()},async putHtmlCards(s){await Q.htmlservers.bulkPut(s)},async getHtmlCard(s){return(await Q.htmlservers.get(s))?.value??null},async putTags(s){await Q.tags.bulkPut(s)},async getAllTags(){return await Q.tags.toArray()},async putProfiles(s){await Q.profiles.bulkPut(s)},async getAllProfiles(){return await Q.profiles.toArray()}};self.onconnect=s=>{const _=s.ports[0];_.start(),sn(Ct,_)}})();
@@ -0,0 +1,5 @@
1
+ (function(){"use strict";/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */const x=Symbol("Comlink.proxy"),N=Symbol("Comlink.endpoint"),H=Symbol("Comlink.releaseProxy"),k=Symbol("Comlink.finalizer"),b=Symbol("Comlink.thrown"),A=e=>typeof e=="object"&&e!==null||typeof e=="function",I={canHandle:e=>A(e)&&e[x],serialize(e){const{port1:t,port2:n}=new MessageChannel;return P(e,t),[n,[n]]},deserialize(e){return e.start(),D(e)}},L={canHandle:e=>A(e)&&b in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},T=new Map([["proxy",I],["throw",L]]);function V(e,t){for(const n of e)if(t===n||n==="*"||n instanceof RegExp&&n.test(t))return!0;return!1}function P(e,t=globalThis,n=["*"]){t.addEventListener("message",function y(r){if(!r||!r.data)return;if(!V(n,r.origin)){console.warn(`Invalid origin '${r.origin}' for comlink proxy`);return}const{id:a,type:g,path:l}=Object.assign({path:[]},r.data),u=(r.data.argumentList||[]).map(d);let s;try{const o=l.slice(0,-1).reduce((i,w)=>i[w],e),f=l.reduce((i,w)=>i[w],e);switch(g){case"GET":s=f;break;case"SET":o[l.slice(-1)[0]]=d(r.data.value),s=!0;break;case"APPLY":s=f.apply(o,u);break;case"CONSTRUCT":{const i=new f(...u);s=Y(i)}break;case"ENDPOINT":{const{port1:i,port2:w}=new MessageChannel;P(e,w),s=G(i,[i])}break;case"RELEASE":s=void 0;break;default:return}}catch(o){s={value:o,[b]:0}}Promise.resolve(s).catch(o=>({value:o,[b]:0})).then(o=>{const[f,i]=S(o);t.postMessage(Object.assign(Object.assign({},f),{id:a}),i),g==="RELEASE"&&(t.removeEventListener("message",y),C(t),k in e&&typeof e[k]=="function"&&e[k]())}).catch(o=>{const[f,i]=S({value:new TypeError("Unserializable return value"),[b]:0});t.postMessage(Object.assign(Object.assign({},f),{id:a}),i)})}),t.start&&t.start()}function _(e){return e.constructor.name==="MessagePort"}function C(e){_(e)&&e.close()}function D(e,t){const n=new Map;return e.addEventListener("message",function(r){const{data:a}=r;if(!a||!a.id)return;const g=n.get(a.id);if(g)try{g(a)}finally{n.delete(a.id)}}),M(e,n,[],t)}function h(e){if(e)throw new Error("Proxy has been released and is not useable")}function R(e){return m(e,new Map,{type:"RELEASE"}).then(()=>{C(e)})}const E=new WeakMap,p="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(E.get(e)||0)-1;E.set(e,t),t===0&&R(e)});function F(e,t){const n=(E.get(t)||0)+1;E.set(t,n),p&&p.register(e,t,e)}function j(e){p&&p.unregister(e)}function M(e,t,n=[],y=function(){}){let r=!1;const a=new Proxy(y,{get(g,l){if(h(r),l===H)return()=>{j(a),R(e),t.clear(),r=!0};if(l==="then"){if(n.length===0)return{then:()=>a};const u=m(e,t,{type:"GET",path:n.map(s=>s.toString())}).then(d);return u.then.bind(u)}return M(e,t,[...n,l])},set(g,l,u){h(r);const[s,o]=S(u);return m(e,t,{type:"SET",path:[...n,l].map(f=>f.toString()),value:s},o).then(d)},apply(g,l,u){h(r);const s=n[n.length-1];if(s===N)return m(e,t,{type:"ENDPOINT"}).then(d);if(s==="bind")return M(e,t,n.slice(0,-1));const[o,f]=O(u);return m(e,t,{type:"APPLY",path:n.map(i=>i.toString()),argumentList:o},f).then(d)},construct(g,l){h(r);const[u,s]=O(l);return m(e,t,{type:"CONSTRUCT",path:n.map(o=>o.toString()),argumentList:u},s).then(d)}});return F(a,e),a}function U(e){return Array.prototype.concat.apply([],e)}function O(e){const t=e.map(S);return[t.map(n=>n[0]),U(t.map(n=>n[1]))]}const W=new WeakMap;function G(e,t){return W.set(e,t),e}function Y(e){return Object.assign(e,{[x]:!0})}function S(e){for(const[t,n]of T)if(n.canHandle(e)){const[y,r]=n.serialize(e);return[{type:"HANDLER",name:t,value:y},r]}return[{type:"RAW",value:e},W.get(e)||[]]}function d(e){switch(e.type){case"HANDLER":return T.get(e.name).deserialize(e.value);case"RAW":return e.value}}function m(e,t,n,y){return new Promise(r=>{const a=q();t.set(a,r),e.start&&e.start(),e.postMessage(Object.assign({id:a},n),y)})}function q(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}let c=null,z=null;const v={async connect(e){c||(c=new WebSocket(e),c.binaryType="arraybuffer",c.onopen=()=>console.log("[WS] Connected:",e),c.onmessage=t=>{try{console.log("[WS] Received binary message"),t.data instanceof ArrayBuffer&&z?.(t.data)}catch(n){console.error("[WS] Failed to forward message",n)}},c.onerror=t=>console.error("[WS] Error:",t),c.onclose=()=>{console.log("[WS] Disconnected"),c=null})},async send(e){c?.readyState===WebSocket.OPEN?c.send(e):console.warn("[WS] Tried to send while disconnected")},async close(){c?.close(),c=null},onMessage(e){z=e}};self.onconnect=e=>{const t=e.ports[0];t.start(),P(v,t)}})();
@@ -0,0 +1,253 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ const M = Symbol("Comlink.proxy"), z = Symbol("Comlink.endpoint"), N = Symbol("Comlink.releaseProxy"), x = Symbol("Comlink.finalizer"), h = Symbol("Comlink.thrown"), S = (e) => typeof e == "object" && e !== null || typeof e == "function", H = {
7
+ canHandle: (e) => S(e) && e[M],
8
+ serialize(e) {
9
+ const { port1: t, port2: r } = new MessageChannel();
10
+ return R(e, t), [r, [r]];
11
+ },
12
+ deserialize(e) {
13
+ return e.start(), I(e);
14
+ }
15
+ }, L = {
16
+ canHandle: (e) => S(e) && h in e,
17
+ serialize({ value: e }) {
18
+ let t;
19
+ return e instanceof Error ? t = {
20
+ isError: !0,
21
+ value: {
22
+ message: e.message,
23
+ name: e.name,
24
+ stack: e.stack
25
+ }
26
+ } : t = { isError: !1, value: e }, [t, []];
27
+ },
28
+ deserialize(e) {
29
+ throw e.isError ? Object.assign(new Error(e.value.message), e.value) : e.value;
30
+ }
31
+ }, A = /* @__PURE__ */ new Map([
32
+ ["proxy", H],
33
+ ["throw", L]
34
+ ]);
35
+ function V(e, t) {
36
+ for (const r of e)
37
+ if (t === r || r === "*" || r instanceof RegExp && r.test(t))
38
+ return !0;
39
+ return !1;
40
+ }
41
+ function R(e, t = globalThis, r = ["*"]) {
42
+ t.addEventListener("message", function g(n) {
43
+ if (!n || !n.data)
44
+ return;
45
+ if (!V(r, n.origin)) {
46
+ console.warn(`Invalid origin '${n.origin}' for comlink proxy`);
47
+ return;
48
+ }
49
+ const { id: a, type: f, path: c } = Object.assign({ path: [] }, n.data), l = (n.data.argumentList || []).map(y);
50
+ let s;
51
+ try {
52
+ const o = c.slice(0, -1).reduce((i, d) => i[d], e), u = c.reduce((i, d) => i[d], e);
53
+ switch (f) {
54
+ case "GET":
55
+ s = u;
56
+ break;
57
+ case "SET":
58
+ o[c.slice(-1)[0]] = y(n.data.value), s = !0;
59
+ break;
60
+ case "APPLY":
61
+ s = u.apply(o, l);
62
+ break;
63
+ case "CONSTRUCT":
64
+ {
65
+ const i = new u(...l);
66
+ s = U(i);
67
+ }
68
+ break;
69
+ case "ENDPOINT":
70
+ {
71
+ const { port1: i, port2: d } = new MessageChannel();
72
+ R(e, d), s = F(i, [i]);
73
+ }
74
+ break;
75
+ case "RELEASE":
76
+ s = void 0;
77
+ break;
78
+ default:
79
+ return;
80
+ }
81
+ } catch (o) {
82
+ s = { value: o, [h]: 0 };
83
+ }
84
+ Promise.resolve(s).catch((o) => ({ value: o, [h]: 0 })).then((o) => {
85
+ const [u, i] = p(o);
86
+ t.postMessage(Object.assign(Object.assign({}, u), { id: a }), i), f === "RELEASE" && (t.removeEventListener("message", g), T(t), x in e && typeof e[x] == "function" && e[x]());
87
+ }).catch((o) => {
88
+ const [u, i] = p({
89
+ value: new TypeError("Unserializable return value"),
90
+ [h]: 0
91
+ });
92
+ t.postMessage(Object.assign(Object.assign({}, u), { id: a }), i);
93
+ });
94
+ }), t.start && t.start();
95
+ }
96
+ function _(e) {
97
+ return e.constructor.name === "MessagePort";
98
+ }
99
+ function T(e) {
100
+ _(e) && e.close();
101
+ }
102
+ function I(e, t) {
103
+ const r = /* @__PURE__ */ new Map();
104
+ return e.addEventListener("message", function(n) {
105
+ const { data: a } = n;
106
+ if (!a || !a.id)
107
+ return;
108
+ const f = r.get(a.id);
109
+ if (f)
110
+ try {
111
+ f(a);
112
+ } finally {
113
+ r.delete(a.id);
114
+ }
115
+ }), P(e, r, [], t);
116
+ }
117
+ function w(e) {
118
+ if (e)
119
+ throw new Error("Proxy has been released and is not useable");
120
+ }
121
+ function C(e) {
122
+ return m(e, /* @__PURE__ */ new Map(), {
123
+ type: "RELEASE"
124
+ }).then(() => {
125
+ T(e);
126
+ });
127
+ }
128
+ const E = /* @__PURE__ */ new WeakMap(), b = "FinalizationRegistry" in globalThis && new FinalizationRegistry((e) => {
129
+ const t = (E.get(e) || 0) - 1;
130
+ E.set(e, t), t === 0 && C(e);
131
+ });
132
+ function W(e, t) {
133
+ const r = (E.get(t) || 0) + 1;
134
+ E.set(t, r), b && b.register(e, t, e);
135
+ }
136
+ function j(e) {
137
+ b && b.unregister(e);
138
+ }
139
+ function P(e, t, r = [], g = function() {
140
+ }) {
141
+ let n = !1;
142
+ const a = new Proxy(g, {
143
+ get(f, c) {
144
+ if (w(n), c === N)
145
+ return () => {
146
+ j(a), C(e), t.clear(), n = !0;
147
+ };
148
+ if (c === "then") {
149
+ if (r.length === 0)
150
+ return { then: () => a };
151
+ const l = m(e, t, {
152
+ type: "GET",
153
+ path: r.map((s) => s.toString())
154
+ }).then(y);
155
+ return l.then.bind(l);
156
+ }
157
+ return P(e, t, [...r, c]);
158
+ },
159
+ set(f, c, l) {
160
+ w(n);
161
+ const [s, o] = p(l);
162
+ return m(e, t, {
163
+ type: "SET",
164
+ path: [...r, c].map((u) => u.toString()),
165
+ value: s
166
+ }, o).then(y);
167
+ },
168
+ apply(f, c, l) {
169
+ w(n);
170
+ const s = r[r.length - 1];
171
+ if (s === z)
172
+ return m(e, t, {
173
+ type: "ENDPOINT"
174
+ }).then(y);
175
+ if (s === "bind")
176
+ return P(e, t, r.slice(0, -1));
177
+ const [o, u] = k(l);
178
+ return m(e, t, {
179
+ type: "APPLY",
180
+ path: r.map((i) => i.toString()),
181
+ argumentList: o
182
+ }, u).then(y);
183
+ },
184
+ construct(f, c) {
185
+ w(n);
186
+ const [l, s] = k(c);
187
+ return m(e, t, {
188
+ type: "CONSTRUCT",
189
+ path: r.map((o) => o.toString()),
190
+ argumentList: l
191
+ }, s).then(y);
192
+ }
193
+ });
194
+ return W(a, e), a;
195
+ }
196
+ function D(e) {
197
+ return Array.prototype.concat.apply([], e);
198
+ }
199
+ function k(e) {
200
+ const t = e.map(p);
201
+ return [t.map((r) => r[0]), D(t.map((r) => r[1]))];
202
+ }
203
+ const O = /* @__PURE__ */ new WeakMap();
204
+ function F(e, t) {
205
+ return O.set(e, t), e;
206
+ }
207
+ function U(e) {
208
+ return Object.assign(e, { [M]: !0 });
209
+ }
210
+ function p(e) {
211
+ for (const [t, r] of A)
212
+ if (r.canHandle(e)) {
213
+ const [g, n] = r.serialize(e);
214
+ return [
215
+ {
216
+ type: "HANDLER",
217
+ name: t,
218
+ value: g
219
+ },
220
+ n
221
+ ];
222
+ }
223
+ return [
224
+ {
225
+ type: "RAW",
226
+ value: e
227
+ },
228
+ O.get(e) || []
229
+ ];
230
+ }
231
+ function y(e) {
232
+ switch (e.type) {
233
+ case "HANDLER":
234
+ return A.get(e.name).deserialize(e.value);
235
+ case "RAW":
236
+ return e.value;
237
+ }
238
+ }
239
+ function m(e, t, r, g) {
240
+ return new Promise((n) => {
241
+ const a = G();
242
+ t.set(a, n), e.start && e.start(), e.postMessage(Object.assign({ id: a }, r), g);
243
+ });
244
+ }
245
+ function G() {
246
+ return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
247
+ }
248
+ export {
249
+ R as e,
250
+ U as p,
251
+ F as t,
252
+ I as w
253
+ };