@ridp/threejs 1.1.7 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/common-C1rNPPkt.cjs +15 -0
  2. package/dist/common-D1_IztgM.js +54 -0
  3. package/dist/hooks.cjs +1 -1
  4. package/dist/hooks.js +4 -4
  5. package/dist/modelSerialize-5oJb1ka7.js +965 -0
  6. package/dist/modelSerialize-Ds_2KBaA.cjs +5 -0
  7. package/dist/threejs.cjs +1 -1
  8. package/dist/threejs.js +184 -24
  9. package/dist/useGLTFLoader-Ca78rpg1.js +5507 -0
  10. package/dist/useGLTFLoader-SChWH4Nf.cjs +4 -0
  11. package/dist/utils.cjs +1 -1
  12. package/dist/utils.js +18 -16
  13. package/esdoc/ast/source/.external-ecmascript.js.json +2801 -2801
  14. package/esdoc/ast/source/hooks/index.js.json +738 -738
  15. package/esdoc/ast/source/hooks/useGLTFLoader.js.json +9110 -9110
  16. package/esdoc/ast/source/hooks/useObb.js.json +16462 -16462
  17. package/esdoc/ast/source/hooks/useRaycaster.js.json +15555 -15555
  18. package/esdoc/ast/source/hooks/useThreeJs.js.json +52886 -52886
  19. package/esdoc/ast/source/index.js.json +569 -569
  20. package/esdoc/ast/source/instance/IDBCache.js.json +40977 -40977
  21. package/esdoc/ast/source/instance/index.js.json +231 -231
  22. package/esdoc/ast/source/utils/ImageLoader.js.json +7036 -7036
  23. package/esdoc/ast/source/utils/common.js.json +5133 -5133
  24. package/esdoc/ast/source/utils/css3dHelper.js.json +9100 -9100
  25. package/esdoc/ast/source/utils/disposeObject.js.json +5977 -5977
  26. package/esdoc/ast/source/utils/helper.js.json +10521 -10521
  27. package/esdoc/ast/source/utils/index.js.json +907 -907
  28. package/esdoc/badge.svg +17 -17
  29. package/esdoc/class/src/instance/IDBCache.js~IDBCache.html +1299 -1299
  30. package/esdoc/coverage.json +85 -85
  31. package/esdoc/css/github.css +83 -83
  32. package/esdoc/css/identifiers.css +37 -37
  33. package/esdoc/css/manual.css +134 -134
  34. package/esdoc/css/prettify-tomorrow.css +132 -132
  35. package/esdoc/css/search.css +84 -84
  36. package/esdoc/css/source.css +55 -55
  37. package/esdoc/css/style.css +608 -608
  38. package/esdoc/css/test.css +58 -58
  39. package/esdoc/file/src/hooks/index.js.html +75 -75
  40. package/esdoc/file/src/hooks/useGLTFLoader.js.html +75 -75
  41. package/esdoc/file/src/hooks/useObb.js.html +75 -75
  42. package/esdoc/file/src/hooks/useRaycaster.js.html +75 -75
  43. package/esdoc/file/src/hooks/useThreeJs.js.html +75 -75
  44. package/esdoc/file/src/index.js.html +75 -75
  45. package/esdoc/file/src/instance/IDBCache.js.html +75 -75
  46. package/esdoc/file/src/instance/index.js.html +75 -75
  47. package/esdoc/file/src/utils/ImageLoader.js.html +75 -75
  48. package/esdoc/file/src/utils/common.js.html +75 -75
  49. package/esdoc/file/src/utils/css3dHelper.js.html +75 -75
  50. package/esdoc/file/src/utils/disposeObject.js.html +75 -75
  51. package/esdoc/file/src/utils/helper.js.html +75 -75
  52. package/esdoc/file/src/utils/index.js.html +75 -75
  53. package/esdoc/function/index.html +2019 -2019
  54. package/esdoc/identifiers.html +738 -738
  55. package/esdoc/image/badge.svg +17 -17
  56. package/esdoc/image/manual-badge.svg +17 -17
  57. package/esdoc/index.html +153 -153
  58. package/esdoc/index.json +2050 -2050
  59. package/esdoc/script/inherited-summary.js +28 -28
  60. package/esdoc/script/inner-link.js +32 -32
  61. package/esdoc/script/manual.js +12 -12
  62. package/esdoc/script/patch-for-local.js +8 -8
  63. package/esdoc/script/prettify/Apache-License-2.0.txt +202 -202
  64. package/esdoc/script/prettify/prettify.js +46 -46
  65. package/esdoc/script/pretty-print.js +25 -25
  66. package/esdoc/script/search.js +117 -117
  67. package/esdoc/script/search_index.js +571 -571
  68. package/esdoc/script/test-summary.js +54 -54
  69. package/esdoc/source.html +213 -213
  70. package/esdoc/variable/index.html +225 -225
  71. package/package.json +3 -5
  72. package/dist/ImageLoader-B_rHfhtt.cjs +0 -1
  73. package/dist/ImageLoader-D9uANgrl.js +0 -1475
  74. package/dist/common-DTEEkXFr.cjs +0 -1
  75. package/dist/common-DhuVL1VV.js +0 -73
  76. package/dist/useGLTFLoader-BDER-upw.cjs +0 -1
  77. package/dist/useGLTFLoader-UD3WYZET.js +0 -7016
@@ -1 +0,0 @@
1
- "use strict";const e=require("./ImageLoader-B_rHfhtt.cjs");const n=e=>{const n=document.createElement("div");n.style.cssText="\n border-radius: 50px;\n border: 2px solid rgba(255, 255, 255, 0.5);\n background-color: rgba(15, 20, 22, 0.562);\n justify-content: flex-start;\n align-items: center;\n padding: 20px 30px;\n display: flex;\n transform-origin: center 0;";const t=document.createElement("span");return t.style.cssText="\n font-size: 40px;\n line-height: 1;\n white-space: nowrap;\n color: #fff;\n font-weight: 700;\n ",t.innerText=e,n.appendChild(t),n};exports.createInfoPlane=function(n,t=[.3,.3,.3]){const r=document.querySelector(`#${n}`);if(!r)return;const o=r.cloneNode(!0);o.style.display="block";const s=new e.CSS3DSprite(o);return s.visible=!1,s.scale.set(...t),s},exports.createTagPlane=function(t,r){const o=n(t);o.style.display="block";const s=new e.CSS3DSprite(o);return s.visible=!1,s.scale.set(r,r,r),s},exports.getCommonParent=(e,n)=>{const t={};e.forEach((e=>{let n=e.parent;for(;n;)t[n.uuid]?t[n.uuid]++:t[n.uuid]=1,n=n.parent}));let r=null,o=0;for(const s in t)t[s]>o&&(o=t[s],r=n.getObjectByProperty("uuid",s));return r};
@@ -1,73 +0,0 @@
1
- import { C as CSS3DSprite } from "./ImageLoader-D9uANgrl.js";
2
- function createInfoPlane(id, scale = [0.3, 0.3, 0.3]) {
3
- const el = document.querySelector(`#${id}`);
4
- if (!el) {
5
- console.log(" 获取 infoPlane 元素失败 (id) =====> :", id);
6
- return;
7
- }
8
- const _el = el.cloneNode(true);
9
- _el.style.display = "block";
10
- const plane = new CSS3DSprite(_el);
11
- plane.visible = false;
12
- plane.scale.set(...scale);
13
- return plane;
14
- }
15
- function createTagPlane(text, scale) {
16
- const el = tagBlock(text);
17
- el.style.display = "block";
18
- const plane = new CSS3DSprite(el);
19
- plane.visible = false;
20
- plane.scale.set(scale, scale, scale);
21
- return plane;
22
- }
23
- const tagBlock = (text) => {
24
- const el = document.createElement("div");
25
- el.style.cssText = `
26
- border-radius: 50px;
27
- border: 2px solid rgba(255, 255, 255, 0.5);
28
- background-color: rgba(15, 20, 22, 0.562);
29
- justify-content: flex-start;
30
- align-items: center;
31
- padding: 20px 30px;
32
- display: flex;
33
- transform-origin: center 0;`;
34
- const textSpan = document.createElement("span");
35
- textSpan.style.cssText = `
36
- font-size: 40px;
37
- line-height: 1;
38
- white-space: nowrap;
39
- color: #fff;
40
- font-weight: 700;
41
- `;
42
- textSpan.innerText = text;
43
- el.appendChild(textSpan);
44
- return el;
45
- };
46
- const getCommonParent = (meshList, objectGroup) => {
47
- const parentCount = {};
48
- meshList.forEach((mesh) => {
49
- let parent = mesh.parent;
50
- while (parent) {
51
- if (parentCount[parent.uuid]) {
52
- parentCount[parent.uuid]++;
53
- } else {
54
- parentCount[parent.uuid] = 1;
55
- }
56
- parent = parent.parent;
57
- }
58
- });
59
- let commonParent = null;
60
- let maxCount = 0;
61
- for (const uuid in parentCount) {
62
- if (parentCount[uuid] > maxCount) {
63
- maxCount = parentCount[uuid];
64
- commonParent = objectGroup.getObjectByProperty("uuid", uuid);
65
- }
66
- }
67
- return commonParent;
68
- };
69
- export {
70
- createTagPlane as a,
71
- createInfoPlane as c,
72
- getCommonParent as g
73
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("three"),t=require("vue"),n=require("./ImageLoader-B_rHfhtt.cjs");function r(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const i=r(e);function o(t,n){if(n===e.TrianglesDrawMode)return t;if(n===e.TriangleFanDrawMode||n===e.TriangleStripDrawMode){let r=t.getIndex();if(null===r){const e=[],n=t.getAttribute("position");if(void 0===n)return t;for(let t=0;t<n.count;t++)e.push(t);t.setIndex(e),r=t.getIndex()}const i=r.count-2,o=[];if(n===e.TriangleFanDrawMode)for(let e=1;e<=i;e++)o.push(r.getX(0)),o.push(r.getX(e)),o.push(r.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(o.push(r.getX(e)),o.push(r.getX(e+1)),o.push(r.getX(e+2))):(o.push(r.getX(e+2)),o.push(r.getX(e+1)),o.push(r.getX(e)));o.length;const s=t.clone();return s.setIndex(o),s.clearGroups(),s}return t}const s=new WeakMap;class a extends e.Loader{constructor(e){super(e),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(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(t,n,r,i){const o=new e.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,(e=>{this.parse(e,n,i)}),r,i)}parse(t,n,r=()=>{}){this.decodeDracoFile(t,n,null,null,e.SRGBColorSpace,r).catch(r)}decodeDracoFile(t,n,r,i,o=e.LinearSRGBColorSpace,s=()=>{}){const a={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:o};return this.decodeGeometry(t,a).then(n).catch(s)}decodeGeometry(e,t){const n=JSON.stringify(t);if(s.has(e)){const t=s.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(i,o).then((n=>(r=n,new Promise(((n,o)=>{r._callbacks[i]={resolve:n,reject:o},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return a.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),s.set(e,{key:n,promise:a}),a}_createGeometry(t){const n=new e.BufferGeometry;t.index&&n.setIndex(new e.BufferAttribute(t.index.array,1));for(let r=0;r<t.attributes.length;r++){const i=t.attributes[r],o=i.name,s=i.array,a=i.itemSize,u=new e.BufferAttribute(s,a);"color"===o&&(this._assignVertexColorSpace(u,i.vertexColorSpace),u.normalized=s instanceof Float32Array==!1),n.setAttribute(o,u)}return n}_assignVertexColorSpace(t,n){if(n!==e.SRGBColorSpace)return;const r=new e.Color;for(let i=0,o=t.count;i<o;i++)r.fromBufferAttribute(t,i),e.ColorManagement.toWorkingColorSpace(r,e.SRGBColorSpace),t.setXYZ(i,r.r,r.g,r.b)}_loadLibrary(t,n){const r=new e.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(n),r.setWithCredentials(this.withCredentials),new Promise(((e,n)=>{r.load(t,e,void 0,n)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=u.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n)}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function u(){let e,t;function n(e,t,n,r,i,o){const s=o.num_components(),a=n.num_points()*s,u=a*i.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),l=e._malloc(u);t.GetAttributeDataArrayForAllPoints(n,o,c,u,l);const h=new i(e.HEAPF32.buffer,l,a).slice();return e._free(l),{name:r,array:h,itemSize:s}}onmessage=function(r){const i=r.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=i.buffer,o=i.taskConfig;t.then((e=>{const t=e.draco,s=new t.Decoder;try{const e=function(e,t,r,i){const o=i.attributeIDs,s=i.attributeTypes;let a,u;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,u=t.DecodeArrayToMesh(r,r.byteLength,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,u=t.DecodeArrayToPointCloud(r,r.byteLength,a)}if(!u.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());const l={index:null,attributes:[]};for(const h in o){const r=self[s[h]];let u,c;if(i.useUniqueIDs)c=o[h],u=t.GetAttributeByUniqueId(a,c);else{if(c=t.GetAttributeId(a,e[o[h]]),-1===c)continue;u=t.GetAttribute(a,c)}const f=n(e,t,a,h,r,u);"color"===h&&(f.vertexColorSpace=i.vertexColorSpace),l.attributes.push(f)}c===e.TRIANGULAR_MESH&&(l.index=function(e,t,n){const r=n.num_faces(),i=3*r,o=4*i,s=e._malloc(o);t.GetTrianglesUInt32Array(n,o,s);const a=new Uint32Array(e.HEAPF32.buffer,s,i).slice();return e._free(s),{array:a,itemSize:1}}(e,t,a));return e.destroy(a),l}(t,s,new Int8Array(r),o),a=e.attributes.map((e=>e.array.buffer));e.index&&a.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},a)}catch(a){self.postMessage({type:"error",id:i.id,error:a.message})}finally{t.destroy(s)}}))}}}class c extends e.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new m(e)})),this.register((function(e){return new y(e)})),this.register((function(e){return new S(e)})),this.register((function(e){return new R(e)})),this.register((function(e){return new E(e)})),this.register((function(e){return new g(e)})),this.register((function(e){return new b(e)})),this.register((function(e){return new w(e)})),this.register((function(e){return new _(e)})),this.register((function(e){return new p(e)})),this.register((function(e){return new x(e)})),this.register((function(e){return new v(e)})),this.register((function(e){return new T(e)})),this.register((function(e){return new A(e)})),this.register((function(e){return new f(e)})),this.register((function(e){return new k(e)})),this.register((function(e){return new M(e)}))}load(t,n,r,i){const o=this;let s;if(""!==this.resourcePath)s=this.resourcePath;else if(""!==this.path){const n=e.LoaderUtils.extractUrlBase(t);s=e.LoaderUtils.resolveURL(n,this.path)}else s=e.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){i&&i(e),o.manager.itemError(t),o.manager.itemEnd(t)},u=new e.FileLoader(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(t,(function(e){try{o.parse(e,s,(function(e){n(e),o.manager.itemEnd(t)}),a)}catch(r){a(r)}}),r,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const o={},s={},a=new TextDecoder;if("string"==typeof e)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===O){try{o[h.KHR_BINARY_GLTF]=new I(e)}catch(c){return void(r&&r(c))}i=JSON.parse(o[h.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(e))}else i=e;if(void 0===i.asset||i.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new ie(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const e=this.pluginCallbacks[l](u);e.name,s[e.name]=e,o[e.name]=!0}if(i.extensionsUsed)for(let l=0;l<i.extensionsUsed.length;++l){const e=i.extensionsUsed[l],t=i.extensionsRequired||[];switch(e){case h.KHR_MATERIALS_UNLIT:o[e]=new d;break;case h.KHR_DRACO_MESH_COMPRESSION:o[e]=new L(i,this.dracoLoader);break;case h.KHR_TEXTURE_TRANSFORM:o[e]=new D;break;case h.KHR_MESH_QUANTIZATION:o[e]=new B;break;default:t.indexOf(e)>=0&&s[e]}}u.setExtensions(o),u.setPlugins(s),u.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function l(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const h={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 f{constructor(e){this.parser=e,this.name=h.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const n=this.parser,r="light:"+t;let i=n.cache.get(r);if(i)return i;const o=n.json,s=((o.extensions&&o.extensions[this.name]||{}).lights||[])[t];let a;const u=new e.Color(16777215);void 0!==s.color&&u.setRGB(s.color[0],s.color[1],s.color[2],e.LinearSRGBColorSpace);const c=void 0!==s.range?s.range:0;switch(s.type){case"directional":a=new e.DirectionalLight(u),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new e.PointLight(u),a.distance=c;break;case"spot":a=new e.SpotLight(u),a.distance=c,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,a.angle=s.spot.outerConeAngle,a.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return a.position.set(0,0,0),Z(a,s),void 0!==s.intensity&&(a.intensity=s.intensity),a.name=n.createUniqueName(s.name||"light_"+t),i=Promise.resolve(a),n.cache.add(r,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class d{constructor(){this.name=h.KHR_MATERIALS_UNLIT}getMaterialType(){return e.MeshBasicMaterial}extendParams(t,n,r){const i=[];t.color=new e.Color(1,1,1),t.opacity=1;const o=n.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const n=o.baseColorFactor;t.color.setRGB(n[0],n[1],n[2],e.LinearSRGBColorSpace),t.opacity=n[3]}void 0!==o.baseColorTexture&&i.push(r.assignTexture(t,"map",o.baseColorTexture,e.SRGBColorSpace))}return Promise.all(i)}}class p{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class m{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,n){const r=this.parser,i=r.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];if(void 0!==s.clearcoatFactor&&(n.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&o.push(r.assignTexture(n,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(n.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&o.push(r.assignTexture(n,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(o.push(r.assignTexture(n,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const t=s.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new e.Vector2(t,t)}return Promise.all(o)}}class y{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_DISPERSION}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.dispersion=void 0!==r.dispersion?r.dispersion:0,Promise.resolve()}}class v{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&i.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(t.iridescenceIOR=o.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&i.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class g{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_SHEEN}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,n){const r=this.parser,i=r.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new e.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const s=i.extensions[this.name];if(void 0!==s.sheenColorFactor){const t=s.sheenColorFactor;n.sheenColor.setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace)}return void 0!==s.sheenRoughnessFactor&&(n.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&o.push(r.assignTexture(n,"sheenColorMap",s.sheenColorTexture,e.SRGBColorSpace)),void 0!==s.sheenRoughnessTexture&&o.push(r.assignTexture(n,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(o)}}class b{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class w{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_VOLUME}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,n){const r=this.parser,i=r.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];n.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&o.push(r.assignTexture(n,"thicknessMap",s.thicknessTexture)),n.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return n.attenuationColor=(new e.Color).setRGB(a[0],a[1],a[2],e.LinearSRGBColorSpace),Promise.all(o)}}class _{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_IOR}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class x{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_SPECULAR}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(t,n){const r=this.parser,i=r.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];n.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&o.push(r.assignTexture(n,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return n.specularColor=(new e.Color).setRGB(a[0],a[1],a[2],e.LinearSRGBColorSpace),void 0!==s.specularColorTexture&&o.push(r.assignTexture(n,"specularColorMap",s.specularColorTexture,e.SRGBColorSpace)),Promise.all(o)}}class A{constructor(e){this.parser=e,this.name=h.EXT_MATERIALS_BUMP}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return t.bumpScale=void 0!==o.bumpFactor?o.bumpFactor:1,void 0!==o.bumpTexture&&i.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class T{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const n=this.parser.json.materials[t];return n.extensions&&n.extensions[this.name]?e.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];return void 0!==o.anisotropyStrength&&(t.anisotropy=o.anisotropyStrength),void 0!==o.anisotropyRotation&&(t.anisotropyRotation=o.anisotropyRotation),void 0!==o.anisotropyTexture&&i.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class S{constructor(e){this.parser=e,this.name=h.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class R{constructor(e){this.parser=e,this.name=h.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],s=r.images[o.source];let a=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class E{constructor(e){this.parser=e,this.name=h.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],s=r.images[o.source];let a=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(a=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,o.source,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class k{constructor(e){this.name=h.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then((function(t){const n=e.byteOffset||0,r=e.byteLength||0,o=e.count,s=e.byteStride,a=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,s,a,e.mode,e.filter).then((function(e){return e.buffer})):i.ready.then((function(){const t=new ArrayBuffer(o*s);return i.decodeGltfBuffer(new Uint8Array(t),o,s,a,e.mode,e.filter),t}))}))}return null}}class M{constructor(e){this.name=h.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(t){const n=this.parser.json,r=n.nodes[t];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;const i=n.meshes[r.mesh];for(const e of i.primitives)if(e.mode!==F.TRIANGLES&&e.mode!==F.TRIANGLE_STRIP&&e.mode!==F.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=r.extensions[this.name].attributes,s=[],a={};for(const e in o)s.push(this.parser.getDependency("accessor",o[e]).then((t=>(a[e]=t,a[e]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(t)),Promise.all(s).then((t=>{const n=t.pop(),r=n.isGroup?n.children:[n],i=t[0].count,o=[];for(const s of r){const t=new e.Matrix4,n=new e.Vector3,r=new e.Quaternion,u=new e.Vector3(1,1,1),c=new e.InstancedMesh(s.geometry,s.material,i);for(let e=0;e<i;e++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&r.fromBufferAttribute(a.ROTATION,e),a.SCALE&&u.fromBufferAttribute(a.SCALE,e),c.setMatrixAt(e,t.compose(n,r,u));for(const i in a)if("_COLOR_0"===i){const t=a[i];c.instanceColor=new e.InstancedBufferAttribute(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==i&&"ROTATION"!==i&&"SCALE"!==i&&s.geometry.setAttribute(i,a[i]);e.Object3D.prototype.copy.call(c,s),this.parser.assignFinalMaterial(c),o.push(c)}return n.isGroup?(n.clear(),n.add(...o),n):o[0]})))}}const O="glTF",P=1313821514,C=5130562;class I{constructor(e){this.name=h.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==O)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,i=new DataView(e,12);let o=0;for(;o<r;){const t=i.getUint32(o,!0);o+=4;const r=i.getUint32(o,!0);if(o+=4,r===P){const r=new Uint8Array(e,12+o,t);this.content=n.decode(r)}else if(r===C){const n=12+o;this.body=e.slice(n,n+t)}o+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class L{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=h.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(t,n){const r=this.json,i=this.dracoLoader,o=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},u={},c={};for(const e in s){const t=z[e]||e.toLowerCase();a[t]=s[e]}for(const e in t.attributes){const n=z[e]||e.toLowerCase();if(void 0!==s[e]){const i=r.accessors[t.attributes[e]],o=U[i.componentType];c[n]=o.name,u[n]=!0===i.normalized}}return n.getDependency("bufferView",o).then((function(t){return new Promise((function(n,r){i.decodeDracoFile(t,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=u[t];void 0!==r&&(n.normalized=r)}n(e)}),a,c,e.LinearSRGBColorSpace,r)}))}))}}class D{constructor(){this.name=h.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class B{constructor(){this.name=h.KHR_MESH_QUANTIZATION}}class N extends e.Interpolant{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let o=0;o!==r;o++)t[o]=n[i+o];return t}interpolate_(e,t,n,r){const i=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=2*s,u=3*s,c=r-t,l=(n-t)/c,h=l*l,f=h*l,d=e*u,p=d-u,m=-2*f+3*h,y=f-h,v=1-m,g=y-h+l;for(let b=0;b!==s;b++){const e=o[p+b+s],t=o[p+b+a]*c,n=o[d+b+s],r=o[d+b]*c;i[b]=v*e+g*t+m*n+y*r}return i}}const j=new e.Quaternion;class K extends N{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return j.fromArray(i).normalize().toArray(i),i}}const F={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},U={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},q={9728:e.NearestFilter,9729:e.LinearFilter,9984:e.NearestMipmapNearestFilter,9985:e.LinearMipmapNearestFilter,9986:e.NearestMipmapLinearFilter,9987:e.LinearMipmapLinearFilter},H={33071:e.ClampToEdgeWrapping,33648:e.MirroredRepeatWrapping,10497:e.RepeatWrapping},G={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},z={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"},V={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},X={CUBICSPLINE:void 0,LINEAR:e.InterpolateLinear,STEP:e.InterpolateDiscrete},W="OPAQUE",Y="MASK",Q="BLEND";function $(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function Z(e,t){void 0!==t.extras&&"object"==typeof t.extras&&Object.assign(e.userData,t.extras)}function J(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}}}function ee(e){let t;const n=e.extensions&&e.extensions[h.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+te(n.attributes):e.indices+":"+te(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,i=e.targets.length;r<i;r++)t+=":"+te(e.targets[r]);return t}function te(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function ne(e){switch(e){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.")}}const re=new e.Matrix4;class ie{constructor(t={},n={}){this.json=t,this.extensions={},this.plugins={},this.options=n,this.cache=new l,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 r=!1,i=-1,o=!1,s=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;r=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);i=r&&t?parseInt(t[1],10):-1,o=e.indexOf("Firefox")>-1,s=o?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||r&&i<17||o&&s<98?this.textureLoader=new e.TextureLoader(this.options.manager):this.textureLoader=new e.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new e.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const o={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return $(i,o,r),Z(o,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(o)}))).then((function(){for(const e of o.scenes)e.updateMatrixWorld();e(o)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,i=t.length;r<i;r++){const n=t[r].joints;for(let t=0,r=n.length;t<r;t++)e[n[t]].isBone=!0}for(let r=0,i=e.length;r<i;r++){const t=e[r];void 0!==t.mesh&&(this._addNodeRef(this.meshCache,t.mesh),void 0!==t.skin&&(n[t.mesh].isSkinnedMesh=!0)),void 0!==t.camera&&this._addNodeRef(this.cameraCache,t.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[r,o]of e.children.entries())i(o,t.children[r])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne((function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)})),!r)throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(t){const n=this.json.buffers[t],r=this.fileLoader;if(n.type&&"arraybuffer"!==n.type)throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(void 0===n.uri&&0===t)return Promise.resolve(this.extensions[h.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(t,o){r.load(e.LoaderUtils.resolveURL(n.uri,i.path),t,void 0,(function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(t){const n=this,r=this.json,i=this.json.accessors[t];if(void 0===i.bufferView&&void 0===i.sparse){const t=G[i.type],n=U[i.componentType],r=!0===i.normalized,o=new n(i.count*t);return Promise.resolve(new e.BufferAttribute(o,t,r))}const o=[];return void 0!==i.bufferView?o.push(this.getDependency("bufferView",i.bufferView)):o.push(null),void 0!==i.sparse&&(o.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(o).then((function(t){const o=t[0],s=G[i.type],a=U[i.componentType],u=a.BYTES_PER_ELEMENT,c=u*s,l=i.byteOffset||0,h=void 0!==i.bufferView?r.bufferViews[i.bufferView].byteStride:void 0,f=!0===i.normalized;let d,p;if(h&&h!==c){const t=Math.floor(l/h),r="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+t+":"+i.count;let c=n.cache.get(r);c||(d=new a(o,t*h,i.count*h/u),c=new e.InterleavedBuffer(d,h/u),n.cache.add(r,c)),p=new e.InterleavedBufferAttribute(c,s,l%h/u,f)}else d=null===o?new a(i.count*s):new a(o,l,i.count*s),p=new e.BufferAttribute(d,s,f);if(void 0!==i.sparse){const n=G.SCALAR,r=U[i.sparse.indices.componentType],u=i.sparse.indices.byteOffset||0,c=i.sparse.values.byteOffset||0,l=new r(t[1],u,i.sparse.count*n),h=new a(t[2],c,i.sparse.count*s);null!==o&&(p=new e.BufferAttribute(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){const t=l[e];if(p.setX(t,h[e*s]),s>=2&&p.setY(t,h[e*s+1]),s>=3&&p.setZ(t,h[e*s+2]),s>=4&&p.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=f}return p}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let o=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(o=e)}return this.loadTextureImage(e,r,o)}loadTextureImage(t,n,r){const i=this,o=this.json,s=o.textures[t],a=o.images[n],u=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[u])return this.textureCache[u];const c=this.loadImageSource(n,r).then((function(n){n.flipY=!1,n.name=s.name||a.name||"",""===n.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(n.name=a.uri);const r=(o.samplers||{})[s.sampler]||{};return n.magFilter=q[r.magFilter]||e.LinearFilter,n.minFilter=q[r.minFilter]||e.LinearMipmapLinearFilter,n.wrapS=H[r.wrapS]||e.RepeatWrapping,n.wrapT=H[r.wrapT]||e.RepeatWrapping,n.generateMipmaps=!n.isCompressedTexture&&n.minFilter!==e.NearestFilter&&n.minFilter!==e.LinearFilter,i.associations.set(n,{textures:t}),n})).catch((function(){return null}));return this.textureCache[u]=c,c}loadImageSource(t,n){const r=this,i=this.json,o=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then((e=>e.clone()));const s=i.images[t],a=self.URL||self.webkitURL;let u=s.uri||"",c=!1;if(void 0!==s.bufferView)u=r.getDependency("bufferView",s.bufferView).then((function(e){c=!0;const t=new Blob([e],{type:s.mimeType});return u=a.createObjectURL(t),u}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(u).then((function(t){return new Promise((function(r,i){let s=r;!0===n.isImageBitmapLoader&&(s=function(t){const n=new e.Texture(t);n.needsUpdate=!0,r(n)}),n.load(e.LoaderUtils.resolveURL(t,o.path),s,void 0,i)}))})).then((function(e){var t;return!0===c&&a.revokeObjectURL(u),Z(e,s),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e})).catch((function(e){throw e}));return this.sourceCache[t]=l,l}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(o){if(!o)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((o=o.clone()).channel=n.texCoord),i.extensions[h.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[h.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(o);o=i.extensions[h.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==r&&(o.colorSpace=r),e[t]=o,o}))}assignFinalMaterial(t){const n=t.geometry;let r=t.material;const i=void 0===n.attributes.tangent,o=void 0!==n.attributes.color,s=void 0===n.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+r.uuid;let n=this.cache.get(t);n||(n=new e.PointsMaterial,e.Material.prototype.copy.call(n,r),n.color.copy(r.color),n.map=r.map,n.sizeAttenuation=!1,this.cache.add(t,n)),r=n}else if(t.isLine){const t="LineBasicMaterial:"+r.uuid;let n=this.cache.get(t);n||(n=new e.LineBasicMaterial,e.Material.prototype.copy.call(n,r),n.color.copy(r.color),n.map=r.map,this.cache.add(t,n)),r=n}if(i||o||s){let e="ClonedMaterial:"+r.uuid+":";i&&(e+="derivative-tangents:"),o&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),o&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}t.material=r}getMaterialType(){return e.MeshStandardMaterial}loadMaterial(t){const n=this,r=this.json,i=this.extensions,o=r.materials[t];let s;const a={},u=[];if((o.extensions||{})[h.KHR_MATERIALS_UNLIT]){const e=i[h.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),u.push(e.extendParams(a,o,n))}else{const r=o.pbrMetallicRoughness||{};if(a.color=new e.Color(1,1,1),a.opacity=1,Array.isArray(r.baseColorFactor)){const t=r.baseColorFactor;a.color.setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace),a.opacity=t[3]}void 0!==r.baseColorTexture&&u.push(n.assignTexture(a,"map",r.baseColorTexture,e.SRGBColorSpace)),a.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,a.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(u.push(n.assignTexture(a,"metalnessMap",r.metallicRoughnessTexture)),u.push(n.assignTexture(a,"roughnessMap",r.metallicRoughnessTexture))),s=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),u.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,a)}))))}!0===o.doubleSided&&(a.side=e.DoubleSide);const c=o.alphaMode||W;if(c===Q?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===Y&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&s!==e.MeshBasicMaterial&&(u.push(n.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new e.Vector2(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&s!==e.MeshBasicMaterial&&(u.push(n.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&s!==e.MeshBasicMaterial){const t=o.emissiveFactor;a.emissive=(new e.Color).setRGB(t[0],t[1],t[2],e.LinearSRGBColorSpace)}return void 0!==o.emissiveTexture&&s!==e.MeshBasicMaterial&&u.push(n.assignTexture(a,"emissiveMap",o.emissiveTexture,e.SRGBColorSpace)),Promise.all(u).then((function(){const e=new s(a);return o.name&&(e.name=o.name),Z(e,o),n.associations.set(e,{materials:t}),o.extensions&&$(i,e,o),e}))}createUniqueName(t){const n=e.PropertyBinding.sanitizeNodeName(t||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(t){const n=this,r=this.extensions,i=this.primitiveCache;function o(e){return r[h.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,n).then((function(t){return oe(t,e,n)}))}const s=[];for(let a=0,u=t.length;a<u;a++){const r=t[a],u=ee(r),c=i[u];if(c)s.push(c.promise);else{let t;t=r.extensions&&r.extensions[h.KHR_DRACO_MESH_COMPRESSION]?o(r):oe(new e.BufferGeometry,r,n),i[u]={primitive:r,promise:t},s.push(t)}}return Promise.all(s)}loadMesh(t){const n=this,r=this.json,i=this.extensions,s=r.meshes[t],a=s.primitives,u=[];for(let o=0,l=a.length;o<l;o++){const t=void 0===a[o].material?(void 0===(c=this.cache).DefaultMaterial&&(c.DefaultMaterial=new e.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:e.FrontSide})),c.DefaultMaterial):this.getDependency("material",a[o].material);u.push(t)}var c;return u.push(n.loadGeometries(a)),Promise.all(u).then((function(r){const u=r.slice(0,r.length-1),c=r[r.length-1],l=[];for(let f=0,d=c.length;f<d;f++){const r=c[f],h=a[f];let d;const p=u[f];if(h.mode===F.TRIANGLES||h.mode===F.TRIANGLE_STRIP||h.mode===F.TRIANGLE_FAN||void 0===h.mode)d=!0===s.isSkinnedMesh?new e.SkinnedMesh(r,p):new e.Mesh(r,p),!0===d.isSkinnedMesh&&d.normalizeSkinWeights(),h.mode===F.TRIANGLE_STRIP?d.geometry=o(d.geometry,e.TriangleStripDrawMode):h.mode===F.TRIANGLE_FAN&&(d.geometry=o(d.geometry,e.TriangleFanDrawMode));else if(h.mode===F.LINES)d=new e.LineSegments(r,p);else if(h.mode===F.LINE_STRIP)d=new e.Line(r,p);else if(h.mode===F.LINE_LOOP)d=new e.LineLoop(r,p);else{if(h.mode!==F.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);d=new e.Points(r,p)}Object.keys(d.geometry.morphAttributes).length>0&&J(d,s),d.name=n.createUniqueName(s.name||"mesh_"+t),Z(d,s),h.extensions&&$(i,d,h),n.assignFinalMaterial(d),l.push(d)}for(let e=0,i=l.length;e<i;e++)n.associations.set(l[e],{meshes:t,primitives:e});if(1===l.length)return s.extensions&&$(i,l[0],s),l[0];const h=new e.Group;s.extensions&&$(i,h,s),n.associations.set(h,{meshes:t});for(let e=0,t=l.length;e<t;e++)h.add(l[e]);return h}))}loadCamera(t){let n;const r=this.json.cameras[t],i=r[r.type];if(i)return"perspective"===r.type?n=new e.PerspectiveCamera(e.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===r.type&&(n=new e.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),r.name&&(n.name=this.createUniqueName(r.name)),Z(n,r),Promise.resolve(n)}loadSkin(t){const n=this.json.skins[t],r=[];for(let e=0,i=n.joints.length;e<i;e++)r.push(this._loadNodeShallow(n.joints[e]));return void 0!==n.inverseBindMatrices?r.push(this.getDependency("accessor",n.inverseBindMatrices)):r.push(null),Promise.all(r).then((function(t){const n=t.pop(),r=t,i=[],o=[];for(let s=0,a=r.length;s<a;s++){const t=r[s];if(t){i.push(t);const r=new e.Matrix4;null!==n&&r.fromArray(n.array,16*s),o.push(r)}}return new e.Skeleton(i,o)}))}loadAnimation(t){const n=this.json,r=this,i=n.animations[t],o=i.name?i.name:"animation_"+t,s=[],a=[],u=[],c=[],l=[];for(let e=0,h=i.channels.length;e<h;e++){const t=i.channels[e],n=i.samplers[t.sampler],r=t.target,o=r.node,h=void 0!==i.parameters?i.parameters[n.input]:n.input,f=void 0!==i.parameters?i.parameters[n.output]:n.output;void 0!==r.node&&(s.push(this.getDependency("node",o)),a.push(this.getDependency("accessor",h)),u.push(this.getDependency("accessor",f)),c.push(n),l.push(r))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(u),Promise.all(c),Promise.all(l)]).then((function(t){const n=t[0],i=t[1],s=t[2],a=t[3],u=t[4],c=[];for(let e=0,o=n.length;e<o;e++){const t=n[e],o=i[e],l=s[e],h=a[e],f=u[e];if(void 0===t)continue;t.updateMatrix&&t.updateMatrix();const d=r._createAnimationTracks(t,o,l,h,f);if(d)for(let e=0;e<d.length;e++)c.push(d[e])}return new e.AnimationClip(o,void 0,c)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this,n=this.json.nodes[e],r=t._loadNodeShallow(e),i=[],o=n.children||[];for(let a=0,u=o.length;a<u;a++)i.push(t.getDependency("node",o[a]));const s=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([r,Promise.all(i),s]).then((function(e){const t=e[0],n=e[1],r=e[2];null!==r&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(r,re)}));for(let i=0,o=n.length;i<o;i++)t.add(n[i]);return t}))}_loadNodeShallow(t){const n=this.json,r=this.extensions,i=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const o=n.nodes[t],s=o.name?i.createUniqueName(o.name):"",a=[],u=i._invokeOne((function(e){return e.createNodeMesh&&e.createNodeMesh(t)}));return u&&a.push(u),void 0!==o.camera&&a.push(i.getDependency("camera",o.camera).then((function(e){return i._getNodeRef(i.cameraCache,o.camera,e)}))),i._invokeAll((function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)})).forEach((function(e){a.push(e)})),this.nodeCache[t]=Promise.all(a).then((function(n){let a;if(a=!0===o.isBone?new e.Bone:n.length>1?new e.Group:1===n.length?n[0]:new e.Object3D,a!==n[0])for(let e=0,t=n.length;e<t;e++)a.add(n[e]);if(o.name&&(a.userData.name=o.name,a.name=s),Z(a,o),o.extensions&&$(r,a,o),void 0!==o.matrix){const t=new e.Matrix4;t.fromArray(o.matrix),a.applyMatrix4(t)}else void 0!==o.translation&&a.position.fromArray(o.translation),void 0!==o.rotation&&a.quaternion.fromArray(o.rotation),void 0!==o.scale&&a.scale.fromArray(o.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=t,a})),this.nodeCache[t]}loadScene(t){const n=this.extensions,r=this.json.scenes[t],i=this,o=new e.Group;r.name&&(o.name=i.createUniqueName(r.name)),Z(o,r),r.extensions&&$(n,o,r);const s=r.nodes||[],a=[];for(let e=0,u=s.length;e<u;e++)a.push(i.getDependency("node",s[e]));return Promise.all(a).then((function(t){for(let e=0,n=t.length;e<n;e++)o.add(t[e]);return i.associations=(t=>{const n=new Map;for(const[r,o]of i.associations)(r instanceof e.Material||r instanceof e.Texture)&&n.set(r,o);return t.traverse((e=>{const t=i.associations.get(e);null!=t&&n.set(e,t)})),n})(o),o}))}_createAnimationTracks(t,n,r,i,o){const s=[],a=t.name?t.name:t.uuid,u=[];let c;switch(V[o.path]===V.weights?t.traverse((function(e){e.morphTargetInfluences&&u.push(e.name?e.name:e.uuid)})):u.push(a),V[o.path]){case V.weights:c=e.NumberKeyframeTrack;break;case V.rotation:c=e.QuaternionKeyframeTrack;break;case V.translation:case V.scale:c=e.VectorKeyframeTrack;break;default:if(1===r.itemSize)c=e.NumberKeyframeTrack;else c=e.VectorKeyframeTrack}const l=void 0!==i.interpolation?X[i.interpolation]:e.InterpolateLinear,h=this._getArrayFromAccessor(r);for(let e=0,f=u.length;e<f;e++){const t=new c(u[e]+"."+V[o.path],n.array,h,l);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(t),s.push(t)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=ne(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(t){return new(this instanceof e.QuaternionKeyframeTrack?K:N)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function oe(t,n,r){const i=n.attributes,o=[];function s(e,n){return r.getDependency("accessor",e).then((function(e){t.setAttribute(n,e)}))}for(const e in i){const n=z[e]||e.toLowerCase();n in t.attributes||o.push(s(i[e],n))}if(void 0!==n.indices&&!t.index){const e=r.getDependency("accessor",n.indices).then((function(e){t.setIndex(e)}));o.push(e)}return e.ColorManagement.workingColorSpace,e.LinearSRGBColorSpace,Z(t,n),function(t,n,r){const i=n.attributes,o=new e.Box3;if(void 0===i.POSITION)return;{const t=r.json.accessors[i.POSITION],n=t.min,s=t.max;if(void 0===n||void 0===s)return;if(o.set(new e.Vector3(n[0],n[1],n[2]),new e.Vector3(s[0],s[1],s[2])),t.normalized){const e=ne(U[t.componentType]);o.min.multiplyScalar(e),o.max.multiplyScalar(e)}}const s=n.targets;if(void 0!==s){const t=new e.Vector3,n=new e.Vector3;for(let e=0,i=s.length;e<i;e++){const i=s[e];if(void 0!==i.POSITION){const e=r.json.accessors[i.POSITION],o=e.min,s=e.max;if(void 0!==o&&void 0!==s){if(n.setX(Math.max(Math.abs(o[0]),Math.abs(s[0]))),n.setY(Math.max(Math.abs(o[1]),Math.abs(s[1]))),n.setZ(Math.max(Math.abs(o[2]),Math.abs(s[2]))),e.normalized){const t=ne(U[e.componentType]);n.multiplyScalar(t)}t.max(n)}}}o.expandByVector(t)}t.boundingBox=o;const a=new e.Sphere;o.getCenter(a.center),a.radius=o.min.distanceTo(o.max)/2,t.boundingSphere=a}(t,n,r),Promise.all(o).then((function(){return void 0!==n.targets?function(e,t,n){let r=!1,i=!1,o=!1;for(let c=0,l=t.length;c<l;c++){const e=t[c];if(void 0!==e.POSITION&&(r=!0),void 0!==e.NORMAL&&(i=!0),void 0!==e.COLOR_0&&(o=!0),r&&i&&o)break}if(!r&&!i&&!o)return Promise.resolve(e);const s=[],a=[],u=[];for(let c=0,l=t.length;c<l;c++){const l=t[c];if(r){const t=void 0!==l.POSITION?n.getDependency("accessor",l.POSITION):e.attributes.position;s.push(t)}if(i){const t=void 0!==l.NORMAL?n.getDependency("accessor",l.NORMAL):e.attributes.normal;a.push(t)}if(o){const t=void 0!==l.COLOR_0?n.getDependency("accessor",l.COLOR_0):e.attributes.color;u.push(t)}}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(u)]).then((function(t){const n=t[0],s=t[1],a=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=s),o&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(t,n.targets,r):t}))}const se={c:null,u:[new e.Vector3,new e.Vector3,new e.Vector3],e:[]},ae={c:null,u:[new e.Vector3,new e.Vector3,new e.Vector3],e:[]},ue=[[],[],[]],ce=[[],[],[]],le=[],he=new e.Vector3,fe=new e.Vector3,de=new e.Vector3,pe=new e.Vector3,me=new e.Vector3,ye=new e.Vector3,ve=new e.Matrix3,ge=new e.Box3,be=new e.Matrix4,we=new e.Matrix4,_e=new e.Ray;class xe{constructor(t=new e.Vector3,n=new e.Vector3,r=new e.Matrix3){this.center=t,this.halfSize=n,this.rotation=r}set(e,t,n){return this.center=e,this.halfSize=t,this.rotation=n,this}copy(e){return this.center.copy(e.center),this.halfSize.copy(e.halfSize),this.rotation.copy(e.rotation),this}clone(){return(new this.constructor).copy(this)}getSize(e){return e.copy(this.halfSize).multiplyScalar(2)}clampPoint(t,n){const r=this.halfSize;pe.subVectors(t,this.center),this.rotation.extractBasis(he,fe,de),n.copy(this.center);const i=e.MathUtils.clamp(pe.dot(he),-r.x,r.x);n.add(he.multiplyScalar(i));const o=e.MathUtils.clamp(pe.dot(fe),-r.y,r.y);n.add(fe.multiplyScalar(o));const s=e.MathUtils.clamp(pe.dot(de),-r.z,r.z);return n.add(de.multiplyScalar(s)),n}containsPoint(e){return pe.subVectors(e,this.center),this.rotation.extractBasis(he,fe,de),Math.abs(pe.dot(he))<=this.halfSize.x&&Math.abs(pe.dot(fe))<=this.halfSize.y&&Math.abs(pe.dot(de))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(Ae.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,ye),ye.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,t=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]),ae.c=e.center,ae.e[0]=e.halfSize.x,ae.e[1]=e.halfSize.y,ae.e[2]=e.halfSize.z,e.rotation.extractBasis(ae.u[0],ae.u[1],ae.u[2]);for(let i=0;i<3;i++)for(let e=0;e<3;e++)ue[i][e]=se.u[i].dot(ae.u[e]);pe.subVectors(ae.c,se.c),le[0]=pe.dot(se.u[0]),le[1]=pe.dot(se.u[1]),le[2]=pe.dot(se.u[2]);for(let i=0;i<3;i++)for(let e=0;e<3;e++)ce[i][e]=Math.abs(ue[i][e])+t;let n,r;for(let i=0;i<3;i++)if(n=se.e[i],r=ae.e[0]*ce[i][0]+ae.e[1]*ce[i][1]+ae.e[2]*ce[i][2],Math.abs(le[i])>n+r)return!1;for(let i=0;i<3;i++)if(n=se.e[0]*ce[0][i]+se.e[1]*ce[1][i]+se.e[2]*ce[2][i],r=ae.e[i],Math.abs(le[0]*ue[0][i]+le[1]*ue[1][i]+le[2]*ue[2][i])>n+r)return!1;return n=se.e[1]*ce[2][0]+se.e[2]*ce[1][0],r=ae.e[1]*ce[0][2]+ae.e[2]*ce[0][1],!(Math.abs(le[2]*ue[1][0]-le[1]*ue[2][0])>n+r)&&(n=se.e[1]*ce[2][1]+se.e[2]*ce[1][1],r=ae.e[0]*ce[0][2]+ae.e[2]*ce[0][0],!(Math.abs(le[2]*ue[1][1]-le[1]*ue[2][1])>n+r)&&(n=se.e[1]*ce[2][2]+se.e[2]*ce[1][2],r=ae.e[0]*ce[0][1]+ae.e[1]*ce[0][0],!(Math.abs(le[2]*ue[1][2]-le[1]*ue[2][2])>n+r)&&(n=se.e[0]*ce[2][0]+se.e[2]*ce[0][0],r=ae.e[1]*ce[1][2]+ae.e[2]*ce[1][1],!(Math.abs(le[0]*ue[2][0]-le[2]*ue[0][0])>n+r)&&(n=se.e[0]*ce[2][1]+se.e[2]*ce[0][1],r=ae.e[0]*ce[1][2]+ae.e[2]*ce[1][0],!(Math.abs(le[0]*ue[2][1]-le[2]*ue[0][1])>n+r)&&(n=se.e[0]*ce[2][2]+se.e[2]*ce[0][2],r=ae.e[0]*ce[1][1]+ae.e[1]*ce[1][0],!(Math.abs(le[0]*ue[2][2]-le[2]*ue[0][2])>n+r)&&(n=se.e[0]*ce[1][0]+se.e[1]*ce[0][0],r=ae.e[1]*ce[2][2]+ae.e[2]*ce[2][1],!(Math.abs(le[1]*ue[0][0]-le[0]*ue[1][0])>n+r)&&(n=se.e[0]*ce[1][1]+se.e[1]*ce[0][1],r=ae.e[0]*ce[2][2]+ae.e[2]*ce[2][0],!(Math.abs(le[1]*ue[0][1]-le[0]*ue[1][1])>n+r)&&(n=se.e[0]*ce[1][2]+se.e[1]*ce[0][2],r=ae.e[0]*ce[2][1]+ae.e[1]*ce[2][0],!(Math.abs(le[1]*ue[0][2]-le[0]*ue[1][2])>n+r)))))))))}intersectsPlane(e){this.rotation.extractBasis(he,fe,de);const t=this.halfSize.x*Math.abs(e.normal.dot(he))+this.halfSize.y*Math.abs(e.normal.dot(fe))+this.halfSize.z*Math.abs(e.normal.dot(de)),n=e.normal.dot(this.center)-e.constant;return Math.abs(n)<=t}intersectRay(e,t){return this.getSize(me),ge.setFromCenterAndSize(pe.set(0,0,0),me),be.setFromMatrix3(this.rotation),be.setPosition(this.center),we.copy(be).invert(),_e.copy(e).applyMatrix4(we),_e.intersectBox(ge,t)?t.applyMatrix4(be):null}intersectsRay(e){return null!==this.intersectRay(e,pe)}fromBox3(e){return e.getCenter(this.center),e.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(e){return e.center.equals(this.center)&&e.halfSize.equals(this.halfSize)&&e.rotation.equals(this.rotation)}applyMatrix4(e){const t=e.elements;let n=pe.set(t[0],t[1],t[2]).length();const r=pe.set(t[4],t[5],t[6]).length(),i=pe.set(t[8],t[9],t[10]).length();e.determinant()<0&&(n=-n),ve.setFromMatrix4(e);const o=1/n,s=1/r,a=1/i;return ve.elements[0]*=o,ve.elements[1]*=o,ve.elements[2]*=o,ve.elements[3]*=s,ve.elements[4]*=s,ve.elements[5]*=s,ve.elements[6]*=a,ve.elements[7]*=a,ve.elements[8]*=a,this.rotation.multiply(ve),this.halfSize.x*=n,this.halfSize.y*=r,this.halfSize.z*=i,pe.setFromMatrixPosition(e),this.center.add(pe),this}}const Ae=new xe,Te={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:e.MathUtils.degToRad(60)};const Se=[],Re=new e.Color(16711680);var Ee="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ke(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Me,Oe={exports:{}};const Pe=ke((Me||(Me=1,Oe.exports=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)},t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function n(e,t,n){for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||((r=r||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Ee,i=Object.keys,o=Array.isArray;function s(e,t){return"object"!=typeof t||i(t).forEach((function(n){e[n]=t[n]})),e}"undefined"==typeof Promise||r.Promise||(r.Promise=Promise);var a=Object.getPrototypeOf,u={}.hasOwnProperty;function c(e,t){return u.call(e,t)}function l(e,t){"function"==typeof t&&(t=t(a(e))),("undefined"==typeof Reflect?i:Reflect.ownKeys)(t).forEach((function(n){f(e,n,t[n])}))}var h=Object.defineProperty;function f(e,t,n,r){h(e,t,s(n&&c(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function d(e){return{from:function(t){return e.prototype=Object.create(t.prototype),f(e.prototype,"constructor",e),{extend:l.bind(null,e.prototype)}}}}var p=Object.getOwnPropertyDescriptor,m=[].slice;function y(e,t,n){return m.call(e,t,n)}function v(e,t){return t(e)}function g(e){if(!e)throw new Error("Assertion Failed")}function b(e){r.setImmediate?setImmediate(e):setTimeout(e,0)}function w(e,t){if("string"==typeof t&&c(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,i=t.length;r<i;++r){var o=w(e,t[r]);n.push(o)}return n}var s=t.indexOf(".");if(-1!==s){var a=e[t.substr(0,s)];return null==a?void 0:w(a,t.substr(s+1))}}function _(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){g("string"!=typeof n&&"length"in n);for(var r=0,i=t.length;r<i;++r)_(e,t[r],n[r])}else{var s,a,u=t.indexOf(".");-1!==u?(s=t.substr(0,u),""===(a=t.substr(u+1))?void 0===n?o(e)&&!isNaN(parseInt(s))?e.splice(s,1):delete e[s]:e[s]=n:_(u=(u=e[s])&&c(e,s)?u:e[s]={},a,n)):void 0===n?o(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function x(e){var t,n={};for(t in e)c(e,t)&&(n[t]=e[t]);return n}var A=[].concat;function T(e){return A.apply([],e)}var S="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(T([8,16,32,64].map((function(e){return["Int","Uint","Float"].map((function(t){return t+e+"Array"}))})))).filter((function(e){return r[e]})),R=new Set(S.map((function(e){return r[e]}))),E=null;function k(e){return E=new WeakMap,e=function e(t){if(!t||"object"!=typeof t)return t;var n=E.get(t);if(n)return n;if(o(t)){n=[],E.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(R.has(t.constructor))n=t;else{var s,u=a(t);for(s in n=u===Object.prototype?{}:Object.create(u),E.set(t,n),t)c(t,s)&&(n[s]=e(t[s]))}return n}(e),E=null,e}var M={}.toString;function O(e){return M.call(e).slice(8,-1)}var P="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",C="symbol"==typeof P?function(e){var t;return null!=e&&(t=e[P])&&t.apply(e)}:function(){return null};function I(e,t){return 0<=(t=e.indexOf(t))&&e.splice(t,1),0<=t}var L={};function D(e){var t,n,r,i;if(1===arguments.length){if(o(e))return e.slice();if(this===L&&"string"==typeof e)return[e];if(i=C(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))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 B="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},N=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(ae=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"]),j={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 K(e,t){this.name=e,this.message=t}function F(e,t){return e+". Errors: "+Object.keys(t).map((function(e){return t[e].toString()})).filter((function(e,t,n){return n.indexOf(e)===t})).join("\n")}function U(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=F(e,t)}function q(e,t){this.name="BulkError",this.failures=Object.keys(t).map((function(e){return t[e]})),this.failuresByPos=t,this.message=F(e,this.failures)}d(K).from(Error).extend({toString:function(){return this.name+": "+this.message}}),d(U).from(K),d(q).from(K);var H=N.reduce((function(e,t){return e[t]=t+"Error",e}),{}),G=K,z=N.reduce((function(e,t){var n=t+"Error";function r(e,r){this.name=n,e?"string"==typeof e?(this.message="".concat(e).concat(r?"\n "+r:""),this.inner=r||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=j[t]||n,this.inner=null)}return d(r).from(G),e[t]=r,e}),{});z.Syntax=SyntaxError,z.Type=TypeError,z.Range=RangeError;var V=ae.reduce((function(e,t){return e[t+"Error"]=z[t],e}),{}),X=N.reduce((function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=z[t]),e}),{});function W(){}function Y(e){return e}function Q(e,t){return null==e||e===Y?t:function(n){return t(e(n))}}function $(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function Z(e,t){return e===W?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?$(r,this.onsuccess):r),i&&(this.onerror=this.onerror?$(i,this.onerror):i),void 0!==o?o:n}}function J(e,t){return e===W?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?$(n,this.onsuccess):n),r&&(this.onerror=this.onerror?$(r,this.onerror):r)}}function ee(e,t){return e===W?t:function(n){var r=e.apply(this,arguments);s(n,r);var i=this.onsuccess,o=this.onerror;return this.onsuccess=null,this.onerror=null,n=t.apply(this,arguments),i&&(this.onsuccess=this.onsuccess?$(i,this.onsuccess):i),o&&(this.onerror=this.onerror?$(o,this.onerror):o),void 0===r?void 0===n?void 0:n:s(r,n)}}function te(e,t){return e===W?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ne(e,t){return e===W?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return n.then((function(){return t.apply(r,o)}))}return t.apply(this,arguments)}}X.ModifyError=U,X.DexieError=K,X.BulkError=q;var re="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function ie(e){re=e}var oe={},se=100,ae=(S="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,a(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,a(t),e]}())[0],ue=(N=S[1],S=S[2],N=N&&N.then,ae&&ae.constructor),ce=!!S,le=function(e,t){ge.push([e,t]),fe&&(queueMicrotask(Me),fe=!1)},he=!0,fe=!0,de=[],pe=[],me=Y,ye={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:W,pgp:!1,env:{},finalize:W},ve=ye,ge=[],be=0,we=[];function _e(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=ve;if("function"!=typeof e){if(e!==oe)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Te(this,this._value))}this._state=null,this._value=null,++t.ref,function e(t,n){try{n((function(n){if(null===t._state){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&Oe();n&&"function"==typeof n.then?e(t,(function(e,t){n instanceof _e?n._then(e,t):n.then(e,t)})):(t._state=!0,t._value=n,Se(t)),r&&Pe()}}),Te.bind(null,t))}catch(r){Te(t,r)}}(this,e)}var xe={get:function(){var e=ve,t=Ke;function n(n,r){var i=this,o=!e.global&&(e!==ve||t!==Ke),s=o&&!He(),a=new _e((function(t,a){Re(i,new Ae(Ye(n,e,o,s),Ye(r,e,o,s),t,a,e))}));return this._consoleTask&&(a._consoleTask=this._consoleTask),a}return n.prototype=oe,n},set:function(e){f(this,"then",e&&e.prototype===oe?xe:{get:function(){return e},set:xe.set})}};function Ae(e,t,n,r,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=i}function Te(e,t){var n,r;pe.push(t),null===e._state&&(n=e._lib&&Oe(),t=me(t),e._state=!1,e._value=t,r=e,de.some((function(e){return e._value===r._value}))||de.push(r),Se(e),n&&Pe())}function Se(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Re(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===be&&(++be,le((function(){0==--be&&Ce()}),[]))}function Re(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++be,le(ke,[n,e,t])}else e._listeners.push(t)}function ke(e,t,n){try{var r,i=t._value;!t._state&&pe.length&&(pe=[]),r=re&&t._consoleTask?t._consoleTask.run((function(){return e(i)})):e(i),t._state||-1!==pe.indexOf(i)||function(e){for(var t=de.length;t;)if(de[--t]._value===e._value)return de.splice(t,1)}(t),n.resolve(r)}catch(o){n.reject(o)}finally{0==--be&&Ce(),--n.psd.ref||n.psd.finalize()}}function Me(){We(ye,(function(){Oe()&&Pe()}))}function Oe(){var e=he;return fe=he=!1,e}function Pe(){var e,t,n;do{for(;0<ge.length;)for(e=ge,ge=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<ge.length);fe=he=!0}function Ce(){var e=de;de=[],e.forEach((function(e){e._PSD.onunhandled.call(null,e._value,e)}));for(var t=we.slice(0),n=t.length;n;)t[--n]()}function Ie(e){return new _e(oe,!1,e)}function Le(e,t){var n=ve;return function(){var r=Oe(),i=ve;try{return Ve(n,!0),e.apply(this,arguments)}catch(o){t&&t(o)}finally{Ve(i,!1),r&&Pe()}}}l(_e.prototype,{then:xe,_then:function(e,t){Re(this,new Ae(null,null,e,t,ve))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=e,n=arguments[1];return"function"==typeof t?this.then(null,(function(e){return(e instanceof t?n:Ie)(e)})):this.then(null,(function(e){return(e&&e.name===t?n:Ie)(e)}))},finally:function(e){return this.then((function(t){return _e.resolve(e()).then((function(){return t}))}),(function(t){return _e.resolve(e()).then((function(){return Ie(t)}))}))},timeout:function(e,t){var n=this;return e<1/0?new _e((function(r,i){var o=setTimeout((function(){return i(new z.Timeout(t))}),e);n.then(r,i).finally(clearTimeout.bind(null,o))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&f(_e.prototype,Symbol.toStringTag,"Dexie.Promise"),ye.env=Xe(),l(_e,{all:function(){var e=D.apply(null,arguments).map(Ge);return new _e((function(t,n){0===e.length&&t([]);var r=e.length;e.forEach((function(i,o){return _e.resolve(i).then((function(n){e[o]=n,--r||t(e)}),n)}))}))},resolve:function(e){return e instanceof _e?e:e&&"function"==typeof e.then?new _e((function(t,n){e.then(t,n)})):new _e(oe,!0,e)},reject:Ie,race:function(){var e=D.apply(null,arguments).map(Ge);return new _e((function(t,n){e.map((function(e){return _e.resolve(e).then(t,n)}))}))},PSD:{get:function(){return ve},set:function(e){return ve=e}},totalEchoes:{get:function(){return Ke}},newPSD:Ue,usePSD:We,scheduler:{get:function(){return le},set:function(e){le=e}},rejectionMapper:{get:function(){return me},set:function(e){me=e}},follow:function(e,t){return new _e((function(n,r){return Ue((function(t,n){var r=ve;r.unhandleds=[],r.onunhandled=n,r.finalize=$((function(){var e,r=this;e=function(){0===r.unhandleds.length?t():n(r.unhandleds[0])},we.push((function t(){e(),we.splice(we.indexOf(t),1)})),++be,le((function(){0==--be&&Ce()}),[])}),r.finalize),e()}),t,n,r)}))}}),ue&&(ue.allSettled&&f(_e,"allSettled",(function(){var e=D.apply(null,arguments).map(Ge);return new _e((function(t){0===e.length&&t([]);var n=e.length,r=new Array(n);e.forEach((function(e,i){return _e.resolve(e).then((function(e){return r[i]={status:"fulfilled",value:e}}),(function(e){return r[i]={status:"rejected",reason:e}})).then((function(){return--n||t(r)}))}))}))})),ue.any&&"undefined"!=typeof AggregateError&&f(_e,"any",(function(){var e=D.apply(null,arguments).map(Ge);return new _e((function(t,n){0===e.length&&n(new AggregateError([]));var r=e.length,i=new Array(r);e.forEach((function(e,o){return _e.resolve(e).then((function(e){return t(e)}),(function(e){i[o]=e,--r||n(new AggregateError(i))}))}))}))})),ue.withResolvers&&(_e.withResolvers=ue.withResolvers));var De={awaits:0,echoes:0,id:0},Be=0,Ne=[],je=0,Ke=0,Fe=0;function Ue(e,t,n,r){var i=ve,o=Object.create(i);return o.parent=i,o.ref=0,o.global=!1,o.id=++Fe,ye.env,o.env=ce?{Promise:_e,PromiseProp:{value:_e,configurable:!0,writable:!0},all:_e.all,race:_e.race,allSettled:_e.allSettled,any:_e.any,resolve:_e.resolve,reject:_e.reject}:{},t&&s(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()},r=We(o,e,n,r),0===o.ref&&o.finalize(),r}function qe(){return De.id||(De.id=++Be),++De.awaits,De.echoes+=se,De.id}function He(){return!!De.awaits&&(0==--De.awaits&&(De.id=0),De.echoes=De.awaits*se,!0)}function Ge(e){return De.echoes&&e&&e.constructor===ue?(qe(),e.then((function(e){return He(),e}),(function(e){return He(),$e(e)}))):e}function ze(){var e=Ne[Ne.length-1];Ne.pop(),Ve(e,!1)}function Ve(e,t){var n,i=ve;(t?!De.echoes||je++&&e===ve:!je||--je&&e===ve)||queueMicrotask(t?function(e){++Ke,De.echoes&&0!=--De.echoes||(De.echoes=De.awaits=De.id=0),Ne.push(ve),Ve(e,!0)}.bind(null,e):ze),e!==ve&&(ve=e,i===ye&&(ye.env=Xe()),ce&&(n=ye.env.Promise,t=e.env,(i.global||e.global)&&(Object.defineProperty(r,"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 Xe(){var e=r.Promise;return ce?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(r,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function We(e,t,n,r,i){var o=ve;try{return Ve(e,!0),t(n,r,i)}finally{Ve(o,!1)}}function Ye(e,t,n,r){return"function"!=typeof e?e:function(){var i=ve;n&&qe(),Ve(t,!0);try{return e.apply(this,arguments)}finally{Ve(i,!1),r&&queueMicrotask(He)}}}function Qe(e){Promise===ue&&0===De.echoes?0===je?e():enqueueNativeMicroTask(e):setTimeout(e,0)}-1===(""+N).indexOf("[native code]")&&(qe=He=W);var $e=_e.reject,Ze=String.fromCharCode(65535),Je="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",et="String expected.",tt=[],nt="__dbnames",rt="readonly",it="readwrite";function ot(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var st={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function at(e){return"string"!=typeof e||/\./.test(e)?function(e){return e}:function(t){return void 0===t[e]&&e in t&&delete(t=k(t))[e],t}}function ut(){throw z.Type()}function ct(e,t){try{var n=lt(e),r=lt(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o)if(e[o]!==t[o])return e[o]<t[o]?-1:1;return n===r?0:n<r?-1:1}(ht(e),ht(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o){var s=ct(e[o],t[o]);if(0!==s)return s}return n===r?0:n<r?-1:1}(e,t)}}catch(i){}return NaN}function lt(e){var t=typeof e;return"object"!=t?t:ArrayBuffer.isView(e)||"ArrayBuffer"===(e=O(e))?"binary":e}function ht(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var ft=(dt.prototype._trans=function(e,t,n){var r=this._tx||ve.trans,i=this.name,o=re&&"undefined"!=typeof console&&console.createTask&&void 0;function s(e,n,r){if(!r.schema[i])throw new z.NotFound("Table "+i+" not part of transaction");return t(r.idbtrans,r)}var a=Oe();try{var u=r&&r.db._novip===this.db._novip?r===ve.trans?r._promise(e,s,n):Ue((function(){return r._promise(e,s,n)}),{trans:r,transless:ve.transless||ve}):function e(t,n,r,i){if(t.idbdb&&(t._state.openComplete||ve.letThrough||t._vip)){var o=t._createTransaction(n,r,t._dbSchema);try{o.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===H.InvalidState&&t.isOpen()&&0<--t._state.PR1398_maxLoop?(t.close({disableAutoOpen:!1}),t.open().then((function(){return e(t,n,r,i)}))):$e(s)}return o._promise(n,(function(e,t){return Ue((function(){return ve.trans=o,i(e,t,o)}))})).then((function(e){if("readwrite"===n)try{o.idbtrans.commit()}catch(t){}return"readonly"===n?e:o._completion.then((function(){return e}))}))}if(t._state.openComplete)return $e(new z.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return $e(new z.DatabaseClosed);t.open().catch(W)}return t._state.dbReadyPromise.then((function(){return e(t,n,r,i)}))}(this.db,e,[this.name],s);return o&&(u._consoleTask=o,u=u.catch((function(e){return $e(e)}))),u}finally{a&&Pe()}},dt.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):null==e?$e(new z.Type("Invalid argument to Table.get()")):this._trans("readonly",(function(t){return n.core.get({trans:t,key:e}).then((function(e){return n.hook.reading.fire(e)}))})).then(t)},dt.prototype.where=function(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(o(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=i(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter((function(e){if(e.compound&&t.every((function(t){return 0<=e.keyPath.indexOf(t)}))){for(var n=0;n<t.length;++n)if(-1===t.indexOf(e.keyPath[n]))return!1;return!0}return!1})).sort((function(e,t){return e.keyPath.length-t.keyPath.length}))[0];if(n&&this.db._maxKey!==Ze){var r=n.keyPath.slice(0,t.length);return this.where(r).equals(r.map((function(t){return e[t]})))}var s=this.schema.idxByName;function a(e,t){return 0===ct(e,t)}r=(u=t.reduce((function(t,n){var r=t[0],i=t[1],u=(t=s[n],e[n]);return[r||t,r||!t?ot(i,t&&t.multi?function(e){return e=w(e,n),o(e)&&e.some((function(e){return a(u,e)}))}:function(e){return a(u,w(e,n))}):i]}),[null,null]))[0];var u=u[1];return r?this.where(r.name).equals(e[r.keyPath]).filter(u):n?this.filter(u):this.where(t).equals("")},dt.prototype.filter=function(e){return this.toCollection().and(e)},dt.prototype.count=function(e){return this.toCollection().count(e)},dt.prototype.offset=function(e){return this.toCollection().offset(e)},dt.prototype.limit=function(e){return this.toCollection().limit(e)},dt.prototype.each=function(e){return this.toCollection().each(e)},dt.prototype.toArray=function(e){return this.toCollection().toArray(e)},dt.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},dt.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,o(e)?"[".concat(e.join("+"),"]"):e))},dt.prototype.reverse=function(){return this.toCollection().reverse()},dt.prototype.mapToClass=function(t){var n,r=this.db,i=this.name;function o(){return null!==n&&n.apply(this,arguments)||this}(this.schema.mappedClass=t).prototype instanceof ut&&(function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(o,n=t),Object.defineProperty(o.prototype,"db",{get:function(){return r},enumerable:!1,configurable:!0}),o.prototype.table=function(){return i},t=o);for(var s=new Set,u=t.prototype;u;u=a(u))Object.getOwnPropertyNames(u).forEach((function(e){return s.add(e)}));function c(e){if(!e)return e;var n,r=Object.create(t.prototype);for(n in e)if(!s.has(n))try{r[n]=e[n]}catch(i){}return r}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=c,this.hook("reading",c),t},dt.prototype.defineClass=function(){return this.mapToClass((function(e){s(this,e)}))},dt.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,s=e;return o&&i&&(s=at(o)(e)),this._trans("readwrite",(function(e){return n.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[s]})})).then((function(e){return e.numFailures?_e.reject(e.failures[0]):e.lastResult})).then((function(t){if(o)try{_(e,o,t)}catch(n){}return t}))},dt.prototype.update=function(e,t){return"object"!=typeof e||o(e)?this.where(":id").equals(e).modify(t):void 0===(e=w(e,this.schema.primKey.keyPath))?$e(new z.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)},dt.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,s=e;return o&&i&&(s=at(o)(e)),this._trans("readwrite",(function(e){return n.core.mutate({trans:e,type:"put",values:[s],keys:null!=t?[t]:null})})).then((function(e){return e.numFailures?_e.reject(e.failures[0]):e.lastResult})).then((function(t){if(o)try{_(e,o,t)}catch(n){}return t}))},dt.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(e){return e.numFailures?_e.reject(e.failures[0]):void 0}))},dt.prototype.clear=function(){var e=this;return this._trans("readwrite",(function(t){return e.core.mutate({trans:t,type:"deleteRange",range:st})})).then((function(e){return e.numFailures?_e.reject(e.failures[0]):void 0}))},dt.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",(function(n){return t.core.getMany({keys:e,trans:n}).then((function(e){return e.map((function(e){return t.hook.reading.fire(e)}))}))}))},dt.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(function(t){var n=(a=r.schema.primKey).auto;if((a=a.keyPath)&&i)throw new z.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new z.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length,a=a&&n?e.map(at(a)):e;return r.core.mutate({trans:t,type:"add",keys:i,values:a,wantResults:o}).then((function(e){var t=e.numFailures,n=e.results,i=e.lastResult;if(e=e.failures,0===t)return o?n:i;throw new q("".concat(r.name,".bulkAdd(): ").concat(t," of ").concat(s," operations failed"),e)}))}))},dt.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(function(t){var n=(a=r.schema.primKey).auto;if((a=a.keyPath)&&i)throw new z.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new z.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length,a=a&&n?e.map(at(a)):e;return r.core.mutate({trans:t,type:"put",keys:i,values:a,wantResults:o}).then((function(e){var t=e.numFailures,n=e.results,i=e.lastResult;if(e=e.failures,0===t)return o?n:i;throw new q("".concat(r.name,".bulkPut(): ").concat(t," of ").concat(s," operations failed"),e)}))}))},dt.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map((function(e){return e.key})),i=e.map((function(e){return e.changes})),o=[];return this._trans("readwrite",(function(s){return n.getMany({trans:s,keys:r,cache:"clone"}).then((function(a){var u=[],c=[];e.forEach((function(e,n){var r=e.key,i=e.changes,s=a[n];if(s){for(var l=0,h=Object.keys(i);l<h.length;l++){var f=h[l],d=i[f];if(f===t.schema.primKey.keyPath){if(0!==ct(d,r))throw new z.Constraint("Cannot update primary key in bulkUpdate()")}else _(s,f,d)}o.push(n),u.push(r),c.push(s)}}));var l=u.length;return n.mutate({trans:s,type:"put",keys:u,values:c,updates:{keys:r,changeSpecs:i}}).then((function(e){var n=e.numFailures,r=e.failures;if(0===n)return l;for(var i=0,s=Object.keys(r);i<s.length;i++){var a,u=s[i],c=o[Number(u)];null!=c&&(a=r[u],delete r[u],r[c]=a)}throw new q("".concat(t.name,".bulkUpdate(): ").concat(n," of ").concat(l," operations failed"),r)}))}))}))},dt.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",(function(n){return t.core.mutate({trans:n,type:"delete",keys:e})})).then((function(e){var r=e.numFailures,i=e.lastResult;if(e=e.failures,0===r)return i;throw new q("".concat(t.name,".bulkDelete(): ").concat(r," of ").concat(n," operations failed"),e)}))},dt);function dt(){}function pt(e){function t(t,r){if(r){for(var i=arguments.length,o=new Array(i-1);--i;)o[i-1]=arguments[i];return n[t].subscribe.apply(null,o),e}if("string"==typeof t)return n[t]}var n={};t.addEventType=a;for(var r=1,s=arguments.length;r<s;++r)a(arguments[r]);return t;function a(e,r,s){if("object"!=typeof e){var u;r=r||te;var c={subscribers:[],fire:s=s||W,subscribe:function(e){-1===c.subscribers.indexOf(e)&&(c.subscribers.push(e),c.fire=r(c.fire,e))},unsubscribe:function(e){c.subscribers=c.subscribers.filter((function(t){return t!==e})),c.fire=c.subscribers.reduce(r,s)}};return n[e]=t[e]=c}i(u=e).forEach((function(e){var t=u[e];if(o(t))a(e,u[e][0],u[e][1]);else{if("asap"!==t)throw new z.InvalidArgument("Invalid event config");var n=a(e,Y,(function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach((function(e){b((function(){e.apply(null,t)}))}))}))}}))}}function mt(e,t){return d(t).from({prototype:e}),t}function yt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function vt(e,t){e.filter=ot(e.filter,t)}function gt(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return ot(r(),t())}:t,e.justLimit=n&&!r}function bt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new z.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function wt(e,t,n){var r=bt(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function _t(e,t,n,r){var i=e.replayFilter?ot(e.filter,e.replayFilter()):e.filter;if(e.or){var o={},s=function(e,n,r){var s,a;i&&!i(n,r,(function(e){return n.stop(e)}),(function(e){return n.fail(e)}))||("[object ArrayBuffer]"==(a=""+(s=n.primaryKey))&&(a=""+new Uint8Array(s)),c(o,a)||(o[a]=!0,t(e,n,r)))};return Promise.all([e.or._iterate(s,n),xt(wt(e,r,n),e.algorithm,s,!e.keysOnly&&e.valueMapper)])}return xt(wt(e,r,n),ot(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function xt(e,t,n,r){var i=Le(r?function(e,t,i){return n(r(e),t,i)}:n);return e.then((function(e){if(e)return e.start((function(){var n=function(){return e.continue()};t&&!t(e,(function(e){return n=e}),(function(t){e.stop(t),n=W}),(function(t){e.fail(t),n=W}))||i(e.value,e,(function(e){return n=e})),n()}))}))}var At=(Tt.prototype.execute=function(e){var t=this["@@propmod"];if(void 0!==t.add){var r=t.add;if(o(r))return n(n([],o(e)?e:[],!0),r).sort();if("number"==typeof r)return(Number(e)||0)+r;if("bigint"==typeof r)try{return BigInt(e)+r}catch(s){return BigInt(0)+r}throw new TypeError("Invalid term ".concat(r))}if(void 0!==t.remove){var i=t.remove;if(o(i))return o(e)?e.filter((function(e){return!i.includes(e)})).sort():[];if("number"==typeof i)return Number(e)-i;if("bigint"==typeof i)try{return BigInt(e)-i}catch(s){return BigInt(0)-i}throw new TypeError("Invalid subtrahend ".concat(i))}return(r=null===(r=t.replacePrefix)||void 0===r?void 0:r[0])&&"string"==typeof e&&e.startsWith(r)?t.replacePrefix[1]+e.substring(r.length):e},Tt);function Tt(e){this["@@propmod"]=e}var St=(Rt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,$e.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Rt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,$e.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Rt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=ot(t.algorithm,e)},Rt.prototype._iterate=function(e,t){return _t(this._ctx,e,t,this._ctx.table.core)},Rt.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&s(n,e),t._ctx=n,t},Rt.prototype.raw=function(){return this._ctx.valueMapper=null,this},Rt.prototype.each=function(e){var t=this._ctx;return this._read((function(n){return _t(t,e,n,t.table.core)}))},Rt.prototype.count=function(e){var t=this;return this._read((function(e){var n=t._ctx,r=n.table.core;if(yt(n,!0))return r.count({trans:e,query:{index:bt(n,r.schema),range:n.range}}).then((function(e){return Math.min(e,n.limit)}));var i=0;return _t(n,(function(){return++i,!1}),e,r).then((function(){return i}))})).then(e)},Rt.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],i=n.length-1;function o(e,t){return t?o(e[n[t]],t-1):e[r]}var s="next"===this._ctx.dir?1:-1;function a(e,t){return ct(o(e,i),o(t,i))*s}return this.toArray((function(e){return e.sort(a)})).then(t)},Rt.prototype.toArray=function(e){var t=this;return this._read((function(e){var n=t._ctx;if("next"===n.dir&&yt(n,!0)&&0<n.limit){var r=n.valueMapper,i=bt(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then((function(e){return e=e.result,r?e.map(r):e}))}var o=[];return _t(n,(function(e){return o.push(e)}),e,n.table.core).then((function(){return o}))}),e)},Rt.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,yt(t)?gt(t,(function(){var t=e;return function(e,n){return 0===t||(1===t?--t:n((function(){e.advance(t),t=0})),!1)}})):gt(t,(function(){var t=e;return function(){return--t<0}}))),this},Rt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),gt(this._ctx,(function(){var t=e;return function(e,n,r){return--t<=0&&n(r),0<=t}}),!0),this},Rt.prototype.until=function(e,t){return vt(this._ctx,(function(n,r,i){return!e(n.value)||(r(i),t)})),this},Rt.prototype.first=function(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)},Rt.prototype.last=function(e){return this.reverse().first(e)},Rt.prototype.filter=function(e){var t;return vt(this._ctx,(function(t){return e(t.value)})),(t=this._ctx).isMatch=ot(t.isMatch,e),this},Rt.prototype.and=function(e){return this.filter(e)},Rt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Rt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Rt.prototype.desc=function(){return this.reverse()},Rt.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.key,n)}))},Rt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Rt.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.primaryKey,n)}))},Rt.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.key)})).then((function(){return n})).then(e)},Rt.prototype.primaryKeys=function(e){var t=this._ctx;if("next"===t.dir&&yt(t,!0)&&0<t.limit)return this._read((function(e){var n=bt(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})})).then((function(e){return e.result})).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.primaryKey)})).then((function(){return n})).then(e)},Rt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Rt.prototype.firstKey=function(e){return this.limit(1).keys((function(e){return e[0]})).then(e)},Rt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Rt.prototype.distinct=function(){var e;if(!(e=(e=this._ctx).index&&e.table.schema.idxByName[e.index])||!e.multi)return this;var t={};return vt(this._ctx,(function(e){var n=e.primaryKey.toString();return e=c(t,n),t[n]=!0,!e})),this},Rt.prototype.modify=function(e){var t=this,n=this._ctx;return this._write((function(r){var o,s,a;a="function"==typeof e?e:(o=i(e),s=o.length,function(t){for(var n=!1,r=0;r<s;++r){var i=o[r],a=e[i],u=w(t,i);a instanceof At?(_(t,i,a.execute(u)),n=!0):u!==a&&(_(t,i,a),n=!0)}return n});var u,c=n.table.core,l=(u=c.schema.primaryKey).outbound,h=u.extractKey,f=200;function d(e,t){var n=t.failures;t=t.numFailures,m+=e-t;for(var r=0,o=i(n);r<o.length;r++){var s=o[r];p.push(n[s])}}(u=t.db._options.modifyChunkSize)&&(f="object"==typeof u?u[c.name]||u["*"]||200:u);var p=[],m=0,y=[];return t.clone().primaryKeys().then((function(t){function i(n){var s=Math.min(f,t.length-n);return c.getMany({trans:r,keys:t.slice(n,n+s),cache:"immutable"}).then((function(u){for(var p=[],m=[],y=l?[]:null,v=[],g=0;g<s;++g){var b=u[g],w={value:k(b),primKey:t[n+g]};!1!==a.call(w,w.value,w)&&(null==w.value?v.push(t[n+g]):l||0===ct(h(b),h(w.value))?(m.push(w.value),l&&y.push(t[n+g])):(v.push(t[n+g]),p.push(w.value)))}return Promise.resolve(0<p.length&&c.mutate({trans:r,type:"add",values:p}).then((function(e){for(var t in e.failures)v.splice(parseInt(t),1);d(p.length,e)}))).then((function(){return(0<m.length||o&&"object"==typeof e)&&c.mutate({trans:r,type:"put",keys:y,values:m,criteria:o,changeSpec:"function"!=typeof e&&e,isAdditionalChunk:0<n}).then((function(e){return d(m.length,e)}))})).then((function(){return(0<v.length||o&&e===Et)&&c.mutate({trans:r,type:"delete",keys:v,criteria:o,isAdditionalChunk:0<n}).then((function(e){return d(v.length,e)}))})).then((function(){return t.length>n+s&&i(n+f)}))}))}var o=yt(n)&&n.limit===1/0&&("function"!=typeof e||e===Et)&&{index:n.index,range:n.range};return i(0).then((function(){if(0<p.length)throw new U("Error modifying one or more objects",p,m,y);return t.length}))}))}))},Rt.prototype.delete=function(){var e=this._ctx,t=e.range;return yt(e)&&(e.isPrimKey||3===t.type)?this._write((function(n){var r=e.table.core.schema.primaryKey,i=t;return e.table.core.count({trans:n,query:{index:r,range:i}}).then((function(t){return e.table.core.mutate({trans:n,type:"deleteRange",range:i}).then((function(e){var n=e.failures;if(e.lastResult,e.results,e=e.numFailures)throw new U("Could not delete some values",Object.keys(n).map((function(e){return n[e]})),t-e);return t-e}))}))})):this.modify(Et)},Rt);function Rt(){}var Et=function(e,t){return t.value=null};function kt(e,t){return e<t?-1:e===t?0:1}function Mt(e,t){return t<e?-1:e===t?0:1}function Ot(e,t,n){return(e=e instanceof Dt?new e.Collection(e):e)._ctx.error=new(n||TypeError)(t),e}function Pt(e){return new e.Collection(e,(function(){return Lt("")})).limit(0)}function Ct(e,t,n,r){var i,o,s,a,u,c,l,h=n.length;if(!n.every((function(e){return"string"==typeof e})))return Ot(e,et);function f(e){i="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},o="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},s="next"===e?kt:Mt;var t=n.map((function(e){return{lower:o(e),upper:i(e)}})).sort((function(e,t){return s(e.lower,t.lower)}));a=t.map((function(e){return e.upper})),u=t.map((function(e){return e.lower})),l="next"===(c=e)?"":r}f("next"),(e=new e.Collection(e,(function(){return It(a[0],u[h-1]+r)})))._ondirectionchange=function(e){f(e)};var d=0;return e._addAlgorithm((function(e,n,r){var i=e.key;if("string"!=typeof i)return!1;var f=o(i);if(t(f,u,d))return!0;for(var p=null,m=d;m<h;++m){var y=function(e,t,n,r,i,o){for(var s=Math.min(e.length,r.length),a=-1,u=0;u<s;++u){var c=t[u];if(c!==r[u])return i(e[u],n[u])<0?e.substr(0,u)+n[u]+n.substr(u+1):i(e[u],r[u])<0?e.substr(0,u)+r[u]+n.substr(u+1):0<=a?e.substr(0,a)+t[a]+n.substr(a+1):null;i(e[u],c)<0&&(a=u)}return s<r.length&&"next"===o?e+n.substr(e.length):s<e.length&&"prev"===o?e.substr(0,n.length):a<0?null:e.substr(0,a)+r[a]+n.substr(a+1)}(i,f,a[m],u[m],s,c);null===y&&null===p?d=m+1:(null===p||0<s(p,y))&&(p=y)}return n(null!==p?function(){e.continue(p+l)}:r),!1})),e}function It(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Lt(e){return{type:1,lower:e,upper:e}}var Dt=(Object.defineProperty(Bt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Bt.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(e,t)||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Pt(this):new this.Collection(this,(function(){return It(e,t,!n,!r)}))}catch(i){return Ot(this,Je)}},Bt.prototype.equals=function(e){return null==e?Ot(this,Je):new this.Collection(this,(function(){return Lt(e)}))},Bt.prototype.above=function(e){return null==e?Ot(this,Je):new this.Collection(this,(function(){return It(e,void 0,!0)}))},Bt.prototype.aboveOrEqual=function(e){return null==e?Ot(this,Je):new this.Collection(this,(function(){return It(e,void 0,!1)}))},Bt.prototype.below=function(e){return null==e?Ot(this,Je):new this.Collection(this,(function(){return It(void 0,e,!1,!0)}))},Bt.prototype.belowOrEqual=function(e){return null==e?Ot(this,Je):new this.Collection(this,(function(){return It(void 0,e)}))},Bt.prototype.startsWith=function(e){return"string"!=typeof e?Ot(this,et):this.between(e,e+Ze,!0,!0)},Bt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Ct(this,(function(e,t){return 0===e.indexOf(t[0])}),[e],Ze)},Bt.prototype.equalsIgnoreCase=function(e){return Ct(this,(function(e,t){return e===t[0]}),[e],"")},Bt.prototype.anyOfIgnoreCase=function(){var e=D.apply(L,arguments);return 0===e.length?Pt(this):Ct(this,(function(e,t){return-1!==t.indexOf(e)}),e,"")},Bt.prototype.startsWithAnyOfIgnoreCase=function(){var e=D.apply(L,arguments);return 0===e.length?Pt(this):Ct(this,(function(e,t){return t.some((function(t){return 0===e.indexOf(t)}))}),e,Ze)},Bt.prototype.anyOf=function(){var e=this,t=D.apply(L,arguments),n=this._cmp;try{t.sort(n)}catch(o){return Ot(this,Je)}if(0===t.length)return Pt(this);var r=new this.Collection(this,(function(){return It(t[0],t[t.length-1])}));r._ondirectionchange=function(r){n="next"===r?e._ascending:e._descending,t.sort(n)};var i=0;return r._addAlgorithm((function(e,r,o){for(var s=e.key;0<n(s,t[i]);)if(++i===t.length)return r(o),!1;return 0===n(s,t[i])||(r((function(){e.continue(t[i])})),!1)})),r},Bt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Bt.prototype.noneOf=function(){var e=D.apply(L,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(n){return Ot(this,Je)}var t=e.reduce((function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]}),null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},Bt.prototype.inAnyRange=function(e,t){var n=this,r=this._cmp,i=this._ascending,o=this._descending,s=this._min,a=this._max;if(0===e.length)return Pt(this);if(!e.every((function(e){return void 0!==e[0]&&void 0!==e[1]&&i(e[0],e[1])<=0})))return Ot(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",z.InvalidArgument);var u,c=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,h=i;function f(e,t){return h(e[0],t[0])}try{(u=e.reduce((function(e,t){for(var n=0,i=e.length;n<i;++n){var o=e[n];if(r(t[0],o[1])<0&&0<r(t[1],o[0])){o[0]=s(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return n===i&&e.push(t),e}),[])).sort(f)}catch(v){return Ot(this,Je)}var d=0,p=l?function(e){return 0<i(e,u[d][1])}:function(e){return 0<=i(e,u[d][1])},m=c?function(e){return 0<o(e,u[d][0])}:function(e){return 0<=o(e,u[d][0])},y=p;return(e=new this.Collection(this,(function(){return It(u[0][0],u[u.length-1][1],!c,!l)})))._ondirectionchange=function(e){h="next"===e?(y=p,i):(y=m,o),u.sort(f)},e._addAlgorithm((function(e,t,r){for(var o,s=e.key;y(s);)if(++d===u.length)return t(r),!1;return!p(o=s)&&!m(o)||(0===n._cmp(s,u[d][1])||0===n._cmp(s,u[d][0])||t((function(){h===i?e.continue(u[d][0]):e.continue(u[d][1])})),!1)})),e},Bt.prototype.startsWithAnyOf=function(){var e=D.apply(L,arguments);return e.every((function(e){return"string"==typeof e}))?0===e.length?Pt(this):this.inAnyRange(e.map((function(e){return[e,e+Ze]}))):Ot(this,"startsWithAnyOf() only works with strings")},Bt);function Bt(){}function Nt(e){return Le((function(t){return jt(t),e(t.target.error),!1}))}function jt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Kt="storagemutated",Ft="x-storagemutated-1",Ut=pt(null,Kt),qt=(Ht.prototype._lock=function(){return g(!ve.global),++this._reculock,1!==this._reculock||ve.global||(ve.lockOwnerFor=this),this},Ht.prototype._unlock=function(){if(g(!ve.global),0==--this._reculock)for(ve.global||(ve.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{We(e[1],e[0])}catch(t){}}return this},Ht.prototype._locked=function(){return this._reculock&&ve.lockOwnerFor!==this},Ht.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if(g(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new z.DatabaseClosed(r);case"MissingAPIError":throw new z.MissingAPI(r.message,r);default:throw new z.OpenFailed(r)}if(!this.active)throw new z.TransactionInactive;return g(null===this._completion._state),(e=this.idbtrans=e||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Le((function(n){jt(n),t._reject(e.error)})),e.onabort=Le((function(n){jt(n),t.active&&t._reject(new z.Abort(e.error)),t.active=!1,t.on("abort").fire(n)})),e.oncomplete=Le((function(){t.active=!1,t._resolve(),"mutatedParts"in e&&Ut.storagemutated.fire(e.mutatedParts)})),this},Ht.prototype._promise=function(e,t,n){var r=this;if("readwrite"===e&&"readwrite"!==this.mode)return $e(new z.ReadOnly("Transaction is readonly"));if(!this.active)return $e(new z.TransactionInactive);if(this._locked())return new _e((function(i,o){r._blockedFuncs.push([function(){r._promise(e,t,n).then(i,o)},ve])}));if(n)return Ue((function(){var e=new _e((function(e,n){r._lock();var i=t(e,n,r);i&&i.then&&i.then(e,n)}));return e.finally((function(){return r._unlock()})),e._lib=!0,e}));var i=new _e((function(e,n){var i=t(e,n,r);i&&i.then&&i.then(e,n)}));return i._lib=!0,i},Ht.prototype._root=function(){return this.parent?this.parent._root():this},Ht.prototype.waitFor=function(e){var t,n=this._root(),r=_e.resolve(e);n._waitingFor?n._waitingFor=n._waitingFor.then((function(){return r})):(n._waitingFor=r,n._waitingQueue=[],t=n.idbtrans.objectStore(n.storeNames[0]),function e(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(t.get(-1/0).onsuccess=e)}());var i=n._waitingFor;return new _e((function(e,t){r.then((function(t){return n._waitingQueue.push(Le(e.bind(null,t)))}),(function(e){return n._waitingQueue.push(Le(t.bind(null,e)))})).finally((function(){n._waitingFor===i&&(n._waitingFor=null)}))}))},Ht.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new z.Abort))},Ht.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(c(t,e))return t[e];var n=this.schema[e];if(!n)throw new z.NotFound("Table "+e+" not part of transaction");return(n=new this.db.Table(e,n,this)).core=this.db.core.table(e),t[e]=n},Ht);function Ht(){}function Gt(e,t,n,r,i,o,s){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:o,src:(n&&!s?"&":"")+(r?"*":"")+(i?"++":"")+zt(t)}}function zt(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function Vt(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(e){return[e.name,e]},n.reduce((function(e,t,n){return(n=r(t,n))&&(e[n[0]]=n[1]),e}),{}))};var r}var Xt=function(e){try{return e.only([[]]),Xt=function(){return[[]]},[[]]}catch(t){return Xt=function(){return Ze},Ze}};function Wt(e){return null==e?function(){}:"string"==typeof e?1===(t=e).split(".").length?function(e){return e[t]}:function(e){return w(e,t)}:function(t){return w(t,e)};var t}function Yt(e){return[].slice.call(e)}var Qt=0;function $t(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function Zt(e,t,n){function r(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var n=e.lower,r=e.upper,i=e.lowerOpen;return e=e.upperOpen,void 0===n?void 0===r?null:t.upperBound(r,!!e):void 0===r?t.lowerBound(n,!!i):t.bound(n,r,!!i,!!e)}function i(e){var t,n=e.name;return{name:n,schema:e,mutate:function(e){var t=e.trans,i=e.type,o=e.keys,s=e.values,a=e.range;return new Promise((function(e,u){e=Le(e);var c=t.objectStore(n),l=null==c.keyPath,h="put"===i||"add"===i;if(!h&&"delete"!==i&&"deleteRange"!==i)throw new Error("Invalid operation type: "+i);var f,d=(o||s||{length:1}).length;if(o&&s&&o.length!==s.length)throw new Error("Given keys array must have same length as given values array.");if(0===d)return e({numFailures:0,failures:{},results:[],lastResult:void 0});function p(e){++v,jt(e)}var m=[],y=[],v=0;if("deleteRange"===i){if(4===a.type)return e({numFailures:v,failures:y,results:[],lastResult:void 0});3===a.type?m.push(f=c.clear()):m.push(f=c.delete(r(a)))}else{var g=(l=h?l?[s,o]:[s,null]:[o,null])[0],b=l[1];if(h)for(var w=0;w<d;++w)m.push(f=b&&void 0!==b[w]?c[i](g[w],b[w]):c[i](g[w])),f.onerror=p;else for(w=0;w<d;++w)m.push(f=c[i](g[w])),f.onerror=p}function _(t){t=t.target.result,m.forEach((function(e,t){return null!=e.error&&(y[t]=e.error)})),e({numFailures:v,failures:y,results:"delete"===i?o:m.map((function(e){return e.result})),lastResult:t})}f.onerror=function(e){p(e),_(e)},f.onsuccess=_}))},getMany:function(e){var t=e.trans,r=e.keys;return new Promise((function(e,i){e=Le(e);for(var o,s=t.objectStore(n),a=r.length,u=new Array(a),c=0,l=0,h=function(t){t=t.target,u[t._pos]=t.result,++l===c&&e(u)},f=Nt(i),d=0;d<a;++d)null!=r[d]&&((o=s.get(r[d]))._pos=d,o.onsuccess=h,o.onerror=f,++c);0===c&&e(u)}))},get:function(e){var t=e.trans,r=e.key;return new Promise((function(e,i){e=Le(e);var o=t.objectStore(n).get(r);o.onsuccess=function(t){return e(t.target.result)},o.onerror=Nt(i)}))},query:(t=c,function(e){return new Promise((function(i,o){i=Le(i);var s,a,u,c=e.trans,l=e.values,h=e.limit,f=e.query,d=h===1/0?void 0:h,p=f.index;if(f=f.range,c=c.objectStore(n),p=p.isPrimaryKey?c:c.index(p.name),f=r(f),0===h)return i({result:[]});t?((d=l?p.getAll(f,d):p.getAllKeys(f,d)).onsuccess=function(e){return i({result:e.target.result})},d.onerror=Nt(o)):(s=0,a=!l&&"openKeyCursor"in p?p.openKeyCursor(f):p.openCursor(f),u=[],a.onsuccess=function(e){var t=a.result;return t?(u.push(l?t.value:t.primaryKey),++s===h?i({result:u}):void t.continue()):i({result:u})},a.onerror=Nt(o))}))}),openCursor:function(e){var t=e.trans,i=e.values,o=e.query,s=e.reverse,a=e.unique;return new Promise((function(e,u){e=Le(e);var c=o.index,l=o.range,h=t.objectStore(n),f=(h=c.isPrimaryKey?h:h.index(c.name),c=s?a?"prevunique":"prev":a?"nextunique":"next",!i&&"openKeyCursor"in h?h.openKeyCursor(r(l),c):h.openCursor(r(l),c));f.onerror=Nt(u),f.onsuccess=Le((function(n){var r,i,o,s,a=f.result;a?(a.___id=++Qt,a.done=!1,r=a.continue.bind(a),i=(i=a.continuePrimaryKey)&&i.bind(a),o=a.advance.bind(a),s=function(){throw new Error("Cursor not stopped")},a.trans=t,a.stop=a.continue=a.continuePrimaryKey=a.advance=function(){throw new Error("Cursor not started")},a.fail=Le(u),a.next=function(){var e=this,t=1;return this.start((function(){return t--?e.continue():e.stop()})).then((function(){return e}))},a.start=function(e){function t(){if(f.result)try{e()}catch(t){a.fail(t)}else a.done=!0,a.start=function(){throw new Error("Cursor behind last entry")},a.stop()}var n=new Promise((function(e,t){e=Le(e),f.onerror=Nt(t),a.fail=t,a.stop=function(t){a.stop=a.continue=a.continuePrimaryKey=a.advance=s,e(t)}}));return f.onsuccess=Le((function(e){f.onsuccess=t,t()})),a.continue=r,a.continuePrimaryKey=i,a.advance=o,t(),n},e(a)):e(null)}),u)}))},count:function(e){var t=e.query,i=e.trans,o=t.index,s=t.range;return new Promise((function(e,t){var a=i.objectStore(n),u=o.isPrimaryKey?a:a.index(o.name);(u=(a=r(s))?u.count(a):u.count()).onsuccess=Le((function(t){return e(t.target.result)})),u.onerror=Nt(t)}))}}}n=(a=n,u=Yt((s=e).objectStoreNames),l={schema:{name:s.name,tables:u.map((function(e){return a.objectStore(e)})).map((function(e){var t=e.keyPath,n=e.autoIncrement,r=o(t),i={};return n={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==t,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:Wt(t)},indexes:Yt(e.indexNames).map((function(t){return e.index(t)})).map((function(e){var t=e.name,n=e.unique,r=e.multiEntry;return e=e.keyPath,r={name:t,compound:o(e),keyPath:e,unique:n,multiEntry:r,extractKey:Wt(e)},i[$t(e)]=r})),getIndexByKeyPath:function(e){return i[$t(e)]}},i[":id"]=n.primaryKey,null!=t&&(i[$t(t)]=n.primaryKey),n}))},hasGetAll:0<u.length&&"getAll"in a.objectStore(u[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}).schema;var s,a,u,c=l.hasGetAll,l=n.tables.map(i),h={};return l.forEach((function(e){return h[e.name]=e})),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!h[e])throw new Error("Table '".concat(e,"' not found"));return h[e]},MIN_KEY:-1/0,MAX_KEY:Xt(t),schema:n}}function Jt(e,n,r,i){var o=r.IDBKeyRange;return r.indexedDB,{dbcore:(i=Zt(n,o,i),e.dbcore.reduce((function(e,n){return n=n.create,t(t({},e),n(e))}),i))}}function en(e,t){var n=t.db;t=Jt(e._middlewares,n,e._deps,t),e.core=t.dbcore,e.tables.forEach((function(t){var n=t.name;e.core.schema.tables.some((function(e){return e.name===n}))&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))}))}function tn(e,t,n,r){n.forEach((function(n){var i=r[n];t.forEach((function(t){var r=function e(t,n){return p(t,n)||(t=a(t))&&e(t,n)}(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?f(t,n,{get:function(){return this.table(n)},set:function(e){h(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,i))}))}))}function nn(e,t){t.forEach((function(t){for(var n in t)t[n]instanceof e.Table&&delete t[n]}))}function rn(e,t){return e._cfg.version-t._cfg.version}function on(e,t,n,r){var o=e._dbSchema;n.objectStoreNames.contains("$meta")&&!o.$meta&&(o.$meta=Vt("$meta",dn("")[0],[]),e._storeNames.push("$meta"));var s=e._createTransaction("readwrite",e._storeNames,o);s.create(n),s._completion.catch(r);var a=s._reject.bind(s),u=ve.transless||ve;Ue((function(){return ve.trans=s,ve.transless=u,0!==t?(en(e,n),c=t,((r=s).storeNames.includes("$meta")?r.table("$meta").get("version").then((function(e){return null!=e?e:c})):_e.resolve(c)).then((function(t){return o=t,a=s,u=n,c=[],t=(r=e)._versions,l=r._dbSchema=hn(0,r.idbdb,u),0!==(t=t.filter((function(e){return e._cfg.version>=o}))).length?(t.forEach((function(e){c.push((function(){var t=l,n=e._cfg.dbschema;fn(r,t,u),fn(r,n,u),l=r._dbSchema=n;var s=an(t,n);s.add.forEach((function(e){un(u,e[0],e[1].primKey,e[1].indexes)})),s.change.forEach((function(e){if(e.recreate)throw new z.Upgrade("Not yet support for changing primary key");var t=u.objectStore(e.name);e.add.forEach((function(e){return ln(t,e)})),e.change.forEach((function(e){t.deleteIndex(e.name),ln(t,e)})),e.del.forEach((function(e){return t.deleteIndex(e)}))}));var c=e._cfg.contentUpgrade;if(c&&e._cfg.version>o){en(r,u),a._memoizedTables={};var h=x(n);s.del.forEach((function(e){h[e]=t[e]})),nn(r,[r.Transaction.prototype]),tn(r,[r.Transaction.prototype],i(h),h),a.schema=h;var f,d=B(c);return d&&qe(),s=_e.follow((function(){var e;(f=c(a))&&d&&(e=He.bind(null,null),f.then(e,e))})),f&&"function"==typeof f.then?_e.resolve(f):s.then((function(){return f}))}})),c.push((function(t){var n,i,o=e._cfg.dbschema;n=o,i=t,[].slice.call(i.db.objectStoreNames).forEach((function(e){return null==n[e]&&i.db.deleteObjectStore(e)})),nn(r,[r.Transaction.prototype]),tn(r,[r.Transaction.prototype],r._storeNames,r._dbSchema),a.schema=r._dbSchema})),c.push((function(t){r.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(r.idbdb.version/10)===e._cfg.version?(r.idbdb.deleteObjectStore("$meta"),delete r._dbSchema.$meta,r._storeNames=r._storeNames.filter((function(e){return"$meta"!==e}))):t.objectStore("$meta").put(e._cfg.version,"version"))}))})),function e(){return c.length?_e.resolve(c.shift()(a.idbtrans)).then(e):_e.resolve()}().then((function(){cn(l,u)}))):_e.resolve();var r,o,a,u,c,l})).catch(a)):(i(o).forEach((function(e){un(n,e,o[e].primKey,o[e].indexes)})),en(e,n),void _e.follow((function(){return e.on.populate.fire(s)})).catch(a));var r,c}))}function sn(e,t){cn(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=hn(0,e.idbdb,t);fn(e,e._dbSchema,t);for(var r=0,i=an(n,e._dbSchema).change;r<i.length;r++){var o=function(e){if(e.change.length||e.recreate)return{value:void 0};var n=t.objectStore(e.name);e.add.forEach((function(e){ln(n,e)}))}(i[r]);if("object"==typeof o)return o.value}}function an(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var i=e[n],o=t[n];if(i){var s={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||i.primKey.auto!==o.primKey.auto)s.recreate=!0,r.change.push(s);else{var a=i.idxByName,u=o.idxByName,c=void 0;for(c in a)u[c]||s.del.push(c);for(c in u){var l=a[c],h=u[c];l?l.src!==h.src&&s.change.push(h):s.add.push(h)}(0<s.del.length||0<s.add.length||0<s.change.length)&&r.change.push(s)}}else r.add.push([n,o])}return r}function un(e,t,n,r){var i=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach((function(e){return ln(i,e)})),i}function cn(e,t){i(e).forEach((function(n){t.db.objectStoreNames.contains(n)||un(t,n,e[n].primKey,e[n].indexes)}))}function ln(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function hn(e,t,n){var r={};return y(t.objectStoreNames,0).forEach((function(e){for(var t=n.objectStore(e),i=Gt(zt(a=t.keyPath),a||"",!0,!1,!!t.autoIncrement,a&&"string"!=typeof a,!0),o=[],s=0;s<t.indexNames.length;++s){var a=(u=t.index(t.indexNames[s])).keyPath,u=Gt(u.name,a,!!u.unique,!!u.multiEntry,!1,a&&"string"!=typeof a,!1);o.push(u)}r[e]=Vt(e,i,o)})),r}function fn(e,t,n){for(var i=n.db.objectStoreNames,o=0;o<i.length;++o){var s=i[o],a=n.objectStore(s);e._hasGetAll="getAll"in a;for(var u=0;u<a.indexNames.length;++u){var c=a.indexNames[u],l=a.index(c).keyPath,h="string"==typeof l?l:"["+y(l).join("+")+"]";!t[s]||(l=t[s].idxByName[h])&&(l.name=c,delete t[s].idxByName[h],t[s].idxByName[c]=l)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&r.WorkerGlobalScope&&r instanceof r.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function dn(e){return e.split(",").map((function(e,t){var n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return Gt(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),o(r),0===t)}))}var pn=(mn.prototype._parseStoresSpec=function(e,t){i(e).forEach((function(n){if(null!==e[n]){var r=dn(e[n]),i=r.shift();if(i.unique=!0,i.multi)throw new z.Schema("Primary key cannot be multi-valued");r.forEach((function(e){if(e.auto)throw new z.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new z.Schema("Index must have a name and cannot be an empty string")})),t[n]=Vt(n,i,r)}}))},mn.prototype.stores=function(e){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?s(this._cfg.storesSource,e):e,e=t._versions;var n={},r={};return e.forEach((function(e){s(n,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(n,r)})),t._dbSchema=r,nn(t,[t._allTables,t,t.Transaction.prototype]),tn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],i(r),r),t._storeNames=i(r),this},mn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=ne(this._cfg.contentUpgrade||W,e),this},mn);function mn(){}function yn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new tr(nt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function vn(e){return e&&"function"==typeof e.databases}function gn(e){return Ue((function(){return ve.letThrough=!0,e()}))}function bn(e){return!("from"in e)}var wn=function(e,t){if(!this){var n=new wn;return e&&"d"in e&&s(n,e),n}s(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function _n(e,t,n){var r=ct(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(bn(e))return s(e,{from:t,to:n,d:1});var i=e.l;if(r=e.r,ct(n,e.from)<0)return i?_n(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Sn(e);if(0<ct(t,e.to))return r?_n(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Sn(e);ct(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<ct(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1),n=!e.r,i&&!e.l&&xn(e,i),r&&n&&xn(e,r)}}function xn(e,t){bn(t)||function e(t,n){var r=n.from,i=n.to,o=n.l;n=n.r,_n(t,r,i),o&&e(t,o),n&&e(t,n)}(e,t)}function An(e,t){var n=Tn(t),r=n.next();if(r.done)return!1;for(var i=r.value,o=Tn(e),s=o.next(i.from),a=s.value;!r.done&&!s.done;){if(ct(a.from,i.to)<=0&&0<=ct(a.to,i.from))return!0;ct(i.from,a.from)<0?i=(r=n.next(a.from)).value:a=(s=o.next(i.from)).value}return!1}function Tn(e){var t=bn(e)?null:{s:0,n:e};return{next:function(e){for(var n=0<arguments.length;t;)switch(t.s){case 0:if(t.s=1,n)for(;t.n.l&&ct(e,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,!n||ct(e,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 Sn(e){var n,r,i=((null===(n=e.r)||void 0===n?void 0:n.d)||0)-((null===(r=e.l)||void 0===r?void 0:r.d)||0),o=1<i?"r":i<-1?"l":"";o&&(n="r"==o?"l":"r",r=t({},e),i=e[o],e.from=i.from,e.to=i.to,e[o]=i[o],r[o]=i[n],(e[n]=r).d=Rn(r)),e.d=Rn(e)}function Rn(e){var t=e.r;return e=e.l,(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}function En(e,t){return i(t).forEach((function(n){e[n]?xn(e[n],t[n]):e[n]=function e(t){var n,r,i={};for(n in t)c(t,n)&&(r=t[n],i[n]=!r||"object"!=typeof r||R.has(r.constructor)?r:e(r));return i}(t[n])})),e}function kn(e,t){return e.all||t.all||Object.keys(e).some((function(n){return t[n]&&An(t[n],e[n])}))}l(wn.prototype,((N={add:function(e){return xn(this,e),this},addKey:function(e){return _n(this,e,e),this},addKeys:function(e){var t=this;return e.forEach((function(e){return _n(t,e,e)})),this},hasKey:function(e){var t=Tn(this).next(e).value;return t&&ct(t.from,e)<=0&&0<=ct(t.to,e)}})[P]=function(){return Tn(this)},N));var Mn={},On={},Pn=!1;function Cn(e){En(On,e),Pn||(Pn=!0,setTimeout((function(){Pn=!1,In(On,!(On={}))}),0))}function In(e,t){void 0===t&&(t=!1);var n=new Set;if(e.all)for(var r=0,i=Object.values(Mn);r<i.length;r++)Ln(s=i[r],e,n,t);else for(var o in e){var s,a=/^idb\:\/\/(.*)\/(.*)\//.exec(o);a&&(o=a[1],a=a[2],(s=Mn["idb://".concat(o,"/").concat(a)])&&Ln(s,e,n,t))}n.forEach((function(e){return e()}))}function Ln(e,t,n,r){for(var i=[],o=0,s=Object.entries(e.queries.query);o<s.length;o++){for(var a=s[o],u=a[0],c=[],l=0,h=a[1];l<h.length;l++){var f=h[l];kn(t,f.obsSet)?f.subscribers.forEach((function(e){return n.add(e)})):r&&c.push(f)}r&&i.push([u,c])}if(r)for(var d=0,p=i;d<p.length;d++){var m=p[d];u=m[0],c=m[1],e.queries.query[u]=c}}function Dn(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then((function(){return t.dbOpenError?$e(t.dbOpenError):e}));t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var r=t.openCanceller,o=Math.round(10*e.verno),s=!1;function a(){if(t.openCanceller!==r)throw new z.DatabaseClosed("db.open() was cancelled")}function u(){return new _e((function(r,c){if(a(),!n)throw new z.MissingAPI;var l=e.name,d=t.autoSchema||!o?n.open(l):n.open(l,o);if(!d)throw new z.MissingAPI;d.onerror=Nt(c),d.onblocked=Le(e._fireOnBlocked),d.onupgradeneeded=Le((function(r){var i;h=d.transaction,t.autoSchema&&!e._options.allowEmptyDB?(d.onerror=jt,h.abort(),d.result.close(),(i=n.deleteDatabase(l)).onsuccess=i.onerror=Le((function(){c(new z.NoSuchDatabase("Database ".concat(l," doesnt exist")))}))):(h.onerror=Nt(c),r=r.oldVersion>Math.pow(2,62)?0:r.oldVersion,f=r<1,e.idbdb=d.result,s&&sn(e,h),on(e,r/10,h,c))}),c),d.onsuccess=Le((function(){h=null;var n,a,c,p,m,v=e.idbdb=d.result,g=y(v.objectStoreNames);if(0<g.length)try{var b=v.transaction(1===(p=g).length?p[0]:p,"readonly");if(t.autoSchema)a=v,c=b,(n=e).verno=a.version/10,c=n._dbSchema=hn(0,a,c),n._storeNames=y(a.objectStoreNames,0),tn(n,[n._allTables],i(c),c);else if(fn(e,e._dbSchema,b),((m=an(hn(0,(m=e).idbdb,b),m._dbSchema)).add.length||m.change.some((function(e){return e.add.length||e.change.length})))&&!s)return v.close(),o=v.version+1,s=!0,r(u());en(e,b)}catch(w){}tt.push(e),v.onversionchange=Le((function(n){t.vcFired=!0,e.on("versionchange").fire(n)})),v.onclose=Le((function(t){e.on("close").fire(t)})),f&&(m=e._deps,b=l,v=m.indexedDB,m=m.IDBKeyRange,vn(v)||b===nt||yn(v,m).put({name:b}).catch(W)),r()}),c)})).catch((function(e){switch(null==e?void 0:e.name){case"UnknownError":if(0<t.PR1398_maxLoop)return t.PR1398_maxLoop--,u();break;case"VersionError":if(0<o)return o=0,u()}return _e.reject(e)}))}var c,l=t.dbReadyResolve,h=null,f=!1;return _e.race([r,("undefined"==typeof navigator?_e.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise((function(e){function t(){return indexedDB.databases().finally(e)}c=setInterval(t,100),t()})).finally((function(){return clearInterval(c)})):Promise.resolve()).then(u)]).then((function(){return a(),t.onReadyBeingFired=[],_e.resolve(gn((function(){return e.on.ready.fire(e.vip)}))).then((function n(){if(0<t.onReadyBeingFired.length){var r=t.onReadyBeingFired.reduce(ne,W);return t.onReadyBeingFired=[],_e.resolve(gn((function(){return r(e.vip)}))).then(n)}}))})).finally((function(){t.openCanceller===r&&(t.onReadyBeingFired=null,t.isBeingOpened=!1)})).catch((function(n){t.dbOpenError=n;try{h&&h.abort()}catch(i){}return r===t.openCanceller&&e._close(),$e(n)})).finally((function(){t.openComplete=!0,l()})).then((function(){var t;return f&&(t={},e.tables.forEach((function(n){n.schema.indexes.forEach((function(r){r.name&&(t["idb://".concat(e.name,"/").concat(n.name,"/").concat(r.name)]=new wn(-1/0,[[[]]]))})),t["idb://".concat(e.name,"/").concat(n.name,"/")]=t["idb://".concat(e.name,"/").concat(n.name,"/:dels")]=new wn(-1/0,[[[]]])})),Ut(Kt).fire(t),In(t,!0)),e}))}function Bn(e){function t(t){return e.next(t)}var n=i(t),r=i((function(t){return e.throw(t)}));function i(e){return function(t){var i=e(t);return t=i.value,i.done?t:t&&"function"==typeof t.then?t.then(n,r):o(t)?Promise.all(t).then(n,r):n(t)}}return i(t)()}function Nn(e,t,n){for(var r=o(e)?e.slice():[e],i=0;i<n;++i)r.push(t);return r}var jn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return t(t({},e),{table:function(n){var r=e.table(n),i=r.schema,o={},s=[];function a(e,n,r){var i=$t(e),u=o[i]=o[i]||[],c=null==e?0:"string"==typeof e?1:e.length,l=0<n;return l=t(t({},r),{name:l?"".concat(i,"(virtual-from:").concat(r.name,")"):r.name,lowLevelIndex:r,isVirtual:l,keyTail:n,keyLength:c,extractKey:Wt(e),unique:!l&&r.unique}),u.push(l),l.isPrimaryKey||s.push(l),1<c&&a(2===c?e[0]:e.slice(0,c-1),n+1,r),u.sort((function(e,t){return e.keyTail-t.keyTail})),l}n=a(i.primaryKey.keyPath,0,i.primaryKey),o[":id"]=[n];for(var u=0,c=i.indexes;u<c.length;u++){var l=c[u];a(l.keyPath,0,l)}function h(n){var r,i=n.query.index;return i.isVirtual?t(t({},n),{query:{index:i.lowLevelIndex,range:(r=n.query.range,i=i.keyTail,{type:1===r.type?2:r.type,lower:Nn(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,i),lowerOpen:!0,upper:Nn(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,i),upperOpen:!0})}}):n}return t(t({},r),{schema:t(t({},i),{primaryKey:n,indexes:s,getIndexByKeyPath:function(e){return(e=o[$t(e)])&&e[0]}}),count:function(e){return r.count(h(e))},query:function(e){return r.query(h(e))},openCursor:function(t){var n=t.query.index,i=n.keyTail,o=n.isVirtual,s=n.keyLength;return o?r.openCursor(h(t)).then((function(e){return e&&a(e)})):r.openCursor(t);function a(n){return Object.create(n,{continue:{value:function(r){null!=r?n.continue(Nn(r,t.reverse?e.MAX_KEY:e.MIN_KEY,i)):t.unique?n.continue(n.key.slice(0,s).concat(t.reverse?e.MIN_KEY:e.MAX_KEY,i)):n.continue()}},continuePrimaryKey:{value:function(t,r){n.continuePrimaryKey(Nn(t,e.MAX_KEY,i),r)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return 1===s?e[0]:e.slice(0,s)}},value:{get:function(){return n.value}}})}}})}})}};function Kn(e,t,n,r){return n=n||{},r=r||"",i(e).forEach((function(i){var o,s,a;c(t,i)?(o=e[i],s=t[i],"object"==typeof o&&"object"==typeof s&&o&&s?(a=O(o))!==O(s)?n[r+i]=t[i]:"Object"===a?Kn(o,s,n,r+i+"."):o!==s&&(n[r+i]=t[i]):o!==s&&(n[r+i]=t[i])):n[r+i]=void 0})),i(t).forEach((function(i){c(e,i)||(n[r+i]=t[i])})),n}function Fn(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}var Un={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return t(t({},e),{table:function(r){var i=e.table(r),o=i.schema.primaryKey;return t(t({},i),{mutate:function(e){var s=ve.trans,a=s.table(r).hook,u=a.deleting,l=a.creating,h=a.updating;switch(e.type){case"add":if(l.fire===W)break;return s._promise("readwrite",(function(){return f(e)}),!0);case"put":if(l.fire===W&&h.fire===W)break;return s._promise("readwrite",(function(){return f(e)}),!0);case"delete":if(u.fire===W)break;return s._promise("readwrite",(function(){return f(e)}),!0);case"deleteRange":if(u.fire===W)break;return s._promise("readwrite",(function(){return function e(n,r,s){return i.query({trans:n,values:!1,query:{index:o,range:r},limit:s}).then((function(i){var o=i.result;return f({type:"delete",keys:o,trans:n}).then((function(i){return 0<i.numFailures?Promise.reject(i.failures[0]):o.length<s?{failures:[],numFailures:0,lastResult:void 0}:e(n,t(t({},r),{lower:o[o.length-1],lowerOpen:!0}),s)}))}))}(e.trans,e.range,1e4)}),!0)}return i.mutate(e);function f(e){var r,s,a,f=ve.trans,d=e.keys||Fn(o,e);if(!d)throw new Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?t(t({},e),{keys:d}):t({},e)).type&&(e.values=n([],e.values)),e.keys&&(e.keys=n([],e.keys)),r=i,a=d,("add"===(s=e).type?Promise.resolve([]):r.getMany({trans:s.trans,keys:a,cache:"immutable"})).then((function(t){var n=d.map((function(n,r){var i,s,a,d=t[r],p={onerror:null,onsuccess:null};return"delete"===e.type?u.fire.call(p,n,d,f):"add"===e.type||void 0===d?(i=l.fire.call(p,n,e.values[r],f),null==n&&null!=i&&(e.keys[r]=n=i,o.outbound||_(e.values[r],o.keyPath,n))):(i=Kn(d,e.values[r]),(s=h.fire.call(p,i,n,d,f))&&(a=e.values[r],Object.keys(s).forEach((function(e){c(a,e)?a[e]=s[e]:_(a,e,s[e])})))),p}));return i.mutate(e).then((function(r){for(var i=r.failures,o=r.results,s=r.numFailures,a=(r=r.lastResult,0);a<d.length;++a){var u=(o||d)[a],c=n[a];null==u?c.onerror&&c.onerror(i[a]):c.onsuccess&&c.onsuccess("put"===e.type&&t[a]?e.values[a]:u)}return{failures:i,results:o,numFailures:s,lastResult:r}})).catch((function(e){return n.forEach((function(t){return t.onerror&&t.onerror(e)})),Promise.reject(e)}))}))}}})}})}};function qn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;for(var r=[],i=0,o=0;i<t.keys.length&&o<e.length;++i)0===ct(t.keys[i],e[o])&&(r.push(n?k(t.values[i]):t.values[i]),++o);return r.length===e.length?r:null}catch(s){return null}}var Hn={stack:"dbcore",level:-1,create:function(e){return{table:function(n){var r=e.table(n);return t(t({},r),{getMany:function(e){if(!e.cache)return r.getMany(e);var t=qn(e.keys,e.trans._cache,"clone"===e.cache);return t?_e.resolve(t):r.getMany(e).then((function(t){return e.trans._cache={keys:e.keys,values:"clone"===e.cache?k(t):t},t}))},mutate:function(e){return"add"!==e.type&&(e.trans._cache=null),r.mutate(e)}})}}}};function Gn(e,t){return"readonly"===e.trans.mode&&!!e.subscr&&!e.trans.explicit&&"disabled"!==e.trans.db._options.cache&&!t.schema.primaryKey.outbound}function zn(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Vn={stack:"dbcore",level:0,name:"Observability",create:function(e){var n=e.schema.name,r=new wn(e.MIN_KEY,e.MAX_KEY);return t(t({},e),{transaction:function(t,n,r){if(ve.subscr&&"readonly"!==n)throw new z.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(ve.querier));return e.transaction(t,n,r)},table:function(s){var a=e.table(s),u=a.schema,c=u.primaryKey,l=u.indexes,h=c.extractKey,f=c.outbound,d=c.autoIncrement&&l.filter((function(e){return e.compound&&e.keyPath.includes(c.keyPath)})),p=t(t({},a),{mutate:function(t){function i(e){return e="idb://".concat(n,"/").concat(s,"/").concat(e),m[e]||(m[e]=new wn)}var l,h,f,p=t.trans,m=t.mutatedParts||(t.mutatedParts={}),y=i(""),v=i(":dels"),g=t.type,b=(_="deleteRange"===t.type?[t.range]:"delete"===t.type?[t.keys]:t.values.length<50?[Fn(c,t).filter((function(e){return e})),t.values]:[])[0],w=_[1],_=t.trans._cache;return o(b)?(y.addKeys(b),(_="delete"===g||b.length===w.length?qn(b,_):null)||v.addKeys(b),(_||w)&&(l=i,h=_,f=w,u.indexes.forEach((function(e){var t=l(e.name||"");function n(t){return null!=t?e.extractKey(t):null}function r(n){return e.multiEntry&&o(n)?n.forEach((function(e){return t.addKey(e)})):t.addKey(n)}(h||f).forEach((function(e,t){var i=h&&n(h[t]);0!==ct(i,t=f&&n(f[t]))&&(null!=i&&r(i),null!=t&&r(t))}))})))):b?(w={from:null!==(w=b.lower)&&void 0!==w?w:e.MIN_KEY,to:null!==(w=b.upper)&&void 0!==w?w:e.MAX_KEY},v.add(w),y.add(w)):(y.add(r),v.add(r),u.indexes.forEach((function(e){return i(e.name).add(r)}))),a.mutate(t).then((function(e){return!b||"add"!==t.type&&"put"!==t.type||(y.addKeys(e.results),d&&d.forEach((function(n){for(var r=t.values.map((function(e){return n.extractKey(e)})),o=n.keyPath.findIndex((function(e){return e===c.keyPath})),s=0,a=e.results.length;s<a;++s)r[s][o]=e.results[s];i(n.name).addKeys(r)}))),p.mutatedParts=En(p.mutatedParts||{},m),e}))}}),m={get:function(e){return[c,new wn(e.key)]},getMany:function(e){return[c,(new wn).addKeys(e.keys)]},count:l=function(t){t=(n=t.query).index;var n=n.range;return[t,new wn(null!==(t=n.lower)&&void 0!==t?t:e.MIN_KEY,null!==(n=n.upper)&&void 0!==n?n:e.MAX_KEY)]},query:l,openCursor:l};return i(m).forEach((function(e){p[e]=function(i){var o=!!(p=ve.subscr),u=Gn(ve,a)&&zn(e,i)?i.obsSet={}:p;if(o){var c=function(e){return e="idb://".concat(n,"/").concat(s,"/").concat(e),u[e]||(u[e]=new wn)},l=c(""),d=c(":dels"),p=(o=(p=m[e](i))[0],p[1]);if(("query"===e&&o.isPrimaryKey&&!i.values?d:c(o.name||"")).add(p),!o.isPrimaryKey){if("count"!==e){var y="query"===e&&f&&i.values&&a.query(t(t({},i),{values:!1}));return a[e].apply(this,arguments).then((function(t){if("query"===e){if(f&&i.values)return y.then((function(e){return e=e.result,l.addKeys(e),t}));var n=i.values?t.result.map(h):t.result;(i.values?l:d).addKeys(n)}else if("openCursor"===e){var r=t,o=i.values;return r&&Object.create(r,{key:{get:function(){return d.addKey(r.primaryKey),r.key}},primaryKey:{get:function(){var e=r.primaryKey;return d.addKey(e),e}},value:{get:function(){return o&&l.addKey(r.primaryKey),r.value}}})}return t}))}d.add(r)}}return a[e].apply(this,arguments)}})),p}})}};function Xn(e,n,r){if(0===r.numFailures)return n;if("deleteRange"===n.type)return null;var i=n.keys?n.keys.length:"values"in n&&n.values?n.values.length:1;return r.numFailures===i?null:(n=t({},n),o(n.keys)&&(n.keys=n.keys.filter((function(e,t){return!(t in r.failures)}))),"values"in n&&o(n.values)&&(n.values=n.values.filter((function(e,t){return!(t in r.failures)}))),n)}function Wn(e,t){return n=e,(void 0===(r=t).lower||(r.lowerOpen?0<ct(n,r.lower):0<=ct(n,r.lower)))&&(void 0===t.upper||(t.upperOpen?ct(e,t.upper)<0:ct(e,t.upper)<=0));var n,r}function Yn(e,t,n,r,i,s){if(!n||0===n.length)return e;var a=t.query.index,u=a.multiEntry,c=t.query.range,l=r.schema.primaryKey.extractKey,h=a.extractKey,f=(a.lowLevelIndex||a).extractKey;return(n=n.reduce((function(e,n){var r=e,i=[];if("add"===n.type||"put"===n.type)for(var s=new wn,a=n.values.length-1;0<=a;--a){var f,d=n.values[a],p=l(d);s.hasKey(p)||(f=h(d),(u&&o(f)?f.some((function(e){return Wn(e,c)})):Wn(f,c))&&(s.addKey(p),i.push(d)))}switch(n.type){case"add":var m=(new wn).addKeys(t.values?e.map((function(e){return l(e)})):e);r=e.concat(t.values?i.filter((function(e){return e=l(e),!m.hasKey(e)&&(m.addKey(e),!0)})):i.map((function(e){return l(e)})).filter((function(e){return!m.hasKey(e)&&(m.addKey(e),!0)})));break;case"put":var y=(new wn).addKeys(n.values.map((function(e){return l(e)})));r=e.filter((function(e){return!y.hasKey(t.values?l(e):e)})).concat(t.values?i:i.map((function(e){return l(e)})));break;case"delete":var v=(new wn).addKeys(n.keys);r=e.filter((function(e){return!v.hasKey(t.values?l(e):e)}));break;case"deleteRange":var g=n.range;r=e.filter((function(e){return!Wn(l(e),g)}))}return r}),e))===e?e:(n.sort((function(e,t){return ct(f(e),f(t))||ct(l(e),l(t))})),t.limit&&t.limit<1/0&&(n.length>t.limit?n.length=t.limit:e.length===t.limit&&n.length<t.limit&&(i.dirty=!0)),s?Object.freeze(n):n)}function Qn(e,t){return 0===ct(e.lower,t.lower)&&0===ct(e.upper,t.upper)&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function $n(e,t){return function(e,t,n,r){if(void 0===e)return void 0!==t?-1:0;if(void 0===t)return 1;if(0===(t=ct(e,t))){if(n&&r)return 0;if(n)return 1;if(r)return-1}return t}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(e,t,n,r){if(void 0===e)return void 0!==t?1:0;if(void 0===t)return-1;if(0===(t=ct(e,t))){if(n&&r)return 0;if(n)return-1;if(r)return 1}return t}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function Zn(e,t,n,r){e.subscribers.add(n),r.addEventListener("abort",(function(){var r,i;e.subscribers.delete(n),0===e.subscribers.size&&(r=e,i=t,setTimeout((function(){0===r.subscribers.size&&I(i,r)}),3e3))}))}var Jn={stack:"dbcore",level:0,name:"Cache",create:function(e){var n=e.schema.name;return t(t({},e),{transaction:function(t,r,i){var o,s,a=e.transaction(t,r,i);return"readwrite"===r&&(s=(o=new AbortController).signal,i=function(i){return function(){if(o.abort(),"readwrite"===r){for(var s=new Set,u=0,c=t;u<c.length;u++){var l=c[u],h=Mn["idb://".concat(n,"/").concat(l)];if(h){var f=e.table(l),d=h.optimisticOps.filter((function(e){return e.trans===a}));if(a._explicit&&i&&a.mutatedParts)for(var p=0,m=Object.values(h.queries.query);p<m.length;p++)for(var y=0,v=(w=m[p]).slice();y<v.length;y++)kn((_=v[y]).obsSet,a.mutatedParts)&&(I(w,_),_.subscribers.forEach((function(e){return s.add(e)})));else if(0<d.length){h.optimisticOps=h.optimisticOps.filter((function(e){return e.trans!==a}));for(var g=0,b=Object.values(h.queries.query);g<b.length;g++)for(var w,_,x,A=0,T=(w=b[g]).slice();A<T.length;A++)null!=(_=T[A]).res&&a.mutatedParts&&(i&&!_.dirty?(x=Object.isFrozen(_.res),x=Yn(_.res,_.req,d,f,_,x),_.dirty?(I(w,_),_.subscribers.forEach((function(e){return s.add(e)}))):x!==_.res&&(_.res=x,_.promise=_e.resolve({result:x}))):(_.dirty&&I(w,_),_.subscribers.forEach((function(e){return s.add(e)}))))}}}s.forEach((function(e){return e()}))}}},a.addEventListener("abort",i(!1),{signal:s}),a.addEventListener("error",i(!1),{signal:s}),a.addEventListener("complete",i(!0),{signal:s})),a},table:function(r){var i=e.table(r),o=i.schema.primaryKey;return t(t({},i),{mutate:function(e){var s=ve.trans;if(o.outbound||"disabled"===s.db._options.cache||s.explicit||"readwrite"!==s.idbtrans.mode)return i.mutate(e);var a=Mn["idb://".concat(n,"/").concat(r)];return a?(s=i.mutate(e),"add"!==e.type&&"put"!==e.type||!(50<=e.values.length||Fn(o,e).some((function(e){return null==e})))?(a.optimisticOps.push(e),e.mutatedParts&&Cn(e.mutatedParts),s.then((function(t){0<t.numFailures&&(I(a.optimisticOps,e),(t=Xn(0,e,t))&&a.optimisticOps.push(t),e.mutatedParts&&Cn(e.mutatedParts))})),s.catch((function(){I(a.optimisticOps,e),e.mutatedParts&&Cn(e.mutatedParts)}))):s.then((function(n){var r=Xn(0,t(t({},e),{values:e.values.map((function(e,r){var i;return n.failures[r]||_(e=null!==(i=o.keyPath)&&void 0!==i&&i.includes(".")?k(e):t({},e),o.keyPath,n.results[r]),e}))}),n);a.optimisticOps.push(r),queueMicrotask((function(){return e.mutatedParts&&Cn(e.mutatedParts)}))})),s):i.mutate(e)},query:function(e){if(!Gn(ve,i)||!zn("query",e))return i.query(e);var t="immutable"===(null===(a=ve.trans)||void 0===a?void 0:a.db._options.cache),o=(c=ve).requery,s=c.signal,a=function(e,t,n,r){var i=Mn["idb://".concat(e,"/").concat(t)];if(!i)return[];if(!(t=i.queries[n]))return[null,!1,i,null];var o=t[(r.query?r.query.index.name:null)||""];if(!o)return[null,!1,i,null];switch(n){case"query":var s=o.find((function(e){return e.req.limit===r.limit&&e.req.values===r.values&&Qn(e.req.query.range,r.query.range)}));return s?[s,!0,i,o]:[o.find((function(e){return("limit"in e.req?e.req.limit:1/0)>=r.limit&&(!r.values||e.req.values)&&$n(e.req.query.range,r.query.range)})),!1,i,o];case"count":return[s=o.find((function(e){return Qn(e.req.query.range,r.query.range)})),!!s,i,o]}}(n,r,"query",e),u=a[0],c=a[1],l=a[2],h=a[3];return u&&c?u.obsSet=e.obsSet:(c=i.query(e).then((function(e){var n=e.result;if(u&&(u.res=n),t){for(var r=0,i=n.length;r<i;++r)Object.freeze(n[r]);Object.freeze(n)}else e.result=k(n);return e})).catch((function(e){return h&&u&&I(h,u),Promise.reject(e)})),u={obsSet:e.obsSet,promise:c,subscribers:new Set,type:"query",req:e,dirty:!1},h?h.push(u):(h=[u],(l=l||(Mn["idb://".concat(n,"/").concat(r)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[e.query.index.name||""]=h)),Zn(u,h,o,s),u.promise.then((function(n){return{result:Yn(n.result,e,null==l?void 0:l.optimisticOps,i,u,t)}}))}})}})}};function er(e,t){return new Proxy(e,{get:function(e,n,r){return"db"===n?t:Reflect.get(e,n,r)}})}var tr=(nr.prototype.version=function(e){if(isNaN(e)||e<.1)throw new z.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new z.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter((function(t){return t._cfg.version===e}))[0];return n||(n=new this.Version(e),t.push(n),t.sort(rn),n.stores({}),this._state.autoSchema=!1,n)},nr.prototype._whenReady=function(e){var t=this;return this.idbdb&&(this._state.openComplete||ve.letThrough||this._vip)?e():new _e((function(e,n){if(t._state.openComplete)return n(new z.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._state.autoOpen)return void n(new z.DatabaseClosed);t.open().catch(W)}t._state.dbReadyPromise.then(e,n)})).then(e)},nr.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,i=e.name;return i&&this.unuse({stack:t,name:i}),(e=this._middlewares[t]||(this._middlewares[t]=[])).push({stack:t,create:n,level:null==r?10:r,name:i}),e.sort((function(e,t){return e.level-t.level})),this},nr.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter((function(e){return r?e.create!==r:!!n&&e.name!==n}))),this},nr.prototype.open=function(){var e=this;return We(ye,(function(){return Dn(e)}))},nr.prototype._close=function(){var e=this._state,t=tt.indexOf(this);if(0<=t&&tt.splice(t,1),this.idbdb){try{this.idbdb.close()}catch(n){}this.idbdb=null}e.isBeingOpened||(e.dbReadyPromise=new _e((function(t){e.dbReadyResolve=t})),e.openCanceller=new _e((function(t,n){e.cancelOpen=n})))},nr.prototype.close=function(e){var t=(void 0===e?{disableAutoOpen:!0}:e).disableAutoOpen;e=this._state,t?(e.isBeingOpened&&e.cancelOpen(new z.DatabaseClosed),this._close(),e.autoOpen=!1,e.dbOpenError=new z.DatabaseClosed):(this._close(),e.autoOpen=this._options.autoOpen||e.isBeingOpened,e.openComplete=!1,e.dbOpenError=null)},nr.prototype.delete=function(e){var t=this;void 0===e&&(e={disableAutoOpen:!0});var n=0<arguments.length&&"object"!=typeof arguments[0],r=this._state;return new _e((function(i,o){function s(){t.close(e);var n=t._deps.indexedDB.deleteDatabase(t.name);n.onsuccess=Le((function(){var e,n,r;e=t._deps,n=t.name,r=e.indexedDB,e=e.IDBKeyRange,vn(r)||n===nt||yn(r,e).delete(n).catch(W),i()})),n.onerror=Nt(o),n.onblocked=t._fireOnBlocked}if(n)throw new z.InvalidArgument("Invalid closeOptions argument to db.delete()");r.isBeingOpened?r.dbReadyPromise.then(s):s()}))},nr.prototype.backendDB=function(){return this.idbdb},nr.prototype.isOpen=function(){return null!==this.idbdb},nr.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},nr.prototype.hasFailed=function(){return null!==this._state.dbOpenError},nr.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(nr.prototype,"tables",{get:function(){var e=this;return i(this._allTables).map((function(t){return e._allTables[t]}))},enumerable:!1,configurable:!0}),nr.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new z.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,T(i),n]}.apply(this,arguments);return this._transaction.apply(this,e)},nr.prototype._transaction=function(e,t,n){var r=this,i=ve.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);var o,s,a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(s=t.map((function(e){if("string"!=typeof(e=e instanceof r.Table?e.name:e))throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e})),"r"==e||e===rt)o=rt;else{if("rw"!=e&&e!=it)throw new z.InvalidArgument("Invalid transaction mode: "+e);o=it}if(i){if(i.mode===rt&&o===it){if(!a)throw new z.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&s.forEach((function(e){if(i&&-1===i.storeNames.indexOf(e)){if(!a)throw new z.SubTransaction("Table "+e+" not included in parent transaction.");i=null}})),a&&i&&!i.active&&(i=null)}}catch(c){return i?i._promise(null,(function(e,t){t(c)})):$e(c)}var u=function e(t,n,r,i,o){return _e.resolve().then((function(){var s=ve.transless||ve,a=t._createTransaction(n,r,t._dbSchema,i);if(a.explicit=!0,s={trans:a,transless:s},i)a.idbtrans=i.idbtrans;else try{a.create(),a.idbtrans._explicit=!0,t._state.PR1398_maxLoop=3}catch(l){return l.name===H.InvalidState&&t.isOpen()&&0<--t._state.PR1398_maxLoop?(t.close({disableAutoOpen:!1}),t.open().then((function(){return e(t,n,r,null,o)}))):$e(l)}var u,c=B(o);return c&&qe(),s=_e.follow((function(){var e;(u=o.call(a,a))&&(c?(e=He.bind(null,null),u.then(e,e)):"function"==typeof u.next&&"function"==typeof u.throw&&(u=Bn(u)))}),s),(u&&"function"==typeof u.then?_e.resolve(u).then((function(e){return a.active?e:$e(new z.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))})):s.then((function(){return u}))).then((function(e){return i&&a._resolve(),a._completion.then((function(){return e}))})).catch((function(e){return a._reject(e),$e(e)}))}))}.bind(null,this,o,s,i,n);return i?i._promise(o,u,"lock"):ve.trans?We(ve.transless,(function(){return r._whenReady(u)})):this._whenReady(u)},nr.prototype.table=function(e){if(!c(this._allTables,e))throw new z.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},nr);function nr(e,n){var r=this;this._middlewares={},this.verno=0;var i=nr.dependencies;this._options=n=t({addons:nr.addons,autoOpen:!0,indexedDB:i.indexedDB,IDBKeyRange:i.IDBKeyRange,cache:"cloned"},n),this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},i=n.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var o,s,a,u,c,l={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:W,dbReadyPromise:null,cancelOpen:W,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:n.autoOpen};l.dbReadyPromise=new _e((function(e){l.dbReadyResolve=e})),l.openCanceller=new _e((function(e,t){l.cancelOpen=t})),this._state=l,this.name=e,this.on=pt(this,"populate","blocked","versionchange","close",{ready:[ne,W]}),this.on.ready.subscribe=v(this.on.ready.subscribe,(function(e){return function(t,n){nr.vip((function(){var i,o=r._state;o.openComplete?(o.dbOpenError||_e.resolve().then(t),n&&e(t)):o.onReadyBeingFired?(o.onReadyBeingFired.push(t),n&&e(t)):(e(t),i=r,n||e((function e(){i.on.ready.unsubscribe(t),i.on.ready.unsubscribe(e)})))}))}})),this.Collection=(o=this,mt(St.prototype,(function(e,t){this.db=o;var n=st,r=null;if(t)try{n=t()}catch(s){r=s}var i=e._ctx;e=(t=i.table).hook.reading.fire,this._ctx={table:t,index:i.index,isPrimKey:!i.index||t.schema.primKey.keyPath&&i.index===t.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:i.or,valueMapper:e!==Y?e:null}}))),this.Table=(s=this,mt(ft.prototype,(function(e,t,n){this.db=s,this._tx=n,this.name=e,this.schema=t,this.hook=s._allTables[e]?s._allTables[e].hook:pt(null,{creating:[Z,W],reading:[Q,Y],updating:[ee,W],deleting:[J,W]})}))),this.Transaction=(a=this,mt(qt.prototype,(function(e,t,n,r,i){var o=this;this.db=a,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=pt(this,"complete","error","abort"),this.parent=i||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 _e((function(e,t){o._resolve=e,o._reject=t})),this._completion.then((function(){o.active=!1,o.on.complete.fire()}),(function(e){var t=o.active;return o.active=!1,o.on.error.fire(e),o.parent?o.parent._reject(e):t&&o.idbtrans&&o.idbtrans.abort(),$e(e)}))}))),this.Version=(u=this,mt(pn.prototype,(function(e){this.db=u,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}}))),this.WhereClause=(c=this,mt(Dt.prototype,(function(e,t,n){if(this.db=c,this._ctx={table:e,index:":id"===t?null:t,or:n},this._cmp=this._ascending=ct,this._descending=function(e,t){return ct(t,e)},this._max=function(e,t){return 0<ct(e,t)?e:t},this._min=function(e,t){return ct(e,t)<0?e:t},this._IDBKeyRange=c._deps.IDBKeyRange,!this._IDBKeyRange)throw new z.MissingAPI}))),this.on("versionchange",(function(e){e.newVersion,r.close({disableAutoOpen:!1})})),this.on("blocked",(function(e){!e.newVersion||(e.newVersion,e.oldVersion)})),this._maxKey=Xt(n.IDBKeyRange),this._createTransaction=function(e,t,n,i){return new r.Transaction(e,t,n,r._options.chromeTransactionDurability,i)},this._fireOnBlocked=function(e){r.on("blocked").fire(e),tt.filter((function(e){return e.name===r.name&&e!==r&&!e._state.vcFired})).map((function(t){return t.on("versionchange").fire(e)}))},this.use(Hn),this.use(Jn),this.use(Vn),this.use(jn),this.use(Un);var h=new Proxy(this,{get:function(e,t,n){if("_vip"===t)return!0;if("table"===t)return function(e){return er(r.table(e),h)};var i=Reflect.get(e,t,n);return i instanceof ft?er(i,h):"tables"===t?i.map((function(e){return er(e,h)})):"_createTransaction"===t?function(){return er(i.apply(this,arguments),h)}:i}});this.vip=h,i.forEach((function(e){return e(r)}))}N="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";var rr,ir=(or.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},or.prototype[N]=function(){return this},or);function or(e){this._subscribe=e}try{rr={indexedDB:r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.msIndexedDB,IDBKeyRange:r.IDBKeyRange||r.webkitIDBKeyRange}}catch(fr){rr={indexedDB:null,IDBKeyRange:null}}function sr(e){var t,n=!1,r=new ir((function(r){var i,o=B(e),s=!1,a={},u={},l={get closed(){return s},unsubscribe:function(){s||(s=!0,i&&i.abort(),h&&Ut.storagemutated.unsubscribe(d))}};r.start&&r.start(l);var h=!1,f=function(){return Qe(p)},d=function(e){En(a,e),kn(u,a)&&f()},p=function(){var l,p,m;!s&&rr.indexedDB&&(a={},l={},i&&i.abort(),i=new AbortController,m=function(t){var n=Oe();try{o&&qe();var r=Ue(e,t);return r=o?r.finally(He):r}finally{n&&Pe()}}(p={subscr:l,signal:i.signal,requery:f,querier:e,trans:null}),Promise.resolve(m).then((function(e){n=!0,t=e,s||p.signal.aborted||(a={},function(e){for(var t in e)if(c(e,t))return;return 1}(u=l)||h||(Ut(Kt,d),h=!0),Qe((function(){return!s&&r.next&&r.next(e)})))}),(function(e){n=!1,["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||s||Qe((function(){s||r.error&&r.error(e)}))})))};return setTimeout(f,0),l}));return r.hasValue=function(){return n},r.getValue=function(){return t},r}var ar=tr;function ur(e){var t=lr;try{lr=!0,Ut.storagemutated.fire(e),In(e,!0)}finally{lr=t}}l(ar,t(t({},X),{delete:function(e){return new ar(e,{addons:[]}).delete()},exists:function(e){return new ar(e,{addons:[]}).open().then((function(e){return e.close(),!0})).catch("NoSuchDatabaseError",(function(){return!1}))},getDatabaseNames:function(e){try{return n=(t=ar.dependencies).indexedDB,t=t.IDBKeyRange,(vn(n)?Promise.resolve(n.databases()).then((function(e){return e.map((function(e){return e.name})).filter((function(e){return e!==nt}))})):yn(n,t).toCollection().primaryKeys()).then(e)}catch(r){return $e(new z.MissingAPI)}var t,n},defineClass:function(){return function(e){s(this,e)}},ignoreTransaction:function(e){return ve.trans?We(ve.transless,e):e()},vip:gn,async:function(e){return function(){try{var t=Bn(e.apply(this,arguments));return t&&"function"==typeof t.then?t:_e.resolve(t)}catch(n){return $e(n)}}},spawn:function(e,t,n){try{var r=Bn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:_e.resolve(r)}catch(i){return $e(i)}},currentTransaction:{get:function(){return ve.trans||null}},waitFor:function(e,t){return t=_e.resolve("function"==typeof e?ar.ignoreTransaction(e):e).timeout(t||6e4),ve.trans?ve.trans.waitFor(t):t},Promise:_e,debug:{get:function(){return re},set:function(e){ie(e)}},derive:d,extend:s,props:l,override:v,Events:pt,on:Ut,liveQuery:sr,extendObservabilitySet:En,getByKeyPath:w,setByKeyPath:_,delByKeyPath:function(e,t){"string"==typeof t?_(e,t,void 0):"length"in t&&[].map.call(t,(function(t){_(e,t,void 0)}))},shallowClone:x,deepClone:k,getObjectDiff:Kn,cmp:ct,asap:b,minKey:-1/0,addons:[],connections:tt,errnames:H,dependencies:rr,cache:Mn,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)}))})),ar.maxKey=Xt(ar.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(Ut(Kt,(function(e){lr||(e=new CustomEvent(Ft,{detail:e}),lr=!0,dispatchEvent(e),lr=!1)})),addEventListener(Ft,(function(e){e=e.detail,lr||ur(e)})));var cr,lr=!1,hr=function(){};return"undefined"!=typeof BroadcastChannel&&((hr=function(){(cr=new BroadcastChannel(Ft)).onmessage=function(e){return e.data&&ur(e.data)}})(),"function"==typeof cr.unref&&cr.unref(),Ut(Kt,(function(e){lr||cr.postMessage(e)}))),"undefined"!=typeof addEventListener&&(addEventListener("pagehide",(function(e){if(!tr.disableBfCache&&e.persisted){null!=cr&&cr.close();for(var t=0,n=tt;t<n.length;t++)n[t].close({disableAutoOpen:!1})}})),addEventListener("pageshow",(function(e){!tr.disableBfCache&&e.persisted&&(hr(),ur({all:new wn(-1/0,[[]])}))}))),_e.rejectionMapper=function(e,t){return!e||e instanceof K||e instanceof TypeError||e instanceof SyntaxError||!e.name||!V[e.name]?e:(t=new V[e.name](t||e.message,e),"stack"in e&&f(t,"stack",{get:function(){return this.inner.stack}}),t)},ie(re),t(tr,Object.freeze({__proto__:null,Dexie:tr,liveQuery:sr,Entity:ut,cmp:ct,PropModification:At,replacePrefix:function(e,t){return new At({replacePrefix:[e,t]})},add:function(e){return new At({add:e})},remove:function(e){return new At({remove:e})},default:tr,RangeSet:wn,mergeRanges:xn,rangesOverlap:An}),{default:tr}),tr}()),Oe.exports)),Ce=Symbol.for("Dexie"),Ie=globalThis[Ce]||(globalThis[Ce]=Pe);if(Pe.semVer!==Ie.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${Pe.semVer} and ${Ie.semVer}`);const{liveQuery:Le,mergeRanges:De,rangesOverlap:Be,RangeSet:Ne,cmp:je,Entity:Ke,PropModification:Fe,replacePrefix:Ue,add:qe,remove:He}=Ie;class Ge{constructor(e="threeJsIDBCache",t=3){this.version=t,this.dbName=e,this.dbInit()}dbInit(){this.db=new Ie(this.dbName),this.materialMap={},this.db.version(this.version).stores({models:"&path, version, data"})}getDatabase(){return this.db}serObject3D(e){const t={type:e.type,name:e.name,position:e.position.toArray(),rotation:e.rotation.toArray(),scale:e.scale.toArray(),visible:e.visible,children:[],geometry:null,material:null,userData:e.userData};e.isMesh&&(t.geometry=this.serGeometry(e.geometry),t.material=this.serMaterial(e.material));for(const n of e.children)t.children.push(this.serObject3D(n));return t}serGeometry(e){const t=[],{attributes:n,index:r,type:i}=e;n.position&&(t.position={type:"Float32Array",array:Array.from(n.position.array),itemSize:3}),n.normal&&(t.normal={type:"Float32Array",array:Array.from(n.normal.array),itemSize:3}),n.uv&&(t.uv={type:"Float32Array",array:Array.from(n.uv.array),itemSize:2});const o={type:i,attributes:t};return r&&r.array&&(o.index={type:"Uint32Array",array:Array.from(r.array),itemSize:1}),o}reSerGeometry(e){const{type:t,attributes:n,index:r}=e,o=new i.BufferGeometry;return Object.keys(n).forEach((e=>{const{type:t,array:r,itemSize:s}=n[e];o.setAttribute(e,new i.BufferAttribute(new Float32Array(r),s))})),r&&o.setIndex(r.array),o}serMaterial(e){return{type:e.type,color:e.color.getHex(),map:e.map?e.map.image.src:null,opacity:e.opacity,name:e.name,depthTest:e.depthTest,depthWrite:e.depthWrite,transparent:e.transparent,side:e.side,roughness:e.roughness,metalness:e.metalness,emissive:e.emissive.getHex()}}reSerMaterial(e){if(this.materialMap[e.name])return this.materialMap[e.name];const{type:t,...n}=e,r=new i[t||"MeshStandardMaterial"]({...n});if(e.map){const t=(new i.TextureLoader).load(e.map);r.map=t}return r.needsUpdate=!0,this.materialMap[e.name]=r,r}reSerObject3D(e){let t;switch(e.type){case"Mesh":const n=this.reSerGeometry(e.geometry),r=this.reSerMaterial(e.material);t=new i.Mesh(n,r);break;case"Group":t=new i.Group;break;case"Object3D":t=new i.Object3D;break;default:return null}t.name=e.name,t.position.fromArray(e.position),t.rotation.fromArray(e.rotation),t.scale.fromArray(e.scale),t.visible=e.visible,t.userData=e.userData;for(const n of e.children){const e=this.reSerObject3D(n);e&&t.add(e)}return t}async cacheModel(e,t,n){const r=this.serObject3D(t);try{await this.db.table("models").put({version:n,path:e,data:r})}catch(i){}}async loadCachedModel(e,t){let n=null;try{if(n=await this.db.table("models").get(e),!n)return null;if(n.version!==t)return await this.db.table("models").delete(e),null}catch(r){return this.db.delete().then((()=>{this.init()})),null}try{return this.reSerObject3D(n.data)}catch(r){return null}}}let ze;exports.IDBCache=Ge,exports.intersectColor=Re,exports.obbObjects=Se,exports.useGLTFLoader=()=>{const e=new c,t=new a;return t.setDecoderPath("/draco/"),e.setDRACOLoader(t),{load:function(t,n,r,i){return e.load(t,n,r,i)},asyncLoad:function(t,n){return new Promise(((r,i)=>{e.load(t,r,n,i)}))},asyncCacheLoad:async function(t,n,r){ze||(ze=new Ge);const i=await ze.loadCachedModel(t,n);return i||new Promise(((n,i)=>{e.load(t,n,r,i)})).then((async e=>(await ze.cacheModel(t,e.scene,n),e.scene)))}}},exports.useObb=()=>{const t=(t,n)=>{if(n.userData.needCheck&&(n.autoUpdateMatrix=!1,n.updateMatrix(),n.updateMatrixWorld(),n.isMesh)){const r=new e.Box3(new e.Vector3).setFromObject(n);n.geometry.userData.obb=new xe,n.geometry.userData.obb.halfSize.copy(r.getSize(new e.Vector3)).multiplyScalar(.5).multiplyScalar(.88),n.userData.obb=new xe,n.userData.originColor=n.material.color.clone(),n.userData.parentUid=t,Se.push({object:n,parentUid:t})}};return{resetObbs:()=>{Se.splice(0)},initObb:(e,n)=>{n.traverse((n=>{n&&t(e,n)}))},getObbObjectByParentUid:e=>Se.filter((t=>t.parentUid===e)),addObbFromArray:(e,n)=>{for(let r=0,i=n.length;r<i;r++)t(e,n[r])},removeObbFromArray:e=>{const t=Se.filter((t=>!e.includes(t.object)));Se.splice(0,Se.length,...t)},removeUidObb:e=>{for(let t=Se.length-1;t>=0;t--)Se[t].parentUid===e&&Se.splice(t,1)}}},exports.useRaycaster=(t="app")=>{const n=new e.Raycaster;n.params.Line.threshold=8;const r=new e.Vector2,i=document.getElementById(t);function o(e,t){const{scaleX:n,scaleY:o}=s(i),{clientWidth:a,clientHeight:u}=t,c=t.getBoundingClientRect(),l=a*n,h=u*o,f=e.clientX-c.left,d=e.clientY-c.top;return r.x=(e.clientX-c.left)/l*2-1,r.y=-(e.clientY-c.top)/h*2+1,{pointer:r,x:f,y:d}}function s(e){const t=window.getComputedStyle(e),n=t.transform||t.webkitTransform||t.mozTransform;if(n&&"none"!==n){const e=n.match(/^matrix\((.+)\)$/);if(e){const t=e[1].split(", ");return{scaleX:parseFloat(t[0]),scaleY:parseFloat(t[3])}}}return{scaleX:1,scaleY:1}}return{raycaster:n,pointer:r,getPointer:o,getScale:s,getIntersects:function(e,t,r,i){const{pointer:s,x:a,y:u}=o(e,t);return n.setFromCamera(s,r),{intersects:n.intersectObjects(i),pointer:s,x:a,y:u}}}},exports.useThreeJs=function(r,i){const o=Object.assign({css3d:!1,stats:!1,renderType:"change",control:{init:!0,options:{}}},i||{});let s,a,u,c=[];const l=t.ref(!1),h=t.shallowRef(),f=t.ref(0),d=t.ref(0),p=new e.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),m=new e.Scene({}),y=new e.PerspectiveCamera(50,1,.1,2e3),v=Math.tan(Math.PI/180*y.fov/2);let g=!1;function b(){l.value=!1;const e=R();let r;if(f.value=e[0],d.value=e[1],y.aspect=f.value/d.value,y.position.set(47,39,100),y.fov=360/Math.PI*Math.atan(v*(d.value/f.value)),y.lookAt(0,0,0),y.updateProjectionMatrix(),p.setSize(f.value,d.value),s.appendChild(p.domElement),o.stats&&(a=new n.Stats,a.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",s.appendChild(a.dom)),o.css3d&&(u=new n.CSS3DRenderer,u.setSize(f.value,d.value),u.domElement.style.position="absolute",u.domElement.style.top=0,u.domElement.style.left=0,u.domElement.style.pointerEvents="none",s.appendChild(u.domElement)),o.control&&o.control.init){r=n.createOrbitControl(y,p.domElement);const e=Object.assign(Te,o.control.options||{});Object.keys(e).forEach((t=>{r[t]=e[t]}))}return t.nextTick((()=>l.value=!0)),r}function w(e){e.preventDefault(),cancelAnimationFrame(x)}function _(e){e.preventDefault(),b(),x()}function x(e){c&&c.length&&c.forEach((e=>{"function"==typeof e&&e()})),"loop"===o.renderType&&A(),requestAnimationFrame(x)}function A(){g=!1,a&&a.update(),h.value&&h.value.update(),p.render(m,y),u&&u.render(m,y)}function T(){g||(g=!0,requestAnimationFrame(A))}function S(){t.nextTick((()=>{const e=R();f.value=e[0],d.value=e[1],y.aspect=f.value/d.value,y.fov=360/Math.PI*Math.atan(v*(d.value/f.value)),y.updateProjectionMatrix(),y.lookAt(m.position),p.setSize(f.value,d.value),u&&u.setSize(f.value,d.value),A()}))}function R(){return s=document.querySelector(r),[s.clientWidth,s.clientHeight]}return p.setPixelRatio(window.devicePixelRatio),t.onMounted((()=>{h.value=b(),window.addEventListener("resize",S,!1),p.domElement.addEventListener("webglcontextlost",w,!1),p.domElement.addEventListener("webglcontextrestored",_,!1),"loop"===o.renderType?requestAnimationFrame(x):"change"===o.renderType&&h.value&&h.value.addEventListener("change",T)})),t.onUnmounted((()=>{cancelAnimationFrame(x),p.domElement.removeEventListener("resize",S,!1),p.domElement.removeEventListener("webglcontextlost",w,!1),p.domElement.removeEventListener("webglcontextrestored",_,!1),n.disposeThreeObject(m)})),{addAnimate:function(e){c.push(e)},frameArea:function(t,n,r,i,o){const s=(new e.Box3).setFromObject(t),a=s.getSize(new e.Vector3).length(),u=s.getCenter(new e.Vector3);o&&u.add(o);const c=.5*(a*n),l=e.MathUtils.degToRad(.5*r.fov),h=c/Math.tan(l),f=(new e.Vector3).subVectors(r.position,u).multiply(new e.Vector3(1,1,1)).normalize().multiplyScalar(h).add(u),d={x:f.x,y:f.y,z:f.z,lookAt_x:u.x,lookAt_y:u.y,lookAt_z:u.z};return r.position.set(d.x,d.y,d.z),r.lookAt(d.lookAt_x,d.lookAt_y,d.lookAt_z),r.updateProjectionMatrix(),i.target.copy(u),i.update(),a},onRender:A,css3dRenderer:u,scene:m,camera:y,control:h,renderer:p,domWidth:f,domHeight:d,isReady:l}};