@ridp/threejs 1.1.0 → 1.1.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.
package/dist/hooks.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useGLTFLoader-DM3-7jdq.cjs");exports.intersectColor=e.intersectColor;exports.obbObjects=e.obbObjects;exports.useGLTFLoader=e.useGLTFLoader;exports.useObb=e.useObb;exports.useRaycaster=e.useRaycaster;exports.useThreeJs=e.useThreeJs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useGLTFLoader-D7AUuGjE.cjs");exports.intersectColor=e.intersectColor;exports.obbObjects=e.obbObjects;exports.useGLTFLoader=e.useGLTFLoader;exports.useObb=e.useObb;exports.useRaycaster=e.useRaycaster;exports.useThreeJs=e.useThreeJs;
package/dist/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as a, o, c as r, b, a as t, u } from "./useGLTFLoader-DHxBLucO.js";
1
+ import { i as a, o, c as r, b, a as t, u } from "./useGLTFLoader-C4MwALJK.js";
2
2
  export {
3
3
  a as intersectColor,
4
4
  o as obbObjects,
package/dist/threejs.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./useGLTFLoader-DM3-7jdq.cjs"),e=require("./ImageLoader-DwvBWW6h.cjs"),a=require("./common-BHi3qsZW.cjs");exports.IDBCache=r.IDBCache;exports.intersectColor=r.intersectColor;exports.obbObjects=r.obbObjects;exports.useGLTFLoader=r.useGLTFLoader;exports.useObb=r.useObb;exports.useRaycaster=r.useRaycaster;exports.useThreeJs=r.useThreeJs;exports.ImageLoader=e.ImageLoader;exports.createArrowHelper=e.createArrowHelper;exports.createAxesHelper=e.createAxesHelper;exports.createBox3Helper=e.createBox3Helper;exports.createCameraHelper=e.createCameraHelper;exports.createGridHelper=e.createGridHelper;exports.createMapControls=e.createMapControls;exports.createOrbitControl=e.createOrbitControl;exports.createRaycaster=e.createRaycaster;exports.createStats=e.createStats;exports.disposeThreeObject=e.disposeThreeObject;exports.initEnvImage=e.initEnvImage;exports.createInfoPlane=a.createInfoPlane;exports.createTagPlane=a.createTagPlane;exports.getCommonParent=a.getCommonParent;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./useGLTFLoader-D7AUuGjE.cjs"),e=require("./ImageLoader-DwvBWW6h.cjs"),a=require("./common-BHi3qsZW.cjs");exports.IDBCache=r.IDBCache;exports.intersectColor=r.intersectColor;exports.obbObjects=r.obbObjects;exports.useGLTFLoader=r.useGLTFLoader;exports.useObb=r.useObb;exports.useRaycaster=r.useRaycaster;exports.useThreeJs=r.useThreeJs;exports.ImageLoader=e.ImageLoader;exports.createArrowHelper=e.createArrowHelper;exports.createAxesHelper=e.createAxesHelper;exports.createBox3Helper=e.createBox3Helper;exports.createCameraHelper=e.createCameraHelper;exports.createGridHelper=e.createGridHelper;exports.createMapControls=e.createMapControls;exports.createOrbitControl=e.createOrbitControl;exports.createRaycaster=e.createRaycaster;exports.createStats=e.createStats;exports.disposeThreeObject=e.disposeThreeObject;exports.initEnvImage=e.initEnvImage;exports.createInfoPlane=a.createInfoPlane;exports.createTagPlane=a.createTagPlane;exports.getCommonParent=a.getCommonParent;
package/dist/threejs.js CHANGED
@@ -1,4 +1,4 @@
1
- import { I as r, i as s, o as t, c as o, b as c, a as l, u as n } from "./useGLTFLoader-DHxBLucO.js";
1
+ import { I as r, i as s, o as t, c as o, b as c, a as l, u as n } from "./useGLTFLoader-C4MwALJK.js";
2
2
  import { I as b, h as i, g as m, b as g, c as C, a as I, e as d, d as f, f as u, i as x, j as H, k as h } from "./ImageLoader-CB_URfeZ.js";
3
3
  import { c as T, a as j, g as L } from "./common-fbJUHqlj.js";
4
4
  export {
@@ -5430,8 +5430,11 @@ class oa {
5430
5430
  * @param {Object} tableDefinitions - 表定义对象,例如 { models: "&path, data" }
5431
5431
  * @param {number} version - 数据库版本号
5432
5432
  */
5433
- constructor(r = "threeJsIDBCache", i = 1) {
5434
- this.db = new Nn(r), this.materialMap = {}, this.db.version(i).stores({ models: "&path, data" });
5433
+ constructor(r = "threeJsIDBCache", i = 2) {
5434
+ this.version = i, this.dbName = r, this.dbInit();
5435
+ }
5436
+ dbInit() {
5437
+ this.db = new Nn(this.dbName), this.materialMap = {}, this.db.version(this.version).stores({ models: "&version, path, data" });
5435
5438
  }
5436
5439
  /**
5437
5440
  * 获取 Dexie 数据库实例
@@ -5575,10 +5578,15 @@ class oa {
5575
5578
  * 缓存模型到 IndexedDB
5576
5579
  * @param {string} path - 主键值
5577
5580
  * @param {THREE.Object3D} model - 要缓存的模型
5581
+ * @param {string} [version] - 缓存模型版本
5578
5582
  */
5579
- async cacheModel(r, i) {
5580
- const a = this.serObject3D(i);
5581
- await this.db.table("models").put({ path: r, data: a }), console.log(`Model "${r}" cached successfully in table models`);
5583
+ async cacheModel(r, i, a) {
5584
+ const u = this.serObject3D(i);
5585
+ try {
5586
+ await this.db.table("models").put({ version: a, path: r, data: u }), console.log(`Model "${r}" cached successfully in table models`);
5587
+ } catch {
5588
+ console.log(" 缓存模型失败 =====> ");
5589
+ }
5582
5590
  }
5583
5591
  /**
5584
5592
  * 从 IndexedDB 加载缓存的模型
@@ -5586,11 +5594,21 @@ class oa {
5586
5594
  * @returns {THREE.Object3D | null} 加载的模型
5587
5595
  */
5588
5596
  async loadCachedModel(r) {
5589
- const i = await this.db.table("models").get(r);
5590
- if (!i)
5591
- return console.warn(`Model "${r}" not found in table models`), null;
5592
- const a = this.reSerObject3D(i.data);
5593
- return console.log(`Model "${r}" loaded from table models`), a;
5597
+ let i = null;
5598
+ try {
5599
+ if (i = await this.db.table("models").get(r), !i)
5600
+ return console.warn(`Model "${r}" not found in table models`), null;
5601
+ } catch {
5602
+ return console.log(" =====> 查询表中模型失败"), this.db.delete().then(() => {
5603
+ this.init();
5604
+ }), null;
5605
+ }
5606
+ try {
5607
+ const a = this.reSerObject3D(i.data);
5608
+ return console.log(`Model "${r}" loaded from table models`), a;
5609
+ } catch (a) {
5610
+ return console.log(" =====> 模型序列号处理失败:", a), null;
5611
+ }
5594
5612
  }
5595
5613
  }
5596
5614
  let In;
@@ -5605,12 +5623,12 @@ const Ta = () => {
5605
5623
  C.load(c, p, l, h);
5606
5624
  });
5607
5625
  }
5608
- async function u(c, l) {
5626
+ async function u(c, l, p) {
5609
5627
  In || (In = new oa());
5610
- const p = await In.loadCachedModel(c);
5611
- return p || new Promise((h, y) => {
5612
- C.load(c, h, l, y);
5613
- }).then(async (h) => (await In.cacheModel(c, h.scene), h));
5628
+ const h = await In.loadCachedModel(l);
5629
+ return h || new Promise((y, E) => {
5630
+ C.load(c, y, p, E);
5631
+ }).then(async (y) => (await In.cacheModel(c, y.scene, l), y.scene));
5614
5632
  }
5615
5633
  return {
5616
5634
  load: i,
@@ -1,4 +1,4 @@
1
1
  "use strict";const x=require("three"),rt=require("vue"),Tn=require("./ImageLoader-DwvBWW6h.cjs");function Xi(L){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(L){for(const s in L)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(L,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:()=>L[s]})}}return r.default=L,Object.freeze(r)}const yt=Xi(x);function ti(L,r){if(r===x.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),L;if(r===x.TriangleFanDrawMode||r===x.TriangleStripDrawMode){let s=L.getIndex();if(s===null){const l=[],p=L.getAttribute("position");if(p!==void 0){for(let h=0;h<p.count;h++)l.push(h);L.setIndex(l),s=L.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),L}const a=s.count-2,u=[];if(r===x.TriangleFanDrawMode)for(let l=1;l<=a;l++)u.push(s.getX(0)),u.push(s.getX(l)),u.push(s.getX(l+1));else for(let l=0;l<a;l++)l%2===0?(u.push(s.getX(l)),u.push(s.getX(l+1)),u.push(s.getX(l+2))):(u.push(s.getX(l+2)),u.push(s.getX(l+1)),u.push(s.getX(l)));u.length/3!==a&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const c=L.clone();return c.setIndex(u),c.clearGroups(),c}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",r),L}const hr=new WeakMap;class Wi extends x.Loader{constructor(r){super(r),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(r){return this.decoderPath=r,this}setDecoderConfig(r){return this.decoderConfig=r,this}setWorkerLimit(r){return this.workerLimit=r,this}load(r,s,a,u){const c=new x.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(r,l=>{this.parse(l,s,u)},a,u)}parse(r,s,a=()=>{}){this.decodeDracoFile(r,s,null,null,x.SRGBColorSpace,a).catch(a)}decodeDracoFile(r,s,a,u,c=x.LinearSRGBColorSpace,l=()=>{}){const p={attributeIDs:a||this.defaultAttributeIDs,attributeTypes:u||this.defaultAttributeTypes,useUniqueIDs:!!a,vertexColorSpace:c};return this.decodeGeometry(r,p).then(s).catch(l)}decodeGeometry(r,s){const a=JSON.stringify(s);if(hr.has(r)){const h=hr.get(r);if(h.key===a)return h.promise;if(r.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let u;const c=this.workerNextTaskID++,l=r.byteLength,p=this._getWorker(c,l).then(h=>(u=h,new Promise((y,E)=>{u._callbacks[c]={resolve:y,reject:E},u.postMessage({type:"decode",id:c,taskConfig:s,buffer:r},[r])}))).then(h=>this._createGeometry(h.geometry));return p.catch(()=>!0).then(()=>{u&&c&&this._releaseTask(u,c)}),hr.set(r,{key:a,promise:p}),p}_createGeometry(r){const s=new x.BufferGeometry;r.index&&s.setIndex(new x.BufferAttribute(r.index.array,1));for(let a=0;a<r.attributes.length;a++){const u=r.attributes[a],c=u.name,l=u.array,p=u.itemSize,h=new x.BufferAttribute(l,p);c==="color"&&(this._assignVertexColorSpace(h,u.vertexColorSpace),h.normalized=!(l instanceof Float32Array)),s.setAttribute(c,h)}return s}_assignVertexColorSpace(r,s){if(s!==x.SRGBColorSpace)return;const a=new x.Color;for(let u=0,c=r.count;u<c;u++)a.fromBufferAttribute(r,u),x.ColorManagement.toWorkingColorSpace(a,x.SRGBColorSpace),r.setXYZ(u,a.r,a.g,a.b)}_loadLibrary(r,s){const a=new x.FileLoader(this.manager);return a.setPath(this.decoderPath),a.setResponseType(s),a.setWithCredentials(this.withCredentials),new Promise((u,c)=>{a.load(r,u,void 0,c)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const r=typeof WebAssembly!="object"||this.decoderConfig.type==="js",s=[];return r?s.push(this._loadLibrary("draco_decoder.js","text")):(s.push(this._loadLibrary("draco_wasm_wrapper.js","text")),s.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(s).then(a=>{const u=a[0];r||(this.decoderConfig.wasmBinary=a[1]);const c=Yi.toString(),l=["/* draco decoder */",u,"","/* worker */",c.substring(c.indexOf("{")+1,c.lastIndexOf("}"))].join(`
2
2
  `);this.workerSourceURL=URL.createObjectURL(new Blob([l]))}),this.decoderPending}_getWorker(r,s){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const u=new Worker(this.workerSourceURL);u._callbacks={},u._taskCosts={},u._taskLoad=0,u.postMessage({type:"init",decoderConfig:this.decoderConfig}),u.onmessage=function(c){const l=c.data;switch(l.type){case"decode":u._callbacks[l.id].resolve(l);break;case"error":u._callbacks[l.id].reject(l);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+l.type+'"')}},this.workerPool.push(u)}else this.workerPool.sort(function(u,c){return u._taskLoad>c._taskLoad?-1:1});const a=this.workerPool[this.workerPool.length-1];return a._taskCosts[r]=s,a._taskLoad+=s,a})}_releaseTask(r,s){r._taskLoad-=r._taskCosts[s],delete r._callbacks[s],delete r._taskCosts[s]}debug(){console.log("Task load: ",this.workerPool.map(r=>r._taskLoad))}dispose(){for(let r=0;r<this.workerPool.length;++r)this.workerPool[r].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Yi(){let L,r;onmessage=function(l){const p=l.data;switch(p.type){case"init":L=p.decoderConfig,r=new Promise(function(E){L.onModuleLoaded=function(_){E({draco:_})},DracoDecoderModule(L)});break;case"decode":const h=p.buffer,y=p.taskConfig;r.then(E=>{const _=E.draco,P=new _.Decoder;try{const D=s(_,P,new Int8Array(h),y),q=D.attributes.map(W=>W.array.buffer);D.index&&q.push(D.index.array.buffer),self.postMessage({type:"decode",id:p.id,geometry:D},q)}catch(D){console.error(D),self.postMessage({type:"error",id:p.id,error:D.message})}finally{_.destroy(P)}});break}};function s(l,p,h,y){const E=y.attributeIDs,_=y.attributeTypes;let P,D;const q=p.GetEncodedGeometryType(h);if(q===l.TRIANGULAR_MESH)P=new l.Mesh,D=p.DecodeArrayToMesh(h,h.byteLength,P);else if(q===l.POINT_CLOUD)P=new l.PointCloud,D=p.DecodeArrayToPointCloud(h,h.byteLength,P);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!D.ok()||P.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+D.error_msg());const W={index:null,attributes:[]};for(const z in E){const Y=self[_[z]];let ee,ae;if(y.useUniqueIDs)ae=E[z],ee=p.GetAttributeByUniqueId(P,ae);else{if(ae=p.GetAttributeId(P,l[E[z]]),ae===-1)continue;ee=p.GetAttribute(P,ae)}const Z=u(l,p,P,z,Y,ee);z==="color"&&(Z.vertexColorSpace=y.vertexColorSpace),W.attributes.push(Z)}return q===l.TRIANGULAR_MESH&&(W.index=a(l,p,P)),l.destroy(P),W}function a(l,p,h){const E=h.num_faces()*3,_=E*4,P=l._malloc(_);p.GetTrianglesUInt32Array(h,_,P);const D=new Uint32Array(l.HEAPF32.buffer,P,E).slice();return l._free(P),{array:D,itemSize:1}}function u(l,p,h,y,E,_){const P=_.num_components(),q=h.num_points()*P,W=q*E.BYTES_PER_ELEMENT,z=c(l,E),Y=l._malloc(W);p.GetAttributeDataArrayForAllPoints(h,_,z,W,Y);const ee=new E(l.HEAPF32.buffer,Y,q).slice();return l._free(Y),{name:y,array:ee,itemSize:P}}function c(l,p){switch(p){case Float32Array:return l.DT_FLOAT32;case Int8Array:return l.DT_INT8;case Int16Array:return l.DT_INT16;case Int32Array:return l.DT_INT32;case Uint8Array:return l.DT_UINT8;case Uint16Array:return l.DT_UINT16;case Uint32Array:return l.DT_UINT32}}}class Qi extends x.Loader{constructor(r){super(r),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(s){return new ts(s)}),this.register(function(s){return new ns(s)}),this.register(function(s){return new fs(s)}),this.register(function(s){return new hs(s)}),this.register(function(s){return new ds(s)}),this.register(function(s){return new is(s)}),this.register(function(s){return new ss(s)}),this.register(function(s){return new os(s)}),this.register(function(s){return new as(s)}),this.register(function(s){return new es(s)}),this.register(function(s){return new us(s)}),this.register(function(s){return new rs(s)}),this.register(function(s){return new ls(s)}),this.register(function(s){return new cs(s)}),this.register(function(s){return new Ji(s)}),this.register(function(s){return new ps(s)}),this.register(function(s){return new ms(s)})}load(r,s,a,u){const c=this;let l;if(this.resourcePath!=="")l=this.resourcePath;else if(this.path!==""){const y=x.LoaderUtils.extractUrlBase(r);l=x.LoaderUtils.resolveURL(y,this.path)}else l=x.LoaderUtils.extractUrlBase(r);this.manager.itemStart(r);const p=function(y){u?u(y):console.error(y),c.manager.itemError(r),c.manager.itemEnd(r)},h=new x.FileLoader(this.manager);h.setPath(this.path),h.setResponseType("arraybuffer"),h.setRequestHeader(this.requestHeader),h.setWithCredentials(this.withCredentials),h.load(r,function(y){try{c.parse(y,l,function(E){s(E),c.manager.itemEnd(r)},p)}catch(E){p(E)}},a,p)}setDRACOLoader(r){return this.dracoLoader=r,this}setKTX2Loader(r){return this.ktx2Loader=r,this}setMeshoptDecoder(r){return this.meshoptDecoder=r,this}register(r){return this.pluginCallbacks.indexOf(r)===-1&&this.pluginCallbacks.push(r),this}unregister(r){return this.pluginCallbacks.indexOf(r)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(r),1),this}parse(r,s,a,u){let c;const l={},p={},h=new TextDecoder;if(typeof r=="string")c=JSON.parse(r);else if(r instanceof ArrayBuffer)if(h.decode(new Uint8Array(r,0,4))===di){try{l[re.KHR_BINARY_GLTF]=new ys(r)}catch(_){u&&u(_);return}c=JSON.parse(l[re.KHR_BINARY_GLTF].content)}else c=JSON.parse(h.decode(r));else c=r;if(c.asset===void 0||c.asset.version[0]<2){u&&u(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const y=new Ms(c,{path:s||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});y.fileLoader.setRequestHeader(this.requestHeader);for(let E=0;E<this.pluginCallbacks.length;E++){const _=this.pluginCallbacks[E](y);_.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),p[_.name]=_,l[_.name]=!0}if(c.extensionsUsed)for(let E=0;E<c.extensionsUsed.length;++E){const _=c.extensionsUsed[E],P=c.extensionsRequired||[];switch(_){case re.KHR_MATERIALS_UNLIT:l[_]=new Zi;break;case re.KHR_DRACO_MESH_COMPRESSION:l[_]=new gs(c,this.dracoLoader);break;case re.KHR_TEXTURE_TRANSFORM:l[_]=new vs;break;case re.KHR_MESH_QUANTIZATION:l[_]=new bs;break;default:P.indexOf(_)>=0&&p[_]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+_+'".')}}y.setExtensions(l),y.setPlugins(p),y.parse(a,u)}parseAsync(r,s){const a=this;return new Promise(function(u,c){a.parse(r,s,u,c)})}}function $i(){let L={};return{get:function(r){return L[r]},add:function(r,s){L[r]=s},remove:function(r){delete L[r]},removeAll:function(){L={}}}}const re={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Ji{constructor(r){this.parser=r,this.name=re.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const r=this.parser,s=this.parser.json.nodes||[];for(let a=0,u=s.length;a<u;a++){const c=s[a];c.extensions&&c.extensions[this.name]&&c.extensions[this.name].light!==void 0&&r._addNodeRef(this.cache,c.extensions[this.name].light)}}_loadLight(r){const s=this.parser,a="light:"+r;let u=s.cache.get(a);if(u)return u;const c=s.json,h=((c.extensions&&c.extensions[this.name]||{}).lights||[])[r];let y;const E=new x.Color(16777215);h.color!==void 0&&E.setRGB(h.color[0],h.color[1],h.color[2],x.LinearSRGBColorSpace);const _=h.range!==void 0?h.range:0;switch(h.type){case"directional":y=new x.DirectionalLight(E),y.target.position.set(0,0,-1),y.add(y.target);break;case"point":y=new x.PointLight(E),y.distance=_;break;case"spot":y=new x.SpotLight(E),y.distance=_,h.spot=h.spot||{},h.spot.innerConeAngle=h.spot.innerConeAngle!==void 0?h.spot.innerConeAngle:0,h.spot.outerConeAngle=h.spot.outerConeAngle!==void 0?h.spot.outerConeAngle:Math.PI/4,y.angle=h.spot.outerConeAngle,y.penumbra=1-h.spot.innerConeAngle/h.spot.outerConeAngle,y.target.position.set(0,0,-1),y.add(y.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+h.type)}return y.position.set(0,0,0),Xe(y,h),h.intensity!==void 0&&(y.intensity=h.intensity),y.name=s.createUniqueName(h.name||"light_"+r),u=Promise.resolve(y),s.cache.add(a,u),u}getDependency(r,s){if(r==="light")return this._loadLight(s)}createNodeAttachment(r){const s=this,a=this.parser,c=a.json.nodes[r],p=(c.extensions&&c.extensions[this.name]||{}).light;return p===void 0?null:this._loadLight(p).then(function(h){return a._getNodeRef(s.cache,p,h)})}}class Zi{constructor(){this.name=re.KHR_MATERIALS_UNLIT}getMaterialType(){return x.MeshBasicMaterial}extendParams(r,s,a){const u=[];r.color=new x.Color(1,1,1),r.opacity=1;const c=s.pbrMetallicRoughness;if(c){if(Array.isArray(c.baseColorFactor)){const l=c.baseColorFactor;r.color.setRGB(l[0],l[1],l[2],x.LinearSRGBColorSpace),r.opacity=l[3]}c.baseColorTexture!==void 0&&u.push(a.assignTexture(r,"map",c.baseColorTexture,x.SRGBColorSpace))}return Promise.all(u)}}class es{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(r,s){const u=this.parser.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=u.extensions[this.name].emissiveStrength;return c!==void 0&&(s.emissiveIntensity=c),Promise.resolve()}}class ts{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_CLEARCOAT}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const a=this.parser,u=a.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];if(l.clearcoatFactor!==void 0&&(s.clearcoat=l.clearcoatFactor),l.clearcoatTexture!==void 0&&c.push(a.assignTexture(s,"clearcoatMap",l.clearcoatTexture)),l.clearcoatRoughnessFactor!==void 0&&(s.clearcoatRoughness=l.clearcoatRoughnessFactor),l.clearcoatRoughnessTexture!==void 0&&c.push(a.assignTexture(s,"clearcoatRoughnessMap",l.clearcoatRoughnessTexture)),l.clearcoatNormalTexture!==void 0&&(c.push(a.assignTexture(s,"clearcoatNormalMap",l.clearcoatNormalTexture)),l.clearcoatNormalTexture.scale!==void 0)){const p=l.clearcoatNormalTexture.scale;s.clearcoatNormalScale=new x.Vector2(p,p)}return Promise.all(c)}}class ns{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_DISPERSION}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const u=this.parser.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=u.extensions[this.name];return s.dispersion=c.dispersion!==void 0?c.dispersion:0,Promise.resolve()}}class rs{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_IRIDESCENCE}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const a=this.parser,u=a.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];return l.iridescenceFactor!==void 0&&(s.iridescence=l.iridescenceFactor),l.iridescenceTexture!==void 0&&c.push(a.assignTexture(s,"iridescenceMap",l.iridescenceTexture)),l.iridescenceIor!==void 0&&(s.iridescenceIOR=l.iridescenceIor),s.iridescenceThicknessRange===void 0&&(s.iridescenceThicknessRange=[100,400]),l.iridescenceThicknessMinimum!==void 0&&(s.iridescenceThicknessRange[0]=l.iridescenceThicknessMinimum),l.iridescenceThicknessMaximum!==void 0&&(s.iridescenceThicknessRange[1]=l.iridescenceThicknessMaximum),l.iridescenceThicknessTexture!==void 0&&c.push(a.assignTexture(s,"iridescenceThicknessMap",l.iridescenceThicknessTexture)),Promise.all(c)}}class is{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_SHEEN}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const a=this.parser,u=a.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[];s.sheenColor=new x.Color(0,0,0),s.sheenRoughness=0,s.sheen=1;const l=u.extensions[this.name];if(l.sheenColorFactor!==void 0){const p=l.sheenColorFactor;s.sheenColor.setRGB(p[0],p[1],p[2],x.LinearSRGBColorSpace)}return l.sheenRoughnessFactor!==void 0&&(s.sheenRoughness=l.sheenRoughnessFactor),l.sheenColorTexture!==void 0&&c.push(a.assignTexture(s,"sheenColorMap",l.sheenColorTexture,x.SRGBColorSpace)),l.sheenRoughnessTexture!==void 0&&c.push(a.assignTexture(s,"sheenRoughnessMap",l.sheenRoughnessTexture)),Promise.all(c)}}class ss{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_TRANSMISSION}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const a=this.parser,u=a.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];return l.transmissionFactor!==void 0&&(s.transmission=l.transmissionFactor),l.transmissionTexture!==void 0&&c.push(a.assignTexture(s,"transmissionMap",l.transmissionTexture)),Promise.all(c)}}class os{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_VOLUME}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const a=this.parser,u=a.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];s.thickness=l.thicknessFactor!==void 0?l.thicknessFactor:0,l.thicknessTexture!==void 0&&c.push(a.assignTexture(s,"thicknessMap",l.thicknessTexture)),s.attenuationDistance=l.attenuationDistance||1/0;const p=l.attenuationColor||[1,1,1];return s.attenuationColor=new x.Color().setRGB(p[0],p[1],p[2],x.LinearSRGBColorSpace),Promise.all(c)}}class as{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_IOR}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const u=this.parser.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=u.extensions[this.name];return s.ior=c.ior!==void 0?c.ior:1.5,Promise.resolve()}}class us{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_SPECULAR}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const a=this.parser,u=a.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];s.specularIntensity=l.specularFactor!==void 0?l.specularFactor:1,l.specularTexture!==void 0&&c.push(a.assignTexture(s,"specularIntensityMap",l.specularTexture));const p=l.specularColorFactor||[1,1,1];return s.specularColor=new x.Color().setRGB(p[0],p[1],p[2],x.LinearSRGBColorSpace),l.specularColorTexture!==void 0&&c.push(a.assignTexture(s,"specularColorMap",l.specularColorTexture,x.SRGBColorSpace)),Promise.all(c)}}class cs{constructor(r){this.parser=r,this.name=re.EXT_MATERIALS_BUMP}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const a=this.parser,u=a.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];return s.bumpScale=l.bumpFactor!==void 0?l.bumpFactor:1,l.bumpTexture!==void 0&&c.push(a.assignTexture(s,"bumpMap",l.bumpTexture)),Promise.all(c)}}class ls{constructor(r){this.parser=r,this.name=re.KHR_MATERIALS_ANISOTROPY}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:x.MeshPhysicalMaterial}extendMaterialParams(r,s){const a=this.parser,u=a.json.materials[r];if(!u.extensions||!u.extensions[this.name])return Promise.resolve();const c=[],l=u.extensions[this.name];return l.anisotropyStrength!==void 0&&(s.anisotropy=l.anisotropyStrength),l.anisotropyRotation!==void 0&&(s.anisotropyRotation=l.anisotropyRotation),l.anisotropyTexture!==void 0&&c.push(a.assignTexture(s,"anisotropyMap",l.anisotropyTexture)),Promise.all(c)}}class fs{constructor(r){this.parser=r,this.name=re.KHR_TEXTURE_BASISU}loadTexture(r){const s=this.parser,a=s.json,u=a.textures[r];if(!u.extensions||!u.extensions[this.name])return null;const c=u.extensions[this.name],l=s.options.ktx2Loader;if(!l){if(a.extensionsRequired&&a.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return s.loadTextureImage(r,c.source,l)}}class hs{constructor(r){this.parser=r,this.name=re.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(r){const s=this.name,a=this.parser,u=a.json,c=u.textures[r];if(!c.extensions||!c.extensions[s])return null;const l=c.extensions[s],p=u.images[l.source];let h=a.textureLoader;if(p.uri){const y=a.options.manager.getHandler(p.uri);y!==null&&(h=y)}return this.detectSupport().then(function(y){if(y)return a.loadTextureImage(r,l.source,h);if(u.extensionsRequired&&u.extensionsRequired.indexOf(s)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return a.loadTexture(r)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(r){const s=new Image;s.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",s.onload=s.onerror=function(){r(s.height===1)}})),this.isSupported}}class ds{constructor(r){this.parser=r,this.name=re.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(r){const s=this.name,a=this.parser,u=a.json,c=u.textures[r];if(!c.extensions||!c.extensions[s])return null;const l=c.extensions[s],p=u.images[l.source];let h=a.textureLoader;if(p.uri){const y=a.options.manager.getHandler(p.uri);y!==null&&(h=y)}return this.detectSupport().then(function(y){if(y)return a.loadTextureImage(r,l.source,h);if(u.extensionsRequired&&u.extensionsRequired.indexOf(s)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return a.loadTexture(r)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(r){const s=new Image;s.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",s.onload=s.onerror=function(){r(s.height===1)}})),this.isSupported}}class ps{constructor(r){this.name=re.EXT_MESHOPT_COMPRESSION,this.parser=r}loadBufferView(r){const s=this.parser.json,a=s.bufferViews[r];if(a.extensions&&a.extensions[this.name]){const u=a.extensions[this.name],c=this.parser.getDependency("buffer",u.buffer),l=this.parser.options.meshoptDecoder;if(!l||!l.supported){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return c.then(function(p){const h=u.byteOffset||0,y=u.byteLength||0,E=u.count,_=u.byteStride,P=new Uint8Array(p,h,y);return l.decodeGltfBufferAsync?l.decodeGltfBufferAsync(E,_,P,u.mode,u.filter).then(function(D){return D.buffer}):l.ready.then(function(){const D=new ArrayBuffer(E*_);return l.decodeGltfBuffer(new Uint8Array(D),E,_,P,u.mode,u.filter),D})})}else return null}}class ms{constructor(r){this.name=re.EXT_MESH_GPU_INSTANCING,this.parser=r}createNodeMesh(r){const s=this.parser.json,a=s.nodes[r];if(!a.extensions||!a.extensions[this.name]||a.mesh===void 0)return null;const u=s.meshes[a.mesh];for(const y of u.primitives)if(y.mode!==Le.TRIANGLES&&y.mode!==Le.TRIANGLE_STRIP&&y.mode!==Le.TRIANGLE_FAN&&y.mode!==void 0)return null;const l=a.extensions[this.name].attributes,p=[],h={};for(const y in l)p.push(this.parser.getDependency("accessor",l[y]).then(E=>(h[y]=E,h[y])));return p.length<1?null:(p.push(this.parser.createNodeMesh(r)),Promise.all(p).then(y=>{const E=y.pop(),_=E.isGroup?E.children:[E],P=y[0].count,D=[];for(const q of _){const W=new x.Matrix4,z=new x.Vector3,Y=new x.Quaternion,ee=new x.Vector3(1,1,1),ae=new x.InstancedMesh(q.geometry,q.material,P);for(let Z=0;Z<P;Z++)h.TRANSLATION&&z.fromBufferAttribute(h.TRANSLATION,Z),h.ROTATION&&Y.fromBufferAttribute(h.ROTATION,Z),h.SCALE&&ee.fromBufferAttribute(h.SCALE,Z),ae.setMatrixAt(Z,W.compose(z,Y,ee));for(const Z in h)if(Z==="_COLOR_0"){const Ae=h[Z];ae.instanceColor=new x.InstancedBufferAttribute(Ae.array,Ae.itemSize,Ae.normalized)}else Z!=="TRANSLATION"&&Z!=="ROTATION"&&Z!=="SCALE"&&q.geometry.setAttribute(Z,h[Z]);x.Object3D.prototype.copy.call(ae,q),this.parser.assignFinalMaterial(ae),D.push(ae)}return E.isGroup?(E.clear(),E.add(...D),E):D[0]}))}}const di="glTF",Xt=12,ni={JSON:1313821514,BIN:5130562};class ys{constructor(r){this.name=re.KHR_BINARY_GLTF,this.content=null,this.body=null;const s=new DataView(r,0,Xt),a=new TextDecoder;if(this.header={magic:a.decode(new Uint8Array(r.slice(0,4))),version:s.getUint32(4,!0),length:s.getUint32(8,!0)},this.header.magic!==di)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const u=this.header.length-Xt,c=new DataView(r,Xt);let l=0;for(;l<u;){const p=c.getUint32(l,!0);l+=4;const h=c.getUint32(l,!0);if(l+=4,h===ni.JSON){const y=new Uint8Array(r,Xt+l,p);this.content=a.decode(y)}else if(h===ni.BIN){const y=Xt+l;this.body=r.slice(y,y+p)}l+=p}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class gs{constructor(r,s){if(!s)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=re.KHR_DRACO_MESH_COMPRESSION,this.json=r,this.dracoLoader=s,this.dracoLoader.preload()}decodePrimitive(r,s){const a=this.json,u=this.dracoLoader,c=r.extensions[this.name].bufferView,l=r.extensions[this.name].attributes,p={},h={},y={};for(const E in l){const _=yr[E]||E.toLowerCase();p[_]=l[E]}for(const E in r.attributes){const _=yr[E]||E.toLowerCase();if(l[E]!==void 0){const P=a.accessors[r.attributes[E]],D=Ct[P.componentType];y[_]=D.name,h[_]=P.normalized===!0}}return s.getDependency("bufferView",c).then(function(E){return new Promise(function(_,P){u.decodeDracoFile(E,function(D){for(const q in D.attributes){const W=D.attributes[q],z=h[q];z!==void 0&&(W.normalized=z)}_(D)},p,y,x.LinearSRGBColorSpace,P)})})}}class vs{constructor(){this.name=re.KHR_TEXTURE_TRANSFORM}extendTexture(r,s){return(s.texCoord===void 0||s.texCoord===r.channel)&&s.offset===void 0&&s.rotation===void 0&&s.scale===void 0||(r=r.clone(),s.texCoord!==void 0&&(r.channel=s.texCoord),s.offset!==void 0&&r.offset.fromArray(s.offset),s.rotation!==void 0&&(r.rotation=s.rotation),s.scale!==void 0&&r.repeat.fromArray(s.scale),r.needsUpdate=!0),r}}class bs{constructor(){this.name=re.KHR_MESH_QUANTIZATION}}class pi extends x.Interpolant{constructor(r,s,a,u){super(r,s,a,u)}copySampleValue_(r){const s=this.resultBuffer,a=this.sampleValues,u=this.valueSize,c=r*u*3+u;for(let l=0;l!==u;l++)s[l]=a[c+l];return s}interpolate_(r,s,a,u){const c=this.resultBuffer,l=this.sampleValues,p=this.valueSize,h=p*2,y=p*3,E=u-s,_=(a-s)/E,P=_*_,D=P*_,q=r*y,W=q-y,z=-2*D+3*P,Y=D-P,ee=1-z,ae=Y-P+_;for(let Z=0;Z!==p;Z++){const Ae=l[W+Z+p],ve=l[W+Z+h]*E,le=l[q+Z+p],Be=l[q+Z]*E;c[Z]=ee*Ae+ae*ve+z*le+Y*Be}return c}}const ws=new x.Quaternion;class _s extends pi{interpolate_(r,s,a,u){const c=super.interpolate_(r,s,a,u);return ws.fromArray(c).normalize().toArray(c),c}}const Le={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Ct={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ri={9728:x.NearestFilter,9729:x.LinearFilter,9984:x.NearestMipmapNearestFilter,9985:x.LinearMipmapNearestFilter,9986:x.NearestMipmapLinearFilter,9987:x.LinearMipmapLinearFilter},ii={33071:x.ClampToEdgeWrapping,33648:x.MirroredRepeatWrapping,10497:x.RepeatWrapping},dr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yr={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},it={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},As={CUBICSPLINE:void 0,LINEAR:x.InterpolateLinear,STEP:x.InterpolateDiscrete},pr={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function xs(L){return L.DefaultMaterial===void 0&&(L.DefaultMaterial=new x.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:x.FrontSide})),L.DefaultMaterial}function gt(L,r,s){for(const a in s.extensions)L[a]===void 0&&(r.userData.gltfExtensions=r.userData.gltfExtensions||{},r.userData.gltfExtensions[a]=s.extensions[a])}function Xe(L,r){r.extras!==void 0&&(typeof r.extras=="object"?Object.assign(L.userData,r.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+r.extras))}function Ts(L,r,s){let a=!1,u=!1,c=!1;for(let y=0,E=r.length;y<E;y++){const _=r[y];if(_.POSITION!==void 0&&(a=!0),_.NORMAL!==void 0&&(u=!0),_.COLOR_0!==void 0&&(c=!0),a&&u&&c)break}if(!a&&!u&&!c)return Promise.resolve(L);const l=[],p=[],h=[];for(let y=0,E=r.length;y<E;y++){const _=r[y];if(a){const P=_.POSITION!==void 0?s.getDependency("accessor",_.POSITION):L.attributes.position;l.push(P)}if(u){const P=_.NORMAL!==void 0?s.getDependency("accessor",_.NORMAL):L.attributes.normal;p.push(P)}if(c){const P=_.COLOR_0!==void 0?s.getDependency("accessor",_.COLOR_0):L.attributes.color;h.push(P)}}return Promise.all([Promise.all(l),Promise.all(p),Promise.all(h)]).then(function(y){const E=y[0],_=y[1],P=y[2];return a&&(L.morphAttributes.position=E),u&&(L.morphAttributes.normal=_),c&&(L.morphAttributes.color=P),L.morphTargetsRelative=!0,L})}function Ss(L,r){if(L.updateMorphTargets(),r.weights!==void 0)for(let s=0,a=r.weights.length;s<a;s++)L.morphTargetInfluences[s]=r.weights[s];if(r.extras&&Array.isArray(r.extras.targetNames)){const s=r.extras.targetNames;if(L.morphTargetInfluences.length===s.length){L.morphTargetDictionary={};for(let a=0,u=s.length;a<u;a++)L.morphTargetDictionary[s[a]]=a}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Es(L){let r;const s=L.extensions&&L.extensions[re.KHR_DRACO_MESH_COMPRESSION];if(s?r="draco:"+s.bufferView+":"+s.indices+":"+mr(s.attributes):r=L.indices+":"+mr(L.attributes)+":"+L.mode,L.targets!==void 0)for(let a=0,u=L.targets.length;a<u;a++)r+=":"+mr(L.targets[a]);return r}function mr(L){let r="";const s=Object.keys(L).sort();for(let a=0,u=s.length;a<u;a++)r+=s[a]+":"+L[s[a]]+";";return r}function gr(L){switch(L){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Rs(L){return L.search(/\.jpe?g($|\?)/i)>0||L.search(/^data\:image\/jpeg/)===0?"image/jpeg":L.search(/\.webp($|\?)/i)>0||L.search(/^data\:image\/webp/)===0?"image/webp":L.search(/\.ktx2($|\?)/i)>0||L.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const ks=new x.Matrix4;class Ms{constructor(r={},s={}){this.json=r,this.extensions={},this.plugins={},this.options=s,this.cache=new $i,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let a=!1,u=-1,c=!1,l=-1;if(typeof navigator<"u"){const p=navigator.userAgent;a=/^((?!chrome|android).)*safari/i.test(p)===!0;const h=p.match(/Version\/(\d+)/);u=a&&h?parseInt(h[1],10):-1,c=p.indexOf("Firefox")>-1,l=c?p.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||a&&u<17||c&&l<98?this.textureLoader=new x.TextureLoader(this.options.manager):this.textureLoader=new x.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new x.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(r){this.extensions=r}setPlugins(r){this.plugins=r}parse(r,s){const a=this,u=this.json,c=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(l){return l._markDefs&&l._markDefs()}),Promise.all(this._invokeAll(function(l){return l.beforeRoot&&l.beforeRoot()})).then(function(){return Promise.all([a.getDependencies("scene"),a.getDependencies("animation"),a.getDependencies("camera")])}).then(function(l){const p={scene:l[0][u.scene||0],scenes:l[0],animations:l[1],cameras:l[2],asset:u.asset,parser:a,userData:{}};return gt(c,p,u),Xe(p,u),Promise.all(a._invokeAll(function(h){return h.afterRoot&&h.afterRoot(p)})).then(function(){for(const h of p.scenes)h.updateMatrixWorld();r(p)})}).catch(s)}_markDefs(){const r=this.json.nodes||[],s=this.json.skins||[],a=this.json.meshes||[];for(let u=0,c=s.length;u<c;u++){const l=s[u].joints;for(let p=0,h=l.length;p<h;p++)r[l[p]].isBone=!0}for(let u=0,c=r.length;u<c;u++){const l=r[u];l.mesh!==void 0&&(this._addNodeRef(this.meshCache,l.mesh),l.skin!==void 0&&(a[l.mesh].isSkinnedMesh=!0)),l.camera!==void 0&&this._addNodeRef(this.cameraCache,l.camera)}}_addNodeRef(r,s){s!==void 0&&(r.refs[s]===void 0&&(r.refs[s]=r.uses[s]=0),r.refs[s]++)}_getNodeRef(r,s,a){if(r.refs[s]<=1)return a;const u=a.clone(),c=(l,p)=>{const h=this.associations.get(l);h!=null&&this.associations.set(p,h);for(const[y,E]of l.children.entries())c(E,p.children[y])};return c(a,u),u.name+="_instance_"+r.uses[s]++,u}_invokeOne(r){const s=Object.values(this.plugins);s.push(this);for(let a=0;a<s.length;a++){const u=r(s[a]);if(u)return u}return null}_invokeAll(r){const s=Object.values(this.plugins);s.unshift(this);const a=[];for(let u=0;u<s.length;u++){const c=r(s[u]);c&&a.push(c)}return a}getDependency(r,s){const a=r+":"+s;let u=this.cache.get(a);if(!u){switch(r){case"scene":u=this.loadScene(s);break;case"node":u=this._invokeOne(function(c){return c.loadNode&&c.loadNode(s)});break;case"mesh":u=this._invokeOne(function(c){return c.loadMesh&&c.loadMesh(s)});break;case"accessor":u=this.loadAccessor(s);break;case"bufferView":u=this._invokeOne(function(c){return c.loadBufferView&&c.loadBufferView(s)});break;case"buffer":u=this.loadBuffer(s);break;case"material":u=this._invokeOne(function(c){return c.loadMaterial&&c.loadMaterial(s)});break;case"texture":u=this._invokeOne(function(c){return c.loadTexture&&c.loadTexture(s)});break;case"skin":u=this.loadSkin(s);break;case"animation":u=this._invokeOne(function(c){return c.loadAnimation&&c.loadAnimation(s)});break;case"camera":u=this.loadCamera(s);break;default:if(u=this._invokeOne(function(c){return c!=this&&c.getDependency&&c.getDependency(r,s)}),!u)throw new Error("Unknown type: "+r);break}this.cache.add(a,u)}return u}getDependencies(r){let s=this.cache.get(r);if(!s){const a=this,u=this.json[r+(r==="mesh"?"es":"s")]||[];s=Promise.all(u.map(function(c,l){return a.getDependency(r,l)})),this.cache.add(r,s)}return s}loadBuffer(r){const s=this.json.buffers[r],a=this.fileLoader;if(s.type&&s.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+s.type+" buffer type is not supported.");if(s.uri===void 0&&r===0)return Promise.resolve(this.extensions[re.KHR_BINARY_GLTF].body);const u=this.options;return new Promise(function(c,l){a.load(x.LoaderUtils.resolveURL(s.uri,u.path),c,void 0,function(){l(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))})})}loadBufferView(r){const s=this.json.bufferViews[r];return this.getDependency("buffer",s.buffer).then(function(a){const u=s.byteLength||0,c=s.byteOffset||0;return a.slice(c,c+u)})}loadAccessor(r){const s=this,a=this.json,u=this.json.accessors[r];if(u.bufferView===void 0&&u.sparse===void 0){const l=dr[u.type],p=Ct[u.componentType],h=u.normalized===!0,y=new p(u.count*l);return Promise.resolve(new x.BufferAttribute(y,l,h))}const c=[];return u.bufferView!==void 0?c.push(this.getDependency("bufferView",u.bufferView)):c.push(null),u.sparse!==void 0&&(c.push(this.getDependency("bufferView",u.sparse.indices.bufferView)),c.push(this.getDependency("bufferView",u.sparse.values.bufferView))),Promise.all(c).then(function(l){const p=l[0],h=dr[u.type],y=Ct[u.componentType],E=y.BYTES_PER_ELEMENT,_=E*h,P=u.byteOffset||0,D=u.bufferView!==void 0?a.bufferViews[u.bufferView].byteStride:void 0,q=u.normalized===!0;let W,z;if(D&&D!==_){const Y=Math.floor(P/D),ee="InterleavedBuffer:"+u.bufferView+":"+u.componentType+":"+Y+":"+u.count;let ae=s.cache.get(ee);ae||(W=new y(p,Y*D,u.count*D/E),ae=new x.InterleavedBuffer(W,D/E),s.cache.add(ee,ae)),z=new x.InterleavedBufferAttribute(ae,h,P%D/E,q)}else p===null?W=new y(u.count*h):W=new y(p,P,u.count*h),z=new x.BufferAttribute(W,h,q);if(u.sparse!==void 0){const Y=dr.SCALAR,ee=Ct[u.sparse.indices.componentType],ae=u.sparse.indices.byteOffset||0,Z=u.sparse.values.byteOffset||0,Ae=new ee(l[1],ae,u.sparse.count*Y),ve=new y(l[2],Z,u.sparse.count*h);p!==null&&(z=new x.BufferAttribute(z.array.slice(),z.itemSize,z.normalized)),z.normalized=!1;for(let le=0,Be=Ae.length;le<Be;le++){const Ce=Ae[le];if(z.setX(Ce,ve[le*h]),h>=2&&z.setY(Ce,ve[le*h+1]),h>=3&&z.setZ(Ce,ve[le*h+2]),h>=4&&z.setW(Ce,ve[le*h+3]),h>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}z.normalized=q}return z})}loadTexture(r){const s=this.json,a=this.options,c=s.textures[r].source,l=s.images[c];let p=this.textureLoader;if(l.uri){const h=a.manager.getHandler(l.uri);h!==null&&(p=h)}return this.loadTextureImage(r,c,p)}loadTextureImage(r,s,a){const u=this,c=this.json,l=c.textures[r],p=c.images[s],h=(p.uri||p.bufferView)+":"+l.sampler;if(this.textureCache[h])return this.textureCache[h];const y=this.loadImageSource(s,a).then(function(E){E.flipY=!1,E.name=l.name||p.name||"",E.name===""&&typeof p.uri=="string"&&p.uri.startsWith("data:image/")===!1&&(E.name=p.uri);const P=(c.samplers||{})[l.sampler]||{};return E.magFilter=ri[P.magFilter]||x.LinearFilter,E.minFilter=ri[P.minFilter]||x.LinearMipmapLinearFilter,E.wrapS=ii[P.wrapS]||x.RepeatWrapping,E.wrapT=ii[P.wrapT]||x.RepeatWrapping,E.generateMipmaps=!E.isCompressedTexture&&E.minFilter!==x.NearestFilter&&E.minFilter!==x.LinearFilter,u.associations.set(E,{textures:r}),E}).catch(function(){return null});return this.textureCache[h]=y,y}loadImageSource(r,s){const a=this,u=this.json,c=this.options;if(this.sourceCache[r]!==void 0)return this.sourceCache[r].then(_=>_.clone());const l=u.images[r],p=self.URL||self.webkitURL;let h=l.uri||"",y=!1;if(l.bufferView!==void 0)h=a.getDependency("bufferView",l.bufferView).then(function(_){y=!0;const P=new Blob([_],{type:l.mimeType});return h=p.createObjectURL(P),h});else if(l.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+r+" is missing URI and bufferView");const E=Promise.resolve(h).then(function(_){return new Promise(function(P,D){let q=P;s.isImageBitmapLoader===!0&&(q=function(W){const z=new x.Texture(W);z.needsUpdate=!0,P(z)}),s.load(x.LoaderUtils.resolveURL(_,c.path),q,void 0,D)})}).then(function(_){return y===!0&&p.revokeObjectURL(h),Xe(_,l),_.userData.mimeType=l.mimeType||Rs(l.uri),_}).catch(function(_){throw console.error("THREE.GLTFLoader: Couldn't load texture",h),_});return this.sourceCache[r]=E,E}assignTexture(r,s,a,u){const c=this;return this.getDependency("texture",a.index).then(function(l){if(!l)return null;if(a.texCoord!==void 0&&a.texCoord>0&&(l=l.clone(),l.channel=a.texCoord),c.extensions[re.KHR_TEXTURE_TRANSFORM]){const p=a.extensions!==void 0?a.extensions[re.KHR_TEXTURE_TRANSFORM]:void 0;if(p){const h=c.associations.get(l);l=c.extensions[re.KHR_TEXTURE_TRANSFORM].extendTexture(l,p),c.associations.set(l,h)}}return u!==void 0&&(l.colorSpace=u),r[s]=l,l})}assignFinalMaterial(r){const s=r.geometry;let a=r.material;const u=s.attributes.tangent===void 0,c=s.attributes.color!==void 0,l=s.attributes.normal===void 0;if(r.isPoints){const p="PointsMaterial:"+a.uuid;let h=this.cache.get(p);h||(h=new x.PointsMaterial,x.Material.prototype.copy.call(h,a),h.color.copy(a.color),h.map=a.map,h.sizeAttenuation=!1,this.cache.add(p,h)),a=h}else if(r.isLine){const p="LineBasicMaterial:"+a.uuid;let h=this.cache.get(p);h||(h=new x.LineBasicMaterial,x.Material.prototype.copy.call(h,a),h.color.copy(a.color),h.map=a.map,this.cache.add(p,h)),a=h}if(u||c||l){let p="ClonedMaterial:"+a.uuid+":";u&&(p+="derivative-tangents:"),c&&(p+="vertex-colors:"),l&&(p+="flat-shading:");let h=this.cache.get(p);h||(h=a.clone(),c&&(h.vertexColors=!0),l&&(h.flatShading=!0),u&&(h.normalScale&&(h.normalScale.y*=-1),h.clearcoatNormalScale&&(h.clearcoatNormalScale.y*=-1)),this.cache.add(p,h),this.associations.set(h,this.associations.get(a))),a=h}r.material=a}getMaterialType(){return x.MeshStandardMaterial}loadMaterial(r){const s=this,a=this.json,u=this.extensions,c=a.materials[r];let l;const p={},h=c.extensions||{},y=[];if(h[re.KHR_MATERIALS_UNLIT]){const _=u[re.KHR_MATERIALS_UNLIT];l=_.getMaterialType(),y.push(_.extendParams(p,c,s))}else{const _=c.pbrMetallicRoughness||{};if(p.color=new x.Color(1,1,1),p.opacity=1,Array.isArray(_.baseColorFactor)){const P=_.baseColorFactor;p.color.setRGB(P[0],P[1],P[2],x.LinearSRGBColorSpace),p.opacity=P[3]}_.baseColorTexture!==void 0&&y.push(s.assignTexture(p,"map",_.baseColorTexture,x.SRGBColorSpace)),p.metalness=_.metallicFactor!==void 0?_.metallicFactor:1,p.roughness=_.roughnessFactor!==void 0?_.roughnessFactor:1,_.metallicRoughnessTexture!==void 0&&(y.push(s.assignTexture(p,"metalnessMap",_.metallicRoughnessTexture)),y.push(s.assignTexture(p,"roughnessMap",_.metallicRoughnessTexture))),l=this._invokeOne(function(P){return P.getMaterialType&&P.getMaterialType(r)}),y.push(Promise.all(this._invokeAll(function(P){return P.extendMaterialParams&&P.extendMaterialParams(r,p)})))}c.doubleSided===!0&&(p.side=x.DoubleSide);const E=c.alphaMode||pr.OPAQUE;if(E===pr.BLEND?(p.transparent=!0,p.depthWrite=!1):(p.transparent=!1,E===pr.MASK&&(p.alphaTest=c.alphaCutoff!==void 0?c.alphaCutoff:.5)),c.normalTexture!==void 0&&l!==x.MeshBasicMaterial&&(y.push(s.assignTexture(p,"normalMap",c.normalTexture)),p.normalScale=new x.Vector2(1,1),c.normalTexture.scale!==void 0)){const _=c.normalTexture.scale;p.normalScale.set(_,_)}if(c.occlusionTexture!==void 0&&l!==x.MeshBasicMaterial&&(y.push(s.assignTexture(p,"aoMap",c.occlusionTexture)),c.occlusionTexture.strength!==void 0&&(p.aoMapIntensity=c.occlusionTexture.strength)),c.emissiveFactor!==void 0&&l!==x.MeshBasicMaterial){const _=c.emissiveFactor;p.emissive=new x.Color().setRGB(_[0],_[1],_[2],x.LinearSRGBColorSpace)}return c.emissiveTexture!==void 0&&l!==x.MeshBasicMaterial&&y.push(s.assignTexture(p,"emissiveMap",c.emissiveTexture,x.SRGBColorSpace)),Promise.all(y).then(function(){const _=new l(p);return c.name&&(_.name=c.name),Xe(_,c),s.associations.set(_,{materials:r}),c.extensions&&gt(u,_,c),_})}createUniqueName(r){const s=x.PropertyBinding.sanitizeNodeName(r||"");return s in this.nodeNamesUsed?s+"_"+ ++this.nodeNamesUsed[s]:(this.nodeNamesUsed[s]=0,s)}loadGeometries(r){const s=this,a=this.extensions,u=this.primitiveCache;function c(p){return a[re.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(p,s).then(function(h){return si(h,p,s)})}const l=[];for(let p=0,h=r.length;p<h;p++){const y=r[p],E=Es(y),_=u[E];if(_)l.push(_.promise);else{let P;y.extensions&&y.extensions[re.KHR_DRACO_MESH_COMPRESSION]?P=c(y):P=si(new x.BufferGeometry,y,s),u[E]={primitive:y,promise:P},l.push(P)}}return Promise.all(l)}loadMesh(r){const s=this,a=this.json,u=this.extensions,c=a.meshes[r],l=c.primitives,p=[];for(let h=0,y=l.length;h<y;h++){const E=l[h].material===void 0?xs(this.cache):this.getDependency("material",l[h].material);p.push(E)}return p.push(s.loadGeometries(l)),Promise.all(p).then(function(h){const y=h.slice(0,h.length-1),E=h[h.length-1],_=[];for(let D=0,q=E.length;D<q;D++){const W=E[D],z=l[D];let Y;const ee=y[D];if(z.mode===Le.TRIANGLES||z.mode===Le.TRIANGLE_STRIP||z.mode===Le.TRIANGLE_FAN||z.mode===void 0)Y=c.isSkinnedMesh===!0?new x.SkinnedMesh(W,ee):new x.Mesh(W,ee),Y.isSkinnedMesh===!0&&Y.normalizeSkinWeights(),z.mode===Le.TRIANGLE_STRIP?Y.geometry=ti(Y.geometry,x.TriangleStripDrawMode):z.mode===Le.TRIANGLE_FAN&&(Y.geometry=ti(Y.geometry,x.TriangleFanDrawMode));else if(z.mode===Le.LINES)Y=new x.LineSegments(W,ee);else if(z.mode===Le.LINE_STRIP)Y=new x.Line(W,ee);else if(z.mode===Le.LINE_LOOP)Y=new x.LineLoop(W,ee);else if(z.mode===Le.POINTS)Y=new x.Points(W,ee);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+z.mode);Object.keys(Y.geometry.morphAttributes).length>0&&Ss(Y,c),Y.name=s.createUniqueName(c.name||"mesh_"+r),Xe(Y,c),z.extensions&&gt(u,Y,z),s.assignFinalMaterial(Y),_.push(Y)}for(let D=0,q=_.length;D<q;D++)s.associations.set(_[D],{meshes:r,primitives:D});if(_.length===1)return c.extensions&&gt(u,_[0],c),_[0];const P=new x.Group;c.extensions&&gt(u,P,c),s.associations.set(P,{meshes:r});for(let D=0,q=_.length;D<q;D++)P.add(_[D]);return P})}loadCamera(r){let s;const a=this.json.cameras[r],u=a[a.type];if(!u){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return a.type==="perspective"?s=new x.PerspectiveCamera(x.MathUtils.radToDeg(u.yfov),u.aspectRatio||1,u.znear||1,u.zfar||2e6):a.type==="orthographic"&&(s=new x.OrthographicCamera(-u.xmag,u.xmag,u.ymag,-u.ymag,u.znear,u.zfar)),a.name&&(s.name=this.createUniqueName(a.name)),Xe(s,a),Promise.resolve(s)}loadSkin(r){const s=this.json.skins[r],a=[];for(let u=0,c=s.joints.length;u<c;u++)a.push(this._loadNodeShallow(s.joints[u]));return s.inverseBindMatrices!==void 0?a.push(this.getDependency("accessor",s.inverseBindMatrices)):a.push(null),Promise.all(a).then(function(u){const c=u.pop(),l=u,p=[],h=[];for(let y=0,E=l.length;y<E;y++){const _=l[y];if(_){p.push(_);const P=new x.Matrix4;c!==null&&P.fromArray(c.array,y*16),h.push(P)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',s.joints[y])}return new x.Skeleton(p,h)})}loadAnimation(r){const s=this.json,a=this,u=s.animations[r],c=u.name?u.name:"animation_"+r,l=[],p=[],h=[],y=[],E=[];for(let _=0,P=u.channels.length;_<P;_++){const D=u.channels[_],q=u.samplers[D.sampler],W=D.target,z=W.node,Y=u.parameters!==void 0?u.parameters[q.input]:q.input,ee=u.parameters!==void 0?u.parameters[q.output]:q.output;W.node!==void 0&&(l.push(this.getDependency("node",z)),p.push(this.getDependency("accessor",Y)),h.push(this.getDependency("accessor",ee)),y.push(q),E.push(W))}return Promise.all([Promise.all(l),Promise.all(p),Promise.all(h),Promise.all(y),Promise.all(E)]).then(function(_){const P=_[0],D=_[1],q=_[2],W=_[3],z=_[4],Y=[];for(let ee=0,ae=P.length;ee<ae;ee++){const Z=P[ee],Ae=D[ee],ve=q[ee],le=W[ee],Be=z[ee];if(Z===void 0)continue;Z.updateMatrix&&Z.updateMatrix();const Ce=a._createAnimationTracks(Z,Ae,ve,le,Be);if(Ce)for(let me=0;me<Ce.length;me++)Y.push(Ce[me])}return new x.AnimationClip(c,void 0,Y)})}createNodeMesh(r){const s=this.json,a=this,u=s.nodes[r];return u.mesh===void 0?null:a.getDependency("mesh",u.mesh).then(function(c){const l=a._getNodeRef(a.meshCache,u.mesh,c);return u.weights!==void 0&&l.traverse(function(p){if(p.isMesh)for(let h=0,y=u.weights.length;h<y;h++)p.morphTargetInfluences[h]=u.weights[h]}),l})}loadNode(r){const s=this.json,a=this,u=s.nodes[r],c=a._loadNodeShallow(r),l=[],p=u.children||[];for(let y=0,E=p.length;y<E;y++)l.push(a.getDependency("node",p[y]));const h=u.skin===void 0?Promise.resolve(null):a.getDependency("skin",u.skin);return Promise.all([c,Promise.all(l),h]).then(function(y){const E=y[0],_=y[1],P=y[2];P!==null&&E.traverse(function(D){D.isSkinnedMesh&&D.bind(P,ks)});for(let D=0,q=_.length;D<q;D++)E.add(_[D]);return E})}_loadNodeShallow(r){const s=this.json,a=this.extensions,u=this;if(this.nodeCache[r]!==void 0)return this.nodeCache[r];const c=s.nodes[r],l=c.name?u.createUniqueName(c.name):"",p=[],h=u._invokeOne(function(y){return y.createNodeMesh&&y.createNodeMesh(r)});return h&&p.push(h),c.camera!==void 0&&p.push(u.getDependency("camera",c.camera).then(function(y){return u._getNodeRef(u.cameraCache,c.camera,y)})),u._invokeAll(function(y){return y.createNodeAttachment&&y.createNodeAttachment(r)}).forEach(function(y){p.push(y)}),this.nodeCache[r]=Promise.all(p).then(function(y){let E;if(c.isBone===!0?E=new x.Bone:y.length>1?E=new x.Group:y.length===1?E=y[0]:E=new x.Object3D,E!==y[0])for(let _=0,P=y.length;_<P;_++)E.add(y[_]);if(c.name&&(E.userData.name=c.name,E.name=l),Xe(E,c),c.extensions&&gt(a,E,c),c.matrix!==void 0){const _=new x.Matrix4;_.fromArray(c.matrix),E.applyMatrix4(_)}else c.translation!==void 0&&E.position.fromArray(c.translation),c.rotation!==void 0&&E.quaternion.fromArray(c.rotation),c.scale!==void 0&&E.scale.fromArray(c.scale);return u.associations.has(E)||u.associations.set(E,{}),u.associations.get(E).nodes=r,E}),this.nodeCache[r]}loadScene(r){const s=this.extensions,a=this.json.scenes[r],u=this,c=new x.Group;a.name&&(c.name=u.createUniqueName(a.name)),Xe(c,a),a.extensions&&gt(s,c,a);const l=a.nodes||[],p=[];for(let h=0,y=l.length;h<y;h++)p.push(u.getDependency("node",l[h]));return Promise.all(p).then(function(h){for(let E=0,_=h.length;E<_;E++)c.add(h[E]);const y=E=>{const _=new Map;for(const[P,D]of u.associations)(P instanceof x.Material||P instanceof x.Texture)&&_.set(P,D);return E.traverse(P=>{const D=u.associations.get(P);D!=null&&_.set(P,D)}),_};return u.associations=y(c),c})}_createAnimationTracks(r,s,a,u,c){const l=[],p=r.name?r.name:r.uuid,h=[];it[c.path]===it.weights?r.traverse(function(P){P.morphTargetInfluences&&h.push(P.name?P.name:P.uuid)}):h.push(p);let y;switch(it[c.path]){case it.weights:y=x.NumberKeyframeTrack;break;case it.rotation:y=x.QuaternionKeyframeTrack;break;case it.translation:case it.scale:y=x.VectorKeyframeTrack;break;default:switch(a.itemSize){case 1:y=x.NumberKeyframeTrack;break;case 2:case 3:default:y=x.VectorKeyframeTrack;break}break}const E=u.interpolation!==void 0?As[u.interpolation]:x.InterpolateLinear,_=this._getArrayFromAccessor(a);for(let P=0,D=h.length;P<D;P++){const q=new y(h[P]+"."+it[c.path],s.array,_,E);u.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(q),l.push(q)}return l}_getArrayFromAccessor(r){let s=r.array;if(r.normalized){const a=gr(s.constructor),u=new Float32Array(s.length);for(let c=0,l=s.length;c<l;c++)u[c]=s[c]*a;s=u}return s}_createCubicSplineTrackInterpolant(r){r.createInterpolant=function(a){const u=this instanceof x.QuaternionKeyframeTrack?_s:pi;return new u(this.times,this.values,this.getValueSize()/3,a)},r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Os(L,r,s){const a=r.attributes,u=new x.Box3;if(a.POSITION!==void 0){const p=s.json.accessors[a.POSITION],h=p.min,y=p.max;if(h!==void 0&&y!==void 0){if(u.set(new x.Vector3(h[0],h[1],h[2]),new x.Vector3(y[0],y[1],y[2])),p.normalized){const E=gr(Ct[p.componentType]);u.min.multiplyScalar(E),u.max.multiplyScalar(E)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const c=r.targets;if(c!==void 0){const p=new x.Vector3,h=new x.Vector3;for(let y=0,E=c.length;y<E;y++){const _=c[y];if(_.POSITION!==void 0){const P=s.json.accessors[_.POSITION],D=P.min,q=P.max;if(D!==void 0&&q!==void 0){if(h.setX(Math.max(Math.abs(D[0]),Math.abs(q[0]))),h.setY(Math.max(Math.abs(D[1]),Math.abs(q[1]))),h.setZ(Math.max(Math.abs(D[2]),Math.abs(q[2]))),P.normalized){const W=gr(Ct[P.componentType]);h.multiplyScalar(W)}p.max(h)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}u.expandByVector(p)}L.boundingBox=u;const l=new x.Sphere;u.getCenter(l.center),l.radius=u.min.distanceTo(u.max)/2,L.boundingSphere=l}function si(L,r,s){const a=r.attributes,u=[];function c(l,p){return s.getDependency("accessor",l).then(function(h){L.setAttribute(p,h)})}for(const l in a){const p=yr[l]||l.toLowerCase();p in L.attributes||u.push(c(a[l],p))}if(r.indices!==void 0&&!L.index){const l=s.getDependency("accessor",r.indices).then(function(p){L.setIndex(p)});u.push(l)}return x.ColorManagement.workingColorSpace!==x.LinearSRGBColorSpace&&"COLOR_0"in a&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${x.ColorManagement.workingColorSpace}" not supported.`),Xe(L,r),Os(L,r,s),Promise.all(u).then(function(){return r.targets!==void 0?Ts(L,r.targets,s):L})}const se={c:null,u:[new x.Vector3,new x.Vector3,new x.Vector3],e:[]},ue={c:null,u:[new x.Vector3,new x.Vector3,new x.Vector3],e:[]},pe=[[],[],[]],$=[[],[],[]],he=[],vt=new x.Vector3,bt=new x.Vector3,wt=new x.Vector3,be=new x.Vector3,oi=new x.Vector3,ai=new x.Vector3,Ne=new x.Matrix3,ui=new x.Box3,Sn=new x.Matrix4,ci=new x.Matrix4,li=new x.Ray;class vr{constructor(r=new x.Vector3,s=new x.Vector3,a=new x.Matrix3){this.center=r,this.halfSize=s,this.rotation=a}set(r,s,a){return this.center=r,this.halfSize=s,this.rotation=a,this}copy(r){return this.center.copy(r.center),this.halfSize.copy(r.halfSize),this.rotation.copy(r.rotation),this}clone(){return new this.constructor().copy(this)}getSize(r){return r.copy(this.halfSize).multiplyScalar(2)}clampPoint(r,s){const a=this.halfSize;be.subVectors(r,this.center),this.rotation.extractBasis(vt,bt,wt),s.copy(this.center);const u=x.MathUtils.clamp(be.dot(vt),-a.x,a.x);s.add(vt.multiplyScalar(u));const c=x.MathUtils.clamp(be.dot(bt),-a.y,a.y);s.add(bt.multiplyScalar(c));const l=x.MathUtils.clamp(be.dot(wt),-a.z,a.z);return s.add(wt.multiplyScalar(l)),s}containsPoint(r){return be.subVectors(r,this.center),this.rotation.extractBasis(vt,bt,wt),Math.abs(be.dot(vt))<=this.halfSize.x&&Math.abs(be.dot(bt))<=this.halfSize.y&&Math.abs(be.dot(wt))<=this.halfSize.z}intersectsBox3(r){return this.intersectsOBB(Cs.fromBox3(r))}intersectsSphere(r){return this.clampPoint(r.center,ai),ai.distanceToSquared(r.center)<=r.radius*r.radius}intersectsOBB(r,s=Number.EPSILON){se.c=this.center,se.e[0]=this.halfSize.x,se.e[1]=this.halfSize.y,se.e[2]=this.halfSize.z,this.rotation.extractBasis(se.u[0],se.u[1],se.u[2]),ue.c=r.center,ue.e[0]=r.halfSize.x,ue.e[1]=r.halfSize.y,ue.e[2]=r.halfSize.z,r.rotation.extractBasis(ue.u[0],ue.u[1],ue.u[2]);for(let c=0;c<3;c++)for(let l=0;l<3;l++)pe[c][l]=se.u[c].dot(ue.u[l]);be.subVectors(ue.c,se.c),he[0]=be.dot(se.u[0]),he[1]=be.dot(se.u[1]),he[2]=be.dot(se.u[2]);for(let c=0;c<3;c++)for(let l=0;l<3;l++)$[c][l]=Math.abs(pe[c][l])+s;let a,u;for(let c=0;c<3;c++)if(a=se.e[c],u=ue.e[0]*$[c][0]+ue.e[1]*$[c][1]+ue.e[2]*$[c][2],Math.abs(he[c])>a+u)return!1;for(let c=0;c<3;c++)if(a=se.e[0]*$[0][c]+se.e[1]*$[1][c]+se.e[2]*$[2][c],u=ue.e[c],Math.abs(he[0]*pe[0][c]+he[1]*pe[1][c]+he[2]*pe[2][c])>a+u)return!1;return a=se.e[1]*$[2][0]+se.e[2]*$[1][0],u=ue.e[1]*$[0][2]+ue.e[2]*$[0][1],!(Math.abs(he[2]*pe[1][0]-he[1]*pe[2][0])>a+u||(a=se.e[1]*$[2][1]+se.e[2]*$[1][1],u=ue.e[0]*$[0][2]+ue.e[2]*$[0][0],Math.abs(he[2]*pe[1][1]-he[1]*pe[2][1])>a+u)||(a=se.e[1]*$[2][2]+se.e[2]*$[1][2],u=ue.e[0]*$[0][1]+ue.e[1]*$[0][0],Math.abs(he[2]*pe[1][2]-he[1]*pe[2][2])>a+u)||(a=se.e[0]*$[2][0]+se.e[2]*$[0][0],u=ue.e[1]*$[1][2]+ue.e[2]*$[1][1],Math.abs(he[0]*pe[2][0]-he[2]*pe[0][0])>a+u)||(a=se.e[0]*$[2][1]+se.e[2]*$[0][1],u=ue.e[0]*$[1][2]+ue.e[2]*$[1][0],Math.abs(he[0]*pe[2][1]-he[2]*pe[0][1])>a+u)||(a=se.e[0]*$[2][2]+se.e[2]*$[0][2],u=ue.e[0]*$[1][1]+ue.e[1]*$[1][0],Math.abs(he[0]*pe[2][2]-he[2]*pe[0][2])>a+u)||(a=se.e[0]*$[1][0]+se.e[1]*$[0][0],u=ue.e[1]*$[2][2]+ue.e[2]*$[2][1],Math.abs(he[1]*pe[0][0]-he[0]*pe[1][0])>a+u)||(a=se.e[0]*$[1][1]+se.e[1]*$[0][1],u=ue.e[0]*$[2][2]+ue.e[2]*$[2][0],Math.abs(he[1]*pe[0][1]-he[0]*pe[1][1])>a+u)||(a=se.e[0]*$[1][2]+se.e[1]*$[0][2],u=ue.e[0]*$[2][1]+ue.e[1]*$[2][0],Math.abs(he[1]*pe[0][2]-he[0]*pe[1][2])>a+u))}intersectsPlane(r){this.rotation.extractBasis(vt,bt,wt);const s=this.halfSize.x*Math.abs(r.normal.dot(vt))+this.halfSize.y*Math.abs(r.normal.dot(bt))+this.halfSize.z*Math.abs(r.normal.dot(wt)),a=r.normal.dot(this.center)-r.constant;return Math.abs(a)<=s}intersectRay(r,s){return this.getSize(oi),ui.setFromCenterAndSize(be.set(0,0,0),oi),Sn.setFromMatrix3(this.rotation),Sn.setPosition(this.center),ci.copy(Sn).invert(),li.copy(r).applyMatrix4(ci),li.intersectBox(ui,s)?s.applyMatrix4(Sn):null}intersectsRay(r){return this.intersectRay(r,be)!==null}fromBox3(r){return r.getCenter(this.center),r.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(r){return r.center.equals(this.center)&&r.halfSize.equals(this.halfSize)&&r.rotation.equals(this.rotation)}applyMatrix4(r){const s=r.elements;let a=be.set(s[0],s[1],s[2]).length();const u=be.set(s[4],s[5],s[6]).length(),c=be.set(s[8],s[9],s[10]).length();r.determinant()<0&&(a=-a),Ne.setFromMatrix4(r);const p=1/a,h=1/u,y=1/c;return Ne.elements[0]*=p,Ne.elements[1]*=p,Ne.elements[2]*=p,Ne.elements[3]*=h,Ne.elements[4]*=h,Ne.elements[5]*=h,Ne.elements[6]*=y,Ne.elements[7]*=y,Ne.elements[8]*=y,this.rotation.multiply(Ne),this.halfSize.x*=a,this.halfSize.y*=u,this.halfSize.z*=c,be.setFromMatrixPosition(r),this.center.add(be),this}}const Cs=new vr,Ps={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:x.MathUtils.degToRad(60)};function Ls(L,r){const s=Object.assign({css3d:!1,stats:!1,control:{init:!0,options:{}}},r||{});let a,u,c,l=[];const p=rt.ref(!1),h=rt.shallowRef(),y=rt.ref(0),E=rt.ref(0),_=new x.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),P=new x.Scene({}),D=new x.PerspectiveCamera(50,1,.1,2e3),q=Math.tan(Math.PI/180*D.fov/2);_.setPixelRatio(window.devicePixelRatio);function W(){p.value=!1;const me=Ae();y.value=me[0],E.value=me[1],D.aspect=y.value/E.value,D.position.set(47,39,100),D.fov=360/Math.PI*Math.atan(q*(E.value/y.value)),D.lookAt(0,0,0),D.updateProjectionMatrix(),_.setSize(y.value,E.value),a.appendChild(_.domElement),s.stats&&ve(),s.css3d&&Be();let Ie;if(s.control&&s.control.init){Ie=Tn.createOrbitControl(D,_.domElement);const Re=Object.assign(Ps,s.control.options||{});Object.keys(Re).forEach(ke=>{Ie[ke]=Re[ke]})}return rt.nextTick(()=>p.value=!0),Ie}function z(me){me.preventDefault(),cancelAnimationFrame(ae)}function Y(me){me.preventDefault(),W(),ae()}function ee(me){l.push(me)}function ae(me){l&&l.length&&l.forEach(Ie=>{typeof Ie=="function"&&Ie()}),h.value&&h.value.update(),_.render(P,D),u&&u.update(),c&&c.render(P,D),requestAnimationFrame(ae)}function Z(){rt.nextTick(()=>{const me=Ae();y.value=me[0],E.value=me[1],D.aspect=y.value/E.value,D.fov=360/Math.PI*Math.atan(q*(E.value/y.value)),D.updateProjectionMatrix(),D.lookAt(P.position),_.render(P,D),_.setSize(y.value,E.value),c&&c.setSize(y.value,E.value)})}function Ae(){return a=document.querySelector(L),[a.clientWidth,a.clientHeight]}function ve(){u=new Tn.Stats,u.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.appendChild(u.dom)}function le(me,Ie,Re,ke,Wt){const _t=new x.Box3().setFromObject(me),At=_t.getSize(new x.Vector3).length(),qe=_t.getCenter(new x.Vector3);Wt&&qe.add(Wt);const Ye=At*Ie*.5,De=x.MathUtils.degToRad(Re.fov*.5),Pt=Ye/Math.tan(De),Fe=new x.Vector3().subVectors(Re.position,qe).multiply(new x.Vector3(1,1,1)).normalize().multiplyScalar(Pt).add(qe),He={x:Fe.x,y:Fe.y,z:Fe.z,lookAt_x:qe.x,lookAt_y:qe.y,lookAt_z:qe.z};return Re.position.set(He.x,He.y,He.z),Re.lookAt(He.lookAt_x,He.lookAt_y,He.lookAt_z),Re.updateProjectionMatrix(),ke.target.copy(qe),ke.update(),At}function Be(){c=new Tn.CSS3DRenderer,c.setSize(y.value,E.value),c.domElement.style.position="absolute",c.domElement.style.top=0,c.domElement.style.left=0,c.domElement.style.pointerEvents="none",a.appendChild(c.domElement)}function Ce(){Tn.disposeThreeObject(P)}return rt.onMounted(()=>{h.value=W(),_.domElement.addEventListener("resize",Z,!1),_.domElement.addEventListener("webglcontextlost",z,!1),_.domElement.addEventListener("webglcontextrestored",Y,!1),requestAnimationFrame(ae)}),rt.onUnmounted(()=>{cancelAnimationFrame(ae),_.domElement.removeEventListener("resize",Z,!1),_.domElement.removeEventListener("webglcontextlost",z,!1),_.domElement.removeEventListener("webglcontextrestored",Y,!1),Ce()}),{addAnimate:ee,frameArea:le,scene:P,camera:D,control:h,renderer:_,domWidth:y,domHeight:E,isReady:p}}const Is=(L="app")=>{const r=new x.Raycaster;r.params.Line.threshold=8;const s=new x.Vector2,a=document.getElementById(L);function u(p,h){const{scaleX:y,scaleY:E}=l(a),{clientWidth:_,clientHeight:P}=h,D=h.getBoundingClientRect(),q=_*y,W=P*E,z=p.clientX-D.left,Y=p.clientY-D.top;return s.x=(p.clientX-D.left)/q*2-1,s.y=-((p.clientY-D.top)/W)*2+1,{pointer:s,x:z,y:Y}}function c(p,h,y,E){const{pointer:_,x:P,y:D}=u(p,h);return r.setFromCamera(_,y),{intersects:r.intersectObjects(E),pointer:_,x:P,y:D}}function l(p){const h=window.getComputedStyle(p),y=h.transform||h.webkitTransform||h.mozTransform;if(y&&y!=="none"){const E=y.match(/^matrix\((.+)\)$/);if(E){const _=E[1].split(", "),P=parseFloat(_[0]),D=parseFloat(_[3]);return{scaleX:P,scaleY:D}}}return{scaleX:1,scaleY:1}}return{raycaster:r,pointer:s,getPointer:u,getScale:l,getIntersects:c}},Ge=[],Ds=new x.Color(16711680),Ns=()=>{const L=()=>{Ge.splice(0)},r=(p,h)=>{h.traverse(y=>{y&&s(p,y)})},s=(p,h)=>{if(h.userData.needCheck&&(h.autoUpdateMatrix=!1,h.updateMatrix(),h.updateMatrixWorld(),h.isMesh)){const y=new x.Box3(new x.Vector3).setFromObject(h);h.geometry.userData.obb=new vr,h.geometry.userData.obb.halfSize.copy(y.getSize(new x.Vector3)).multiplyScalar(.5).multiplyScalar(.88),h.userData.obb=new vr,h.userData.originColor=h.material.color.clone(),h.userData.parentUid=p,Ge.push({object:h,parentUid:p})}};return{resetObbs:L,initObb:r,getObbObjectByParentUid:p=>Ge.filter(h=>h.parentUid===p),addObbFromArray:(p,h)=>{for(let y=0,E=h.length;y<E;y++)s(p,h[y])},removeObbFromArray:p=>{const h=Ge.filter(y=>!p.includes(y.object));Ge.splice(0,Ge.length,...h)},removeUidObb:p=>{for(let h=Ge.length-1;h>=0;h--)Ge[h].parentUid===p&&Ge.splice(h,1)}}};var Bs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fs(L){return L&&L.__esModule&&Object.prototype.hasOwnProperty.call(L,"default")?L.default:L}var Rn={exports:{}},js=Rn.exports,fi;function Ks(){return fi||(fi=1,function(L,r){(function(s,a){L.exports=a()})(js,function(){var s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(n[o]=i[o])})(e,t)},a=function(){return(a=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function u(e,t,n){for(var i,o=0,f=t.length;o<f;o++)!i&&o in t||((i=i||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var c=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Bs,l=Object.keys,p=Array.isArray;function h(e,t){return typeof t!="object"||l(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||c.Promise||(c.Promise=Promise);var y=Object.getPrototypeOf,E={}.hasOwnProperty;function _(e,t){return E.call(e,t)}function P(e,t){typeof t=="function"&&(t=t(y(e))),(typeof Reflect>"u"?l:Reflect.ownKeys)(t).forEach(function(n){q(e,n,t[n])})}var D=Object.defineProperty;function q(e,t,n,i){D(e,t,h(n&&_(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},i))}function W(e){return{from:function(t){return e.prototype=Object.create(t.prototype),q(e.prototype,"constructor",e),{extend:P.bind(null,e.prototype)}}}}var z=Object.getOwnPropertyDescriptor,Y=[].slice;function ee(e,t,n){return Y.call(e,t,n)}function ae(e,t){return t(e)}function Z(e){if(!e)throw new Error("Assertion Failed")}function Ae(e){c.setImmediate?setImmediate(e):setTimeout(e,0)}function ve(e,t){if(typeof t=="string"&&_(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var n=[],i=0,o=t.length;i<o;++i){var f=ve(e,t[i]);n.push(f)}return n}var d=t.indexOf(".");if(d!==-1){var m=e[t.substr(0,d)];return m==null?void 0:ve(m,t.substr(d+1))}}function le(e,t,n){if(e&&t!==void 0&&!("isFrozen"in Object&&Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){Z(typeof n!="string"&&"length"in n);for(var i=0,o=t.length;i<o;++i)le(e,t[i],n[i])}else{var f,d,m=t.indexOf(".");m!==-1?(f=t.substr(0,m),(d=t.substr(m+1))===""?n===void 0?p(e)&&!isNaN(parseInt(f))?e.splice(f,1):delete e[f]:e[f]=n:le(m=!(m=e[f])||!_(e,f)?e[f]={}:m,d,n)):n===void 0?p(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function Be(e){var t,n={};for(t in e)_(e,t)&&(n[t]=e[t]);return n}var Ce=[].concat;function me(e){return Ce.apply([],e)}var ot="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(me([8,16,32,64].map(function(e){return["Int","Uint","Float"].map(function(t){return t+e+"Array"})}))).filter(function(e){return c[e]}),Ie=new Set(ot.map(function(e){return c[e]})),Re=null;function ke(e){return Re=new WeakMap,e=function t(n){if(!n||typeof n!="object")return n;var i=Re.get(n);if(i)return i;if(p(n)){i=[],Re.set(n,i);for(var o=0,f=n.length;o<f;++o)i.push(t(n[o]))}else if(Ie.has(n.constructor))i=n;else{var d,m=y(n);for(d in i=m===Object.prototype?{}:Object.create(m),Re.set(n,i),n)_(n,d)&&(i[d]=t(n[d]))}return i}(e),Re=null,e}var Wt={}.toString;function _t(e){return Wt.call(e).slice(8,-1)}var At=typeof Symbol<"u"?Symbol.iterator:"@@iterator",qe=typeof At=="symbol"?function(e){var t;return e!=null&&(t=e[At])&&t.apply(e)}:function(){return null};function We(e,t){return t=e.indexOf(t),0<=t&&e.splice(t,1),0<=t}var Ye={};function De(e){var t,n,i,o;if(arguments.length===1){if(p(e))return e.slice();if(this===Ye&&typeof e=="string")return[e];if(o=qe(e)){for(n=[];!(i=o.next()).done;)n.push(i.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 Pt=typeof Symbol<"u"?function(e){return e[Symbol.toStringTag]==="AsyncFunction"}:function(){return!1},Dt=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Pe=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Dt),wr={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 Fe(e,t){this.name=e,this.message=t}function He(e,t){return e+". Errors: "+Object.keys(t).map(function(n){return t[n].toString()}).filter(function(n,i,o){return o.indexOf(n)===i}).join(`
3
3
  `)}function Yt(e,t,n,i){this.failures=t,this.failedKeys=i,this.successCount=n,this.message=He(e,t)}function xt(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(n){return t[n]}),this.failuresByPos=t,this.message=He(e,this.failures)}W(Fe).from(Error).extend({toString:function(){return this.name+": "+this.message}}),W(Yt).from(Fe),W(xt).from(Fe);var Mn=Pe.reduce(function(e,t){return e[t]=t+"Error",e},{}),yi=Fe,X=Pe.reduce(function(e,t){var n=t+"Error";function i(o,f){this.name=n,o?typeof o=="string"?(this.message="".concat(o).concat(f?`
4
- `+f:""),this.inner=f||null):typeof o=="object"&&(this.message="".concat(o.name," ").concat(o.message),this.inner=o):(this.message=wr[t]||n,this.inner=null)}return W(i).from(yi),e[t]=i,e},{});X.Syntax=SyntaxError,X.Type=TypeError,X.Range=RangeError;var _r=Dt.reduce(function(e,t){return e[t+"Error"]=X[t],e},{}),Qt=Pe.reduce(function(e,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=X[t]),e},{});function ce(){}function Lt(e){return e}function gi(e,t){return e==null||e===Lt?t:function(n){return t(e(n))}}function st(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function vi(e,t){return e===ce?t:function(){var n=e.apply(this,arguments);n!==void 0&&(arguments[0]=n);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var f=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?st(i,this.onsuccess):i),o&&(this.onerror=this.onerror?st(o,this.onerror):o),f!==void 0?f:n}}function bi(e,t){return e===ce?t:function(){e.apply(this,arguments);var n=this.onsuccess,i=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?st(n,this.onsuccess):n),i&&(this.onerror=this.onerror?st(i,this.onerror):i)}}function wi(e,t){return e===ce?t:function(n){var i=e.apply(this,arguments);h(n,i);var o=this.onsuccess,f=this.onerror;return this.onsuccess=null,this.onerror=null,n=t.apply(this,arguments),o&&(this.onsuccess=this.onsuccess?st(o,this.onsuccess):o),f&&(this.onerror=this.onerror?st(f,this.onerror):f),i===void 0?n===void 0?void 0:n:h(i,n)}}function _i(e,t){return e===ce?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function On(e,t){return e===ce?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var i=this,o=arguments.length,f=new Array(o);o--;)f[o]=arguments[o];return n.then(function(){return t.apply(i,f)})}return t.apply(this,arguments)}}Qt.ModifyError=Yt,Qt.DexieError=Fe,Qt.BulkError=xt;var je=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Ar(e){je=e}var It={},xr=100,ot=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]}(),Dt=ot[0],Pe=ot[1],ot=ot[2],Pe=Pe&&Pe.then,at=Dt&&Dt.constructor,Cn=!!ot,Nt=function(e,t){Bt.push([e,t]),$t&&(queueMicrotask(xi),$t=!1)},Pn=!0,$t=!0,ut=[],Jt=[],Ln=Lt,Qe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ce,pgp:!1,env:{},finalize:ce},V=Qe,Bt=[],ct=0,Zt=[];function G(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=V;if(typeof e!="function"){if(e!==It)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Dn(this,this._value))}this._state=null,this._value=null,++t.ref,function n(i,o){try{o(function(f){if(i._state===null){if(f===i)throw new TypeError("A promise cannot be resolved with itself.");var d=i._lib&&Tt();f&&typeof f.then=="function"?n(i,function(m,v){f instanceof G?f._then(m,v):f.then(m,v)}):(i._state=!0,i._value=f,Sr(i)),d&&St()}},Dn.bind(null,i))}catch(f){Dn(i,f)}}(this,e)}var In={get:function(){var e=V,t=rn;function n(i,o){var f=this,d=!e.global&&(e!==V||t!==rn),m=d&&!Je(),v=new G(function(w,S){Nn(f,new Tr(Rr(i,e,d,m),Rr(o,e,d,m),w,S,e))});return this._consoleTask&&(v._consoleTask=this._consoleTask),v}return n.prototype=It,n},set:function(e){q(this,"then",e&&e.prototype===It?In:{get:function(){return e},set:In.set})}};function Tr(e,t,n,i,o){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=i,this.psd=o}function Dn(e,t){var n,i;Jt.push(t),e._state===null&&(n=e._lib&&Tt(),t=Ln(t),e._state=!1,e._value=t,i=e,ut.some(function(o){return o._value===i._value})||ut.push(i),Sr(e),n&&St())}function Sr(e){var t=e._listeners;e._listeners=[];for(var n=0,i=t.length;n<i;++n)Nn(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),ct===0&&(++ct,Nt(function(){--ct==0&&Bn()},[]))}function Nn(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,++ct,Nt(Ai,[n,e,t])}else e._listeners.push(t)}function Ai(e,t,n){try{var i,o=t._value;!t._state&&Jt.length&&(Jt=[]),i=je&&t._consoleTask?t._consoleTask.run(function(){return e(o)}):e(o),t._state||Jt.indexOf(o)!==-1||function(f){for(var d=ut.length;d;)if(ut[--d]._value===f._value)return ut.splice(d,1)}(t),n.resolve(i)}catch(f){n.reject(f)}finally{--ct==0&&Bn(),--n.psd.ref||n.psd.finalize()}}function xi(){lt(Qe,function(){Tt()&&St()})}function Tt(){var e=Pn;return $t=Pn=!1,e}function St(){var e,t,n;do for(;0<Bt.length;)for(e=Bt,Bt=[],n=e.length,t=0;t<n;++t){var i=e[t];i[0].apply(null,i[1])}while(0<Bt.length);$t=Pn=!0}function Bn(){var e=ut;ut=[],e.forEach(function(i){i._PSD.onunhandled.call(null,i._value,i)});for(var t=Zt.slice(0),n=t.length;n;)t[--n]()}function en(e){return new G(It,!1,e)}function de(e,t){var n=V;return function(){var i=Tt(),o=V;try{return Ze(n,!0),e.apply(this,arguments)}catch(f){t&&t(f)}finally{Ze(o,!1),i&&St()}}}P(G.prototype,{then:In,_then:function(e,t){Nn(this,new Tr(null,null,e,t,V))},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(i){return(i instanceof t?n:en)(i)}):this.then(null,function(i){return(i&&i.name===t?n:en)(i)})},finally:function(e){return this.then(function(t){return G.resolve(e()).then(function(){return t})},function(t){return G.resolve(e()).then(function(){return en(t)})})},timeout:function(e,t){var n=this;return e<1/0?new G(function(i,o){var f=setTimeout(function(){return o(new X.Timeout(t))},e);n.then(i,o).finally(clearTimeout.bind(null,f))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&q(G.prototype,Symbol.toStringTag,"Dexie.Promise"),Qe.env=Er(),P(G,{all:function(){var e=De.apply(null,arguments).map(sn);return new G(function(t,n){e.length===0&&t([]);var i=e.length;e.forEach(function(o,f){return G.resolve(o).then(function(d){e[f]=d,--i||t(e)},n)})})},resolve:function(e){return e instanceof G?e:e&&typeof e.then=="function"?new G(function(t,n){e.then(t,n)}):new G(It,!0,e)},reject:en,race:function(){var e=De.apply(null,arguments).map(sn);return new G(function(t,n){e.map(function(i){return G.resolve(i).then(t,n)})})},PSD:{get:function(){return V},set:function(e){return V=e}},totalEchoes:{get:function(){return rn}},newPSD:$e,usePSD:lt,scheduler:{get:function(){return Nt},set:function(e){Nt=e}},rejectionMapper:{get:function(){return Ln},set:function(e){Ln=e}},follow:function(e,t){return new G(function(n,i){return $e(function(o,f){var d=V;d.unhandleds=[],d.onunhandled=f,d.finalize=st(function(){var m,v=this;m=function(){v.unhandleds.length===0?o():f(v.unhandleds[0])},Zt.push(function w(){m(),Zt.splice(Zt.indexOf(w),1)}),++ct,Nt(function(){--ct==0&&Bn()},[])},d.finalize),e()},t,n,i)})}}),at&&(at.allSettled&&q(G,"allSettled",function(){var e=De.apply(null,arguments).map(sn);return new G(function(t){e.length===0&&t([]);var n=e.length,i=new Array(n);e.forEach(function(o,f){return G.resolve(o).then(function(d){return i[f]={status:"fulfilled",value:d}},function(d){return i[f]={status:"rejected",reason:d}}).then(function(){return--n||t(i)})})})}),at.any&&typeof AggregateError<"u"&&q(G,"any",function(){var e=De.apply(null,arguments).map(sn);return new G(function(t,n){e.length===0&&n(new AggregateError([]));var i=e.length,o=new Array(i);e.forEach(function(f,d){return G.resolve(f).then(function(m){return t(m)},function(m){o[d]=m,--i||n(new AggregateError(o))})})})}),at.withResolvers&&(G.withResolvers=at.withResolvers));var we={awaits:0,echoes:0,id:0},Ti=0,tn=[],nn=0,rn=0,Si=0;function $e(e,t,n,i){var o=V,f=Object.create(o);return f.parent=o,f.ref=0,f.global=!1,f.id=++Si,Qe.env,f.env=Cn?{Promise:G,PromiseProp:{value:G,configurable:!0,writable:!0},all:G.all,race:G.race,allSettled:G.allSettled,any:G.any,resolve:G.resolve,reject:G.reject}:{},t&&h(f,t),++o.ref,f.finalize=function(){--this.parent.ref||this.parent.finalize()},i=lt(f,e,n,i),f.ref===0&&f.finalize(),i}function Et(){return we.id||(we.id=++Ti),++we.awaits,we.echoes+=xr,we.id}function Je(){return!!we.awaits&&(--we.awaits==0&&(we.id=0),we.echoes=we.awaits*xr,!0)}function sn(e){return we.echoes&&e&&e.constructor===at?(Et(),e.then(function(t){return Je(),t},function(t){return Je(),ye(t)})):e}function Ei(){var e=tn[tn.length-1];tn.pop(),Ze(e,!1)}function Ze(e,t){var n,i=V;(t?!we.echoes||nn++&&e===V:!nn||--nn&&e===V)||queueMicrotask(t?(function(o){++rn,we.echoes&&--we.echoes!=0||(we.echoes=we.awaits=we.id=0),tn.push(V),Ze(o,!0)}).bind(null,e):Ei),e!==V&&(V=e,i===Qe&&(Qe.env=Er()),Cn&&(n=Qe.env.Promise,t=e.env,(i.global||e.global)&&(Object.defineProperty(c,"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 Er(){var e=c.Promise;return Cn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(c,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function lt(e,t,n,i,o){var f=V;try{return Ze(e,!0),t(n,i,o)}finally{Ze(f,!1)}}function Rr(e,t,n,i){return typeof e!="function"?e:function(){var o=V;n&&Et(),Ze(t,!0);try{return e.apply(this,arguments)}finally{Ze(o,!1),i&&queueMicrotask(Je)}}}function Fn(e){Promise===at&&we.echoes===0?nn===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(""+Pe).indexOf("[native code]")===-1&&(Et=Je=ce);var ye=G.reject,ft="￿",ze="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",kr="String expected.",Rt=[],on="__dbnames",jn="readonly",Kn="readwrite";function ht(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Mr={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function an(e){return typeof e!="string"||/\./.test(e)?function(t){return t}:function(t){return t[e]===void 0&&e in t&&delete(t=ke(t))[e],t}}function Or(){throw X.Type()}function ie(e,t){try{var n=Cr(e),i=Cr(t);if(n!==i)return n==="Array"?1:i==="Array"?-1:n==="binary"?1:i==="binary"?-1:n==="string"?1:i==="string"?-1:n==="Date"?1:i!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(o,f){for(var d=o.length,m=f.length,v=d<m?d:m,w=0;w<v;++w)if(o[w]!==f[w])return o[w]<f[w]?-1:1;return d===m?0:d<m?-1:1}(Pr(e),Pr(t));case"Array":return function(o,f){for(var d=o.length,m=f.length,v=d<m?d:m,w=0;w<v;++w){var S=ie(o[w],f[w]);if(S!==0)return S}return d===m?0:d<m?-1:1}(e,t)}}catch{}return NaN}function Cr(e){var t=typeof e;return t!="object"?t:ArrayBuffer.isView(e)?"binary":(e=_t(e),e==="ArrayBuffer"?"binary":e)}function Pr(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Lr=(fe.prototype._trans=function(e,t,n){var i=this._tx||V.trans,o=this.name,f=je&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(e==="readonly"?"read":"write"," ").concat(this.name));function d(w,S,g){if(!g.schema[o])throw new X.NotFound("Table "+o+" not part of transaction");return t(g.idbtrans,g)}var m=Tt();try{var v=i&&i.db._novip===this.db._novip?i===V.trans?i._promise(e,d,n):$e(function(){return i._promise(e,d,n)},{trans:i,transless:V.transless||V}):function w(S,g,k,b){if(S.idbdb&&(S._state.openComplete||V.letThrough||S._vip)){var T=S._createTransaction(g,k,S._dbSchema);try{T.create(),S._state.PR1398_maxLoop=3}catch(R){return R.name===Mn.InvalidState&&S.isOpen()&&0<--S._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),S.close({disableAutoOpen:!1}),S.open().then(function(){return w(S,g,k,b)})):ye(R)}return T._promise(g,function(R,A){return $e(function(){return V.trans=T,b(R,A,T)})}).then(function(R){if(g==="readwrite")try{T.idbtrans.commit()}catch{}return g==="readonly"?R:T._completion.then(function(){return R})})}if(S._state.openComplete)return ye(new X.DatabaseClosed(S._state.dbOpenError));if(!S._state.isBeingOpened){if(!S._state.autoOpen)return ye(new X.DatabaseClosed);S.open().catch(ce)}return S._state.dbReadyPromise.then(function(){return w(S,g,k,b)})}(this.db,e,[this.name],d);return f&&(v._consoleTask=f,v=v.catch(function(w){return console.trace(w),ye(w)})),v}finally{m&&St()}},fe.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):e==null?ye(new X.Type("Invalid argument to Table.get()")):this._trans("readonly",function(i){return n.core.get({trans:i,key:e}).then(function(o){return n.hook.reading.fire(o)})}).then(t)},fe.prototype.where=function(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(p(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=l(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(m){if(m.compound&&t.every(function(w){return 0<=m.keyPath.indexOf(w)})){for(var v=0;v<t.length;++v)if(t.indexOf(m.keyPath[v])===-1)return!1;return!0}return!1}).sort(function(m,v){return m.keyPath.length-v.keyPath.length})[0];if(n&&this.db._maxKey!==ft){var f=n.keyPath.slice(0,t.length);return this.where(f).equals(f.map(function(v){return e[v]}))}!n&&je&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(t.join("+"),"]"));var i=this.schema.idxByName;function o(m,v){return ie(m,v)===0}var d=t.reduce(function(g,v){var w=g[0],S=g[1],g=i[v],k=e[v];return[w||g,w||!g?ht(S,g&&g.multi?function(b){return b=ve(b,v),p(b)&&b.some(function(T){return o(k,T)})}:function(b){return o(k,ve(b,v))}):S]},[null,null]),f=d[0],d=d[1];return f?this.where(f.name).equals(e[f.keyPath]).filter(d):n?this.filter(d):this.where(t).equals("")},fe.prototype.filter=function(e){return this.toCollection().and(e)},fe.prototype.count=function(e){return this.toCollection().count(e)},fe.prototype.offset=function(e){return this.toCollection().offset(e)},fe.prototype.limit=function(e){return this.toCollection().limit(e)},fe.prototype.each=function(e){return this.toCollection().each(e)},fe.prototype.toArray=function(e){return this.toCollection().toArray(e)},fe.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},fe.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,p(e)?"[".concat(e.join("+"),"]"):e))},fe.prototype.reverse=function(){return this.toCollection().reverse()},fe.prototype.mapToClass=function(e){var t,n=this.db,i=this.name;function o(){return t!==null&&t.apply(this,arguments)||this}(this.schema.mappedClass=e).prototype instanceof Or&&(function(v,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");function S(){this.constructor=v}s(v,w),v.prototype=w===null?Object.create(w):(S.prototype=w.prototype,new S)}(o,t=e),Object.defineProperty(o.prototype,"db",{get:function(){return n},enumerable:!1,configurable:!0}),o.prototype.table=function(){return i},e=o);for(var f=new Set,d=e.prototype;d;d=y(d))Object.getOwnPropertyNames(d).forEach(function(v){return f.add(v)});function m(v){if(!v)return v;var w,S=Object.create(e.prototype);for(w in v)if(!f.has(w))try{S[w]=v[w]}catch{}return S}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=m,this.hook("reading",m),e},fe.prototype.defineClass=function(){return this.mapToClass(function(e){h(this,e)})},fe.prototype.add=function(e,t){var n=this,i=this.schema.primKey,o=i.auto,f=i.keyPath,d=e;return f&&o&&(d=an(f)(e)),this._trans("readwrite",function(m){return n.core.mutate({trans:m,type:"add",keys:t!=null?[t]:null,values:[d]})}).then(function(m){return m.numFailures?G.reject(m.failures[0]):m.lastResult}).then(function(m){if(f)try{le(e,f,m)}catch{}return m})},fe.prototype.update=function(e,t){return typeof e!="object"||p(e)?this.where(":id").equals(e).modify(t):(e=ve(e,this.schema.primKey.keyPath),e===void 0?ye(new X.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t))},fe.prototype.put=function(e,t){var n=this,i=this.schema.primKey,o=i.auto,f=i.keyPath,d=e;return f&&o&&(d=an(f)(e)),this._trans("readwrite",function(m){return n.core.mutate({trans:m,type:"put",values:[d],keys:t!=null?[t]:null})}).then(function(m){return m.numFailures?G.reject(m.failures[0]):m.lastResult}).then(function(m){if(f)try{le(e,f,m)}catch{}return m})},fe.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?G.reject(n.failures[0]):void 0})},fe.prototype.clear=function(){var e=this;return this._trans("readwrite",function(t){return e.core.mutate({trans:t,type:"deleteRange",range:Mr})}).then(function(t){return t.numFailures?G.reject(t.failures[0]):void 0})},fe.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",function(n){return t.core.getMany({keys:e,trans:n}).then(function(i){return i.map(function(o){return t.hook.reading.fire(o)})})})},fe.prototype.bulkAdd=function(e,t,n){var i=this,o=Array.isArray(t)?t:void 0,f=(n=n||(o?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(d){var w=i.schema.primKey,m=w.auto,w=w.keyPath;if(w&&o)throw new X.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");var v=e.length,w=w&&m?e.map(an(w)):e;return i.core.mutate({trans:d,type:"add",keys:o,values:w,wantResults:f}).then(function(T){var g=T.numFailures,k=T.results,b=T.lastResult,T=T.failures;if(g===0)return f?k:b;throw new xt("".concat(i.name,".bulkAdd(): ").concat(g," of ").concat(v," operations failed"),T)})})},fe.prototype.bulkPut=function(e,t,n){var i=this,o=Array.isArray(t)?t:void 0,f=(n=n||(o?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(d){var w=i.schema.primKey,m=w.auto,w=w.keyPath;if(w&&o)throw new X.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");var v=e.length,w=w&&m?e.map(an(w)):e;return i.core.mutate({trans:d,type:"put",keys:o,values:w,wantResults:f}).then(function(T){var g=T.numFailures,k=T.results,b=T.lastResult,T=T.failures;if(g===0)return f?k:b;throw new xt("".concat(i.name,".bulkPut(): ").concat(g," of ").concat(v," operations failed"),T)})})},fe.prototype.bulkUpdate=function(e){var t=this,n=this.core,i=e.map(function(d){return d.key}),o=e.map(function(d){return d.changes}),f=[];return this._trans("readwrite",function(d){return n.getMany({trans:d,keys:i,cache:"clone"}).then(function(m){var v=[],w=[];e.forEach(function(g,k){var b=g.key,T=g.changes,R=m[k];if(R){for(var A=0,M=Object.keys(T);A<M.length;A++){var O=M[A],C=T[O];if(O===t.schema.primKey.keyPath){if(ie(C,b)!==0)throw new X.Constraint("Cannot update primary key in bulkUpdate()")}else le(R,O,C)}f.push(k),v.push(b),w.push(R)}});var S=v.length;return n.mutate({trans:d,type:"put",keys:v,values:w,updates:{keys:i,changeSpecs:o}}).then(function(g){var k=g.numFailures,b=g.failures;if(k===0)return S;for(var T=0,R=Object.keys(b);T<R.length;T++){var A,M=R[T],O=f[Number(M)];O!=null&&(A=b[M],delete b[M],b[O]=A)}throw new xt("".concat(t.name,".bulkUpdate(): ").concat(k," of ").concat(S," operations failed"),b)})})})},fe.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",function(i){return t.core.mutate({trans:i,type:"delete",keys:e})}).then(function(d){var o=d.numFailures,f=d.lastResult,d=d.failures;if(o===0)return f;throw new xt("".concat(t.name,".bulkDelete(): ").concat(o," of ").concat(n," operations failed"),d)})},fe);function fe(){}function Ft(e){function t(d,m){if(m){for(var v=arguments.length,w=new Array(v-1);--v;)w[v-1]=arguments[v];return n[d].subscribe.apply(null,w),e}if(typeof d=="string")return n[d]}var n={};t.addEventType=f;for(var i=1,o=arguments.length;i<o;++i)f(arguments[i]);return t;function f(d,m,v){if(typeof d!="object"){var w;m=m||_i;var S={subscribers:[],fire:v=v||ce,subscribe:function(g){S.subscribers.indexOf(g)===-1&&(S.subscribers.push(g),S.fire=m(S.fire,g))},unsubscribe:function(g){S.subscribers=S.subscribers.filter(function(k){return k!==g}),S.fire=S.subscribers.reduce(m,v)}};return n[d]=t[d]=S}l(w=d).forEach(function(g){var k=w[g];if(p(k))f(g,w[g][0],w[g][1]);else{if(k!=="asap")throw new X.InvalidArgument("Invalid event config");var b=f(g,Lt,function(){for(var T=arguments.length,R=new Array(T);T--;)R[T]=arguments[T];b.subscribers.forEach(function(A){Ae(function(){A.apply(null,R)})})})}})}}function jt(e,t){return W(t).from({prototype:e}),t}function kt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Un(e,t){e.filter=ht(e.filter,t)}function Gn(e,t,n){var i=e.replayFilter;e.replayFilter=i?function(){return ht(i(),t())}:t,e.justLimit=n&&!i}function un(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new X.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Ir(e,t,n){var i=un(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:i,range:e.range}})}function cn(e,t,n,i){var o=e.replayFilter?ht(e.filter,e.replayFilter()):e.filter;if(e.or){var f={},d=function(m,v,w){var S,g;o&&!o(v,w,function(k){return v.stop(k)},function(k){return v.fail(k)})||((g=""+(S=v.primaryKey))=="[object ArrayBuffer]"&&(g=""+new Uint8Array(S)),_(f,g)||(f[g]=!0,t(m,v,w)))};return Promise.all([e.or._iterate(d,n),Dr(Ir(e,i,n),e.algorithm,d,!e.keysOnly&&e.valueMapper)])}return Dr(Ir(e,i,n),ht(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function Dr(e,t,n,i){var o=de(i?function(f,d,m){return n(i(f),d,m)}:n);return e.then(function(f){if(f)return f.start(function(){var d=function(){return f.continue()};t&&!t(f,function(m){return d=m},function(m){f.stop(m),d=ce},function(m){f.fail(m),d=ce})||o(f.value,f,function(m){return d=m}),d()})})}var Kt=(Nr.prototype.execute=function(e){var t=this["@@propmod"];if(t.add!==void 0){var n=t.add;if(p(n))return u(u([],p(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 i=t.remove;if(p(i))return p(e)?e.filter(function(o){return!i.includes(o)}).sort():[];if(typeof i=="number")return Number(e)-i;if(typeof i=="bigint")try{return BigInt(e)-i}catch{return BigInt(0)-i}throw new TypeError("Invalid subtrahend ".concat(i))}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 Ri=(oe.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,ye.bind(null,n.error)):n.table._trans("readonly",e).then(t)},oe.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,ye.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},oe.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=ht(t.algorithm,e)},oe.prototype._iterate=function(e,t){return cn(this._ctx,e,t,this._ctx.table.core)},oe.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&h(n,e),t._ctx=n,t},oe.prototype.raw=function(){return this._ctx.valueMapper=null,this},oe.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return cn(t,e,n,t.table.core)})},oe.prototype.count=function(e){var t=this;return this._read(function(n){var i=t._ctx,o=i.table.core;if(kt(i,!0))return o.count({trans:n,query:{index:un(i,o.schema),range:i.range}}).then(function(d){return Math.min(d,i.limit)});var f=0;return cn(i,function(){return++f,!1},n,o).then(function(){return f})}).then(e)},oe.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),i=n[0],o=n.length-1;function f(v,w){return w?f(v[n[w]],w-1):v[i]}var d=this._ctx.dir==="next"?1:-1;function m(v,w){return ie(f(v,o),f(w,o))*d}return this.toArray(function(v){return v.sort(m)}).then(t)},oe.prototype.toArray=function(e){var t=this;return this._read(function(n){var i=t._ctx;if(i.dir==="next"&&kt(i,!0)&&0<i.limit){var o=i.valueMapper,f=un(i,i.table.core.schema);return i.table.core.query({trans:n,limit:i.limit,values:!0,query:{index:f,range:i.range}}).then(function(m){return m=m.result,o?m.map(o):m})}var d=[];return cn(i,function(m){return d.push(m)},n,i.table.core).then(function(){return d})},e)},oe.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,kt(t)?Gn(t,function(){var n=e;return function(i,o){return n===0||(n===1?--n:o(function(){i.advance(n),n=0}),!1)}}):Gn(t,function(){var n=e;return function(){return--n<0}})),this},oe.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Gn(this._ctx,function(){var t=e;return function(n,i,o){return--t<=0&&i(o),0<=t}},!0),this},oe.prototype.until=function(e,t){return Un(this._ctx,function(n,i,o){return!e(n.value)||(i(o),t)}),this},oe.prototype.first=function(e){return this.limit(1).toArray(function(t){return t[0]}).then(e)},oe.prototype.last=function(e){return this.reverse().first(e)},oe.prototype.filter=function(e){var t;return Un(this._ctx,function(n){return e(n.value)}),(t=this._ctx).isMatch=ht(t.isMatch,e),this},oe.prototype.and=function(e){return this.filter(e)},oe.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},oe.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},oe.prototype.desc=function(){return this.reverse()},oe.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,i){e(i.key,i)})},oe.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},oe.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,i){e(i.primaryKey,i)})},oe.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(i,o){n.push(o.key)}).then(function(){return n}).then(e)},oe.prototype.primaryKeys=function(e){var t=this._ctx;if(t.dir==="next"&&kt(t,!0)&&0<t.limit)return this._read(function(i){var o=un(t,t.table.core.schema);return t.table.core.query({trans:i,values:!1,limit:t.limit,query:{index:o,range:t.range}})}).then(function(i){return i.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(i,o){n.push(o.primaryKey)}).then(function(){return n}).then(e)},oe.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},oe.prototype.firstKey=function(e){return this.limit(1).keys(function(t){return t[0]}).then(e)},oe.prototype.lastKey=function(e){return this.reverse().firstKey(e)},oe.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 Un(this._ctx,function(o){var i=o.primaryKey.toString(),o=_(t,i);return t[i]=!0,!o}),this},oe.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(i){var o,f,d;d=typeof e=="function"?e:(o=l(e),f=o.length,function(A){for(var M=!1,O=0;O<f;++O){var C=o[O],I=e[C],N=ve(A,C);I instanceof Kt?(le(A,C,I.execute(N)),M=!0):N!==I&&(le(A,C,I),M=!0)}return M});var m=n.table.core,g=m.schema.primaryKey,v=g.outbound,w=g.extractKey,S=200,g=t.db._options.modifyChunkSize;g&&(S=typeof g=="object"?g[m.name]||g["*"]||200:g);function k(A,C){var O=C.failures,C=C.numFailures;T+=A-C;for(var I=0,N=l(O);I<N.length;I++){var K=N[I];b.push(O[K])}}var b=[],T=0,R=[];return t.clone().primaryKeys().then(function(A){function M(C){var I=Math.min(S,A.length-C);return m.getMany({trans:i,keys:A.slice(C,C+I),cache:"immutable"}).then(function(N){for(var K=[],B=[],F=v?[]:null,U=[],j=0;j<I;++j){var H=N[j],J={value:ke(H),primKey:A[C+j]};d.call(J,J.value,J)!==!1&&(J.value==null?U.push(A[C+j]):v||ie(w(H),w(J.value))===0?(B.push(J.value),v&&F.push(A[C+j])):(U.push(A[C+j]),K.push(J.value)))}return Promise.resolve(0<K.length&&m.mutate({trans:i,type:"add",values:K}).then(function(te){for(var ne in te.failures)U.splice(parseInt(ne),1);k(K.length,te)})).then(function(){return(0<B.length||O&&typeof e=="object")&&m.mutate({trans:i,type:"put",keys:F,values:B,criteria:O,changeSpec:typeof e!="function"&&e,isAdditionalChunk:0<C}).then(function(te){return k(B.length,te)})}).then(function(){return(0<U.length||O&&e===qn)&&m.mutate({trans:i,type:"delete",keys:U,criteria:O,isAdditionalChunk:0<C}).then(function(te){return k(U.length,te)})}).then(function(){return A.length>C+I&&M(C+S)})})}var O=kt(n)&&n.limit===1/0&&(typeof e!="function"||e===qn)&&{index:n.index,range:n.range};return M(0).then(function(){if(0<b.length)throw new Yt("Error modifying one or more objects",b,T,R);return A.length})})})},oe.prototype.delete=function(){var e=this._ctx,t=e.range;return kt(e)&&(e.isPrimKey||t.type===3)?this._write(function(n){var i=e.table.core.schema.primaryKey,o=t;return e.table.core.count({trans:n,query:{index:i,range:o}}).then(function(f){return e.table.core.mutate({trans:n,type:"deleteRange",range:o}).then(function(d){var m=d.failures;if(d.lastResult,d.results,d=d.numFailures,d)throw new Yt("Could not delete some values",Object.keys(m).map(function(v){return m[v]}),f-d);return f-d})})}):this.modify(qn)},oe);function oe(){}var qn=function(e,t){return t.value=null};function ki(e,t){return e<t?-1:e===t?0:1}function Mi(e,t){return t<e?-1:e===t?0:1}function Me(e,t,n){return e=e instanceof Fr?new e.Collection(e):e,e._ctx.error=new(n||TypeError)(t),e}function Mt(e){return new e.Collection(e,function(){return Br("")}).limit(0)}function ln(e,t,n,i){var o,f,d,m,v,w,S,g=n.length;if(!n.every(function(T){return typeof T=="string"}))return Me(e,kr);function k(T){o=T==="next"?function(A){return A.toUpperCase()}:function(A){return A.toLowerCase()},f=T==="next"?function(A){return A.toLowerCase()}:function(A){return A.toUpperCase()},d=T==="next"?ki:Mi;var R=n.map(function(A){return{lower:f(A),upper:o(A)}}).sort(function(A,M){return d(A.lower,M.lower)});m=R.map(function(A){return A.upper}),v=R.map(function(A){return A.lower}),S=(w=T)==="next"?"":i}k("next"),e=new e.Collection(e,function(){return et(m[0],v[g-1]+i)}),e._ondirectionchange=function(T){k(T)};var b=0;return e._addAlgorithm(function(T,R,A){var M=T.key;if(typeof M!="string")return!1;var O=f(M);if(t(O,v,b))return!0;for(var C=null,I=b;I<g;++I){var N=function(K,B,F,U,j,H){for(var J=Math.min(K.length,U.length),te=-1,ne=0;ne<J;++ne){var Oe=B[ne];if(Oe!==U[ne])return j(K[ne],F[ne])<0?K.substr(0,ne)+F[ne]+F.substr(ne+1):j(K[ne],U[ne])<0?K.substr(0,ne)+U[ne]+F.substr(ne+1):0<=te?K.substr(0,te)+B[te]+F.substr(te+1):null;j(K[ne],Oe)<0&&(te=ne)}return J<U.length&&H==="next"?K+F.substr(K.length):J<K.length&&H==="prev"?K.substr(0,F.length):te<0?null:K.substr(0,te)+U[te]+F.substr(te+1)}(M,O,m[I],v[I],d,w);N===null&&C===null?b=I+1:(C===null||0<d(C,N))&&(C=N)}return R(C!==null?function(){T.continue(C+S)}:A),!1}),e}function et(e,t,n,i){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:i}}function Br(e){return{type:1,lower:e,upper:e}}var Fr=(Object.defineProperty(_e.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),_e.prototype.between=function(e,t,n,i){n=n!==!1,i=i===!0;try{return 0<this._cmp(e,t)||this._cmp(e,t)===0&&(n||i)&&(!n||!i)?Mt(this):new this.Collection(this,function(){return et(e,t,!n,!i)})}catch{return Me(this,ze)}},_e.prototype.equals=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return Br(e)})},_e.prototype.above=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return et(e,void 0,!0)})},_e.prototype.aboveOrEqual=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return et(e,void 0,!1)})},_e.prototype.below=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return et(void 0,e,!1,!0)})},_e.prototype.belowOrEqual=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return et(void 0,e)})},_e.prototype.startsWith=function(e){return typeof e!="string"?Me(this,kr):this.between(e,e+ft,!0,!0)},_e.prototype.startsWithIgnoreCase=function(e){return e===""?this.startsWith(e):ln(this,function(t,n){return t.indexOf(n[0])===0},[e],ft)},_e.prototype.equalsIgnoreCase=function(e){return ln(this,function(t,n){return t===n[0]},[e],"")},_e.prototype.anyOfIgnoreCase=function(){var e=De.apply(Ye,arguments);return e.length===0?Mt(this):ln(this,function(t,n){return n.indexOf(t)!==-1},e,"")},_e.prototype.startsWithAnyOfIgnoreCase=function(){var e=De.apply(Ye,arguments);return e.length===0?Mt(this):ln(this,function(t,n){return n.some(function(i){return t.indexOf(i)===0})},e,ft)},_e.prototype.anyOf=function(){var e=this,t=De.apply(Ye,arguments),n=this._cmp;try{t.sort(n)}catch{return Me(this,ze)}if(t.length===0)return Mt(this);var i=new this.Collection(this,function(){return et(t[0],t[t.length-1])});i._ondirectionchange=function(f){n=f==="next"?e._ascending:e._descending,t.sort(n)};var o=0;return i._addAlgorithm(function(f,d,m){for(var v=f.key;0<n(v,t[o]);)if(++o===t.length)return d(m),!1;return n(v,t[o])===0||(d(function(){f.continue(t[o])}),!1)}),i},_e.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},_e.prototype.noneOf=function(){var e=De.apply(Ye,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Me(this,ze)}var t=e.reduce(function(n,i){return n?n.concat([[n[n.length-1][1],i]]):[[-1/0,i]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},_e.prototype.inAnyRange=function(M,t){var n=this,i=this._cmp,o=this._ascending,f=this._descending,d=this._min,m=this._max;if(M.length===0)return Mt(this);if(!M.every(function(O){return O[0]!==void 0&&O[1]!==void 0&&o(O[0],O[1])<=0}))return Me(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",X.InvalidArgument);var v=!t||t.includeLowers!==!1,w=t&&t.includeUppers===!0,S,g=o;function k(O,C){return g(O[0],C[0])}try{(S=M.reduce(function(O,C){for(var I=0,N=O.length;I<N;++I){var K=O[I];if(i(C[0],K[1])<0&&0<i(C[1],K[0])){K[0]=d(K[0],C[0]),K[1]=m(K[1],C[1]);break}}return I===N&&O.push(C),O},[])).sort(k)}catch{return Me(this,ze)}var b=0,T=w?function(O){return 0<o(O,S[b][1])}:function(O){return 0<=o(O,S[b][1])},R=v?function(O){return 0<f(O,S[b][0])}:function(O){return 0<=f(O,S[b][0])},A=T,M=new this.Collection(this,function(){return et(S[0][0],S[S.length-1][1],!v,!w)});return M._ondirectionchange=function(O){g=O==="next"?(A=T,o):(A=R,f),S.sort(k)},M._addAlgorithm(function(O,C,I){for(var N,K=O.key;A(K);)if(++b===S.length)return C(I),!1;return!T(N=K)&&!R(N)||(n._cmp(K,S[b][1])===0||n._cmp(K,S[b][0])===0||C(function(){g===o?O.continue(S[b][0]):O.continue(S[b][1])}),!1)}),M},_e.prototype.startsWithAnyOf=function(){var e=De.apply(Ye,arguments);return e.every(function(t){return typeof t=="string"})?e.length===0?Mt(this):this.inAnyRange(e.map(function(t){return[t,t+ft]})):Me(this,"startsWithAnyOf() only works with strings")},_e);function _e(){}function Ke(e){return de(function(t){return Ut(t),e(t.target.error),!1})}function Ut(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Gt="storagemutated",Hn="x-storagemutated-1",tt=Ft(null,Gt),Oi=(Ue.prototype._lock=function(){return Z(!V.global),++this._reculock,this._reculock!==1||V.global||(V.lockOwnerFor=this),this},Ue.prototype._unlock=function(){if(Z(!V.global),--this._reculock==0)for(V.global||(V.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{lt(e[1],e[0])}catch{}}return this},Ue.prototype._locked=function(){return this._reculock&&V.lockOwnerFor!==this},Ue.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,i=this.db._state.dbOpenError;if(Z(!this.idbtrans),!e&&!n)switch(i&&i.name){case"DatabaseClosedError":throw new X.DatabaseClosed(i);case"MissingAPIError":throw new X.MissingAPI(i.message,i);default:throw new X.OpenFailed(i)}if(!this.active)throw new X.TransactionInactive;return Z(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=de(function(o){Ut(o),t._reject(e.error)}),e.onabort=de(function(o){Ut(o),t.active&&t._reject(new X.Abort(e.error)),t.active=!1,t.on("abort").fire(o)}),e.oncomplete=de(function(){t.active=!1,t._resolve(),"mutatedParts"in e&&tt.storagemutated.fire(e.mutatedParts)}),this},Ue.prototype._promise=function(e,t,n){var i=this;if(e==="readwrite"&&this.mode!=="readwrite")return ye(new X.ReadOnly("Transaction is readonly"));if(!this.active)return ye(new X.TransactionInactive);if(this._locked())return new G(function(f,d){i._blockedFuncs.push([function(){i._promise(e,t,n).then(f,d)},V])});if(n)return $e(function(){var f=new G(function(d,m){i._lock();var v=t(d,m,i);v&&v.then&&v.then(d,m)});return f.finally(function(){return i._unlock()}),f._lib=!0,f});var o=new G(function(f,d){var m=t(f,d,i);m&&m.then&&m.then(f,d)});return o._lib=!0,o},Ue.prototype._root=function(){return this.parent?this.parent._root():this},Ue.prototype.waitFor=function(e){var t,n=this._root(),i=G.resolve(e);n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return i}):(n._waitingFor=i,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function f(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=f)}());var o=n._waitingFor;return new G(function(f,d){i.then(function(m){return n._waitingQueue.push(de(f.bind(null,m)))},function(m){return n._waitingQueue.push(de(d.bind(null,m)))}).finally(function(){n._waitingFor===o&&(n._waitingFor=null)})})},Ue.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new X.Abort))},Ue.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(_(t,e))return t[e];var n=this.schema[e];if(!n)throw new X.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},Ue);function Ue(){}function zn(e,t,n,i,o,f,d){return{name:e,keyPath:t,unique:n,multi:i,auto:o,compound:f,src:(n&&!d?"&":"")+(i?"*":"")+(o?"++":"")+jr(t)}}function jr(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Vn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(i=function(o){return[o.name,o]},n.reduce(function(o,f,d){return d=i(f,d),d&&(o[d[0]]=d[1]),o},{}))};var i}var qt=function(e){try{return e.only([[]]),qt=function(){return[[]]},[[]]}catch{return qt=function(){return ft},ft}};function Xn(e){return e==null?function(){}:typeof e=="string"?(t=e).split(".").length===1?function(n){return n[t]}:function(n){return ve(n,t)}:function(n){return ve(n,e)};var t}function Kr(e){return[].slice.call(e)}var Ci=0;function Ht(e){return e==null?":id":typeof e=="string"?e:"[".concat(e.join("+"),"]")}function Pi(e,t,v){function i(A){if(A.type===3)return null;if(A.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var b=A.lower,T=A.upper,R=A.lowerOpen,A=A.upperOpen;return b===void 0?T===void 0?null:t.upperBound(T,!!A):T===void 0?t.lowerBound(b,!!R):t.bound(b,T,!!R,!!A)}function o(k){var b,T=k.name;return{name:T,schema:k,mutate:function(R){var A=R.trans,M=R.type,O=R.keys,C=R.values,I=R.range;return new Promise(function(N,K){N=de(N);var B=A.objectStore(T),F=B.keyPath==null,U=M==="put"||M==="add";if(!U&&M!=="delete"&&M!=="deleteRange")throw new Error("Invalid operation type: "+M);var j,H=(O||C||{length:1}).length;if(O&&C&&O.length!==C.length)throw new Error("Given keys array must have same length as given values array.");if(H===0)return N({numFailures:0,failures:{},results:[],lastResult:void 0});function J(Ee){++Oe,Ut(Ee)}var te=[],ne=[],Oe=0;if(M==="deleteRange"){if(I.type===4)return N({numFailures:Oe,failures:ne,results:[],lastResult:void 0});I.type===3?te.push(j=B.clear()):te.push(j=B.delete(i(I)))}else{var F=U?F?[C,O]:[C,null]:[O,null],Q=F[0],Te=F[1];if(U)for(var Se=0;Se<H;++Se)te.push(j=Te&&Te[Se]!==void 0?B[M](Q[Se],Te[Se]):B[M](Q[Se])),j.onerror=J;else for(Se=0;Se<H;++Se)te.push(j=B[M](Q[Se])),j.onerror=J}function xn(Ee){Ee=Ee.target.result,te.forEach(function(mt,fr){return mt.error!=null&&(ne[fr]=mt.error)}),N({numFailures:Oe,failures:ne,results:M==="delete"?O:te.map(function(mt){return mt.result}),lastResult:Ee})}j.onerror=function(Ee){J(Ee),xn(Ee)},j.onsuccess=xn})},getMany:function(R){var A=R.trans,M=R.keys;return new Promise(function(O,C){O=de(O);for(var I,N=A.objectStore(T),K=M.length,B=new Array(K),F=0,U=0,j=function(te){te=te.target,B[te._pos]=te.result,++U===F&&O(B)},H=Ke(C),J=0;J<K;++J)M[J]!=null&&((I=N.get(M[J]))._pos=J,I.onsuccess=j,I.onerror=H,++F);F===0&&O(B)})},get:function(R){var A=R.trans,M=R.key;return new Promise(function(O,C){O=de(O);var I=A.objectStore(T).get(M);I.onsuccess=function(N){return O(N.target.result)},I.onerror=Ke(C)})},query:(b=w,function(R){return new Promise(function(A,M){A=de(A);var O,C,I,F=R.trans,N=R.values,K=R.limit,j=R.query,B=K===1/0?void 0:K,U=j.index,j=j.range,F=F.objectStore(T),U=U.isPrimaryKey?F:F.index(U.name),j=i(j);if(K===0)return A({result:[]});b?((B=N?U.getAll(j,B):U.getAllKeys(j,B)).onsuccess=function(H){return A({result:H.target.result})},B.onerror=Ke(M)):(O=0,C=!N&&"openKeyCursor"in U?U.openKeyCursor(j):U.openCursor(j),I=[],C.onsuccess=function(H){var J=C.result;return J?(I.push(N?J.value:J.primaryKey),++O===K?A({result:I}):void J.continue()):A({result:I})},C.onerror=Ke(M))})}),openCursor:function(R){var A=R.trans,M=R.values,O=R.query,C=R.reverse,I=R.unique;return new Promise(function(N,K){N=de(N);var U=O.index,B=O.range,F=A.objectStore(T),F=U.isPrimaryKey?F:F.index(U.name),U=C?I?"prevunique":"prev":I?"nextunique":"next",j=!M&&"openKeyCursor"in F?F.openKeyCursor(i(B),U):F.openCursor(i(B),U);j.onerror=Ke(K),j.onsuccess=de(function(H){var J,te,ne,Oe,Q=j.result;Q?(Q.___id=++Ci,Q.done=!1,J=Q.continue.bind(Q),te=(te=Q.continuePrimaryKey)&&te.bind(Q),ne=Q.advance.bind(Q),Oe=function(){throw new Error("Cursor not stopped")},Q.trans=A,Q.stop=Q.continue=Q.continuePrimaryKey=Q.advance=function(){throw new Error("Cursor not started")},Q.fail=de(K),Q.next=function(){var Te=this,Se=1;return this.start(function(){return Se--?Te.continue():Te.stop()}).then(function(){return Te})},Q.start=function(Te){function Se(){if(j.result)try{Te()}catch(Ee){Q.fail(Ee)}else Q.done=!0,Q.start=function(){throw new Error("Cursor behind last entry")},Q.stop()}var xn=new Promise(function(Ee,mt){Ee=de(Ee),j.onerror=Ke(mt),Q.fail=mt,Q.stop=function(fr){Q.stop=Q.continue=Q.continuePrimaryKey=Q.advance=Oe,Ee(fr)}});return j.onsuccess=de(function(Ee){j.onsuccess=Se,Se()}),Q.continue=J,Q.continuePrimaryKey=te,Q.advance=ne,Se(),xn},N(Q)):N(null)},K)})},count:function(R){var A=R.query,M=R.trans,O=A.index,C=A.range;return new Promise(function(I,N){var K=M.objectStore(T),B=O.isPrimaryKey?K:K.index(O.name),K=i(C),B=K?B.count(K):B.count();B.onsuccess=de(function(F){return I(F.target.result)}),B.onerror=Ke(N)})}}}var f,d,m,S=(d=v,m=Kr((f=e).objectStoreNames),{schema:{name:f.name,tables:m.map(function(k){return d.objectStore(k)}).map(function(k){var b=k.keyPath,A=k.autoIncrement,T=p(b),R={},A={name:k.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:b==null,compound:T,keyPath:b,autoIncrement:A,unique:!0,extractKey:Xn(b)},indexes:Kr(k.indexNames).map(function(M){return k.index(M)}).map(function(I){var O=I.name,C=I.unique,N=I.multiEntry,I=I.keyPath,N={name:O,compound:p(I),keyPath:I,unique:C,multiEntry:N,extractKey:Xn(I)};return R[Ht(I)]=N}),getIndexByKeyPath:function(M){return R[Ht(M)]}};return R[":id"]=A.primaryKey,b!=null&&(R[Ht(b)]=A.primaryKey),A})},hasGetAll:0<m.length&&"getAll"in d.objectStore(m[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),v=S.schema,w=S.hasGetAll,S=v.tables.map(o),g={};return S.forEach(function(k){return g[k.name]=k}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(k){if(!g[k])throw new Error("Table '".concat(k,"' not found"));return g[k]},MIN_KEY:-1/0,MAX_KEY:qt(t),schema:v}}function Li(e,t,n,i){var o=n.IDBKeyRange;return n.indexedDB,{dbcore:(i=Pi(t,o,i),e.dbcore.reduce(function(f,d){return d=d.create,a(a({},f),d(f))},i))}}function fn(e,i){var n=i.db,i=Li(e._middlewares,n,e._deps,i);e.core=i.dbcore,e.tables.forEach(function(o){var f=o.name;e.core.schema.tables.some(function(d){return d.name===f})&&(o.core=e.core.table(f),e[f]instanceof e.Table&&(e[f].core=o.core))})}function hn(e,t,n,i){n.forEach(function(o){var f=i[o];t.forEach(function(d){var m=function v(w,S){return z(w,S)||(w=y(w))&&v(w,S)}(d,o);(!m||"value"in m&&m.value===void 0)&&(d===e.Transaction.prototype||d instanceof e.Transaction?q(d,o,{get:function(){return this.table(o)},set:function(v){D(this,o,{value:v,writable:!0,configurable:!0,enumerable:!0})}}):d[o]=new e.Table(o,f))})})}function Wn(e,t){t.forEach(function(n){for(var i in n)n[i]instanceof e.Table&&delete n[i]})}function Ii(e,t){return e._cfg.version-t._cfg.version}function Di(e,t,n,i){var o=e._dbSchema;n.objectStoreNames.contains("$meta")&&!o.$meta&&(o.$meta=Vn("$meta",Gr("")[0],[]),e._storeNames.push("$meta"));var f=e._createTransaction("readwrite",e._storeNames,o);f.create(n),f._completion.catch(i);var d=f._reject.bind(f),m=V.transless||V;$e(function(){return V.trans=f,V.transless=m,t!==0?(fn(e,n),w=t,((v=f).storeNames.includes("$meta")?v.table("$meta").get("version").then(function(S){return S??w}):G.resolve(w)).then(function(S){return k=S,b=f,T=n,R=[],S=(g=e)._versions,A=g._dbSchema=pn(0,g.idbdb,T),(S=S.filter(function(M){return M._cfg.version>=k})).length!==0?(S.forEach(function(M){R.push(function(){var O=A,C=M._cfg.dbschema;mn(g,O,T),mn(g,C,T),A=g._dbSchema=C;var I=Yn(O,C);I.add.forEach(function(U){Qn(T,U[0],U[1].primKey,U[1].indexes)}),I.change.forEach(function(U){if(U.recreate)throw new X.Upgrade("Not yet support for changing primary key");var j=T.objectStore(U.name);U.add.forEach(function(H){return dn(j,H)}),U.change.forEach(function(H){j.deleteIndex(H.name),dn(j,H)}),U.del.forEach(function(H){return j.deleteIndex(H)})});var N=M._cfg.contentUpgrade;if(N&&M._cfg.version>k){fn(g,T),b._memoizedTables={};var K=Be(C);I.del.forEach(function(U){K[U]=O[U]}),Wn(g,[g.Transaction.prototype]),hn(g,[g.Transaction.prototype],l(K),K),b.schema=K;var B,F=Pt(N);return F&&Et(),I=G.follow(function(){var U;(B=N(b))&&F&&(U=Je.bind(null,null),B.then(U,U))}),B&&typeof B.then=="function"?G.resolve(B):I.then(function(){return B})}}),R.push(function(O){var C,I,N=M._cfg.dbschema;C=N,I=O,[].slice.call(I.db.objectStoreNames).forEach(function(K){return C[K]==null&&I.db.deleteObjectStore(K)}),Wn(g,[g.Transaction.prototype]),hn(g,[g.Transaction.prototype],g._storeNames,g._dbSchema),b.schema=g._dbSchema}),R.push(function(O){g.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(g.idbdb.version/10)===M._cfg.version?(g.idbdb.deleteObjectStore("$meta"),delete g._dbSchema.$meta,g._storeNames=g._storeNames.filter(function(C){return C!=="$meta"})):O.objectStore("$meta").put(M._cfg.version,"version"))})}),function M(){return R.length?G.resolve(R.shift()(b.idbtrans)).then(M):G.resolve()}().then(function(){Ur(A,T)})):G.resolve();var g,k,b,T,R,A}).catch(d)):(l(o).forEach(function(S){Qn(n,S,o[S].primKey,o[S].indexes)}),fn(e,n),void G.follow(function(){return e.on.populate.fire(f)}).catch(d));var v,w})}function Ni(e,t){Ur(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=pn(0,e.idbdb,t);mn(e,e._dbSchema,t);for(var i=0,o=Yn(n,e._dbSchema).change;i<o.length;i++){var f=function(d){if(d.change.length||d.recreate)return console.warn("Unable to patch indexes of table ".concat(d.name," because it has changes on the type of index or primary key.")),{value:void 0};var m=t.objectStore(d.name);d.add.forEach(function(v){je&&console.debug("Dexie upgrade patch: Creating missing index ".concat(d.name,".").concat(v.src)),dn(m,v)})}(o[i]);if(typeof f=="object")return f.value}}function Yn(e,t){var n,i={del:[],add:[],change:[]};for(n in e)t[n]||i.del.push(n);for(n in t){var o=e[n],f=t[n];if(o){var d={name:n,def:f,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(f.primKey.keyPath||"")||o.primKey.auto!==f.primKey.auto)d.recreate=!0,i.change.push(d);else{var m=o.idxByName,v=f.idxByName,w=void 0;for(w in m)v[w]||d.del.push(w);for(w in v){var S=m[w],g=v[w];S?S.src!==g.src&&d.change.push(g):d.add.push(g)}(0<d.del.length||0<d.add.length||0<d.change.length)&&i.change.push(d)}}else i.add.push([n,f])}return i}function Qn(e,t,n,i){var o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return i.forEach(function(f){return dn(o,f)}),o}function Ur(e,t){l(e).forEach(function(n){t.db.objectStoreNames.contains(n)||(je&&console.debug("Dexie: Creating missing table",n),Qn(t,n,e[n].primKey,e[n].indexes))})}function dn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function pn(e,t,n){var i={};return ee(t.objectStoreNames,0).forEach(function(o){for(var f=n.objectStore(o),d=zn(jr(w=f.keyPath),w||"",!0,!1,!!f.autoIncrement,w&&typeof w!="string",!0),m=[],v=0;v<f.indexNames.length;++v){var S=f.index(f.indexNames[v]),w=S.keyPath,S=zn(S.name,w,!!S.unique,!!S.multiEntry,!1,w&&typeof w!="string",!1);m.push(S)}i[o]=Vn(o,d,m)}),i}function mn(e,t,n){for(var i=n.db.objectStoreNames,o=0;o<i.length;++o){var f=i[o],d=n.objectStore(f);e._hasGetAll="getAll"in d;for(var m=0;m<d.indexNames.length;++m){var v=d.indexNames[m],w=d.index(v).keyPath,S=typeof w=="string"?w:"["+ee(w).join("+")+"]";!t[f]||(w=t[f].idxByName[S])&&(w.name=v,delete t[f].idxByName[S],t[f].idxByName[v]=w)}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&c.WorkerGlobalScope&&c instanceof c.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function Gr(e){return e.split(",").map(function(t,n){var i=(t=t.trim()).replace(/([&*]|\+\+)/g,""),o=/^\[/.test(i)?i.match(/^\[(.*)\]$/)[1].split("+"):i;return zn(i,o||null,/\&/.test(t),/\*/.test(t),/\+\+/.test(t),p(o),n===0)})}var Bi=(yn.prototype._parseStoresSpec=function(e,t){l(e).forEach(function(n){if(e[n]!==null){var i=Gr(e[n]),o=i.shift();if(o.unique=!0,o.multi)throw new X.Schema("Primary key cannot be multi-valued");i.forEach(function(f){if(f.auto)throw new X.Schema("Only primary key can be marked as autoIncrement (++)");if(!f.keyPath)throw new X.Schema("Index must have a name and cannot be an empty string")}),t[n]=Vn(n,o,i)}})},yn.prototype.stores=function(n){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?h(this._cfg.storesSource,n):n;var n=t._versions,i={},o={};return n.forEach(function(f){h(i,f._cfg.storesSource),o=f._cfg.dbschema={},f._parseStoresSpec(i,o)}),t._dbSchema=o,Wn(t,[t._allTables,t,t.Transaction.prototype]),hn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],l(o),o),t._storeNames=l(o),this},yn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=On(this._cfg.contentUpgrade||ce,e),this},yn);function yn(){}function $n(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Ve(on,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Jn(e){return e&&typeof e.databases=="function"}function Zn(e){return $e(function(){return V.letThrough=!0,e()})}function er(e){return!("from"in e)}var xe=function(e,t){if(!this){var n=new xe;return e&&"d"in e&&h(n,e),n}h(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function zt(e,t,n){var i=ie(t,n);if(!isNaN(i)){if(0<i)throw RangeError();if(er(e))return h(e,{from:t,to:n,d:1});var o=e.l,i=e.r;if(ie(n,e.from)<0)return o?zt(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Hr(e);if(0<ie(t,e.to))return i?zt(i,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Hr(e);ie(t,e.from)<0&&(e.from=t,e.l=null,e.d=i?i.d+1:1),0<ie(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1),n=!e.r,o&&!e.l&&Vt(e,o),i&&n&&Vt(e,i)}}function Vt(e,t){er(t)||function n(i,v){var f=v.from,d=v.to,m=v.l,v=v.r;zt(i,f,d),m&&n(i,m),v&&n(i,v)}(e,t)}function qr(e,t){var n=gn(t),i=n.next();if(i.done)return!1;for(var o=i.value,f=gn(e),d=f.next(o.from),m=d.value;!i.done&&!d.done;){if(ie(m.from,o.to)<=0&&0<=ie(m.to,o.from))return!0;ie(o.from,m.from)<0?o=(i=n.next(m.from)).value:m=(d=f.next(o.from)).value}return!1}function gn(e){var t=er(e)?null:{s:0,n:e};return{next:function(n){for(var i=0<arguments.length;t;)switch(t.s){case 0:if(t.s=1,i)for(;t.n.l&&ie(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,!i||ie(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 Hr(e){var t,n,i=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((n=e.l)===null||n===void 0?void 0:n.d)||0),o=1<i?"r":i<-1?"l":"";o&&(t=o=="r"?"l":"r",n=a({},e),i=e[o],e.from=i.from,e.to=i.to,e[o]=i[o],n[o]=i[t],(e[t]=n).d=zr(n)),e.d=zr(e)}function zr(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 vn(e,t){return l(t).forEach(function(n){e[n]?Vt(e[n],t[n]):e[n]=function i(o){var f,d,m={};for(f in o)_(o,f)&&(d=o[f],m[f]=!d||typeof d!="object"||Ie.has(d.constructor)?d:i(d));return m}(t[n])}),e}function tr(e,t){return e.all||t.all||Object.keys(e).some(function(n){return t[n]&&qr(t[n],e[n])})}P(xe.prototype,((Pe={add:function(e){return Vt(this,e),this},addKey:function(e){return zt(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(n){return zt(t,n,n)}),this},hasKey:function(e){var t=gn(this).next(e).value;return t&&ie(t.from,e)<=0&&0<=ie(t.to,e)}})[At]=function(){return gn(this)},Pe));var dt={},nr={},rr=!1;function bn(e){vn(nr,e),rr||(rr=!0,setTimeout(function(){rr=!1,ir(nr,!(nr={}))},0))}function ir(e,t){t===void 0&&(t=!1);var n=new Set;if(e.all)for(var i=0,o=Object.values(dt);i<o.length;i++)Vr(d=o[i],e,n,t);else for(var f in e){var d,m=/^idb\:\/\/(.*)\/(.*)\//.exec(f);m&&(f=m[1],m=m[2],(d=dt["idb://".concat(f,"/").concat(m)])&&Vr(d,e,n,t))}n.forEach(function(v){return v()})}function Vr(e,t,n,i){for(var o=[],f=0,d=Object.entries(e.queries.query);f<d.length;f++){for(var m=d[f],v=m[0],w=[],S=0,g=m[1];S<g.length;S++){var k=g[S];tr(t,k.obsSet)?k.subscribers.forEach(function(A){return n.add(A)}):i&&w.push(k)}i&&o.push([v,w])}if(i)for(var b=0,T=o;b<T.length;b++){var R=T[b],v=R[0],w=R[1];e.queries.query[v]=w}}function Fi(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(function(){return t.dbOpenError?ye(t.dbOpenError):e});t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var i=t.openCanceller,o=Math.round(10*e.verno),f=!1;function d(){if(t.openCanceller!==i)throw new X.DatabaseClosed("db.open() was cancelled")}function m(){return new G(function(k,b){if(d(),!n)throw new X.MissingAPI;var T=e.name,R=t.autoSchema||!o?n.open(T):n.open(T,o);if(!R)throw new X.MissingAPI;R.onerror=Ke(b),R.onblocked=de(e._fireOnBlocked),R.onupgradeneeded=de(function(A){var M;S=R.transaction,t.autoSchema&&!e._options.allowEmptyDB?(R.onerror=Ut,S.abort(),R.result.close(),(M=n.deleteDatabase(T)).onsuccess=M.onerror=de(function(){b(new X.NoSuchDatabase("Database ".concat(T," doesnt exist")))})):(S.onerror=Ke(b),A=A.oldVersion>Math.pow(2,62)?0:A.oldVersion,g=A<1,e.idbdb=R.result,f&&Ni(e,S),Di(e,A/10,S,b))},b),R.onsuccess=de(function(){S=null;var A,M,O,C,I,N=e.idbdb=R.result,K=ee(N.objectStoreNames);if(0<K.length)try{var B=N.transaction((C=K).length===1?C[0]:C,"readonly");if(t.autoSchema)M=N,O=B,(A=e).verno=M.version/10,O=A._dbSchema=pn(0,M,O),A._storeNames=ee(M.objectStoreNames,0),hn(A,[A._allTables],l(O),O);else if(mn(e,e._dbSchema,B),((I=Yn(pn(0,(I=e).idbdb,B),I._dbSchema)).add.length||I.change.some(function(F){return F.add.length||F.change.length}))&&!f)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."),N.close(),o=N.version+1,f=!0,k(m());fn(e,B)}catch{}Rt.push(e),N.onversionchange=de(function(F){t.vcFired=!0,e.on("versionchange").fire(F)}),N.onclose=de(function(F){e.on("close").fire(F)}),g&&(I=e._deps,B=T,N=I.indexedDB,I=I.IDBKeyRange,Jn(N)||B===on||$n(N,I).put({name:B}).catch(ce)),k()},b)}).catch(function(k){switch(k==null?void 0:k.name){case"UnknownError":if(0<t.PR1398_maxLoop)return t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),m();break;case"VersionError":if(0<o)return o=0,m()}return G.reject(k)})}var v,w=t.dbReadyResolve,S=null,g=!1;return G.race([i,(typeof navigator>"u"?G.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(k){function b(){return indexedDB.databases().finally(k)}v=setInterval(b,100),b()}).finally(function(){return clearInterval(v)}):Promise.resolve()).then(m)]).then(function(){return d(),t.onReadyBeingFired=[],G.resolve(Zn(function(){return e.on.ready.fire(e.vip)})).then(function k(){if(0<t.onReadyBeingFired.length){var b=t.onReadyBeingFired.reduce(On,ce);return t.onReadyBeingFired=[],G.resolve(Zn(function(){return b(e.vip)})).then(k)}})}).finally(function(){t.openCanceller===i&&(t.onReadyBeingFired=null,t.isBeingOpened=!1)}).catch(function(k){t.dbOpenError=k;try{S&&S.abort()}catch{}return i===t.openCanceller&&e._close(),ye(k)}).finally(function(){t.openComplete=!0,w()}).then(function(){var k;return g&&(k={},e.tables.forEach(function(b){b.schema.indexes.forEach(function(T){T.name&&(k["idb://".concat(e.name,"/").concat(b.name,"/").concat(T.name)]=new xe(-1/0,[[[]]]))}),k["idb://".concat(e.name,"/").concat(b.name,"/")]=k["idb://".concat(e.name,"/").concat(b.name,"/:dels")]=new xe(-1/0,[[[]]])}),tt(Gt).fire(k),ir(k,!0)),e})}function sr(e){function t(f){return e.next(f)}var n=o(t),i=o(function(f){return e.throw(f)});function o(f){return function(v){var m=f(v),v=m.value;return m.done?v:v&&typeof v.then=="function"?v.then(n,i):p(v)?Promise.all(v).then(n,i):n(v)}}return o(t)()}function wn(e,t,n){for(var i=p(e)?e.slice():[e],o=0;o<n;++o)i.push(t);return i}var ji={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return a(a({},e),{table:function(t){var n=e.table(t),i=n.schema,o={},f=[];function d(g,k,b){var T=Ht(g),R=o[T]=o[T]||[],A=g==null?0:typeof g=="string"?1:g.length,M=0<k,M=a(a({},b),{name:M?"".concat(T,"(virtual-from:").concat(b.name,")"):b.name,lowLevelIndex:b,isVirtual:M,keyTail:k,keyLength:A,extractKey:Xn(g),unique:!M&&b.unique});return R.push(M),M.isPrimaryKey||f.push(M),1<A&&d(A===2?g[0]:g.slice(0,A-1),k+1,b),R.sort(function(O,C){return O.keyTail-C.keyTail}),M}t=d(i.primaryKey.keyPath,0,i.primaryKey),o[":id"]=[t];for(var m=0,v=i.indexes;m<v.length;m++){var w=v[m];d(w.keyPath,0,w)}function S(g){var k,b=g.query.index;return b.isVirtual?a(a({},g),{query:{index:b.lowLevelIndex,range:(k=g.query.range,b=b.keyTail,{type:k.type===1?2:k.type,lower:wn(k.lower,k.lowerOpen?e.MAX_KEY:e.MIN_KEY,b),lowerOpen:!0,upper:wn(k.upper,k.upperOpen?e.MIN_KEY:e.MAX_KEY,b),upperOpen:!0})}}):g}return a(a({},n),{schema:a(a({},i),{primaryKey:t,indexes:f,getIndexByKeyPath:function(g){return(g=o[Ht(g)])&&g[0]}}),count:function(g){return n.count(S(g))},query:function(g){return n.query(S(g))},openCursor:function(g){var k=g.query.index,b=k.keyTail,T=k.isVirtual,R=k.keyLength;return T?n.openCursor(S(g)).then(function(M){return M&&A(M)}):n.openCursor(g);function A(M){return Object.create(M,{continue:{value:function(O){O!=null?M.continue(wn(O,g.reverse?e.MAX_KEY:e.MIN_KEY,b)):g.unique?M.continue(M.key.slice(0,R).concat(g.reverse?e.MIN_KEY:e.MAX_KEY,b)):M.continue()}},continuePrimaryKey:{value:function(O,C){M.continuePrimaryKey(wn(O,e.MAX_KEY,b),C)}},primaryKey:{get:function(){return M.primaryKey}},key:{get:function(){var O=M.key;return R===1?O[0]:O.slice(0,R)}},value:{get:function(){return M.value}}})}}})}})}};function or(e,t,n,i){return n=n||{},i=i||"",l(e).forEach(function(o){var f,d,m;_(t,o)?(f=e[o],d=t[o],typeof f=="object"&&typeof d=="object"&&f&&d?(m=_t(f))!==_t(d)?n[i+o]=t[o]:m==="Object"?or(f,d,n,i+o+"."):f!==d&&(n[i+o]=t[o]):f!==d&&(n[i+o]=t[o])):n[i+o]=void 0}),l(t).forEach(function(o){_(e,o)||(n[i+o]=t[o])}),n}function ar(e,t){return t.type==="delete"?t.keys:t.keys||t.values.map(e.extractKey)}var Ki={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return a(a({},e),{table:function(t){var n=e.table(t),i=n.schema.primaryKey;return a(a({},n),{mutate:function(o){var f=V.trans,d=f.table(t).hook,m=d.deleting,v=d.creating,w=d.updating;switch(o.type){case"add":if(v.fire===ce)break;return f._promise("readwrite",function(){return S(o)},!0);case"put":if(v.fire===ce&&w.fire===ce)break;return f._promise("readwrite",function(){return S(o)},!0);case"delete":if(m.fire===ce)break;return f._promise("readwrite",function(){return S(o)},!0);case"deleteRange":if(m.fire===ce)break;return f._promise("readwrite",function(){return function g(k,b,T){return n.query({trans:k,values:!1,query:{index:i,range:b},limit:T}).then(function(R){var A=R.result;return S({type:"delete",keys:A,trans:k}).then(function(M){return 0<M.numFailures?Promise.reject(M.failures[0]):A.length<T?{failures:[],numFailures:0,lastResult:void 0}:g(k,a(a({},b),{lower:A[A.length-1],lowerOpen:!0}),T)})})}(o.trans,o.range,1e4)},!0)}return n.mutate(o);function S(g){var k,b,T,R=V.trans,A=g.keys||ar(i,g);if(!A)throw new Error("Keys missing");return(g=g.type==="add"||g.type==="put"?a(a({},g),{keys:A}):a({},g)).type!=="delete"&&(g.values=u([],g.values)),g.keys&&(g.keys=u([],g.keys)),k=n,T=A,((b=g).type==="add"?Promise.resolve([]):k.getMany({trans:b.trans,keys:T,cache:"immutable"})).then(function(M){var O=A.map(function(C,I){var N,K,B,F=M[I],U={onerror:null,onsuccess:null};return g.type==="delete"?m.fire.call(U,C,F,R):g.type==="add"||F===void 0?(N=v.fire.call(U,C,g.values[I],R),C==null&&N!=null&&(g.keys[I]=C=N,i.outbound||le(g.values[I],i.keyPath,C))):(N=or(F,g.values[I]),(K=w.fire.call(U,N,C,F,R))&&(B=g.values[I],Object.keys(K).forEach(function(j){_(B,j)?B[j]=K[j]:le(B,j,K[j])}))),U});return n.mutate(g).then(function(C){for(var I=C.failures,N=C.results,K=C.numFailures,C=C.lastResult,B=0;B<A.length;++B){var F=(N||A)[B],U=O[B];F==null?U.onerror&&U.onerror(I[B]):U.onsuccess&&U.onsuccess(g.type==="put"&&M[B]?g.values[B]:F)}return{failures:I,results:N,numFailures:K,lastResult:C}}).catch(function(C){return O.forEach(function(I){return I.onerror&&I.onerror(C)}),Promise.reject(C)})})}}})}})}};function Xr(e,t,n){try{if(!t||t.keys.length<e.length)return null;for(var i=[],o=0,f=0;o<t.keys.length&&f<e.length;++o)ie(t.keys[o],e[f])===0&&(i.push(n?ke(t.values[o]):t.values[o]),++f);return i.length===e.length?i:null}catch{return null}}var Ui={stack:"dbcore",level:-1,create:function(e){return{table:function(t){var n=e.table(t);return a(a({},n),{getMany:function(i){if(!i.cache)return n.getMany(i);var o=Xr(i.keys,i.trans._cache,i.cache==="clone");return o?G.resolve(o):n.getMany(i).then(function(f){return i.trans._cache={keys:i.keys,values:i.cache==="clone"?ke(f):f},f})},mutate:function(i){return i.type!=="add"&&(i.trans._cache=null),n.mutate(i)}})}}}};function Wr(e,t){return e.trans.mode==="readonly"&&!!e.subscr&&!e.trans.explicit&&e.trans.db._options.cache!=="disabled"&&!t.schema.primaryKey.outbound}function Yr(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Gi={stack:"dbcore",level:0,name:"Observability",create:function(e){var t=e.schema.name,n=new xe(e.MIN_KEY,e.MAX_KEY);return a(a({},e),{transaction:function(i,o,f){if(V.subscr&&o!=="readonly")throw new X.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(V.querier));return e.transaction(i,o,f)},table:function(i){var o=e.table(i),f=o.schema,d=f.primaryKey,g=f.indexes,m=d.extractKey,v=d.outbound,w=d.autoIncrement&&g.filter(function(b){return b.compound&&b.keyPath.includes(d.keyPath)}),S=a(a({},o),{mutate:function(b){function T(j){return j="idb://".concat(t,"/").concat(i,"/").concat(j),C[j]||(C[j]=new xe)}var R,A,M,O=b.trans,C=b.mutatedParts||(b.mutatedParts={}),I=T(""),N=T(":dels"),K=b.type,U=b.type==="deleteRange"?[b.range]:b.type==="delete"?[b.keys]:b.values.length<50?[ar(d,b).filter(function(j){return j}),b.values]:[],B=U[0],F=U[1],U=b.trans._cache;return p(B)?(I.addKeys(B),(U=K==="delete"||B.length===F.length?Xr(B,U):null)||N.addKeys(B),(U||F)&&(R=T,A=U,M=F,f.indexes.forEach(function(j){var H=R(j.name||"");function J(ne){return ne!=null?j.extractKey(ne):null}function te(ne){return j.multiEntry&&p(ne)?ne.forEach(function(Oe){return H.addKey(Oe)}):H.addKey(ne)}(A||M).forEach(function(ne,Te){var Q=A&&J(A[Te]),Te=M&&J(M[Te]);ie(Q,Te)!==0&&(Q!=null&&te(Q),Te!=null&&te(Te))})}))):B?(F={from:(F=B.lower)!==null&&F!==void 0?F:e.MIN_KEY,to:(F=B.upper)!==null&&F!==void 0?F:e.MAX_KEY},N.add(F),I.add(F)):(I.add(n),N.add(n),f.indexes.forEach(function(j){return T(j.name).add(n)})),o.mutate(b).then(function(j){return!B||b.type!=="add"&&b.type!=="put"||(I.addKeys(j.results),w&&w.forEach(function(H){for(var J=b.values.map(function(Q){return H.extractKey(Q)}),te=H.keyPath.findIndex(function(Q){return Q===d.keyPath}),ne=0,Oe=j.results.length;ne<Oe;++ne)J[ne][te]=j.results[ne];T(H.name).addKeys(J)})),O.mutatedParts=vn(O.mutatedParts||{},C),j})}}),g=function(T){var R=T.query,T=R.index,R=R.range;return[T,new xe((T=R.lower)!==null&&T!==void 0?T:e.MIN_KEY,(R=R.upper)!==null&&R!==void 0?R:e.MAX_KEY)]},k={get:function(b){return[d,new xe(b.key)]},getMany:function(b){return[d,new xe().addKeys(b.keys)]},count:g,query:g,openCursor:g};return l(k).forEach(function(b){S[b]=function(T){var R=V.subscr,A=!!R,M=Wr(V,o)&&Yr(b,T)?T.obsSet={}:R;if(A){var O=function(F){return F="idb://".concat(t,"/").concat(i,"/").concat(F),M[F]||(M[F]=new xe)},C=O(""),I=O(":dels"),R=k[b](T),A=R[0],R=R[1];if((b==="query"&&A.isPrimaryKey&&!T.values?I:O(A.name||"")).add(R),!A.isPrimaryKey){if(b!=="count"){var N=b==="query"&&v&&T.values&&o.query(a(a({},T),{values:!1}));return o[b].apply(this,arguments).then(function(F){if(b==="query"){if(v&&T.values)return N.then(function(J){return J=J.result,C.addKeys(J),F});var U=T.values?F.result.map(m):F.result;(T.values?C:I).addKeys(U)}else if(b==="openCursor"){var j=F,H=T.values;return j&&Object.create(j,{key:{get:function(){return I.addKey(j.primaryKey),j.key}},primaryKey:{get:function(){var J=j.primaryKey;return I.addKey(J),J}},value:{get:function(){return H&&C.addKey(j.primaryKey),j.value}}})}return F})}I.add(n)}}return o[b].apply(this,arguments)}}),S}})}};function Qr(e,t,n){if(n.numFailures===0)return t;if(t.type==="deleteRange")return null;var i=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1;return n.numFailures===i?null:(t=a({},t),p(t.keys)&&(t.keys=t.keys.filter(function(o,f){return!(f in n.failures)})),"values"in t&&p(t.values)&&(t.values=t.values.filter(function(o,f){return!(f in n.failures)})),t)}function ur(e,t){return n=e,((i=t).lower===void 0||(i.lowerOpen?0<ie(n,i.lower):0<=ie(n,i.lower)))&&(e=e,(t=t).upper===void 0||(t.upperOpen?ie(e,t.upper)<0:ie(e,t.upper)<=0));var n,i}function $r(e,t,k,i,o,f){if(!k||k.length===0)return e;var d=t.query.index,m=d.multiEntry,v=t.query.range,w=i.schema.primaryKey.extractKey,S=d.extractKey,g=(d.lowLevelIndex||d).extractKey,k=k.reduce(function(b,T){var R=b,A=[];if(T.type==="add"||T.type==="put")for(var M=new xe,O=T.values.length-1;0<=O;--O){var C,I=T.values[O],N=w(I);M.hasKey(N)||(C=S(I),(m&&p(C)?C.some(function(j){return ur(j,v)}):ur(C,v))&&(M.addKey(N),A.push(I)))}switch(T.type){case"add":var K=new xe().addKeys(t.values?b.map(function(H){return w(H)}):b),R=b.concat(t.values?A.filter(function(H){return H=w(H),!K.hasKey(H)&&(K.addKey(H),!0)}):A.map(function(H){return w(H)}).filter(function(H){return!K.hasKey(H)&&(K.addKey(H),!0)}));break;case"put":var B=new xe().addKeys(T.values.map(function(H){return w(H)}));R=b.filter(function(H){return!B.hasKey(t.values?w(H):H)}).concat(t.values?A:A.map(function(H){return w(H)}));break;case"delete":var F=new xe().addKeys(T.keys);R=b.filter(function(H){return!F.hasKey(t.values?w(H):H)});break;case"deleteRange":var U=T.range;R=b.filter(function(H){return!ur(w(H),U)})}return R},e);return k===e?e:(k.sort(function(b,T){return ie(g(b),g(T))||ie(w(b),w(T))}),t.limit&&t.limit<1/0&&(k.length>t.limit?k.length=t.limit:e.length===t.limit&&k.length<t.limit&&(o.dirty=!0)),f?Object.freeze(k):k)}function Jr(e,t){return ie(e.lower,t.lower)===0&&ie(e.upper,t.upper)===0&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function qi(e,t){return function(n,i,o,f){if(n===void 0)return i!==void 0?-1:0;if(i===void 0)return 1;if((i=ie(n,i))===0){if(o&&f)return 0;if(o)return 1;if(f)return-1}return i}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(n,i,o,f){if(n===void 0)return i!==void 0?1:0;if(i===void 0)return-1;if((i=ie(n,i))===0){if(o&&f)return 0;if(o)return-1;if(f)return 1}return i}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function Hi(e,t,n,i){e.subscribers.add(n),i.addEventListener("abort",function(){var o,f;e.subscribers.delete(n),e.subscribers.size===0&&(o=e,f=t,setTimeout(function(){o.subscribers.size===0&&We(f,o)},3e3))})}var zi={stack:"dbcore",level:0,name:"Cache",create:function(e){var t=e.schema.name;return a(a({},e),{transaction:function(n,i,o){var f,d,m=e.transaction(n,i,o);return i==="readwrite"&&(d=(f=new AbortController).signal,o=function(v){return function(){if(f.abort(),i==="readwrite"){for(var w=new Set,S=0,g=n;S<g.length;S++){var k=g[S],b=dt["idb://".concat(t,"/").concat(k)];if(b){var T=e.table(k),R=b.optimisticOps.filter(function(H){return H.trans===m});if(m._explicit&&v&&m.mutatedParts)for(var A=0,M=Object.values(b.queries.query);A<M.length;A++)for(var O=0,C=(K=M[A]).slice();O<C.length;O++)tr((B=C[O]).obsSet,m.mutatedParts)&&(We(K,B),B.subscribers.forEach(function(H){return w.add(H)}));else if(0<R.length){b.optimisticOps=b.optimisticOps.filter(function(H){return H.trans!==m});for(var I=0,N=Object.values(b.queries.query);I<N.length;I++)for(var K,B,F,U=0,j=(K=N[I]).slice();U<j.length;U++)(B=j[U]).res!=null&&m.mutatedParts&&(v&&!B.dirty?(F=Object.isFrozen(B.res),F=$r(B.res,B.req,R,T,B,F),B.dirty?(We(K,B),B.subscribers.forEach(function(H){return w.add(H)})):F!==B.res&&(B.res=F,B.promise=G.resolve({result:F}))):(B.dirty&&We(K,B),B.subscribers.forEach(function(H){return w.add(H)})))}}}w.forEach(function(H){return H()})}}},m.addEventListener("abort",o(!1),{signal:d}),m.addEventListener("error",o(!1),{signal:d}),m.addEventListener("complete",o(!0),{signal:d})),m},table:function(n){var i=e.table(n),o=i.schema.primaryKey;return a(a({},i),{mutate:function(f){var d=V.trans;if(o.outbound||d.db._options.cache==="disabled"||d.explicit||d.idbtrans.mode!=="readwrite")return i.mutate(f);var m=dt["idb://".concat(t,"/").concat(n)];return m?(d=i.mutate(f),f.type!=="add"&&f.type!=="put"||!(50<=f.values.length||ar(o,f).some(function(v){return v==null}))?(m.optimisticOps.push(f),f.mutatedParts&&bn(f.mutatedParts),d.then(function(v){0<v.numFailures&&(We(m.optimisticOps,f),(v=Qr(0,f,v))&&m.optimisticOps.push(v),f.mutatedParts&&bn(f.mutatedParts))}),d.catch(function(){We(m.optimisticOps,f),f.mutatedParts&&bn(f.mutatedParts)})):d.then(function(v){var w=Qr(0,a(a({},f),{values:f.values.map(function(S,g){var k;return v.failures[g]?S:(S=(k=o.keyPath)!==null&&k!==void 0&&k.includes(".")?ke(S):a({},S),le(S,o.keyPath,v.results[g]),S)})}),v);m.optimisticOps.push(w),queueMicrotask(function(){return f.mutatedParts&&bn(f.mutatedParts)})}),d):i.mutate(f)},query:function(f){if(!Wr(V,i)||!Yr("query",f))return i.query(f);var d=((w=V.trans)===null||w===void 0?void 0:w.db._options.cache)==="immutable",g=V,m=g.requery,v=g.signal,w=function(T,R,A,M){var O=dt["idb://".concat(T,"/").concat(R)];if(!O)return[];if(!(R=O.queries[A]))return[null,!1,O,null];var C=R[(M.query?M.query.index.name:null)||""];if(!C)return[null,!1,O,null];switch(A){case"query":var I=C.find(function(N){return N.req.limit===M.limit&&N.req.values===M.values&&Jr(N.req.query.range,M.query.range)});return I?[I,!0,O,C]:[C.find(function(N){return("limit"in N.req?N.req.limit:1/0)>=M.limit&&(!M.values||N.req.values)&&qi(N.req.query.range,M.query.range)}),!1,O,C];case"count":return I=C.find(function(N){return Jr(N.req.query.range,M.query.range)}),[I,!!I,O,C]}}(t,n,"query",f),S=w[0],g=w[1],k=w[2],b=w[3];return S&&g?S.obsSet=f.obsSet:(g=i.query(f).then(function(T){var R=T.result;if(S&&(S.res=R),d){for(var A=0,M=R.length;A<M;++A)Object.freeze(R[A]);Object.freeze(R)}else T.result=ke(R);return T}).catch(function(T){return b&&S&&We(b,S),Promise.reject(T)}),S={obsSet:f.obsSet,promise:g,subscribers:new Set,type:"query",req:f,dirty:!1},b?b.push(S):(b=[S],(k=k||(dt["idb://".concat(t,"/").concat(n)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[f.query.index.name||""]=b)),Hi(S,b,m,v),S.promise.then(function(T){return{result:$r(T.result,f,k==null?void 0:k.optimisticOps,i,S,d)}})}})}})}};function _n(e,t){return new Proxy(e,{get:function(n,i,o){return i==="db"?t:Reflect.get(n,i,o)}})}var Ve=(ge.prototype.version=function(e){if(isNaN(e)||e<.1)throw new X.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new X.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter(function(i){return i._cfg.version===e})[0];return n||(n=new this.Version(e),t.push(n),t.sort(Ii),n.stores({}),this._state.autoSchema=!1,n)},ge.prototype._whenReady=function(e){var t=this;return this.idbdb&&(this._state.openComplete||V.letThrough||this._vip)?e():new G(function(n,i){if(t._state.openComplete)return i(new X.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return void i(new X.DatabaseClosed);t.open().catch(ce)}t._state.dbReadyPromise.then(n,i)}).then(e)},ge.prototype.use=function(e){var t=e.stack,n=e.create,i=e.level,o=e.name;return o&&this.unuse({stack:t,name:o}),e=this._middlewares[t]||(this._middlewares[t]=[]),e.push({stack:t,create:n,level:i??10,name:o}),e.sort(function(f,d){return f.level-d.level}),this},ge.prototype.unuse=function(e){var t=e.stack,n=e.name,i=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(o){return i?o.create!==i:!!n&&o.name!==n})),this},ge.prototype.open=function(){var e=this;return lt(Qe,function(){return Fi(e)})},ge.prototype._close=function(){var e=this._state,t=Rt.indexOf(this);if(0<=t&&Rt.splice(t,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new G(function(n){e.dbReadyResolve=n}),e.openCanceller=new G(function(n,i){e.cancelOpen=i}))},ge.prototype.close=function(n){var t=(n===void 0?{disableAutoOpen:!0}:n).disableAutoOpen,n=this._state;t?(n.isBeingOpened&&n.cancelOpen(new X.DatabaseClosed),this._close(),n.autoOpen=!1,n.dbOpenError=new X.DatabaseClosed):(this._close(),n.autoOpen=this._options.autoOpen||n.isBeingOpened,n.openComplete=!1,n.dbOpenError=null)},ge.prototype.delete=function(e){var t=this;e===void 0&&(e={disableAutoOpen:!0});var n=0<arguments.length&&typeof arguments[0]!="object",i=this._state;return new G(function(o,f){function d(){t.close(e);var m=t._deps.indexedDB.deleteDatabase(t.name);m.onsuccess=de(function(){var v,w,S;v=t._deps,w=t.name,S=v.indexedDB,v=v.IDBKeyRange,Jn(S)||w===on||$n(S,v).delete(w).catch(ce),o()}),m.onerror=Ke(f),m.onblocked=t._fireOnBlocked}if(n)throw new X.InvalidArgument("Invalid closeOptions argument to db.delete()");i.isBeingOpened?i.dbReadyPromise.then(d):d()})},ge.prototype.backendDB=function(){return this.idbdb},ge.prototype.isOpen=function(){return this.idbdb!==null},ge.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"},ge.prototype.hasFailed=function(){return this._state.dbOpenError!==null},ge.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(ge.prototype,"tables",{get:function(){var e=this;return l(this._allTables).map(function(t){return e._allTables[t]})},enumerable:!1,configurable:!0}),ge.prototype.transaction=function(){var e=(function(t,n,i){var o=arguments.length;if(o<2)throw new X.InvalidArgument("Too few arguments");for(var f=new Array(o-1);--o;)f[o-1]=arguments[o];return i=f.pop(),[t,me(f),i]}).apply(this,arguments);return this._transaction.apply(this,e)},ge.prototype._transaction=function(e,t,n){var i=this,o=V.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);var f,d,m=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");try{if(d=t.map(function(w){if(w=w instanceof i.Table?w.name:w,typeof w!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return w}),e=="r"||e===jn)f=jn;else{if(e!="rw"&&e!=Kn)throw new X.InvalidArgument("Invalid transaction mode: "+e);f=Kn}if(o){if(o.mode===jn&&f===Kn){if(!m)throw new X.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&d.forEach(function(w){if(o&&o.storeNames.indexOf(w)===-1){if(!m)throw new X.SubTransaction("Table "+w+" not included in parent transaction.");o=null}}),m&&o&&!o.active&&(o=null)}}catch(w){return o?o._promise(null,function(S,g){g(w)}):ye(w)}var v=(function w(S,g,k,b,T){return G.resolve().then(function(){var R=V.transless||V,A=S._createTransaction(g,k,S._dbSchema,b);if(A.explicit=!0,R={trans:A,transless:R},b)A.idbtrans=b.idbtrans;else try{A.create(),A.idbtrans._explicit=!0,S._state.PR1398_maxLoop=3}catch(C){return C.name===Mn.InvalidState&&S.isOpen()&&0<--S._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),S.close({disableAutoOpen:!1}),S.open().then(function(){return w(S,g,k,null,T)})):ye(C)}var M,O=Pt(T);return O&&Et(),R=G.follow(function(){var C;(M=T.call(A,A))&&(O?(C=Je.bind(null,null),M.then(C,C)):typeof M.next=="function"&&typeof M.throw=="function"&&(M=sr(M)))},R),(M&&typeof M.then=="function"?G.resolve(M).then(function(C){return A.active?C:ye(new X.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):R.then(function(){return M})).then(function(C){return b&&A._resolve(),A._completion.then(function(){return C})}).catch(function(C){return A._reject(C),ye(C)})})}).bind(null,this,f,d,o,n);return o?o._promise(f,v,"lock"):V.trans?lt(V.transless,function(){return i._whenReady(v)}):this._whenReady(v)},ge.prototype.table=function(e){if(!_(this._allTables,e))throw new X.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},ge);function ge(e,t){var n=this;this._middlewares={},this.verno=0;var i=ge.dependencies;this._options=t=a({addons:ge.addons,autoOpen:!0,indexedDB:i.indexedDB,IDBKeyRange:i.IDBKeyRange,cache:"cloned"},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange},i=t.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var o,f,d,m,v,w={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ce,dbReadyPromise:null,cancelOpen:ce,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:t.autoOpen};w.dbReadyPromise=new G(function(g){w.dbReadyResolve=g}),w.openCanceller=new G(function(g,k){w.cancelOpen=k}),this._state=w,this.name=e,this.on=Ft(this,"populate","blocked","versionchange","close",{ready:[On,ce]}),this.on.ready.subscribe=ae(this.on.ready.subscribe,function(g){return function(k,b){ge.vip(function(){var T,R=n._state;R.openComplete?(R.dbOpenError||G.resolve().then(k),b&&g(k)):R.onReadyBeingFired?(R.onReadyBeingFired.push(k),b&&g(k)):(g(k),T=n,b||g(function A(){T.on.ready.unsubscribe(k),T.on.ready.unsubscribe(A)}))})}}),this.Collection=(o=this,jt(Ri.prototype,function(M,A){this.db=o;var b=Mr,T=null;if(A)try{b=A()}catch(O){T=O}var R=M._ctx,A=R.table,M=A.hook.reading.fire;this._ctx={table:A,index:R.index,isPrimKey:!R.index||A.schema.primKey.keyPath&&R.index===A.schema.primKey.name,range:b,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:T,or:R.or,valueMapper:M!==Lt?M:null}})),this.Table=(f=this,jt(Lr.prototype,function(g,k,b){this.db=f,this._tx=b,this.name=g,this.schema=k,this.hook=f._allTables[g]?f._allTables[g].hook:Ft(null,{creating:[vi,ce],reading:[gi,Lt],updating:[wi,ce],deleting:[bi,ce]})})),this.Transaction=(d=this,jt(Oi.prototype,function(g,k,b,T,R){var A=this;this.db=d,this.mode=g,this.storeNames=k,this.schema=b,this.chromeTransactionDurability=T,this.idbtrans=null,this.on=Ft(this,"complete","error","abort"),this.parent=R||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 G(function(M,O){A._resolve=M,A._reject=O}),this._completion.then(function(){A.active=!1,A.on.complete.fire()},function(M){var O=A.active;return A.active=!1,A.on.error.fire(M),A.parent?A.parent._reject(M):O&&A.idbtrans&&A.idbtrans.abort(),ye(M)})})),this.Version=(m=this,jt(Bi.prototype,function(g){this.db=m,this._cfg={version:g,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(v=this,jt(Fr.prototype,function(g,k,b){if(this.db=v,this._ctx={table:g,index:k===":id"?null:k,or:b},this._cmp=this._ascending=ie,this._descending=function(T,R){return ie(R,T)},this._max=function(T,R){return 0<ie(T,R)?T:R},this._min=function(T,R){return ie(T,R)<0?T:R},this._IDBKeyRange=v._deps.IDBKeyRange,!this._IDBKeyRange)throw new X.MissingAPI})),this.on("versionchange",function(g){0<g.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(g){!g.newVersion||g.newVersion<g.oldVersion?console.warn("Dexie.delete('".concat(n.name,"') was blocked")):console.warn("Upgrade '".concat(n.name,"' blocked by other connection holding version ").concat(g.oldVersion/10))}),this._maxKey=qt(t.IDBKeyRange),this._createTransaction=function(g,k,b,T){return new n.Transaction(g,k,b,n._options.chromeTransactionDurability,T)},this._fireOnBlocked=function(g){n.on("blocked").fire(g),Rt.filter(function(k){return k.name===n.name&&k!==n&&!k._state.vcFired}).map(function(k){return k.on("versionchange").fire(g)})},this.use(Ui),this.use(zi),this.use(Gi),this.use(ji),this.use(Ki);var S=new Proxy(this,{get:function(g,k,b){if(k==="_vip")return!0;if(k==="table")return function(R){return _n(n.table(R),S)};var T=Reflect.get(g,k,b);return T instanceof Lr?_n(T,S):k==="tables"?T.map(function(R){return _n(R,S)}):k==="_createTransaction"?function(){return _n(T.apply(this,arguments),S)}:T}});this.vip=S,i.forEach(function(g){return g(n)})}var An,Pe=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",Vi=(cr.prototype.subscribe=function(e,t,n){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:t,complete:n})},cr.prototype[Pe]=function(){return this},cr);function cr(e){this._subscribe=e}try{An={indexedDB:c.indexedDB||c.mozIndexedDB||c.webkitIndexedDB||c.msIndexedDB,IDBKeyRange:c.IDBKeyRange||c.webkitIDBKeyRange}}catch{An={indexedDB:null,IDBKeyRange:null}}function Zr(e){var t,n=!1,i=new Vi(function(o){var f=Pt(e),d,m=!1,v={},w={},S={get closed(){return m},unsubscribe:function(){m||(m=!0,d&&d.abort(),g&&tt.storagemutated.unsubscribe(b))}};o.start&&o.start(S);var g=!1,k=function(){return Fn(T)},b=function(R){vn(v,R),tr(w,v)&&k()},T=function(){var R,A,M;!m&&An.indexedDB&&(v={},R={},d&&d.abort(),d=new AbortController,M=function(O){var C=Tt();try{f&&Et();var I=$e(e,O);return I=f?I.finally(Je):I}finally{C&&St()}}(A={subscr:R,signal:d.signal,requery:k,querier:e,trans:null}),Promise.resolve(M).then(function(O){n=!0,t=O,m||A.signal.aborted||(v={},function(C){for(var I in C)if(_(C,I))return;return 1}(w=R)||g||(tt(Gt,b),g=!0),Fn(function(){return!m&&o.next&&o.next(O)}))},function(O){n=!1,["DatabaseClosedError","AbortError"].includes(O==null?void 0:O.name)||m||Fn(function(){m||o.error&&o.error(O)})}))};return setTimeout(k,0),S});return i.hasValue=function(){return n},i.getValue=function(){return t},i}var pt=Ve;function lr(e){var t=nt;try{nt=!0,tt.storagemutated.fire(e),ir(e,!0)}finally{nt=t}}P(pt,a(a({},Qt),{delete:function(e){return new pt(e,{addons:[]}).delete()},exists:function(e){return new pt(e,{addons:[]}).open().then(function(t){return t.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=pt.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Jn(n)?Promise.resolve(n.databases()).then(function(i){return i.map(function(o){return o.name}).filter(function(o){return o!==on})}):$n(n,t).toCollection().primaryKeys()).then(e)}catch{return ye(new X.MissingAPI)}var t,n},defineClass:function(){return function(e){h(this,e)}},ignoreTransaction:function(e){return V.trans?lt(V.transless,e):e()},vip:Zn,async:function(e){return function(){try{var t=sr(e.apply(this,arguments));return t&&typeof t.then=="function"?t:G.resolve(t)}catch(n){return ye(n)}}},spawn:function(e,t,n){try{var i=sr(e.apply(n,t||[]));return i&&typeof i.then=="function"?i:G.resolve(i)}catch(o){return ye(o)}},currentTransaction:{get:function(){return V.trans||null}},waitFor:function(e,t){return t=G.resolve(typeof e=="function"?pt.ignoreTransaction(e):e).timeout(t||6e4),V.trans?V.trans.waitFor(t):t},Promise:G,debug:{get:function(){return je},set:function(e){Ar(e)}},derive:W,extend:h,props:P,override:ae,Events:Ft,on:tt,liveQuery:Zr,extendObservabilitySet:vn,getByKeyPath:ve,setByKeyPath:le,delByKeyPath:function(e,t){typeof t=="string"?le(e,t,void 0):"length"in t&&[].map.call(t,function(n){le(e,n,void 0)})},shallowClone:Be,deepClone:ke,getObjectDiff:or,cmp:ie,asap:Ae,minKey:-1/0,addons:[],connections:Rt,errnames:Mn,dependencies:An,cache:dt,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)})})),pt.maxKey=qt(pt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(tt(Gt,function(e){nt||(e=new CustomEvent(Hn,{detail:e}),nt=!0,dispatchEvent(e),nt=!1)}),addEventListener(Hn,function(e){e=e.detail,nt||lr(e)}));var Ot,nt=!1,ei=function(){};return typeof BroadcastChannel<"u"&&((ei=function(){(Ot=new BroadcastChannel(Hn)).onmessage=function(e){return e.data&&lr(e.data)}})(),typeof Ot.unref=="function"&&Ot.unref(),tt(Gt,function(e){nt||Ot.postMessage(e)})),typeof addEventListener<"u"&&(addEventListener("pagehide",function(e){if(!Ve.disableBfCache&&e.persisted){je&&console.debug("Dexie: handling persisted pagehide"),Ot!=null&&Ot.close();for(var t=0,n=Rt;t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(e){!Ve.disableBfCache&&e.persisted&&(je&&console.debug("Dexie: handling persisted pageshow"),ei(),lr({all:new xe(-1/0,[[]])}))})),G.rejectionMapper=function(e,t){return!e||e instanceof Fe||e instanceof TypeError||e instanceof SyntaxError||!e.name||!_r[e.name]?e:(t=new _r[e.name](t||e.message,e),"stack"in e&&q(t,"stack",{get:function(){return this.inner.stack}}),t)},Ar(je),a(Ve,Object.freeze({__proto__:null,Dexie:Ve,liveQuery:Zr,Entity:Or,cmp:ie,PropModification:Kt,replacePrefix:function(e,t){return new Kt({replacePrefix:[e,t]})},add:function(e){return new Kt({add:e})},remove:function(e){return new Kt({remove:e})},default:Ve,RangeSet:xe,mergeRanges:Vt,rangesOverlap:qr}),{default:Ve}),Ve})}(Rn)),Rn.exports}var Us=Ks();const br=Fs(Us),hi=Symbol.for("Dexie"),kn=globalThis[hi]||(globalThis[hi]=br);if(br.semVer!==kn.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${br.semVer} and ${kn.semVer}`);const{liveQuery:qs,mergeRanges:Hs,rangesOverlap:zs,RangeSet:Vs,cmp:Xs,Entity:Ws,PropModification:Ys,replacePrefix:Qs,add:$s,remove:Js}=kn;class mi{constructor(r="threeJsIDBCache",s=1){this.db=new kn(r),this.materialMap={},this.db.version(s).stores({models:"&path, data"})}getDatabase(){return this.db}serObject3D(r){const s={type:r.type,name:r.name,position:r.position.toArray(),rotation:r.rotation.toArray(),scale:r.scale.toArray(),visible:r.visible,children:[],geometry:null,material:null,userData:r.userData};r.isMesh&&(s.geometry=this.serGeometry(r.geometry),s.material=this.serMaterial(r.material));for(const a of r.children)s.children.push(this.serObject3D(a));return s}serGeometry(r){const s=[],{attributes:a,index:u,type:c}=r;a.position&&(s.position={type:"Float32Array",array:Array.from(a.position.array),itemSize:3}),a.normal&&(s.normal={type:"Float32Array",array:Array.from(a.normal.array),itemSize:3}),a.uv&&(s.uv={type:"Float32Array",array:Array.from(a.uv.array),itemSize:2});const l={type:c,attributes:s};return u&&u.array&&(l.index={type:"Uint32Array",array:Array.from(u.array),itemSize:1}),l}reSerGeometry(r){const{type:s,attributes:a,index:u}=r,c=new yt.BufferGeometry;return Object.keys(a).forEach(l=>{const{type:p,array:h,itemSize:y}=a[l];c.setAttribute(l,new yt.BufferAttribute(new Float32Array(h),y))}),u&&c.setIndex(u.array),c}serMaterial(r){return{type:r.type,color:r.color.getHex(),map:r.map?r.map.image.src:null,opacity:r.opacity,name:r.name,depthTest:r.depthTest,depthWrite:r.depthWrite,transparent:r.transparent,side:r.side,roughness:r.roughness,metalness:r.metalness,emissive:r.emissive.getHex()}}reSerMaterial(r){if(this.materialMap[r.name])return this.materialMap[r.name];const{type:s,...a}=r,u=s||"MeshStandardMaterial",c=new yt[u]({...a});if(r.map){const l=new yt.TextureLoader().load(r.map);c.map=l}return c.needsUpdate=!0,this.materialMap[r.name]=c,c}reSerObject3D(r){let s;switch(r.type){case"Mesh":const a=this.reSerGeometry(r.geometry),u=this.reSerMaterial(r.material);s=new yt.Mesh(a,u);break;case"Group":s=new yt.Group;break;case"Object3D":s=new yt.Object3D;break;default:return console.warn(`Unsupported object type: ${r.type}`),null}s.name=r.name,s.position.fromArray(r.position),s.rotation.fromArray(r.rotation),s.scale.fromArray(r.scale),s.visible=r.visible,s.userData=r.userData;for(const a of r.children){const u=this.reSerObject3D(a);u&&s.add(u)}return s}async cacheModel(r,s){const a=this.serObject3D(s);await this.db.table("models").put({path:r,data:a}),console.log(`Model "${r}" cached successfully in table models`)}async loadCachedModel(r){const s=await this.db.table("models").get(r);if(!s)return console.warn(`Model "${r}" not found in table models`),null;const a=this.reSerObject3D(s.data);return console.log(`Model "${r}" loaded from table models`),a}}let En;const Gs=()=>{const L=new Qi,r=new Wi;r.setDecoderPath("/draco/"),L.setDRACOLoader(r);function s(c,l,p,h){return L.load(c,l,p,h)}function a(c,l){return new Promise((p,h)=>{L.load(c,p,l,h)})}async function u(c,l){En||(En=new mi);const p=await En.loadCachedModel(c);return p||new Promise((h,y)=>{L.load(c,h,l,y)}).then(async h=>(await En.cacheModel(c,h.scene),h))}return{load:s,asyncLoad:a,asyncCacheLoad:u}};exports.IDBCache=mi;exports.intersectColor=Ds;exports.obbObjects=Ge;exports.useGLTFLoader=Gs;exports.useObb=Ns;exports.useRaycaster=Is;exports.useThreeJs=Ls;
4
+ `+f:""),this.inner=f||null):typeof o=="object"&&(this.message="".concat(o.name," ").concat(o.message),this.inner=o):(this.message=wr[t]||n,this.inner=null)}return W(i).from(yi),e[t]=i,e},{});X.Syntax=SyntaxError,X.Type=TypeError,X.Range=RangeError;var _r=Dt.reduce(function(e,t){return e[t+"Error"]=X[t],e},{}),Qt=Pe.reduce(function(e,t){return["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=X[t]),e},{});function ce(){}function Lt(e){return e}function gi(e,t){return e==null||e===Lt?t:function(n){return t(e(n))}}function st(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function vi(e,t){return e===ce?t:function(){var n=e.apply(this,arguments);n!==void 0&&(arguments[0]=n);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var f=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?st(i,this.onsuccess):i),o&&(this.onerror=this.onerror?st(o,this.onerror):o),f!==void 0?f:n}}function bi(e,t){return e===ce?t:function(){e.apply(this,arguments);var n=this.onsuccess,i=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?st(n,this.onsuccess):n),i&&(this.onerror=this.onerror?st(i,this.onerror):i)}}function wi(e,t){return e===ce?t:function(n){var i=e.apply(this,arguments);h(n,i);var o=this.onsuccess,f=this.onerror;return this.onsuccess=null,this.onerror=null,n=t.apply(this,arguments),o&&(this.onsuccess=this.onsuccess?st(o,this.onsuccess):o),f&&(this.onerror=this.onerror?st(f,this.onerror):f),i===void 0?n===void 0?void 0:n:h(i,n)}}function _i(e,t){return e===ce?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function On(e,t){return e===ce?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var i=this,o=arguments.length,f=new Array(o);o--;)f[o]=arguments[o];return n.then(function(){return t.apply(i,f)})}return t.apply(this,arguments)}}Qt.ModifyError=Yt,Qt.DexieError=Fe,Qt.BulkError=xt;var je=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Ar(e){je=e}var It={},xr=100,ot=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]}(),Dt=ot[0],Pe=ot[1],ot=ot[2],Pe=Pe&&Pe.then,at=Dt&&Dt.constructor,Cn=!!ot,Nt=function(e,t){Bt.push([e,t]),$t&&(queueMicrotask(xi),$t=!1)},Pn=!0,$t=!0,ut=[],Jt=[],Ln=Lt,Qe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ce,pgp:!1,env:{},finalize:ce},V=Qe,Bt=[],ct=0,Zt=[];function G(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=V;if(typeof e!="function"){if(e!==It)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Dn(this,this._value))}this._state=null,this._value=null,++t.ref,function n(i,o){try{o(function(f){if(i._state===null){if(f===i)throw new TypeError("A promise cannot be resolved with itself.");var d=i._lib&&Tt();f&&typeof f.then=="function"?n(i,function(m,v){f instanceof G?f._then(m,v):f.then(m,v)}):(i._state=!0,i._value=f,Sr(i)),d&&St()}},Dn.bind(null,i))}catch(f){Dn(i,f)}}(this,e)}var In={get:function(){var e=V,t=rn;function n(i,o){var f=this,d=!e.global&&(e!==V||t!==rn),m=d&&!Je(),v=new G(function(w,S){Nn(f,new Tr(Rr(i,e,d,m),Rr(o,e,d,m),w,S,e))});return this._consoleTask&&(v._consoleTask=this._consoleTask),v}return n.prototype=It,n},set:function(e){q(this,"then",e&&e.prototype===It?In:{get:function(){return e},set:In.set})}};function Tr(e,t,n,i,o){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=i,this.psd=o}function Dn(e,t){var n,i;Jt.push(t),e._state===null&&(n=e._lib&&Tt(),t=Ln(t),e._state=!1,e._value=t,i=e,ut.some(function(o){return o._value===i._value})||ut.push(i),Sr(e),n&&St())}function Sr(e){var t=e._listeners;e._listeners=[];for(var n=0,i=t.length;n<i;++n)Nn(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),ct===0&&(++ct,Nt(function(){--ct==0&&Bn()},[]))}function Nn(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,++ct,Nt(Ai,[n,e,t])}else e._listeners.push(t)}function Ai(e,t,n){try{var i,o=t._value;!t._state&&Jt.length&&(Jt=[]),i=je&&t._consoleTask?t._consoleTask.run(function(){return e(o)}):e(o),t._state||Jt.indexOf(o)!==-1||function(f){for(var d=ut.length;d;)if(ut[--d]._value===f._value)return ut.splice(d,1)}(t),n.resolve(i)}catch(f){n.reject(f)}finally{--ct==0&&Bn(),--n.psd.ref||n.psd.finalize()}}function xi(){lt(Qe,function(){Tt()&&St()})}function Tt(){var e=Pn;return $t=Pn=!1,e}function St(){var e,t,n;do for(;0<Bt.length;)for(e=Bt,Bt=[],n=e.length,t=0;t<n;++t){var i=e[t];i[0].apply(null,i[1])}while(0<Bt.length);$t=Pn=!0}function Bn(){var e=ut;ut=[],e.forEach(function(i){i._PSD.onunhandled.call(null,i._value,i)});for(var t=Zt.slice(0),n=t.length;n;)t[--n]()}function en(e){return new G(It,!1,e)}function de(e,t){var n=V;return function(){var i=Tt(),o=V;try{return Ze(n,!0),e.apply(this,arguments)}catch(f){t&&t(f)}finally{Ze(o,!1),i&&St()}}}P(G.prototype,{then:In,_then:function(e,t){Nn(this,new Tr(null,null,e,t,V))},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(i){return(i instanceof t?n:en)(i)}):this.then(null,function(i){return(i&&i.name===t?n:en)(i)})},finally:function(e){return this.then(function(t){return G.resolve(e()).then(function(){return t})},function(t){return G.resolve(e()).then(function(){return en(t)})})},timeout:function(e,t){var n=this;return e<1/0?new G(function(i,o){var f=setTimeout(function(){return o(new X.Timeout(t))},e);n.then(i,o).finally(clearTimeout.bind(null,f))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&q(G.prototype,Symbol.toStringTag,"Dexie.Promise"),Qe.env=Er(),P(G,{all:function(){var e=De.apply(null,arguments).map(sn);return new G(function(t,n){e.length===0&&t([]);var i=e.length;e.forEach(function(o,f){return G.resolve(o).then(function(d){e[f]=d,--i||t(e)},n)})})},resolve:function(e){return e instanceof G?e:e&&typeof e.then=="function"?new G(function(t,n){e.then(t,n)}):new G(It,!0,e)},reject:en,race:function(){var e=De.apply(null,arguments).map(sn);return new G(function(t,n){e.map(function(i){return G.resolve(i).then(t,n)})})},PSD:{get:function(){return V},set:function(e){return V=e}},totalEchoes:{get:function(){return rn}},newPSD:$e,usePSD:lt,scheduler:{get:function(){return Nt},set:function(e){Nt=e}},rejectionMapper:{get:function(){return Ln},set:function(e){Ln=e}},follow:function(e,t){return new G(function(n,i){return $e(function(o,f){var d=V;d.unhandleds=[],d.onunhandled=f,d.finalize=st(function(){var m,v=this;m=function(){v.unhandleds.length===0?o():f(v.unhandleds[0])},Zt.push(function w(){m(),Zt.splice(Zt.indexOf(w),1)}),++ct,Nt(function(){--ct==0&&Bn()},[])},d.finalize),e()},t,n,i)})}}),at&&(at.allSettled&&q(G,"allSettled",function(){var e=De.apply(null,arguments).map(sn);return new G(function(t){e.length===0&&t([]);var n=e.length,i=new Array(n);e.forEach(function(o,f){return G.resolve(o).then(function(d){return i[f]={status:"fulfilled",value:d}},function(d){return i[f]={status:"rejected",reason:d}}).then(function(){return--n||t(i)})})})}),at.any&&typeof AggregateError<"u"&&q(G,"any",function(){var e=De.apply(null,arguments).map(sn);return new G(function(t,n){e.length===0&&n(new AggregateError([]));var i=e.length,o=new Array(i);e.forEach(function(f,d){return G.resolve(f).then(function(m){return t(m)},function(m){o[d]=m,--i||n(new AggregateError(o))})})})}),at.withResolvers&&(G.withResolvers=at.withResolvers));var we={awaits:0,echoes:0,id:0},Ti=0,tn=[],nn=0,rn=0,Si=0;function $e(e,t,n,i){var o=V,f=Object.create(o);return f.parent=o,f.ref=0,f.global=!1,f.id=++Si,Qe.env,f.env=Cn?{Promise:G,PromiseProp:{value:G,configurable:!0,writable:!0},all:G.all,race:G.race,allSettled:G.allSettled,any:G.any,resolve:G.resolve,reject:G.reject}:{},t&&h(f,t),++o.ref,f.finalize=function(){--this.parent.ref||this.parent.finalize()},i=lt(f,e,n,i),f.ref===0&&f.finalize(),i}function Et(){return we.id||(we.id=++Ti),++we.awaits,we.echoes+=xr,we.id}function Je(){return!!we.awaits&&(--we.awaits==0&&(we.id=0),we.echoes=we.awaits*xr,!0)}function sn(e){return we.echoes&&e&&e.constructor===at?(Et(),e.then(function(t){return Je(),t},function(t){return Je(),ye(t)})):e}function Ei(){var e=tn[tn.length-1];tn.pop(),Ze(e,!1)}function Ze(e,t){var n,i=V;(t?!we.echoes||nn++&&e===V:!nn||--nn&&e===V)||queueMicrotask(t?(function(o){++rn,we.echoes&&--we.echoes!=0||(we.echoes=we.awaits=we.id=0),tn.push(V),Ze(o,!0)}).bind(null,e):Ei),e!==V&&(V=e,i===Qe&&(Qe.env=Er()),Cn&&(n=Qe.env.Promise,t=e.env,(i.global||e.global)&&(Object.defineProperty(c,"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 Er(){var e=c.Promise;return Cn?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(c,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function lt(e,t,n,i,o){var f=V;try{return Ze(e,!0),t(n,i,o)}finally{Ze(f,!1)}}function Rr(e,t,n,i){return typeof e!="function"?e:function(){var o=V;n&&Et(),Ze(t,!0);try{return e.apply(this,arguments)}finally{Ze(o,!1),i&&queueMicrotask(Je)}}}function Fn(e){Promise===at&&we.echoes===0?nn===0?e():enqueueNativeMicroTask(e):setTimeout(e,0)}(""+Pe).indexOf("[native code]")===-1&&(Et=Je=ce);var ye=G.reject,ft="￿",ze="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",kr="String expected.",Rt=[],on="__dbnames",jn="readonly",Kn="readwrite";function ht(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var Mr={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function an(e){return typeof e!="string"||/\./.test(e)?function(t){return t}:function(t){return t[e]===void 0&&e in t&&delete(t=ke(t))[e],t}}function Or(){throw X.Type()}function ie(e,t){try{var n=Cr(e),i=Cr(t);if(n!==i)return n==="Array"?1:i==="Array"?-1:n==="binary"?1:i==="binary"?-1:n==="string"?1:i==="string"?-1:n==="Date"?1:i!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(o,f){for(var d=o.length,m=f.length,v=d<m?d:m,w=0;w<v;++w)if(o[w]!==f[w])return o[w]<f[w]?-1:1;return d===m?0:d<m?-1:1}(Pr(e),Pr(t));case"Array":return function(o,f){for(var d=o.length,m=f.length,v=d<m?d:m,w=0;w<v;++w){var S=ie(o[w],f[w]);if(S!==0)return S}return d===m?0:d<m?-1:1}(e,t)}}catch{}return NaN}function Cr(e){var t=typeof e;return t!="object"?t:ArrayBuffer.isView(e)?"binary":(e=_t(e),e==="ArrayBuffer"?"binary":e)}function Pr(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Lr=(fe.prototype._trans=function(e,t,n){var i=this._tx||V.trans,o=this.name,f=je&&typeof console<"u"&&console.createTask&&console.createTask("Dexie: ".concat(e==="readonly"?"read":"write"," ").concat(this.name));function d(w,S,g){if(!g.schema[o])throw new X.NotFound("Table "+o+" not part of transaction");return t(g.idbtrans,g)}var m=Tt();try{var v=i&&i.db._novip===this.db._novip?i===V.trans?i._promise(e,d,n):$e(function(){return i._promise(e,d,n)},{trans:i,transless:V.transless||V}):function w(S,g,k,b){if(S.idbdb&&(S._state.openComplete||V.letThrough||S._vip)){var T=S._createTransaction(g,k,S._dbSchema);try{T.create(),S._state.PR1398_maxLoop=3}catch(R){return R.name===Mn.InvalidState&&S.isOpen()&&0<--S._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),S.close({disableAutoOpen:!1}),S.open().then(function(){return w(S,g,k,b)})):ye(R)}return T._promise(g,function(R,A){return $e(function(){return V.trans=T,b(R,A,T)})}).then(function(R){if(g==="readwrite")try{T.idbtrans.commit()}catch{}return g==="readonly"?R:T._completion.then(function(){return R})})}if(S._state.openComplete)return ye(new X.DatabaseClosed(S._state.dbOpenError));if(!S._state.isBeingOpened){if(!S._state.autoOpen)return ye(new X.DatabaseClosed);S.open().catch(ce)}return S._state.dbReadyPromise.then(function(){return w(S,g,k,b)})}(this.db,e,[this.name],d);return f&&(v._consoleTask=f,v=v.catch(function(w){return console.trace(w),ye(w)})),v}finally{m&&St()}},fe.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):e==null?ye(new X.Type("Invalid argument to Table.get()")):this._trans("readonly",function(i){return n.core.get({trans:i,key:e}).then(function(o){return n.hook.reading.fire(o)})}).then(t)},fe.prototype.where=function(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if(p(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=l(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(m){if(m.compound&&t.every(function(w){return 0<=m.keyPath.indexOf(w)})){for(var v=0;v<t.length;++v)if(t.indexOf(m.keyPath[v])===-1)return!1;return!0}return!1}).sort(function(m,v){return m.keyPath.length-v.keyPath.length})[0];if(n&&this.db._maxKey!==ft){var f=n.keyPath.slice(0,t.length);return this.where(f).equals(f.map(function(v){return e[v]}))}!n&&je&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(t.join("+"),"]"));var i=this.schema.idxByName;function o(m,v){return ie(m,v)===0}var d=t.reduce(function(g,v){var w=g[0],S=g[1],g=i[v],k=e[v];return[w||g,w||!g?ht(S,g&&g.multi?function(b){return b=ve(b,v),p(b)&&b.some(function(T){return o(k,T)})}:function(b){return o(k,ve(b,v))}):S]},[null,null]),f=d[0],d=d[1];return f?this.where(f.name).equals(e[f.keyPath]).filter(d):n?this.filter(d):this.where(t).equals("")},fe.prototype.filter=function(e){return this.toCollection().and(e)},fe.prototype.count=function(e){return this.toCollection().count(e)},fe.prototype.offset=function(e){return this.toCollection().offset(e)},fe.prototype.limit=function(e){return this.toCollection().limit(e)},fe.prototype.each=function(e){return this.toCollection().each(e)},fe.prototype.toArray=function(e){return this.toCollection().toArray(e)},fe.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},fe.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,p(e)?"[".concat(e.join("+"),"]"):e))},fe.prototype.reverse=function(){return this.toCollection().reverse()},fe.prototype.mapToClass=function(e){var t,n=this.db,i=this.name;function o(){return t!==null&&t.apply(this,arguments)||this}(this.schema.mappedClass=e).prototype instanceof Or&&(function(v,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");function S(){this.constructor=v}s(v,w),v.prototype=w===null?Object.create(w):(S.prototype=w.prototype,new S)}(o,t=e),Object.defineProperty(o.prototype,"db",{get:function(){return n},enumerable:!1,configurable:!0}),o.prototype.table=function(){return i},e=o);for(var f=new Set,d=e.prototype;d;d=y(d))Object.getOwnPropertyNames(d).forEach(function(v){return f.add(v)});function m(v){if(!v)return v;var w,S=Object.create(e.prototype);for(w in v)if(!f.has(w))try{S[w]=v[w]}catch{}return S}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=m,this.hook("reading",m),e},fe.prototype.defineClass=function(){return this.mapToClass(function(e){h(this,e)})},fe.prototype.add=function(e,t){var n=this,i=this.schema.primKey,o=i.auto,f=i.keyPath,d=e;return f&&o&&(d=an(f)(e)),this._trans("readwrite",function(m){return n.core.mutate({trans:m,type:"add",keys:t!=null?[t]:null,values:[d]})}).then(function(m){return m.numFailures?G.reject(m.failures[0]):m.lastResult}).then(function(m){if(f)try{le(e,f,m)}catch{}return m})},fe.prototype.update=function(e,t){return typeof e!="object"||p(e)?this.where(":id").equals(e).modify(t):(e=ve(e,this.schema.primKey.keyPath),e===void 0?ye(new X.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t))},fe.prototype.put=function(e,t){var n=this,i=this.schema.primKey,o=i.auto,f=i.keyPath,d=e;return f&&o&&(d=an(f)(e)),this._trans("readwrite",function(m){return n.core.mutate({trans:m,type:"put",values:[d],keys:t!=null?[t]:null})}).then(function(m){return m.numFailures?G.reject(m.failures[0]):m.lastResult}).then(function(m){if(f)try{le(e,f,m)}catch{}return m})},fe.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?G.reject(n.failures[0]):void 0})},fe.prototype.clear=function(){var e=this;return this._trans("readwrite",function(t){return e.core.mutate({trans:t,type:"deleteRange",range:Mr})}).then(function(t){return t.numFailures?G.reject(t.failures[0]):void 0})},fe.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",function(n){return t.core.getMany({keys:e,trans:n}).then(function(i){return i.map(function(o){return t.hook.reading.fire(o)})})})},fe.prototype.bulkAdd=function(e,t,n){var i=this,o=Array.isArray(t)?t:void 0,f=(n=n||(o?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(d){var w=i.schema.primKey,m=w.auto,w=w.keyPath;if(w&&o)throw new X.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");var v=e.length,w=w&&m?e.map(an(w)):e;return i.core.mutate({trans:d,type:"add",keys:o,values:w,wantResults:f}).then(function(T){var g=T.numFailures,k=T.results,b=T.lastResult,T=T.failures;if(g===0)return f?k:b;throw new xt("".concat(i.name,".bulkAdd(): ").concat(g," of ").concat(v," operations failed"),T)})})},fe.prototype.bulkPut=function(e,t,n){var i=this,o=Array.isArray(t)?t:void 0,f=(n=n||(o?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(d){var w=i.schema.primKey,m=w.auto,w=w.keyPath;if(w&&o)throw new X.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(o&&o.length!==e.length)throw new X.InvalidArgument("Arguments objects and keys must have the same length");var v=e.length,w=w&&m?e.map(an(w)):e;return i.core.mutate({trans:d,type:"put",keys:o,values:w,wantResults:f}).then(function(T){var g=T.numFailures,k=T.results,b=T.lastResult,T=T.failures;if(g===0)return f?k:b;throw new xt("".concat(i.name,".bulkPut(): ").concat(g," of ").concat(v," operations failed"),T)})})},fe.prototype.bulkUpdate=function(e){var t=this,n=this.core,i=e.map(function(d){return d.key}),o=e.map(function(d){return d.changes}),f=[];return this._trans("readwrite",function(d){return n.getMany({trans:d,keys:i,cache:"clone"}).then(function(m){var v=[],w=[];e.forEach(function(g,k){var b=g.key,T=g.changes,R=m[k];if(R){for(var A=0,M=Object.keys(T);A<M.length;A++){var O=M[A],C=T[O];if(O===t.schema.primKey.keyPath){if(ie(C,b)!==0)throw new X.Constraint("Cannot update primary key in bulkUpdate()")}else le(R,O,C)}f.push(k),v.push(b),w.push(R)}});var S=v.length;return n.mutate({trans:d,type:"put",keys:v,values:w,updates:{keys:i,changeSpecs:o}}).then(function(g){var k=g.numFailures,b=g.failures;if(k===0)return S;for(var T=0,R=Object.keys(b);T<R.length;T++){var A,M=R[T],O=f[Number(M)];O!=null&&(A=b[M],delete b[M],b[O]=A)}throw new xt("".concat(t.name,".bulkUpdate(): ").concat(k," of ").concat(S," operations failed"),b)})})})},fe.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",function(i){return t.core.mutate({trans:i,type:"delete",keys:e})}).then(function(d){var o=d.numFailures,f=d.lastResult,d=d.failures;if(o===0)return f;throw new xt("".concat(t.name,".bulkDelete(): ").concat(o," of ").concat(n," operations failed"),d)})},fe);function fe(){}function Ft(e){function t(d,m){if(m){for(var v=arguments.length,w=new Array(v-1);--v;)w[v-1]=arguments[v];return n[d].subscribe.apply(null,w),e}if(typeof d=="string")return n[d]}var n={};t.addEventType=f;for(var i=1,o=arguments.length;i<o;++i)f(arguments[i]);return t;function f(d,m,v){if(typeof d!="object"){var w;m=m||_i;var S={subscribers:[],fire:v=v||ce,subscribe:function(g){S.subscribers.indexOf(g)===-1&&(S.subscribers.push(g),S.fire=m(S.fire,g))},unsubscribe:function(g){S.subscribers=S.subscribers.filter(function(k){return k!==g}),S.fire=S.subscribers.reduce(m,v)}};return n[d]=t[d]=S}l(w=d).forEach(function(g){var k=w[g];if(p(k))f(g,w[g][0],w[g][1]);else{if(k!=="asap")throw new X.InvalidArgument("Invalid event config");var b=f(g,Lt,function(){for(var T=arguments.length,R=new Array(T);T--;)R[T]=arguments[T];b.subscribers.forEach(function(A){Ae(function(){A.apply(null,R)})})})}})}}function jt(e,t){return W(t).from({prototype:e}),t}function kt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Un(e,t){e.filter=ht(e.filter,t)}function Gn(e,t,n){var i=e.replayFilter;e.replayFilter=i?function(){return ht(i(),t())}:t,e.justLimit=n&&!i}function un(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new X.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Ir(e,t,n){var i=un(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:i,range:e.range}})}function cn(e,t,n,i){var o=e.replayFilter?ht(e.filter,e.replayFilter()):e.filter;if(e.or){var f={},d=function(m,v,w){var S,g;o&&!o(v,w,function(k){return v.stop(k)},function(k){return v.fail(k)})||((g=""+(S=v.primaryKey))=="[object ArrayBuffer]"&&(g=""+new Uint8Array(S)),_(f,g)||(f[g]=!0,t(m,v,w)))};return Promise.all([e.or._iterate(d,n),Dr(Ir(e,i,n),e.algorithm,d,!e.keysOnly&&e.valueMapper)])}return Dr(Ir(e,i,n),ht(e.algorithm,o),t,!e.keysOnly&&e.valueMapper)}function Dr(e,t,n,i){var o=de(i?function(f,d,m){return n(i(f),d,m)}:n);return e.then(function(f){if(f)return f.start(function(){var d=function(){return f.continue()};t&&!t(f,function(m){return d=m},function(m){f.stop(m),d=ce},function(m){f.fail(m),d=ce})||o(f.value,f,function(m){return d=m}),d()})})}var Kt=(Nr.prototype.execute=function(e){var t=this["@@propmod"];if(t.add!==void 0){var n=t.add;if(p(n))return u(u([],p(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 i=t.remove;if(p(i))return p(e)?e.filter(function(o){return!i.includes(o)}).sort():[];if(typeof i=="number")return Number(e)-i;if(typeof i=="bigint")try{return BigInt(e)-i}catch{return BigInt(0)-i}throw new TypeError("Invalid subtrahend ".concat(i))}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 Ri=(oe.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,ye.bind(null,n.error)):n.table._trans("readonly",e).then(t)},oe.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,ye.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},oe.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=ht(t.algorithm,e)},oe.prototype._iterate=function(e,t){return cn(this._ctx,e,t,this._ctx.table.core)},oe.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&h(n,e),t._ctx=n,t},oe.prototype.raw=function(){return this._ctx.valueMapper=null,this},oe.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return cn(t,e,n,t.table.core)})},oe.prototype.count=function(e){var t=this;return this._read(function(n){var i=t._ctx,o=i.table.core;if(kt(i,!0))return o.count({trans:n,query:{index:un(i,o.schema),range:i.range}}).then(function(d){return Math.min(d,i.limit)});var f=0;return cn(i,function(){return++f,!1},n,o).then(function(){return f})}).then(e)},oe.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),i=n[0],o=n.length-1;function f(v,w){return w?f(v[n[w]],w-1):v[i]}var d=this._ctx.dir==="next"?1:-1;function m(v,w){return ie(f(v,o),f(w,o))*d}return this.toArray(function(v){return v.sort(m)}).then(t)},oe.prototype.toArray=function(e){var t=this;return this._read(function(n){var i=t._ctx;if(i.dir==="next"&&kt(i,!0)&&0<i.limit){var o=i.valueMapper,f=un(i,i.table.core.schema);return i.table.core.query({trans:n,limit:i.limit,values:!0,query:{index:f,range:i.range}}).then(function(m){return m=m.result,o?m.map(o):m})}var d=[];return cn(i,function(m){return d.push(m)},n,i.table.core).then(function(){return d})},e)},oe.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,kt(t)?Gn(t,function(){var n=e;return function(i,o){return n===0||(n===1?--n:o(function(){i.advance(n),n=0}),!1)}}):Gn(t,function(){var n=e;return function(){return--n<0}})),this},oe.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Gn(this._ctx,function(){var t=e;return function(n,i,o){return--t<=0&&i(o),0<=t}},!0),this},oe.prototype.until=function(e,t){return Un(this._ctx,function(n,i,o){return!e(n.value)||(i(o),t)}),this},oe.prototype.first=function(e){return this.limit(1).toArray(function(t){return t[0]}).then(e)},oe.prototype.last=function(e){return this.reverse().first(e)},oe.prototype.filter=function(e){var t;return Un(this._ctx,function(n){return e(n.value)}),(t=this._ctx).isMatch=ht(t.isMatch,e),this},oe.prototype.and=function(e){return this.filter(e)},oe.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},oe.prototype.reverse=function(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},oe.prototype.desc=function(){return this.reverse()},oe.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,i){e(i.key,i)})},oe.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},oe.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(n,i){e(i.primaryKey,i)})},oe.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(i,o){n.push(o.key)}).then(function(){return n}).then(e)},oe.prototype.primaryKeys=function(e){var t=this._ctx;if(t.dir==="next"&&kt(t,!0)&&0<t.limit)return this._read(function(i){var o=un(t,t.table.core.schema);return t.table.core.query({trans:i,values:!1,limit:t.limit,query:{index:o,range:t.range}})}).then(function(i){return i.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(i,o){n.push(o.primaryKey)}).then(function(){return n}).then(e)},oe.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},oe.prototype.firstKey=function(e){return this.limit(1).keys(function(t){return t[0]}).then(e)},oe.prototype.lastKey=function(e){return this.reverse().firstKey(e)},oe.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 Un(this._ctx,function(o){var i=o.primaryKey.toString(),o=_(t,i);return t[i]=!0,!o}),this},oe.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(i){var o,f,d;d=typeof e=="function"?e:(o=l(e),f=o.length,function(A){for(var M=!1,O=0;O<f;++O){var C=o[O],I=e[C],N=ve(A,C);I instanceof Kt?(le(A,C,I.execute(N)),M=!0):N!==I&&(le(A,C,I),M=!0)}return M});var m=n.table.core,g=m.schema.primaryKey,v=g.outbound,w=g.extractKey,S=200,g=t.db._options.modifyChunkSize;g&&(S=typeof g=="object"?g[m.name]||g["*"]||200:g);function k(A,C){var O=C.failures,C=C.numFailures;T+=A-C;for(var I=0,N=l(O);I<N.length;I++){var K=N[I];b.push(O[K])}}var b=[],T=0,R=[];return t.clone().primaryKeys().then(function(A){function M(C){var I=Math.min(S,A.length-C);return m.getMany({trans:i,keys:A.slice(C,C+I),cache:"immutable"}).then(function(N){for(var K=[],B=[],F=v?[]:null,U=[],j=0;j<I;++j){var H=N[j],J={value:ke(H),primKey:A[C+j]};d.call(J,J.value,J)!==!1&&(J.value==null?U.push(A[C+j]):v||ie(w(H),w(J.value))===0?(B.push(J.value),v&&F.push(A[C+j])):(U.push(A[C+j]),K.push(J.value)))}return Promise.resolve(0<K.length&&m.mutate({trans:i,type:"add",values:K}).then(function(te){for(var ne in te.failures)U.splice(parseInt(ne),1);k(K.length,te)})).then(function(){return(0<B.length||O&&typeof e=="object")&&m.mutate({trans:i,type:"put",keys:F,values:B,criteria:O,changeSpec:typeof e!="function"&&e,isAdditionalChunk:0<C}).then(function(te){return k(B.length,te)})}).then(function(){return(0<U.length||O&&e===qn)&&m.mutate({trans:i,type:"delete",keys:U,criteria:O,isAdditionalChunk:0<C}).then(function(te){return k(U.length,te)})}).then(function(){return A.length>C+I&&M(C+S)})})}var O=kt(n)&&n.limit===1/0&&(typeof e!="function"||e===qn)&&{index:n.index,range:n.range};return M(0).then(function(){if(0<b.length)throw new Yt("Error modifying one or more objects",b,T,R);return A.length})})})},oe.prototype.delete=function(){var e=this._ctx,t=e.range;return kt(e)&&(e.isPrimKey||t.type===3)?this._write(function(n){var i=e.table.core.schema.primaryKey,o=t;return e.table.core.count({trans:n,query:{index:i,range:o}}).then(function(f){return e.table.core.mutate({trans:n,type:"deleteRange",range:o}).then(function(d){var m=d.failures;if(d.lastResult,d.results,d=d.numFailures,d)throw new Yt("Could not delete some values",Object.keys(m).map(function(v){return m[v]}),f-d);return f-d})})}):this.modify(qn)},oe);function oe(){}var qn=function(e,t){return t.value=null};function ki(e,t){return e<t?-1:e===t?0:1}function Mi(e,t){return t<e?-1:e===t?0:1}function Me(e,t,n){return e=e instanceof Fr?new e.Collection(e):e,e._ctx.error=new(n||TypeError)(t),e}function Mt(e){return new e.Collection(e,function(){return Br("")}).limit(0)}function ln(e,t,n,i){var o,f,d,m,v,w,S,g=n.length;if(!n.every(function(T){return typeof T=="string"}))return Me(e,kr);function k(T){o=T==="next"?function(A){return A.toUpperCase()}:function(A){return A.toLowerCase()},f=T==="next"?function(A){return A.toLowerCase()}:function(A){return A.toUpperCase()},d=T==="next"?ki:Mi;var R=n.map(function(A){return{lower:f(A),upper:o(A)}}).sort(function(A,M){return d(A.lower,M.lower)});m=R.map(function(A){return A.upper}),v=R.map(function(A){return A.lower}),S=(w=T)==="next"?"":i}k("next"),e=new e.Collection(e,function(){return et(m[0],v[g-1]+i)}),e._ondirectionchange=function(T){k(T)};var b=0;return e._addAlgorithm(function(T,R,A){var M=T.key;if(typeof M!="string")return!1;var O=f(M);if(t(O,v,b))return!0;for(var C=null,I=b;I<g;++I){var N=function(K,B,F,U,j,H){for(var J=Math.min(K.length,U.length),te=-1,ne=0;ne<J;++ne){var Oe=B[ne];if(Oe!==U[ne])return j(K[ne],F[ne])<0?K.substr(0,ne)+F[ne]+F.substr(ne+1):j(K[ne],U[ne])<0?K.substr(0,ne)+U[ne]+F.substr(ne+1):0<=te?K.substr(0,te)+B[te]+F.substr(te+1):null;j(K[ne],Oe)<0&&(te=ne)}return J<U.length&&H==="next"?K+F.substr(K.length):J<K.length&&H==="prev"?K.substr(0,F.length):te<0?null:K.substr(0,te)+U[te]+F.substr(te+1)}(M,O,m[I],v[I],d,w);N===null&&C===null?b=I+1:(C===null||0<d(C,N))&&(C=N)}return R(C!==null?function(){T.continue(C+S)}:A),!1}),e}function et(e,t,n,i){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:i}}function Br(e){return{type:1,lower:e,upper:e}}var Fr=(Object.defineProperty(_e.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),_e.prototype.between=function(e,t,n,i){n=n!==!1,i=i===!0;try{return 0<this._cmp(e,t)||this._cmp(e,t)===0&&(n||i)&&(!n||!i)?Mt(this):new this.Collection(this,function(){return et(e,t,!n,!i)})}catch{return Me(this,ze)}},_e.prototype.equals=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return Br(e)})},_e.prototype.above=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return et(e,void 0,!0)})},_e.prototype.aboveOrEqual=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return et(e,void 0,!1)})},_e.prototype.below=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return et(void 0,e,!1,!0)})},_e.prototype.belowOrEqual=function(e){return e==null?Me(this,ze):new this.Collection(this,function(){return et(void 0,e)})},_e.prototype.startsWith=function(e){return typeof e!="string"?Me(this,kr):this.between(e,e+ft,!0,!0)},_e.prototype.startsWithIgnoreCase=function(e){return e===""?this.startsWith(e):ln(this,function(t,n){return t.indexOf(n[0])===0},[e],ft)},_e.prototype.equalsIgnoreCase=function(e){return ln(this,function(t,n){return t===n[0]},[e],"")},_e.prototype.anyOfIgnoreCase=function(){var e=De.apply(Ye,arguments);return e.length===0?Mt(this):ln(this,function(t,n){return n.indexOf(t)!==-1},e,"")},_e.prototype.startsWithAnyOfIgnoreCase=function(){var e=De.apply(Ye,arguments);return e.length===0?Mt(this):ln(this,function(t,n){return n.some(function(i){return t.indexOf(i)===0})},e,ft)},_e.prototype.anyOf=function(){var e=this,t=De.apply(Ye,arguments),n=this._cmp;try{t.sort(n)}catch{return Me(this,ze)}if(t.length===0)return Mt(this);var i=new this.Collection(this,function(){return et(t[0],t[t.length-1])});i._ondirectionchange=function(f){n=f==="next"?e._ascending:e._descending,t.sort(n)};var o=0;return i._addAlgorithm(function(f,d,m){for(var v=f.key;0<n(v,t[o]);)if(++o===t.length)return d(m),!1;return n(v,t[o])===0||(d(function(){f.continue(t[o])}),!1)}),i},_e.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},_e.prototype.noneOf=function(){var e=De.apply(Ye,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Me(this,ze)}var t=e.reduce(function(n,i){return n?n.concat([[n[n.length-1][1],i]]):[[-1/0,i]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},_e.prototype.inAnyRange=function(M,t){var n=this,i=this._cmp,o=this._ascending,f=this._descending,d=this._min,m=this._max;if(M.length===0)return Mt(this);if(!M.every(function(O){return O[0]!==void 0&&O[1]!==void 0&&o(O[0],O[1])<=0}))return Me(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",X.InvalidArgument);var v=!t||t.includeLowers!==!1,w=t&&t.includeUppers===!0,S,g=o;function k(O,C){return g(O[0],C[0])}try{(S=M.reduce(function(O,C){for(var I=0,N=O.length;I<N;++I){var K=O[I];if(i(C[0],K[1])<0&&0<i(C[1],K[0])){K[0]=d(K[0],C[0]),K[1]=m(K[1],C[1]);break}}return I===N&&O.push(C),O},[])).sort(k)}catch{return Me(this,ze)}var b=0,T=w?function(O){return 0<o(O,S[b][1])}:function(O){return 0<=o(O,S[b][1])},R=v?function(O){return 0<f(O,S[b][0])}:function(O){return 0<=f(O,S[b][0])},A=T,M=new this.Collection(this,function(){return et(S[0][0],S[S.length-1][1],!v,!w)});return M._ondirectionchange=function(O){g=O==="next"?(A=T,o):(A=R,f),S.sort(k)},M._addAlgorithm(function(O,C,I){for(var N,K=O.key;A(K);)if(++b===S.length)return C(I),!1;return!T(N=K)&&!R(N)||(n._cmp(K,S[b][1])===0||n._cmp(K,S[b][0])===0||C(function(){g===o?O.continue(S[b][0]):O.continue(S[b][1])}),!1)}),M},_e.prototype.startsWithAnyOf=function(){var e=De.apply(Ye,arguments);return e.every(function(t){return typeof t=="string"})?e.length===0?Mt(this):this.inAnyRange(e.map(function(t){return[t,t+ft]})):Me(this,"startsWithAnyOf() only works with strings")},_e);function _e(){}function Ke(e){return de(function(t){return Ut(t),e(t.target.error),!1})}function Ut(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Gt="storagemutated",Hn="x-storagemutated-1",tt=Ft(null,Gt),Oi=(Ue.prototype._lock=function(){return Z(!V.global),++this._reculock,this._reculock!==1||V.global||(V.lockOwnerFor=this),this},Ue.prototype._unlock=function(){if(Z(!V.global),--this._reculock==0)for(V.global||(V.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{lt(e[1],e[0])}catch{}}return this},Ue.prototype._locked=function(){return this._reculock&&V.lockOwnerFor!==this},Ue.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,i=this.db._state.dbOpenError;if(Z(!this.idbtrans),!e&&!n)switch(i&&i.name){case"DatabaseClosedError":throw new X.DatabaseClosed(i);case"MissingAPIError":throw new X.MissingAPI(i.message,i);default:throw new X.OpenFailed(i)}if(!this.active)throw new X.TransactionInactive;return Z(this._completion._state===null),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=de(function(o){Ut(o),t._reject(e.error)}),e.onabort=de(function(o){Ut(o),t.active&&t._reject(new X.Abort(e.error)),t.active=!1,t.on("abort").fire(o)}),e.oncomplete=de(function(){t.active=!1,t._resolve(),"mutatedParts"in e&&tt.storagemutated.fire(e.mutatedParts)}),this},Ue.prototype._promise=function(e,t,n){var i=this;if(e==="readwrite"&&this.mode!=="readwrite")return ye(new X.ReadOnly("Transaction is readonly"));if(!this.active)return ye(new X.TransactionInactive);if(this._locked())return new G(function(f,d){i._blockedFuncs.push([function(){i._promise(e,t,n).then(f,d)},V])});if(n)return $e(function(){var f=new G(function(d,m){i._lock();var v=t(d,m,i);v&&v.then&&v.then(d,m)});return f.finally(function(){return i._unlock()}),f._lib=!0,f});var o=new G(function(f,d){var m=t(f,d,i);m&&m.then&&m.then(f,d)});return o._lib=!0,o},Ue.prototype._root=function(){return this.parent?this.parent._root():this},Ue.prototype.waitFor=function(e){var t,n=this._root(),i=G.resolve(e);n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return i}):(n._waitingFor=i,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function f(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=f)}());var o=n._waitingFor;return new G(function(f,d){i.then(function(m){return n._waitingQueue.push(de(f.bind(null,m)))},function(m){return n._waitingQueue.push(de(d.bind(null,m)))}).finally(function(){n._waitingFor===o&&(n._waitingFor=null)})})},Ue.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new X.Abort))},Ue.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(_(t,e))return t[e];var n=this.schema[e];if(!n)throw new X.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},Ue);function Ue(){}function zn(e,t,n,i,o,f,d){return{name:e,keyPath:t,unique:n,multi:i,auto:o,compound:f,src:(n&&!d?"&":"")+(i?"*":"")+(o?"++":"")+jr(t)}}function jr(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Vn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(i=function(o){return[o.name,o]},n.reduce(function(o,f,d){return d=i(f,d),d&&(o[d[0]]=d[1]),o},{}))};var i}var qt=function(e){try{return e.only([[]]),qt=function(){return[[]]},[[]]}catch{return qt=function(){return ft},ft}};function Xn(e){return e==null?function(){}:typeof e=="string"?(t=e).split(".").length===1?function(n){return n[t]}:function(n){return ve(n,t)}:function(n){return ve(n,e)};var t}function Kr(e){return[].slice.call(e)}var Ci=0;function Ht(e){return e==null?":id":typeof e=="string"?e:"[".concat(e.join("+"),"]")}function Pi(e,t,v){function i(A){if(A.type===3)return null;if(A.type===4)throw new Error("Cannot convert never type to IDBKeyRange");var b=A.lower,T=A.upper,R=A.lowerOpen,A=A.upperOpen;return b===void 0?T===void 0?null:t.upperBound(T,!!A):T===void 0?t.lowerBound(b,!!R):t.bound(b,T,!!R,!!A)}function o(k){var b,T=k.name;return{name:T,schema:k,mutate:function(R){var A=R.trans,M=R.type,O=R.keys,C=R.values,I=R.range;return new Promise(function(N,K){N=de(N);var B=A.objectStore(T),F=B.keyPath==null,U=M==="put"||M==="add";if(!U&&M!=="delete"&&M!=="deleteRange")throw new Error("Invalid operation type: "+M);var j,H=(O||C||{length:1}).length;if(O&&C&&O.length!==C.length)throw new Error("Given keys array must have same length as given values array.");if(H===0)return N({numFailures:0,failures:{},results:[],lastResult:void 0});function J(Ee){++Oe,Ut(Ee)}var te=[],ne=[],Oe=0;if(M==="deleteRange"){if(I.type===4)return N({numFailures:Oe,failures:ne,results:[],lastResult:void 0});I.type===3?te.push(j=B.clear()):te.push(j=B.delete(i(I)))}else{var F=U?F?[C,O]:[C,null]:[O,null],Q=F[0],Te=F[1];if(U)for(var Se=0;Se<H;++Se)te.push(j=Te&&Te[Se]!==void 0?B[M](Q[Se],Te[Se]):B[M](Q[Se])),j.onerror=J;else for(Se=0;Se<H;++Se)te.push(j=B[M](Q[Se])),j.onerror=J}function xn(Ee){Ee=Ee.target.result,te.forEach(function(mt,fr){return mt.error!=null&&(ne[fr]=mt.error)}),N({numFailures:Oe,failures:ne,results:M==="delete"?O:te.map(function(mt){return mt.result}),lastResult:Ee})}j.onerror=function(Ee){J(Ee),xn(Ee)},j.onsuccess=xn})},getMany:function(R){var A=R.trans,M=R.keys;return new Promise(function(O,C){O=de(O);for(var I,N=A.objectStore(T),K=M.length,B=new Array(K),F=0,U=0,j=function(te){te=te.target,B[te._pos]=te.result,++U===F&&O(B)},H=Ke(C),J=0;J<K;++J)M[J]!=null&&((I=N.get(M[J]))._pos=J,I.onsuccess=j,I.onerror=H,++F);F===0&&O(B)})},get:function(R){var A=R.trans,M=R.key;return new Promise(function(O,C){O=de(O);var I=A.objectStore(T).get(M);I.onsuccess=function(N){return O(N.target.result)},I.onerror=Ke(C)})},query:(b=w,function(R){return new Promise(function(A,M){A=de(A);var O,C,I,F=R.trans,N=R.values,K=R.limit,j=R.query,B=K===1/0?void 0:K,U=j.index,j=j.range,F=F.objectStore(T),U=U.isPrimaryKey?F:F.index(U.name),j=i(j);if(K===0)return A({result:[]});b?((B=N?U.getAll(j,B):U.getAllKeys(j,B)).onsuccess=function(H){return A({result:H.target.result})},B.onerror=Ke(M)):(O=0,C=!N&&"openKeyCursor"in U?U.openKeyCursor(j):U.openCursor(j),I=[],C.onsuccess=function(H){var J=C.result;return J?(I.push(N?J.value:J.primaryKey),++O===K?A({result:I}):void J.continue()):A({result:I})},C.onerror=Ke(M))})}),openCursor:function(R){var A=R.trans,M=R.values,O=R.query,C=R.reverse,I=R.unique;return new Promise(function(N,K){N=de(N);var U=O.index,B=O.range,F=A.objectStore(T),F=U.isPrimaryKey?F:F.index(U.name),U=C?I?"prevunique":"prev":I?"nextunique":"next",j=!M&&"openKeyCursor"in F?F.openKeyCursor(i(B),U):F.openCursor(i(B),U);j.onerror=Ke(K),j.onsuccess=de(function(H){var J,te,ne,Oe,Q=j.result;Q?(Q.___id=++Ci,Q.done=!1,J=Q.continue.bind(Q),te=(te=Q.continuePrimaryKey)&&te.bind(Q),ne=Q.advance.bind(Q),Oe=function(){throw new Error("Cursor not stopped")},Q.trans=A,Q.stop=Q.continue=Q.continuePrimaryKey=Q.advance=function(){throw new Error("Cursor not started")},Q.fail=de(K),Q.next=function(){var Te=this,Se=1;return this.start(function(){return Se--?Te.continue():Te.stop()}).then(function(){return Te})},Q.start=function(Te){function Se(){if(j.result)try{Te()}catch(Ee){Q.fail(Ee)}else Q.done=!0,Q.start=function(){throw new Error("Cursor behind last entry")},Q.stop()}var xn=new Promise(function(Ee,mt){Ee=de(Ee),j.onerror=Ke(mt),Q.fail=mt,Q.stop=function(fr){Q.stop=Q.continue=Q.continuePrimaryKey=Q.advance=Oe,Ee(fr)}});return j.onsuccess=de(function(Ee){j.onsuccess=Se,Se()}),Q.continue=J,Q.continuePrimaryKey=te,Q.advance=ne,Se(),xn},N(Q)):N(null)},K)})},count:function(R){var A=R.query,M=R.trans,O=A.index,C=A.range;return new Promise(function(I,N){var K=M.objectStore(T),B=O.isPrimaryKey?K:K.index(O.name),K=i(C),B=K?B.count(K):B.count();B.onsuccess=de(function(F){return I(F.target.result)}),B.onerror=Ke(N)})}}}var f,d,m,S=(d=v,m=Kr((f=e).objectStoreNames),{schema:{name:f.name,tables:m.map(function(k){return d.objectStore(k)}).map(function(k){var b=k.keyPath,A=k.autoIncrement,T=p(b),R={},A={name:k.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:b==null,compound:T,keyPath:b,autoIncrement:A,unique:!0,extractKey:Xn(b)},indexes:Kr(k.indexNames).map(function(M){return k.index(M)}).map(function(I){var O=I.name,C=I.unique,N=I.multiEntry,I=I.keyPath,N={name:O,compound:p(I),keyPath:I,unique:C,multiEntry:N,extractKey:Xn(I)};return R[Ht(I)]=N}),getIndexByKeyPath:function(M){return R[Ht(M)]}};return R[":id"]=A.primaryKey,b!=null&&(R[Ht(b)]=A.primaryKey),A})},hasGetAll:0<m.length&&"getAll"in d.objectStore(m[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),v=S.schema,w=S.hasGetAll,S=v.tables.map(o),g={};return S.forEach(function(k){return g[k.name]=k}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(k){if(!g[k])throw new Error("Table '".concat(k,"' not found"));return g[k]},MIN_KEY:-1/0,MAX_KEY:qt(t),schema:v}}function Li(e,t,n,i){var o=n.IDBKeyRange;return n.indexedDB,{dbcore:(i=Pi(t,o,i),e.dbcore.reduce(function(f,d){return d=d.create,a(a({},f),d(f))},i))}}function fn(e,i){var n=i.db,i=Li(e._middlewares,n,e._deps,i);e.core=i.dbcore,e.tables.forEach(function(o){var f=o.name;e.core.schema.tables.some(function(d){return d.name===f})&&(o.core=e.core.table(f),e[f]instanceof e.Table&&(e[f].core=o.core))})}function hn(e,t,n,i){n.forEach(function(o){var f=i[o];t.forEach(function(d){var m=function v(w,S){return z(w,S)||(w=y(w))&&v(w,S)}(d,o);(!m||"value"in m&&m.value===void 0)&&(d===e.Transaction.prototype||d instanceof e.Transaction?q(d,o,{get:function(){return this.table(o)},set:function(v){D(this,o,{value:v,writable:!0,configurable:!0,enumerable:!0})}}):d[o]=new e.Table(o,f))})})}function Wn(e,t){t.forEach(function(n){for(var i in n)n[i]instanceof e.Table&&delete n[i]})}function Ii(e,t){return e._cfg.version-t._cfg.version}function Di(e,t,n,i){var o=e._dbSchema;n.objectStoreNames.contains("$meta")&&!o.$meta&&(o.$meta=Vn("$meta",Gr("")[0],[]),e._storeNames.push("$meta"));var f=e._createTransaction("readwrite",e._storeNames,o);f.create(n),f._completion.catch(i);var d=f._reject.bind(f),m=V.transless||V;$e(function(){return V.trans=f,V.transless=m,t!==0?(fn(e,n),w=t,((v=f).storeNames.includes("$meta")?v.table("$meta").get("version").then(function(S){return S??w}):G.resolve(w)).then(function(S){return k=S,b=f,T=n,R=[],S=(g=e)._versions,A=g._dbSchema=pn(0,g.idbdb,T),(S=S.filter(function(M){return M._cfg.version>=k})).length!==0?(S.forEach(function(M){R.push(function(){var O=A,C=M._cfg.dbschema;mn(g,O,T),mn(g,C,T),A=g._dbSchema=C;var I=Yn(O,C);I.add.forEach(function(U){Qn(T,U[0],U[1].primKey,U[1].indexes)}),I.change.forEach(function(U){if(U.recreate)throw new X.Upgrade("Not yet support for changing primary key");var j=T.objectStore(U.name);U.add.forEach(function(H){return dn(j,H)}),U.change.forEach(function(H){j.deleteIndex(H.name),dn(j,H)}),U.del.forEach(function(H){return j.deleteIndex(H)})});var N=M._cfg.contentUpgrade;if(N&&M._cfg.version>k){fn(g,T),b._memoizedTables={};var K=Be(C);I.del.forEach(function(U){K[U]=O[U]}),Wn(g,[g.Transaction.prototype]),hn(g,[g.Transaction.prototype],l(K),K),b.schema=K;var B,F=Pt(N);return F&&Et(),I=G.follow(function(){var U;(B=N(b))&&F&&(U=Je.bind(null,null),B.then(U,U))}),B&&typeof B.then=="function"?G.resolve(B):I.then(function(){return B})}}),R.push(function(O){var C,I,N=M._cfg.dbschema;C=N,I=O,[].slice.call(I.db.objectStoreNames).forEach(function(K){return C[K]==null&&I.db.deleteObjectStore(K)}),Wn(g,[g.Transaction.prototype]),hn(g,[g.Transaction.prototype],g._storeNames,g._dbSchema),b.schema=g._dbSchema}),R.push(function(O){g.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(g.idbdb.version/10)===M._cfg.version?(g.idbdb.deleteObjectStore("$meta"),delete g._dbSchema.$meta,g._storeNames=g._storeNames.filter(function(C){return C!=="$meta"})):O.objectStore("$meta").put(M._cfg.version,"version"))})}),function M(){return R.length?G.resolve(R.shift()(b.idbtrans)).then(M):G.resolve()}().then(function(){Ur(A,T)})):G.resolve();var g,k,b,T,R,A}).catch(d)):(l(o).forEach(function(S){Qn(n,S,o[S].primKey,o[S].indexes)}),fn(e,n),void G.follow(function(){return e.on.populate.fire(f)}).catch(d));var v,w})}function Ni(e,t){Ur(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=pn(0,e.idbdb,t);mn(e,e._dbSchema,t);for(var i=0,o=Yn(n,e._dbSchema).change;i<o.length;i++){var f=function(d){if(d.change.length||d.recreate)return console.warn("Unable to patch indexes of table ".concat(d.name," because it has changes on the type of index or primary key.")),{value:void 0};var m=t.objectStore(d.name);d.add.forEach(function(v){je&&console.debug("Dexie upgrade patch: Creating missing index ".concat(d.name,".").concat(v.src)),dn(m,v)})}(o[i]);if(typeof f=="object")return f.value}}function Yn(e,t){var n,i={del:[],add:[],change:[]};for(n in e)t[n]||i.del.push(n);for(n in t){var o=e[n],f=t[n];if(o){var d={name:n,def:f,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(f.primKey.keyPath||"")||o.primKey.auto!==f.primKey.auto)d.recreate=!0,i.change.push(d);else{var m=o.idxByName,v=f.idxByName,w=void 0;for(w in m)v[w]||d.del.push(w);for(w in v){var S=m[w],g=v[w];S?S.src!==g.src&&d.change.push(g):d.add.push(g)}(0<d.del.length||0<d.add.length||0<d.change.length)&&i.change.push(d)}}else i.add.push([n,f])}return i}function Qn(e,t,n,i){var o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return i.forEach(function(f){return dn(o,f)}),o}function Ur(e,t){l(e).forEach(function(n){t.db.objectStoreNames.contains(n)||(je&&console.debug("Dexie: Creating missing table",n),Qn(t,n,e[n].primKey,e[n].indexes))})}function dn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function pn(e,t,n){var i={};return ee(t.objectStoreNames,0).forEach(function(o){for(var f=n.objectStore(o),d=zn(jr(w=f.keyPath),w||"",!0,!1,!!f.autoIncrement,w&&typeof w!="string",!0),m=[],v=0;v<f.indexNames.length;++v){var S=f.index(f.indexNames[v]),w=S.keyPath,S=zn(S.name,w,!!S.unique,!!S.multiEntry,!1,w&&typeof w!="string",!1);m.push(S)}i[o]=Vn(o,d,m)}),i}function mn(e,t,n){for(var i=n.db.objectStoreNames,o=0;o<i.length;++o){var f=i[o],d=n.objectStore(f);e._hasGetAll="getAll"in d;for(var m=0;m<d.indexNames.length;++m){var v=d.indexNames[m],w=d.index(v).keyPath,S=typeof w=="string"?w:"["+ee(w).join("+")+"]";!t[f]||(w=t[f].idxByName[S])&&(w.name=v,delete t[f].idxByName[S],t[f].idxByName[v]=w)}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&c.WorkerGlobalScope&&c instanceof c.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function Gr(e){return e.split(",").map(function(t,n){var i=(t=t.trim()).replace(/([&*]|\+\+)/g,""),o=/^\[/.test(i)?i.match(/^\[(.*)\]$/)[1].split("+"):i;return zn(i,o||null,/\&/.test(t),/\*/.test(t),/\+\+/.test(t),p(o),n===0)})}var Bi=(yn.prototype._parseStoresSpec=function(e,t){l(e).forEach(function(n){if(e[n]!==null){var i=Gr(e[n]),o=i.shift();if(o.unique=!0,o.multi)throw new X.Schema("Primary key cannot be multi-valued");i.forEach(function(f){if(f.auto)throw new X.Schema("Only primary key can be marked as autoIncrement (++)");if(!f.keyPath)throw new X.Schema("Index must have a name and cannot be an empty string")}),t[n]=Vn(n,o,i)}})},yn.prototype.stores=function(n){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?h(this._cfg.storesSource,n):n;var n=t._versions,i={},o={};return n.forEach(function(f){h(i,f._cfg.storesSource),o=f._cfg.dbschema={},f._parseStoresSpec(i,o)}),t._dbSchema=o,Wn(t,[t._allTables,t,t.Transaction.prototype]),hn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],l(o),o),t._storeNames=l(o),this},yn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=On(this._cfg.contentUpgrade||ce,e),this},yn);function yn(){}function $n(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new Ve(on,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Jn(e){return e&&typeof e.databases=="function"}function Zn(e){return $e(function(){return V.letThrough=!0,e()})}function er(e){return!("from"in e)}var xe=function(e,t){if(!this){var n=new xe;return e&&"d"in e&&h(n,e),n}h(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function zt(e,t,n){var i=ie(t,n);if(!isNaN(i)){if(0<i)throw RangeError();if(er(e))return h(e,{from:t,to:n,d:1});var o=e.l,i=e.r;if(ie(n,e.from)<0)return o?zt(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Hr(e);if(0<ie(t,e.to))return i?zt(i,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Hr(e);ie(t,e.from)<0&&(e.from=t,e.l=null,e.d=i?i.d+1:1),0<ie(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1),n=!e.r,o&&!e.l&&Vt(e,o),i&&n&&Vt(e,i)}}function Vt(e,t){er(t)||function n(i,v){var f=v.from,d=v.to,m=v.l,v=v.r;zt(i,f,d),m&&n(i,m),v&&n(i,v)}(e,t)}function qr(e,t){var n=gn(t),i=n.next();if(i.done)return!1;for(var o=i.value,f=gn(e),d=f.next(o.from),m=d.value;!i.done&&!d.done;){if(ie(m.from,o.to)<=0&&0<=ie(m.to,o.from))return!0;ie(o.from,m.from)<0?o=(i=n.next(m.from)).value:m=(d=f.next(o.from)).value}return!1}function gn(e){var t=er(e)?null:{s:0,n:e};return{next:function(n){for(var i=0<arguments.length;t;)switch(t.s){case 0:if(t.s=1,i)for(;t.n.l&&ie(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,!i||ie(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 Hr(e){var t,n,i=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((n=e.l)===null||n===void 0?void 0:n.d)||0),o=1<i?"r":i<-1?"l":"";o&&(t=o=="r"?"l":"r",n=a({},e),i=e[o],e.from=i.from,e.to=i.to,e[o]=i[o],n[o]=i[t],(e[t]=n).d=zr(n)),e.d=zr(e)}function zr(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 vn(e,t){return l(t).forEach(function(n){e[n]?Vt(e[n],t[n]):e[n]=function i(o){var f,d,m={};for(f in o)_(o,f)&&(d=o[f],m[f]=!d||typeof d!="object"||Ie.has(d.constructor)?d:i(d));return m}(t[n])}),e}function tr(e,t){return e.all||t.all||Object.keys(e).some(function(n){return t[n]&&qr(t[n],e[n])})}P(xe.prototype,((Pe={add:function(e){return Vt(this,e),this},addKey:function(e){return zt(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(n){return zt(t,n,n)}),this},hasKey:function(e){var t=gn(this).next(e).value;return t&&ie(t.from,e)<=0&&0<=ie(t.to,e)}})[At]=function(){return gn(this)},Pe));var dt={},nr={},rr=!1;function bn(e){vn(nr,e),rr||(rr=!0,setTimeout(function(){rr=!1,ir(nr,!(nr={}))},0))}function ir(e,t){t===void 0&&(t=!1);var n=new Set;if(e.all)for(var i=0,o=Object.values(dt);i<o.length;i++)Vr(d=o[i],e,n,t);else for(var f in e){var d,m=/^idb\:\/\/(.*)\/(.*)\//.exec(f);m&&(f=m[1],m=m[2],(d=dt["idb://".concat(f,"/").concat(m)])&&Vr(d,e,n,t))}n.forEach(function(v){return v()})}function Vr(e,t,n,i){for(var o=[],f=0,d=Object.entries(e.queries.query);f<d.length;f++){for(var m=d[f],v=m[0],w=[],S=0,g=m[1];S<g.length;S++){var k=g[S];tr(t,k.obsSet)?k.subscribers.forEach(function(A){return n.add(A)}):i&&w.push(k)}i&&o.push([v,w])}if(i)for(var b=0,T=o;b<T.length;b++){var R=T[b],v=R[0],w=R[1];e.queries.query[v]=w}}function Fi(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(function(){return t.dbOpenError?ye(t.dbOpenError):e});t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var i=t.openCanceller,o=Math.round(10*e.verno),f=!1;function d(){if(t.openCanceller!==i)throw new X.DatabaseClosed("db.open() was cancelled")}function m(){return new G(function(k,b){if(d(),!n)throw new X.MissingAPI;var T=e.name,R=t.autoSchema||!o?n.open(T):n.open(T,o);if(!R)throw new X.MissingAPI;R.onerror=Ke(b),R.onblocked=de(e._fireOnBlocked),R.onupgradeneeded=de(function(A){var M;S=R.transaction,t.autoSchema&&!e._options.allowEmptyDB?(R.onerror=Ut,S.abort(),R.result.close(),(M=n.deleteDatabase(T)).onsuccess=M.onerror=de(function(){b(new X.NoSuchDatabase("Database ".concat(T," doesnt exist")))})):(S.onerror=Ke(b),A=A.oldVersion>Math.pow(2,62)?0:A.oldVersion,g=A<1,e.idbdb=R.result,f&&Ni(e,S),Di(e,A/10,S,b))},b),R.onsuccess=de(function(){S=null;var A,M,O,C,I,N=e.idbdb=R.result,K=ee(N.objectStoreNames);if(0<K.length)try{var B=N.transaction((C=K).length===1?C[0]:C,"readonly");if(t.autoSchema)M=N,O=B,(A=e).verno=M.version/10,O=A._dbSchema=pn(0,M,O),A._storeNames=ee(M.objectStoreNames,0),hn(A,[A._allTables],l(O),O);else if(mn(e,e._dbSchema,B),((I=Yn(pn(0,(I=e).idbdb,B),I._dbSchema)).add.length||I.change.some(function(F){return F.add.length||F.change.length}))&&!f)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."),N.close(),o=N.version+1,f=!0,k(m());fn(e,B)}catch{}Rt.push(e),N.onversionchange=de(function(F){t.vcFired=!0,e.on("versionchange").fire(F)}),N.onclose=de(function(F){e.on("close").fire(F)}),g&&(I=e._deps,B=T,N=I.indexedDB,I=I.IDBKeyRange,Jn(N)||B===on||$n(N,I).put({name:B}).catch(ce)),k()},b)}).catch(function(k){switch(k==null?void 0:k.name){case"UnknownError":if(0<t.PR1398_maxLoop)return t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),m();break;case"VersionError":if(0<o)return o=0,m()}return G.reject(k)})}var v,w=t.dbReadyResolve,S=null,g=!1;return G.race([i,(typeof navigator>"u"?G.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(k){function b(){return indexedDB.databases().finally(k)}v=setInterval(b,100),b()}).finally(function(){return clearInterval(v)}):Promise.resolve()).then(m)]).then(function(){return d(),t.onReadyBeingFired=[],G.resolve(Zn(function(){return e.on.ready.fire(e.vip)})).then(function k(){if(0<t.onReadyBeingFired.length){var b=t.onReadyBeingFired.reduce(On,ce);return t.onReadyBeingFired=[],G.resolve(Zn(function(){return b(e.vip)})).then(k)}})}).finally(function(){t.openCanceller===i&&(t.onReadyBeingFired=null,t.isBeingOpened=!1)}).catch(function(k){t.dbOpenError=k;try{S&&S.abort()}catch{}return i===t.openCanceller&&e._close(),ye(k)}).finally(function(){t.openComplete=!0,w()}).then(function(){var k;return g&&(k={},e.tables.forEach(function(b){b.schema.indexes.forEach(function(T){T.name&&(k["idb://".concat(e.name,"/").concat(b.name,"/").concat(T.name)]=new xe(-1/0,[[[]]]))}),k["idb://".concat(e.name,"/").concat(b.name,"/")]=k["idb://".concat(e.name,"/").concat(b.name,"/:dels")]=new xe(-1/0,[[[]]])}),tt(Gt).fire(k),ir(k,!0)),e})}function sr(e){function t(f){return e.next(f)}var n=o(t),i=o(function(f){return e.throw(f)});function o(f){return function(v){var m=f(v),v=m.value;return m.done?v:v&&typeof v.then=="function"?v.then(n,i):p(v)?Promise.all(v).then(n,i):n(v)}}return o(t)()}function wn(e,t,n){for(var i=p(e)?e.slice():[e],o=0;o<n;++o)i.push(t);return i}var ji={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return a(a({},e),{table:function(t){var n=e.table(t),i=n.schema,o={},f=[];function d(g,k,b){var T=Ht(g),R=o[T]=o[T]||[],A=g==null?0:typeof g=="string"?1:g.length,M=0<k,M=a(a({},b),{name:M?"".concat(T,"(virtual-from:").concat(b.name,")"):b.name,lowLevelIndex:b,isVirtual:M,keyTail:k,keyLength:A,extractKey:Xn(g),unique:!M&&b.unique});return R.push(M),M.isPrimaryKey||f.push(M),1<A&&d(A===2?g[0]:g.slice(0,A-1),k+1,b),R.sort(function(O,C){return O.keyTail-C.keyTail}),M}t=d(i.primaryKey.keyPath,0,i.primaryKey),o[":id"]=[t];for(var m=0,v=i.indexes;m<v.length;m++){var w=v[m];d(w.keyPath,0,w)}function S(g){var k,b=g.query.index;return b.isVirtual?a(a({},g),{query:{index:b.lowLevelIndex,range:(k=g.query.range,b=b.keyTail,{type:k.type===1?2:k.type,lower:wn(k.lower,k.lowerOpen?e.MAX_KEY:e.MIN_KEY,b),lowerOpen:!0,upper:wn(k.upper,k.upperOpen?e.MIN_KEY:e.MAX_KEY,b),upperOpen:!0})}}):g}return a(a({},n),{schema:a(a({},i),{primaryKey:t,indexes:f,getIndexByKeyPath:function(g){return(g=o[Ht(g)])&&g[0]}}),count:function(g){return n.count(S(g))},query:function(g){return n.query(S(g))},openCursor:function(g){var k=g.query.index,b=k.keyTail,T=k.isVirtual,R=k.keyLength;return T?n.openCursor(S(g)).then(function(M){return M&&A(M)}):n.openCursor(g);function A(M){return Object.create(M,{continue:{value:function(O){O!=null?M.continue(wn(O,g.reverse?e.MAX_KEY:e.MIN_KEY,b)):g.unique?M.continue(M.key.slice(0,R).concat(g.reverse?e.MIN_KEY:e.MAX_KEY,b)):M.continue()}},continuePrimaryKey:{value:function(O,C){M.continuePrimaryKey(wn(O,e.MAX_KEY,b),C)}},primaryKey:{get:function(){return M.primaryKey}},key:{get:function(){var O=M.key;return R===1?O[0]:O.slice(0,R)}},value:{get:function(){return M.value}}})}}})}})}};function or(e,t,n,i){return n=n||{},i=i||"",l(e).forEach(function(o){var f,d,m;_(t,o)?(f=e[o],d=t[o],typeof f=="object"&&typeof d=="object"&&f&&d?(m=_t(f))!==_t(d)?n[i+o]=t[o]:m==="Object"?or(f,d,n,i+o+"."):f!==d&&(n[i+o]=t[o]):f!==d&&(n[i+o]=t[o])):n[i+o]=void 0}),l(t).forEach(function(o){_(e,o)||(n[i+o]=t[o])}),n}function ar(e,t){return t.type==="delete"?t.keys:t.keys||t.values.map(e.extractKey)}var Ki={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return a(a({},e),{table:function(t){var n=e.table(t),i=n.schema.primaryKey;return a(a({},n),{mutate:function(o){var f=V.trans,d=f.table(t).hook,m=d.deleting,v=d.creating,w=d.updating;switch(o.type){case"add":if(v.fire===ce)break;return f._promise("readwrite",function(){return S(o)},!0);case"put":if(v.fire===ce&&w.fire===ce)break;return f._promise("readwrite",function(){return S(o)},!0);case"delete":if(m.fire===ce)break;return f._promise("readwrite",function(){return S(o)},!0);case"deleteRange":if(m.fire===ce)break;return f._promise("readwrite",function(){return function g(k,b,T){return n.query({trans:k,values:!1,query:{index:i,range:b},limit:T}).then(function(R){var A=R.result;return S({type:"delete",keys:A,trans:k}).then(function(M){return 0<M.numFailures?Promise.reject(M.failures[0]):A.length<T?{failures:[],numFailures:0,lastResult:void 0}:g(k,a(a({},b),{lower:A[A.length-1],lowerOpen:!0}),T)})})}(o.trans,o.range,1e4)},!0)}return n.mutate(o);function S(g){var k,b,T,R=V.trans,A=g.keys||ar(i,g);if(!A)throw new Error("Keys missing");return(g=g.type==="add"||g.type==="put"?a(a({},g),{keys:A}):a({},g)).type!=="delete"&&(g.values=u([],g.values)),g.keys&&(g.keys=u([],g.keys)),k=n,T=A,((b=g).type==="add"?Promise.resolve([]):k.getMany({trans:b.trans,keys:T,cache:"immutable"})).then(function(M){var O=A.map(function(C,I){var N,K,B,F=M[I],U={onerror:null,onsuccess:null};return g.type==="delete"?m.fire.call(U,C,F,R):g.type==="add"||F===void 0?(N=v.fire.call(U,C,g.values[I],R),C==null&&N!=null&&(g.keys[I]=C=N,i.outbound||le(g.values[I],i.keyPath,C))):(N=or(F,g.values[I]),(K=w.fire.call(U,N,C,F,R))&&(B=g.values[I],Object.keys(K).forEach(function(j){_(B,j)?B[j]=K[j]:le(B,j,K[j])}))),U});return n.mutate(g).then(function(C){for(var I=C.failures,N=C.results,K=C.numFailures,C=C.lastResult,B=0;B<A.length;++B){var F=(N||A)[B],U=O[B];F==null?U.onerror&&U.onerror(I[B]):U.onsuccess&&U.onsuccess(g.type==="put"&&M[B]?g.values[B]:F)}return{failures:I,results:N,numFailures:K,lastResult:C}}).catch(function(C){return O.forEach(function(I){return I.onerror&&I.onerror(C)}),Promise.reject(C)})})}}})}})}};function Xr(e,t,n){try{if(!t||t.keys.length<e.length)return null;for(var i=[],o=0,f=0;o<t.keys.length&&f<e.length;++o)ie(t.keys[o],e[f])===0&&(i.push(n?ke(t.values[o]):t.values[o]),++f);return i.length===e.length?i:null}catch{return null}}var Ui={stack:"dbcore",level:-1,create:function(e){return{table:function(t){var n=e.table(t);return a(a({},n),{getMany:function(i){if(!i.cache)return n.getMany(i);var o=Xr(i.keys,i.trans._cache,i.cache==="clone");return o?G.resolve(o):n.getMany(i).then(function(f){return i.trans._cache={keys:i.keys,values:i.cache==="clone"?ke(f):f},f})},mutate:function(i){return i.type!=="add"&&(i.trans._cache=null),n.mutate(i)}})}}}};function Wr(e,t){return e.trans.mode==="readonly"&&!!e.subscr&&!e.trans.explicit&&e.trans.db._options.cache!=="disabled"&&!t.schema.primaryKey.outbound}function Yr(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Gi={stack:"dbcore",level:0,name:"Observability",create:function(e){var t=e.schema.name,n=new xe(e.MIN_KEY,e.MAX_KEY);return a(a({},e),{transaction:function(i,o,f){if(V.subscr&&o!=="readonly")throw new X.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(V.querier));return e.transaction(i,o,f)},table:function(i){var o=e.table(i),f=o.schema,d=f.primaryKey,g=f.indexes,m=d.extractKey,v=d.outbound,w=d.autoIncrement&&g.filter(function(b){return b.compound&&b.keyPath.includes(d.keyPath)}),S=a(a({},o),{mutate:function(b){function T(j){return j="idb://".concat(t,"/").concat(i,"/").concat(j),C[j]||(C[j]=new xe)}var R,A,M,O=b.trans,C=b.mutatedParts||(b.mutatedParts={}),I=T(""),N=T(":dels"),K=b.type,U=b.type==="deleteRange"?[b.range]:b.type==="delete"?[b.keys]:b.values.length<50?[ar(d,b).filter(function(j){return j}),b.values]:[],B=U[0],F=U[1],U=b.trans._cache;return p(B)?(I.addKeys(B),(U=K==="delete"||B.length===F.length?Xr(B,U):null)||N.addKeys(B),(U||F)&&(R=T,A=U,M=F,f.indexes.forEach(function(j){var H=R(j.name||"");function J(ne){return ne!=null?j.extractKey(ne):null}function te(ne){return j.multiEntry&&p(ne)?ne.forEach(function(Oe){return H.addKey(Oe)}):H.addKey(ne)}(A||M).forEach(function(ne,Te){var Q=A&&J(A[Te]),Te=M&&J(M[Te]);ie(Q,Te)!==0&&(Q!=null&&te(Q),Te!=null&&te(Te))})}))):B?(F={from:(F=B.lower)!==null&&F!==void 0?F:e.MIN_KEY,to:(F=B.upper)!==null&&F!==void 0?F:e.MAX_KEY},N.add(F),I.add(F)):(I.add(n),N.add(n),f.indexes.forEach(function(j){return T(j.name).add(n)})),o.mutate(b).then(function(j){return!B||b.type!=="add"&&b.type!=="put"||(I.addKeys(j.results),w&&w.forEach(function(H){for(var J=b.values.map(function(Q){return H.extractKey(Q)}),te=H.keyPath.findIndex(function(Q){return Q===d.keyPath}),ne=0,Oe=j.results.length;ne<Oe;++ne)J[ne][te]=j.results[ne];T(H.name).addKeys(J)})),O.mutatedParts=vn(O.mutatedParts||{},C),j})}}),g=function(T){var R=T.query,T=R.index,R=R.range;return[T,new xe((T=R.lower)!==null&&T!==void 0?T:e.MIN_KEY,(R=R.upper)!==null&&R!==void 0?R:e.MAX_KEY)]},k={get:function(b){return[d,new xe(b.key)]},getMany:function(b){return[d,new xe().addKeys(b.keys)]},count:g,query:g,openCursor:g};return l(k).forEach(function(b){S[b]=function(T){var R=V.subscr,A=!!R,M=Wr(V,o)&&Yr(b,T)?T.obsSet={}:R;if(A){var O=function(F){return F="idb://".concat(t,"/").concat(i,"/").concat(F),M[F]||(M[F]=new xe)},C=O(""),I=O(":dels"),R=k[b](T),A=R[0],R=R[1];if((b==="query"&&A.isPrimaryKey&&!T.values?I:O(A.name||"")).add(R),!A.isPrimaryKey){if(b!=="count"){var N=b==="query"&&v&&T.values&&o.query(a(a({},T),{values:!1}));return o[b].apply(this,arguments).then(function(F){if(b==="query"){if(v&&T.values)return N.then(function(J){return J=J.result,C.addKeys(J),F});var U=T.values?F.result.map(m):F.result;(T.values?C:I).addKeys(U)}else if(b==="openCursor"){var j=F,H=T.values;return j&&Object.create(j,{key:{get:function(){return I.addKey(j.primaryKey),j.key}},primaryKey:{get:function(){var J=j.primaryKey;return I.addKey(J),J}},value:{get:function(){return H&&C.addKey(j.primaryKey),j.value}}})}return F})}I.add(n)}}return o[b].apply(this,arguments)}}),S}})}};function Qr(e,t,n){if(n.numFailures===0)return t;if(t.type==="deleteRange")return null;var i=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1;return n.numFailures===i?null:(t=a({},t),p(t.keys)&&(t.keys=t.keys.filter(function(o,f){return!(f in n.failures)})),"values"in t&&p(t.values)&&(t.values=t.values.filter(function(o,f){return!(f in n.failures)})),t)}function ur(e,t){return n=e,((i=t).lower===void 0||(i.lowerOpen?0<ie(n,i.lower):0<=ie(n,i.lower)))&&(e=e,(t=t).upper===void 0||(t.upperOpen?ie(e,t.upper)<0:ie(e,t.upper)<=0));var n,i}function $r(e,t,k,i,o,f){if(!k||k.length===0)return e;var d=t.query.index,m=d.multiEntry,v=t.query.range,w=i.schema.primaryKey.extractKey,S=d.extractKey,g=(d.lowLevelIndex||d).extractKey,k=k.reduce(function(b,T){var R=b,A=[];if(T.type==="add"||T.type==="put")for(var M=new xe,O=T.values.length-1;0<=O;--O){var C,I=T.values[O],N=w(I);M.hasKey(N)||(C=S(I),(m&&p(C)?C.some(function(j){return ur(j,v)}):ur(C,v))&&(M.addKey(N),A.push(I)))}switch(T.type){case"add":var K=new xe().addKeys(t.values?b.map(function(H){return w(H)}):b),R=b.concat(t.values?A.filter(function(H){return H=w(H),!K.hasKey(H)&&(K.addKey(H),!0)}):A.map(function(H){return w(H)}).filter(function(H){return!K.hasKey(H)&&(K.addKey(H),!0)}));break;case"put":var B=new xe().addKeys(T.values.map(function(H){return w(H)}));R=b.filter(function(H){return!B.hasKey(t.values?w(H):H)}).concat(t.values?A:A.map(function(H){return w(H)}));break;case"delete":var F=new xe().addKeys(T.keys);R=b.filter(function(H){return!F.hasKey(t.values?w(H):H)});break;case"deleteRange":var U=T.range;R=b.filter(function(H){return!ur(w(H),U)})}return R},e);return k===e?e:(k.sort(function(b,T){return ie(g(b),g(T))||ie(w(b),w(T))}),t.limit&&t.limit<1/0&&(k.length>t.limit?k.length=t.limit:e.length===t.limit&&k.length<t.limit&&(o.dirty=!0)),f?Object.freeze(k):k)}function Jr(e,t){return ie(e.lower,t.lower)===0&&ie(e.upper,t.upper)===0&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function qi(e,t){return function(n,i,o,f){if(n===void 0)return i!==void 0?-1:0;if(i===void 0)return 1;if((i=ie(n,i))===0){if(o&&f)return 0;if(o)return 1;if(f)return-1}return i}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(n,i,o,f){if(n===void 0)return i!==void 0?1:0;if(i===void 0)return-1;if((i=ie(n,i))===0){if(o&&f)return 0;if(o)return-1;if(f)return 1}return i}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function Hi(e,t,n,i){e.subscribers.add(n),i.addEventListener("abort",function(){var o,f;e.subscribers.delete(n),e.subscribers.size===0&&(o=e,f=t,setTimeout(function(){o.subscribers.size===0&&We(f,o)},3e3))})}var zi={stack:"dbcore",level:0,name:"Cache",create:function(e){var t=e.schema.name;return a(a({},e),{transaction:function(n,i,o){var f,d,m=e.transaction(n,i,o);return i==="readwrite"&&(d=(f=new AbortController).signal,o=function(v){return function(){if(f.abort(),i==="readwrite"){for(var w=new Set,S=0,g=n;S<g.length;S++){var k=g[S],b=dt["idb://".concat(t,"/").concat(k)];if(b){var T=e.table(k),R=b.optimisticOps.filter(function(H){return H.trans===m});if(m._explicit&&v&&m.mutatedParts)for(var A=0,M=Object.values(b.queries.query);A<M.length;A++)for(var O=0,C=(K=M[A]).slice();O<C.length;O++)tr((B=C[O]).obsSet,m.mutatedParts)&&(We(K,B),B.subscribers.forEach(function(H){return w.add(H)}));else if(0<R.length){b.optimisticOps=b.optimisticOps.filter(function(H){return H.trans!==m});for(var I=0,N=Object.values(b.queries.query);I<N.length;I++)for(var K,B,F,U=0,j=(K=N[I]).slice();U<j.length;U++)(B=j[U]).res!=null&&m.mutatedParts&&(v&&!B.dirty?(F=Object.isFrozen(B.res),F=$r(B.res,B.req,R,T,B,F),B.dirty?(We(K,B),B.subscribers.forEach(function(H){return w.add(H)})):F!==B.res&&(B.res=F,B.promise=G.resolve({result:F}))):(B.dirty&&We(K,B),B.subscribers.forEach(function(H){return w.add(H)})))}}}w.forEach(function(H){return H()})}}},m.addEventListener("abort",o(!1),{signal:d}),m.addEventListener("error",o(!1),{signal:d}),m.addEventListener("complete",o(!0),{signal:d})),m},table:function(n){var i=e.table(n),o=i.schema.primaryKey;return a(a({},i),{mutate:function(f){var d=V.trans;if(o.outbound||d.db._options.cache==="disabled"||d.explicit||d.idbtrans.mode!=="readwrite")return i.mutate(f);var m=dt["idb://".concat(t,"/").concat(n)];return m?(d=i.mutate(f),f.type!=="add"&&f.type!=="put"||!(50<=f.values.length||ar(o,f).some(function(v){return v==null}))?(m.optimisticOps.push(f),f.mutatedParts&&bn(f.mutatedParts),d.then(function(v){0<v.numFailures&&(We(m.optimisticOps,f),(v=Qr(0,f,v))&&m.optimisticOps.push(v),f.mutatedParts&&bn(f.mutatedParts))}),d.catch(function(){We(m.optimisticOps,f),f.mutatedParts&&bn(f.mutatedParts)})):d.then(function(v){var w=Qr(0,a(a({},f),{values:f.values.map(function(S,g){var k;return v.failures[g]?S:(S=(k=o.keyPath)!==null&&k!==void 0&&k.includes(".")?ke(S):a({},S),le(S,o.keyPath,v.results[g]),S)})}),v);m.optimisticOps.push(w),queueMicrotask(function(){return f.mutatedParts&&bn(f.mutatedParts)})}),d):i.mutate(f)},query:function(f){if(!Wr(V,i)||!Yr("query",f))return i.query(f);var d=((w=V.trans)===null||w===void 0?void 0:w.db._options.cache)==="immutable",g=V,m=g.requery,v=g.signal,w=function(T,R,A,M){var O=dt["idb://".concat(T,"/").concat(R)];if(!O)return[];if(!(R=O.queries[A]))return[null,!1,O,null];var C=R[(M.query?M.query.index.name:null)||""];if(!C)return[null,!1,O,null];switch(A){case"query":var I=C.find(function(N){return N.req.limit===M.limit&&N.req.values===M.values&&Jr(N.req.query.range,M.query.range)});return I?[I,!0,O,C]:[C.find(function(N){return("limit"in N.req?N.req.limit:1/0)>=M.limit&&(!M.values||N.req.values)&&qi(N.req.query.range,M.query.range)}),!1,O,C];case"count":return I=C.find(function(N){return Jr(N.req.query.range,M.query.range)}),[I,!!I,O,C]}}(t,n,"query",f),S=w[0],g=w[1],k=w[2],b=w[3];return S&&g?S.obsSet=f.obsSet:(g=i.query(f).then(function(T){var R=T.result;if(S&&(S.res=R),d){for(var A=0,M=R.length;A<M;++A)Object.freeze(R[A]);Object.freeze(R)}else T.result=ke(R);return T}).catch(function(T){return b&&S&&We(b,S),Promise.reject(T)}),S={obsSet:f.obsSet,promise:g,subscribers:new Set,type:"query",req:f,dirty:!1},b?b.push(S):(b=[S],(k=k||(dt["idb://".concat(t,"/").concat(n)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[f.query.index.name||""]=b)),Hi(S,b,m,v),S.promise.then(function(T){return{result:$r(T.result,f,k==null?void 0:k.optimisticOps,i,S,d)}})}})}})}};function _n(e,t){return new Proxy(e,{get:function(n,i,o){return i==="db"?t:Reflect.get(n,i,o)}})}var Ve=(ge.prototype.version=function(e){if(isNaN(e)||e<.1)throw new X.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new X.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter(function(i){return i._cfg.version===e})[0];return n||(n=new this.Version(e),t.push(n),t.sort(Ii),n.stores({}),this._state.autoSchema=!1,n)},ge.prototype._whenReady=function(e){var t=this;return this.idbdb&&(this._state.openComplete||V.letThrough||this._vip)?e():new G(function(n,i){if(t._state.openComplete)return i(new X.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return void i(new X.DatabaseClosed);t.open().catch(ce)}t._state.dbReadyPromise.then(n,i)}).then(e)},ge.prototype.use=function(e){var t=e.stack,n=e.create,i=e.level,o=e.name;return o&&this.unuse({stack:t,name:o}),e=this._middlewares[t]||(this._middlewares[t]=[]),e.push({stack:t,create:n,level:i??10,name:o}),e.sort(function(f,d){return f.level-d.level}),this},ge.prototype.unuse=function(e){var t=e.stack,n=e.name,i=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(o){return i?o.create!==i:!!n&&o.name!==n})),this},ge.prototype.open=function(){var e=this;return lt(Qe,function(){return Fi(e)})},ge.prototype._close=function(){var e=this._state,t=Rt.indexOf(this);if(0<=t&&Rt.splice(t,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new G(function(n){e.dbReadyResolve=n}),e.openCanceller=new G(function(n,i){e.cancelOpen=i}))},ge.prototype.close=function(n){var t=(n===void 0?{disableAutoOpen:!0}:n).disableAutoOpen,n=this._state;t?(n.isBeingOpened&&n.cancelOpen(new X.DatabaseClosed),this._close(),n.autoOpen=!1,n.dbOpenError=new X.DatabaseClosed):(this._close(),n.autoOpen=this._options.autoOpen||n.isBeingOpened,n.openComplete=!1,n.dbOpenError=null)},ge.prototype.delete=function(e){var t=this;e===void 0&&(e={disableAutoOpen:!0});var n=0<arguments.length&&typeof arguments[0]!="object",i=this._state;return new G(function(o,f){function d(){t.close(e);var m=t._deps.indexedDB.deleteDatabase(t.name);m.onsuccess=de(function(){var v,w,S;v=t._deps,w=t.name,S=v.indexedDB,v=v.IDBKeyRange,Jn(S)||w===on||$n(S,v).delete(w).catch(ce),o()}),m.onerror=Ke(f),m.onblocked=t._fireOnBlocked}if(n)throw new X.InvalidArgument("Invalid closeOptions argument to db.delete()");i.isBeingOpened?i.dbReadyPromise.then(d):d()})},ge.prototype.backendDB=function(){return this.idbdb},ge.prototype.isOpen=function(){return this.idbdb!==null},ge.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"},ge.prototype.hasFailed=function(){return this._state.dbOpenError!==null},ge.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(ge.prototype,"tables",{get:function(){var e=this;return l(this._allTables).map(function(t){return e._allTables[t]})},enumerable:!1,configurable:!0}),ge.prototype.transaction=function(){var e=(function(t,n,i){var o=arguments.length;if(o<2)throw new X.InvalidArgument("Too few arguments");for(var f=new Array(o-1);--o;)f[o-1]=arguments[o];return i=f.pop(),[t,me(f),i]}).apply(this,arguments);return this._transaction.apply(this,e)},ge.prototype._transaction=function(e,t,n){var i=this,o=V.trans;o&&o.db===this&&e.indexOf("!")===-1||(o=null);var f,d,m=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");try{if(d=t.map(function(w){if(w=w instanceof i.Table?w.name:w,typeof w!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return w}),e=="r"||e===jn)f=jn;else{if(e!="rw"&&e!=Kn)throw new X.InvalidArgument("Invalid transaction mode: "+e);f=Kn}if(o){if(o.mode===jn&&f===Kn){if(!m)throw new X.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&d.forEach(function(w){if(o&&o.storeNames.indexOf(w)===-1){if(!m)throw new X.SubTransaction("Table "+w+" not included in parent transaction.");o=null}}),m&&o&&!o.active&&(o=null)}}catch(w){return o?o._promise(null,function(S,g){g(w)}):ye(w)}var v=(function w(S,g,k,b,T){return G.resolve().then(function(){var R=V.transless||V,A=S._createTransaction(g,k,S._dbSchema,b);if(A.explicit=!0,R={trans:A,transless:R},b)A.idbtrans=b.idbtrans;else try{A.create(),A.idbtrans._explicit=!0,S._state.PR1398_maxLoop=3}catch(C){return C.name===Mn.InvalidState&&S.isOpen()&&0<--S._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),S.close({disableAutoOpen:!1}),S.open().then(function(){return w(S,g,k,null,T)})):ye(C)}var M,O=Pt(T);return O&&Et(),R=G.follow(function(){var C;(M=T.call(A,A))&&(O?(C=Je.bind(null,null),M.then(C,C)):typeof M.next=="function"&&typeof M.throw=="function"&&(M=sr(M)))},R),(M&&typeof M.then=="function"?G.resolve(M).then(function(C){return A.active?C:ye(new X.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):R.then(function(){return M})).then(function(C){return b&&A._resolve(),A._completion.then(function(){return C})}).catch(function(C){return A._reject(C),ye(C)})})}).bind(null,this,f,d,o,n);return o?o._promise(f,v,"lock"):V.trans?lt(V.transless,function(){return i._whenReady(v)}):this._whenReady(v)},ge.prototype.table=function(e){if(!_(this._allTables,e))throw new X.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},ge);function ge(e,t){var n=this;this._middlewares={},this.verno=0;var i=ge.dependencies;this._options=t=a({addons:ge.addons,autoOpen:!0,indexedDB:i.indexedDB,IDBKeyRange:i.IDBKeyRange,cache:"cloned"},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange},i=t.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var o,f,d,m,v,w={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ce,dbReadyPromise:null,cancelOpen:ce,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:t.autoOpen};w.dbReadyPromise=new G(function(g){w.dbReadyResolve=g}),w.openCanceller=new G(function(g,k){w.cancelOpen=k}),this._state=w,this.name=e,this.on=Ft(this,"populate","blocked","versionchange","close",{ready:[On,ce]}),this.on.ready.subscribe=ae(this.on.ready.subscribe,function(g){return function(k,b){ge.vip(function(){var T,R=n._state;R.openComplete?(R.dbOpenError||G.resolve().then(k),b&&g(k)):R.onReadyBeingFired?(R.onReadyBeingFired.push(k),b&&g(k)):(g(k),T=n,b||g(function A(){T.on.ready.unsubscribe(k),T.on.ready.unsubscribe(A)}))})}}),this.Collection=(o=this,jt(Ri.prototype,function(M,A){this.db=o;var b=Mr,T=null;if(A)try{b=A()}catch(O){T=O}var R=M._ctx,A=R.table,M=A.hook.reading.fire;this._ctx={table:A,index:R.index,isPrimKey:!R.index||A.schema.primKey.keyPath&&R.index===A.schema.primKey.name,range:b,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:T,or:R.or,valueMapper:M!==Lt?M:null}})),this.Table=(f=this,jt(Lr.prototype,function(g,k,b){this.db=f,this._tx=b,this.name=g,this.schema=k,this.hook=f._allTables[g]?f._allTables[g].hook:Ft(null,{creating:[vi,ce],reading:[gi,Lt],updating:[wi,ce],deleting:[bi,ce]})})),this.Transaction=(d=this,jt(Oi.prototype,function(g,k,b,T,R){var A=this;this.db=d,this.mode=g,this.storeNames=k,this.schema=b,this.chromeTransactionDurability=T,this.idbtrans=null,this.on=Ft(this,"complete","error","abort"),this.parent=R||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 G(function(M,O){A._resolve=M,A._reject=O}),this._completion.then(function(){A.active=!1,A.on.complete.fire()},function(M){var O=A.active;return A.active=!1,A.on.error.fire(M),A.parent?A.parent._reject(M):O&&A.idbtrans&&A.idbtrans.abort(),ye(M)})})),this.Version=(m=this,jt(Bi.prototype,function(g){this.db=m,this._cfg={version:g,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(v=this,jt(Fr.prototype,function(g,k,b){if(this.db=v,this._ctx={table:g,index:k===":id"?null:k,or:b},this._cmp=this._ascending=ie,this._descending=function(T,R){return ie(R,T)},this._max=function(T,R){return 0<ie(T,R)?T:R},this._min=function(T,R){return ie(T,R)<0?T:R},this._IDBKeyRange=v._deps.IDBKeyRange,!this._IDBKeyRange)throw new X.MissingAPI})),this.on("versionchange",function(g){0<g.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(g){!g.newVersion||g.newVersion<g.oldVersion?console.warn("Dexie.delete('".concat(n.name,"') was blocked")):console.warn("Upgrade '".concat(n.name,"' blocked by other connection holding version ").concat(g.oldVersion/10))}),this._maxKey=qt(t.IDBKeyRange),this._createTransaction=function(g,k,b,T){return new n.Transaction(g,k,b,n._options.chromeTransactionDurability,T)},this._fireOnBlocked=function(g){n.on("blocked").fire(g),Rt.filter(function(k){return k.name===n.name&&k!==n&&!k._state.vcFired}).map(function(k){return k.on("versionchange").fire(g)})},this.use(Ui),this.use(zi),this.use(Gi),this.use(ji),this.use(Ki);var S=new Proxy(this,{get:function(g,k,b){if(k==="_vip")return!0;if(k==="table")return function(R){return _n(n.table(R),S)};var T=Reflect.get(g,k,b);return T instanceof Lr?_n(T,S):k==="tables"?T.map(function(R){return _n(R,S)}):k==="_createTransaction"?function(){return _n(T.apply(this,arguments),S)}:T}});this.vip=S,i.forEach(function(g){return g(n)})}var An,Pe=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",Vi=(cr.prototype.subscribe=function(e,t,n){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:t,complete:n})},cr.prototype[Pe]=function(){return this},cr);function cr(e){this._subscribe=e}try{An={indexedDB:c.indexedDB||c.mozIndexedDB||c.webkitIndexedDB||c.msIndexedDB,IDBKeyRange:c.IDBKeyRange||c.webkitIDBKeyRange}}catch{An={indexedDB:null,IDBKeyRange:null}}function Zr(e){var t,n=!1,i=new Vi(function(o){var f=Pt(e),d,m=!1,v={},w={},S={get closed(){return m},unsubscribe:function(){m||(m=!0,d&&d.abort(),g&&tt.storagemutated.unsubscribe(b))}};o.start&&o.start(S);var g=!1,k=function(){return Fn(T)},b=function(R){vn(v,R),tr(w,v)&&k()},T=function(){var R,A,M;!m&&An.indexedDB&&(v={},R={},d&&d.abort(),d=new AbortController,M=function(O){var C=Tt();try{f&&Et();var I=$e(e,O);return I=f?I.finally(Je):I}finally{C&&St()}}(A={subscr:R,signal:d.signal,requery:k,querier:e,trans:null}),Promise.resolve(M).then(function(O){n=!0,t=O,m||A.signal.aborted||(v={},function(C){for(var I in C)if(_(C,I))return;return 1}(w=R)||g||(tt(Gt,b),g=!0),Fn(function(){return!m&&o.next&&o.next(O)}))},function(O){n=!1,["DatabaseClosedError","AbortError"].includes(O==null?void 0:O.name)||m||Fn(function(){m||o.error&&o.error(O)})}))};return setTimeout(k,0),S});return i.hasValue=function(){return n},i.getValue=function(){return t},i}var pt=Ve;function lr(e){var t=nt;try{nt=!0,tt.storagemutated.fire(e),ir(e,!0)}finally{nt=t}}P(pt,a(a({},Qt),{delete:function(e){return new pt(e,{addons:[]}).delete()},exists:function(e){return new pt(e,{addons:[]}).open().then(function(t){return t.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=pt.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Jn(n)?Promise.resolve(n.databases()).then(function(i){return i.map(function(o){return o.name}).filter(function(o){return o!==on})}):$n(n,t).toCollection().primaryKeys()).then(e)}catch{return ye(new X.MissingAPI)}var t,n},defineClass:function(){return function(e){h(this,e)}},ignoreTransaction:function(e){return V.trans?lt(V.transless,e):e()},vip:Zn,async:function(e){return function(){try{var t=sr(e.apply(this,arguments));return t&&typeof t.then=="function"?t:G.resolve(t)}catch(n){return ye(n)}}},spawn:function(e,t,n){try{var i=sr(e.apply(n,t||[]));return i&&typeof i.then=="function"?i:G.resolve(i)}catch(o){return ye(o)}},currentTransaction:{get:function(){return V.trans||null}},waitFor:function(e,t){return t=G.resolve(typeof e=="function"?pt.ignoreTransaction(e):e).timeout(t||6e4),V.trans?V.trans.waitFor(t):t},Promise:G,debug:{get:function(){return je},set:function(e){Ar(e)}},derive:W,extend:h,props:P,override:ae,Events:Ft,on:tt,liveQuery:Zr,extendObservabilitySet:vn,getByKeyPath:ve,setByKeyPath:le,delByKeyPath:function(e,t){typeof t=="string"?le(e,t,void 0):"length"in t&&[].map.call(t,function(n){le(e,n,void 0)})},shallowClone:Be,deepClone:ke,getObjectDiff:or,cmp:ie,asap:Ae,minKey:-1/0,addons:[],connections:Rt,errnames:Mn,dependencies:An,cache:dt,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)})})),pt.maxKey=qt(pt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(tt(Gt,function(e){nt||(e=new CustomEvent(Hn,{detail:e}),nt=!0,dispatchEvent(e),nt=!1)}),addEventListener(Hn,function(e){e=e.detail,nt||lr(e)}));var Ot,nt=!1,ei=function(){};return typeof BroadcastChannel<"u"&&((ei=function(){(Ot=new BroadcastChannel(Hn)).onmessage=function(e){return e.data&&lr(e.data)}})(),typeof Ot.unref=="function"&&Ot.unref(),tt(Gt,function(e){nt||Ot.postMessage(e)})),typeof addEventListener<"u"&&(addEventListener("pagehide",function(e){if(!Ve.disableBfCache&&e.persisted){je&&console.debug("Dexie: handling persisted pagehide"),Ot!=null&&Ot.close();for(var t=0,n=Rt;t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(e){!Ve.disableBfCache&&e.persisted&&(je&&console.debug("Dexie: handling persisted pageshow"),ei(),lr({all:new xe(-1/0,[[]])}))})),G.rejectionMapper=function(e,t){return!e||e instanceof Fe||e instanceof TypeError||e instanceof SyntaxError||!e.name||!_r[e.name]?e:(t=new _r[e.name](t||e.message,e),"stack"in e&&q(t,"stack",{get:function(){return this.inner.stack}}),t)},Ar(je),a(Ve,Object.freeze({__proto__:null,Dexie:Ve,liveQuery:Zr,Entity:Or,cmp:ie,PropModification:Kt,replacePrefix:function(e,t){return new Kt({replacePrefix:[e,t]})},add:function(e){return new Kt({add:e})},remove:function(e){return new Kt({remove:e})},default:Ve,RangeSet:xe,mergeRanges:Vt,rangesOverlap:qr}),{default:Ve}),Ve})}(Rn)),Rn.exports}var Us=Ks();const br=Fs(Us),hi=Symbol.for("Dexie"),kn=globalThis[hi]||(globalThis[hi]=br);if(br.semVer!==kn.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${br.semVer} and ${kn.semVer}`);const{liveQuery:qs,mergeRanges:Hs,rangesOverlap:zs,RangeSet:Vs,cmp:Xs,Entity:Ws,PropModification:Ys,replacePrefix:Qs,add:$s,remove:Js}=kn;class mi{constructor(r="threeJsIDBCache",s=2){this.version=s,this.dbName=r,this.dbInit()}dbInit(){this.db=new kn(this.dbName),this.materialMap={},this.db.version(this.version).stores({models:"&version, path, data"})}getDatabase(){return this.db}serObject3D(r){const s={type:r.type,name:r.name,position:r.position.toArray(),rotation:r.rotation.toArray(),scale:r.scale.toArray(),visible:r.visible,children:[],geometry:null,material:null,userData:r.userData};r.isMesh&&(s.geometry=this.serGeometry(r.geometry),s.material=this.serMaterial(r.material));for(const a of r.children)s.children.push(this.serObject3D(a));return s}serGeometry(r){const s=[],{attributes:a,index:u,type:c}=r;a.position&&(s.position={type:"Float32Array",array:Array.from(a.position.array),itemSize:3}),a.normal&&(s.normal={type:"Float32Array",array:Array.from(a.normal.array),itemSize:3}),a.uv&&(s.uv={type:"Float32Array",array:Array.from(a.uv.array),itemSize:2});const l={type:c,attributes:s};return u&&u.array&&(l.index={type:"Uint32Array",array:Array.from(u.array),itemSize:1}),l}reSerGeometry(r){const{type:s,attributes:a,index:u}=r,c=new yt.BufferGeometry;return Object.keys(a).forEach(l=>{const{type:p,array:h,itemSize:y}=a[l];c.setAttribute(l,new yt.BufferAttribute(new Float32Array(h),y))}),u&&c.setIndex(u.array),c}serMaterial(r){return{type:r.type,color:r.color.getHex(),map:r.map?r.map.image.src:null,opacity:r.opacity,name:r.name,depthTest:r.depthTest,depthWrite:r.depthWrite,transparent:r.transparent,side:r.side,roughness:r.roughness,metalness:r.metalness,emissive:r.emissive.getHex()}}reSerMaterial(r){if(this.materialMap[r.name])return this.materialMap[r.name];const{type:s,...a}=r,u=s||"MeshStandardMaterial",c=new yt[u]({...a});if(r.map){const l=new yt.TextureLoader().load(r.map);c.map=l}return c.needsUpdate=!0,this.materialMap[r.name]=c,c}reSerObject3D(r){let s;switch(r.type){case"Mesh":const a=this.reSerGeometry(r.geometry),u=this.reSerMaterial(r.material);s=new yt.Mesh(a,u);break;case"Group":s=new yt.Group;break;case"Object3D":s=new yt.Object3D;break;default:return console.warn(`Unsupported object type: ${r.type}`),null}s.name=r.name,s.position.fromArray(r.position),s.rotation.fromArray(r.rotation),s.scale.fromArray(r.scale),s.visible=r.visible,s.userData=r.userData;for(const a of r.children){const u=this.reSerObject3D(a);u&&s.add(u)}return s}async cacheModel(r,s,a){const u=this.serObject3D(s);try{await this.db.table("models").put({version:a,path:r,data:u}),console.log(`Model "${r}" cached successfully in table models`)}catch{console.log(" 缓存模型失败 =====> ")}}async loadCachedModel(r){let s=null;try{if(s=await this.db.table("models").get(r),!s)return console.warn(`Model "${r}" not found in table models`),null}catch{return console.log(" =====> 查询表中模型失败"),this.db.delete().then(()=>{this.init()}),null}try{const a=this.reSerObject3D(s.data);return console.log(`Model "${r}" loaded from table models`),a}catch(a){return console.log(" =====> 模型序列号处理失败:",a),null}}}let En;const Gs=()=>{const L=new Qi,r=new Wi;r.setDecoderPath("/draco/"),L.setDRACOLoader(r);function s(c,l,p,h){return L.load(c,l,p,h)}function a(c,l){return new Promise((p,h)=>{L.load(c,p,l,h)})}async function u(c,l,p){En||(En=new mi);const h=await En.loadCachedModel(l);return h||new Promise((y,E)=>{L.load(c,y,p,E)}).then(async y=>(await En.cacheModel(c,y.scene,l),y.scene))}return{load:s,asyncLoad:a,asyncCacheLoad:u}};exports.IDBCache=mi;exports.intersectColor=Ds;exports.obbObjects=Ge;exports.useGLTFLoader=Gs;exports.useObb=Ns;exports.useRaycaster=Is;exports.useThreeJs=Ls;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ridp/threejs",
3
3
  "private": false,
4
- "version": "1.1.0",
4
+ "version": "1.1.3",
5
5
  "type": "module",
6
6
  "main": "dist/threejs.js",
7
7
  "exports": {