diff --git a/dist/xeokit-sdk.cjs.js b/dist/xeokit-sdk.cjs.js index 2b56c76c73..238bc3278d 100644 --- a/dist/xeokit-sdk.cjs.js +++ b/dist/xeokit-sdk.cjs.js @@ -80391,7 +80391,7 @@ class SceneModelTransform { _addChildTransform(childTransform) { this._childTransforms.push(childTransform); childTransform._parentTransform = this; - childTransform._setWorldMatrixDirty(); + childTransform._transformDirty(); childTransform._setAABBDirty(); } @@ -115909,7 +115909,7 @@ function loadNode(ctx, node, depth, matrix) { meshCfg.opacity = 1.0; } - const backfaces = ((ctx.backfaces !== false) || (material.doubleSided !== false)); + const backfaces = ((ctx.backfaces !== false) || (material && material.doubleSided !== false)); switch (primitive.mode) { case 0: // POINTS diff --git a/dist/xeokit-sdk.es.js b/dist/xeokit-sdk.es.js index 4df218f8a5..cbf6c7f6fa 100644 --- a/dist/xeokit-sdk.es.js +++ b/dist/xeokit-sdk.es.js @@ -80387,7 +80387,7 @@ class SceneModelTransform { _addChildTransform(childTransform) { this._childTransforms.push(childTransform); childTransform._parentTransform = this; - childTransform._setWorldMatrixDirty(); + childTransform._transformDirty(); childTransform._setAABBDirty(); } @@ -115905,7 +115905,7 @@ function loadNode(ctx, node, depth, matrix) { meshCfg.opacity = 1.0; } - const backfaces = ((ctx.backfaces !== false) || (material.doubleSided !== false)); + const backfaces = ((ctx.backfaces !== false) || (material && material.doubleSided !== false)); switch (primitive.mode) { case 0: // POINTS diff --git a/dist/xeokit-sdk.es5.js b/dist/xeokit-sdk.es5.js index 1de921ff27..328f32b513 100644 --- a/dist/xeokit-sdk.es5.js +++ b/dist/xeokit-sdk.es5.js @@ -16791,7 +16791,7 @@ var edgeIndex=void 0;if((edgeIndex=edgeSearch(ii0,ii1))>=0){if(alreadyOutputEdge * Unique ID of this SceneModelTransform. * * The SceneModelTransform is registered against this ID in {@link SceneModel#transforms}. - */this.id=cfg.id;this._parentTransform=cfg.parent;this._childTransforms=[];this._meshes=[];this._scale=new Float32Array([1,1,1]);this._quaternion=math.identityQuaternion(new Float32Array(4));this._rotation=new Float32Array(3);this._position=new Float32Array(3);this._localMatrix=math.identityMat4(new Float32Array(16));this._worldMatrix=math.identityMat4(new Float32Array(16));this._localMatrixDirty=true;this._worldMatrixDirty=true;if(cfg.matrix){this.matrix=cfg.matrix;}else{this.scale=cfg.scale;this.position=cfg.position;if(cfg.quaternion);else{this.rotation=cfg.rotation;}}if(cfg.parent){cfg.parent._addChildTransform(this);}}_createClass(SceneModelTransform,[{key:"_addChildTransform",value:function _addChildTransform(childTransform){this._childTransforms.push(childTransform);childTransform._parentTransform=this;childTransform._setWorldMatrixDirty();childTransform._setAABBDirty();}},{key:"_addMesh",value:function _addMesh(mesh){this._meshes.push(mesh);mesh.transform=this;// childTransform._setWorldMatrixDirty(); + */this.id=cfg.id;this._parentTransform=cfg.parent;this._childTransforms=[];this._meshes=[];this._scale=new Float32Array([1,1,1]);this._quaternion=math.identityQuaternion(new Float32Array(4));this._rotation=new Float32Array(3);this._position=new Float32Array(3);this._localMatrix=math.identityMat4(new Float32Array(16));this._worldMatrix=math.identityMat4(new Float32Array(16));this._localMatrixDirty=true;this._worldMatrixDirty=true;if(cfg.matrix){this.matrix=cfg.matrix;}else{this.scale=cfg.scale;this.position=cfg.position;if(cfg.quaternion);else{this.rotation=cfg.rotation;}}if(cfg.parent){cfg.parent._addChildTransform(this);}}_createClass(SceneModelTransform,[{key:"_addChildTransform",value:function _addChildTransform(childTransform){this._childTransforms.push(childTransform);childTransform._parentTransform=this;childTransform._transformDirty();childTransform._setAABBDirty();}},{key:"_addMesh",value:function _addMesh(mesh){this._meshes.push(mesh);mesh.transform=this;// childTransform._setWorldMatrixDirty(); // childTransform._setAABBDirty(); }/** * The optional parent SceneModelTransform. @@ -24476,7 +24476,7 @@ numObjects:0,nodes:[],nextId:0,log:function log(msg){plugin.log(msg);}};loadText // materialCfg.alphaCutoff = alphaCutoff; // } var metallicPBR=material.pbrMetallicRoughness;if(material.pbrMetallicRoughness){var pbrMetallicRoughness=material.pbrMetallicRoughness;var baseColorTexture=pbrMetallicRoughness.baseColorTexture||pbrMetallicRoughness.colorTexture;if(baseColorTexture){if(baseColorTexture.texture){textureSetCfg.colorTextureId=baseColorTexture.texture._textureId;}else{textureSetCfg.colorTextureId=ctx.gltfData.textures[baseColorTexture.index]._textureId;}}if(metallicPBR.metallicRoughnessTexture){textureSetCfg.metallicRoughnessTextureId=metallicPBR.metallicRoughnessTexture.texture._textureId;}}var extensions=material.extensions;if(extensions){var specularPBR=extensions["KHR_materials_pbrSpecularGlossiness"];if(specularPBR){specularPBR.specularTexture;var specularColorTexture=specularPBR.specularColorTexture;if(specularColorTexture!==null&&specularColorTexture!==undefined){textureSetCfg.colorTextureId=ctx.gltfData.textures[specularColorTexture.index]._textureId;}}}if(textureSetCfg.normalTextureId!==undefined||textureSetCfg.occlusionTextureId!==undefined||textureSetCfg.emissiveTextureId!==undefined||textureSetCfg.colorTextureId!==undefined||textureSetCfg.metallicRoughnessTextureId!==undefined){textureSetCfg.id="textureSet-".concat(ctx.nextId++,";");ctx.sceneModel.createTextureSet(textureSetCfg);return textureSetCfg.id;}return null;}function loadMaterialAttributes(ctx,material){// Substitute RGBA for material, to use fast flat shading instead -var extensions=material.extensions;var materialAttributes={color:new Float32Array([1,1,1,1]),opacity:1,metallic:0,roughness:1,doubleSided:true};if(extensions){var specularPBR=extensions["KHR_materials_pbrSpecularGlossiness"];if(specularPBR){var diffuseFactor=specularPBR.diffuseFactor;if(diffuseFactor!==null&&diffuseFactor!==undefined){materialAttributes.color.set(diffuseFactor);}}var common=extensions["KHR_materials_common"];if(common){var technique=common.technique;var values=common.values||{};var blinn=technique==="BLINN";var phong=technique==="PHONG";var lambert=technique==="LAMBERT";var diffuse=values.diffuse;if(diffuse&&(blinn||phong||lambert)){if(!utils.isString(diffuse)){materialAttributes.color.set(diffuse);}}var transparency=values.transparency;if(transparency!==null&&transparency!==undefined){materialAttributes.opacity=transparency;}var transparent=values.transparent;if(transparent!==null&&transparent!==undefined){materialAttributes.opacity=transparent;}}}var metallicPBR=material.pbrMetallicRoughness;if(metallicPBR){var baseColorFactor=metallicPBR.baseColorFactor;if(baseColorFactor){materialAttributes.color[0]=baseColorFactor[0];materialAttributes.color[1]=baseColorFactor[1];materialAttributes.color[2]=baseColorFactor[2];materialAttributes.opacity=baseColorFactor[3];}var metallicFactor=metallicPBR.metallicFactor;if(metallicFactor!==null&&metallicFactor!==undefined){materialAttributes.metallic=metallicFactor;}var roughnessFactor=metallicPBR.roughnessFactor;if(roughnessFactor!==null&&roughnessFactor!==undefined){materialAttributes.roughness=roughnessFactor;}}materialAttributes.doubleSided=material.doubleSided!==false;return materialAttributes;}function loadDefaultScene(ctx){var gltfData=ctx.gltfData;var scene=gltfData.scene||gltfData.scenes[0];if(!scene){error(ctx,"glTF has no default scene");return;}loadScene(ctx,scene);}function loadScene(ctx,scene){var nodes=scene.nodes;if(!nodes){return;}for(var _i512=0,len=nodes.length;_i5120){for(var _i515=0;_i5150){for(var _i515=0;_i515>t;i.sort(wA);const s=new Int32Array(e.length);for(let t=0,r=i.length;te[t+1]){let i=e[t];e[t]=e[t+1],e[t+1]=i}PA=new Int32Array(e),t.sort(CA);const i=new Int32Array(e.length);for(let s=0,r=t.length;st){let i=e;e=t,t=i}function i(i,s){return i!==e?e-i:s!==t?t-s:0}let s=0,r=(o.length>>1)-1;for(;s<=r;){const e=r+s>>1,t=i(o[2*e],o[2*e+1]);if(t>0)s=e+1;else{if(!(t<0))return e;r=e-1}}return-s-1}const a=new Int32Array(o.length/2);a.fill(0);const l=s.length/3;if(l>8*(1<u.maxNumPositions&&(u=c()),u.bucketNumber>8)return[e];let p;-1===A[l]&&(A[l]=u.numPositions++,u.positionsCompressed.push(s[3*l]),u.positionsCompressed.push(s[3*l+1]),u.positionsCompressed.push(s[3*l+2])),-1===A[h]&&(A[h]=u.numPositions++,u.positionsCompressed.push(s[3*h]),u.positionsCompressed.push(s[3*h+1]),u.positionsCompressed.push(s[3*h+2])),-1===A[d]&&(A[d]=u.numPositions++,u.positionsCompressed.push(s[3*d]),u.positionsCompressed.push(s[3*d+1]),u.positionsCompressed.push(s[3*d+2])),u.indices.push(A[l]),u.indices.push(A[h]),u.indices.push(A[d]),(p=n(l,h))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]])),(p=n(l,d))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]])),(p=n(h,d))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]]))}const d=t/8*2,p=t/8,f=2*s.length+(r.length+o.length)*d;let g=0,m=-s.length/3;return h.forEach((e=>{g+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*p,m+=e.positionsCompressed.length/3})),g>f?[e]:(i&&function(e,t){const i={},s={};let r=0;e.forEach((e=>{const t=e.indices,o=e.edgeIndices,n=e.positionsCompressed;for(let e=0,s=t.length;e0){const e=t._meshes;for(let t=0,i=e.length;t0){const e=this._meshes;for(let t=0,i=e.length;t{this._viewMatrixDirty=!0})),this._meshesWithDirtyMatrices=[],this._numMeshesWithDirtyMatrices=0,this._onTick=this.scene.on("tick",(()=>{for(;this._numMeshesWithDirtyMatrices>0;)this._meshesWithDirtyMatrices[--this._numMeshesWithDirtyMatrices]._updateMatrix()})),this._createDefaultTextureSet(),this.visible=t.visible,this.culled=t.culled,this.pickable=t.pickable,this.clippable=t.clippable,this.collidable=t.collidable,this.castsShadow=t.castsShadow,this.receivesShadow=t.receivesShadow,this.xrayed=t.xrayed,this.highlighted=t.highlighted,this.selected=t.selected,this.edges=t.edges,this.colorize=t.colorize,this.opacity=t.opacity,this.backfaces=t.backfaces}_meshMatrixDirty(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}_createDefaultTextureSet(){const e=new aA({id:"defaultColorTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),t=new aA({id:"defaultMetalRoughTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),i=new aA({id:"defaultNormalsTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),s=new aA({id:"defaultEmissiveTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),r=new aA({id:"defaultOcclusionTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures.defaultColorTexture=e,this._textures.defaultMetalRoughTexture=t,this._textures.defaultNormalsTexture=i,this._textures.defaultEmissiveTexture=s,this._textures.defaultOcclusionTexture=r,this._textureSets.defaultTextureSet=new nA({id:"defaultTextureSet",model:this,colorTexture:e,metallicRoughnessTexture:t,normalsTexture:i,emissiveTexture:s,occlusionTexture:r})}get isPerformanceModel(){return!0}get transforms(){return this._transforms}get textures(){return this._textures}get textureSets(){return this._textureSets}get meshes(){return this._meshes}get objects(){return this._entities}get origin(){return this._origin}set position(e){this._position.set(e||[0,0,0]),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get position(){return this._position}set rotation(e){this._rotation.set(e||[0,0,0]),c.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get rotation(){return this._rotation}set quaternion(e){this._quaternion.set(e||[0,0,0,1]),c.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get quaternion(){return this._quaternion}set scale(e){}get scale(){return this._scale}set matrix(e){this._matrix.set(e||HA),c.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),c.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),c.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),c.translateMat4v(this._position,this._matrix),this._matrixDirty=!1,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get matrix(){return this._matrixDirty&&this._rebuildMatrices(),this._matrix}get rotationMatrix(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrix}_rebuildMatrices(){this._matrixDirty&&(c.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),c.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),c.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),c.translateMat4v(this._position,this._matrix),this._matrixDirty=!1)}get rotationMatrixConjugate(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrixConjugate}_setWorldMatrixDirty(){this._matrixDirty=!0,this._aabbDirty=!0}_transformDirty(){this._matrixDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0}_sceneModelDirty(){this.scene._aabbDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._matrixDirty=!0;for(let e=0,t=this._entityList.length;e0}set visible(e){e=!1!==e,this._visible=e;for(let t=0,i=this._entityList.length;t0}set xrayed(e){e=!!e,this._xrayed=e;for(let t=0,i=this._entityList.length;t0}set highlighted(e){e=!!e,this._highlighted=e;for(let t=0,i=this._entityList.length;t0}set selected(e){e=!!e,this._selected=e;for(let t=0,i=this._entityList.length;t0}set edges(e){e=!!e,this._edges=e;for(let t=0,i=this._entityList.length;t0}set pickable(e){e=!1!==e,this._pickable=e;for(let t=0,i=this._entityList.length;t0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){const t=e.colors,i=new Uint8Array(t.length);for(let e=0,s=t.length;e{l.setImage(A,{minFilter:i,magFilter:s,wrapS:r,wrapT:o,wrapR:n,flipY:e.flipY,encoding:a}),this.glRedraw()},A.src=e.src;break;default:this._textureTranscoder?_.loadArraybuffer(e.src,(e=>{e.byteLength?this._textureTranscoder.transcode([e],l).then((()=>{this.glRedraw()})):this.error("[createTexture] Can't create texture from 'src': file data is zero length")}),(function(e){this.error(`[createTexture] Can't create texture from 'src': ${e}`)})):this.error(`[createTexture] Can't create texture from 'src' - SceneModel needs to be configured with a TextureTranscoder for this file type ('${t}')`)}}else e.buffers&&(this._textureTranscoder?this._textureTranscoder.transcode(e.buffers,l).then((()=>{this.glRedraw()})):this.error("[createTexture] Can't create texture from 'buffers' - SceneModel needs to be configured with a TextureTranscoder for this option"));this._textures[t]=new aA({id:t,texture:l})}createTextureSet(e){const t=e.id;if(null==t)return void this.error("[createTextureSet] Config missing: id");if(this._textureSets[t])return void this.error(`[createTextureSet] Texture set already created: ${t}`);let i,s,r,o,n;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(i=this._textures[e.colorTextureId],!i)return void this.error(`[createTextureSet] Texture not found: ${e.colorTextureId} - ensure that you create it first with createTexture()`)}else i=this._textures.defaultColorTexture;if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(s=this._textures[e.metallicRoughnessTextureId],!s)return void this.error(`[createTextureSet] Texture not found: ${e.metallicRoughnessTextureId} - ensure that you create it first with createTexture()`)}else s=this._textures.defaultMetalRoughTexture;if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(r=this._textures[e.normalsTextureId],!r)return void this.error(`[createTextureSet] Texture not found: ${e.normalsTextureId} - ensure that you create it first with createTexture()`)}else r=this._textures.defaultNormalsTexture;if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(o=this._textures[e.emissiveTextureId],!o)return void this.error(`[createTextureSet] Texture not found: ${e.emissiveTextureId} - ensure that you create it first with createTexture()`)}else o=this._textures.defaultEmissiveTexture;if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(n=this._textures[e.occlusionTextureId],!n)return void this.error(`[createTextureSet] Texture not found: ${e.occlusionTextureId} - ensure that you create it first with createTexture()`)}else n=this._textures.defaultOcclusionTexture;const a=new nA({id:t,model:this,colorTexture:i,metallicRoughnessTexture:s,normalsTexture:r,emissiveTexture:o,occlusionTexture:n});return this._textureSets[t]=a,a}createTransform(e){if(void 0===e.id||null===e.id)return void this.error("[createTransform] SceneModel.createTransform() config missing: id");if(this._transforms[e.id])return void this.error(`[createTransform] SceneModel already has a transform with this ID: ${e.id}`);let t;if(e.parentTransformId&&(t=this._transforms[e.parentTransformId],!t))return void this.error("[createTransform] SceneModel.createTransform() config missing: id");const i=new LA({id:e.id,model:this,parent:t,matrix:e.matrix,position:e.position,scale:e.scale,rotation:e.rotation,quaternion:e.quaternion});return this._transforms[i.id]=i,i}createMesh(e){if(void 0===e.id||null===e.id)return this.error("[createMesh] SceneModel.createMesh() config missing: id"),!1;if(this._meshes[e.id])return this.error(`[createMesh] SceneModel already has a mesh with this ID: ${e.id}`),!1;if(!(void 0!==e.geometryId)){if(void 0!==e.primitive&&null!==e.primitive||(e.primitive="triangles"),"points"!==e.primitive&&"lines"!==e.primitive&&"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)return this.error(`Unsupported value for 'primitive': '${primitive}' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.`),!1;if(!e.positions&&!e.positionsCompressed&&!e.buckets)return this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)"),!1;if(e.positions&&(e.positionsDecodeMatrix||e.positionsDecodeBoundary))return this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.positionsCompressed&&!e.positionsDecodeMatrix&&!e.positionsDecodeBoundary)return this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.uvCompressed&&!e.uvDecodeMatrix)return this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)"),!1;if(!(e.buckets||e.indices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)){const t=(e.positions||e.positionsCompressed).length/3;e.indices=this._createDefaultIndices(t)}if(!e.buckets&&!e.indices&&"points"!==e.primitive)return e.indices=this._createDefaultIndices(numIndices),this.error(`Param expected: indices (required for '${e.primitive}' primitive type)`),!1;if((e.matrix||e.position||e.rotation||e.scale)&&(e.positionsCompressed||e.positionsDecodeBoundary))return this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'"),!1;const t=!(!this._dtxEnabled||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||e.textureSetId);if(e.origin=e.origin?c.addVec3(this._origin,e.origin,c.vec3()):this._origin,e.matrix)e.meshMatrix=e.matrix;else if(e.scale||e.rotation||e.position){const t=e.scale||OA,i=e.position||NA,s=e.rotation||QA;c.eulerToQuaternion(s,"XYZ",VA),e.meshMatrix=c.composeMat4(i,VA,t,c.mat4())}if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=Tr(e.positionsDecodeBoundary,c.mat4())),t){if(e.type=2,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):jA,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.positions){const t=c.vec3(),i=[];z(e.positions,i,t)&&(e.positions=i,e.origin=c.addVec3(e.origin,t,t))}if(e.positions){const t=c.collapseAABB3();e.positionsDecodeMatrix=c.mat4(),c.expandAABB3Points3(t,e.positions),e.positionsCompressed=Sr(e.positions,t,e.positionsDecodeMatrix),e.aabb=t}else if(e.positionsCompressed){const t=c.collapseAABB3();c.expandAABB3Points3(t,e.positionsCompressed),Tt.decompressAABB(t,e.positionsDecodeMatrix),e.aabb=t}if(e.buckets){const t=c.collapseAABB3();for(let i=0,s=e.buckets.length;i>24&255,r=i>>16&255,o=i>>8&255,n=255&i;switch(e.pickColor=new Uint8Array([n,o,r,s]),e.solid="solid"===e.primitive,t.origin=c.vec3(e.origin),e.type){case 2:t.layer=this._getDTXLayer(e),t.aabb=e.aabb;break;case 1:t.layer=this._getVBOBatchingLayer(e),t.aabb=e.aabb;break;case 0:t.layer=this._getVBOInstancingLayer(e),t.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),t.portionId=t.layer.createPortion(t,e),this._meshes[e.id]=t,this._unusedMeshes[e.id]=t,this._meshList.push(t),t}_getNumPrimitives(e){let t=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(let i=0,s=e.buckets.length;i>>0).toString(16)}_getVBOInstancingLayer(e){const t=this,i=e.origin,s=e.textureSetId||"-",r=e.geometryId,o=`${Math.round(i[0])}.${Math.round(i[1])}.${Math.round(i[2])}.${s}.${r}`;let n=this._vboInstancingLayers[o];if(n)return n;let a=e.textureSet;const l=e.geometry;for(;!n;)switch(l.primitive){case"triangles":case"surface":n=new Oo({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!1});break;case"solid":n=new Oo({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!0});break;case"lines":n=new wn({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0});break;case"points":n=new ma({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0})}return this._vboInstancingLayers[o]=n,this.layerList.push(n),n}createEntity(e){if(void 0===e.id?e.id=c.createUUID():this.scene.components[e.id]&&(this.error(`Scene already has a Component with this ID: ${e.id} - will assign random ID`),e.id=c.createUUID()),void 0===e.meshIds)return void this.error("Config missing: meshIds");let t=0;this._visible&&!1!==e.visible&&(t|=K),this._pickable&&!1!==e.pickable&&(t|=J),this._culled&&!1!==e.culled&&(t|=X),this._clippable&&!1!==e.clippable&&(t|=Y),this._collidable&&!1!==e.collidable&&(t|=Z),this._edges&&!1!==e.edges&&(t|=te),this._xrayed&&!1!==e.xrayed&&(t|=q),this._highlighted&&!1!==e.highlighted&&(t|=$),this._selected&&!1!==e.selected&&(t|=ee),e.flags=t,this._createEntity(e)}_createEntity(e){let t=[];for(let i=0,s=e.meshIds.length;ie.sortIdt.sortId?1:0));for(let e=0,t=this.layerList.length;e0&&0===this.renderFlags.numVisibleLayers?this.renderFlags.culled=!0:this._updateRenderFlags()}_updateRenderFlagsVisibleLayers(){const e=this.renderFlags;e.numLayers=this.layerList.length,e.numVisibleLayers=0;for(let t=0,i=this.layerList.length;t0){const t=`${this.id}-dummyEntityForUnusedMeshes`;this.warn(`Creating dummy SceneModelEntity "${t}" for unused SceneMeshes: [${e.join(",")}]`),this.createEntity({id:t,meshIds:e,isObject:!0})}this._unusedMeshes={}}_getActiveSectionPlanesForLayer(e){const t=this.renderFlags,i=this.scene._sectionPlanesState.sectionPlanes,s=i.length,r=e.layerIndex*s;if(s>0)for(let e=0;e0&&(e.colorTransparent=!0),this.numXRayedLayerPortions>0){const t=this.scene.xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}if(this.numEdgesLayerPortions>0){this.scene.edgeMaterial._state.edges&&(e.edgesOpaque=this.numTransparentLayerPortions0&&(e.edgesTransparent=!0))}if(this.numSelectedLayerPortions>0){const t=this.scene.selectedMaterial._state;t.fill&&(t.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){const t=this.scene.highlightMaterial._state;t.fill&&(t.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}drawColorOpaque(e){const t=this.renderFlags;for(let i=0,s=t.visibleLayers.length;i65536?16:8)}else n=[{positionsCompressed:s,indices:r,edgeIndices:o}];return n}class WA extends D{constructor(e,t={}){if(super(e,t),this._positions=t.positions||[],t.indices)this._indices=t.indices;else{this._indices=[];for(let e=0,t=this._positions.length/3-1;e{var r=e-i,o=t-s;return Math.sqrt(r*r+o*o)};class sh extends D{constructor(e,t={}){if(super(e.viewer.scene,t),this.plugin=e,this._container=t.container,!this._container)throw"config missing: container";this._eventSubs={};var i=this.plugin.viewer.scene;this._originMarker=new ae(i,t.origin),this._targetMarker=new ae(i,t.target),this._originWorld=c.vec3(),this._targetWorld=c.vec3(),this._wp=new Float64Array(24),this._vp=new Float64Array(24),this._pp=new Float64Array(24),this._cp=new Float64Array(8),this._xAxisLabelCulled=!1,this._yAxisLabelCulled=!1,this._zAxisLabelCulled=!1,this._color=t.color||this.plugin.defaultColor;const s=t.onMouseOver?e=>{t.onMouseOver(e,this),this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,r=t.onMouseLeave?e=>{t.onMouseLeave(e,this),this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,o=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},n=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},a=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},l=t.onContextMenu?e=>{t.onContextMenu(e,this)}:null,A=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};this._originDot=new Ae(this._container,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._targetDot=new Ae(this._container,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._lengthWire=new le(this._container,{color:this._color,thickness:2,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._xAxisWire=new le(this._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._yAxisWire=new le(this._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._zAxisWire=new le(this._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._lengthLabel=new he(this._container,{fillColor:this._color,prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._xAxisLabel=new he(this._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._yAxisLabel=new he(this._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._zAxisLabel=new he(this._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._wpDirty=!1,this._vpDirty=!1,this._cpDirty=!1,this._sectionPlanesDirty=!0,this._visible=!1,this._originVisible=!1,this._targetVisible=!1,this._wireVisible=!1,this._axisVisible=!1,this._xAxisVisible=!1,this._yAxisVisible=!1,this._zAxisVisible=!1,this._axisEnabled=!0,this._labelsVisible=!1,this._labelsOnWires=!1,this._clickable=!1,this._originMarker.on("worldPos",(e=>{this._originWorld.set(e||[0,0,0]),this._wpDirty=!0,this._needUpdate(0)})),this._targetMarker.on("worldPos",(e=>{this._targetWorld.set(e||[0,0,0]),this._wpDirty=!0,this._needUpdate(0)})),this._onViewMatrix=i.camera.on("viewMatrix",(()=>{this._vpDirty=!0,this._needUpdate(0)})),this._onProjMatrix=i.camera.on("projMatrix",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onCanvasBoundary=i.canvas.on("boundary",(()=>{this._cpDirty=!0,this._needUpdate(0)})),this._onMetricsUnits=i.metrics.on("units",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onMetricsScale=i.metrics.on("scale",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onMetricsOrigin=i.metrics.on("origin",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onSectionPlaneUpdated=i.on("sectionPlaneUpdated",(()=>{this._sectionPlanesDirty=!0,this._needUpdate()})),this.approximate=t.approximate,this.visible=t.visible,this.originVisible=t.originVisible,this.targetVisible=t.targetVisible,this.wireVisible=t.wireVisible,this.axisVisible=t.axisVisible,this.xAxisVisible=t.xAxisVisible,this.yAxisVisible=t.yAxisVisible,this.zAxisVisible=t.zAxisVisible,this.labelsVisible=t.labelsVisible,this.labelsOnWires=t.labelsOnWires}_update(){if(!this._visible)return;const e=this.plugin.viewer.scene;if(this._wpDirty&&(this._wp[0]=this._originWorld[0],this._wp[1]=this._originWorld[1],this._wp[2]=this._originWorld[2],this._wp[3]=1,this._wp[4]=this._targetWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._targetWorld[0],this._wp[9]=this._targetWorld[1],this._wp[10]=this._originWorld[2],this._wp[11]=1,this._wp[12]=this._targetWorld[0],this._wp[13]=this._targetWorld[1],this._wp[14]=this._targetWorld[2],this._wp[15]=1,this._wpDirty=!1,this._vpDirty=!0),this._vpDirty&&(c.transformPositions4(e.camera.viewMatrix,this._wp,this._vp),this._vp[3]=1,this._vp[7]=1,this._vp[11]=1,this._vp[15]=1,this._vpDirty=!1,this._cpDirty=!0),this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld))return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setCulled(!0),this._yAxisWire.setCulled(!0),this._zAxisWire.setCulled(!0),this._lengthWire.setCulled(!0),this._originDot.setCulled(!0),void this._targetDot.setCulled(!0);this._xAxisLabel.setCulled(!1),this._yAxisLabel.setCulled(!1),this._zAxisLabel.setCulled(!1),this._lengthLabel.setCulled(!1),this._xAxisWire.setCulled(!1),this._yAxisWire.setCulled(!1),this._zAxisWire.setCulled(!1),this._lengthWire.setCulled(!1),this._originDot.setCulled(!1),this._targetDot.setCulled(!1),this._sectionPlanesDirty=!0}const t=this._originMarker.viewPos[2],i=this._targetMarker.viewPos[2];if(t>-.3||i>-.3)return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setVisible(!1),this._yAxisWire.setVisible(!1),this._zAxisWire.setVisible(!1),this._lengthWire.setVisible(!1),this._originDot.setVisible(!1),void this._targetDot.setVisible(!1);if(this._cpDirty){c.transformPositions4(e.camera.project.matrix,this._vp,this._pp);var s=this._pp,r=this._cp,o=e.canvas.canvas.getBoundingClientRect();const t=this._container.getBoundingClientRect();var n=o.top-t.top,a=o.left-t.left,l=e.canvas.boundary,A=l[2],h=l[3],u=0;const i=this.plugin.viewer.scene.metrics,f=i.scale,g=i.units,m=i.unitsInfo[g].abbrev;for(var d=0,p=s.length;de.offsetTop+(e.offsetParent&&h(e.offsetParent)),u=e=>e.offsetLeft+(e.offsetParent&&u(e.offsetParent)),d=c.vec2();this._onCameraControlHoverSnapOrSurface=i.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(e=>{const t=e.snappedCanvasPos||e.canvasPos;r=!0,o.set(e.worldPos),n.set(e.canvasPos),0===this._mouseState?(this._canvasToPagePos?(this._canvasToPagePos(s,t,d),this._markerDiv.style.left=d[0]-5+"px",this._markerDiv.style.top=d[1]-5+"px"):(this._markerDiv.style.left=u(s)+t[0]-5+"px",this._markerDiv.style.top=h(s)+t[1]-5+"px"),this._markerDiv.style.background="pink",e.snappedToVertex||e.snappedToEdge?(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,this.pointerLens.snapped=!0),this._markerDiv.style.background="greenyellow",this._markerDiv.style.border="2px solid green"):(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.canvasPos,this.pointerLens.snapped=!1),this._markerDiv.style.background="pink",this._markerDiv.style.border="2px solid red"),A=e.entity):(this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px"),s.style.cursor="pointer",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=this._currentDistanceMeasurementInitState.wireVisible,this._currentDistanceMeasurement.axisVisible=this._currentDistanceMeasurementInitState.axisVisible&&this.distanceMeasurementsPlugin.defaultAxisVisible,this._currentDistanceMeasurement.xAxisVisible=this._currentDistanceMeasurementInitState.xAxisVisible&&this.distanceMeasurementsPlugin.defaultXAxisVisible,this._currentDistanceMeasurement.yAxisVisible=this._currentDistanceMeasurementInitState.yAxisVisible&&this.distanceMeasurementsPlugin.defaultYAxisVisible,this._currentDistanceMeasurement.zAxisVisible=this._currentDistanceMeasurementInitState.zAxisVisible&&this.distanceMeasurementsPlugin.defaultZAxisVisible,this._currentDistanceMeasurement.targetVisible=this._currentDistanceMeasurementInitState.targetVisible,this._currentDistanceMeasurement.target.worldPos=o.slice(),this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px")})),s.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(a=e.clientX,l=e.clientY)}),s.addEventListener("mouseup",this._onMouseUp=t=>{1===t.which&&(t.clientX>a+20||t.clientXl+20||t.clientY{this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos),r=!1,this._markerDiv.style.left="-100px",this._markerDiv.style.top="-100px",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.axisVisible=!1),s.style.cursor="default"})),this._active=!0}deactivate(){if(!this._active)return;this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1),this._markerDiv&&this._destroyMarkerDiv(),this.reset();const e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);const t=this.distanceMeasurementsPlugin.viewer.cameraControl;t.off(this._onCameraControlHoverSnapOrSurface),t.off(this._onCameraControlHoverSnapOrSurfaceOff),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._active=!1}reset(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null))}destroy(){this.deactivate(),super.destroy()}}class nh{constructor(){}getMetaModel(e,t,i){_.loadJSON(e,(e=>{t(e)}),(function(e){i(e)}))}getGLTF(e,t,i){_.loadArraybuffer(e,(e=>{t(e)}),(function(e){i(e)}))}getGLB(e,t,i){_.loadArraybuffer(e,(e=>{t(e)}),(function(e){i(e)}))}getArrayBuffer(e,t,i,s){!function(e,t,i,s){var r=()=>{};i=i||r,s=s||r;const o=/^data:(.*?)(;base64)?,(.*)$/,n=t.match(o);if(n){const e=!!n[2];var a=n[3];a=window.decodeURIComponent(a),e&&(a=window.atob(a));try{const e=new ArrayBuffer(a.length),t=new Uint8Array(e);for(var l=0;l{i(e)}),(function(e){s(e)}))}}class ah{constructor(e={}){this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=e.messages,this.locale=e.locale}set messages(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}loadMessages(e={}){for(let t in e)this._messages[t]=e[t];this.messages=this._messages}clearMessages(){this.messages={}}get locales(){return this._locales}set locale(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}get locale(){return this._locale}translate(e,t){const i=this._messages[this._locale];if(!i)return null;const s=lh(e,i);return s?t?Ah(s,t):s:null}translatePlurals(e,t,i){const s=this._messages[this._locale];if(!s)return null;let r=lh(e,s);return r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one,r?(r=Ah(r,[t]),i&&(r=Ah(r,i)),r):null}fire(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);const s=this._eventSubs[e];if(s)for(const e in s)if(s.hasOwnProperty(e)){s[e].callback(t)}}on(t,i){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new e),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});let s=this._eventSubs[t];s||(s={},this._eventSubs[t]=s);const r=this._eventSubIDMap.addItem();s[r]={callback:i},this._eventSubEvents[r]=t;const o=this._events[t];return void 0!==o&&i(o),r}off(e){if(null==e)return;if(!this._eventSubEvents)return;const t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];const i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}function lh(e,t){if(t[e])return t[e];const i=e.split(".");let s=t;for(let e=0,t=i.length;s&&e1?1:e}get t(){return this._t}get tangent(){return this.getTangent(this._t)}get length(){var e=this._getLengths();return e[e.length-1]}getTangent(e){var t=1e-4;void 0===e&&(e=this._t);var i=e-t,s=e+t;i<0&&(i=0),s>1&&(s=1);var r=this.getPoint(i),o=this.getPoint(s),n=c.subVec3(o,r,[]);return c.normalizeVec3(n,[])}getPointAt(e){var t=this.getUToTMapping(e);return this.getPoint(t)}getPoints(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}_getLengths(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,s=[],r=this.getPoint(0),o=0;for(s.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),o+=c.lenVec3(c.subVec3(t,r,[])),s.push(o),r=t;return this.cacheArcLengths=s,s}_updateArcLengths(){this.needsUpdate=!0,this._getLengths()}getUToTMapping(e,t){var i,s=this._getLengths(),r=0,o=s.length;i=t||e*s[o-1];for(var n,a=0,l=o-1;a<=l;)if((n=s[r=Math.floor(a+(l-a)/2)]-i)<0)a=r+1;else{if(!(n>0)){l=r;break}l=r-1}if(s[r=l]===i)return r/(o-1);var A=s[r];return(r+(i-A)/(s[r+1]-A))/(o-1)}}class ch extends hh{constructor(e,t={}){super(e,t),this.points=t.points,this.t=t.t}set points(e){this._points=e||[]}get points(){return this._points}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=this.points;if(!(t.length<3)){var i=(t.length-1)*e,s=Math.floor(i),r=i-s,o=t[0===s?s:s-1],n=t[s],a=t[s>t.length-2?t.length-1:s+1],l=t[s>t.length-3?t.length-1:s+2],A=c.vec3();return A[0]=c.catmullRomInterpolate(o[0],n[0],a[0],l[0],r),A[1]=c.catmullRomInterpolate(o[1],n[1],a[1],l[1],r),A[2]=c.catmullRomInterpolate(o[2],n[2],a[2],l[2],r),A}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}getJSON(){return{points:points,t:this._t}}}const uh=c.vec3();const dh=c.vec3(),ph=c.vec3(),fh=c.vec3(),gh=c.vec3(),mh=c.vec3();class _h extends D{get type(){return"CameraFlightAnimation"}constructor(e,t={}){super(e,t),this._look1=c.vec3(),this._eye1=c.vec3(),this._up1=c.vec3(),this._look2=c.vec3(),this._eye2=c.vec3(),this._up2=c.vec3(),this._orthoScale1=1,this._orthoScale2=1,this._flying=!1,this._flyEyeLookUp=!1,this._flyingEye=!1,this._flyingLook=!1,this._callback=null,this._callbackScope=null,this._time1=null,this._time2=null,this.easing=!1!==t.easing,this.duration=t.duration,this.fit=t.fit,this.fitFOV=t.fitFOV,this.trail=t.trail}flyTo(e,t,i){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=t,this._callbackScope=i;const s=this.scene.camera,r=!!e.projection&&e.projection!==s.projection;let o,n,a,l,A;if(this._eye1[0]=s.eye[0],this._eye1[1]=s.eye[1],this._eye1[2]=s.eye[2],this._look1[0]=s.look[0],this._look1[1]=s.look[1],this._look1[2]=s.look[2],this._up1[0]=s.up[0],this._up1[1]=s.up[1],this._up1[2]=s.up[2],this._orthoScale1=s.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)o=e.aabb;else if(6===e.length)o=e;else if(e.eye&&e.look||e.up)n=e.eye,a=e.look,l=e.up;else if(e.eye)n=e.eye;else if(e.look)a=e.look;else{let s=e;if((_.isNumeric(s)||_.isString(s))&&(A=s,s=this.scene.components[A],!s))return this.error("Component not found: "+_.inQuotes(A)),void(t&&(i?t.call(i):t()));r||(o=s.aabb||this.scene.aabb)}const h=e.poi;if(o){if(o[3]=1;e>1&&(e=1);const i=this.easing?_h._ease(e,0,1,1):e,s=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(c.subVec3(s.eye,s.look,mh),s.eye=c.lerpVec3(i,0,1,this._eye1,this._eye2,fh),s.look=c.subVec3(fh,mh,ph)):this._flyingLook&&(s.look=c.lerpVec3(i,0,1,this._look1,this._look2,ph),s.up=c.lerpVec3(i,0,1,this._up1,this._up2,gh)):this._flyingEyeLookUp&&(s.eye=c.lerpVec3(i,0,1,this._eye1,this._eye2,fh),s.look=c.lerpVec3(i,0,1,this._look1,this._look2,ph),s.up=c.lerpVec3(i,0,1,this._up1,this._up2,gh)),this._projection2){const t="ortho"===this._projection2?_h._easeOutExpo(e,0,1,1):_h._easeInCubic(e,0,1,1);s.customProjection.matrix=c.lerpMat4(t,0,1,this._projMatrix1,this._projMatrix2)}else s.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return s.ortho.scale=this._orthoScale2,void this.stop();M.scheduleTask(this._update,this)}static _ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}static _easeInCubic(e,t,i,s){return i*(e/=s)*e*e+t}static _easeOutExpo(e,t,i,s){return i*(1-Math.pow(2,-10*e/s))+t}stop(){if(!this._flying)return;this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);const e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}cancel(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}set duration(e){this._duration=e?1e3*e:500,this.stop()}get duration(){return this._duration/1e3}set fit(e){this._fit=!1!==e}get fit(){return this._fit}set fitFOV(e){this._fitFOV=e||45}get fitFOV(){return this._fitFOV}set trail(e){this._trail=!!e}get trail(){return this._trail}destroy(){this.stop(),super.destroy()}}class vh extends D{get type(){return"CameraPathAnimation"}constructor(e,t={}){super(e,t),this._cameraFlightAnimation=new _h(this),this._t=0,this.state=vh.SCRUBBING,this._playingFromT=0,this._playingToT=0,this._playingRate=t.playingRate||1,this._playingDir=1,this._lastTime=null,this.cameraPath=t.cameraPath,this._tick=this.scene.on("tick",this._updateT,this)}_updateT(){const e=this._cameraPath;if(!e)return;let t,i;const s=performance.now(),r=this._lastTime?.001*(s-this._lastTime):0;if(this._lastTime=s,0!==r)switch(this.state){case vh.SCRUBBING:return;case vh.PLAYING:if(this._t+=this._playingRate*r,t=this._cameraPath.frames.length,0===t||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=vh.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case vh.PLAYING_TO:i=this._t+this._playingRate*r*this._playingDir,(this._playingDir<0&&i<=this._playingToT||this._playingDir>0&&i>=this._playingToT)&&(i=this._playingToT,this.state=vh.SCRUBBING,this.fire("stopped")),this._t=i,e.loadFrame(this._t)}}_ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}set cameraPath(e){this._cameraPath=e}get cameraPath(){return this._cameraPath}set rate(e){this._playingRate=e}get rate(){return this._playingRate}play(){this._cameraPath&&(this._lastTime=null,this.state=vh.PLAYING)}playToT(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=vh.PLAYING_TO)}playToFrame(e){const t=this._cameraPath;if(!t)return;const i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}flyToFrame(e,t){const i=this._cameraPath;if(!i)return;const s=i.frames[e];s?(this.state=vh.SCRUBBING,this._cameraFlightAnimation.flyTo(s,t)):this.error("flyToFrame - frame index out of range: "+e)}scrubToT(e){const t=this._cameraPath;if(!t)return;this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=vh.SCRUBBING)}scrubToFrame(e){const t=this._cameraPath;if(!t)return;if(!this.scene.camera)return;t.frames[e]?(t.loadFrame(this._t),this.state=vh.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)}stop(){this.state=vh.SCRUBBING,this.fire("stopped")}destroy(){super.destroy(),this.scene.off(this._tick)}}vh.STOPPED=0,vh.SCRUBBING=1,vh.PLAYING=2,vh.PLAYING_TO=3;const bh=c.vec3(),yh=c.vec3();c.vec3();const xh=c.vec3([0,-1,0]),Bh=c.vec4([0,0,0,1]);function wh(e){if(!Ph(e.width)||!Ph(e.height)){const t=document.createElement("canvas");t.width=Ch(e.width),t.height=Ch(e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}function Ph(e){return 0==(e&e-1)}function Ch(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}class Mh extends D{get type(){return"CubeTexture"}constructor(e,t={}){super(e,t);const i=this.scene.canvas.gl;this._state=new et({texture:new ms({gl:i,target:i.TEXTURE_CUBE_MAP}),flipY:this._checkFlipY(t.minFilter),encoding:this._checkEncoding(t.encoding),minFilter:1008,magFilter:1006,wrapS:1001,wrapT:1001,mipmaps:!0}),this._src=t.src,this._images=[],this._loadSrc(t.src),p.memory.textures++}_checkFlipY(e){return!!e}_checkEncoding(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),e}_webglContextRestored(){this.scene.canvas.gl,this._state.texture=null,this._src&&this._loadSrc(this._src)}_loadSrc(e){const t=this,i=this.scene.canvas.gl;this._images=[];let s=!1,r=0;for(let o=0;o{r(),t()})):(i.eye=this._eye,i.look=this._look,i.up=this._up,r(),i.projection=s.projection)}}const Eh=c.vec3();const Ih=c.vec3();class Dh{constructor(){this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsHasColorize=[],this.objectsOpacity=[],this.numObjects=0}saveObjects(e,t){this.numObjects=0,this._mask=t?_.apply(t,{}):null;const i=e.objects,s=!t||t.visible,r=!t||t.edges,o=!t||t.xrayed,n=!t||t.highlighted,a=!t||t.selected,l=!t||t.clippable,A=!t||t.pickable,h=!t||t.colorize,c=!t||t.opacity;for(let e in i)if(i.hasOwnProperty(e)){const t=i[e],u=this.numObjects;if(s&&(this.objectsVisible[u]=t.visible),r&&(this.objectsEdges[u]=t.edges),o&&(this.objectsXrayed[u]=t.xrayed),n&&(this.objectsHighlighted[u]=t.highlighted),a&&(this.objectsSelected[u]=t.selected),l&&(this.objectsClippable[u]=t.clippable),A&&(this.objectsPickable[u]=t.pickable),h){const e=t.colorize;e?(this.objectsColorize[3*u+0]=e[0],this.objectsColorize[3*u+1]=e[1],this.objectsColorize[3*u+2]=e[2],this.objectsHasColorize[u]=!0):this.objectsHasColorize[u]=!1}c&&(this.objectsOpacity[u]=t.opacity),this.numObjects++}}restoreObjects(e){const t=this._mask,i=!t||t.visible,s=!t||t.edges,r=!t||t.xrayed,o=!t||t.highlighted,n=!t||t.selected,a=!t||t.clippable,l=!t||t.pickable,A=!t||t.colorize,h=!t||t.opacity;var c=0;const u=e.objects;for(let e in u)if(u.hasOwnProperty(e)){const t=u[e];i&&(t.visible=this.objectsVisible[c]),s&&(t.edges=this.objectsEdges[c]),r&&(t.xrayed=this.objectsXrayed[c]),o&&(t.highlighted=this.objectsHighlighted[c]),n&&(t.selected=this.objectsSelected[c]),a&&(t.clippable=this.objectsClippable[c]),l&&(t.pickable=this.objectsPickable[c]),A&&(this.objectsHasColorize[c]?(Ih[0]=this.objectsColorize[3*c+0],Ih[1]=this.objectsColorize[3*c+1],Ih[2]=this.objectsColorize[3*c+2],t.colorize=Ih):t.colorize=null),h&&(t.opacity=this.objectsOpacity[c]),c++}}}class Sh extends D{constructor(e,t={}){super(e,t),this._skyboxMesh=new zi(this,{geometry:new Ut(this,{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[2e3,2e3,2e3],rotation:[0,-90,0],material:new Vt(this,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Bs(this,{src:t.src,flipY:!0,wrapS:"clampToEdge",wrapT:"clampToEdge",encoding:t.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),this.size=t.size,this.active=t.active}set size(e){this._size=e||1e3,this._skyboxMesh.scale=[this._size,this._size,this._size]}get size(){return this._size}set active(e){this._skyboxMesh.visible=e}get active(){return this._skyboxMesh.visible}}const Th=c.vec4(),Rh=c.vec4(),Lh=c.vec3(),Uh=c.vec3(),kh=c.vec3(),Oh=c.vec4(),Nh=c.vec4(),Qh=c.vec4();class Vh{constructor(e){this._scene=e}dollyToCanvasPos(e,t,i){let s=!1;const r=this._scene.camera;if(e){const t=c.subVec3(e,r.eye,Lh);s=c.lenVec3(t){this._cameraDirty=!0})),this._onProjMatrix=this._scene.camera.on("projMatrix",(()=>{this._cameraDirty=!0})),this._onTick=this._scene.on("tick",(()=>{this.updatePivotElement(),this.updatePivotSphere()}))}createPivotSphere(){const e=this.getPivotPos(),t=c.vec3();c.decomposeMat4(c.inverseMat4(this._scene.viewer.camera.viewMatrix,c.mat4()),t,c.vec4(),c.vec3());const i=c.distVec3(t,e);let s=Math.tan(Math.PI/500)*i*this._pivotSphereSize;"ortho"==this._scene.camera.projection&&(s/=this._scene.camera.ortho.scale/2),G(e,this._rtcCenter,this._rtcPos),this._pivotSphereGeometry=new Cs(this._scene,Xi({radius:s})),this._pivotSphere=new zi(this._scene,{geometry:this._pivotSphereGeometry,material:this._pivotSphereMaterial,pickable:!1,position:this._rtcPos,rtcCenter:this._rtcCenter})}destroyPivotSphere(){this._pivotSphere&&(this._pivotSphere.destroy(),this._pivotSphere=null),this._pivotSphereGeometry&&(this._pivotSphereGeometry.destroy(),this._pivotSphereGeometry=null)}updatePivotElement(){const e=this._scene.camera,t=this._scene.canvas;if(this._pivoting&&this._cameraDirty){c.transformPoint3(e.viewMatrix,this.getPivotPos(),this._pivotViewPos),this._pivotViewPos[3]=1,c.transformPoint4(e.projMatrix,this._pivotViewPos,this._pivotProjPos);const i=t.boundary,s=i[2],r=i[3];this._pivotCanvasPos[0]=Math.floor((1+this._pivotProjPos[0]/this._pivotProjPos[3])*s/2),this._pivotCanvasPos[1]=Math.floor((1-this._pivotProjPos[1]/this._pivotProjPos[3])*r/2);let o=t._lastBoundingClientRect;if(!o||t._canvasSizeChanged){const e=t.canvas;o=t._lastBoundingClientRect=e.getBoundingClientRect()}this._pivotElement&&(this._pivotElement.style.left=Math.floor(o.left+this._pivotCanvasPos[0])-this._pivotElement.clientWidth/2+window.scrollX+"px",this._pivotElement.style.top=Math.floor(o.top+this._pivotCanvasPos[1])-this._pivotElement.clientHeight/2+window.scrollY+"px"),this._cameraDirty=!1}}updatePivotSphere(){this._pivoting&&this._pivotSphere&&(G(this.getPivotPos(),this._rtcCenter,this._rtcPos),c.compareVec3(this._rtcPos,this._pivotSphere.position)||(this.destroyPivotSphere(),this.createPivotSphere()))}setPivotElement(e){this._pivotElement=e}enablePivotSphere(e={}){this.destroyPivotSphere(),this._pivotSphereEnabled=!0,e.size&&(this._pivotSphereSize=e.size);const t=e.color||[1,0,0];this._pivotSphereMaterial=new Vt(this._scene,{emissive:t,ambient:t,specular:[0,0,0],diffuse:[0,0,0]})}disablePivotSphere(){this.destroyPivotSphere(),this._pivotSphereEnabled=!1}startPivot(){if(this._cameraLookingDownwards())return this._pivoting=!1,!1;const e=this._scene.camera;let t=c.lookAtMat4v(e.eye,e.look,e.worldUp);c.transformPoint3(t,this.getPivotPos(),this._cameraOffset);const i=this.getPivotPos();this._cameraOffset[2]+=c.distVec3(e.eye,i),t=c.inverseMat4(t);const s=c.transformVec3(t,this._cameraOffset),r=c.vec3();if(c.subVec3(e.eye,i,r),c.addVec3(r,s),e.zUp){const e=r[1];r[1]=r[2],r[2]=e}this._radius=c.lenVec3(r),this._polar=Math.acos(r[1]/this._radius),this._azimuth=Math.atan2(r[0],r[2]),this._pivoting=!0}_cameraLookingDownwards(){const e=this._scene.camera,t=c.normalizeVec3(c.subVec3(e.look,e.eye,Hh)),i=c.cross3Vec3(t,e.worldUp,jh);return c.sqLenVec3(i)<=1e-4}getPivoting(){return this._pivoting}setPivotPos(e){this._pivotWorldPos.set(e),this._pivotPosSet=!0}setCanvasPivotPos(e){const t=this._scene.camera,i=Math.abs(c.distVec3(this._scene.center,t.eye)),s=t.project.transposedMatrix,r=s.subarray(8,12),o=s.subarray(12),n=[0,0,-1,1],a=c.dotVec4(n,r)/c.dotVec4(n,o),l=zh;t.project.unproject(e,a,Wh,Kh,l);const A=c.normalizeVec3(c.subVec3(l,t.eye,Hh)),h=c.addVec3(t.eye,c.mulVec3Scalar(A,i,jh),Gh);this.setPivotPos(h)}getPivotPos(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}continuePivot(e,t){if(!this._pivoting)return;if(0===e&&0===t)return;const i=this._scene.camera;var s=-e;const r=-t;1===i.worldUp[2]&&(s=-s),this._azimuth+=.01*-s,this._polar+=.01*r,this._polar=c.clamp(this._polar,.001,Math.PI-.001);const o=[this._radius*Math.sin(this._polar)*Math.sin(this._azimuth),this._radius*Math.cos(this._polar),this._radius*Math.sin(this._polar)*Math.cos(this._azimuth)];if(1===i.worldUp[2]){const e=o[1];o[1]=o[2],o[2]=e}const n=c.lenVec3(c.subVec3(i.look,i.eye,c.vec3())),a=this.getPivotPos();c.addVec3(o,a);let l=c.lookAtMat4v(o,a,i.worldUp);l=c.inverseMat4(l);const A=c.transformVec3(l,this._cameraOffset);l[12]-=A[0],l[13]-=A[1],l[14]-=A[2];const h=[l[8],l[9],l[10]];i.eye=[l[12],l[13],l[14]],c.subVec3(i.eye,c.mulVec3Scalar(h,n),i.look),i.up=[l[4],l[5],l[6]],this.showPivot()}showPivot(){this._shown||(this._pivotElement&&(this.updatePivotElement(),this._pivotElement.style.visibility="visible"),this._pivotSphereEnabled&&(this.destroyPivotSphere(),this.createPivotSphere()),this._shown=!0)}hidePivot(){this._shown&&(this._pivotElement&&(this._pivotElement.style.visibility="hidden"),this._pivotSphereEnabled&&this.destroyPivotSphere(),this._shown=!1)}endPivot(){this._pivoting=!1}destroy(){this.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}class Jh{constructor(e,t){this._scene=e.scene,this._cameraControl=e,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=t,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=c.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}update(){if(!this._configs.pointerEnabled)return;if(!this.schedulePickEntity&&!this.schedulePickSurface)return;const e=`${~~this.pickCursorPos[0]}-${~~this.pickCursorPos[1]}-${this.scheduleSnapOrPick}-${this.schedulePickSurface}-${this.schedulePickEntity}`;if(this._lastHash===e)return;this.picked=!1,this.pickedSurface=!1,this.snappedOrPicked=!1,this.hoveredSnappedOrSurfaceOff=!1;const t=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){const e=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});e&&(e.snappedToEdge||e.snappedToVertex)?(this.snapPickResult=e,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){const e=this.pickResult.canvasPos;if(e[0]===this.pickCursorPos[0]&&e[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=t?1:0,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.hoveredSnappedOrSurfaceOff=!0,void(this.scheduleSnapOrPick=!1)}if(this.schedulePickEntity&&this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){const e=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(e[0]===this.pickCursorPos[0]&&e[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!1,this.schedulePickEntity=!1,void(this.schedulePickSurface=!1)}this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult?(this.pickResult=this._scene.pick({pickSurface:!0,pickSurfaceNormal:!1,canvasPos:this.pickCursorPos}),this.pickResult?(this.picked=!0,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.pickedSurface=!0,this._needFireEvents++):this.scheduleSnapOrPick&&(this.hoveredSnappedOrSurfaceOff=!0,this._needFireEvents++)):(this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos}),this.pickResult&&(this.picked=!0,this.pickedSurface=!1,this._needFireEvents++)),this.scheduleSnapOrPick=!1,this.schedulePickEntity=!1,this.schedulePickSurface=!1}fireEvents(){if(0!==this._needFireEvents){if(this.hoveredSnappedOrSurfaceOff&&this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},!0),this.snappedOrPicked)if(this.snapPickResult){const e=new Ce;e.entity=this.snapPickResult.entity,e.snappedToVertex=this.snapPickResult.snappedToVertex,e.snappedToEdge=this.snapPickResult.snappedToEdge,e.worldPos=this.snapPickResult.worldPos,e.canvasPos=this.pickCursorPos,e.snappedCanvasPos=this.snapPickResult.snappedCanvasPos,this._cameraControl.fire("hoverSnapOrSurface",e,!0),this.snapPickResult=null}else this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,!0);if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){const e=this.pickResult.entity.id;this._lastPickedEntityId!==e&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=e)}this._cameraControl.fire("hover",this.pickResult,!0),this.pickResult.worldPos&&(this.pickedSurface=!0,this._cameraControl.fire("hoverSurface",this.pickResult,!0))}else void 0!==this._lastPickedEntityId&&(this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},!0);this.pickResult=null,this._needFireEvents=0}}}const Yh=c.vec2();class Zh{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController;let n,a,l,A=0,h=0,u=0,d=0,p=!1;const f=c.vec3();let g=!0;const m=this._scene.canvas.canvas,_=[];function v(e=!0){m.style.cursor="move",A=s.pointerCanvasPos[0],h=s.pointerCanvasPos[1],u=s.pointerCanvasPos[0],d=s.pointerCanvasPos[1],e&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickSurface=!0,o.update(),o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(p=!0,f.set(o.pickResult.worldPos)):p=!1)}document.addEventListener("keydown",this._documentKeyDownHandler=t=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;const s=t.keyCode;_[s]=!0}),document.addEventListener("keyup",this._documentKeyUpHandler=t=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;const s=t.keyCode;_[s]=!1}),m.addEventListener("mousedown",this._mouseDownHandler=t=>{if(i.active&&i.pointerEnabled)switch(t.which){case 1:_[e.input.KEY_SHIFT]||i.planView?(n=!0,v()):(n=!0,v(!1));break;case 2:a=!0,v();break;case 3:l=!0,i.panRightClick&&v()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(!n&&!a&&!l)return;const o=e.canvas.boundary,u=o[2],d=o[3],g=s.pointerCanvasPos[0],m=s.pointerCanvasPos[1],v=_[e.input.KEY_SHIFT]||i.planView||!i.panRightClick&&a||i.panRightClick&&l,b=document.pointerLockElement?t.movementX:g-A,y=document.pointerLockElement?t.movementY:m-h;if(v){const t=e.camera;if("perspective"===t.projection){const i=Math.abs(p?c.lenVec3(c.subVec3(f,e.camera.eye,[])):e.camera.eyeLookDist)*Math.tan(t.perspective.fov/2*Math.PI/180);r.panDeltaX+=1.5*b*i/d,r.panDeltaY+=1.5*y*i/d}else r.panDeltaX+=.5*t.ortho.scale*(b/d),r.panDeltaY+=.5*t.ortho.scale*(y/d)}else!n||a||l||i.planView||(i.firstPerson?(r.rotateDeltaY-=b/u*i.dragRotationRate/2,r.rotateDeltaX+=y/d*(i.dragRotationRate/4)):(r.rotateDeltaY-=b/u*(1.5*i.dragRotationRate),r.rotateDeltaX+=y/d*(1.5*i.dragRotationRate)));A=g,h=m}),m.addEventListener("mousemove",this._canvasMouseMoveHandler=e=>{i.active&&i.pointerEnabled&&s.mouseover&&(g=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=e=>{if(i.active&&i.pointerEnabled)switch(e.which){case 1:case 2:case 3:n=!1,a=!1,l=!1}}),m.addEventListener("mouseup",this._mouseUpHandler=e=>{if(i.active&&i.pointerEnabled){if(3===e.which){!function(e,t){if(e){let i=e.target,s=0,r=0,o=0,n=0;for(;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,o+=i.scrollLeft,n+=i.scrollTop,i=i.offsetParent;t[0]=e.pageX+o-s,t[1]=e.pageY+n-r}else e=window.event,t[0]=e.x,t[1]=e.y}(e,Yh);const i=Yh[0],s=Yh[1];Math.abs(i-u)<3&&Math.abs(s-d)<3&&t.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Yh,event:e},!0)}m.style.removeProperty("cursor")}}),m.addEventListener("mouseenter",this._mouseEnterHandler=()=>{i.active&&i.pointerEnabled});const b=1/60;let y=null;m.addEventListener("wheel",this._mouseWheelHandler=e=>{if(!i.active||!i.pointerEnabled)return;const t=performance.now()/1e3;var o=null!==y?t-y:0;y=t,o>.05&&(o=.05),o{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;if(!s.mouseover)return;const n=r._isKeyDownForAction(r.AXIS_VIEW_RIGHT),a=r._isKeyDownForAction(r.AXIS_VIEW_BACK),l=r._isKeyDownForAction(r.AXIS_VIEW_LEFT),A=r._isKeyDownForAction(r.AXIS_VIEW_FRONT),h=r._isKeyDownForAction(r.AXIS_VIEW_TOP),u=r._isKeyDownForAction(r.AXIS_VIEW_BOTTOM);if(!(n||a||l||A||h||u))return;const d=e.aabb,p=c.getAABB3Diag(d);c.getAABB3Center(d,qh);const f=Math.abs(p/Math.tan(t.cameraFlight.fitFOV*c.DEGTORAD)),g=1.1*p;sc.orthoScale=g,n?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldRight,f,$h),ic)),sc.look.set(qh),sc.up.set(o.worldUp)):a?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldForward,f,$h),ic)),sc.look.set(qh),sc.up.set(o.worldUp)):l?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldRight,-f,$h),ic)),sc.look.set(qh),sc.up.set(o.worldUp)):A?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldForward,-f,$h),ic)),sc.look.set(qh),sc.up.set(o.worldUp)):h?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldUp,f,$h),ic)),sc.look.set(qh),sc.up.set(c.normalizeVec3(c.mulVec3Scalar(o.worldForward,1,ec),tc))):u&&(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldUp,-f,$h),ic)),sc.look.set(qh),sc.up.set(c.normalizeVec3(c.mulVec3Scalar(o.worldForward,-1,ec)))),!i.firstPerson&&i.followPointer&&t.pivotController.setPivotPos(qh),t.cameraFlight.duration>0?t.cameraFlight.flyTo(sc,(()=>{t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot()})):(t.cameraFlight.jumpTo(sc),t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot())}))}reset(){}destroy(){this._scene.input.off(this._onSceneKeyDown)}}class oc{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController,n=t.pivotController,a=t.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;let l=!1,A=!1;const h=this._scene.canvas.canvas,u=i=>{let s;i&&i.worldPos&&(s=i.worldPos);const r=i&&i.entity?i.entity.aabb:e.aabb;if(s){const i=e.camera;c.subVec3(i.eye,i.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})},d=e.tickify(this._canvasMouseMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(l||A)return;const r=a.hasSubs("hover"),n=a.hasSubs("hoverEnter"),h=a.hasSubs("hoverOut"),c=a.hasSubs("hoverOff"),u=a.hasSubs("hoverSurface"),d=a.hasSubs("hoverSnapOrSurface");if(r||n||h||c||u||d)if(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=!0,o.schedulePickSurface=u,o.scheduleSnapOrPick=d,o.update(),o.pickResult){if(o.pickResult.entity){const t=o.pickResult.entity.id;this._lastPickedEntityId!==t&&(void 0!==this._lastPickedEntityId&&a.fire("hoverOut",{entity:e.objects[this._lastPickedEntityId]},!0),a.fire("hoverEnter",o.pickResult,!0),this._lastPickedEntityId=t)}a.fire("hover",o.pickResult,!0),(o.pickResult.worldPos||o.pickResult.snappedWorldPos)&&a.fire("hoverSurface",o.pickResult,!0)}else void 0!==this._lastPickedEntityId&&(a.fire("hoverOut",{entity:e.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),a.fire("hoverOff",{canvasPos:o.pickCursorPos},!0)});h.addEventListener("mousemove",d),h.addEventListener("mousedown",this._canvasMouseDownHandler=t=>{1===t.which&&(l=!0),3===t.which&&(A=!0);if(1===t.which&&i.active&&i.pointerEnabled&&(s.mouseDownClientX=t.clientX,s.mouseDownClientY=t.clientY,s.mouseDownCursorX=s.pointerCanvasPos[0],s.mouseDownCursorY=s.pointerCanvasPos[1],!i.firstPerson&&i.followPointer&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickSurface=!0,o.update(),1===t.which))){const t=o.pickResult;t&&t.worldPos?(n.setPivotPos(t.worldPos),n.startPivot()):(i.smartPivot?n.setCanvasPivotPos(s.pointerCanvasPos):n.setPivotPos(e.camera.look),n.startPivot())}}),document.addEventListener("mouseup",this._documentMouseUpHandler=e=>{1===e.which&&(l=!1),3===e.which&&(A=!1),n.getPivoting()&&n.endPivot()}),h.addEventListener("mouseup",this._canvasMouseUpHandler=r=>{if(!i.active||!i.pointerEnabled)return;if(!(1===r.which))return;if(n.hidePivot(),Math.abs(r.clientX-s.mouseDownClientX)>3||Math.abs(r.clientY-s.mouseDownClientY)>3)return;const l=a.hasSubs("picked"),A=a.hasSubs("pickedNothing"),h=a.hasSubs("pickedSurface"),d=a.hasSubs("doublePicked"),p=a.hasSubs("doublePickedSurface"),f=a.hasSubs("doublePickedNothing");if(!(i.doublePickFlyTo||d||p||f))return(l||A||h)&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=!0,o.schedulePickSurface=h,o.update(),o.pickResult?(a.fire("picked",o.pickResult,!0),o.pickedSurface&&a.fire("pickedSurface",o.pickResult,!0)):a.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0)),void(this._clicks=0);if(this._clicks++,1===this._clicks){o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=i.doublePickFlyTo,o.schedulePickSurface=h,o.update();const e=o.pickResult,r=o.pickedSurface;this._timeout=setTimeout((()=>{e?(a.fire("picked",e,!0),r&&(a.fire("pickedSurface",e,!0),!i.firstPerson&&i.followPointer&&(t.pivotController.setPivotPos(e.worldPos),t.pivotController.startPivot()&&t.pivotController.showPivot()))):a.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0),this._clicks=0}),i.doubleClickTimeFrame)}else{if(null!==this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null),o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=i.doublePickFlyTo||d||p,o.schedulePickSurface=o.schedulePickEntity&&p,o.update(),o.pickResult){if(a.fire("doublePicked",o.pickResult,!0),o.pickedSurface&&a.fire("doublePickedSurface",o.pickResult,!0),i.doublePickFlyTo&&(u(o.pickResult),!i.firstPerson&&i.followPointer)){const e=o.pickResult.entity.aabb,i=c.getAABB3Center(e);t.pivotController.setPivotPos(i),t.pivotController.startPivot()&&t.pivotController.showPivot()}}else if(a.fire("doublePickedNothing",{canvasPos:s.pointerCanvasPos},!0),i.doublePickFlyTo&&(u(),!i.firstPerson&&i.followPointer)){const i=e.aabb,s=c.getAABB3Center(i);t.pivotController.setPivotPos(s),t.pivotController.startPivot()&&t.pivotController.showPivot()}this._clicks=0}},!1)}reset(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}destroy(){const e=this._scene.canvas.canvas;e.removeEventListener("mousemove",this._canvasMouseMoveHandler),e.removeEventListener("mousedown",this._canvasMouseDownHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._canvasMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}class nc{constructor(e,t,i,s,r){this._scene=e;const o=e.input,n=[],a=e.canvas.canvas;let l=!0;this._onSceneMouseMove=o.on("mousemove",(()=>{l=!0})),this._onSceneKeyDown=o.on("keydown",(t=>{i.active&&i.pointerEnabled&&e.input.keyboardEnabled&&s.mouseover&&(n[t]=!0,t===o.KEY_SHIFT&&(a.style.cursor="move"))})),this._onSceneKeyUp=o.on("keyup",(s=>{i.active&&i.pointerEnabled&&e.input.keyboardEnabled&&(n[s]=!1,s===o.KEY_SHIFT&&(a.style.cursor=null),t.pivotController.getPivoting()&&t.pivotController.endPivot())})),this._onTick=e.on("tick",(a=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;if(!s.mouseover)return;const A=t.cameraControl,h=a.deltaTime/1e3;if(!i.planView){const e=A._isKeyDownForAction(A.ROTATE_Y_POS,n),s=A._isKeyDownForAction(A.ROTATE_Y_NEG,n),o=A._isKeyDownForAction(A.ROTATE_X_POS,n),a=A._isKeyDownForAction(A.ROTATE_X_NEG,n),l=h*i.keyboardRotationRate;(e||s||o||a)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),e?r.rotateDeltaY+=l:s&&(r.rotateDeltaY-=l),o?r.rotateDeltaX+=l:a&&(r.rotateDeltaX-=l),!i.firstPerson&&i.followPointer&&t.pivotController.startPivot())}if(!n[o.KEY_CTRL]&&!n[o.KEY_ALT]){const e=A._isKeyDownForAction(A.DOLLY_BACKWARDS,n),o=A._isKeyDownForAction(A.DOLLY_FORWARDS,n);if(e||o){const n=h*i.keyboardDollyRate;!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),o?r.dollyDelta-=n:e&&(r.dollyDelta+=n),l&&(s.followPointerDirty=!0,l=!1)}}const c=A._isKeyDownForAction(A.PAN_FORWARDS,n),u=A._isKeyDownForAction(A.PAN_BACKWARDS,n),d=A._isKeyDownForAction(A.PAN_LEFT,n),p=A._isKeyDownForAction(A.PAN_RIGHT,n),f=A._isKeyDownForAction(A.PAN_UP,n),g=A._isKeyDownForAction(A.PAN_DOWN,n),m=(n[o.KEY_ALT]?.3:1)*h*i.keyboardPanRate;(c||u||d||p||f||g)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),g?r.panDeltaY+=m:f&&(r.panDeltaY+=-m),p?r.panDeltaX+=-m:d&&(r.panDeltaX+=m),u?r.panDeltaZ+=m:c&&(r.panDeltaZ+=-m))}))}reset(){}destroy(){this._scene.off(this._onTick),this._scene.input.off(this._onSceneMouseMove),this._scene.input.off(this._onSceneKeyDown),this._scene.input.off(this._onSceneKeyUp)}}const ac=c.vec3();class lc{constructor(e,t,i,s,r){this._scene=e;const o=e.camera,n=t.pickController,a=t.pivotController,l=t.panController;let A=1,h=1,u=null;this._onTick=e.on("tick",(()=>{if(!i.active||!i.pointerEnabled)return;let t="default";if(Math.abs(r.dollyDelta)<.001&&(r.dollyDelta=0),Math.abs(r.rotateDeltaX)<.001&&(r.rotateDeltaX=0),Math.abs(r.rotateDeltaY)<.001&&(r.rotateDeltaY=0),0===r.rotateDeltaX&&0===r.rotateDeltaY||(r.dollyDelta=0),i.followPointer){if(--A<=0&&(A=1,0!==r.dollyDelta)){if(0===r.rotateDeltaY&&0===r.rotateDeltaX&&i.followPointer&&s.followPointerDirty&&(n.pickCursorPos=s.pointerCanvasPos,n.schedulePickSurface=!0,n.update(),n.pickResult&&n.pickResult.worldPos?u=n.pickResult.worldPos:(h=1,u=null),s.followPointerDirty=!1),u){const t=Math.abs(c.lenVec3(c.subVec3(u,e.camera.eye,ac)));h=t/i.dollyProximityThreshold}h{s.mouseover=!0}),o.addEventListener("mouseleave",this._mouseLeaveHandler=()=>{s.mouseover=!1,o.style.cursor=null}),document.addEventListener("mousemove",this._mouseMoveHandler=e=>{hc(e,o,s.pointerCanvasPos)}),o.addEventListener("mousedown",this._mouseDownHandler=e=>{i.active&&i.pointerEnabled&&(hc(e,o,s.pointerCanvasPos),s.mouseover=!0)}),o.addEventListener("mouseup",this._mouseUpHandler=e=>{i.active&&i.pointerEnabled})}reset(){}destroy(){const e=this._scene.canvas.canvas;document.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseenter",this._mouseEnterHandler),e.removeEventListener("mouseleave",this._mouseLeaveHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mouseup",this._mouseUpHandler)}}function hc(e,t,i){if(e){const{left:s,top:r}=t.getBoundingClientRect();i[0]=e.clientX-s-window.scrollX,i[1]=e.clientY-r-window.scrollY}else e=window.event,i[0]=e.x,i[1]=e.y;return i}const cc=function(e,t){if(e){let i=e.target,s=0,r=0;for(;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t};class uc{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController,n=t.pivotController,a=c.vec2(),l=c.vec2(),A=c.vec2(),h=c.vec2(),u=[],d=this._scene.canvas.canvas;let p=0,f=!1;this._onTick=e.on("tick",(()=>{f=!1})),d.addEventListener("touchstart",this._canvasTouchStartHandler=t=>{if(!i.active||!i.pointerEnabled)return;t.preventDefault();const r=t.touches,l=t.changedTouches;for(s.touchStartTime=Date.now(),1===r.length&&1===l.length&&(cc(r[0],a),i.followPointer&&(o.pickCursorPos=a,o.schedulePickSurface=!0,o.update(),i.planView||(o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(n.setPivotPos(o.pickResult.worldPos),!i.firstPerson&&n.startPivot()&&n.showPivot()):(i.smartPivot?n.setCanvasPivotPos(s.pointerCanvasPos):n.setPivotPos(e.camera.look),!i.firstPerson&&n.startPivot()&&n.showPivot()))));u.length{n.getPivoting()&&n.endPivot()}),d.addEventListener("touchmove",this._canvasTouchMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(t.stopPropagation(),t.preventDefault(),f)return;f=!0;const n=e.canvas.boundary,a=n[2],d=n[3],g=t.touches;if(t.touches.length===p){if(1===p){cc(g[0],l),c.subVec2(l,u[0],h);const t=h[0],o=h[1];if(null!==s.longTouchTimeout&&(Math.abs(t)>i.longTapRadius||Math.abs(o)>i.longTapRadius)&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),i.planView){const s=e.camera;if("perspective"===s.projection){const n=Math.abs(e.camera.eyeLookDist)*Math.tan(s.perspective.fov/2*Math.PI/180);r.panDeltaX+=t*n/d*i.touchPanRate,r.panDeltaY+=o*n/d*i.touchPanRate}else r.panDeltaX+=.5*s.ortho.scale*(t/d)*i.touchPanRate,r.panDeltaY+=.5*s.ortho.scale*(o/d)*i.touchPanRate}else r.rotateDeltaY-=t/a*(1*i.dragRotationRate),r.rotateDeltaX+=o/d*(1.5*i.dragRotationRate)}else if(2===p){const t=g[0],n=g[1];cc(t,l),cc(n,A);const a=c.geometricMeanVec2(u[0],u[1]),h=c.geometricMeanVec2(l,A),p=c.vec2();c.subVec2(a,h,p);const f=p[0],m=p[1],_=e.camera,v=c.distVec2([t.pageX,t.pageY],[n.pageX,n.pageY]),b=(c.distVec2(u[0],u[1])-v)*i.touchDollyRate;if(r.dollyDelta=b,Math.abs(b)<1)if("perspective"===_.projection){const t=o.pickResult?o.pickResult.worldPos:e.center,s=Math.abs(c.lenVec3(c.subVec3(t,e.camera.eye,[])))*Math.tan(_.perspective.fov/2*Math.PI/180);r.panDeltaX-=f*s/d*i.touchPanRate,r.panDeltaY-=m*s/d*i.touchPanRate}else r.panDeltaX-=.5*_.ortho.scale*(f/d)*i.touchPanRate,r.panDeltaY-=.5*_.ortho.scale*(m/d)*i.touchPanRate;s.pointerCanvasPos=h}for(let e=0;e{let s;i&&i.worldPos&&(s=i.worldPos);const r=i?i.entity.aabb:e.aabb;if(s){const i=e.camera;c.subVec3(i.eye,i.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})};d.addEventListener("touchstart",this._canvasTouchStartHandler=e=>{if(!i.active||!i.pointerEnabled)return;null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null);const r=e.touches,o=e.changedTouches;if(a=Date.now(),1===r.length&&1===o.length){h=a,dc(r[0],A);const o=A[0],n=A[1],l=r[0].pageX,c=r[0].pageY;s.longTouchTimeout=setTimeout((()=>{t.cameraControl.fire("rightClick",{pagePos:[Math.round(l),Math.round(c)],canvasPos:[Math.round(o),Math.round(n)],event:e},!0),s.longTouchTimeout=null}),i.longTapTimeout)}else h=-1;for(;l.length{if(!i.active||!i.pointerEnabled)return;const t=Date.now(),r=e.touches,a=e.changedTouches,d=n.hasSubs("pickedSurface");null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),0===r.length&&1===a.length&&h>-1&&t-h<150&&(u>-1&&h-u<325?(dc(a[0],o.pickCursorPos),o.schedulePickEntity=!0,o.schedulePickSurface=d,o.update(),o.pickResult?(o.pickResult.touchInput=!0,n.fire("doublePicked",o.pickResult),o.pickedSurface&&n.fire("doublePickedSurface",o.pickResult),i.doublePickFlyTo&&p(o.pickResult)):(n.fire("doublePickedNothing"),i.doublePickFlyTo&&p()),u=-1):c.distVec2(l[0],A)<4&&(dc(a[0],o.pickCursorPos),o.schedulePickEntity=!0,o.schedulePickSurface=d,o.update(),o.pickResult?(o.pickResult.touchInput=!0,n.fire("picked",o.pickResult),o.pickedSurface&&n.fire("pickedSurface",o.pickResult)):n.fire("pickedNothing"),u=t),h=-1),l.length=r.length;for(let e=0,t=r.length;e{e.preventDefault()},this._configs={longTapTimeout:600,longTapRadius:5,active:!0,keyboardLayout:"qwerty",navMode:"orbit",planView:!1,firstPerson:!1,followPointer:!0,doublePickFlyTo:!0,panRightClick:!0,showPivot:!1,pointerEnabled:!0,constrainVertical:!1,smartPivot:!1,doubleClickTimeFrame:250,snapToVertex:true,snapToEdge:true,snapRadius:30,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},this._states={pointerCanvasPos:c.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:c.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},this._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};const i=this.scene;this._controllers={cameraControl:this,pickController:new Jh(this,this._configs),pivotController:new Xh(i,this._configs),panController:new Vh(i),cameraFlight:new _h(this,{duration:.5})},this._handlers=[new Ac(this.scene,this._controllers,this._configs,this._states,this._updates),new uc(this.scene,this._controllers,this._configs,this._states,this._updates),new Zh(this.scene,this._controllers,this._configs,this._states,this._updates),new rc(this.scene,this._controllers,this._configs,this._states,this._updates),new oc(this.scene,this._controllers,this._configs,this._states,this._updates),new pc(this.scene,this._controllers,this._configs,this._states,this._updates),new nc(this.scene,this._controllers,this._configs,this._states,this._updates)],this._cameraUpdater=new lc(this.scene,this._controllers,this._configs,this._states,this._updates),this.navMode=t.navMode,t.planView&&(this.planView=t.planView),this.constrainVertical=t.constrainVertical,t.keyboardLayout?this.keyboardLayout=t.keyboardLayout:this.keyMap=t.keyMap,this.doublePickFlyTo=t.doublePickFlyTo,this.panRightClick=t.panRightClick,this.active=t.active,this.followPointer=t.followPointer,this.rotationInertia=t.rotationInertia,this.keyboardPanRate=t.keyboardPanRate,this.touchPanRate=t.touchPanRate,this.keyboardRotationRate=t.keyboardRotationRate,this.dragRotationRate=t.dragRotationRate,this.touchDollyRate=t.touchDollyRate,this.dollyInertia=t.dollyInertia,this.dollyProximityThreshold=t.dollyProximityThreshold,this.dollyMinSpeed=t.dollyMinSpeed,this.panInertia=t.panInertia,this.pointerEnabled=!0,this.keyboardDollyRate=t.keyboardDollyRate,this.mouseWheelDollyRate=t.mouseWheelDollyRate}set keyMap(e){if(e=e||"qwerty",_.isString(e)){const t=this.scene.input,i={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":i[this.PAN_LEFT]=[t.KEY_A],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_Z],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_W,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_Q,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6];break;case"azerty":i[this.PAN_LEFT]=[t.KEY_Q],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_W],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_Z,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_A,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6]}this._keyMap=i}else{const t=e;this._keyMap=t}}get keyMap(){return this._keyMap}_isKeyDownForAction(e,t){const i=this._keyMap[e];if(!i)return!1;t||(t=this.scene.input.keyDown);for(let e=0,s=i.length;e0?yc(t):null,n=i&&i.length>0?yc(i):null,a=e=>{if(!e)return;var t=!0;(n&&n[e.type]||o&&!o[e.type])&&(t=!1),t&&s.push(e.id);const i=e.children;if(i)for(var r=0,l=i.length;r>t;i.sort(wA);const s=new Int32Array(e.length);for(let t=0,r=i.length;te[t+1]){let i=e[t];e[t]=e[t+1],e[t+1]=i}PA=new Int32Array(e),t.sort(CA);const i=new Int32Array(e.length);for(let s=0,r=t.length;st){let i=e;e=t,t=i}function i(i,s){return i!==e?e-i:s!==t?t-s:0}let s=0,r=(o.length>>1)-1;for(;s<=r;){const e=r+s>>1,t=i(o[2*e],o[2*e+1]);if(t>0)s=e+1;else{if(!(t<0))return e;r=e-1}}return-s-1}const a=new Int32Array(o.length/2);a.fill(0);const l=s.length/3;if(l>8*(1<u.maxNumPositions&&(u=c()),u.bucketNumber>8)return[e];let p;-1===A[l]&&(A[l]=u.numPositions++,u.positionsCompressed.push(s[3*l]),u.positionsCompressed.push(s[3*l+1]),u.positionsCompressed.push(s[3*l+2])),-1===A[h]&&(A[h]=u.numPositions++,u.positionsCompressed.push(s[3*h]),u.positionsCompressed.push(s[3*h+1]),u.positionsCompressed.push(s[3*h+2])),-1===A[d]&&(A[d]=u.numPositions++,u.positionsCompressed.push(s[3*d]),u.positionsCompressed.push(s[3*d+1]),u.positionsCompressed.push(s[3*d+2])),u.indices.push(A[l]),u.indices.push(A[h]),u.indices.push(A[d]),(p=n(l,h))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]])),(p=n(l,d))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]])),(p=n(h,d))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]]))}const d=t/8*2,p=t/8,f=2*s.length+(r.length+o.length)*d;let g=0,m=-s.length/3;return h.forEach((e=>{g+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*p,m+=e.positionsCompressed.length/3})),g>f?[e]:(i&&function(e,t){const i={},s={};let r=0;e.forEach((e=>{const t=e.indices,o=e.edgeIndices,n=e.positionsCompressed;for(let e=0,s=t.length;e0){const e=t._meshes;for(let t=0,i=e.length;t0){const e=this._meshes;for(let t=0,i=e.length;t{this._viewMatrixDirty=!0})),this._meshesWithDirtyMatrices=[],this._numMeshesWithDirtyMatrices=0,this._onTick=this.scene.on("tick",(()=>{for(;this._numMeshesWithDirtyMatrices>0;)this._meshesWithDirtyMatrices[--this._numMeshesWithDirtyMatrices]._updateMatrix()})),this._createDefaultTextureSet(),this.visible=t.visible,this.culled=t.culled,this.pickable=t.pickable,this.clippable=t.clippable,this.collidable=t.collidable,this.castsShadow=t.castsShadow,this.receivesShadow=t.receivesShadow,this.xrayed=t.xrayed,this.highlighted=t.highlighted,this.selected=t.selected,this.edges=t.edges,this.colorize=t.colorize,this.opacity=t.opacity,this.backfaces=t.backfaces}_meshMatrixDirty(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}_createDefaultTextureSet(){const e=new aA({id:"defaultColorTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),t=new aA({id:"defaultMetalRoughTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),i=new aA({id:"defaultNormalsTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),s=new aA({id:"defaultEmissiveTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),r=new aA({id:"defaultOcclusionTexture",texture:new ms({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures.defaultColorTexture=e,this._textures.defaultMetalRoughTexture=t,this._textures.defaultNormalsTexture=i,this._textures.defaultEmissiveTexture=s,this._textures.defaultOcclusionTexture=r,this._textureSets.defaultTextureSet=new nA({id:"defaultTextureSet",model:this,colorTexture:e,metallicRoughnessTexture:t,normalsTexture:i,emissiveTexture:s,occlusionTexture:r})}get isPerformanceModel(){return!0}get transforms(){return this._transforms}get textures(){return this._textures}get textureSets(){return this._textureSets}get meshes(){return this._meshes}get objects(){return this._entities}get origin(){return this._origin}set position(e){this._position.set(e||[0,0,0]),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get position(){return this._position}set rotation(e){this._rotation.set(e||[0,0,0]),c.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get rotation(){return this._rotation}set quaternion(e){this._quaternion.set(e||[0,0,0,1]),c.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get quaternion(){return this._quaternion}set scale(e){}get scale(){return this._scale}set matrix(e){this._matrix.set(e||HA),c.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),c.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),c.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),c.translateMat4v(this._position,this._matrix),this._matrixDirty=!1,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get matrix(){return this._matrixDirty&&this._rebuildMatrices(),this._matrix}get rotationMatrix(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrix}_rebuildMatrices(){this._matrixDirty&&(c.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),c.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),c.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),c.translateMat4v(this._position,this._matrix),this._matrixDirty=!1)}get rotationMatrixConjugate(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrixConjugate}_setWorldMatrixDirty(){this._matrixDirty=!0,this._aabbDirty=!0}_transformDirty(){this._matrixDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0}_sceneModelDirty(){this.scene._aabbDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._matrixDirty=!0;for(let e=0,t=this._entityList.length;e0}set visible(e){e=!1!==e,this._visible=e;for(let t=0,i=this._entityList.length;t0}set xrayed(e){e=!!e,this._xrayed=e;for(let t=0,i=this._entityList.length;t0}set highlighted(e){e=!!e,this._highlighted=e;for(let t=0,i=this._entityList.length;t0}set selected(e){e=!!e,this._selected=e;for(let t=0,i=this._entityList.length;t0}set edges(e){e=!!e,this._edges=e;for(let t=0,i=this._entityList.length;t0}set pickable(e){e=!1!==e,this._pickable=e;for(let t=0,i=this._entityList.length;t0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){const t=e.colors,i=new Uint8Array(t.length);for(let e=0,s=t.length;e{l.setImage(A,{minFilter:i,magFilter:s,wrapS:r,wrapT:o,wrapR:n,flipY:e.flipY,encoding:a}),this.glRedraw()},A.src=e.src;break;default:this._textureTranscoder?_.loadArraybuffer(e.src,(e=>{e.byteLength?this._textureTranscoder.transcode([e],l).then((()=>{this.glRedraw()})):this.error("[createTexture] Can't create texture from 'src': file data is zero length")}),(function(e){this.error(`[createTexture] Can't create texture from 'src': ${e}`)})):this.error(`[createTexture] Can't create texture from 'src' - SceneModel needs to be configured with a TextureTranscoder for this file type ('${t}')`)}}else e.buffers&&(this._textureTranscoder?this._textureTranscoder.transcode(e.buffers,l).then((()=>{this.glRedraw()})):this.error("[createTexture] Can't create texture from 'buffers' - SceneModel needs to be configured with a TextureTranscoder for this option"));this._textures[t]=new aA({id:t,texture:l})}createTextureSet(e){const t=e.id;if(null==t)return void this.error("[createTextureSet] Config missing: id");if(this._textureSets[t])return void this.error(`[createTextureSet] Texture set already created: ${t}`);let i,s,r,o,n;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(i=this._textures[e.colorTextureId],!i)return void this.error(`[createTextureSet] Texture not found: ${e.colorTextureId} - ensure that you create it first with createTexture()`)}else i=this._textures.defaultColorTexture;if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(s=this._textures[e.metallicRoughnessTextureId],!s)return void this.error(`[createTextureSet] Texture not found: ${e.metallicRoughnessTextureId} - ensure that you create it first with createTexture()`)}else s=this._textures.defaultMetalRoughTexture;if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(r=this._textures[e.normalsTextureId],!r)return void this.error(`[createTextureSet] Texture not found: ${e.normalsTextureId} - ensure that you create it first with createTexture()`)}else r=this._textures.defaultNormalsTexture;if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(o=this._textures[e.emissiveTextureId],!o)return void this.error(`[createTextureSet] Texture not found: ${e.emissiveTextureId} - ensure that you create it first with createTexture()`)}else o=this._textures.defaultEmissiveTexture;if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(n=this._textures[e.occlusionTextureId],!n)return void this.error(`[createTextureSet] Texture not found: ${e.occlusionTextureId} - ensure that you create it first with createTexture()`)}else n=this._textures.defaultOcclusionTexture;const a=new nA({id:t,model:this,colorTexture:i,metallicRoughnessTexture:s,normalsTexture:r,emissiveTexture:o,occlusionTexture:n});return this._textureSets[t]=a,a}createTransform(e){if(void 0===e.id||null===e.id)return void this.error("[createTransform] SceneModel.createTransform() config missing: id");if(this._transforms[e.id])return void this.error(`[createTransform] SceneModel already has a transform with this ID: ${e.id}`);let t;if(e.parentTransformId&&(t=this._transforms[e.parentTransformId],!t))return void this.error("[createTransform] SceneModel.createTransform() config missing: id");const i=new LA({id:e.id,model:this,parent:t,matrix:e.matrix,position:e.position,scale:e.scale,rotation:e.rotation,quaternion:e.quaternion});return this._transforms[i.id]=i,i}createMesh(e){if(void 0===e.id||null===e.id)return this.error("[createMesh] SceneModel.createMesh() config missing: id"),!1;if(this._meshes[e.id])return this.error(`[createMesh] SceneModel already has a mesh with this ID: ${e.id}`),!1;if(!(void 0!==e.geometryId)){if(void 0!==e.primitive&&null!==e.primitive||(e.primitive="triangles"),"points"!==e.primitive&&"lines"!==e.primitive&&"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)return this.error(`Unsupported value for 'primitive': '${primitive}' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.`),!1;if(!e.positions&&!e.positionsCompressed&&!e.buckets)return this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)"),!1;if(e.positions&&(e.positionsDecodeMatrix||e.positionsDecodeBoundary))return this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.positionsCompressed&&!e.positionsDecodeMatrix&&!e.positionsDecodeBoundary)return this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.uvCompressed&&!e.uvDecodeMatrix)return this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)"),!1;if(!(e.buckets||e.indices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)){const t=(e.positions||e.positionsCompressed).length/3;e.indices=this._createDefaultIndices(t)}if(!e.buckets&&!e.indices&&"points"!==e.primitive)return e.indices=this._createDefaultIndices(numIndices),this.error(`Param expected: indices (required for '${e.primitive}' primitive type)`),!1;if((e.matrix||e.position||e.rotation||e.scale)&&(e.positionsCompressed||e.positionsDecodeBoundary))return this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'"),!1;const t=!(!this._dtxEnabled||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||e.textureSetId);if(e.origin=e.origin?c.addVec3(this._origin,e.origin,c.vec3()):this._origin,e.matrix)e.meshMatrix=e.matrix;else if(e.scale||e.rotation||e.position){const t=e.scale||OA,i=e.position||NA,s=e.rotation||QA;c.eulerToQuaternion(s,"XYZ",VA),e.meshMatrix=c.composeMat4(i,VA,t,c.mat4())}if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=Tr(e.positionsDecodeBoundary,c.mat4())),t){if(e.type=2,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):jA,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.positions){const t=c.vec3(),i=[];z(e.positions,i,t)&&(e.positions=i,e.origin=c.addVec3(e.origin,t,t))}if(e.positions){const t=c.collapseAABB3();e.positionsDecodeMatrix=c.mat4(),c.expandAABB3Points3(t,e.positions),e.positionsCompressed=Sr(e.positions,t,e.positionsDecodeMatrix),e.aabb=t}else if(e.positionsCompressed){const t=c.collapseAABB3();c.expandAABB3Points3(t,e.positionsCompressed),Tt.decompressAABB(t,e.positionsDecodeMatrix),e.aabb=t}if(e.buckets){const t=c.collapseAABB3();for(let i=0,s=e.buckets.length;i>24&255,r=i>>16&255,o=i>>8&255,n=255&i;switch(e.pickColor=new Uint8Array([n,o,r,s]),e.solid="solid"===e.primitive,t.origin=c.vec3(e.origin),e.type){case 2:t.layer=this._getDTXLayer(e),t.aabb=e.aabb;break;case 1:t.layer=this._getVBOBatchingLayer(e),t.aabb=e.aabb;break;case 0:t.layer=this._getVBOInstancingLayer(e),t.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),t.portionId=t.layer.createPortion(t,e),this._meshes[e.id]=t,this._unusedMeshes[e.id]=t,this._meshList.push(t),t}_getNumPrimitives(e){let t=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(let i=0,s=e.buckets.length;i>>0).toString(16)}_getVBOInstancingLayer(e){const t=this,i=e.origin,s=e.textureSetId||"-",r=e.geometryId,o=`${Math.round(i[0])}.${Math.round(i[1])}.${Math.round(i[2])}.${s}.${r}`;let n=this._vboInstancingLayers[o];if(n)return n;let a=e.textureSet;const l=e.geometry;for(;!n;)switch(l.primitive){case"triangles":case"surface":n=new Oo({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!1});break;case"solid":n=new Oo({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!0});break;case"lines":n=new wn({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0});break;case"points":n=new ma({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0})}return this._vboInstancingLayers[o]=n,this.layerList.push(n),n}createEntity(e){if(void 0===e.id?e.id=c.createUUID():this.scene.components[e.id]&&(this.error(`Scene already has a Component with this ID: ${e.id} - will assign random ID`),e.id=c.createUUID()),void 0===e.meshIds)return void this.error("Config missing: meshIds");let t=0;this._visible&&!1!==e.visible&&(t|=K),this._pickable&&!1!==e.pickable&&(t|=J),this._culled&&!1!==e.culled&&(t|=X),this._clippable&&!1!==e.clippable&&(t|=Y),this._collidable&&!1!==e.collidable&&(t|=Z),this._edges&&!1!==e.edges&&(t|=te),this._xrayed&&!1!==e.xrayed&&(t|=q),this._highlighted&&!1!==e.highlighted&&(t|=$),this._selected&&!1!==e.selected&&(t|=ee),e.flags=t,this._createEntity(e)}_createEntity(e){let t=[];for(let i=0,s=e.meshIds.length;ie.sortIdt.sortId?1:0));for(let e=0,t=this.layerList.length;e0&&0===this.renderFlags.numVisibleLayers?this.renderFlags.culled=!0:this._updateRenderFlags()}_updateRenderFlagsVisibleLayers(){const e=this.renderFlags;e.numLayers=this.layerList.length,e.numVisibleLayers=0;for(let t=0,i=this.layerList.length;t0){const t=`${this.id}-dummyEntityForUnusedMeshes`;this.warn(`Creating dummy SceneModelEntity "${t}" for unused SceneMeshes: [${e.join(",")}]`),this.createEntity({id:t,meshIds:e,isObject:!0})}this._unusedMeshes={}}_getActiveSectionPlanesForLayer(e){const t=this.renderFlags,i=this.scene._sectionPlanesState.sectionPlanes,s=i.length,r=e.layerIndex*s;if(s>0)for(let e=0;e0&&(e.colorTransparent=!0),this.numXRayedLayerPortions>0){const t=this.scene.xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}if(this.numEdgesLayerPortions>0){this.scene.edgeMaterial._state.edges&&(e.edgesOpaque=this.numTransparentLayerPortions0&&(e.edgesTransparent=!0))}if(this.numSelectedLayerPortions>0){const t=this.scene.selectedMaterial._state;t.fill&&(t.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){const t=this.scene.highlightMaterial._state;t.fill&&(t.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}drawColorOpaque(e){const t=this.renderFlags;for(let i=0,s=t.visibleLayers.length;i65536?16:8)}else n=[{positionsCompressed:s,indices:r,edgeIndices:o}];return n}class WA extends D{constructor(e,t={}){if(super(e,t),this._positions=t.positions||[],t.indices)this._indices=t.indices;else{this._indices=[];for(let e=0,t=this._positions.length/3-1;e{var r=e-i,o=t-s;return Math.sqrt(r*r+o*o)};class sh extends D{constructor(e,t={}){if(super(e.viewer.scene,t),this.plugin=e,this._container=t.container,!this._container)throw"config missing: container";this._eventSubs={};var i=this.plugin.viewer.scene;this._originMarker=new ae(i,t.origin),this._targetMarker=new ae(i,t.target),this._originWorld=c.vec3(),this._targetWorld=c.vec3(),this._wp=new Float64Array(24),this._vp=new Float64Array(24),this._pp=new Float64Array(24),this._cp=new Float64Array(8),this._xAxisLabelCulled=!1,this._yAxisLabelCulled=!1,this._zAxisLabelCulled=!1,this._color=t.color||this.plugin.defaultColor;const s=t.onMouseOver?e=>{t.onMouseOver(e,this),this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,r=t.onMouseLeave?e=>{t.onMouseLeave(e,this),this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,o=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},n=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},a=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},l=t.onContextMenu?e=>{t.onContextMenu(e,this)}:null,A=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};this._originDot=new Ae(this._container,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._targetDot=new Ae(this._container,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._lengthWire=new le(this._container,{color:this._color,thickness:2,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._xAxisWire=new le(this._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._yAxisWire=new le(this._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._zAxisWire=new le(this._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._lengthLabel=new he(this._container,{fillColor:this._color,prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._xAxisLabel=new he(this._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._yAxisLabel=new he(this._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._zAxisLabel=new he(this._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._wpDirty=!1,this._vpDirty=!1,this._cpDirty=!1,this._sectionPlanesDirty=!0,this._visible=!1,this._originVisible=!1,this._targetVisible=!1,this._wireVisible=!1,this._axisVisible=!1,this._xAxisVisible=!1,this._yAxisVisible=!1,this._zAxisVisible=!1,this._axisEnabled=!0,this._labelsVisible=!1,this._labelsOnWires=!1,this._clickable=!1,this._originMarker.on("worldPos",(e=>{this._originWorld.set(e||[0,0,0]),this._wpDirty=!0,this._needUpdate(0)})),this._targetMarker.on("worldPos",(e=>{this._targetWorld.set(e||[0,0,0]),this._wpDirty=!0,this._needUpdate(0)})),this._onViewMatrix=i.camera.on("viewMatrix",(()=>{this._vpDirty=!0,this._needUpdate(0)})),this._onProjMatrix=i.camera.on("projMatrix",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onCanvasBoundary=i.canvas.on("boundary",(()=>{this._cpDirty=!0,this._needUpdate(0)})),this._onMetricsUnits=i.metrics.on("units",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onMetricsScale=i.metrics.on("scale",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onMetricsOrigin=i.metrics.on("origin",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onSectionPlaneUpdated=i.on("sectionPlaneUpdated",(()=>{this._sectionPlanesDirty=!0,this._needUpdate()})),this.approximate=t.approximate,this.visible=t.visible,this.originVisible=t.originVisible,this.targetVisible=t.targetVisible,this.wireVisible=t.wireVisible,this.axisVisible=t.axisVisible,this.xAxisVisible=t.xAxisVisible,this.yAxisVisible=t.yAxisVisible,this.zAxisVisible=t.zAxisVisible,this.labelsVisible=t.labelsVisible,this.labelsOnWires=t.labelsOnWires}_update(){if(!this._visible)return;const e=this.plugin.viewer.scene;if(this._wpDirty&&(this._wp[0]=this._originWorld[0],this._wp[1]=this._originWorld[1],this._wp[2]=this._originWorld[2],this._wp[3]=1,this._wp[4]=this._targetWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._targetWorld[0],this._wp[9]=this._targetWorld[1],this._wp[10]=this._originWorld[2],this._wp[11]=1,this._wp[12]=this._targetWorld[0],this._wp[13]=this._targetWorld[1],this._wp[14]=this._targetWorld[2],this._wp[15]=1,this._wpDirty=!1,this._vpDirty=!0),this._vpDirty&&(c.transformPositions4(e.camera.viewMatrix,this._wp,this._vp),this._vp[3]=1,this._vp[7]=1,this._vp[11]=1,this._vp[15]=1,this._vpDirty=!1,this._cpDirty=!0),this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld))return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setCulled(!0),this._yAxisWire.setCulled(!0),this._zAxisWire.setCulled(!0),this._lengthWire.setCulled(!0),this._originDot.setCulled(!0),void this._targetDot.setCulled(!0);this._xAxisLabel.setCulled(!1),this._yAxisLabel.setCulled(!1),this._zAxisLabel.setCulled(!1),this._lengthLabel.setCulled(!1),this._xAxisWire.setCulled(!1),this._yAxisWire.setCulled(!1),this._zAxisWire.setCulled(!1),this._lengthWire.setCulled(!1),this._originDot.setCulled(!1),this._targetDot.setCulled(!1),this._sectionPlanesDirty=!0}const t=this._originMarker.viewPos[2],i=this._targetMarker.viewPos[2];if(t>-.3||i>-.3)return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setVisible(!1),this._yAxisWire.setVisible(!1),this._zAxisWire.setVisible(!1),this._lengthWire.setVisible(!1),this._originDot.setVisible(!1),void this._targetDot.setVisible(!1);if(this._cpDirty){c.transformPositions4(e.camera.project.matrix,this._vp,this._pp);var s=this._pp,r=this._cp,o=e.canvas.canvas.getBoundingClientRect();const t=this._container.getBoundingClientRect();var n=o.top-t.top,a=o.left-t.left,l=e.canvas.boundary,A=l[2],h=l[3],u=0;const i=this.plugin.viewer.scene.metrics,f=i.scale,g=i.units,m=i.unitsInfo[g].abbrev;for(var d=0,p=s.length;de.offsetTop+(e.offsetParent&&h(e.offsetParent)),u=e=>e.offsetLeft+(e.offsetParent&&u(e.offsetParent)),d=c.vec2();this._onCameraControlHoverSnapOrSurface=i.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(e=>{const t=e.snappedCanvasPos||e.canvasPos;r=!0,o.set(e.worldPos),n.set(e.canvasPos),0===this._mouseState?(this._canvasToPagePos?(this._canvasToPagePos(s,t,d),this._markerDiv.style.left=d[0]-5+"px",this._markerDiv.style.top=d[1]-5+"px"):(this._markerDiv.style.left=u(s)+t[0]-5+"px",this._markerDiv.style.top=h(s)+t[1]-5+"px"),this._markerDiv.style.background="pink",e.snappedToVertex||e.snappedToEdge?(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,this.pointerLens.snapped=!0),this._markerDiv.style.background="greenyellow",this._markerDiv.style.border="2px solid green"):(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.canvasPos,this.pointerLens.snapped=!1),this._markerDiv.style.background="pink",this._markerDiv.style.border="2px solid red"),A=e.entity):(this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px"),s.style.cursor="pointer",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=this._currentDistanceMeasurementInitState.wireVisible,this._currentDistanceMeasurement.axisVisible=this._currentDistanceMeasurementInitState.axisVisible&&this.distanceMeasurementsPlugin.defaultAxisVisible,this._currentDistanceMeasurement.xAxisVisible=this._currentDistanceMeasurementInitState.xAxisVisible&&this.distanceMeasurementsPlugin.defaultXAxisVisible,this._currentDistanceMeasurement.yAxisVisible=this._currentDistanceMeasurementInitState.yAxisVisible&&this.distanceMeasurementsPlugin.defaultYAxisVisible,this._currentDistanceMeasurement.zAxisVisible=this._currentDistanceMeasurementInitState.zAxisVisible&&this.distanceMeasurementsPlugin.defaultZAxisVisible,this._currentDistanceMeasurement.targetVisible=this._currentDistanceMeasurementInitState.targetVisible,this._currentDistanceMeasurement.target.worldPos=o.slice(),this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px")})),s.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(a=e.clientX,l=e.clientY)}),s.addEventListener("mouseup",this._onMouseUp=t=>{1===t.which&&(t.clientX>a+20||t.clientXl+20||t.clientY{this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos),r=!1,this._markerDiv.style.left="-100px",this._markerDiv.style.top="-100px",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.axisVisible=!1),s.style.cursor="default"})),this._active=!0}deactivate(){if(!this._active)return;this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1),this._markerDiv&&this._destroyMarkerDiv(),this.reset();const e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);const t=this.distanceMeasurementsPlugin.viewer.cameraControl;t.off(this._onCameraControlHoverSnapOrSurface),t.off(this._onCameraControlHoverSnapOrSurfaceOff),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._active=!1}reset(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null))}destroy(){this.deactivate(),super.destroy()}}class nh{constructor(){}getMetaModel(e,t,i){_.loadJSON(e,(e=>{t(e)}),(function(e){i(e)}))}getGLTF(e,t,i){_.loadArraybuffer(e,(e=>{t(e)}),(function(e){i(e)}))}getGLB(e,t,i){_.loadArraybuffer(e,(e=>{t(e)}),(function(e){i(e)}))}getArrayBuffer(e,t,i,s){!function(e,t,i,s){var r=()=>{};i=i||r,s=s||r;const o=/^data:(.*?)(;base64)?,(.*)$/,n=t.match(o);if(n){const e=!!n[2];var a=n[3];a=window.decodeURIComponent(a),e&&(a=window.atob(a));try{const e=new ArrayBuffer(a.length),t=new Uint8Array(e);for(var l=0;l{i(e)}),(function(e){s(e)}))}}class ah{constructor(e={}){this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=e.messages,this.locale=e.locale}set messages(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}loadMessages(e={}){for(let t in e)this._messages[t]=e[t];this.messages=this._messages}clearMessages(){this.messages={}}get locales(){return this._locales}set locale(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}get locale(){return this._locale}translate(e,t){const i=this._messages[this._locale];if(!i)return null;const s=lh(e,i);return s?t?Ah(s,t):s:null}translatePlurals(e,t,i){const s=this._messages[this._locale];if(!s)return null;let r=lh(e,s);return r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one,r?(r=Ah(r,[t]),i&&(r=Ah(r,i)),r):null}fire(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);const s=this._eventSubs[e];if(s)for(const e in s)if(s.hasOwnProperty(e)){s[e].callback(t)}}on(t,i){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new e),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});let s=this._eventSubs[t];s||(s={},this._eventSubs[t]=s);const r=this._eventSubIDMap.addItem();s[r]={callback:i},this._eventSubEvents[r]=t;const o=this._events[t];return void 0!==o&&i(o),r}off(e){if(null==e)return;if(!this._eventSubEvents)return;const t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];const i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}function lh(e,t){if(t[e])return t[e];const i=e.split(".");let s=t;for(let e=0,t=i.length;s&&e1?1:e}get t(){return this._t}get tangent(){return this.getTangent(this._t)}get length(){var e=this._getLengths();return e[e.length-1]}getTangent(e){var t=1e-4;void 0===e&&(e=this._t);var i=e-t,s=e+t;i<0&&(i=0),s>1&&(s=1);var r=this.getPoint(i),o=this.getPoint(s),n=c.subVec3(o,r,[]);return c.normalizeVec3(n,[])}getPointAt(e){var t=this.getUToTMapping(e);return this.getPoint(t)}getPoints(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}_getLengths(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,s=[],r=this.getPoint(0),o=0;for(s.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),o+=c.lenVec3(c.subVec3(t,r,[])),s.push(o),r=t;return this.cacheArcLengths=s,s}_updateArcLengths(){this.needsUpdate=!0,this._getLengths()}getUToTMapping(e,t){var i,s=this._getLengths(),r=0,o=s.length;i=t||e*s[o-1];for(var n,a=0,l=o-1;a<=l;)if((n=s[r=Math.floor(a+(l-a)/2)]-i)<0)a=r+1;else{if(!(n>0)){l=r;break}l=r-1}if(s[r=l]===i)return r/(o-1);var A=s[r];return(r+(i-A)/(s[r+1]-A))/(o-1)}}class ch extends hh{constructor(e,t={}){super(e,t),this.points=t.points,this.t=t.t}set points(e){this._points=e||[]}get points(){return this._points}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=this.points;if(!(t.length<3)){var i=(t.length-1)*e,s=Math.floor(i),r=i-s,o=t[0===s?s:s-1],n=t[s],a=t[s>t.length-2?t.length-1:s+1],l=t[s>t.length-3?t.length-1:s+2],A=c.vec3();return A[0]=c.catmullRomInterpolate(o[0],n[0],a[0],l[0],r),A[1]=c.catmullRomInterpolate(o[1],n[1],a[1],l[1],r),A[2]=c.catmullRomInterpolate(o[2],n[2],a[2],l[2],r),A}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}getJSON(){return{points:points,t:this._t}}}const uh=c.vec3();const dh=c.vec3(),ph=c.vec3(),fh=c.vec3(),gh=c.vec3(),mh=c.vec3();class _h extends D{get type(){return"CameraFlightAnimation"}constructor(e,t={}){super(e,t),this._look1=c.vec3(),this._eye1=c.vec3(),this._up1=c.vec3(),this._look2=c.vec3(),this._eye2=c.vec3(),this._up2=c.vec3(),this._orthoScale1=1,this._orthoScale2=1,this._flying=!1,this._flyEyeLookUp=!1,this._flyingEye=!1,this._flyingLook=!1,this._callback=null,this._callbackScope=null,this._time1=null,this._time2=null,this.easing=!1!==t.easing,this.duration=t.duration,this.fit=t.fit,this.fitFOV=t.fitFOV,this.trail=t.trail}flyTo(e,t,i){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=t,this._callbackScope=i;const s=this.scene.camera,r=!!e.projection&&e.projection!==s.projection;let o,n,a,l,A;if(this._eye1[0]=s.eye[0],this._eye1[1]=s.eye[1],this._eye1[2]=s.eye[2],this._look1[0]=s.look[0],this._look1[1]=s.look[1],this._look1[2]=s.look[2],this._up1[0]=s.up[0],this._up1[1]=s.up[1],this._up1[2]=s.up[2],this._orthoScale1=s.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)o=e.aabb;else if(6===e.length)o=e;else if(e.eye&&e.look||e.up)n=e.eye,a=e.look,l=e.up;else if(e.eye)n=e.eye;else if(e.look)a=e.look;else{let s=e;if((_.isNumeric(s)||_.isString(s))&&(A=s,s=this.scene.components[A],!s))return this.error("Component not found: "+_.inQuotes(A)),void(t&&(i?t.call(i):t()));r||(o=s.aabb||this.scene.aabb)}const h=e.poi;if(o){if(o[3]=1;e>1&&(e=1);const i=this.easing?_h._ease(e,0,1,1):e,s=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(c.subVec3(s.eye,s.look,mh),s.eye=c.lerpVec3(i,0,1,this._eye1,this._eye2,fh),s.look=c.subVec3(fh,mh,ph)):this._flyingLook&&(s.look=c.lerpVec3(i,0,1,this._look1,this._look2,ph),s.up=c.lerpVec3(i,0,1,this._up1,this._up2,gh)):this._flyingEyeLookUp&&(s.eye=c.lerpVec3(i,0,1,this._eye1,this._eye2,fh),s.look=c.lerpVec3(i,0,1,this._look1,this._look2,ph),s.up=c.lerpVec3(i,0,1,this._up1,this._up2,gh)),this._projection2){const t="ortho"===this._projection2?_h._easeOutExpo(e,0,1,1):_h._easeInCubic(e,0,1,1);s.customProjection.matrix=c.lerpMat4(t,0,1,this._projMatrix1,this._projMatrix2)}else s.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return s.ortho.scale=this._orthoScale2,void this.stop();M.scheduleTask(this._update,this)}static _ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}static _easeInCubic(e,t,i,s){return i*(e/=s)*e*e+t}static _easeOutExpo(e,t,i,s){return i*(1-Math.pow(2,-10*e/s))+t}stop(){if(!this._flying)return;this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);const e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}cancel(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}set duration(e){this._duration=e?1e3*e:500,this.stop()}get duration(){return this._duration/1e3}set fit(e){this._fit=!1!==e}get fit(){return this._fit}set fitFOV(e){this._fitFOV=e||45}get fitFOV(){return this._fitFOV}set trail(e){this._trail=!!e}get trail(){return this._trail}destroy(){this.stop(),super.destroy()}}class vh extends D{get type(){return"CameraPathAnimation"}constructor(e,t={}){super(e,t),this._cameraFlightAnimation=new _h(this),this._t=0,this.state=vh.SCRUBBING,this._playingFromT=0,this._playingToT=0,this._playingRate=t.playingRate||1,this._playingDir=1,this._lastTime=null,this.cameraPath=t.cameraPath,this._tick=this.scene.on("tick",this._updateT,this)}_updateT(){const e=this._cameraPath;if(!e)return;let t,i;const s=performance.now(),r=this._lastTime?.001*(s-this._lastTime):0;if(this._lastTime=s,0!==r)switch(this.state){case vh.SCRUBBING:return;case vh.PLAYING:if(this._t+=this._playingRate*r,t=this._cameraPath.frames.length,0===t||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=vh.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case vh.PLAYING_TO:i=this._t+this._playingRate*r*this._playingDir,(this._playingDir<0&&i<=this._playingToT||this._playingDir>0&&i>=this._playingToT)&&(i=this._playingToT,this.state=vh.SCRUBBING,this.fire("stopped")),this._t=i,e.loadFrame(this._t)}}_ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}set cameraPath(e){this._cameraPath=e}get cameraPath(){return this._cameraPath}set rate(e){this._playingRate=e}get rate(){return this._playingRate}play(){this._cameraPath&&(this._lastTime=null,this.state=vh.PLAYING)}playToT(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=vh.PLAYING_TO)}playToFrame(e){const t=this._cameraPath;if(!t)return;const i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}flyToFrame(e,t){const i=this._cameraPath;if(!i)return;const s=i.frames[e];s?(this.state=vh.SCRUBBING,this._cameraFlightAnimation.flyTo(s,t)):this.error("flyToFrame - frame index out of range: "+e)}scrubToT(e){const t=this._cameraPath;if(!t)return;this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=vh.SCRUBBING)}scrubToFrame(e){const t=this._cameraPath;if(!t)return;if(!this.scene.camera)return;t.frames[e]?(t.loadFrame(this._t),this.state=vh.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)}stop(){this.state=vh.SCRUBBING,this.fire("stopped")}destroy(){super.destroy(),this.scene.off(this._tick)}}vh.STOPPED=0,vh.SCRUBBING=1,vh.PLAYING=2,vh.PLAYING_TO=3;const bh=c.vec3(),yh=c.vec3();c.vec3();const xh=c.vec3([0,-1,0]),Bh=c.vec4([0,0,0,1]);function wh(e){if(!Ph(e.width)||!Ph(e.height)){const t=document.createElement("canvas");t.width=Ch(e.width),t.height=Ch(e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}function Ph(e){return 0==(e&e-1)}function Ch(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}class Mh extends D{get type(){return"CubeTexture"}constructor(e,t={}){super(e,t);const i=this.scene.canvas.gl;this._state=new et({texture:new ms({gl:i,target:i.TEXTURE_CUBE_MAP}),flipY:this._checkFlipY(t.minFilter),encoding:this._checkEncoding(t.encoding),minFilter:1008,magFilter:1006,wrapS:1001,wrapT:1001,mipmaps:!0}),this._src=t.src,this._images=[],this._loadSrc(t.src),p.memory.textures++}_checkFlipY(e){return!!e}_checkEncoding(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),e}_webglContextRestored(){this.scene.canvas.gl,this._state.texture=null,this._src&&this._loadSrc(this._src)}_loadSrc(e){const t=this,i=this.scene.canvas.gl;this._images=[];let s=!1,r=0;for(let o=0;o{r(),t()})):(i.eye=this._eye,i.look=this._look,i.up=this._up,r(),i.projection=s.projection)}}const Eh=c.vec3();const Ih=c.vec3();class Dh{constructor(){this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsHasColorize=[],this.objectsOpacity=[],this.numObjects=0}saveObjects(e,t){this.numObjects=0,this._mask=t?_.apply(t,{}):null;const i=e.objects,s=!t||t.visible,r=!t||t.edges,o=!t||t.xrayed,n=!t||t.highlighted,a=!t||t.selected,l=!t||t.clippable,A=!t||t.pickable,h=!t||t.colorize,c=!t||t.opacity;for(let e in i)if(i.hasOwnProperty(e)){const t=i[e],u=this.numObjects;if(s&&(this.objectsVisible[u]=t.visible),r&&(this.objectsEdges[u]=t.edges),o&&(this.objectsXrayed[u]=t.xrayed),n&&(this.objectsHighlighted[u]=t.highlighted),a&&(this.objectsSelected[u]=t.selected),l&&(this.objectsClippable[u]=t.clippable),A&&(this.objectsPickable[u]=t.pickable),h){const e=t.colorize;e?(this.objectsColorize[3*u+0]=e[0],this.objectsColorize[3*u+1]=e[1],this.objectsColorize[3*u+2]=e[2],this.objectsHasColorize[u]=!0):this.objectsHasColorize[u]=!1}c&&(this.objectsOpacity[u]=t.opacity),this.numObjects++}}restoreObjects(e){const t=this._mask,i=!t||t.visible,s=!t||t.edges,r=!t||t.xrayed,o=!t||t.highlighted,n=!t||t.selected,a=!t||t.clippable,l=!t||t.pickable,A=!t||t.colorize,h=!t||t.opacity;var c=0;const u=e.objects;for(let e in u)if(u.hasOwnProperty(e)){const t=u[e];i&&(t.visible=this.objectsVisible[c]),s&&(t.edges=this.objectsEdges[c]),r&&(t.xrayed=this.objectsXrayed[c]),o&&(t.highlighted=this.objectsHighlighted[c]),n&&(t.selected=this.objectsSelected[c]),a&&(t.clippable=this.objectsClippable[c]),l&&(t.pickable=this.objectsPickable[c]),A&&(this.objectsHasColorize[c]?(Ih[0]=this.objectsColorize[3*c+0],Ih[1]=this.objectsColorize[3*c+1],Ih[2]=this.objectsColorize[3*c+2],t.colorize=Ih):t.colorize=null),h&&(t.opacity=this.objectsOpacity[c]),c++}}}class Sh extends D{constructor(e,t={}){super(e,t),this._skyboxMesh=new zi(this,{geometry:new Ut(this,{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[2e3,2e3,2e3],rotation:[0,-90,0],material:new Vt(this,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Bs(this,{src:t.src,flipY:!0,wrapS:"clampToEdge",wrapT:"clampToEdge",encoding:t.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),this.size=t.size,this.active=t.active}set size(e){this._size=e||1e3,this._skyboxMesh.scale=[this._size,this._size,this._size]}get size(){return this._size}set active(e){this._skyboxMesh.visible=e}get active(){return this._skyboxMesh.visible}}const Th=c.vec4(),Rh=c.vec4(),Lh=c.vec3(),Uh=c.vec3(),kh=c.vec3(),Oh=c.vec4(),Nh=c.vec4(),Qh=c.vec4();class Vh{constructor(e){this._scene=e}dollyToCanvasPos(e,t,i){let s=!1;const r=this._scene.camera;if(e){const t=c.subVec3(e,r.eye,Lh);s=c.lenVec3(t){this._cameraDirty=!0})),this._onProjMatrix=this._scene.camera.on("projMatrix",(()=>{this._cameraDirty=!0})),this._onTick=this._scene.on("tick",(()=>{this.updatePivotElement(),this.updatePivotSphere()}))}createPivotSphere(){const e=this.getPivotPos(),t=c.vec3();c.decomposeMat4(c.inverseMat4(this._scene.viewer.camera.viewMatrix,c.mat4()),t,c.vec4(),c.vec3());const i=c.distVec3(t,e);let s=Math.tan(Math.PI/500)*i*this._pivotSphereSize;"ortho"==this._scene.camera.projection&&(s/=this._scene.camera.ortho.scale/2),G(e,this._rtcCenter,this._rtcPos),this._pivotSphereGeometry=new Cs(this._scene,Xi({radius:s})),this._pivotSphere=new zi(this._scene,{geometry:this._pivotSphereGeometry,material:this._pivotSphereMaterial,pickable:!1,position:this._rtcPos,rtcCenter:this._rtcCenter})}destroyPivotSphere(){this._pivotSphere&&(this._pivotSphere.destroy(),this._pivotSphere=null),this._pivotSphereGeometry&&(this._pivotSphereGeometry.destroy(),this._pivotSphereGeometry=null)}updatePivotElement(){const e=this._scene.camera,t=this._scene.canvas;if(this._pivoting&&this._cameraDirty){c.transformPoint3(e.viewMatrix,this.getPivotPos(),this._pivotViewPos),this._pivotViewPos[3]=1,c.transformPoint4(e.projMatrix,this._pivotViewPos,this._pivotProjPos);const i=t.boundary,s=i[2],r=i[3];this._pivotCanvasPos[0]=Math.floor((1+this._pivotProjPos[0]/this._pivotProjPos[3])*s/2),this._pivotCanvasPos[1]=Math.floor((1-this._pivotProjPos[1]/this._pivotProjPos[3])*r/2);let o=t._lastBoundingClientRect;if(!o||t._canvasSizeChanged){const e=t.canvas;o=t._lastBoundingClientRect=e.getBoundingClientRect()}this._pivotElement&&(this._pivotElement.style.left=Math.floor(o.left+this._pivotCanvasPos[0])-this._pivotElement.clientWidth/2+window.scrollX+"px",this._pivotElement.style.top=Math.floor(o.top+this._pivotCanvasPos[1])-this._pivotElement.clientHeight/2+window.scrollY+"px"),this._cameraDirty=!1}}updatePivotSphere(){this._pivoting&&this._pivotSphere&&(G(this.getPivotPos(),this._rtcCenter,this._rtcPos),c.compareVec3(this._rtcPos,this._pivotSphere.position)||(this.destroyPivotSphere(),this.createPivotSphere()))}setPivotElement(e){this._pivotElement=e}enablePivotSphere(e={}){this.destroyPivotSphere(),this._pivotSphereEnabled=!0,e.size&&(this._pivotSphereSize=e.size);const t=e.color||[1,0,0];this._pivotSphereMaterial=new Vt(this._scene,{emissive:t,ambient:t,specular:[0,0,0],diffuse:[0,0,0]})}disablePivotSphere(){this.destroyPivotSphere(),this._pivotSphereEnabled=!1}startPivot(){if(this._cameraLookingDownwards())return this._pivoting=!1,!1;const e=this._scene.camera;let t=c.lookAtMat4v(e.eye,e.look,e.worldUp);c.transformPoint3(t,this.getPivotPos(),this._cameraOffset);const i=this.getPivotPos();this._cameraOffset[2]+=c.distVec3(e.eye,i),t=c.inverseMat4(t);const s=c.transformVec3(t,this._cameraOffset),r=c.vec3();if(c.subVec3(e.eye,i,r),c.addVec3(r,s),e.zUp){const e=r[1];r[1]=r[2],r[2]=e}this._radius=c.lenVec3(r),this._polar=Math.acos(r[1]/this._radius),this._azimuth=Math.atan2(r[0],r[2]),this._pivoting=!0}_cameraLookingDownwards(){const e=this._scene.camera,t=c.normalizeVec3(c.subVec3(e.look,e.eye,Hh)),i=c.cross3Vec3(t,e.worldUp,jh);return c.sqLenVec3(i)<=1e-4}getPivoting(){return this._pivoting}setPivotPos(e){this._pivotWorldPos.set(e),this._pivotPosSet=!0}setCanvasPivotPos(e){const t=this._scene.camera,i=Math.abs(c.distVec3(this._scene.center,t.eye)),s=t.project.transposedMatrix,r=s.subarray(8,12),o=s.subarray(12),n=[0,0,-1,1],a=c.dotVec4(n,r)/c.dotVec4(n,o),l=zh;t.project.unproject(e,a,Wh,Kh,l);const A=c.normalizeVec3(c.subVec3(l,t.eye,Hh)),h=c.addVec3(t.eye,c.mulVec3Scalar(A,i,jh),Gh);this.setPivotPos(h)}getPivotPos(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}continuePivot(e,t){if(!this._pivoting)return;if(0===e&&0===t)return;const i=this._scene.camera;var s=-e;const r=-t;1===i.worldUp[2]&&(s=-s),this._azimuth+=.01*-s,this._polar+=.01*r,this._polar=c.clamp(this._polar,.001,Math.PI-.001);const o=[this._radius*Math.sin(this._polar)*Math.sin(this._azimuth),this._radius*Math.cos(this._polar),this._radius*Math.sin(this._polar)*Math.cos(this._azimuth)];if(1===i.worldUp[2]){const e=o[1];o[1]=o[2],o[2]=e}const n=c.lenVec3(c.subVec3(i.look,i.eye,c.vec3())),a=this.getPivotPos();c.addVec3(o,a);let l=c.lookAtMat4v(o,a,i.worldUp);l=c.inverseMat4(l);const A=c.transformVec3(l,this._cameraOffset);l[12]-=A[0],l[13]-=A[1],l[14]-=A[2];const h=[l[8],l[9],l[10]];i.eye=[l[12],l[13],l[14]],c.subVec3(i.eye,c.mulVec3Scalar(h,n),i.look),i.up=[l[4],l[5],l[6]],this.showPivot()}showPivot(){this._shown||(this._pivotElement&&(this.updatePivotElement(),this._pivotElement.style.visibility="visible"),this._pivotSphereEnabled&&(this.destroyPivotSphere(),this.createPivotSphere()),this._shown=!0)}hidePivot(){this._shown&&(this._pivotElement&&(this._pivotElement.style.visibility="hidden"),this._pivotSphereEnabled&&this.destroyPivotSphere(),this._shown=!1)}endPivot(){this._pivoting=!1}destroy(){this.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}class Jh{constructor(e,t){this._scene=e.scene,this._cameraControl=e,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=t,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=c.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}update(){if(!this._configs.pointerEnabled)return;if(!this.schedulePickEntity&&!this.schedulePickSurface)return;const e=`${~~this.pickCursorPos[0]}-${~~this.pickCursorPos[1]}-${this.scheduleSnapOrPick}-${this.schedulePickSurface}-${this.schedulePickEntity}`;if(this._lastHash===e)return;this.picked=!1,this.pickedSurface=!1,this.snappedOrPicked=!1,this.hoveredSnappedOrSurfaceOff=!1;const t=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){const e=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});e&&(e.snappedToEdge||e.snappedToVertex)?(this.snapPickResult=e,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){const e=this.pickResult.canvasPos;if(e[0]===this.pickCursorPos[0]&&e[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=t?1:0,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.hoveredSnappedOrSurfaceOff=!0,void(this.scheduleSnapOrPick=!1)}if(this.schedulePickEntity&&this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){const e=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(e[0]===this.pickCursorPos[0]&&e[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!1,this.schedulePickEntity=!1,void(this.schedulePickSurface=!1)}this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult?(this.pickResult=this._scene.pick({pickSurface:!0,pickSurfaceNormal:!1,canvasPos:this.pickCursorPos}),this.pickResult?(this.picked=!0,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.pickedSurface=!0,this._needFireEvents++):this.scheduleSnapOrPick&&(this.hoveredSnappedOrSurfaceOff=!0,this._needFireEvents++)):(this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos}),this.pickResult&&(this.picked=!0,this.pickedSurface=!1,this._needFireEvents++)),this.scheduleSnapOrPick=!1,this.schedulePickEntity=!1,this.schedulePickSurface=!1}fireEvents(){if(0!==this._needFireEvents){if(this.hoveredSnappedOrSurfaceOff&&this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},!0),this.snappedOrPicked)if(this.snapPickResult){const e=new Ce;e.entity=this.snapPickResult.entity,e.snappedToVertex=this.snapPickResult.snappedToVertex,e.snappedToEdge=this.snapPickResult.snappedToEdge,e.worldPos=this.snapPickResult.worldPos,e.canvasPos=this.pickCursorPos,e.snappedCanvasPos=this.snapPickResult.snappedCanvasPos,this._cameraControl.fire("hoverSnapOrSurface",e,!0),this.snapPickResult=null}else this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,!0);if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){const e=this.pickResult.entity.id;this._lastPickedEntityId!==e&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=e)}this._cameraControl.fire("hover",this.pickResult,!0),this.pickResult.worldPos&&(this.pickedSurface=!0,this._cameraControl.fire("hoverSurface",this.pickResult,!0))}else void 0!==this._lastPickedEntityId&&(this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},!0);this.pickResult=null,this._needFireEvents=0}}}const Yh=c.vec2();class Zh{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController;let n,a,l,A=0,h=0,u=0,d=0,p=!1;const f=c.vec3();let g=!0;const m=this._scene.canvas.canvas,_=[];function v(e=!0){m.style.cursor="move",A=s.pointerCanvasPos[0],h=s.pointerCanvasPos[1],u=s.pointerCanvasPos[0],d=s.pointerCanvasPos[1],e&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickSurface=!0,o.update(),o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(p=!0,f.set(o.pickResult.worldPos)):p=!1)}document.addEventListener("keydown",this._documentKeyDownHandler=t=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;const s=t.keyCode;_[s]=!0}),document.addEventListener("keyup",this._documentKeyUpHandler=t=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;const s=t.keyCode;_[s]=!1}),m.addEventListener("mousedown",this._mouseDownHandler=t=>{if(i.active&&i.pointerEnabled)switch(t.which){case 1:_[e.input.KEY_SHIFT]||i.planView?(n=!0,v()):(n=!0,v(!1));break;case 2:a=!0,v();break;case 3:l=!0,i.panRightClick&&v()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(!n&&!a&&!l)return;const o=e.canvas.boundary,u=o[2],d=o[3],g=s.pointerCanvasPos[0],m=s.pointerCanvasPos[1],v=_[e.input.KEY_SHIFT]||i.planView||!i.panRightClick&&a||i.panRightClick&&l,b=document.pointerLockElement?t.movementX:g-A,y=document.pointerLockElement?t.movementY:m-h;if(v){const t=e.camera;if("perspective"===t.projection){const i=Math.abs(p?c.lenVec3(c.subVec3(f,e.camera.eye,[])):e.camera.eyeLookDist)*Math.tan(t.perspective.fov/2*Math.PI/180);r.panDeltaX+=1.5*b*i/d,r.panDeltaY+=1.5*y*i/d}else r.panDeltaX+=.5*t.ortho.scale*(b/d),r.panDeltaY+=.5*t.ortho.scale*(y/d)}else!n||a||l||i.planView||(i.firstPerson?(r.rotateDeltaY-=b/u*i.dragRotationRate/2,r.rotateDeltaX+=y/d*(i.dragRotationRate/4)):(r.rotateDeltaY-=b/u*(1.5*i.dragRotationRate),r.rotateDeltaX+=y/d*(1.5*i.dragRotationRate)));A=g,h=m}),m.addEventListener("mousemove",this._canvasMouseMoveHandler=e=>{i.active&&i.pointerEnabled&&s.mouseover&&(g=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=e=>{if(i.active&&i.pointerEnabled)switch(e.which){case 1:case 2:case 3:n=!1,a=!1,l=!1}}),m.addEventListener("mouseup",this._mouseUpHandler=e=>{if(i.active&&i.pointerEnabled){if(3===e.which){!function(e,t){if(e){let i=e.target,s=0,r=0,o=0,n=0;for(;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,o+=i.scrollLeft,n+=i.scrollTop,i=i.offsetParent;t[0]=e.pageX+o-s,t[1]=e.pageY+n-r}else e=window.event,t[0]=e.x,t[1]=e.y}(e,Yh);const i=Yh[0],s=Yh[1];Math.abs(i-u)<3&&Math.abs(s-d)<3&&t.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Yh,event:e},!0)}m.style.removeProperty("cursor")}}),m.addEventListener("mouseenter",this._mouseEnterHandler=()=>{i.active&&i.pointerEnabled});const b=1/60;let y=null;m.addEventListener("wheel",this._mouseWheelHandler=e=>{if(!i.active||!i.pointerEnabled)return;const t=performance.now()/1e3;var o=null!==y?t-y:0;y=t,o>.05&&(o=.05),o{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;if(!s.mouseover)return;const n=r._isKeyDownForAction(r.AXIS_VIEW_RIGHT),a=r._isKeyDownForAction(r.AXIS_VIEW_BACK),l=r._isKeyDownForAction(r.AXIS_VIEW_LEFT),A=r._isKeyDownForAction(r.AXIS_VIEW_FRONT),h=r._isKeyDownForAction(r.AXIS_VIEW_TOP),u=r._isKeyDownForAction(r.AXIS_VIEW_BOTTOM);if(!(n||a||l||A||h||u))return;const d=e.aabb,p=c.getAABB3Diag(d);c.getAABB3Center(d,qh);const f=Math.abs(p/Math.tan(t.cameraFlight.fitFOV*c.DEGTORAD)),g=1.1*p;sc.orthoScale=g,n?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldRight,f,$h),ic)),sc.look.set(qh),sc.up.set(o.worldUp)):a?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldForward,f,$h),ic)),sc.look.set(qh),sc.up.set(o.worldUp)):l?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldRight,-f,$h),ic)),sc.look.set(qh),sc.up.set(o.worldUp)):A?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldForward,-f,$h),ic)),sc.look.set(qh),sc.up.set(o.worldUp)):h?(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldUp,f,$h),ic)),sc.look.set(qh),sc.up.set(c.normalizeVec3(c.mulVec3Scalar(o.worldForward,1,ec),tc))):u&&(sc.eye.set(c.addVec3(qh,c.mulVec3Scalar(o.worldUp,-f,$h),ic)),sc.look.set(qh),sc.up.set(c.normalizeVec3(c.mulVec3Scalar(o.worldForward,-1,ec)))),!i.firstPerson&&i.followPointer&&t.pivotController.setPivotPos(qh),t.cameraFlight.duration>0?t.cameraFlight.flyTo(sc,(()=>{t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot()})):(t.cameraFlight.jumpTo(sc),t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot())}))}reset(){}destroy(){this._scene.input.off(this._onSceneKeyDown)}}class oc{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController,n=t.pivotController,a=t.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;let l=!1,A=!1;const h=this._scene.canvas.canvas,u=i=>{let s;i&&i.worldPos&&(s=i.worldPos);const r=i&&i.entity?i.entity.aabb:e.aabb;if(s){const i=e.camera;c.subVec3(i.eye,i.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})},d=e.tickify(this._canvasMouseMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(l||A)return;const r=a.hasSubs("hover"),n=a.hasSubs("hoverEnter"),h=a.hasSubs("hoverOut"),c=a.hasSubs("hoverOff"),u=a.hasSubs("hoverSurface"),d=a.hasSubs("hoverSnapOrSurface");if(r||n||h||c||u||d)if(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=!0,o.schedulePickSurface=u,o.scheduleSnapOrPick=d,o.update(),o.pickResult){if(o.pickResult.entity){const t=o.pickResult.entity.id;this._lastPickedEntityId!==t&&(void 0!==this._lastPickedEntityId&&a.fire("hoverOut",{entity:e.objects[this._lastPickedEntityId]},!0),a.fire("hoverEnter",o.pickResult,!0),this._lastPickedEntityId=t)}a.fire("hover",o.pickResult,!0),(o.pickResult.worldPos||o.pickResult.snappedWorldPos)&&a.fire("hoverSurface",o.pickResult,!0)}else void 0!==this._lastPickedEntityId&&(a.fire("hoverOut",{entity:e.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),a.fire("hoverOff",{canvasPos:o.pickCursorPos},!0)});h.addEventListener("mousemove",d),h.addEventListener("mousedown",this._canvasMouseDownHandler=t=>{1===t.which&&(l=!0),3===t.which&&(A=!0);if(1===t.which&&i.active&&i.pointerEnabled&&(s.mouseDownClientX=t.clientX,s.mouseDownClientY=t.clientY,s.mouseDownCursorX=s.pointerCanvasPos[0],s.mouseDownCursorY=s.pointerCanvasPos[1],!i.firstPerson&&i.followPointer&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickSurface=!0,o.update(),1===t.which))){const t=o.pickResult;t&&t.worldPos?(n.setPivotPos(t.worldPos),n.startPivot()):(i.smartPivot?n.setCanvasPivotPos(s.pointerCanvasPos):n.setPivotPos(e.camera.look),n.startPivot())}}),document.addEventListener("mouseup",this._documentMouseUpHandler=e=>{1===e.which&&(l=!1),3===e.which&&(A=!1),n.getPivoting()&&n.endPivot()}),h.addEventListener("mouseup",this._canvasMouseUpHandler=r=>{if(!i.active||!i.pointerEnabled)return;if(!(1===r.which))return;if(n.hidePivot(),Math.abs(r.clientX-s.mouseDownClientX)>3||Math.abs(r.clientY-s.mouseDownClientY)>3)return;const l=a.hasSubs("picked"),A=a.hasSubs("pickedNothing"),h=a.hasSubs("pickedSurface"),d=a.hasSubs("doublePicked"),p=a.hasSubs("doublePickedSurface"),f=a.hasSubs("doublePickedNothing");if(!(i.doublePickFlyTo||d||p||f))return(l||A||h)&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=!0,o.schedulePickSurface=h,o.update(),o.pickResult?(a.fire("picked",o.pickResult,!0),o.pickedSurface&&a.fire("pickedSurface",o.pickResult,!0)):a.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0)),void(this._clicks=0);if(this._clicks++,1===this._clicks){o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=i.doublePickFlyTo,o.schedulePickSurface=h,o.update();const e=o.pickResult,r=o.pickedSurface;this._timeout=setTimeout((()=>{e?(a.fire("picked",e,!0),r&&(a.fire("pickedSurface",e,!0),!i.firstPerson&&i.followPointer&&(t.pivotController.setPivotPos(e.worldPos),t.pivotController.startPivot()&&t.pivotController.showPivot()))):a.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0),this._clicks=0}),i.doubleClickTimeFrame)}else{if(null!==this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null),o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=i.doublePickFlyTo||d||p,o.schedulePickSurface=o.schedulePickEntity&&p,o.update(),o.pickResult){if(a.fire("doublePicked",o.pickResult,!0),o.pickedSurface&&a.fire("doublePickedSurface",o.pickResult,!0),i.doublePickFlyTo&&(u(o.pickResult),!i.firstPerson&&i.followPointer)){const e=o.pickResult.entity.aabb,i=c.getAABB3Center(e);t.pivotController.setPivotPos(i),t.pivotController.startPivot()&&t.pivotController.showPivot()}}else if(a.fire("doublePickedNothing",{canvasPos:s.pointerCanvasPos},!0),i.doublePickFlyTo&&(u(),!i.firstPerson&&i.followPointer)){const i=e.aabb,s=c.getAABB3Center(i);t.pivotController.setPivotPos(s),t.pivotController.startPivot()&&t.pivotController.showPivot()}this._clicks=0}},!1)}reset(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}destroy(){const e=this._scene.canvas.canvas;e.removeEventListener("mousemove",this._canvasMouseMoveHandler),e.removeEventListener("mousedown",this._canvasMouseDownHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._canvasMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}class nc{constructor(e,t,i,s,r){this._scene=e;const o=e.input,n=[],a=e.canvas.canvas;let l=!0;this._onSceneMouseMove=o.on("mousemove",(()=>{l=!0})),this._onSceneKeyDown=o.on("keydown",(t=>{i.active&&i.pointerEnabled&&e.input.keyboardEnabled&&s.mouseover&&(n[t]=!0,t===o.KEY_SHIFT&&(a.style.cursor="move"))})),this._onSceneKeyUp=o.on("keyup",(s=>{i.active&&i.pointerEnabled&&e.input.keyboardEnabled&&(n[s]=!1,s===o.KEY_SHIFT&&(a.style.cursor=null),t.pivotController.getPivoting()&&t.pivotController.endPivot())})),this._onTick=e.on("tick",(a=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;if(!s.mouseover)return;const A=t.cameraControl,h=a.deltaTime/1e3;if(!i.planView){const e=A._isKeyDownForAction(A.ROTATE_Y_POS,n),s=A._isKeyDownForAction(A.ROTATE_Y_NEG,n),o=A._isKeyDownForAction(A.ROTATE_X_POS,n),a=A._isKeyDownForAction(A.ROTATE_X_NEG,n),l=h*i.keyboardRotationRate;(e||s||o||a)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),e?r.rotateDeltaY+=l:s&&(r.rotateDeltaY-=l),o?r.rotateDeltaX+=l:a&&(r.rotateDeltaX-=l),!i.firstPerson&&i.followPointer&&t.pivotController.startPivot())}if(!n[o.KEY_CTRL]&&!n[o.KEY_ALT]){const e=A._isKeyDownForAction(A.DOLLY_BACKWARDS,n),o=A._isKeyDownForAction(A.DOLLY_FORWARDS,n);if(e||o){const n=h*i.keyboardDollyRate;!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),o?r.dollyDelta-=n:e&&(r.dollyDelta+=n),l&&(s.followPointerDirty=!0,l=!1)}}const c=A._isKeyDownForAction(A.PAN_FORWARDS,n),u=A._isKeyDownForAction(A.PAN_BACKWARDS,n),d=A._isKeyDownForAction(A.PAN_LEFT,n),p=A._isKeyDownForAction(A.PAN_RIGHT,n),f=A._isKeyDownForAction(A.PAN_UP,n),g=A._isKeyDownForAction(A.PAN_DOWN,n),m=(n[o.KEY_ALT]?.3:1)*h*i.keyboardPanRate;(c||u||d||p||f||g)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),g?r.panDeltaY+=m:f&&(r.panDeltaY+=-m),p?r.panDeltaX+=-m:d&&(r.panDeltaX+=m),u?r.panDeltaZ+=m:c&&(r.panDeltaZ+=-m))}))}reset(){}destroy(){this._scene.off(this._onTick),this._scene.input.off(this._onSceneMouseMove),this._scene.input.off(this._onSceneKeyDown),this._scene.input.off(this._onSceneKeyUp)}}const ac=c.vec3();class lc{constructor(e,t,i,s,r){this._scene=e;const o=e.camera,n=t.pickController,a=t.pivotController,l=t.panController;let A=1,h=1,u=null;this._onTick=e.on("tick",(()=>{if(!i.active||!i.pointerEnabled)return;let t="default";if(Math.abs(r.dollyDelta)<.001&&(r.dollyDelta=0),Math.abs(r.rotateDeltaX)<.001&&(r.rotateDeltaX=0),Math.abs(r.rotateDeltaY)<.001&&(r.rotateDeltaY=0),0===r.rotateDeltaX&&0===r.rotateDeltaY||(r.dollyDelta=0),i.followPointer){if(--A<=0&&(A=1,0!==r.dollyDelta)){if(0===r.rotateDeltaY&&0===r.rotateDeltaX&&i.followPointer&&s.followPointerDirty&&(n.pickCursorPos=s.pointerCanvasPos,n.schedulePickSurface=!0,n.update(),n.pickResult&&n.pickResult.worldPos?u=n.pickResult.worldPos:(h=1,u=null),s.followPointerDirty=!1),u){const t=Math.abs(c.lenVec3(c.subVec3(u,e.camera.eye,ac)));h=t/i.dollyProximityThreshold}h{s.mouseover=!0}),o.addEventListener("mouseleave",this._mouseLeaveHandler=()=>{s.mouseover=!1,o.style.cursor=null}),document.addEventListener("mousemove",this._mouseMoveHandler=e=>{hc(e,o,s.pointerCanvasPos)}),o.addEventListener("mousedown",this._mouseDownHandler=e=>{i.active&&i.pointerEnabled&&(hc(e,o,s.pointerCanvasPos),s.mouseover=!0)}),o.addEventListener("mouseup",this._mouseUpHandler=e=>{i.active&&i.pointerEnabled})}reset(){}destroy(){const e=this._scene.canvas.canvas;document.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseenter",this._mouseEnterHandler),e.removeEventListener("mouseleave",this._mouseLeaveHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mouseup",this._mouseUpHandler)}}function hc(e,t,i){if(e){const{left:s,top:r}=t.getBoundingClientRect();i[0]=e.clientX-s-window.scrollX,i[1]=e.clientY-r-window.scrollY}else e=window.event,i[0]=e.x,i[1]=e.y;return i}const cc=function(e,t){if(e){let i=e.target,s=0,r=0;for(;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t};class uc{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController,n=t.pivotController,a=c.vec2(),l=c.vec2(),A=c.vec2(),h=c.vec2(),u=[],d=this._scene.canvas.canvas;let p=0,f=!1;this._onTick=e.on("tick",(()=>{f=!1})),d.addEventListener("touchstart",this._canvasTouchStartHandler=t=>{if(!i.active||!i.pointerEnabled)return;t.preventDefault();const r=t.touches,l=t.changedTouches;for(s.touchStartTime=Date.now(),1===r.length&&1===l.length&&(cc(r[0],a),i.followPointer&&(o.pickCursorPos=a,o.schedulePickSurface=!0,o.update(),i.planView||(o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(n.setPivotPos(o.pickResult.worldPos),!i.firstPerson&&n.startPivot()&&n.showPivot()):(i.smartPivot?n.setCanvasPivotPos(s.pointerCanvasPos):n.setPivotPos(e.camera.look),!i.firstPerson&&n.startPivot()&&n.showPivot()))));u.length{n.getPivoting()&&n.endPivot()}),d.addEventListener("touchmove",this._canvasTouchMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(t.stopPropagation(),t.preventDefault(),f)return;f=!0;const n=e.canvas.boundary,a=n[2],d=n[3],g=t.touches;if(t.touches.length===p){if(1===p){cc(g[0],l),c.subVec2(l,u[0],h);const t=h[0],o=h[1];if(null!==s.longTouchTimeout&&(Math.abs(t)>i.longTapRadius||Math.abs(o)>i.longTapRadius)&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),i.planView){const s=e.camera;if("perspective"===s.projection){const n=Math.abs(e.camera.eyeLookDist)*Math.tan(s.perspective.fov/2*Math.PI/180);r.panDeltaX+=t*n/d*i.touchPanRate,r.panDeltaY+=o*n/d*i.touchPanRate}else r.panDeltaX+=.5*s.ortho.scale*(t/d)*i.touchPanRate,r.panDeltaY+=.5*s.ortho.scale*(o/d)*i.touchPanRate}else r.rotateDeltaY-=t/a*(1*i.dragRotationRate),r.rotateDeltaX+=o/d*(1.5*i.dragRotationRate)}else if(2===p){const t=g[0],n=g[1];cc(t,l),cc(n,A);const a=c.geometricMeanVec2(u[0],u[1]),h=c.geometricMeanVec2(l,A),p=c.vec2();c.subVec2(a,h,p);const f=p[0],m=p[1],_=e.camera,v=c.distVec2([t.pageX,t.pageY],[n.pageX,n.pageY]),b=(c.distVec2(u[0],u[1])-v)*i.touchDollyRate;if(r.dollyDelta=b,Math.abs(b)<1)if("perspective"===_.projection){const t=o.pickResult?o.pickResult.worldPos:e.center,s=Math.abs(c.lenVec3(c.subVec3(t,e.camera.eye,[])))*Math.tan(_.perspective.fov/2*Math.PI/180);r.panDeltaX-=f*s/d*i.touchPanRate,r.panDeltaY-=m*s/d*i.touchPanRate}else r.panDeltaX-=.5*_.ortho.scale*(f/d)*i.touchPanRate,r.panDeltaY-=.5*_.ortho.scale*(m/d)*i.touchPanRate;s.pointerCanvasPos=h}for(let e=0;e{let s;i&&i.worldPos&&(s=i.worldPos);const r=i?i.entity.aabb:e.aabb;if(s){const i=e.camera;c.subVec3(i.eye,i.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})};d.addEventListener("touchstart",this._canvasTouchStartHandler=e=>{if(!i.active||!i.pointerEnabled)return;null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null);const r=e.touches,o=e.changedTouches;if(a=Date.now(),1===r.length&&1===o.length){h=a,dc(r[0],A);const o=A[0],n=A[1],l=r[0].pageX,c=r[0].pageY;s.longTouchTimeout=setTimeout((()=>{t.cameraControl.fire("rightClick",{pagePos:[Math.round(l),Math.round(c)],canvasPos:[Math.round(o),Math.round(n)],event:e},!0),s.longTouchTimeout=null}),i.longTapTimeout)}else h=-1;for(;l.length{if(!i.active||!i.pointerEnabled)return;const t=Date.now(),r=e.touches,a=e.changedTouches,d=n.hasSubs("pickedSurface");null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),0===r.length&&1===a.length&&h>-1&&t-h<150&&(u>-1&&h-u<325?(dc(a[0],o.pickCursorPos),o.schedulePickEntity=!0,o.schedulePickSurface=d,o.update(),o.pickResult?(o.pickResult.touchInput=!0,n.fire("doublePicked",o.pickResult),o.pickedSurface&&n.fire("doublePickedSurface",o.pickResult),i.doublePickFlyTo&&p(o.pickResult)):(n.fire("doublePickedNothing"),i.doublePickFlyTo&&p()),u=-1):c.distVec2(l[0],A)<4&&(dc(a[0],o.pickCursorPos),o.schedulePickEntity=!0,o.schedulePickSurface=d,o.update(),o.pickResult?(o.pickResult.touchInput=!0,n.fire("picked",o.pickResult),o.pickedSurface&&n.fire("pickedSurface",o.pickResult)):n.fire("pickedNothing"),u=t),h=-1),l.length=r.length;for(let e=0,t=r.length;e{e.preventDefault()},this._configs={longTapTimeout:600,longTapRadius:5,active:!0,keyboardLayout:"qwerty",navMode:"orbit",planView:!1,firstPerson:!1,followPointer:!0,doublePickFlyTo:!0,panRightClick:!0,showPivot:!1,pointerEnabled:!0,constrainVertical:!1,smartPivot:!1,doubleClickTimeFrame:250,snapToVertex:true,snapToEdge:true,snapRadius:30,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},this._states={pointerCanvasPos:c.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:c.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},this._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};const i=this.scene;this._controllers={cameraControl:this,pickController:new Jh(this,this._configs),pivotController:new Xh(i,this._configs),panController:new Vh(i),cameraFlight:new _h(this,{duration:.5})},this._handlers=[new Ac(this.scene,this._controllers,this._configs,this._states,this._updates),new uc(this.scene,this._controllers,this._configs,this._states,this._updates),new Zh(this.scene,this._controllers,this._configs,this._states,this._updates),new rc(this.scene,this._controllers,this._configs,this._states,this._updates),new oc(this.scene,this._controllers,this._configs,this._states,this._updates),new pc(this.scene,this._controllers,this._configs,this._states,this._updates),new nc(this.scene,this._controllers,this._configs,this._states,this._updates)],this._cameraUpdater=new lc(this.scene,this._controllers,this._configs,this._states,this._updates),this.navMode=t.navMode,t.planView&&(this.planView=t.planView),this.constrainVertical=t.constrainVertical,t.keyboardLayout?this.keyboardLayout=t.keyboardLayout:this.keyMap=t.keyMap,this.doublePickFlyTo=t.doublePickFlyTo,this.panRightClick=t.panRightClick,this.active=t.active,this.followPointer=t.followPointer,this.rotationInertia=t.rotationInertia,this.keyboardPanRate=t.keyboardPanRate,this.touchPanRate=t.touchPanRate,this.keyboardRotationRate=t.keyboardRotationRate,this.dragRotationRate=t.dragRotationRate,this.touchDollyRate=t.touchDollyRate,this.dollyInertia=t.dollyInertia,this.dollyProximityThreshold=t.dollyProximityThreshold,this.dollyMinSpeed=t.dollyMinSpeed,this.panInertia=t.panInertia,this.pointerEnabled=!0,this.keyboardDollyRate=t.keyboardDollyRate,this.mouseWheelDollyRate=t.mouseWheelDollyRate}set keyMap(e){if(e=e||"qwerty",_.isString(e)){const t=this.scene.input,i={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":i[this.PAN_LEFT]=[t.KEY_A],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_Z],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_W,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_Q,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6];break;case"azerty":i[this.PAN_LEFT]=[t.KEY_Q],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_W],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_Z,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_A,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6]}this._keyMap=i}else{const t=e;this._keyMap=t}}get keyMap(){return this._keyMap}_isKeyDownForAction(e,t){const i=this._keyMap[e];if(!i)return!1;t||(t=this.scene.input.keyDown);for(let e=0,s=i.length;e0?yc(t):null,n=i&&i.length>0?yc(i):null,a=e=>{if(!e)return;var t=!0;(n&&n[e.type]||o&&!o[e.type])&&(t=!1),t&&s.push(e.id);const i=e.children;if(i)for(var r=0,l=i.length;r * Copyright (c) 2022 Niklas von Hertzen @@ -33,5 +33,5 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var xc=function(e,t){return xc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},xc(e,t)};function Bc(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}xc(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var wc=function(){return wc=Object.assign||function(e){for(var t,i=1,s=arguments.length;i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=55296&&r<=56319&&i>10),n%1024+56320)),(r+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Sc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tc="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Rc=0;Rc=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Qc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vc="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Hc=0;Hc>4,h[l++]=(15&s)<<4|r>>2,h[l++]=(3&r)<<6|63&o;return A}(e),n=Array.isArray(o)?function(e){for(var t=e.length,i=[],s=0;s0;){var n=s[--o];if(Array.isArray(e)?-1!==e.indexOf(n):e===n)for(var a=i;a<=s.length;){var l;if((l=s[++a])===t)return!0;if(l!==jc)break}if(n!==jc)break}return!1},Bu=function(e,t){for(var i=e;i>=0;){var s=t[i];if(s!==jc)return s;i--}return 0},wu=function(e,t,i,s,r){if(0===i[s])return"×";var o=s-1;if(Array.isArray(r)&&!0===r[o])return"×";var n=o-1,a=o+1,l=t[o],A=n>=0?t[n]:0,h=t[a];if(2===l&&3===h)return"×";if(-1!==gu.indexOf(l))return"!";if(-1!==gu.indexOf(h))return"×";if(-1!==mu.indexOf(h))return"×";if(8===Bu(o,t))return"÷";if(11===pu.get(e[o]))return"×";if((l===ru||l===ou)&&11===pu.get(e[a]))return"×";if(7===l||7===h)return"×";if(9===l)return"×";if(-1===[jc,Gc,zc].indexOf(l)&&9===h)return"×";if(-1!==[Wc,Kc,Xc,qc,iu].indexOf(h))return"×";if(Bu(o,t)===Zc)return"×";if(xu(23,Zc,o,t))return"×";if(xu([Wc,Kc],Yc,o,t))return"×";if(xu(12,12,o,t))return"×";if(l===jc)return"÷";if(23===l||23===h)return"×";if(16===h||16===l)return"÷";if(-1!==[Gc,zc,Yc].indexOf(h)||14===l)return"×";if(36===A&&-1!==yu.indexOf(l))return"×";if(l===iu&&36===h)return"×";if(h===Jc)return"×";if(-1!==fu.indexOf(h)&&l===$c||-1!==fu.indexOf(l)&&h===$c)return"×";if(l===tu&&-1!==[lu,ru,ou].indexOf(h)||-1!==[lu,ru,ou].indexOf(l)&&h===eu)return"×";if(-1!==fu.indexOf(l)&&-1!==_u.indexOf(h)||-1!==_u.indexOf(l)&&-1!==fu.indexOf(h))return"×";if(-1!==[tu,eu].indexOf(l)&&(h===$c||-1!==[Zc,zc].indexOf(h)&&t[a+1]===$c)||-1!==[Zc,zc].indexOf(l)&&h===$c||l===$c&&-1!==[$c,iu,qc].indexOf(h))return"×";if(-1!==[$c,iu,qc,Wc,Kc].indexOf(h))for(var c=o;c>=0;){if((u=t[c])===$c)return"×";if(-1===[iu,qc].indexOf(u))break;c--}if(-1!==[tu,eu].indexOf(h))for(c=-1!==[Wc,Kc].indexOf(l)?n:o;c>=0;){var u;if((u=t[c])===$c)return"×";if(-1===[iu,qc].indexOf(u))break;c--}if(Au===l&&-1!==[Au,hu,nu,au].indexOf(h)||-1!==[hu,nu].indexOf(l)&&-1!==[hu,cu].indexOf(h)||-1!==[cu,au].indexOf(l)&&h===cu)return"×";if(-1!==bu.indexOf(l)&&-1!==[Jc,eu].indexOf(h)||-1!==bu.indexOf(h)&&l===tu)return"×";if(-1!==fu.indexOf(l)&&-1!==fu.indexOf(h))return"×";if(l===qc&&-1!==fu.indexOf(h))return"×";if(-1!==fu.concat($c).indexOf(l)&&h===Zc&&-1===du.indexOf(e[a])||-1!==fu.concat($c).indexOf(h)&&l===Kc)return"×";if(41===l&&41===h){for(var d=i[o],p=1;d>0&&41===t[--d];)p++;if(p%2!=0)return"×"}return l===ru&&h===ou?"×":"÷"},Pu=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=function(e,t){void 0===t&&(t="strict");var i=[],s=[],r=[];return e.forEach((function(e,o){var n=pu.get(e);if(n>50?(r.push(!0),n-=50):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return s.push(o),i.push(16);if(4===n||11===n){if(0===o)return s.push(o),i.push(su);var a=i[o-1];return-1===vu.indexOf(a)?(s.push(s[o-1]),i.push(a)):(s.push(o),i.push(su))}return s.push(o),31===n?i.push("strict"===t?Yc:lu):n===uu||29===n?i.push(su):43===n?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(lu):i.push(su):void i.push(n)})),[s,i,r]}(e,t.lineBreak),s=i[0],r=i[1],o=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[$c,su,uu].indexOf(e)?lu:e})));var n="keep-all"===t.wordBreak?o.map((function(t,i){return t&&e[i]>=19968&&e[i]<=40959})):void 0;return[s,r,n]},Cu=function(){function e(e,t,i,s){this.codePoints=e,this.required="!"===t,this.start=i,this.end=s}return e.prototype.slice=function(){return Dc.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),Mu=function(e){return e>=48&&e<=57},Fu=function(e){return Mu(e)||e>=65&&e<=70||e>=97&&e<=102},Eu=function(e){return 10===e||9===e||32===e},Iu=function(e){return function(e){return function(e){return e>=97&&e<=122}(e)||function(e){return e>=65&&e<=90}(e)}(e)||function(e){return e>=128}(e)||95===e},Du=function(e){return Iu(e)||Mu(e)||45===e},Su=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},Tu=function(e,t){return 92===e&&10!==t},Ru=function(e,t,i){return 45===e?Iu(t)||Tu(t,i):!!Iu(e)||!(92!==e||!Tu(e,t))},Lu=function(e,t,i){return 43===e||45===e?!!Mu(t)||46===t&&Mu(i):Mu(46===e?t:e)},Uu=function(e){var t=0,i=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(i=-1),t++);for(var s=[];Mu(e[t]);)s.push(e[t++]);var r=s.length?parseInt(Dc.apply(void 0,s),10):0;46===e[t]&&t++;for(var o=[];Mu(e[t]);)o.push(e[t++]);var n=o.length,a=n?parseInt(Dc.apply(void 0,o),10):0;69!==e[t]&&101!==e[t]||t++;var l=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(l=-1),t++);for(var A=[];Mu(e[t]);)A.push(e[t++]);var h=A.length?parseInt(Dc.apply(void 0,A),10):0;return i*(r+a*Math.pow(10,-n))*Math.pow(10,l*h)},ku={type:2},Ou={type:3},Nu={type:4},Qu={type:13},Vu={type:8},Hu={type:21},ju={type:9},Gu={type:10},zu={type:11},Wu={type:12},Ku={type:14},Xu={type:23},Ju={type:1},Yu={type:25},Zu={type:24},qu={type:26},$u={type:27},ed={type:28},td={type:29},id={type:31},sd={type:32},rd=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(Ic(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==sd;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(Du(t)||Tu(i,s)){var r=Ru(t,i,s)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Qu;break;case 39:return this.consumeStringToken(39);case 40:return ku;case 41:return Ou;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Ku;break;case 43:if(Lu(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return Nu;case 45:var o=e,n=this.peekCodePoint(0),a=this.peekCodePoint(1);if(Lu(o,n,a))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Ru(o,n,a))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===n&&62===a)return this.consumeCodePoint(),this.consumeCodePoint(),Zu;break;case 46:if(Lu(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(42===l&&47===(l=this.consumeCodePoint()))return this.consumeToken();if(-1===l)return this.consumeToken()}break;case 58:return qu;case 59:return $u;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),Yu;break;case 64:var A=this.peekCodePoint(0),h=this.peekCodePoint(1),c=this.peekCodePoint(2);if(Ru(A,h,c))return{type:7,value:this.consumeName()};break;case 91:return ed;case 92:if(Tu(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return td;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Vu;break;case 123:return zu;case 125:return Wu;case 117:case 85:var u=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==u||!Fu(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),ju;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),Hu;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Gu;break;case-1:return sd}return Eu(e)?(this.consumeWhiteSpace(),id):Mu(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):Iu(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:Dc(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();Fu(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(Dc.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(Dc.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var s=parseInt(Dc.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&Fu(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Fu(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:s,end:parseInt(Dc.apply(void 0,r),16)}}return{type:30,start:s,end:s}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var t=this.peekCodePoint(0);if(39===t||34===t){var i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),Xu)}for(;;){var s=this.consumeCodePoint();if(-1===s||41===s)return{type:22,value:Dc.apply(void 0,e)};if(Eu(s))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:Dc.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Xu);if(34===s||39===s||40===s||Su(s))return this.consumeBadUrlRemnants(),Xu;if(92===s){if(!Tu(s,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),Xu;e.push(this.consumeEscapedCodePoint())}else e.push(s)}},e.prototype.consumeWhiteSpace=function(){for(;Eu(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;Tu(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var i=Math.min(5e4,e);t+=Dc.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var s=this._value[i];if(-1===s||void 0===s||s===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(10===s)return this._value.splice(0,i),Ju;if(92===s){var r=this._value[i+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):Tu(s,r)&&(t+=this.consumeStringSlice(i),t+=Dc(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=4,i=this.peekCodePoint(0);for(43!==i&&45!==i||e.push(this.consumeCodePoint());Mu(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var s=this.peekCodePoint(1);if(46===i&&Mu(s))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Mu(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),s=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===i||101===i)&&((43===s||45===s)&&Mu(r)||Mu(s)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Mu(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Uu(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],s=this.peekCodePoint(0),r=this.peekCodePoint(1),o=this.peekCodePoint(2);return Ru(s,r,o)?{type:15,number:t,flags:i,unit:this.consumeName()}:37===s?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Fu(e)){for(var t=Dc(e);Fu(this.peekCodePoint(0))&&t.length<6;)t+=Dc(this.consumeCodePoint());Eu(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||function(e){return e>=55296&&e<=57343}(i)||i>1114111?65533:i}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(Du(t))e+=Dc(t);else{if(!Tu(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=Dc(this.consumeEscapedCodePoint())}}},e}(),od=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new rd;return i.write(t),new e(i.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(32===i.type||pd(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?sd:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),nd=function(e){return 15===e.type},ad=function(e){return 17===e.type},ld=function(e){return 20===e.type},Ad=function(e){return 0===e.type},hd=function(e,t){return ld(e)&&e.value===t},cd=function(e){return 31!==e.type},ud=function(e){return 31!==e.type&&4!==e.type},dd=function(e){var t=[],i=[];return e.forEach((function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)})),i.length&&t.push(i),t},pd=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},fd=function(e){return 17===e.type||15===e.type},gd=function(e){return 16===e.type||fd(e)},md=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},_d={type:17,number:0,flags:4},vd={type:16,number:50,flags:4},bd={type:16,number:100,flags:4},yd=function(e,t,i){var s=e[0],r=e[1];return[xd(s,t),xd(void 0!==r?r:s,i)]},xd=function(e,t){if(16===e.type)return e.number/100*t;if(nd(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},Bd=function(e,t){if(15===t.type)switch(t.unit){case"deg":return Math.PI*t.number/180;case"grad":return Math.PI/200*t.number;case"rad":return t.number;case"turn":return 2*Math.PI*t.number}throw new Error("Unsupported angle type")},wd=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},Pd=function(e){switch(e.filter(ld).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[_d,_d];case"to top":case"bottom":return Cd(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[_d,bd];case"to right":case"left":return Cd(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[bd,bd];case"to bottom":case"top":return Cd(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[bd,_d];case"to left":case"right":return Cd(270)}return 0},Cd=function(e){return Math.PI*e/180},Md=function(e,t){if(18===t.type){var i=Ld[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var s=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);return Id(parseInt(s+s,16),parseInt(r+r,16),parseInt(o+o,16),1)}if(4===t.value.length){s=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);var n=t.value.substring(3,4);return Id(parseInt(s+s,16),parseInt(r+r,16),parseInt(o+o,16),parseInt(n+n,16)/255)}if(6===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6);return Id(parseInt(s,16),parseInt(r,16),parseInt(o,16),1)}if(8===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6),n=t.value.substring(6,8);return Id(parseInt(s,16),parseInt(r,16),parseInt(o,16),parseInt(n,16)/255)}}if(20===t.type){var a=kd[t.value.toUpperCase()];if(void 0!==a)return a}return kd.TRANSPARENT},Fd=function(e){return 0==(255&e)},Ed=function(e){var t=255&e,i=255&e>>8,s=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+s+","+i+","+t/255+")":"rgb("+r+","+s+","+i+")"},Id=function(e,t,i,s){return(e<<24|t<<16|i<<8|Math.round(255*s)<<0)>>>0},Dd=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},Sd=function(e,t){var i=t.filter(ud);if(3===i.length){var s=i.map(Dd),r=s[0],o=s[1],n=s[2];return Id(r,o,n,1)}if(4===i.length){var a=i.map(Dd),l=(r=a[0],o=a[1],n=a[2],a[3]);return Id(r,o,n,l)}return 0};function Td(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var Rd=function(e,t){var i=t.filter(ud),s=i[0],r=i[1],o=i[2],n=i[3],a=(17===s.type?Cd(s.number):Bd(e,s))/(2*Math.PI),l=gd(r)?r.number/100:0,A=gd(o)?o.number/100:0,h=void 0!==n&&gd(n)?xd(n,1):1;if(0===l)return Id(255*A,255*A,255*A,1);var c=A<=.5?A*(l+1):A+l-A*l,u=2*A-c,d=Td(u,c,a+1/3),p=Td(u,c,a),f=Td(u,c,a-1/3);return Id(255*d,255*p,255*f,h)},Ld={hsl:Rd,hsla:Rd,rgb:Sd,rgba:Sd},Ud=function(e,t){return Md(e,od.create(t).parseComponentValue())},kd={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Od={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(ld(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Nd={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Qd=function(e,t){var i=Md(e,t[0]),s=t[1];return s&&gd(s)?{color:i,stop:s}:{color:i,stop:null}},Vd=function(e,t){var i=e[0],s=e[e.length-1];null===i.stop&&(i.stop=_d),null===s.stop&&(s.stop=bd);for(var r=[],o=0,n=0;no?r.push(l):r.push(o),o=l}else r.push(null)}var A=null;for(n=0;ne.optimumDistance)?{optimumCorner:t,optimumDistance:a}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},zd=function(e,t){var i=Cd(180),s=[];return dd(t).forEach((function(t,r){if(0===r){var o=t[0];if(20===o.type&&-1!==["top","left","right","bottom"].indexOf(o.value))return void(i=Pd(t));if(wd(o))return void(i=(Bd(e,o)+Cd(270))%Cd(360))}var n=Qd(e,t);s.push(n)})),{angle:i,stops:s,type:1}},Wd=function(e,t){var i=0,s=3,r=[],o=[];return dd(t).forEach((function(t,n){var a=!0;if(0===n?a=t.reduce((function(e,t){if(ld(t))switch(t.value){case"center":return o.push(vd),!1;case"top":case"left":return o.push(_d),!1;case"right":case"bottom":return o.push(bd),!1}else if(gd(t)||fd(t))return o.push(t),!1;return e}),a):1===n&&(a=t.reduce((function(e,t){if(ld(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"contain":case"closest-side":return s=0,!1;case"farthest-side":return s=1,!1;case"closest-corner":return s=2,!1;case"cover":case"farthest-corner":return s=3,!1}else if(fd(t)||gd(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)),a){var l=Qd(e,t);r.push(l)}})),{size:s,shape:i,stops:r,position:o,type:2}},Kd=function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var s=Jd[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(e,t.values)}throw new Error("Unsupported image type "+t.type)};var Xd,Jd={"linear-gradient":function(e,t){var i=Cd(180),s=[];return dd(t).forEach((function(t,r){if(0===r){var o=t[0];if(20===o.type&&"to"===o.value)return void(i=Pd(t));if(wd(o))return void(i=Bd(e,o))}var n=Qd(e,t);s.push(n)})),{angle:i,stops:s,type:1}},"-moz-linear-gradient":zd,"-ms-linear-gradient":zd,"-o-linear-gradient":zd,"-webkit-linear-gradient":zd,"radial-gradient":function(e,t){var i=0,s=3,r=[],o=[];return dd(t).forEach((function(t,n){var a=!0;if(0===n){var l=!1;a=t.reduce((function(e,t){if(l)if(ld(t))switch(t.value){case"center":return o.push(vd),e;case"top":case"left":return o.push(_d),e;case"right":case"bottom":return o.push(bd),e}else(gd(t)||fd(t))&&o.push(t);else if(ld(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"at":return l=!0,!1;case"closest-side":return s=0,!1;case"cover":case"farthest-side":return s=1,!1;case"contain":case"closest-corner":return s=2,!1;case"farthest-corner":return s=3,!1}else if(fd(t)||gd(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)}if(a){var A=Qd(e,t);r.push(A)}})),{size:s,shape:i,stops:r,position:o,type:2}},"-moz-radial-gradient":Wd,"-ms-radial-gradient":Wd,"-o-radial-gradient":Wd,"-webkit-radial-gradient":Wd,"-webkit-gradient":function(e,t){var i=Cd(180),s=[],r=1;return dd(t).forEach((function(t,i){var o=t[0];if(0===i){if(ld(o)&&"linear"===o.value)return void(r=1);if(ld(o)&&"radial"===o.value)return void(r=2)}if(18===o.type)if("from"===o.name){var n=Md(e,o.values[0]);s.push({stop:_d,color:n})}else if("to"===o.name){n=Md(e,o.values[0]);s.push({stop:bd,color:n})}else if("color-stop"===o.name){var a=o.values.filter(ud);if(2===a.length){n=Md(e,a[1]);var l=a[0];ad(l)&&s.push({stop:{type:16,number:100*l.number,flags:l.flags},color:n})}}})),1===r?{angle:(i+Cd(180))%Cd(360),stops:s,type:r}:{size:3,shape:0,stops:s,position:[],type:r}}},Yd={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter((function(e){return ud(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Jd[e.name])}(e)})).map((function(t){return Kd(e,t)}))}},Zd={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(ld(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},qd={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return dd(t).map((function(e){return e.filter(gd)})).map(md)}},$d={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return dd(t).map((function(e){return e.filter(ld).map((function(e){return e.value})).join(" ")})).map(ep)}},ep=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Xd||(Xd={}));var tp,ip={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return dd(t).map((function(e){return e.filter(sp)}))}},sp=function(e){return ld(e)||gd(e)},rp=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},op=rp("top"),np=rp("right"),ap=rp("bottom"),lp=rp("left"),Ap=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return md(t.filter(gd))}}},hp=Ap("top-left"),cp=Ap("top-right"),up=Ap("bottom-right"),dp=Ap("bottom-left"),pp=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},fp=pp("top"),gp=pp("right"),mp=pp("bottom"),_p=pp("left"),vp=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return nd(t)?t.number:0}}},bp=vp("top"),yp=vp("right"),xp=vp("bottom"),Bp=vp("left"),wp={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Pp={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},Cp={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(ld).reduce((function(e,t){return e|Mp(t.value)}),0)}},Mp=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},Fp={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Ep={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(tp||(tp={}));var Ip,Dp={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?tp.STRICT:tp.NORMAL}},Sp={name:"line-height",initialValue:"normal",prefix:!1,type:4},Tp=function(e,t){return ld(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:gd(e)?xd(e,t):t},Rp={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:Kd(e,t)}},Lp={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Up={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},kp=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},Op=kp("top"),Np=kp("right"),Qp=kp("bottom"),Vp=kp("left"),Hp={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(ld).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},jp={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Gp=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},zp=Gp("top"),Wp=Gp("right"),Kp=Gp("bottom"),Xp=Gp("left"),Jp={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Yp={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Zp={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&hd(t[0],"none")?[]:dd(t).map((function(t){for(var i={color:kd.TRANSPARENT,offsetX:_d,offsetY:_d,blur:_d},s=0,r=0;r1?1:0],this.overflowWrap=Df(e,jp,t.overflowWrap),this.paddingTop=Df(e,zp,t.paddingTop),this.paddingRight=Df(e,Wp,t.paddingRight),this.paddingBottom=Df(e,Kp,t.paddingBottom),this.paddingLeft=Df(e,Xp,t.paddingLeft),this.paintOrder=Df(e,Pf,t.paintOrder),this.position=Df(e,Yp,t.position),this.textAlign=Df(e,Jp,t.textAlign),this.textDecorationColor=Df(e,hf,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=Df(e,cf,null!==(s=t.textDecorationLine)&&void 0!==s?s:t.textDecoration),this.textShadow=Df(e,Zp,t.textShadow),this.textTransform=Df(e,qp,t.textTransform),this.transform=Df(e,$p,t.transform),this.transformOrigin=Df(e,rf,t.transformOrigin),this.visibility=Df(e,of,t.visibility),this.webkitTextStrokeColor=Df(e,Cf,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=Df(e,Mf,t.webkitTextStrokeWidth),this.wordBreak=Df(e,nf,t.wordBreak),this.zIndex=Df(e,af,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return Fd(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return mf(this.display,4)||mf(this.display,33554432)||mf(this.display,268435456)||mf(this.display,536870912)||mf(this.display,67108864)||mf(this.display,134217728)},e}(),Ef=function(e,t){this.content=Df(e,_f,t.content),this.quotes=Df(e,xf,t.quotes)},If=function(e,t){this.counterIncrement=Df(e,vf,t.counterIncrement),this.counterReset=Df(e,bf,t.counterReset)},Df=function(e,t,i){var s=new rd,r=null!=i?i.toString():t.initialValue;s.write(r);var o=new od(s.read());switch(t.type){case 2:var n=o.parseComponentValue();return t.parse(e,ld(n)?n.value:t.initialValue);case 0:return t.parse(e,o.parseComponentValue());case 1:return t.parse(e,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case"angle":return Bd(e,o.parseComponentValue());case"color":return Md(e,o.parseComponentValue());case"image":return Kd(e,o.parseComponentValue());case"length":var a=o.parseComponentValue();return fd(a)?a:_d;case"length-percentage":var l=o.parseComponentValue();return gd(l)?l:_d;case"time":return lf(e,o.parseComponentValue())}}},Sf=function(e,t){var i=function(e){switch(e.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(e);return 1===i||t===i},Tf=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Sf(t,3),this.styles=new Ff(e,window.getComputedStyle(t,null)),Tg(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=Ec(this.context,t),Sf(t,4)&&(this.flags|=16)},Rf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Lf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Uf=0;Uf=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Nf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Qf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Vf=0;Vf>10),n%1024+56320)),(r+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Xf=function(e,t){var i,s,r,o=function(e){var t,i,s,r,o,n=.75*e.length,a=e.length,l=0;"="===e[e.length-1]&&(n--,"="===e[e.length-2]&&n--);var A="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(n):new Array(n),h=Array.isArray(A)?A:new Uint8Array(A);for(t=0;t>4,h[l++]=(15&s)<<4|r>>2,h[l++]=(3&r)<<6|63&o;return A}(e),n=Array.isArray(o)?function(e){for(var t=e.length,i=[],s=0;s=55296&&r<=56319&&i=i)return{done:!0,value:null};for(var e="×";sn.x||r.y>n.y;return n=r,0===t||a}));return e.body.removeChild(t),a}(document);return Object.defineProperty(tg,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,i=e.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,";try{s.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(tg,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?function(e){var t=e.createElement("canvas"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var r=new Image,o=t.toDataURL();r.src=o;var n=$f(i,i,0,0,r);return s.fillStyle="red",s.fillRect(0,0,i,i),eg(n).then((function(t){s.drawImage(t,0,0);var r=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var n=e.createElement("div");return n.style.backgroundImage="url("+o+")",n.style.height="100px",qf(r)?eg($f(i,i,0,0,n)):Promise.reject(!1)})).then((function(e){return s.drawImage(e,0,0),qf(s.getImageData(0,0,i,i).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(tg,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(tg,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(tg,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(tg,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(tg,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},ig=function(e,t){this.text=e,this.bounds=t},sg=function(e,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(s,t);var o=Ec(e,s);return s.firstChild&&r.replaceChild(s.firstChild,s),o}}return Fc.EMPTY},rg=function(e,t,i){var s=e.ownerDocument;if(!s)throw new Error("Node has no owner document");var r=s.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},og=function(e){if(tg.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return function(e){for(var t,i=Zf(e),s=[];!(t=i.next()).done;)t.value&&s.push(t.value.slice());return s}(e)},ng=function(e,t){return 0!==t.letterSpacing?og(e):function(e,t){if(tg.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map((function(e){return e.segment}))}return lg(e,t)}(e,t)},ag=[32,160,4961,65792,65793,4153,4241],lg=function(e,t){for(var i,s=function(e,t){var i=Ic(e),s=Pu(i,t),r=s[0],o=s[1],n=s[2],a=i.length,l=0,A=0;return{next:function(){if(A>=a)return{done:!0,value:null};for(var e="×";A0)if(tg.SUPPORT_RANGE_BOUNDS){var r=rg(s,n,t.length).getClientRects();if(r.length>1){var a=og(t),l=0;a.forEach((function(t){o.push(new ig(t,Fc.fromDOMRectList(e,rg(s,l+n,t.length).getClientRects()))),l+=t.length}))}else o.push(new ig(t,Fc.fromDOMRectList(e,r)))}else{var A=s.splitText(t.length);o.push(new ig(t,sg(e,s))),s=A}else tg.SUPPORT_RANGE_BOUNDS||(s=s.splitText(t.length));n+=t.length})),o}(e,this.text,i,t)},hg=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(cg,ug);case 2:return e.toUpperCase();default:return e}},cg=/(^|\s|:|-|\(|\))([a-z])/g,ug=function(e,t,i){return e.length>0?t+i.toUpperCase():e},dg=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.src=i.currentSrc||i.src,s.intrinsicWidth=i.naturalWidth,s.intrinsicHeight=i.naturalHeight,s.context.cache.addImage(s.src),s}return Bc(t,e),t}(Tf),pg=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i,s.intrinsicWidth=i.width,s.intrinsicHeight=i.height,s}return Bc(t,e),t}(Tf),fg=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=new XMLSerializer,o=Ec(t,i);return i.setAttribute("width",o.width+"px"),i.setAttribute("height",o.height+"px"),s.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),s.intrinsicWidth=i.width.baseVal.value,s.intrinsicHeight=i.height.baseVal.value,s.context.cache.addImage(s.svg),s}return Bc(t,e),t}(Tf),gg=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return Bc(t,e),t}(Tf),mg=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.start=i.start,s.reversed="boolean"==typeof i.reversed&&!0===i.reversed,s}return Bc(t,e),t}(Tf),_g=[{type:15,flags:0,unit:"px",number:3}],vg=[{type:16,flags:0,number:50}],bg="password",yg=function(e){function t(t,i){var s,r=e.call(this,t,i)||this;switch(r.type=i.type.toLowerCase(),r.checked=i.checked,r.value=function(e){var t=e.type===bg?new Array(e.value.length+1).join("•"):e.value;return 0===t.length?e.placeholder||"":t}(i),"checkbox"!==r.type&&"radio"!==r.type||(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=(s=r.bounds).width>s.height?new Fc(s.left+(s.width-s.height)/2,s.top,s.height,s.height):s.width0)i.textNodes.push(new Ag(e,r,i.styles));else if(Sg(r))if(Kg(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return Cg(e,t,i,s)}));else{var n=Mg(e,r);n.styles.isVisible()&&(Eg(r,n,s)?n.flags|=4:Ig(n.styles)&&(n.flags|=2),-1!==Pg.indexOf(r.tagName)&&(n.flags|=8),i.elements.push(n),r.slot,r.shadowRoot?Cg(e,r.shadowRoot,n,s):zg(r)||Og(r)||Wg(r)||Cg(e,r,n,s))}},Mg=function(e,t){return Hg(t)?new dg(e,t):Qg(t)?new pg(e,t):Og(t)?new fg(e,t):Lg(t)?new gg(e,t):Ug(t)?new mg(e,t):kg(t)?new yg(e,t):Wg(t)?new xg(e,t):zg(t)?new Bg(e,t):jg(t)?new wg(e,t):new Tf(e,t)},Fg=function(e,t){var i=Mg(e,t);return i.flags|=4,Cg(e,t,i,i),i},Eg=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||Ng(e)&&i.styles.isTransparent()},Ig=function(e){return e.isPositioned()||e.isFloating()},Dg=function(e){return e.nodeType===Node.TEXT_NODE},Sg=function(e){return e.nodeType===Node.ELEMENT_NODE},Tg=function(e){return Sg(e)&&void 0!==e.style&&!Rg(e)},Rg=function(e){return"object"==typeof e.className},Lg=function(e){return"LI"===e.tagName},Ug=function(e){return"OL"===e.tagName},kg=function(e){return"INPUT"===e.tagName},Og=function(e){return"svg"===e.tagName},Ng=function(e){return"BODY"===e.tagName},Qg=function(e){return"CANVAS"===e.tagName},Vg=function(e){return"VIDEO"===e.tagName},Hg=function(e){return"IMG"===e.tagName},jg=function(e){return"IFRAME"===e.tagName},Gg=function(e){return"STYLE"===e.tagName},zg=function(e){return"TEXTAREA"===e.tagName},Wg=function(e){return"SELECT"===e.tagName},Kg=function(e){return"SLOT"===e.tagName},Xg=function(e){return e.tagName.indexOf("-")>0},Jg=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,i=e.counterIncrement,s=e.counterReset,r=!0;null!==i&&i.forEach((function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)}));var o=[];return r&&s.forEach((function(e){var i=t.counters[e.counter];o.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)})),o},e}(),Yg={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},Zg={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},qg={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},$g={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},em=function(e,t,i,s,r,o){return ei?om(e,r,o.length>0):s.integers.reduce((function(t,i,r){for(;e>=i;)e-=i,t+=s.values[r];return t}),"")+o},tm=function(e,t,i,s){var r="";do{i||e--,r=s(e)+r,e/=t}while(e*t>=t);return r},im=function(e,t,i,s,r){var o=i-t+1;return(e<0?"-":"")+(tm(Math.abs(e),o,s,(function(e){return Dc(Math.floor(e%o)+t)}))+r)},sm=function(e,t,i){void 0===i&&(i=". ");var s=t.length;return tm(Math.abs(e),s,!1,(function(e){return t[Math.floor(e%s)]}))+i},rm=function(e,t,i,s,r,o){if(e<-9999||e>9999)return om(e,4,r.length>0);var n=Math.abs(e),a=r;if(0===n)return t[0]+a;for(var l=0;n>0&&l<=4;l++){var A=n%10;0===A&&mf(o,1)&&""!==a?a=t[A]+a:A>1||1===A&&0===l||1===A&&1===l&&mf(o,2)||1===A&&1===l&&mf(o,4)&&e>100||1===A&&l>1&&mf(o,8)?a=t[A]+(l>0?i[l-1]:"")+a:1===A&&l>0&&(a=i[l-1]+a),n=Math.floor(n/10)}return(e<0?s:"")+a},om=function(e,t,i){var s=i?". ":"",r=i?"、":"",o=i?", ":"",n=i?" ":"";switch(t){case 0:return"•"+n;case 1:return"◦"+n;case 2:return"◾"+n;case 5:var a=im(e,48,57,!0,s);return a.length<4?"0"+a:a;case 4:return sm(e,"〇一二三四五六七八九",r);case 6:return em(e,1,3999,Yg,3,s).toLowerCase();case 7:return em(e,1,3999,Yg,3,s);case 8:return im(e,945,969,!1,s);case 9:return im(e,97,122,!1,s);case 10:return im(e,65,90,!1,s);case 11:return im(e,1632,1641,!0,s);case 12:case 49:return em(e,1,9999,Zg,3,s);case 35:return em(e,1,9999,Zg,3,s).toLowerCase();case 13:return im(e,2534,2543,!0,s);case 14:case 30:return im(e,6112,6121,!0,s);case 15:return sm(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return sm(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return rm(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return rm(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return rm(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return rm(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return rm(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return rm(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return rm(e,"영일이삼사오육칠팔구","십백천만","마이너스",o,7);case 33:return rm(e,"零一二三四五六七八九","十百千萬","마이너스",o,0);case 32:return rm(e,"零壹貳參四五六七八九","拾百千","마이너스",o,7);case 18:return im(e,2406,2415,!0,s);case 20:return em(e,1,19999,$g,3,s);case 21:return im(e,2790,2799,!0,s);case 22:return im(e,2662,2671,!0,s);case 22:return em(e,1,10999,qg,3,s);case 23:return sm(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return sm(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return im(e,3302,3311,!0,s);case 28:return sm(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return sm(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return im(e,3792,3801,!0,s);case 37:return im(e,6160,6169,!0,s);case 38:return im(e,4160,4169,!0,s);case 39:return im(e,2918,2927,!0,s);case 40:return im(e,1776,1785,!0,s);case 43:return im(e,3046,3055,!0,s);case 44:return im(e,3174,3183,!0,s);case 45:return im(e,3664,3673,!0,s);case 46:return im(e,3872,3881,!0,s);default:return im(e,48,57,!0,s)}},nm=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new Jg,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var i=this,s=lm(e,t);if(!s.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,o=e.defaultView.pageYOffset,n=s.contentWindow,a=n.document,l=cm(s).then((function(){return Pc(i,void 0,void 0,(function(){var e,i;return Cc(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(gm),n&&(n.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||n.scrollY===t.top&&n.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(n.scrollX-t.left,n.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(i=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:a.fonts&&a.fonts.ready?[4,a.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,hm(a)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(a,i)})).then((function(){return s}))]:[2,s]}}))}))}));return a.open(),a.write(pm(document.doctype)+""),fm(this.referenceElement.ownerDocument,r,o),a.replaceChild(a.adoptNode(this.documentElement),a.documentElement),a.close(),l},e.prototype.createElementClone=function(e){if(Sf(e,2),Qg(e))return this.createCanvasClone(e);if(Vg(e))return this.createVideoClone(e);if(Gg(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Hg(t)&&(Hg(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),Xg(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return dm(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),s=e.cloneNode(!1);return s.textContent=i,s}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var s=e.cloneNode(!1);try{s.width=e.width,s.height=e.height;var r=e.getContext("2d"),o=s.getContext("2d");if(o)if(!this.options.allowTaint&&r)o.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var n=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(n){var a=n.getContextAttributes();!1===(null==a?void 0:a.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}o.drawImage(e,0,0)}return s}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return s},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var s=e.ownerDocument.createElement("canvas");return s.width=e.offsetWidth,s.height=e.offsetHeight,s},e.prototype.appendChildNode=function(e,t,i){Sg(t)&&(function(e){return"SCRIPT"===e.tagName}(t)||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&Sg(t)&&Gg(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var s=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(Sg(r)&&Kg(r)&&"function"==typeof r.assignedNodes){var o=r.assignedNodes();o.length&&o.forEach((function(e){return s.appendChildNode(t,e,i)}))}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(Dg(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&Sg(e)&&(Tg(e)||Rg(e))){var s=this.createElementClone(e);s.style.transitionProperty="none";var r=i.getComputedStyle(e),o=i.getComputedStyle(e,":before"),n=i.getComputedStyle(e,":after");this.referenceElement===e&&Tg(s)&&(this.clonedReferenceElement=s),Ng(s)&&vm(s);var a=this.counters.parse(new If(this.context,r)),l=this.resolvePseudoContent(e,s,o,Hf.BEFORE);Xg(e)&&(t=!0),Vg(e)||this.cloneChildNodes(e,s,t),l&&s.insertBefore(l,s.firstChild);var A=this.resolvePseudoContent(e,s,n,Hf.AFTER);return A&&s.appendChild(A),this.counters.pop(a),(r&&(this.options.copyStyles||Rg(e))&&!jg(e)||t)&&dm(r,s),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([s,e.scrollLeft,e.scrollTop]),(zg(e)||Wg(e))&&(zg(s)||Wg(s))&&(s.value=e.value),s}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,s){var r=this;if(i){var o=i.content,n=t.ownerDocument;if(n&&o&&"none"!==o&&"-moz-alt-content"!==o&&"none"!==i.display){this.counters.parse(new If(this.context,i));var a=new Ef(this.context,i),l=n.createElement("html2canvaspseudoelement");dm(i,l),a.content.forEach((function(t){if(0===t.type)l.appendChild(n.createTextNode(t.value));else if(22===t.type){var i=n.createElement("img");i.src=t.value,i.style.opacity="1",l.appendChild(i)}else if(18===t.type){if("attr"===t.name){var s=t.values.filter(ld);s.length&&l.appendChild(n.createTextNode(e.getAttribute(s[0].value)||""))}else if("counter"===t.name){var o=t.values.filter(ud),A=o[0],h=o[1];if(A&&ld(A)){var c=r.counters.getCounterValue(A.value),u=h&&ld(h)?Up.parse(r.context,h.value):3;l.appendChild(n.createTextNode(om(c,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(ud),p=(A=d[0],d[1]);h=d[2];if(A&&ld(A)){var f=r.counters.getCounterValues(A.value),g=h&&ld(h)?Up.parse(r.context,h.value):3,m=p&&0===p.type?p.value:"",_=f.map((function(e){return om(e,g,!1)})).join(m);l.appendChild(n.createTextNode(_))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(n.createTextNode(Bf(a.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(n.createTextNode(Bf(a.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(n.createTextNode(t.value))}})),l.className=mm+" "+_m;var A=s===Hf.BEFORE?" "+mm:" "+_m;return Rg(t)?t.className.baseValue+=A:t.className+=A,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(Hf||(Hf={}));var am,lm=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(i),i},Am=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},hm=function(e){return Promise.all([].slice.call(e.images,0).map(Am))},cm=function(e){return new Promise((function(t,i){var s=e.contentWindow;if(!s)return i("No window assigned for iframe");var r=s.document;s.onload=e.onload=function(){s.onload=e.onload=null;var i=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))}),50)}}))},um=["all","d","content"],dm=function(e,t){for(var i=e.length-1;i>=0;i--){var s=e.item(i);-1===um.indexOf(s)&&t.style.setProperty(s,e.getPropertyValue(s))}return t},pm=function(e){var t="";return e&&(t+=""),t},fm=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},gm=function(e){var t=e[0],i=e[1],s=e[2];t.scrollLeft=i,t.scrollTop=s},mm="___html2canvas___pseudoelement_before",_m="___html2canvas___pseudoelement_after",vm=function(e){bm(e,"."+mm+':before{\n content: "" !important;\n display: none !important;\n}\n .'+_m+':after{\n content: "" !important;\n display: none !important;\n}')},bm=function(e,t){var i=e.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,e.appendChild(s)}},ym=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),xm=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:Em(e)||Cm(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return Pc(this,void 0,void 0,(function(){var t,i,s,r,o=this;return Cc(this,(function(n){switch(n.label){case 0:return t=ym.isSameOrigin(e),i=!Mm(e)&&!0===this._options.useCORS&&tg.SUPPORT_CORS_IMAGES&&!t,s=!Mm(e)&&!t&&!Em(e)&&"string"==typeof this._options.proxy&&tg.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||Mm(e)||Em(e)||s||i?(r=e,s?[4,this.proxy(r)]:[3,2]):[2];case 1:r=n.sent(),n.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var s=new Image;s.onload=function(){return e(s)},s.onerror=t,(Fm(r)||i)&&(s.crossOrigin="anonymous"),s.src=r,!0===s.complete&&setTimeout((function(){return e(s)}),500),o._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+o._options.imageTimeout+"ms) loading image")}),o._options.imageTimeout)}))];case 3:return[2,n.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var s=e.substring(0,256);return new Promise((function(r,o){var n=tg.SUPPORT_RESPONSE_TYPE?"blob":"text",a=new XMLHttpRequest;a.onload=function(){if(200===a.status)if("text"===n)r(a.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return o(e)}),!1),e.readAsDataURL(a.response)}else o("Failed to proxy resource "+s+" with status code "+a.status)},a.onerror=o;var l=i.indexOf("?")>-1?"&":"?";if(a.open("GET",""+i+l+"url="+encodeURIComponent(e)+"&responseType="+n),"text"!==n&&a instanceof XMLHttpRequest&&(a.responseType=n),t._options.imageTimeout){var A=t._options.imageTimeout;a.timeout=A,a.ontimeout=function(){return o("Timed out ("+A+"ms) proxying "+s)}}a.send()}))},e}(),Bm=/^data:image\/svg\+xml/i,wm=/^data:image\/.*;base64,/i,Pm=/^data:image\/.*/i,Cm=function(e){return tg.SUPPORT_SVG_DRAWING||!Im(e)},Mm=function(e){return Pm.test(e)},Fm=function(e){return wm.test(e)},Em=function(e){return"blob"===e.substr(0,4)},Im=function(e){return"svg"===e.substr(-3).toLowerCase()||Bm.test(e)},Dm=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),Sm=function(e,t,i){return new Dm(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},Tm=function(){function e(e,t,i,s){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=s}return e.prototype.subdivide=function(t,i){var s=Sm(this.start,this.startControl,t),r=Sm(this.startControl,this.endControl,t),o=Sm(this.endControl,this.end,t),n=Sm(s,r,t),a=Sm(r,o,t),l=Sm(n,a,t);return i?new e(this.start,s,n,l):new e(l,a,o,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),Rm=function(e){return 1===e.type},Lm=function(e){var t=e.styles,i=e.bounds,s=yd(t.borderTopLeftRadius,i.width,i.height),r=s[0],o=s[1],n=yd(t.borderTopRightRadius,i.width,i.height),a=n[0],l=n[1],A=yd(t.borderBottomRightRadius,i.width,i.height),h=A[0],c=A[1],u=yd(t.borderBottomLeftRadius,i.width,i.height),d=u[0],p=u[1],f=[];f.push((r+a)/i.width),f.push((d+h)/i.width),f.push((o+p)/i.height),f.push((l+c)/i.height);var g=Math.max.apply(Math,f);g>1&&(r/=g,o/=g,a/=g,l/=g,h/=g,c/=g,d/=g,p/=g);var m=i.width-a,_=i.height-c,v=i.width-h,b=i.height-p,y=t.borderTopWidth,x=t.borderRightWidth,B=t.borderBottomWidth,w=t.borderLeftWidth,P=xd(t.paddingTop,e.bounds.width),C=xd(t.paddingRight,e.bounds.width),M=xd(t.paddingBottom,e.bounds.width),F=xd(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||o>0?Um(i.left+w/3,i.top+y/3,r-w/3,o-y/3,am.TOP_LEFT):new Dm(i.left+w/3,i.top+y/3),this.topRightBorderDoubleOuterBox=r>0||o>0?Um(i.left+m,i.top+y/3,a-x/3,l-y/3,am.TOP_RIGHT):new Dm(i.left+i.width-x/3,i.top+y/3),this.bottomRightBorderDoubleOuterBox=h>0||c>0?Um(i.left+v,i.top+_,h-x/3,c-B/3,am.BOTTOM_RIGHT):new Dm(i.left+i.width-x/3,i.top+i.height-B/3),this.bottomLeftBorderDoubleOuterBox=d>0||p>0?Um(i.left+w/3,i.top+b,d-w/3,p-B/3,am.BOTTOM_LEFT):new Dm(i.left+w/3,i.top+i.height-B/3),this.topLeftBorderDoubleInnerBox=r>0||o>0?Um(i.left+2*w/3,i.top+2*y/3,r-2*w/3,o-2*y/3,am.TOP_LEFT):new Dm(i.left+2*w/3,i.top+2*y/3),this.topRightBorderDoubleInnerBox=r>0||o>0?Um(i.left+m,i.top+2*y/3,a-2*x/3,l-2*y/3,am.TOP_RIGHT):new Dm(i.left+i.width-2*x/3,i.top+2*y/3),this.bottomRightBorderDoubleInnerBox=h>0||c>0?Um(i.left+v,i.top+_,h-2*x/3,c-2*B/3,am.BOTTOM_RIGHT):new Dm(i.left+i.width-2*x/3,i.top+i.height-2*B/3),this.bottomLeftBorderDoubleInnerBox=d>0||p>0?Um(i.left+2*w/3,i.top+b,d-2*w/3,p-2*B/3,am.BOTTOM_LEFT):new Dm(i.left+2*w/3,i.top+i.height-2*B/3),this.topLeftBorderStroke=r>0||o>0?Um(i.left+w/2,i.top+y/2,r-w/2,o-y/2,am.TOP_LEFT):new Dm(i.left+w/2,i.top+y/2),this.topRightBorderStroke=r>0||o>0?Um(i.left+m,i.top+y/2,a-x/2,l-y/2,am.TOP_RIGHT):new Dm(i.left+i.width-x/2,i.top+y/2),this.bottomRightBorderStroke=h>0||c>0?Um(i.left+v,i.top+_,h-x/2,c-B/2,am.BOTTOM_RIGHT):new Dm(i.left+i.width-x/2,i.top+i.height-B/2),this.bottomLeftBorderStroke=d>0||p>0?Um(i.left+w/2,i.top+b,d-w/2,p-B/2,am.BOTTOM_LEFT):new Dm(i.left+w/2,i.top+i.height-B/2),this.topLeftBorderBox=r>0||o>0?Um(i.left,i.top,r,o,am.TOP_LEFT):new Dm(i.left,i.top),this.topRightBorderBox=a>0||l>0?Um(i.left+m,i.top,a,l,am.TOP_RIGHT):new Dm(i.left+i.width,i.top),this.bottomRightBorderBox=h>0||c>0?Um(i.left+v,i.top+_,h,c,am.BOTTOM_RIGHT):new Dm(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=d>0||p>0?Um(i.left,i.top+b,d,p,am.BOTTOM_LEFT):new Dm(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||o>0?Um(i.left+w,i.top+y,Math.max(0,r-w),Math.max(0,o-y),am.TOP_LEFT):new Dm(i.left+w,i.top+y),this.topRightPaddingBox=a>0||l>0?Um(i.left+Math.min(m,i.width-x),i.top+y,m>i.width+x?0:Math.max(0,a-x),Math.max(0,l-y),am.TOP_RIGHT):new Dm(i.left+i.width-x,i.top+y),this.bottomRightPaddingBox=h>0||c>0?Um(i.left+Math.min(v,i.width-w),i.top+Math.min(_,i.height-B),Math.max(0,h-x),Math.max(0,c-B),am.BOTTOM_RIGHT):new Dm(i.left+i.width-x,i.top+i.height-B),this.bottomLeftPaddingBox=d>0||p>0?Um(i.left+w,i.top+Math.min(b,i.height-B),Math.max(0,d-w),Math.max(0,p-B),am.BOTTOM_LEFT):new Dm(i.left+w,i.top+i.height-B),this.topLeftContentBox=r>0||o>0?Um(i.left+w+F,i.top+y+P,Math.max(0,r-(w+F)),Math.max(0,o-(y+P)),am.TOP_LEFT):new Dm(i.left+w+F,i.top+y+P),this.topRightContentBox=a>0||l>0?Um(i.left+Math.min(m,i.width+w+F),i.top+y+P,m>i.width+w+F?0:a-w+F,l-(y+P),am.TOP_RIGHT):new Dm(i.left+i.width-(x+C),i.top+y+P),this.bottomRightContentBox=h>0||c>0?Um(i.left+Math.min(v,i.width-(w+F)),i.top+Math.min(_,i.height+y+P),Math.max(0,h-(x+C)),c-(B+M),am.BOTTOM_RIGHT):new Dm(i.left+i.width-(x+C),i.top+i.height-(B+M)),this.bottomLeftContentBox=d>0||p>0?Um(i.left+w+F,i.top+b,Math.max(0,d-(w+F)),p-(B+M),am.BOTTOM_LEFT):new Dm(i.left+w+F,i.top+i.height-(B+M))};!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(am||(am={}));var Um=function(e,t,i,s,r){var o=(Math.sqrt(2)-1)/3*4,n=i*o,a=s*o,l=e+i,A=t+s;switch(r){case am.TOP_LEFT:return new Tm(new Dm(e,A),new Dm(e,A-a),new Dm(l-n,t),new Dm(l,t));case am.TOP_RIGHT:return new Tm(new Dm(e,t),new Dm(e+n,t),new Dm(l,A-a),new Dm(l,A));case am.BOTTOM_RIGHT:return new Tm(new Dm(l,t),new Dm(l,t+a),new Dm(e+n,A),new Dm(e,A));case am.BOTTOM_LEFT:default:return new Tm(new Dm(l,A),new Dm(l-n,A),new Dm(e,t+a),new Dm(e,t))}},km=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Om=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},Nm=function(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6},Qm=function(e,t){this.path=e,this.target=t,this.type=1},Vm=function(e){this.opacity=e,this.type=2,this.target=6},Hm=function(e){return 1===e.type},jm=function(e,t){return e.length===t.length&&e.some((function(e,i){return e===t[i]}))},Gm=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},zm=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Lm(this.container),this.container.styles.opacity<1&&this.effects.push(new Vm(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,s=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new Nm(i,s,r))}if(0!==this.container.styles.overflowX){var o=km(this.curves),n=Om(this.curves);jm(o,n)?this.effects.push(new Qm(o,6)):(this.effects.push(new Qm(o,2)),this.effects.push(new Qm(n,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,s=this.effects.slice(0);i;){var r=i.effects.filter((function(e){return!Hm(e)}));if(t||0!==i.container.styles.position||!i.parent){if(s.unshift.apply(s,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var o=km(i.curves),n=Om(i.curves);jm(o,n)||s.unshift(new Qm(n,6))}}else s.unshift.apply(s,r);i=i.parent}return s.filter((function(t){return mf(t.target,e)}))},e}(),Wm=function(e,t,i,s){e.container.elements.forEach((function(r){var o=mf(r.flags,4),n=mf(r.flags,2),a=new zm(r,e);mf(r.styles.display,2048)&&s.push(a);var l=mf(r.flags,8)?[]:s;if(o||n){var A=o||r.styles.isPositioned()?i:t,h=new Gm(a);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var c=r.styles.zIndex.order;if(c<0){var u=0;A.negativeZIndex.some((function(e,t){return c>e.element.container.styles.zIndex.order?(u=t,!1):u>0})),A.negativeZIndex.splice(u,0,h)}else if(c>0){var d=0;A.positiveZIndex.some((function(e,t){return c>=e.element.container.styles.zIndex.order?(d=t+1,!1):d>0})),A.positiveZIndex.splice(d,0,h)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(h)}else r.styles.isFloating()?A.nonPositionedFloats.push(h):A.nonPositionedInlineLevel.push(h);Wm(a,h,o?h:i,l)}else r.styles.isInlineLevel()?t.inlineLevel.push(a):t.nonInlineLevel.push(a),Wm(a,t,i,l);mf(r.flags,8)&&Km(r,l)}))},Km=function(e,t){for(var i=e instanceof mg?e.start:1,s=e instanceof mg&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var s=qm(e),r=Om(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return Pc(this,void 0,void 0,(function(){var i,s,r,o,n,a,l,A,h,c,u,d,p,f,g,m,_,v;return Cc(this,(function(b){switch(b.label){case 0:this.applyEffects(e.getEffects(4)),i=e.container,s=e.curves,r=i.styles,o=0,n=i.textNodes,b.label=1;case 1:return o0&&B>0&&(m=s.ctx.createPattern(p,"repeat"),s.renderRepeat(v,m,P,C))):function(e){return 2===e.type}(i)&&(_=$m(e,t,[null,null,null]),v=_[0],b=_[1],y=_[2],x=_[3],B=_[4],w=0===i.position.length?[vd]:i.position,P=xd(w[0],x),C=xd(w[w.length-1],B),M=function(e,t,i,s,r){var o=0,n=0;switch(e.size){case 0:0===e.shape?o=n=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.min(Math.abs(t),Math.abs(t-s)),n=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)o=n=Math.min(jd(t,i),jd(t,i-r),jd(t-s,i),jd(t-s,i-r));else if(1===e.shape){var a=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-s)),l=Gd(s,r,t,i,!0),A=l[0],h=l[1];n=a*(o=jd(A-t,(h-i)/a))}break;case 1:0===e.shape?o=n=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.max(Math.abs(t),Math.abs(t-s)),n=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)o=n=Math.max(jd(t,i),jd(t,i-r),jd(t-s,i),jd(t-s,i-r));else if(1===e.shape){a=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-s));var c=Gd(s,r,t,i,!1);A=c[0],h=c[1],n=a*(o=jd(A-t,(h-i)/a))}}return Array.isArray(e.size)&&(o=xd(e.size[0],s),n=2===e.size.length?xd(e.size[1],r):o),[o,n]}(i,P,C,x,B),F=M[0],E=M[1],F>0&&E>0&&(I=s.ctx.createRadialGradient(b+P,y+C,0,b+P,y+C,F),Vd(i.stops,2*F).forEach((function(e){return I.addColorStop(e.stop,Ed(e.color))})),s.path(v),s.ctx.fillStyle=I,F!==E?(D=e.bounds.left+.5*e.bounds.width,S=e.bounds.top+.5*e.bounds.height,R=1/(T=E/F),s.ctx.save(),s.ctx.translate(D,S),s.ctx.transform(1,0,0,T,0,0),s.ctx.translate(-D,-S),s.ctx.fillRect(b,R*(y-S)+S,x,B*R),s.ctx.restore()):s.ctx.fill())),L.label=6;case 6:return t--,[2]}}))},s=this,r=0,o=e.styles.backgroundImage.slice(0).reverse(),a.label=1;case 1:return r0?2!==l.style?[3,5]:[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,2)]:[3,11]:[3,13];case 4:return h.sent(),[3,11];case 5:return 3!==l.style?[3,7]:[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,3)];case 6:return h.sent(),[3,11];case 7:return 4!==l.style?[3,9]:[4,this.renderDoubleBorder(l.color,l.width,o,e.curves)];case 8:return h.sent(),[3,11];case 9:return[4,this.renderSolidBorder(l.color,o,e.curves)];case 10:h.sent(),h.label=11;case 11:o++,h.label=12;case 12:return n++,[3,3];case 13:return[2]}}))}))},t.prototype.renderDashedDottedBorder=function(e,t,i,s,r){return Pc(this,void 0,void 0,(function(){var o,n,a,l,A,h,c,u,d,p,f,g,m,_,v,b;return Cc(this,(function(y){return this.ctx.save(),o=function(e,t){switch(t){case 0:return Jm(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Jm(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Jm(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return Jm(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(s,i),n=Xm(s,i),2===r&&(this.path(n),this.ctx.clip()),Rm(n[0])?(a=n[0].start.x,l=n[0].start.y):(a=n[0].x,l=n[0].y),Rm(n[1])?(A=n[1].end.x,h=n[1].end.y):(A=n[1].x,h=n[1].y),c=0===i||2===i?Math.abs(a-A):Math.abs(l-h),this.ctx.beginPath(),3===r?this.formatPath(o):this.formatPath(n.slice(0,2)),u=t<3?3*t:2*t,d=t<3?2*t:t,3===r&&(u=t,d=t),p=!0,c<=2*u?p=!1:c<=2*u+d?(u*=f=c/(2*u+d),d*=f):(g=Math.floor((c+d)/(u+d)),m=(c-g*u)/(g-1),d=(_=(c-(g+1)*u)/g)<=0||Math.abs(d-m){})),I_(this,"_reject",(()=>{})),this.name=e,this.workerThread=t,this.result=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){B_(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){B_(this.isRunning),this.isRunning=!1,this._reject(e)}}class S_{}const T_=new Map;function R_(e){B_(e.source&&!e.url||!e.source&&e.url);let t=T_.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return L_((t=e,"try {\n importScripts('".concat(t,"');\n} catch (error) {\n console.error(error);\n throw error;\n}")));var t}(e.url),T_.set(e.url,t)),e.source&&(t=L_(e.source),T_.set(e.source,t))),B_(t),t}function L_(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function U_(e,t=!0,i){const s=i||new Set;if(e){if(k_(e))s.add(e);else if(k_(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)U_(e[i],t,s)}else;return void 0===i?Array.from(s):[]}function k_(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const O_=()=>{};class N_{static isSupported(){return"undefined"!=typeof Worker&&C_||void 0!==typeof S_}constructor(e){I_(this,"name",void 0),I_(this,"source",void 0),I_(this,"url",void 0),I_(this,"terminated",!1),I_(this,"worker",void 0),I_(this,"onMessage",void 0),I_(this,"onError",void 0),I_(this,"_loadableURL","");const{name:t,source:i,url:s}=e;B_(i||s),this.name=t,this.source=i,this.url=s,this.onMessage=O_,this.onError=e=>console.log(e),this.worker=C_?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=O_,this.onError=O_,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||U_(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+="worker ".concat(this.name," from ").concat(this.url,". "),e.message&&(t+="".concat(e.message," in ")),e.lineno&&(t+=":".concat(e.lineno,":").concat(e.colno)),new Error(t)}_createBrowserWorker(){this._loadableURL=R_({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);e=new S_(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new S_(this.source,{eval:!0})}return e.on("message",(e=>{this.onMessage(e)})),e.on("error",(e=>{this.onError(e)})),e.on("exit",(e=>{})),e}}class Q_{static isSupported(){return N_.isSupported()}constructor(e){I_(this,"name","unnamed"),I_(this,"source",void 0),I_(this,"url",void 0),I_(this,"maxConcurrency",1),I_(this,"maxMobileConcurrency",1),I_(this,"onDebug",(()=>{})),I_(this,"reuseWorkers",!0),I_(this,"props",{}),I_(this,"jobQueue",[]),I_(this,"idleQueue",[]),I_(this,"count",0),I_(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach((e=>e.destroy())),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=((e,t,i)=>e.done(i)),i=((e,t)=>e.error(t))){const s=new Promise((s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this)));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new D_(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class H_{static isSupported(){return N_.isSupported()}static getWorkerFarm(e={}){return H_._workerFarm=H_._workerFarm||new H_({}),H_._workerFarm.setProps(e),H_._workerFarm}constructor(e){I_(this,"props",void 0),I_(this,"workerPools",new Map),this.props={...V_},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:s}=e;let r=this.workerPools.get(t);return r||(r=new Q_({name:t,source:i,url:s}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}I_(H_,"_workerFarm",void 0);var j_=Object.freeze({__proto__:null,default:{}});const G_={};async function z_(e,t=null,i={}){return t&&(e=function(e,t,i){if(e.startsWith("http"))return e;const s=i.modules||{};if(s[e])return s[e];if(!C_)return"modules/".concat(t,"/dist/libs/").concat(e);if(i.CDN)return B_(i.CDN.startsWith("http")),"".concat(i.CDN,"/").concat(t,"@").concat("3.2.6","/dist/libs/").concat(e);if(M_)return"../src/libs/".concat(e);return"modules/".concat(t,"/src/libs/").concat(e)}(e,t,i)),G_[e]=G_[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!C_)try{return j_&&void 0}catch{return null}if(M_)return importScripts(e);const t=await fetch(e);return function(e,t){if(!C_)return;if(M_)return eval.call(P_,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(await t.text(),e)}(e),await G_[e]}async function W_(e,t,i,s,r){const o=e.id,n=function(e,t={}){const i=t[e.id]||{},s="".concat(e.id,"-worker.js");let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r="modules/".concat(e.module,"/dist/").concat(s)),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?"@".concat(t):"";r="https://unpkg.com/@loaders.gl/".concat(e.module).concat(i,"/dist/").concat(s)}return B_(r),r}(e,i),a=H_.getWorkerFarm(i).getWorkerPool({name:o,url:n});i=JSON.parse(JSON.stringify(i)),s=JSON.parse(JSON.stringify(s||{}));const l=await a.startJob("process-on-worker",K_.bind(null,r));l.postMessage("process",{input:t,options:i,context:s});const A=await l.result;return await A.result}async function K_(e,t,i,s){switch(i){case"done":t.done(s);break;case"error":t.error(new Error(s.error));break;case"process":const{id:r,input:o,options:n}=s;try{const i=await e(o,n);t.postMessage("done",{id:r,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:i})}break;default:console.warn("parse-with-worker unknown message ".concat(i))}}function X_(e,t,i){if(e.byteLength<=t+i)return"";const s=new DataView(e);let r="";for(let e=0;e=0),b_(t>0),e+(t-1)&~(t-1)}function ev(e,t,i){let s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;s=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(s,i),i+$_(s.byteLength,4)}async function tv(e){const t=[];for await(const i of e)t.push(i);return function(...e){const t=e.map((e=>e instanceof ArrayBuffer?new Uint8Array(e):e)),i=t.reduce(((e,t)=>e+t.byteLength),0),s=new Uint8Array(i);let r=0;for(const e of t)s.set(e,r),r+=e.byteLength;return s.buffer}(...t)}const iv={};const sv=e=>"function"==typeof e,rv=e=>null!==e&&"object"==typeof e,ov=e=>rv(e)&&e.constructor==={}.constructor,nv=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,av=e=>"undefined"!=typeof Blob&&e instanceof Blob,lv=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||rv(e)&&sv(e.tee)&&sv(e.cancel)&&sv(e.getReader))(e)||(e=>rv(e)&&sv(e.read)&&sv(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e),Av=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,hv=/^([-\w.]+\/[-\w.+]+)/;function cv(e){const t=hv.exec(e);return t?t[1]:e}function uv(e){const t=Av.exec(e);return t?t[1]:""}const dv=/\?.*/;function pv(e){if(nv(e)){const t=fv(e.url||"");return{url:t,type:cv(e.headers.get("content-type")||"")||uv(t)}}return av(e)?{url:fv(e.name||""),type:e.type||""}:"string"==typeof e?{url:fv(e),type:uv(e)}:{url:"",type:""}}function fv(e){return e.replace(dv,"")}async function gv(e){if(nv(e))return e;const t={},i=function(e){return nv(e)?e.headers["content-length"]||-1:av(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const{url:s,type:r}=pv(e);r&&(t["content-type"]=r);const o=await async function(e){const t=5;if("string"==typeof e)return"data:,".concat(e.slice(0,t));if(e instanceof Blob){const t=e.slice(0,5);return await new Promise((e=>{const i=new FileReader;i.onload=t=>{var i;return e(null==t||null===(i=t.target)||void 0===i?void 0:i.result)},i.readAsDataURL(t)}))}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e=0)}();class Bv{constructor(e,t,i="sessionStorage"){this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function wv(e,t,i,s=600){const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));const o=e.width*i,n=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(n/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(n,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(n,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}const Pv={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function Cv(e){return"string"==typeof e?Pv[e.toUpperCase()]||Pv.WHITE:e}function Mv(e,t){if(!e)throw new Error(t||"Assertion failed")}function Fv(){let e;if(xv&&vv.performance)e=vv.performance.now();else if(bv.hrtime){const t=bv.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const Ev={debug:xv&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Iv={enabled:!0,level:0};function Dv(){}const Sv={},Tv={once:!0};function Rv(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}class Lv{constructor({id:e}={id:""}){this.id=e,this.VERSION=yv,this._startTs=Fv(),this._deltaTs=Fv(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new Bv("__probe-".concat(this.id,"__"),Iv),this.userData={},this.timeStamp("".concat(this.id," started")),function(e,t=["constructor"]){const i=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(i);for(const i of s)"function"==typeof e[i]&&(t.find((e=>i===e))||(e[i]=e[i].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Fv()-this._startTs).toPrecision(10))}getDelta(){return Number((Fv()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}assert(e,t){Mv(e,t)}warn(e){return this._getLogFunction(0,e,Ev.warn,arguments,Tv)}error(e){return this._getLogFunction(0,e,Ev.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,Ev.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Ev.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Ev.debug||Ev.info,arguments,Tv)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||Dv,i&&[i],{tag:Rv(t)}):Dv}image({logLevel:e,priority:t,image:i,message:s="",scale:r=1}){return this._shouldLog(e||t)?xv?function({image:e,message:t="",scale:i=1}){if("string"==typeof e){const s=new Image;return s.onload=()=>{const e=wv(s,t,i);console.log(...e)},s.src=e,Dv}const s=e.nodeName||"";if("img"===s.toLowerCase())return console.log(...wv(e,t,i)),Dv;if("canvas"===s.toLowerCase()){const s=new Image;return s.onload=()=>console.log(...wv(s,t,i)),s.src=e.toDataURL(),Dv}return Dv}({image:i,message:s,scale:r}):function({image:e,message:t="",scale:i=1}){let s=null;try{s=module.require("asciify-image")}catch(e){}if(s)return()=>s(e,{fit:"box",width:"".concat(Math.round(80*i),"%")}).then((e=>console.log(e)));return Dv}({image:i,message:s,scale:r}):Dv}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Dv)}group(e,t,i={collapsed:!1}){i=kv({logLevel:e,message:t,opts:i});const{collapsed:s}=i;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Dv)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Uv(e)}_getLogFunction(e,t,i,s=[],r){if(this._shouldLog(e)){r=kv({logLevel:e,message:t,args:s,opts:r}),Mv(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Fv();const o=r.tag||r.message;if(r.once){if(Sv[o])return Dv;Sv[o]=Fv()}return t=function(e,t,i){if("string"==typeof t){const s=i.time?function(e,t=8){const i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),t=function(e,t,i){return xv||"string"!=typeof e||(t&&(t=Cv(t),e="[".concat(t,"m").concat(e,"")),i&&(t=Cv(i),e="[".concat(i+10,"m").concat(e,""))),e}(t,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return Dv}}function Uv(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Mv(Number.isFinite(t)&&t>=0),t}function kv(e){const{logLevel:t,message:i}=e;e.logLevel=Uv(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==i;);switch(e.args=s,typeof t){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return Mv("string"===r||"object"===r),Object.assign(e,e.opts)}Lv.VERSION=yv;const Ov=new Lv({id:"loaders.gl"});class Nv{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const Qv={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){I_(this,"console",void 0),this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:y_,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Vv={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function Hv(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state=e._state||{},e._state}const jv=()=>{const e=Hv();return e.globalOptions=e.globalOptions||{...Qv},e.globalOptions};function Gv(e,t,i,s){return i=i||[],function(e,t){Wv(e,null,Qv,Vv,t);for(const i of t){const s=e&&e[i.id]||{},r=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};Wv(s,i.id,r,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const s={...e.options||{}};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(s,i),null===s.log&&(s.log=new Nv);return Xv(s,jv()),Xv(s,t),s}(t,e,s)}function zv(e,t){const i=jv(),s=e||i;return"function"==typeof s.fetch?s.fetch:rv(s.fetch)?e=>mv(e,s):null!=t&&t.fetch?null==t?void 0:t.fetch:mv}function Wv(e,t,i,s,r){const o=t||"Top level",n=t?"".concat(t,"."):"";for(const a in e){const l=!t&&rv(e[a]),A="baseUri"===a&&!t,h="workerUrl"===a&&t;if(!(a in i)&&!A&&!h)if(a in s)Ov.warn("".concat(o," loader option '").concat(n).concat(a,"' no longer supported, use '").concat(s[a],"'"))();else if(!l){const e=Kv(a,r);Ov.warn("".concat(o," loader option '").concat(n).concat(a,"' not recognized. ").concat(e))()}}}function Kv(e,t){const i=e.toLowerCase();let s="";for(const r of t)for(const t in r.options){if(e===t)return"Did you mean '".concat(r.id,".").concat(t,"'?");const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(s=s||"Did you mean '".concat(r.id,".").concat(t,"'?"))}return s}function Xv(e,t){for(const i in t)if(i in t){const s=t[i];ov(s)&&ov(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function Jv(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function Yv(e){var t,i;let s;return b_(e,"null loader"),b_(Jv(e),"invalid loader"),Array.isArray(e)&&(s=e[1],e=e[0],e={...e,options:{...e.options,...s}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(i=e)&&void 0!==i&&i.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}function Zv(){return(()=>{const e=Hv();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry})()}function qv(){return!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||function(e){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof process&&"object"==typeof process.versions&&Boolean(process.versions.electron))return!0;const t="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,i=e||t;return!!(i&&i.indexOf("Electron")>=0)}()}const $v={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"==typeof process&&process},eb=$v.window||$v.self||$v.global,tb=$v.process||{},ib="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";qv();class sb{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";I_(this,"storage",void 0),I_(this,"id",void 0),I_(this,"config",{}),this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function rb(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));const o=e.width*i,n=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(n/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(n,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(n,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}let ob;function nb(e){return"string"==typeof e?ob[e.toUpperCase()]||ob.WHITE:e}function ab(e,t){if(!e)throw new Error(t||"Assertion failed")}function lb(){let e;var t,i;if(qv&&"performance"in eb)e=null==eb||null===(t=eb.performance)||void 0===t||null===(i=t.now)||void 0===i?void 0:i.call(t);else if("hrtime"in tb){var s;const t=null==tb||null===(s=tb.hrtime)||void 0===s?void 0:s.call(tb);e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(ob||(ob={}));const Ab={debug:qv&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},hb={enabled:!0,level:0};function cb(){}const ub={},db={once:!0};class pb{constructor(){let{id:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};I_(this,"id",void 0),I_(this,"VERSION",ib),I_(this,"_startTs",lb()),I_(this,"_deltaTs",lb()),I_(this,"_storage",void 0),I_(this,"userData",{}),I_(this,"LOG_THROTTLE_TIMEOUT",0),this.id=e,this._storage=new sb("__probe-".concat(this.id,"__"),hb),this.userData={},this.timeStamp("".concat(this.id," started")),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const i=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(i);for(const i of s)"function"==typeof e[i]&&(t.find((e=>i===e))||(e[i]=e[i].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((lb()-this._startTs).toPrecision(10))}getDelta(){return Number((lb()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){ab(e,t)}warn(e){return this._getLogFunction(0,e,Ab.warn,arguments,db)}error(e){return this._getLogFunction(0,e,Ab.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,Ab.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Ab.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){for(var i=arguments.length,s=new Array(i>2?i-2:0),r=2;r{const t=rb(e,i,s);console.log(...t)},e.src=t,cb}const r=t.nodeName||"";if("img"===r.toLowerCase())return console.log(...rb(t,i,s)),cb;if("canvas"===r.toLowerCase()){const e=new Image;return e.onload=()=>console.log(...rb(e,i,s)),e.src=t.toDataURL(),cb}return cb}({image:s,message:r,scale:o}):function(e){let{image:t,message:i="",scale:s=1}=e,r=null;try{r=module.require("asciify-image")}catch(e){}if(r)return()=>r(t,{fit:"box",width:"".concat(Math.round(80*s),"%")}).then((e=>console.log(e)));return cb}({image:s,message:r,scale:o}):cb}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||cb)}group(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const s=gb({logLevel:e,message:t,opts:i}),{collapsed:r}=i;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||cb)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=fb(e)}_getLogFunction(e,t,i,s,r){if(this._shouldLog(e)){r=gb({logLevel:e,message:t,args:s,opts:r}),ab(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=lb();const o=r.tag||r.message;if(r.once){if(ub[o])return cb;ub[o]=lb()}return t=function(e,t,i){if("string"==typeof t){const s=i.time?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),t=function(e,t,i){return qv||"string"!=typeof e||(t&&(t=nb(t),e="[".concat(t,"m").concat(e,"")),i&&(t=nb(i),e="[".concat(i+10,"m").concat(e,""))),e}(t,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return cb}}function fb(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return ab(Number.isFinite(t)&&t>=0),t}function gb(e){const{logLevel:t,message:i}=e;e.logLevel=fb(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return ab("string"===r||"object"===r),Object.assign(e,{args:s},e.opts)}function mb(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}I_(pb,"VERSION",ib);const _b=new pb({id:"loaders.gl"}),vb=/\.([^.]+)$/;function bb(e,t=[],i,s){if(!yb(e))return null;if(t&&!Array.isArray(t))return Yv(t);let r=[];t&&(r=r.concat(t)),null!=i&&i.ignoreRegisteredLoaders||r.push(...Zv()),function(e){for(const t of e)Yv(t)}(r);const o=function(e,t,i,s){const{url:r,type:o}=pv(e),n=r||(null==s?void 0:s.url);let a=null,l="";null!=i&&i.mimeType&&(a=Bb(t,null==i?void 0:i.mimeType),l="match forced by supplied MIME type ".concat(null==i?void 0:i.mimeType));var A;a=a||function(e,t){const i=t&&vb.exec(t),s=i&&i[1];return s?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,s):null}(t,n),l=l||(a?"matched url ".concat(n):""),a=a||Bb(t,o),l=l||(a?"matched MIME type ".concat(o):""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(wb(t,i))return i}else if(ArrayBuffer.isView(t)){if(Pb(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(Pb(t,0,i))return i}return null}(t,e),l=l||(a?"matched initial data ".concat(Cb(e)):""),a=a||Bb(t,null==i?void 0:i.fallbackMimeType),l=l||(a?"matched fallback MIME type ".concat(o):""),l&&_b.log(1,"selectLoader selected ".concat(null===(A=a)||void 0===A?void 0:A.name,": ").concat(l,"."));return a}(e,r,i,s);if(!(o||null!=i&&i.nothrow))throw new Error(xb(e));return o}function yb(e){return!(e instanceof Response&&204===e.status)}function xb(e){const{url:t,type:i}=pv(e);let s="No valid loader found (";s+=t?"".concat(function(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(t+1):""}(t),", "):"no url provided, ",s+="MIME type: ".concat(i?'"'.concat(i,'"'):"not provided",", ");const r=e?Cb(e):"";return s+=r?' first bytes: "'.concat(r,'"'):"first bytes: not available",s+=")",s}function Bb(e,t){for(const i of e){if(i.mimeTypes&&i.mimeTypes.includes(t))return i;if(t==="application/x.".concat(i.id))return i}return null}function wb(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some((t=>e.startsWith(t)))}function Pb(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some((s=>function(e,t,i,s){if(s instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLength60?"".concat(t.slice(0,60),"..."):t}catch(e){}return t}(e);throw new Error(t)}}(i),t.binary?await i.arrayBuffer():await i.text()}if(lv(e)&&(e=Ib(e,i)),(r=e)&&"function"==typeof r[Symbol.iterator]||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return tv(e);var r;throw new Error(Db)}async function Tb(e,t,i,s){B_(!s||"object"==typeof s),!t||Array.isArray(t)||Jv(t)||(s=void 0,i=t,t=void 0),e=await e,i=i||{};const{url:r}=pv(e),o=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:null}(t,s),n=await async function(e,t=[],i,s){if(!yb(e))return null;let r=bb(e,t,{...i,nothrow:!0},s);if(r)return r;if(av(e)&&(r=bb(e=await e.slice(0,10).arrayBuffer(),t,i,s)),!(r||null!=i&&i.nothrow))throw new Error(xb(e));return r}(e,o,i);return n?(s=function(e,t,i=null){if(i)return i;const s={fetch:zv(t,e),...e};return Array.isArray(s.loaders)||(s.loaders=null),s}({url:r,parse:Tb,loaders:o},i=Gv(i,n,o,r),s),await async function(e,t,i,s){if(function(e,t="3.2.6"){B_(e,"no worker provided");const i=e.version}(e),nv(t)){const e=t,{ok:i,redirected:r,status:o,statusText:n,type:a,url:l}=e,A=Object.fromEntries(e.headers.entries());s.response={headers:A,ok:i,redirected:r,status:o,statusText:n,type:a,url:l}}if(t=await Sb(t,e,i),e.parseTextSync&&"string"==typeof t)return i.dataType="text",e.parseTextSync(t,i,s,e);if(function(e,t){return!!H_.isSupported()&&!!(C_||null!=t&&t._nodeWorkers)&&e.worker&&(null==t?void 0:t.worker)}(e,i))return await W_(e,t,i,s,Tb);if(e.parseText&&"string"==typeof t)return await e.parseText(t,i,s,e);if(e.parse)return await e.parse(t,i,s,e);throw B_(!e.parseSync),new Error("".concat(e.id," loader - no parser found and worker is disabled"))}(n,e,i,s)):null}const Rb="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.wasm"),Lb="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.js");let Ub,kb;async function Ob(e){const t=e.modules||{};return t.basis?t.basis:(Ub=Ub||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await z_("basis_transcoder.js","textures",e),await z_("basis_transcoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e(i).then((e=>{const{BasisFile:i,initializeBasis:s}=e;s(),t({BasisFile:i})}))}))}(t,i)}(e),await Ub)}async function Nb(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(kb=kb||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await z_(Lb,"textures",e),await z_(Rb,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e(i).then((e=>{const{BasisFile:i,KTX2File:s,initializeBasis:r,BasisEncoder:o}=e;r(),t({BasisFile:i,KTX2File:s,BasisEncoder:o})}))}))}(t,i)}(e),await kb)}const Qb=33776,Vb=33779,Hb=35840,jb=35842,Gb=36196,zb=37808,Wb=["","WEBKIT_","MOZ_"],Kb={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let Xb=null;function Jb(e){if(!Xb){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Xb=new Set;for(const t of Wb)for(const i in Kb)if(e&&e.getExtension("".concat(t).concat(i))){const e=Kb[i];Xb.add(e)}}return Xb}var Yb,Zb,qb,$b,ey,ty,iy,sy,ry;(ry=Yb||(Yb={}))[ry.NONE=0]="NONE",ry[ry.BASISLZ=1]="BASISLZ",ry[ry.ZSTD=2]="ZSTD",ry[ry.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(Zb||(Zb={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(qb||(qb={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}($b||($b={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(ey||(ey={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(ty||(ty={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(iy||(iy={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(sy||(sy={}));const oy=[171,75,84,88,32,50,48,187,13,10,26,10];const ny={etc1:{basisFormat:0,compressed:!0,format:Gb},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:Qb},bc3:{basisFormat:3,compressed:!0,format:Vb},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:Hb},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:jb},"astc-4x4":{basisFormat:10,compressed:!0,format:zb},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function ay(e,t,i){const s=new e(new Uint8Array(t));try{if(!s.startTranscoding())throw new Error("Failed to start basis transcoding");const e=s.getNumImages(),t=[];for(let r=0;r{try{i.onload=()=>t(i),i.onerror=t=>s(new Error("Could not load image ".concat(e,": ").concat(t)))}catch(e){s(e)}}))}(o||s,t)}finally{o&&r.revokeObjectURL(o)}}const Py={};let Cy=!0;async function My(e,t,i){let s;if(xy(i)){s=await wy(e,t,i)}else s=By(e,i);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||Py)return!1;return!0}(t)&&Cy||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Cy=!1}return await createImageBitmap(e)}(s,r)}function Fy(e){const t=Ey(e);return function(e){const t=Ey(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,false)))return null;return{mimeType:"image/png",width:t.getUint32(16,false),height:t.getUint32(20,false)}}(t)||function(e){const t=Ey(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,false)&&255===t.getUint8(2)))return null;const{tableMarkers:i,sofMarkers:s}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r+9=10&&1195984440===t.getUint32(0,false)))return null;return{mimeType:"image/gif",width:t.getUint16(6,true),height:t.getUint16(8,true)}}(t)||function(e){const t=Ey(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,false)&&t.getUint32(2,true)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,true),height:t.getUint32(22,true)}}(t)}function Ey(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const Iy={id:"image",module:"images",name:"Images",version:"3.2.6",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,i){const s=((t=t||{}).image||{}).type||"auto",{url:r}=i||{};let o;switch(function(e){switch(e){case"auto":case"data":return function(){if(gy)return"imagebitmap";if(fy)return"image";if(_y)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return gy||fy||_y;case"imagebitmap":return gy;case"image":return fy;case"data":return _y;default:throw new Error("@loaders.gl/images: image ".concat(e," not supported in this environment"))}}(e),e}}(s)){case"imagebitmap":o=await My(e,t,r);break;case"image":o=await wy(e,t,r);break;case"data":o=await async function(e,t){const{mimeType:i}=Fy(e)||{},s=globalThis._parseImageNode;return b_(s),await s(e,i)}(e);break;default:b_(!1)}return"data"===s&&(o=function(e){switch(vy(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}(o)),o},tests:[e=>Boolean(Fy(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Dy=["image/png","image/jpeg","image/gif"],Sy={};function Ty(e){return void 0===Sy[e]&&(Sy[e]=function(e){switch(e){case"image/webp":return function(){if(!y_)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch{return!1}}();case"image/svg":return y_;default:if(!y_){const{_parseImageNode:t}=globalThis;return Boolean(t)&&Dy.includes(e)}return!0}}(e)),Sy[e]}function Ry(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function Ly(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error("'baseUri' must be provided to resolve relative url ".concat(e));return i.substr(0,i.lastIndexOf("/")+1)+e}const Uy=["SCALAR","VEC2","VEC3","VEC4"],ky=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Oy=new Map(ky),Ny={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Qy={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Vy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Hy(e){return Uy[e-1]||Uy[0]}function jy(e){const t=Oy.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Gy(e,t){const i=Vy[e.componentType],s=Ny[e.type],r=Qy[e.componentType],o=e.count*s,n=e.count*s*r;return Ry(n>=0&&n<=t.byteLength),{ArrayType:i,length:o,byteLength:n}}const zy={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class Wy{constructor(e){I_(this,"gltf",void 0),I_(this,"sourceBuffers",void 0),I_(this,"byteLength",void 0),this.gltf=e||{json:{...zy},buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find((t=>t===e)),i=this.json.extensions||{};return t?i[e]||!0:null}getRequiredExtension(e){const t=this.getRequiredExtensions().find((t=>t===e));return t?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error("glTF file error: Could not find ".concat(e,"[").concat(t,"]"));return i}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];Ry(i);const s=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,{ArrayType:s,length:r}=Gy(e,t);return new s(i,t.byteOffset+e.byteOffset,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(i,s,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,i){return e.extensions=e.extensions||{},e.extensions[t]=i,this.registerUsedExtension(t),this}setObjectExtension(e,t,i){(e.extensions||{})[t]=i}removeObjectExtension(e,t){const i=e.extensions||{},s=i[t];return delete i[t],s}addExtension(e,t={}){return Ry(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return Ry(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((t=>t===e))||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((t=>t===e))||this.json.extensionsRequired.push(e)}removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const s={mesh:t};return i&&(s.matrix=i),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:s,mode:r=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(i){const e=this._addIndices(i);o.primitives[0].indices=e}return Number.isFinite(s)&&(o.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=Fy(e),s=t||(null==i?void 0:i.mimeType),r={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e){const t=e.byteLength;Ry(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const i={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=$_(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:Hy(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const i=this.addBufferView(e);let s={min:t.min,max:t.max};s.min&&s.max||(s=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:jy(e),count:Math.round(e.length/t.size),min:s.min,max:s.max};return this.addAccessor(i,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const i=this.byteLength,s=new ArrayBuffer(i),r=new Uint8Array(s);let o=0;for(const e of this.sourceBuffers||[])o=ev(e,r,o);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=i:this.json.buffers=[{byteLength:i}],this.gltf.binary=s,this.sourceBuffers=[s]}_removeStringFromArray(e,t){let i=!0;for(;i;){const s=e.indexOf(t);s>-1?e.splice(s,1):i=!1}}_addAttributes(e={}){const t={};for(const i in e){const s=e[i],r=this._getGltfAttributeName(i),o=this.addBinaryBuffer(s.value,s);t[r]=o}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const i={min:null,max:null};if(e.length96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let i=0;for(let s=0;st[e.name]));return new nx(i,this.metadata)}selectAt(...e){const t=e.map((e=>this.fields[e])).filter(Boolean);return new nx(t,this.metadata)}assign(e){let t,i=this.metadata;if(e instanceof nx){const s=e;t=s.fields,i=ax(ax(new Map,this.metadata),s.metadata)}else t=e;const s=Object.create(null);for(const e of this.fields)s[e.name]=e;for(const e of t)s[e.name]=e;const r=Object.values(s);return new nx(r,i)}}function ax(e,t){return new Map([...e||new Map,...t||new Map])}class lx{constructor(e,t,i=!1,s=new Map){I_(this,"name",void 0),I_(this,"type",void 0),I_(this,"nullable",void 0),I_(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=i,this.metadata=s}get typeId(){return this.type&&this.type.typeId}clone(){return new lx(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}let Ax,hx,cx,ux;!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(Ax||(Ax={}));class dx{static isNull(e){return e&&e.typeId===Ax.Null}static isInt(e){return e&&e.typeId===Ax.Int}static isFloat(e){return e&&e.typeId===Ax.Float}static isBinary(e){return e&&e.typeId===Ax.Binary}static isUtf8(e){return e&&e.typeId===Ax.Utf8}static isBool(e){return e&&e.typeId===Ax.Bool}static isDecimal(e){return e&&e.typeId===Ax.Decimal}static isDate(e){return e&&e.typeId===Ax.Date}static isTime(e){return e&&e.typeId===Ax.Time}static isTimestamp(e){return e&&e.typeId===Ax.Timestamp}static isInterval(e){return e&&e.typeId===Ax.Interval}static isList(e){return e&&e.typeId===Ax.List}static isStruct(e){return e&&e.typeId===Ax.Struct}static isUnion(e){return e&&e.typeId===Ax.Union}static isFixedSizeBinary(e){return e&&e.typeId===Ax.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===Ax.FixedSizeList}static isMap(e){return e&&e.typeId===Ax.Map}static isDictionary(e){return e&&e.typeId===Ax.Dictionary}get typeId(){return Ax.NONE}compareTo(e){return this===e}}hx=Symbol.toStringTag;class px extends dx{constructor(e,t){super(),I_(this,"isSigned",void 0),I_(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return Ax.Int}get[hx](){return"Int"}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}class fx extends px{constructor(){super(!0,8)}}class gx extends px{constructor(){super(!0,16)}}class mx extends px{constructor(){super(!0,32)}}class _x extends px{constructor(){super(!1,8)}}class vx extends px{constructor(){super(!1,16)}}class bx extends px{constructor(){super(!1,32)}}const yx=32,xx=64;cx=Symbol.toStringTag;class Bx extends dx{constructor(e){super(),I_(this,"precision",void 0),this.precision=e}get typeId(){return Ax.Float}get[cx](){return"Float"}toString(){return"Float".concat(this.precision)}}class wx extends Bx{constructor(){super(yx)}}class Px extends Bx{constructor(){super(xx)}}ux=Symbol.toStringTag;class Cx extends dx{constructor(e,t){super(),I_(this,"listSize",void 0),I_(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return Ax.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[ux](){return"FixedSizeList"}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}function Mx(e,t,i){const s=function(e){switch(e.constructor){case Int8Array:return new fx;case Uint8Array:return new _x;case Int16Array:return new gx;case Uint16Array:return new vx;case Int32Array:return new mx;case Uint32Array:return new bx;case Float32Array:return new wx;case Float64Array:return new Px;default:throw new Error("array type not supported")}}(t.value),r=i||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new lx(e,new Cx(t.size,new lx("value",s)),!1,r)}function Fx(e,t,i){return Mx(e,t,i?Ex(i.metadata):void 0)}function Ex(e){const t=new Map;for(const i in e)t.set("".concat(i,".string"),JSON.stringify(e[i]));return t}const Ix={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Dx={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class Sx{constructor(e){I_(this,"draco",void 0),I_(this,"decoder",void 0),I_(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const s=this.decoder.GetEncodedGeometryType(i),r=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(s){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t="DRACO decompression failed: ".concat(e.error_msg());throw new Error(t)}const o=this._getDracoLoaderData(r,s,t),n=this._getMeshData(r,o,t),a=function(e){let t=1/0,i=1/0,s=1/0,r=-1/0,o=-1/0,n=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;er?l:r,o=A>o?A:o,n=h>n?h:n}return[[t,i,s],[r,o,n]]}(n.attributes),l=function(e,t,i){const s=Ex(t.metadata),r=[],o=function(e){const t={};for(const i in e){const s=e[i];t[s.name||"undefined"]=s}return t}(t.attributes);for(const t in e){const i=Fx(t,e[t],o[t]);r.push(i)}if(i){const e=Fx("indices",i);r.push(e)}return new nx(r,s)}(n.attributes,o,n.indices);return{loader:"draco",loaderData:o,header:{vertexCount:r.num_points(),boundingBox:a},...n,schema:l}}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,i){const s=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:r}}_getDracoAttributes(e,t){const i={};for(let s=0;sthis.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map((e=>t.min_value(e)))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,s=e.attribute_type();if(i.map((e=>this.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const Tx="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.js"),Rx="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_wasm_wrapper.js"),Lx="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.wasm");let Ux;async function kx(e){const t=e.modules||{};return Ux=t.draco3d?Ux||t.draco3d.createDecoderModule({}).then((e=>({draco:e}))):Ux||async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await z_(Tx,"draco",e);else[t,i]=await Promise.all([await z_(Rx,"draco",e),await z_(Lx,"draco",e)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e({...i,onModuleLoaded:e=>t({draco:e})})}))}(t,i)}(e),await Ux}const Ox={...ox,parse:async function(e,t){const{draco:i}=await kx(t),s=new Sx(i);try{return s.parseSync(e,null==t?void 0:t.draco)}finally{s.destroy()}}};function Nx(e){const{buffer:t,size:i,count:s}=function(e){let t=e,i=1,s=0;e&&e.value&&(t=e.value,i=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,i=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),s=t.length/i);return{buffer:t,size:i,count:s}}(e);return{value:t,size:i,byteOffset:0,count:s,type:Hy(i),componentType:jy(t)}}async function Qx(e,t,i,s){const r=e.getObjectExtension(t,"KHR_draco_mesh_compression");if(!r)return;const o=e.getTypedArrayForBufferView(r.bufferView),n=q_(o.buffer,o.byteOffset),{parse:a}=s,l={...i};delete l["3d-tiles"];const A=await a(n,Ox,l,s),h=function(e){const t={};for(const i in e){const s=e[i];if("indices"!==i){const e=Nx(s);t[i]=e}}return t}(A.attributes);for(const[i,s]of Object.entries(h))if(i in t.attributes){const r=t.attributes[i],o=e.getAccessor(r);null!=o&&o.min&&null!=o&&o.max&&(s.min=o.min,s.max=o.max)}t.attributes=h,A.indices&&(t.indices=Nx(A.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function Vx(e,t,i=4,s,r){var o;if(!s.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const n=s.DracoWriter.encodeSync({attributes:e}),a=null==r||null===(o=r.parseSync)||void 0===o?void 0:o.call(r,{attributes:e}),l=s._addFauxAttributes(a.attributes);return{primitives:[{attributes:l,mode:i,extensions:{KHR_draco_mesh_compression:{bufferView:s.addBufferView(n),attributes:l}}}]}}function*Hx(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var jx=Object.freeze({__proto__:null,name:"KHR_draco_mesh_compression",preprocess:function(e,t,i){const s=new Wy(e);for(const e of Hx(s))s.getObjectExtension(e,"KHR_draco_mesh_compression")},decode:async function(e,t,i){var s;if(null==t||null===(s=t.gltf)||void 0===s||!s.decompressMeshes)return;const r=new Wy(e),o=[];for(const e of Hx(r))r.getObjectExtension(e,"KHR_draco_mesh_compression")&&o.push(Qx(r,e,t,i));await Promise.all(o),r.removeExtension("KHR_draco_mesh_compression")},encode:function(e,t={}){const i=new Wy(e);for(const e of i.json.meshes||[])Vx(e),i.addRequiredExtension("KHR_draco_mesh_compression")}});var Gx=Object.freeze({__proto__:null,name:"KHR_lights_punctual",decode:async function(e){const t=new Wy(e),{json:i}=t,s=t.getExtension("KHR_lights_punctual");s&&(t.json.lights=s.lights,t.removeExtension("KHR_lights_punctual"));for(const e of i.nodes||[]){const i=t.getObjectExtension(e,"KHR_lights_punctual");i&&(e.light=i.light),t.removeObjectExtension(e,"KHR_lights_punctual")}},encode:async function(e){const t=new Wy(e),{json:i}=t;if(i.lights){const e=t.addExtension("KHR_lights_punctual");Ry(!e.lights),e.lights=i.lights,delete i.lights}if(t.json.lights){for(const e of t.json.lights){const i=e.node;t.addObjectExtension(i,"KHR_lights_punctual",e)}delete t.json.lights}}});function zx(e,t){const i=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach((t=>{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)})),Object.keys(i).forEach((e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))})),i}const Wx=[ix,sx,rx,jx,Gx,Object.freeze({__proto__:null,name:"KHR_materials_unlit",decode:async function(e){const t=new Wy(e),{json:i}=t;t.removeExtension("KHR_materials_unlit");for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,"KHR_materials_unlit")}},encode:function(e){const t=new Wy(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}}),Object.freeze({__proto__:null,name:"KHR_techniques_webgl",decode:async function(e){const t=new Wy(e),{json:i}=t,s=t.getExtension("KHR_techniques_webgl");if(s){const e=function(e,t){const{programs:i=[],shaders:s=[],techniques:r=[]}=e,o=new TextDecoder;return s.forEach((e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))})),i.forEach((e=>{e.fragmentShader=s[e.fragmentShader],e.vertexShader=s[e.vertexShader]})),r.forEach((e=>{e.program=i[e.program]})),r}(s,t);for(const s of i.materials||[]){const i=t.getObjectExtension(s,"KHR_techniques_webgl");i&&(s.technique=Object.assign({},i,e[i.technique]),s.technique.values=zx(s.technique,t)),t.removeObjectExtension(s,"KHR_techniques_webgl")}t.removeExtension("KHR_techniques_webgl")}},encode:async function(e,t){}})];function Kx(e,t){var i;const s=(null==t||null===(i=t.gltf)||void 0===i?void 0:i.excludeExtensions)||{};return!(e in s&&!s[e])}const Xx={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Jx={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class Yx{constructor(){I_(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),I_(this,"json",void 0)}normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version ".concat(i.asset.version))}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new Wy(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,"KHR_binary_glTF");i&&Object.assign(e,i),t.removeObjectExtension(e,"KHR_binary_glTF")}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in Xx)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const s in i){const r=i[s];r.id=r.id||s;const o=e[t].length;e[t].push(r),this.idToIndexMap[t][s]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in Xx)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:s}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),s&&(t.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map((e=>this._convertIdToIndex(e,"node")))),e.meshes&&(e.meshes=e.meshes.map((e=>this._convertIdToIndex(e,"mesh"))))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map((e=>this._convertIdToIndex(e,"node"))))}_convertIdsToIndices(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute ".concat(t)),e[t]=[]);for(const i of e[t])for(const e in i){const t=i[e],s=this._convertIdToIndex(t,e);i[e]=s}}_convertIdToIndex(e,t){const i=Jx[t];if(i in this.idToIndexMap){const s=this.idToIndexMap[i][e];if(!Number.isFinite(s))throw new Error("gltf v1: failed to resolve ".concat(t," with id ").concat(e));return s}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const s of e.materials){var t,i;s.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const r=(null===(t=s.values)||void 0===t?void 0:t.tex)||(null===(i=s.values)||void 0===i?void 0:i.texture2d_0),o=e.textures.findIndex((e=>e.id===r));-1!==o&&(s.pbrMetallicRoughness.baseColorTexture={index:o})}}}const Zx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qx={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},$x=10240,eB=10241,tB=10242,iB=10243,sB=10497,rB={magFilter:$x,minFilter:eB,wrapS:tB,wrapT:iB},oB={[$x]:9729,[eB]:9986,[tB]:sB,[iB]:sB};class nB{constructor(){I_(this,"baseUri",""),I_(this,"json",{}),I_(this,"buffers",[]),I_(this,"images",[])}postProcess(e,t={}){const{json:i,buffers:s=[],images:r=[],baseUri:o=""}=e;return Ry(i),this.baseUri=o,this.json=i,this.buffers=s,this.images=r,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map(((e,t)=>this._resolveBufferView(e,t)))),e.images&&(e.images=e.images.map(((e,t)=>this._resolveImage(e,t)))),e.samplers&&(e.samplers=e.samplers.map(((e,t)=>this._resolveSampler(e,t)))),e.textures&&(e.textures=e.textures.map(((e,t)=>this._resolveTexture(e,t)))),e.accessors&&(e.accessors=e.accessors.map(((e,t)=>this._resolveAccessor(e,t)))),e.materials&&(e.materials=e.materials.map(((e,t)=>this._resolveMaterial(e,t)))),e.meshes&&(e.meshes=e.meshes.map(((e,t)=>this._resolveMesh(e,t)))),e.nodes&&(e.nodes=e.nodes.map(((e,t)=>this._resolveNode(e,t)))),e.skins&&(e.skins=e.skins.map(((e,t)=>this._resolveSkin(e,t)))),e.scenes&&(e.scenes=e.scenes.map(((e,t)=>this._resolveScene(e,t)))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];return i||console.warn("glTF file error: Could not find ".concat(e,"[").concat(t,"]")),i}_resolveScene(e,t){return e.id=e.id||"scene-".concat(t),e.nodes=(e.nodes||[]).map((e=>this.getNode(e))),e}_resolveNode(e,t){return e.id=e.id||"node-".concat(t),e.children&&(e.children=e.children.map((e=>this.getNode(e)))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce(((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e}),{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-".concat(t),e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-".concat(t),e.primitives&&(e.primitives=e.primitives.map((e=>{const t=(e={...e}).attributes;e.attributes={};for(const i in t)e.attributes[i]=this.getAccessor(t[i]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e}))),e}_resolveMaterial(e,t){if(e.id=e.id||"material-".concat(t),e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var i,s;if(e.id=e.id||"accessor-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(i=e.componentType,qx[i]),e.components=(s=e.type,Zx[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:i,byteLength:s}=Gy(e,e.bufferView),r=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset;let o=t.arrayBuffer.slice(r,r+s);e.bufferView.byteStride&&(o=this._getValueFromInterleavedBuffer(t,r,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new i(o)}return e}_getValueFromInterleavedBuffer(e,t,i,s,r){const o=new Uint8Array(r*s);for(let n=0;n20);const s=t.getUint32(i+0,lB),r=t.getUint32(i+4,lB);return i+=8,b_(0===r),hB(e,t,i,s),i+=s,i+=cB(e,t,i,e.header.byteLength)}(e,r,i);case 2:return function(e,t,i,s){return b_(e.header.byteLength>20),function(e,t,i,s){for(;i+8<=e.header.byteLength;){const r=t.getUint32(i+0,lB),o=t.getUint32(i+4,lB);switch(i+=8,o){case 1313821514:hB(e,t,i,r);break;case 5130562:cB(e,t,i,r);break;case 0:s.strict||hB(e,t,i,r);break;case 1:s.strict||cB(e,t,i,r)}i+=$_(r,4)}}(e,t,i,s),i+e.header.byteLength}(e,r,i,{});default:throw new Error("Invalid GLB version ".concat(e.version,". Only supports v1 and v2."))}}function hB(e,t,i,s){const r=new Uint8Array(t.buffer,i,s),o=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(o),$_(s,4)}function cB(e,t,i,s){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:s,arrayBuffer:t.buffer}),$_(s,4)}async function uB(e,t,i=0,s,r){var o,n,a,l;!function(e,t,i,s){s.uri&&(e.baseUri=s.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,i={}){const s=new DataView(e),{magic:r=aB}=i,o=s.getUint32(t,!1);return o===r||o===aB}(t,i,s)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=J_(t);else if(t instanceof ArrayBuffer){const r={};i=AB(r,t,i,s.glb),Ry("glTF"===r.type,"Invalid GLB magic string ".concat(r.type)),e._glb=r,e.json=r.json}else Ry(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,i,s),function(e,t={}){(new Yx).normalize(e,t)}(e,{normalize:null==s||null===(o=s.gltf)||void 0===o?void 0:o.normalize}),function(e,t={},i){const s=Wx.filter((e=>Kx(e.name,t)));for(const o of s){var r;null===(r=o.preprocess)||void 0===r||r.call(o,e,t,i)}}(e,s,r);const A=[];if(null!=s&&null!==(n=s.gltf)&&void 0!==n&&n.loadBuffers&&e.json.buffers&&await async function(e,t,i){const s=e.json.buffers||[];for(let n=0;nKx(e.name,t)));for(const o of s){var r;await(null===(r=o.decode)||void 0===r?void 0:r.call(o,e,t,i))}}(e,s,r);return A.push(h),await Promise.all(A),null!=s&&null!==(l=s.gltf)&&void 0!==l&&l.postProcess?function(e,t){return(new nB).postProcess(e,t)}(e,s):e}async function dB(e,t,i,s,r){const{fetch:o,parse:n}=r;let a;if(t.uri){const e=Ly(t.uri,s),i=await o(e);a=await i.arrayBuffer()}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const s=e.bufferViews[i];Ry(s);const r=t[s.buffer];Ry(r);const o=(s.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,o,s.byteLength)}(e.json,e.buffers,t.bufferView);a=q_(i.buffer,i.byteOffset,i.byteLength)}Ry(a,"glTF image has no data");let l=await n(a,[Iy,dy],{mimeType:t.mimeType,basis:s.basis||{format:uy()}},r);l&&l[0]&&(l={compressed:!0,mipmaps:!1,width:l[0].width,height:l[0].height,data:l[0]}),e.images=e.images||[],e.images[i]=l}const pB={name:"glTF",id:"gltf",module:"gltf",version:"3.2.6",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},i){(t={...pB.options,...t}).gltf={...pB.options.gltf,...t.gltf};const{byteOffset:s=0}=t;return await uB({},e,s,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};class fB{constructor(e){}load(e,t,i,s,r,o,n){!function(e,t,i,s,r,o,n){const a=e.viewer.scene.canvas.spinner;a.processes++;"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(n=>{s.basePath=mB(t),_B(e,t,n,i,s,r,o),a.processes--}),(e=>{a.processes--,n(e)})):e.dataSource.getGLTF(t,(n=>{s.basePath=mB(t),_B(e,t,n,i,s,r,o),a.processes--}),(e=>{a.processes--,n(e)}))}(e,t,i,s=s||{},r,(function(){M.scheduleTask((function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1)})),o&&o()}),(function(t){e.error(t),n&&n(t),r.fire("error",t)}))}parse(e,t,i,s,r,o,n){_B(e,"",t,i,s=s||{},r,(function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1),o&&o()}))}}function gB(e){const t={},i={},s=e.metaObjects||[],r={};for(let e=0,t=s.length;e{const l={src:t,metaModelCorrections:s?gB(s):null,loadBuffer:r.loadBuffer,basePath:r.basePath,handlenode:r.handlenode,backfaces:!!r.backfaces,gltfData:i,scene:o.scene,plugin:e,sceneModel:o,numObjects:0,nodes:[],nextId:0,log:t=>{e.log(t)}};!function(e){const t=e.gltfData.textures;if(t)for(let i=0,s=t.length;i0)for(let t=0;t0){null==n&&e.log("Warning: 'name' properties not found on glTF scene nodes - will randomly-generate object IDs in XKT");let t=n;if(e.metaModelCorrections){const i=e.metaModelCorrections.eachChildRoot[t];if(i){const t=e.metaModelCorrections.eachRootStats[i.id];t.countChildren++,t.countChildren>=t.numChildren&&(o.createEntity({id:i.id,meshIds:BB}),BB.length=0)}else{e.metaModelCorrections.metaObjectsMap[t]&&(o.createEntity({id:t,meshIds:BB}),BB.length=0)}}else o.createEntity({id:t,meshIds:BB}),BB.length=0}}function PB(e,t){e.plugin.error(t)}const CB={DEFAULT:{}};function MB(e,t,i={}){const s="lightgrey",r=i.hoverColor||"rgba(0,0,0,0.4)",o=i.textColor||"black",n=500,a=n+n/3,l=a/24,A=[{boundary:[6,6,6,6],color:i.frontColor||i.color||"#55FF55"},{boundary:[18,6,6,6],color:i.backColor||i.color||"#55FF55"},{boundary:[12,6,6,6],color:i.rightColor||i.color||"#FF5555"},{boundary:[0,6,6,6],color:i.leftColor||i.color||"#FF5555"},{boundary:[6,0,6,6],color:i.topColor||i.color||"#7777FF"},{boundary:[6,12,6,6],color:i.bottomColor||i.color||"#7777FF"}],h=[{label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,1,0],up:[0,0,1]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,-1,0],up:[0,0,1]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,0,1]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,0,1]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,0,1],up:[0,-1,0]},{boundaries:[[7,5,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,0,-1],up:[1,0,1]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-1,-1],up:[0,-1,1]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,0,-1],up:[-1,0,1]},{boundaries:[[7,11,4,2]],dir:[0,1,1],up:[0,-1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,0,1],up:[-1,0,1]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,-1,1],up:[0,1,1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,0,1],up:[1,0,1]},{boundaries:[[5,7,2,4]],dir:[1,1,0],up:[0,0,1]},{boundaries:[[11,7,2,4]],dir:[-1,1,0],up:[0,0,1]},{boundaries:[[17,7,2,4]],dir:[-1,-1,0],up:[0,0,1]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,-1,0],up:[0,0,1]},{boundaries:[[5,11,2,2]],dir:[1,1,1],up:[-1,-1,1]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[1,-1,1],up:[-1,1,1]},{boundaries:[[5,5,2,2]],dir:[1,1,-1],up:[1,1,1]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-1,-1,1],up:[1,1,1]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-1,-1,-1],up:[-1,-1,1]},{boundaries:[[11,11,2,2]],dir:[-1,1,1],up:[1,-1,1]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[1,-1,-1],up:[1,-1,1]},{boundaries:[[11,5,2,2]],dir:[-1,1,-1],up:[-1,1,1]}];i.frontColor||i.color,i.backColor||i.color,i.rightColor||i.color,i.leftColor||i.color,i.topColor||i.color,i.bottomColor||i.color;const u=[{yUp:"",label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,0,1],up:[0,1,0]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,1,0]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,1,0]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,-1,0],up:[0,0,-1]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,1,0],up:[0,0,1]},{boundaries:[[7,5,4,2]],dir:[0,-.7071,-.7071],up:[0,.7071,-.7071]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,-1,0],up:[1,1,0]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-.7071,.7071],up:[0,.7071,.7071]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,-1,0],up:[-1,1,0]},{boundaries:[[7,11,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,1,0],up:[-1,1,0]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,1,1],up:[0,1,-1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,1,0],up:[1,1,0]},{boundaries:[[5,7,2,4]],dir:[1,0,-1],up:[0,1,0]},{boundaries:[[11,7,2,4]],dir:[-1,0,-1],up:[0,1,0]},{boundaries:[[17,7,2,4]],dir:[-1,0,1],up:[0,1,0]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,0,1],up:[0,1,0]},{boundaries:[[5,11,2,2]],dir:[.5,.7071,-.5],up:[-.5,.7071,.5]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[.5,.7071,.5],up:[-.5,.7071,-.5]},{boundaries:[[5,5,2,2]],dir:[.5,-.7071,-.5],up:[.5,.7071,-.5]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-.5,.7071,.5],up:[.5,.7071,-.5]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-.5,-.7071,.5],up:[-.5,.7071,.5]},{boundaries:[[11,11,2,2]],dir:[-.5,.7071,-.5],up:[.5,.7071,.5]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[.5,-.7071,.5],up:[.5,.7071,.5]},{boundaries:[[11,5,2,2]],dir:[-.5,-.7071,-.5],up:[-.5,.7071,-.5]}];for(let e=0,t=h.length;e=r[0]*l&&t<=(r[0]+r[2])*l&&i>=r[1]*l&&i<=(r[1]+r[3])*l)return s}}return-1},this.setAreaHighlighted=function(e,t){var i=d[e];if(!i)throw"Area not found: "+e;i.highlighted=!!t,g()},this.getAreaDir=function(e){var t=d[e];if(!t)throw"Unknown area: "+e;return t.dir},this.getAreaUp=function(e){var t=d[e];if(!t)throw"Unknown area: "+e;return t.up},this.getImage=function(){return this._textureCanvas},this.destroy=function(){this._textureCanvas&&(this._textureCanvas.parentNode.removeChild(this._textureCanvas),this._textureCanvas=null)}}const FB=c.vec3(),EB=c.vec3();c.mat4();const IB=c.vec3();class DB{load(e,t,i={}){var s=e.scene.canvas.spinner;s.processes++,SB(e,t,(function(t){!function(e,t,i){for(var s=t.basePath,r=Object.keys(t.materialLibraries),o=r.length,n=0,a=o;n=0?i-1:i+t/3)}function r(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function o(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)}function n(e,t,i,s){var r=e.positions,o=e.object.geometry.positions;o.push(r[t+0]),o.push(r[t+1]),o.push(r[t+2]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[i+2]),o.push(r[s+0]),o.push(r[s+1]),o.push(r[s+2])}function a(e,t){var i=e.positions,s=e.object.geometry.positions;s.push(i[t+0]),s.push(i[t+1]),s.push(i[t+2])}function l(e,t,i,s){var r=e.normals,o=e.object.geometry.normals;o.push(r[t+0]),o.push(r[t+1]),o.push(r[t+2]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[i+2]),o.push(r[s+0]),o.push(r[s+1]),o.push(r[s+2])}function A(e,t,i,s){var r=e.uv,o=e.object.geometry.uv;o.push(r[t+0]),o.push(r[t+1]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[s+0]),o.push(r[s+1])}function h(e,t){var i=e.uv,s=e.object.geometry.uv;s.push(i[t+0]),s.push(i[t+1])}function c(e,t,i,a,h,c,u,d,p,f,g,m,_){var v,b=e.positions.length,y=s(t,b),x=s(i,b),B=s(a,b);if(void 0===h?n(e,y,x,B):(n(e,y,x,v=s(h,b)),n(e,x,B,v)),void 0!==c){var w=e.uv.length;y=o(c,w),x=o(u,w),B=o(d,w),void 0===h?A(e,y,x,B):(A(e,y,x,v=o(p,w)),A(e,x,B,v))}if(void 0!==f){var P=e.normals.length;y=r(f,P),x=f===g?y:r(g,P),B=f===m?y:r(m,P),void 0===h?l(e,y,x,B):(l(e,y,x,v=r(_,P)),l(e,x,B,v))}}function u(e,t,i){e.object.geometry.type="Line";for(var r=e.positions.length,n=e.uv.length,l=0,A=t.length;l=0?n.substring(0,a):n).toLowerCase(),A=(A=a>=0?n.substring(a+1):"").trim(),l.toLowerCase()){case"newmtl":i(e,u),u={id:A},d=!0;break;case"ka":u.ambient=s(A);break;case"kd":u.diffuse=s(A);break;case"ks":u.specular=s(A);break;case"map_kd":u.diffuseMap||(u.diffuseMap=t(e,o,A,"sRGB"));break;case"map_ks":u.specularMap||(u.specularMap=t(e,o,A,"linear"));break;case"map_bump":case"bump":u.normalMap||(u.normalMap=t(e,o,A));break;case"ns":u.shininess=parseFloat(A);break;case"d":(h=parseFloat(A))<1&&(u.alpha=h,u.alphaMode="blend");break;case"tr":(h=parseFloat(A))>0&&(u.alpha=1-h,u.alphaMode="blend")}d&&i(e,u)};function t(e,t,i,s){var r={},o=i.split(/\s+/),n=o.indexOf("-bm");return n>=0&&o.splice(n,2),(n=o.indexOf("-s"))>=0&&(r.scale=[parseFloat(o[n+1]),parseFloat(o[n+2])],o.splice(n,4)),(n=o.indexOf("-o"))>=0&&(r.translate=[parseFloat(o[n+1]),parseFloat(o[n+2])],o.splice(n,4)),r.src=t+o.join(" ").trim(),r.flipY=!0,r.encoding=s||"linear",new Bs(e,r).id}function i(e,t){new Vt(e,t)}function s(t){var i=t.split(e,3);return[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])]}}();function UB(e,t){for(var i=0,s=t.objects.length;i0&&(n.normals=o.normals),o.uv.length>0&&(n.uv=o.uv);for(var a=new Array(n.positions.length/3),l=0;l{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),G(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=c.vec3PairToQuaternion(OB,e,NB)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,i=.01;this._rootNode=new as(t,{position:[0,0,0],scale:[5,5,5],isObject:!1});const s=this._rootNode,r={arrowHead:new Ut(s,Ki({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Ut(s,Ki({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),arrowHeadHandle:new Ut(s,Ki({radiusTop:.09,radiusBottom:.09,radialSegments:8,heightSegments:1,height:.37,openEnded:!1})),curve:new Ut(s,Ds({radius:.8,tube:i,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),curveHandle:new Ut(s,Ds({radius:.8,tube:.06,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),hoop:new Ut(s,Ds({radius:.8,tube:i,radialSegments:64,tubeSegments:8,arc:2*Math.PI})),axis:new Ut(s,Ki({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1})),axisHandle:new Ut(s,Ki({radiusTop:.08,radiusBottom:.08,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},o={pickable:new Vt(s,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),red:new Vt(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new jt(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6}),green:new Vt(s,{diffuse:[0,1,0],emissive:[0,1,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightGreen:new jt(s,{edges:!1,fill:!0,fillColor:[0,1,0],fillAlpha:.6}),blue:new Vt(s,{diffuse:[0,0,1],emissive:[0,0,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightBlue:new jt(s,{edges:!1,fill:!0,fillColor:[0,0,1],fillAlpha:.2}),center:new Vt(s,{diffuse:[0,0,0],emissive:[0,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80}),highlightBall:new jt(s,{edges:!1,fill:!0,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1}),highlightPlane:new jt(s,{edges:!0,edgeWidth:3,fill:!1,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1})};this._displayMeshes={plane:s.addChild(new zi(s,{geometry:new Ut(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Vt(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new jt(s,{edges:!1,filled:!0,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:.1,backfaces:!0}),pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1],isObject:!1}),e),planeFrame:s.addChild(new zi(s,{geometry:new Ut(s,Ds({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Vt(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new jt(s,{edges:!1,edgeColor:[0,0,0],filled:!0,fillColor:[.8,.8,.8],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45],isObject:!1}),e),xCurve:s.addChild(new zi(s,{geometry:r.curve,material:o.red,matrix:function(){const e=c.rotationMat4v(90*c.DEGTORAD,[0,1,0],c.identityMat4()),t=c.rotationMat4v(270*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveHandle:s.addChild(new zi(s,{geometry:r.curveHandle,material:o.pickable,matrix:function(){const e=c.rotationMat4v(90*c.DEGTORAD,[0,1,0],c.identityMat4()),t=c.rotationMat4v(270*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveArrow1:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=c.translateMat4c(0,-.07,-.8,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(0*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xCurveArrow2:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=c.translateMat4c(0,-.8,-.07,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurve:s.addChild(new zi(s,{geometry:r.curve,material:o.green,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveHandle:s.addChild(new zi(s,{geometry:r.curveHandle,material:o.pickable,rotation:[-90,0,0],pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveArrow1:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=c.translateMat4c(.07,0,-.8,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurveArrow2:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=c.translateMat4c(.8,0,-.07,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurve:s.addChild(new zi(s,{geometry:r.curve,material:o.blue,matrix:c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4()),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveHandle:s.addChild(new zi(s,{geometry:r.curveHandle,material:o.pickable,matrix:c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4()),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveCurveArrow1:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=c.translateMat4c(.8,-.07,0,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4());return c.mulMat4(e,t,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveArrow2:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=c.translateMat4c(.05,-.8,0,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),center:s.addChild(new zi(s,{geometry:new Ut(s,Xi({radius:.05})),material:o.center,pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrowHandle:s.addChild(new zi(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxis:s.addChild(new zi(s,{geometry:r.axis,material:o.red,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisHandle:s.addChild(new zi(s,{geometry:r.axisHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrowHandle:s.addChild(new zi(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,opacity:.2,isObject:!1}),e),yShaft:s.addChild(new zi(s,{geometry:r.axis,material:o.green,position:[0,-.5,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yShaftHandle:s.addChild(new zi(s,{geometry:r.axisHandle,material:o.pickable,position:[0,-.5,0],pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrowHandle:s.addChild(new zi(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zShaft:s.addChild(new zi(s,{geometry:r.axis,material:o.blue,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1,isObject:!1}),e),zAxisHandle:s.addChild(new zi(s,{geometry:r.axisHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),clippable:!1,pickable:!0,collidable:!0,visible:!1,isObject:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new zi(s,{geometry:new Ut(s,Ds({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Vt(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new jt(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45],isObject:!1}),e),xHoop:s.addChild(new zi(s,{geometry:r.hoop,material:o.red,highlighted:!0,highlightMaterial:o.highlightRed,matrix:function(){const e=c.rotationMat4v(90*c.DEGTORAD,[0,1,0],c.identityMat4()),t=c.rotationMat4v(270*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yHoop:s.addChild(new zi(s,{geometry:r.hoop,material:o.green,highlighted:!0,highlightMaterial:o.highlightGreen,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zHoop:s.addChild(new zi(s,{geometry:r.hoop,material:o.blue,highlighted:!0,highlightMaterial:o.highlightBlue,matrix:c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4()),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHeadBig,material:o.red,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHeadBig,material:o.green,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHeadBig,material:o.blue,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e)}}_bindEvents(){const e=this;var t=!1;const i=-1,s=0,r=1,o=2,n=3,a=4,l=5,A=this._rootNode;var h=null,u=null;const d=c.vec2(),p=c.vec3([1,0,0]),f=c.vec3([0,1,0]),g=c.vec3([0,0,1]),m=this._viewer.scene.canvas.canvas,_=this._viewer.camera,v=this._viewer.scene;{const e=c.vec3([0,0,0]);let t=-1;this._onCameraViewMatrix=v.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=v.camera.on("projMatrix",(()=>{})),this._onSceneTick=v.on("tick",(()=>{const i=Math.abs(c.lenVec3(c.subVec3(v.camera.eye,this._pos,e)));if(i!==t&&"perspective"===_.projection){const e=.07*(Math.tan(_.perspective.fov*c.DEGTORAD)*i);A.scale=[e,e,e],t=i}if("ortho"===_.projection){const e=_.ortho.scale/10;A.scale=[e,e,e],t=i}}))}const b=function(){const e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),y=function(){const t=c.mat4();return function(i,s){return c.quaternionToMat4(e._rootNode.quaternion,t),c.transformVec3(t,i,s),c.normalizeVec3(s),s}}();var x=function(){const e=c.vec3();return function(t){const i=Math.abs(t[0]);return i>Math.abs(t[1])&&i>Math.abs(t[2])?c.cross3Vec3(t,[0,1,0],e):c.cross3Vec3(t,[1,0,0],e),c.cross3Vec3(e,t,e),c.normalizeVec3(e),e}}();const B=function(){const t=c.vec3(),i=c.vec3(),s=c.vec4();return function(r,o,n){y(r,s);const a=x(s,o,n);P(o,a,t),P(n,a,i),c.subVec3(i,t);const l=c.dotVec3(i,s);e._pos[0]+=s[0]*l,e._pos[1]+=s[1]*l,e._pos[2]+=s[2]*l,e._rootNode.position=e._pos,e._sectionPlane&&(e._sectionPlane.pos=e._pos)}}();var w=function(){const t=c.vec4(),i=c.vec4(),s=c.vec4(),r=c.vec4();return function(o,n,a){y(o,r);if(!(P(n,r,t)&&P(a,r,i))){const e=x(r,n,a);P(n,e,t,1),P(a,e,i,1);var l=c.dotVec3(t,r);t[0]-=l*r[0],t[1]-=l*r[1],t[2]-=l*r[2],l=c.dotVec3(i,r),i[0]-=l*r[0],i[1]-=l*r[1],i[2]-=l*r[2]}c.normalizeVec3(t),c.normalizeVec3(i),l=c.dotVec3(t,i),l=c.clamp(l,-1,1);var A=Math.acos(l)*c.RADTODEG;c.cross3Vec3(t,i,s),c.dotVec3(s,r)<0&&(A=-A),e._rootNode.rotate(o,A),C()}}(),P=function(){const t=c.vec4([0,0,0,1]),i=c.mat4();return function(s,r,o,n){n=n||0,t[0]=s[0]/m.width*2-1,t[1]=-(s[1]/m.height*2-1),t[2]=0,t[3]=1,c.mulMat4(_.projMatrix,_.viewMatrix,i),c.inverseMat4(i),c.transformVec4(i,t,t),c.mulVec4Scalar(t,1/t[3]);var a=_.eye;c.subVec4(t,a,t);const l=e._sectionPlane.pos;var A=-c.dotVec3(l,r)-n,h=c.dotVec3(r,t);if(Math.abs(h)>.005){var u=-(c.dotVec3(r,a)+A)/h;return c.mulVec3Scalar(t,u,o),c.addVec3(o,a),c.subVec3(o,l,o),!0}return!1}}();const C=function(){const t=c.vec3(),i=c.mat4();return function(){e.sectionPlane&&(c.quaternionToMat4(A.quaternion,i),c.transformVec3(i,[0,0,1],t),e._setSectionPlaneDir(t))}}();var M,F=!1;this._onCameraControlHover=this._viewer.cameraControl.on("hoverEnter",(e=>{if(!this._visible)return;if(F)return;var A;t=!1,M&&(M.visible=!1);switch(e.entity.id){case this._displayMeshes.xAxisArrowHandle.id:case this._displayMeshes.xAxisHandle.id:A=this._affordanceMeshes.xAxisArrow,h=s;break;case this._displayMeshes.yAxisArrowHandle.id:case this._displayMeshes.yShaftHandle.id:A=this._affordanceMeshes.yAxisArrow,h=r;break;case this._displayMeshes.zAxisArrowHandle.id:case this._displayMeshes.zAxisHandle.id:A=this._affordanceMeshes.zAxisArrow,h=o;break;case this._displayMeshes.xCurveHandle.id:A=this._affordanceMeshes.xHoop,h=n;break;case this._displayMeshes.yCurveHandle.id:A=this._affordanceMeshes.yHoop,h=a;break;case this._displayMeshes.zCurveHandle.id:A=this._affordanceMeshes.zHoop,h=l;break;default:return void(h=i)}A&&(A.visible=!0),M=A,t=!0})),this._onCameraControlHoverLeave=this._viewer.cameraControl.on("hoverOutEntity",(e=>{this._visible&&(M&&(M.visible=!1),M=null,h=i)})),m.addEventListener("mousedown",this._canvasMouseDownListener=e=>{if(e.preventDefault(),this._visible&&t&&(this._viewer.cameraControl.pointerEnabled=!1,1===e.which)){F=!0;var i=b(e);u=h,d[0]=i[0],d[1]=i[1]}}),m.addEventListener("mousemove",this._canvasMouseMoveListener=e=>{if(!this._visible)return;if(!F)return;var t=b(e);const i=t[0],A=t[1];switch(u){case s:B(p,d,t);break;case r:B(f,d,t);break;case o:B(g,d,t);break;case n:w(p,d,t);break;case a:w(f,d,t);break;case l:w(g,d,t)}d[0]=i,d[1]=A}),m.addEventListener("mouseup",this._canvasMouseUpListener=e=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,F&&(e.which,F=!1,t=!1))}),m.addEventListener("wheel",this._canvasWheelListener=e=>{if(this._visible)Math.max(-1,Math.min(1,40*-e.deltaY))})}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=e.cameraControl;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix),r.off(this._onCameraControlHover),r.off(this._onCameraControlHoverLeave)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class VB{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new zi(t,{id:i.id,geometry:new Ut(t,kt({xSize:.5,ySize:.5,zSize:.001})),material:new Vt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new zt(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new jt(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new jt(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=c.vec3([0,0,0]),t=c.vec3(),i=c.vec3([0,0,1]),s=c.vec4(4),r=c.vec3(),o=()=>{const o=this._sectionPlane.scene.center,n=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];c.subVec3(o,this._sectionPlane.pos,e);const a=-c.dotVec3(n,e);c.normalizeVec3(n),c.mulVec3Scalar(n,a,t);const l=c.vec3PairToQuaternion(i,this._sectionPlane.dir,s);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=l,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",o),this._onSectionPlaneDir=this._sectionPlane.on("dir",o)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class HB{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new ei(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Bt(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Bt(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Bt(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=c.rotationMat4c(-90*c.DEGTORAD,1,0,0),i=c.vec3(),s=c.vec3(),r=c.vec3();this._synchCamera=()=>{const o=this._viewer.camera.eye,n=this._viewer.camera.look,a=this._viewer.camera.up;c.mulVec3Scalar(c.normalizeVec3(c.subVec3(o,n,i)),7),this._zUp?(c.transformVec3(t,i,s),c.transformVec3(t,a,r),e.look=[0,0,0],e.eye=c.transformVec3(t,i,s),e.up=c.transformPoint3(t,a,r)):(e.look=[0,0,0],e.eye=i,e.up=a)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new VB(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const jB=c.AABB3(),GB=c.vec3();class zB{constructor(e,t,i,s,r,o){this.plugin=e,this.storeyId=r,this.modelId=s,this.storeyAABB=i.slice(),this.aabb=this.storeyAABB,this.modelAABB=t.slice(),this.numObjects=o}}class WB{constructor(e,t,i,s,r,o){this.storeyId=e,this.imageData=t,this.format=i,this.width=s,this.height=r}}const KB=c.vec3(),XB=c.mat4();const JB=new Float64Array([0,0,1]),YB=new Float64Array(4);class ZB{constructor(e){this.id=null,this._viewer=e.viewer,this._plugin=e,this._visible=!1,this._pos=c.vec3(),this._origin=c.vec3(),this._rtcPos=c.vec3(),this._baseDir=c.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}_setSectionPlane(e){this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(()=>{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),G(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=c.vec3PairToQuaternion(JB,e,YB)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,i=.01;this._rootNode=new as(t,{position:[0,0,0],scale:[5,5,5]});const s=this._rootNode,r={arrowHead:new Ut(s,Ki({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Ut(s,Ki({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new Ut(s,Ki({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},o={red:new Vt(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new Vt(s,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new Vt(s,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new jt(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:s.addChild(new zi(s,{geometry:new Ut(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Vt(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1]}),e),planeFrame:s.addChild(new zi(s,{geometry:new Ut(s,Ds({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Vt(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45]}),e),center:s.addChild(new zi(s,{geometry:new Ut(s,Xi({radius:.05})),material:o.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:s.addChild(new zi(s,{geometry:r.axis,material:o.blue,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new zi(s,{geometry:new Ut(s,Ds({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Vt(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new jt(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45]}),e),zAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHeadBig,material:o.blue,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}_bindEvents(){const e=this._rootNode,t=c.vec2(),i=this._viewer.camera,s=this._viewer.scene;let r=0,o=!1;{const t=c.vec3([0,0,0]);let n=-1;this._onCameraViewMatrix=s.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=s.camera.on("projMatrix",(()=>{})),this._onSceneTick=s.on("tick",(()=>{o=!1;const l=Math.abs(c.lenVec3(c.subVec3(s.camera.eye,this._pos,t)));if(l!==n&&"perspective"===i.projection){const t=.07*(Math.tan(i.perspective.fov*c.DEGTORAD)*l);e.scale=[t,t,t],n=l}if("ortho"===i.projection){const t=i.ortho.scale/10;e.scale=[t,t,t],n=l}0!==r&&(a(r),r=0)}))}const n=function(){const e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),a=e=>{const t=this._sectionPlane.pos,i=this._sectionPlane.dir;c.addVec3(t,c.mulVec3Scalar(i,.1*e*this._plugin.getDragSensitivity(),c.vec3())),this._sectionPlane.pos=t};{let e=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=i=>{if(i.preventDefault(),this._visible&&(this._viewer.cameraControl.pointerEnabled=!1,1===i.which)){e=!0;var s=n(i);t[0]=s[0],t[1]=s[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=i=>{if(!this._visible)return;if(!e)return;if(o)return;var s=n(i);const r=s[0],l=s[1];a(l-t[1]),t[0]=r,t[1]=l}),this._plugin._controlElement.addEventListener("mouseup",this._canvasMouseUpListener=t=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,e&&(t.which,e=!1))}),this._plugin._controlElement.addEventListener("wheel",this._canvasWheelListener=e=>{this._visible&&(r+=Math.max(-1,Math.min(1,40*-e.deltaY)))})}{let e,t,i=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=t=>{t.stopPropagation(),t.preventDefault(),this._visible&&(e=t.touches[0].clientY,i=e,r=0)}),this._plugin._controlElement.addEventListener("touchmove",this._handleTouchMove=e=>{e.stopPropagation(),e.preventDefault(),this._visible&&(o||(o=!0,t=e.touches[0].clientY,null!==i&&(r+=t-i),i=t))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=i=>{i.stopPropagation(),i.preventDefault(),this._visible&&(e=null,t=null,r=0)})}}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class qB{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new zi(t,{id:i.id,geometry:new Ut(t,kt({xSize:.5,ySize:.5,zSize:.001})),material:new Vt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new zt(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new jt(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new jt(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=c.vec3([0,0,0]),t=c.vec3(),i=c.vec3([0,0,1]),s=c.vec4(4),r=c.vec3(),o=()=>{const o=this._sectionPlane.scene.center,n=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];c.subVec3(o,this._sectionPlane.pos,e);const a=-c.dotVec3(n,e);c.normalizeVec3(n),c.mulVec3Scalar(n,a,t);const l=c.vec3PairToQuaternion(i,this._sectionPlane.dir,s);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=l,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",o),this._onSectionPlaneDir=this._sectionPlane.on("dir",o)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class $B{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new ei(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Bt(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Bt(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Bt(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=c.rotationMat4c(-90*c.DEGTORAD,1,0,0),i=c.vec3(),s=c.vec3(),r=c.vec3();this._synchCamera=()=>{const o=this._viewer.camera.eye,n=this._viewer.camera.look,a=this._viewer.camera.up;c.mulVec3Scalar(c.normalizeVec3(c.subVec3(o,n,i)),7),this._zUp?(c.transformVec3(t,i,s),c.transformVec3(t,a,r),e.look=[0,0,0],e.eye=c.transformVec3(t,i,s),e.up=c.transformPoint3(t,a,r)):(e.look=[0,0,0],e.eye=i,e.up=a)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new qB(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const ew=c.AABB3(),tw=c.vec3();class iw{getSTL(e,t,i){const s=new XMLHttpRequest;s.overrideMimeType("application/json"),s.open("GET",e,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i(s.statusText))},s.send(null)}}const sw=c.vec3();class rw{load(e,t,i,s,r,o){s=s||{};const n=e.viewer.scene.canvas.spinner;n.processes++,e.dataSource.getSTL(i,(function(i){!function(e,t,i,s){try{const r=hw(i);ow(r)?nw(e,r,t,s):aw(e,Aw(i),t,s)}catch(e){t.fire("error",e)}}(e,t,i,s);try{const o=hw(i);ow(o)?nw(e,o,t,s):aw(e,Aw(i),t,s),n.processes--,M.scheduleTask((function(){t.fire("loaded",!0,!1)})),r&&r()}catch(i){n.processes--,e.error(i),o&&o(i),t.fire("error",i)}}),(function(i){n.processes--,e.error(i),o&&o(i),t.fire("error",i)}))}parse(e,t,i,s){const r=e.viewer.scene.canvas.spinner;r.processes++;try{const o=hw(i);ow(o)?nw(e,o,t,s):aw(e,Aw(i),t,s),r.processes--,M.scheduleTask((function(){t.fire("loaded",!0,!1)}))}catch(e){r.processes--,t.fire("error",e)}}}function ow(e){const t=new DataView(e);if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;const i=[115,111,108,105,100];for(var s=0;s<5;s++)if(i[s]!==t.getUint8(s,!1))return!0;return!1}function nw(e,t,i,s){const r=new DataView(t),o=r.getUint32(80,!0);let n,a,l,A,h,c,u,d=!1,p=null,f=null,g=null,m=!1;for(let e=0;e<70;e++)1129270351===r.getUint32(e,!1)&&82===r.getUint8(e+4)&&61===r.getUint8(e+5)&&(d=!0,A=[],h=r.getUint8(e+6)/255,c=r.getUint8(e+7)/255,u=r.getUint8(e+8)/255,r.getUint8(e+9));const _=new cs(i,{roughness:.5});let v=[],b=[],y=s.splitMeshes;for(let e=0;e>5&31)/31,l=(e>>10&31)/31):(n=h,a=c,l=u),(y&&n!==p||a!==f||l!==g)&&(null!==p&&(m=!0),p=n,f=a,g=l)}for(let e=1;e<=3;e++){let i=t+12*e;v.push(r.getFloat32(i,!0)),v.push(r.getFloat32(i+4,!0)),v.push(r.getFloat32(i+8,!0)),b.push(o,x,B),d&&A.push(n,a,l,1)}y&&m&&(lw(i,v,b,A,_,s),v=[],b=[],A=A?[]:null,m=!1)}v.length>0&&lw(i,v,b,A,_,s)}function aw(e,t,i,s){const r=/facet([\s\S]*?)endfacet/g;let o=0;const n=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,a=new RegExp("vertex"+n+n+n,"g"),l=new RegExp("normal"+n+n+n,"g"),A=[],h=[];let c,u,d,p,f,g,m;for(;null!==(p=r.exec(t));){for(f=0,g=0,m=p[0];null!==(p=l.exec(m));)c=parseFloat(p[1]),u=parseFloat(p[2]),d=parseFloat(p[3]),g++;for(;null!==(p=a.exec(m));)A.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),h.push(c,u,d),f++;1!==g&&e.error("Error in normal of face "+o),3!==f&&e.error("Error in positions of face "+o),o++}lw(i,A,h,null,new cs(i,{roughness:.5}),s)}function lw(e,t,i,s,r,o){const n=new Int32Array(t.length/3);for(let e=0,t=n.length;e0?i:null,s=s&&s.length>0?s:null,o.smoothNormals&&c.faceToVertexNormals(t,i,o);const a=sw;z(t,t,a);const l=new Ut(e,{primitive:"triangles",positions:t,normals:i,colors:s,indices:n}),A=new zi(e,{origin:0!==a[0]||0!==a[1]||0!==a[2]?a:null,geometry:l,material:r,edges:o.edges});e.addChild(A)}function Aw(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,s=e.length;i0){const i=document.createElement("a");i.href="#",i.id=`switch-${e.nodeId}`,i.textContent="+",i.classList.add("plus"),t&&i.addEventListener("click",t),o.appendChild(i)}const n=document.createElement("input");n.id=`checkbox-${e.nodeId}`,n.type="checkbox",n.checked=e.checked,n.style["pointer-events"]="all",i&&n.addEventListener("change",i),o.appendChild(n);const a=document.createElement("span");return a.textContent=e.title,o.appendChild(a),s&&(a.oncontextmenu=s),r&&(a.onclick=r),o}createDisabledNodeElement(e){const t=document.createElement("li"),i=document.createElement("a");i.href="#",i.textContent="!",i.classList.add("warn"),i.classList.add("warning"),t.appendChild(i);const s=document.createElement("span");return s.textContent=e,t.appendChild(s),t}addChildren(e,t){const i=document.createElement("ul");t.forEach((e=>{i.appendChild(e)})),e.parentElement.appendChild(i)}expand(e,t,i){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",i)}collapse(e,t,i){if(!e)return;const s=e.parentElement;if(!s)return;const r=s.querySelector("ul");r&&(s.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",i),e.addEventListener("click",t))}isExpanded(e){return void 0!==e.parentElement.getElementsByTagName("li")[0]}getId(e){return e.parentElement.id}getIdFromCheckbox(e){return e.id.replace("checkbox-","")}getSwitchElement(e){return document.getElementById(`switch-${e}`)}isChecked(e){return e.checked}setCheckbox(e,t){const i=document.getElementById(`checkbox-${e}`);i&&t!==i.checked&&(i.checked=t)}setXRayed(e,t){const i=document.getElementById(e);i&&(t?i.classList.add("xrayed-node"):i.classList.remove("xrayed-node"))}setHighlighted(e,t){const i=document.getElementById(e);i&&(t?(i.scrollIntoView({block:"center"}),i.classList.add("highlighted-node")):i.classList.remove("highlighted-node"))}}const uw=[];class dw{constructor(e){this._scene=e,this._objects=[],this._objectsViewCulled=[],this._objectsDetailCulled=[],this._objectsChanged=[],this._objectsChangedList=[],this._modelInfos={},this._numObjects=0,this._lenObjectsChangedList=0,this._dirty=!0,this._onModelLoaded=e.on("modelLoaded",(t=>{const i=e.models[t];i&&this._addModel(i)})),this._onTick=e.on("tick",(()=>{this._dirty&&this._build(),this._applyChanges()}))}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._dirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._dirty=!0)}_build(){if(!this._dirty)return;this._applyChanges();const e=this._scene.objects;for(let e=0;e0){for(let e=0;e{t(e)}),(function(e){i(e)}))}getMetaModel(e,t,i){_.loadJSON(e,(e=>{t(e)}),(function(e){i(e)}))}getXKT(e,t,i){var s=()=>{};t=t||s,i=i||s;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var o=r[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),i=new Uint8Array(e);for(var n=0;n0&&r[r.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=55296&&r<=56319&&i>10),n%1024+56320)),(r+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Sc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tc="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Rc=0;Rc=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Qc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Vc="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Hc=0;Hc>4,h[l++]=(15&s)<<4|r>>2,h[l++]=(3&r)<<6|63&o;return A}(e),n=Array.isArray(o)?function(e){for(var t=e.length,i=[],s=0;s0;){var n=s[--o];if(Array.isArray(e)?-1!==e.indexOf(n):e===n)for(var a=i;a<=s.length;){var l;if((l=s[++a])===t)return!0;if(l!==jc)break}if(n!==jc)break}return!1},Bu=function(e,t){for(var i=e;i>=0;){var s=t[i];if(s!==jc)return s;i--}return 0},wu=function(e,t,i,s,r){if(0===i[s])return"×";var o=s-1;if(Array.isArray(r)&&!0===r[o])return"×";var n=o-1,a=o+1,l=t[o],A=n>=0?t[n]:0,h=t[a];if(2===l&&3===h)return"×";if(-1!==gu.indexOf(l))return"!";if(-1!==gu.indexOf(h))return"×";if(-1!==mu.indexOf(h))return"×";if(8===Bu(o,t))return"÷";if(11===pu.get(e[o]))return"×";if((l===ru||l===ou)&&11===pu.get(e[a]))return"×";if(7===l||7===h)return"×";if(9===l)return"×";if(-1===[jc,Gc,zc].indexOf(l)&&9===h)return"×";if(-1!==[Wc,Kc,Xc,qc,iu].indexOf(h))return"×";if(Bu(o,t)===Zc)return"×";if(xu(23,Zc,o,t))return"×";if(xu([Wc,Kc],Yc,o,t))return"×";if(xu(12,12,o,t))return"×";if(l===jc)return"÷";if(23===l||23===h)return"×";if(16===h||16===l)return"÷";if(-1!==[Gc,zc,Yc].indexOf(h)||14===l)return"×";if(36===A&&-1!==yu.indexOf(l))return"×";if(l===iu&&36===h)return"×";if(h===Jc)return"×";if(-1!==fu.indexOf(h)&&l===$c||-1!==fu.indexOf(l)&&h===$c)return"×";if(l===tu&&-1!==[lu,ru,ou].indexOf(h)||-1!==[lu,ru,ou].indexOf(l)&&h===eu)return"×";if(-1!==fu.indexOf(l)&&-1!==_u.indexOf(h)||-1!==_u.indexOf(l)&&-1!==fu.indexOf(h))return"×";if(-1!==[tu,eu].indexOf(l)&&(h===$c||-1!==[Zc,zc].indexOf(h)&&t[a+1]===$c)||-1!==[Zc,zc].indexOf(l)&&h===$c||l===$c&&-1!==[$c,iu,qc].indexOf(h))return"×";if(-1!==[$c,iu,qc,Wc,Kc].indexOf(h))for(var c=o;c>=0;){if((u=t[c])===$c)return"×";if(-1===[iu,qc].indexOf(u))break;c--}if(-1!==[tu,eu].indexOf(h))for(c=-1!==[Wc,Kc].indexOf(l)?n:o;c>=0;){var u;if((u=t[c])===$c)return"×";if(-1===[iu,qc].indexOf(u))break;c--}if(Au===l&&-1!==[Au,hu,nu,au].indexOf(h)||-1!==[hu,nu].indexOf(l)&&-1!==[hu,cu].indexOf(h)||-1!==[cu,au].indexOf(l)&&h===cu)return"×";if(-1!==bu.indexOf(l)&&-1!==[Jc,eu].indexOf(h)||-1!==bu.indexOf(h)&&l===tu)return"×";if(-1!==fu.indexOf(l)&&-1!==fu.indexOf(h))return"×";if(l===qc&&-1!==fu.indexOf(h))return"×";if(-1!==fu.concat($c).indexOf(l)&&h===Zc&&-1===du.indexOf(e[a])||-1!==fu.concat($c).indexOf(h)&&l===Kc)return"×";if(41===l&&41===h){for(var d=i[o],p=1;d>0&&41===t[--d];)p++;if(p%2!=0)return"×"}return l===ru&&h===ou?"×":"÷"},Pu=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=function(e,t){void 0===t&&(t="strict");var i=[],s=[],r=[];return e.forEach((function(e,o){var n=pu.get(e);if(n>50?(r.push(!0),n-=50):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return s.push(o),i.push(16);if(4===n||11===n){if(0===o)return s.push(o),i.push(su);var a=i[o-1];return-1===vu.indexOf(a)?(s.push(s[o-1]),i.push(a)):(s.push(o),i.push(su))}return s.push(o),31===n?i.push("strict"===t?Yc:lu):n===uu||29===n?i.push(su):43===n?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(lu):i.push(su):void i.push(n)})),[s,i,r]}(e,t.lineBreak),s=i[0],r=i[1],o=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[$c,su,uu].indexOf(e)?lu:e})));var n="keep-all"===t.wordBreak?o.map((function(t,i){return t&&e[i]>=19968&&e[i]<=40959})):void 0;return[s,r,n]},Cu=function(){function e(e,t,i,s){this.codePoints=e,this.required="!"===t,this.start=i,this.end=s}return e.prototype.slice=function(){return Dc.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),Mu=function(e){return e>=48&&e<=57},Fu=function(e){return Mu(e)||e>=65&&e<=70||e>=97&&e<=102},Eu=function(e){return 10===e||9===e||32===e},Iu=function(e){return function(e){return function(e){return e>=97&&e<=122}(e)||function(e){return e>=65&&e<=90}(e)}(e)||function(e){return e>=128}(e)||95===e},Du=function(e){return Iu(e)||Mu(e)||45===e},Su=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},Tu=function(e,t){return 92===e&&10!==t},Ru=function(e,t,i){return 45===e?Iu(t)||Tu(t,i):!!Iu(e)||!(92!==e||!Tu(e,t))},Lu=function(e,t,i){return 43===e||45===e?!!Mu(t)||46===t&&Mu(i):Mu(46===e?t:e)},Uu=function(e){var t=0,i=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(i=-1),t++);for(var s=[];Mu(e[t]);)s.push(e[t++]);var r=s.length?parseInt(Dc.apply(void 0,s),10):0;46===e[t]&&t++;for(var o=[];Mu(e[t]);)o.push(e[t++]);var n=o.length,a=n?parseInt(Dc.apply(void 0,o),10):0;69!==e[t]&&101!==e[t]||t++;var l=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(l=-1),t++);for(var A=[];Mu(e[t]);)A.push(e[t++]);var h=A.length?parseInt(Dc.apply(void 0,A),10):0;return i*(r+a*Math.pow(10,-n))*Math.pow(10,l*h)},ku={type:2},Ou={type:3},Nu={type:4},Qu={type:13},Vu={type:8},Hu={type:21},ju={type:9},Gu={type:10},zu={type:11},Wu={type:12},Ku={type:14},Xu={type:23},Ju={type:1},Yu={type:25},Zu={type:24},qu={type:26},$u={type:27},ed={type:28},td={type:29},id={type:31},sd={type:32},rd=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(Ic(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==sd;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(Du(t)||Tu(i,s)){var r=Ru(t,i,s)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Qu;break;case 39:return this.consumeStringToken(39);case 40:return ku;case 41:return Ou;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Ku;break;case 43:if(Lu(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return Nu;case 45:var o=e,n=this.peekCodePoint(0),a=this.peekCodePoint(1);if(Lu(o,n,a))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(Ru(o,n,a))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===n&&62===a)return this.consumeCodePoint(),this.consumeCodePoint(),Zu;break;case 46:if(Lu(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(42===l&&47===(l=this.consumeCodePoint()))return this.consumeToken();if(-1===l)return this.consumeToken()}break;case 58:return qu;case 59:return $u;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),Yu;break;case 64:var A=this.peekCodePoint(0),h=this.peekCodePoint(1),c=this.peekCodePoint(2);if(Ru(A,h,c))return{type:7,value:this.consumeName()};break;case 91:return ed;case 92:if(Tu(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return td;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Vu;break;case 123:return zu;case 125:return Wu;case 117:case 85:var u=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==u||!Fu(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),ju;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),Hu;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Gu;break;case-1:return sd}return Eu(e)?(this.consumeWhiteSpace(),id):Mu(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):Iu(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:Dc(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();Fu(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(Dc.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(Dc.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var s=parseInt(Dc.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&Fu(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Fu(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:s,end:parseInt(Dc.apply(void 0,r),16)}}return{type:30,start:s,end:s}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var t=this.peekCodePoint(0);if(39===t||34===t){var i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),Xu)}for(;;){var s=this.consumeCodePoint();if(-1===s||41===s)return{type:22,value:Dc.apply(void 0,e)};if(Eu(s))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:Dc.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Xu);if(34===s||39===s||40===s||Su(s))return this.consumeBadUrlRemnants(),Xu;if(92===s){if(!Tu(s,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),Xu;e.push(this.consumeEscapedCodePoint())}else e.push(s)}},e.prototype.consumeWhiteSpace=function(){for(;Eu(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;Tu(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var i=Math.min(5e4,e);t+=Dc.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var s=this._value[i];if(-1===s||void 0===s||s===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(10===s)return this._value.splice(0,i),Ju;if(92===s){var r=this._value[i+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):Tu(s,r)&&(t+=this.consumeStringSlice(i),t+=Dc(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=4,i=this.peekCodePoint(0);for(43!==i&&45!==i||e.push(this.consumeCodePoint());Mu(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var s=this.peekCodePoint(1);if(46===i&&Mu(s))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Mu(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),s=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===i||101===i)&&((43===s||45===s)&&Mu(r)||Mu(s)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Mu(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Uu(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],s=this.peekCodePoint(0),r=this.peekCodePoint(1),o=this.peekCodePoint(2);return Ru(s,r,o)?{type:15,number:t,flags:i,unit:this.consumeName()}:37===s?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Fu(e)){for(var t=Dc(e);Fu(this.peekCodePoint(0))&&t.length<6;)t+=Dc(this.consumeCodePoint());Eu(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||function(e){return e>=55296&&e<=57343}(i)||i>1114111?65533:i}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(Du(t))e+=Dc(t);else{if(!Tu(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=Dc(this.consumeEscapedCodePoint())}}},e}(),od=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new rd;return i.write(t),new e(i.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(32===i.type||pd(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?sd:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),nd=function(e){return 15===e.type},ad=function(e){return 17===e.type},ld=function(e){return 20===e.type},Ad=function(e){return 0===e.type},hd=function(e,t){return ld(e)&&e.value===t},cd=function(e){return 31!==e.type},ud=function(e){return 31!==e.type&&4!==e.type},dd=function(e){var t=[],i=[];return e.forEach((function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)})),i.length&&t.push(i),t},pd=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},fd=function(e){return 17===e.type||15===e.type},gd=function(e){return 16===e.type||fd(e)},md=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},_d={type:17,number:0,flags:4},vd={type:16,number:50,flags:4},bd={type:16,number:100,flags:4},yd=function(e,t,i){var s=e[0],r=e[1];return[xd(s,t),xd(void 0!==r?r:s,i)]},xd=function(e,t){if(16===e.type)return e.number/100*t;if(nd(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},Bd=function(e,t){if(15===t.type)switch(t.unit){case"deg":return Math.PI*t.number/180;case"grad":return Math.PI/200*t.number;case"rad":return t.number;case"turn":return 2*Math.PI*t.number}throw new Error("Unsupported angle type")},wd=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},Pd=function(e){switch(e.filter(ld).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[_d,_d];case"to top":case"bottom":return Cd(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[_d,bd];case"to right":case"left":return Cd(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[bd,bd];case"to bottom":case"top":return Cd(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[bd,_d];case"to left":case"right":return Cd(270)}return 0},Cd=function(e){return Math.PI*e/180},Md=function(e,t){if(18===t.type){var i=Ld[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var s=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);return Id(parseInt(s+s,16),parseInt(r+r,16),parseInt(o+o,16),1)}if(4===t.value.length){s=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);var n=t.value.substring(3,4);return Id(parseInt(s+s,16),parseInt(r+r,16),parseInt(o+o,16),parseInt(n+n,16)/255)}if(6===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6);return Id(parseInt(s,16),parseInt(r,16),parseInt(o,16),1)}if(8===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6),n=t.value.substring(6,8);return Id(parseInt(s,16),parseInt(r,16),parseInt(o,16),parseInt(n,16)/255)}}if(20===t.type){var a=kd[t.value.toUpperCase()];if(void 0!==a)return a}return kd.TRANSPARENT},Fd=function(e){return 0==(255&e)},Ed=function(e){var t=255&e,i=255&e>>8,s=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+s+","+i+","+t/255+")":"rgb("+r+","+s+","+i+")"},Id=function(e,t,i,s){return(e<<24|t<<16|i<<8|Math.round(255*s)<<0)>>>0},Dd=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},Sd=function(e,t){var i=t.filter(ud);if(3===i.length){var s=i.map(Dd),r=s[0],o=s[1],n=s[2];return Id(r,o,n,1)}if(4===i.length){var a=i.map(Dd),l=(r=a[0],o=a[1],n=a[2],a[3]);return Id(r,o,n,l)}return 0};function Td(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var Rd=function(e,t){var i=t.filter(ud),s=i[0],r=i[1],o=i[2],n=i[3],a=(17===s.type?Cd(s.number):Bd(e,s))/(2*Math.PI),l=gd(r)?r.number/100:0,A=gd(o)?o.number/100:0,h=void 0!==n&&gd(n)?xd(n,1):1;if(0===l)return Id(255*A,255*A,255*A,1);var c=A<=.5?A*(l+1):A+l-A*l,u=2*A-c,d=Td(u,c,a+1/3),p=Td(u,c,a),f=Td(u,c,a-1/3);return Id(255*d,255*p,255*f,h)},Ld={hsl:Rd,hsla:Rd,rgb:Sd,rgba:Sd},Ud=function(e,t){return Md(e,od.create(t).parseComponentValue())},kd={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Od={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(ld(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Nd={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Qd=function(e,t){var i=Md(e,t[0]),s=t[1];return s&&gd(s)?{color:i,stop:s}:{color:i,stop:null}},Vd=function(e,t){var i=e[0],s=e[e.length-1];null===i.stop&&(i.stop=_d),null===s.stop&&(s.stop=bd);for(var r=[],o=0,n=0;no?r.push(l):r.push(o),o=l}else r.push(null)}var A=null;for(n=0;ne.optimumDistance)?{optimumCorner:t,optimumDistance:a}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},zd=function(e,t){var i=Cd(180),s=[];return dd(t).forEach((function(t,r){if(0===r){var o=t[0];if(20===o.type&&-1!==["top","left","right","bottom"].indexOf(o.value))return void(i=Pd(t));if(wd(o))return void(i=(Bd(e,o)+Cd(270))%Cd(360))}var n=Qd(e,t);s.push(n)})),{angle:i,stops:s,type:1}},Wd=function(e,t){var i=0,s=3,r=[],o=[];return dd(t).forEach((function(t,n){var a=!0;if(0===n?a=t.reduce((function(e,t){if(ld(t))switch(t.value){case"center":return o.push(vd),!1;case"top":case"left":return o.push(_d),!1;case"right":case"bottom":return o.push(bd),!1}else if(gd(t)||fd(t))return o.push(t),!1;return e}),a):1===n&&(a=t.reduce((function(e,t){if(ld(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"contain":case"closest-side":return s=0,!1;case"farthest-side":return s=1,!1;case"closest-corner":return s=2,!1;case"cover":case"farthest-corner":return s=3,!1}else if(fd(t)||gd(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)),a){var l=Qd(e,t);r.push(l)}})),{size:s,shape:i,stops:r,position:o,type:2}},Kd=function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var s=Jd[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(e,t.values)}throw new Error("Unsupported image type "+t.type)};var Xd,Jd={"linear-gradient":function(e,t){var i=Cd(180),s=[];return dd(t).forEach((function(t,r){if(0===r){var o=t[0];if(20===o.type&&"to"===o.value)return void(i=Pd(t));if(wd(o))return void(i=Bd(e,o))}var n=Qd(e,t);s.push(n)})),{angle:i,stops:s,type:1}},"-moz-linear-gradient":zd,"-ms-linear-gradient":zd,"-o-linear-gradient":zd,"-webkit-linear-gradient":zd,"radial-gradient":function(e,t){var i=0,s=3,r=[],o=[];return dd(t).forEach((function(t,n){var a=!0;if(0===n){var l=!1;a=t.reduce((function(e,t){if(l)if(ld(t))switch(t.value){case"center":return o.push(vd),e;case"top":case"left":return o.push(_d),e;case"right":case"bottom":return o.push(bd),e}else(gd(t)||fd(t))&&o.push(t);else if(ld(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"at":return l=!0,!1;case"closest-side":return s=0,!1;case"cover":case"farthest-side":return s=1,!1;case"contain":case"closest-corner":return s=2,!1;case"farthest-corner":return s=3,!1}else if(fd(t)||gd(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)}if(a){var A=Qd(e,t);r.push(A)}})),{size:s,shape:i,stops:r,position:o,type:2}},"-moz-radial-gradient":Wd,"-ms-radial-gradient":Wd,"-o-radial-gradient":Wd,"-webkit-radial-gradient":Wd,"-webkit-gradient":function(e,t){var i=Cd(180),s=[],r=1;return dd(t).forEach((function(t,i){var o=t[0];if(0===i){if(ld(o)&&"linear"===o.value)return void(r=1);if(ld(o)&&"radial"===o.value)return void(r=2)}if(18===o.type)if("from"===o.name){var n=Md(e,o.values[0]);s.push({stop:_d,color:n})}else if("to"===o.name){n=Md(e,o.values[0]);s.push({stop:bd,color:n})}else if("color-stop"===o.name){var a=o.values.filter(ud);if(2===a.length){n=Md(e,a[1]);var l=a[0];ad(l)&&s.push({stop:{type:16,number:100*l.number,flags:l.flags},color:n})}}})),1===r?{angle:(i+Cd(180))%Cd(360),stops:s,type:r}:{size:3,shape:0,stops:s,position:[],type:r}}},Yd={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter((function(e){return ud(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Jd[e.name])}(e)})).map((function(t){return Kd(e,t)}))}},Zd={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(ld(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},qd={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return dd(t).map((function(e){return e.filter(gd)})).map(md)}},$d={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return dd(t).map((function(e){return e.filter(ld).map((function(e){return e.value})).join(" ")})).map(ep)}},ep=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Xd||(Xd={}));var tp,ip={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return dd(t).map((function(e){return e.filter(sp)}))}},sp=function(e){return ld(e)||gd(e)},rp=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},op=rp("top"),np=rp("right"),ap=rp("bottom"),lp=rp("left"),Ap=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return md(t.filter(gd))}}},hp=Ap("top-left"),cp=Ap("top-right"),up=Ap("bottom-right"),dp=Ap("bottom-left"),pp=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},fp=pp("top"),gp=pp("right"),mp=pp("bottom"),_p=pp("left"),vp=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return nd(t)?t.number:0}}},bp=vp("top"),yp=vp("right"),xp=vp("bottom"),Bp=vp("left"),wp={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Pp={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},Cp={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(ld).reduce((function(e,t){return e|Mp(t.value)}),0)}},Mp=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},Fp={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Ep={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(tp||(tp={}));var Ip,Dp={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?tp.STRICT:tp.NORMAL}},Sp={name:"line-height",initialValue:"normal",prefix:!1,type:4},Tp=function(e,t){return ld(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:gd(e)?xd(e,t):t},Rp={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:Kd(e,t)}},Lp={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Up={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},kp=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},Op=kp("top"),Np=kp("right"),Qp=kp("bottom"),Vp=kp("left"),Hp={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(ld).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},jp={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Gp=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},zp=Gp("top"),Wp=Gp("right"),Kp=Gp("bottom"),Xp=Gp("left"),Jp={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Yp={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Zp={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&hd(t[0],"none")?[]:dd(t).map((function(t){for(var i={color:kd.TRANSPARENT,offsetX:_d,offsetY:_d,blur:_d},s=0,r=0;r1?1:0],this.overflowWrap=Df(e,jp,t.overflowWrap),this.paddingTop=Df(e,zp,t.paddingTop),this.paddingRight=Df(e,Wp,t.paddingRight),this.paddingBottom=Df(e,Kp,t.paddingBottom),this.paddingLeft=Df(e,Xp,t.paddingLeft),this.paintOrder=Df(e,Pf,t.paintOrder),this.position=Df(e,Yp,t.position),this.textAlign=Df(e,Jp,t.textAlign),this.textDecorationColor=Df(e,hf,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=Df(e,cf,null!==(s=t.textDecorationLine)&&void 0!==s?s:t.textDecoration),this.textShadow=Df(e,Zp,t.textShadow),this.textTransform=Df(e,qp,t.textTransform),this.transform=Df(e,$p,t.transform),this.transformOrigin=Df(e,rf,t.transformOrigin),this.visibility=Df(e,of,t.visibility),this.webkitTextStrokeColor=Df(e,Cf,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=Df(e,Mf,t.webkitTextStrokeWidth),this.wordBreak=Df(e,nf,t.wordBreak),this.zIndex=Df(e,af,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return Fd(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return mf(this.display,4)||mf(this.display,33554432)||mf(this.display,268435456)||mf(this.display,536870912)||mf(this.display,67108864)||mf(this.display,134217728)},e}(),Ef=function(e,t){this.content=Df(e,_f,t.content),this.quotes=Df(e,xf,t.quotes)},If=function(e,t){this.counterIncrement=Df(e,vf,t.counterIncrement),this.counterReset=Df(e,bf,t.counterReset)},Df=function(e,t,i){var s=new rd,r=null!=i?i.toString():t.initialValue;s.write(r);var o=new od(s.read());switch(t.type){case 2:var n=o.parseComponentValue();return t.parse(e,ld(n)?n.value:t.initialValue);case 0:return t.parse(e,o.parseComponentValue());case 1:return t.parse(e,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case"angle":return Bd(e,o.parseComponentValue());case"color":return Md(e,o.parseComponentValue());case"image":return Kd(e,o.parseComponentValue());case"length":var a=o.parseComponentValue();return fd(a)?a:_d;case"length-percentage":var l=o.parseComponentValue();return gd(l)?l:_d;case"time":return lf(e,o.parseComponentValue())}}},Sf=function(e,t){var i=function(e){switch(e.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(e);return 1===i||t===i},Tf=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Sf(t,3),this.styles=new Ff(e,window.getComputedStyle(t,null)),Tg(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=Ec(this.context,t),Sf(t,4)&&(this.flags|=16)},Rf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Lf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Uf=0;Uf=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Nf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Qf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Vf=0;Vf>10),n%1024+56320)),(r+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Xf=function(e,t){var i,s,r,o=function(e){var t,i,s,r,o,n=.75*e.length,a=e.length,l=0;"="===e[e.length-1]&&(n--,"="===e[e.length-2]&&n--);var A="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(n):new Array(n),h=Array.isArray(A)?A:new Uint8Array(A);for(t=0;t>4,h[l++]=(15&s)<<4|r>>2,h[l++]=(3&r)<<6|63&o;return A}(e),n=Array.isArray(o)?function(e){for(var t=e.length,i=[],s=0;s=55296&&r<=56319&&i=i)return{done:!0,value:null};for(var e="×";sn.x||r.y>n.y;return n=r,0===t||a}));return e.body.removeChild(t),a}(document);return Object.defineProperty(tg,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,i=e.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,";try{s.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(tg,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?function(e){var t=e.createElement("canvas"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var r=new Image,o=t.toDataURL();r.src=o;var n=$f(i,i,0,0,r);return s.fillStyle="red",s.fillRect(0,0,i,i),eg(n).then((function(t){s.drawImage(t,0,0);var r=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var n=e.createElement("div");return n.style.backgroundImage="url("+o+")",n.style.height="100px",qf(r)?eg($f(i,i,0,0,n)):Promise.reject(!1)})).then((function(e){return s.drawImage(e,0,0),qf(s.getImageData(0,0,i,i).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(tg,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(tg,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(tg,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(tg,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(tg,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},ig=function(e,t){this.text=e,this.bounds=t},sg=function(e,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(s,t);var o=Ec(e,s);return s.firstChild&&r.replaceChild(s.firstChild,s),o}}return Fc.EMPTY},rg=function(e,t,i){var s=e.ownerDocument;if(!s)throw new Error("Node has no owner document");var r=s.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},og=function(e){if(tg.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return function(e){for(var t,i=Zf(e),s=[];!(t=i.next()).done;)t.value&&s.push(t.value.slice());return s}(e)},ng=function(e,t){return 0!==t.letterSpacing?og(e):function(e,t){if(tg.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map((function(e){return e.segment}))}return lg(e,t)}(e,t)},ag=[32,160,4961,65792,65793,4153,4241],lg=function(e,t){for(var i,s=function(e,t){var i=Ic(e),s=Pu(i,t),r=s[0],o=s[1],n=s[2],a=i.length,l=0,A=0;return{next:function(){if(A>=a)return{done:!0,value:null};for(var e="×";A0)if(tg.SUPPORT_RANGE_BOUNDS){var r=rg(s,n,t.length).getClientRects();if(r.length>1){var a=og(t),l=0;a.forEach((function(t){o.push(new ig(t,Fc.fromDOMRectList(e,rg(s,l+n,t.length).getClientRects()))),l+=t.length}))}else o.push(new ig(t,Fc.fromDOMRectList(e,r)))}else{var A=s.splitText(t.length);o.push(new ig(t,sg(e,s))),s=A}else tg.SUPPORT_RANGE_BOUNDS||(s=s.splitText(t.length));n+=t.length})),o}(e,this.text,i,t)},hg=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(cg,ug);case 2:return e.toUpperCase();default:return e}},cg=/(^|\s|:|-|\(|\))([a-z])/g,ug=function(e,t,i){return e.length>0?t+i.toUpperCase():e},dg=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.src=i.currentSrc||i.src,s.intrinsicWidth=i.naturalWidth,s.intrinsicHeight=i.naturalHeight,s.context.cache.addImage(s.src),s}return Bc(t,e),t}(Tf),pg=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i,s.intrinsicWidth=i.width,s.intrinsicHeight=i.height,s}return Bc(t,e),t}(Tf),fg=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=new XMLSerializer,o=Ec(t,i);return i.setAttribute("width",o.width+"px"),i.setAttribute("height",o.height+"px"),s.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),s.intrinsicWidth=i.width.baseVal.value,s.intrinsicHeight=i.height.baseVal.value,s.context.cache.addImage(s.svg),s}return Bc(t,e),t}(Tf),gg=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return Bc(t,e),t}(Tf),mg=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.start=i.start,s.reversed="boolean"==typeof i.reversed&&!0===i.reversed,s}return Bc(t,e),t}(Tf),_g=[{type:15,flags:0,unit:"px",number:3}],vg=[{type:16,flags:0,number:50}],bg="password",yg=function(e){function t(t,i){var s,r=e.call(this,t,i)||this;switch(r.type=i.type.toLowerCase(),r.checked=i.checked,r.value=function(e){var t=e.type===bg?new Array(e.value.length+1).join("•"):e.value;return 0===t.length?e.placeholder||"":t}(i),"checkbox"!==r.type&&"radio"!==r.type||(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=(s=r.bounds).width>s.height?new Fc(s.left+(s.width-s.height)/2,s.top,s.height,s.height):s.width0)i.textNodes.push(new Ag(e,r,i.styles));else if(Sg(r))if(Kg(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return Cg(e,t,i,s)}));else{var n=Mg(e,r);n.styles.isVisible()&&(Eg(r,n,s)?n.flags|=4:Ig(n.styles)&&(n.flags|=2),-1!==Pg.indexOf(r.tagName)&&(n.flags|=8),i.elements.push(n),r.slot,r.shadowRoot?Cg(e,r.shadowRoot,n,s):zg(r)||Og(r)||Wg(r)||Cg(e,r,n,s))}},Mg=function(e,t){return Hg(t)?new dg(e,t):Qg(t)?new pg(e,t):Og(t)?new fg(e,t):Lg(t)?new gg(e,t):Ug(t)?new mg(e,t):kg(t)?new yg(e,t):Wg(t)?new xg(e,t):zg(t)?new Bg(e,t):jg(t)?new wg(e,t):new Tf(e,t)},Fg=function(e,t){var i=Mg(e,t);return i.flags|=4,Cg(e,t,i,i),i},Eg=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||Ng(e)&&i.styles.isTransparent()},Ig=function(e){return e.isPositioned()||e.isFloating()},Dg=function(e){return e.nodeType===Node.TEXT_NODE},Sg=function(e){return e.nodeType===Node.ELEMENT_NODE},Tg=function(e){return Sg(e)&&void 0!==e.style&&!Rg(e)},Rg=function(e){return"object"==typeof e.className},Lg=function(e){return"LI"===e.tagName},Ug=function(e){return"OL"===e.tagName},kg=function(e){return"INPUT"===e.tagName},Og=function(e){return"svg"===e.tagName},Ng=function(e){return"BODY"===e.tagName},Qg=function(e){return"CANVAS"===e.tagName},Vg=function(e){return"VIDEO"===e.tagName},Hg=function(e){return"IMG"===e.tagName},jg=function(e){return"IFRAME"===e.tagName},Gg=function(e){return"STYLE"===e.tagName},zg=function(e){return"TEXTAREA"===e.tagName},Wg=function(e){return"SELECT"===e.tagName},Kg=function(e){return"SLOT"===e.tagName},Xg=function(e){return e.tagName.indexOf("-")>0},Jg=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,i=e.counterIncrement,s=e.counterReset,r=!0;null!==i&&i.forEach((function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)}));var o=[];return r&&s.forEach((function(e){var i=t.counters[e.counter];o.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)})),o},e}(),Yg={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},Zg={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},qg={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},$g={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},em=function(e,t,i,s,r,o){return ei?om(e,r,o.length>0):s.integers.reduce((function(t,i,r){for(;e>=i;)e-=i,t+=s.values[r];return t}),"")+o},tm=function(e,t,i,s){var r="";do{i||e--,r=s(e)+r,e/=t}while(e*t>=t);return r},im=function(e,t,i,s,r){var o=i-t+1;return(e<0?"-":"")+(tm(Math.abs(e),o,s,(function(e){return Dc(Math.floor(e%o)+t)}))+r)},sm=function(e,t,i){void 0===i&&(i=". ");var s=t.length;return tm(Math.abs(e),s,!1,(function(e){return t[Math.floor(e%s)]}))+i},rm=function(e,t,i,s,r,o){if(e<-9999||e>9999)return om(e,4,r.length>0);var n=Math.abs(e),a=r;if(0===n)return t[0]+a;for(var l=0;n>0&&l<=4;l++){var A=n%10;0===A&&mf(o,1)&&""!==a?a=t[A]+a:A>1||1===A&&0===l||1===A&&1===l&&mf(o,2)||1===A&&1===l&&mf(o,4)&&e>100||1===A&&l>1&&mf(o,8)?a=t[A]+(l>0?i[l-1]:"")+a:1===A&&l>0&&(a=i[l-1]+a),n=Math.floor(n/10)}return(e<0?s:"")+a},om=function(e,t,i){var s=i?". ":"",r=i?"、":"",o=i?", ":"",n=i?" ":"";switch(t){case 0:return"•"+n;case 1:return"◦"+n;case 2:return"◾"+n;case 5:var a=im(e,48,57,!0,s);return a.length<4?"0"+a:a;case 4:return sm(e,"〇一二三四五六七八九",r);case 6:return em(e,1,3999,Yg,3,s).toLowerCase();case 7:return em(e,1,3999,Yg,3,s);case 8:return im(e,945,969,!1,s);case 9:return im(e,97,122,!1,s);case 10:return im(e,65,90,!1,s);case 11:return im(e,1632,1641,!0,s);case 12:case 49:return em(e,1,9999,Zg,3,s);case 35:return em(e,1,9999,Zg,3,s).toLowerCase();case 13:return im(e,2534,2543,!0,s);case 14:case 30:return im(e,6112,6121,!0,s);case 15:return sm(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return sm(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return rm(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return rm(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return rm(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return rm(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return rm(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return rm(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return rm(e,"영일이삼사오육칠팔구","십백천만","마이너스",o,7);case 33:return rm(e,"零一二三四五六七八九","十百千萬","마이너스",o,0);case 32:return rm(e,"零壹貳參四五六七八九","拾百千","마이너스",o,7);case 18:return im(e,2406,2415,!0,s);case 20:return em(e,1,19999,$g,3,s);case 21:return im(e,2790,2799,!0,s);case 22:return im(e,2662,2671,!0,s);case 22:return em(e,1,10999,qg,3,s);case 23:return sm(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return sm(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return im(e,3302,3311,!0,s);case 28:return sm(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return sm(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return im(e,3792,3801,!0,s);case 37:return im(e,6160,6169,!0,s);case 38:return im(e,4160,4169,!0,s);case 39:return im(e,2918,2927,!0,s);case 40:return im(e,1776,1785,!0,s);case 43:return im(e,3046,3055,!0,s);case 44:return im(e,3174,3183,!0,s);case 45:return im(e,3664,3673,!0,s);case 46:return im(e,3872,3881,!0,s);default:return im(e,48,57,!0,s)}},nm=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new Jg,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var i=this,s=lm(e,t);if(!s.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,o=e.defaultView.pageYOffset,n=s.contentWindow,a=n.document,l=cm(s).then((function(){return Pc(i,void 0,void 0,(function(){var e,i;return Cc(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(gm),n&&(n.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||n.scrollY===t.top&&n.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(n.scrollX-t.left,n.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(i=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:a.fonts&&a.fonts.ready?[4,a.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,hm(a)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(a,i)})).then((function(){return s}))]:[2,s]}}))}))}));return a.open(),a.write(pm(document.doctype)+""),fm(this.referenceElement.ownerDocument,r,o),a.replaceChild(a.adoptNode(this.documentElement),a.documentElement),a.close(),l},e.prototype.createElementClone=function(e){if(Sf(e,2),Qg(e))return this.createCanvasClone(e);if(Vg(e))return this.createVideoClone(e);if(Gg(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Hg(t)&&(Hg(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),Xg(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return dm(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),s=e.cloneNode(!1);return s.textContent=i,s}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var s=e.cloneNode(!1);try{s.width=e.width,s.height=e.height;var r=e.getContext("2d"),o=s.getContext("2d");if(o)if(!this.options.allowTaint&&r)o.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var n=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(n){var a=n.getContextAttributes();!1===(null==a?void 0:a.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}o.drawImage(e,0,0)}return s}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return s},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var s=e.ownerDocument.createElement("canvas");return s.width=e.offsetWidth,s.height=e.offsetHeight,s},e.prototype.appendChildNode=function(e,t,i){Sg(t)&&(function(e){return"SCRIPT"===e.tagName}(t)||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&Sg(t)&&Gg(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var s=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(Sg(r)&&Kg(r)&&"function"==typeof r.assignedNodes){var o=r.assignedNodes();o.length&&o.forEach((function(e){return s.appendChildNode(t,e,i)}))}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(Dg(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&Sg(e)&&(Tg(e)||Rg(e))){var s=this.createElementClone(e);s.style.transitionProperty="none";var r=i.getComputedStyle(e),o=i.getComputedStyle(e,":before"),n=i.getComputedStyle(e,":after");this.referenceElement===e&&Tg(s)&&(this.clonedReferenceElement=s),Ng(s)&&vm(s);var a=this.counters.parse(new If(this.context,r)),l=this.resolvePseudoContent(e,s,o,Hf.BEFORE);Xg(e)&&(t=!0),Vg(e)||this.cloneChildNodes(e,s,t),l&&s.insertBefore(l,s.firstChild);var A=this.resolvePseudoContent(e,s,n,Hf.AFTER);return A&&s.appendChild(A),this.counters.pop(a),(r&&(this.options.copyStyles||Rg(e))&&!jg(e)||t)&&dm(r,s),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([s,e.scrollLeft,e.scrollTop]),(zg(e)||Wg(e))&&(zg(s)||Wg(s))&&(s.value=e.value),s}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,s){var r=this;if(i){var o=i.content,n=t.ownerDocument;if(n&&o&&"none"!==o&&"-moz-alt-content"!==o&&"none"!==i.display){this.counters.parse(new If(this.context,i));var a=new Ef(this.context,i),l=n.createElement("html2canvaspseudoelement");dm(i,l),a.content.forEach((function(t){if(0===t.type)l.appendChild(n.createTextNode(t.value));else if(22===t.type){var i=n.createElement("img");i.src=t.value,i.style.opacity="1",l.appendChild(i)}else if(18===t.type){if("attr"===t.name){var s=t.values.filter(ld);s.length&&l.appendChild(n.createTextNode(e.getAttribute(s[0].value)||""))}else if("counter"===t.name){var o=t.values.filter(ud),A=o[0],h=o[1];if(A&&ld(A)){var c=r.counters.getCounterValue(A.value),u=h&&ld(h)?Up.parse(r.context,h.value):3;l.appendChild(n.createTextNode(om(c,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(ud),p=(A=d[0],d[1]);h=d[2];if(A&&ld(A)){var f=r.counters.getCounterValues(A.value),g=h&&ld(h)?Up.parse(r.context,h.value):3,m=p&&0===p.type?p.value:"",_=f.map((function(e){return om(e,g,!1)})).join(m);l.appendChild(n.createTextNode(_))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(n.createTextNode(Bf(a.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(n.createTextNode(Bf(a.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(n.createTextNode(t.value))}})),l.className=mm+" "+_m;var A=s===Hf.BEFORE?" "+mm:" "+_m;return Rg(t)?t.className.baseValue+=A:t.className+=A,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(Hf||(Hf={}));var am,lm=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(i),i},Am=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},hm=function(e){return Promise.all([].slice.call(e.images,0).map(Am))},cm=function(e){return new Promise((function(t,i){var s=e.contentWindow;if(!s)return i("No window assigned for iframe");var r=s.document;s.onload=e.onload=function(){s.onload=e.onload=null;var i=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))}),50)}}))},um=["all","d","content"],dm=function(e,t){for(var i=e.length-1;i>=0;i--){var s=e.item(i);-1===um.indexOf(s)&&t.style.setProperty(s,e.getPropertyValue(s))}return t},pm=function(e){var t="";return e&&(t+=""),t},fm=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},gm=function(e){var t=e[0],i=e[1],s=e[2];t.scrollLeft=i,t.scrollTop=s},mm="___html2canvas___pseudoelement_before",_m="___html2canvas___pseudoelement_after",vm=function(e){bm(e,"."+mm+':before{\n content: "" !important;\n display: none !important;\n}\n .'+_m+':after{\n content: "" !important;\n display: none !important;\n}')},bm=function(e,t){var i=e.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,e.appendChild(s)}},ym=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),xm=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:Em(e)||Cm(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return Pc(this,void 0,void 0,(function(){var t,i,s,r,o=this;return Cc(this,(function(n){switch(n.label){case 0:return t=ym.isSameOrigin(e),i=!Mm(e)&&!0===this._options.useCORS&&tg.SUPPORT_CORS_IMAGES&&!t,s=!Mm(e)&&!t&&!Em(e)&&"string"==typeof this._options.proxy&&tg.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||Mm(e)||Em(e)||s||i?(r=e,s?[4,this.proxy(r)]:[3,2]):[2];case 1:r=n.sent(),n.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var s=new Image;s.onload=function(){return e(s)},s.onerror=t,(Fm(r)||i)&&(s.crossOrigin="anonymous"),s.src=r,!0===s.complete&&setTimeout((function(){return e(s)}),500),o._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+o._options.imageTimeout+"ms) loading image")}),o._options.imageTimeout)}))];case 3:return[2,n.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var s=e.substring(0,256);return new Promise((function(r,o){var n=tg.SUPPORT_RESPONSE_TYPE?"blob":"text",a=new XMLHttpRequest;a.onload=function(){if(200===a.status)if("text"===n)r(a.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return o(e)}),!1),e.readAsDataURL(a.response)}else o("Failed to proxy resource "+s+" with status code "+a.status)},a.onerror=o;var l=i.indexOf("?")>-1?"&":"?";if(a.open("GET",""+i+l+"url="+encodeURIComponent(e)+"&responseType="+n),"text"!==n&&a instanceof XMLHttpRequest&&(a.responseType=n),t._options.imageTimeout){var A=t._options.imageTimeout;a.timeout=A,a.ontimeout=function(){return o("Timed out ("+A+"ms) proxying "+s)}}a.send()}))},e}(),Bm=/^data:image\/svg\+xml/i,wm=/^data:image\/.*;base64,/i,Pm=/^data:image\/.*/i,Cm=function(e){return tg.SUPPORT_SVG_DRAWING||!Im(e)},Mm=function(e){return Pm.test(e)},Fm=function(e){return wm.test(e)},Em=function(e){return"blob"===e.substr(0,4)},Im=function(e){return"svg"===e.substr(-3).toLowerCase()||Bm.test(e)},Dm=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),Sm=function(e,t,i){return new Dm(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},Tm=function(){function e(e,t,i,s){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=s}return e.prototype.subdivide=function(t,i){var s=Sm(this.start,this.startControl,t),r=Sm(this.startControl,this.endControl,t),o=Sm(this.endControl,this.end,t),n=Sm(s,r,t),a=Sm(r,o,t),l=Sm(n,a,t);return i?new e(this.start,s,n,l):new e(l,a,o,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),Rm=function(e){return 1===e.type},Lm=function(e){var t=e.styles,i=e.bounds,s=yd(t.borderTopLeftRadius,i.width,i.height),r=s[0],o=s[1],n=yd(t.borderTopRightRadius,i.width,i.height),a=n[0],l=n[1],A=yd(t.borderBottomRightRadius,i.width,i.height),h=A[0],c=A[1],u=yd(t.borderBottomLeftRadius,i.width,i.height),d=u[0],p=u[1],f=[];f.push((r+a)/i.width),f.push((d+h)/i.width),f.push((o+p)/i.height),f.push((l+c)/i.height);var g=Math.max.apply(Math,f);g>1&&(r/=g,o/=g,a/=g,l/=g,h/=g,c/=g,d/=g,p/=g);var m=i.width-a,_=i.height-c,v=i.width-h,b=i.height-p,y=t.borderTopWidth,x=t.borderRightWidth,B=t.borderBottomWidth,w=t.borderLeftWidth,P=xd(t.paddingTop,e.bounds.width),C=xd(t.paddingRight,e.bounds.width),M=xd(t.paddingBottom,e.bounds.width),F=xd(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||o>0?Um(i.left+w/3,i.top+y/3,r-w/3,o-y/3,am.TOP_LEFT):new Dm(i.left+w/3,i.top+y/3),this.topRightBorderDoubleOuterBox=r>0||o>0?Um(i.left+m,i.top+y/3,a-x/3,l-y/3,am.TOP_RIGHT):new Dm(i.left+i.width-x/3,i.top+y/3),this.bottomRightBorderDoubleOuterBox=h>0||c>0?Um(i.left+v,i.top+_,h-x/3,c-B/3,am.BOTTOM_RIGHT):new Dm(i.left+i.width-x/3,i.top+i.height-B/3),this.bottomLeftBorderDoubleOuterBox=d>0||p>0?Um(i.left+w/3,i.top+b,d-w/3,p-B/3,am.BOTTOM_LEFT):new Dm(i.left+w/3,i.top+i.height-B/3),this.topLeftBorderDoubleInnerBox=r>0||o>0?Um(i.left+2*w/3,i.top+2*y/3,r-2*w/3,o-2*y/3,am.TOP_LEFT):new Dm(i.left+2*w/3,i.top+2*y/3),this.topRightBorderDoubleInnerBox=r>0||o>0?Um(i.left+m,i.top+2*y/3,a-2*x/3,l-2*y/3,am.TOP_RIGHT):new Dm(i.left+i.width-2*x/3,i.top+2*y/3),this.bottomRightBorderDoubleInnerBox=h>0||c>0?Um(i.left+v,i.top+_,h-2*x/3,c-2*B/3,am.BOTTOM_RIGHT):new Dm(i.left+i.width-2*x/3,i.top+i.height-2*B/3),this.bottomLeftBorderDoubleInnerBox=d>0||p>0?Um(i.left+2*w/3,i.top+b,d-2*w/3,p-2*B/3,am.BOTTOM_LEFT):new Dm(i.left+2*w/3,i.top+i.height-2*B/3),this.topLeftBorderStroke=r>0||o>0?Um(i.left+w/2,i.top+y/2,r-w/2,o-y/2,am.TOP_LEFT):new Dm(i.left+w/2,i.top+y/2),this.topRightBorderStroke=r>0||o>0?Um(i.left+m,i.top+y/2,a-x/2,l-y/2,am.TOP_RIGHT):new Dm(i.left+i.width-x/2,i.top+y/2),this.bottomRightBorderStroke=h>0||c>0?Um(i.left+v,i.top+_,h-x/2,c-B/2,am.BOTTOM_RIGHT):new Dm(i.left+i.width-x/2,i.top+i.height-B/2),this.bottomLeftBorderStroke=d>0||p>0?Um(i.left+w/2,i.top+b,d-w/2,p-B/2,am.BOTTOM_LEFT):new Dm(i.left+w/2,i.top+i.height-B/2),this.topLeftBorderBox=r>0||o>0?Um(i.left,i.top,r,o,am.TOP_LEFT):new Dm(i.left,i.top),this.topRightBorderBox=a>0||l>0?Um(i.left+m,i.top,a,l,am.TOP_RIGHT):new Dm(i.left+i.width,i.top),this.bottomRightBorderBox=h>0||c>0?Um(i.left+v,i.top+_,h,c,am.BOTTOM_RIGHT):new Dm(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=d>0||p>0?Um(i.left,i.top+b,d,p,am.BOTTOM_LEFT):new Dm(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||o>0?Um(i.left+w,i.top+y,Math.max(0,r-w),Math.max(0,o-y),am.TOP_LEFT):new Dm(i.left+w,i.top+y),this.topRightPaddingBox=a>0||l>0?Um(i.left+Math.min(m,i.width-x),i.top+y,m>i.width+x?0:Math.max(0,a-x),Math.max(0,l-y),am.TOP_RIGHT):new Dm(i.left+i.width-x,i.top+y),this.bottomRightPaddingBox=h>0||c>0?Um(i.left+Math.min(v,i.width-w),i.top+Math.min(_,i.height-B),Math.max(0,h-x),Math.max(0,c-B),am.BOTTOM_RIGHT):new Dm(i.left+i.width-x,i.top+i.height-B),this.bottomLeftPaddingBox=d>0||p>0?Um(i.left+w,i.top+Math.min(b,i.height-B),Math.max(0,d-w),Math.max(0,p-B),am.BOTTOM_LEFT):new Dm(i.left+w,i.top+i.height-B),this.topLeftContentBox=r>0||o>0?Um(i.left+w+F,i.top+y+P,Math.max(0,r-(w+F)),Math.max(0,o-(y+P)),am.TOP_LEFT):new Dm(i.left+w+F,i.top+y+P),this.topRightContentBox=a>0||l>0?Um(i.left+Math.min(m,i.width+w+F),i.top+y+P,m>i.width+w+F?0:a-w+F,l-(y+P),am.TOP_RIGHT):new Dm(i.left+i.width-(x+C),i.top+y+P),this.bottomRightContentBox=h>0||c>0?Um(i.left+Math.min(v,i.width-(w+F)),i.top+Math.min(_,i.height+y+P),Math.max(0,h-(x+C)),c-(B+M),am.BOTTOM_RIGHT):new Dm(i.left+i.width-(x+C),i.top+i.height-(B+M)),this.bottomLeftContentBox=d>0||p>0?Um(i.left+w+F,i.top+b,Math.max(0,d-(w+F)),p-(B+M),am.BOTTOM_LEFT):new Dm(i.left+w+F,i.top+i.height-(B+M))};!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(am||(am={}));var Um=function(e,t,i,s,r){var o=(Math.sqrt(2)-1)/3*4,n=i*o,a=s*o,l=e+i,A=t+s;switch(r){case am.TOP_LEFT:return new Tm(new Dm(e,A),new Dm(e,A-a),new Dm(l-n,t),new Dm(l,t));case am.TOP_RIGHT:return new Tm(new Dm(e,t),new Dm(e+n,t),new Dm(l,A-a),new Dm(l,A));case am.BOTTOM_RIGHT:return new Tm(new Dm(l,t),new Dm(l,t+a),new Dm(e+n,A),new Dm(e,A));case am.BOTTOM_LEFT:default:return new Tm(new Dm(l,A),new Dm(l-n,A),new Dm(e,t+a),new Dm(e,t))}},km=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Om=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},Nm=function(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6},Qm=function(e,t){this.path=e,this.target=t,this.type=1},Vm=function(e){this.opacity=e,this.type=2,this.target=6},Hm=function(e){return 1===e.type},jm=function(e,t){return e.length===t.length&&e.some((function(e,i){return e===t[i]}))},Gm=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},zm=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Lm(this.container),this.container.styles.opacity<1&&this.effects.push(new Vm(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,s=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new Nm(i,s,r))}if(0!==this.container.styles.overflowX){var o=km(this.curves),n=Om(this.curves);jm(o,n)?this.effects.push(new Qm(o,6)):(this.effects.push(new Qm(o,2)),this.effects.push(new Qm(n,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,s=this.effects.slice(0);i;){var r=i.effects.filter((function(e){return!Hm(e)}));if(t||0!==i.container.styles.position||!i.parent){if(s.unshift.apply(s,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var o=km(i.curves),n=Om(i.curves);jm(o,n)||s.unshift(new Qm(n,6))}}else s.unshift.apply(s,r);i=i.parent}return s.filter((function(t){return mf(t.target,e)}))},e}(),Wm=function(e,t,i,s){e.container.elements.forEach((function(r){var o=mf(r.flags,4),n=mf(r.flags,2),a=new zm(r,e);mf(r.styles.display,2048)&&s.push(a);var l=mf(r.flags,8)?[]:s;if(o||n){var A=o||r.styles.isPositioned()?i:t,h=new Gm(a);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var c=r.styles.zIndex.order;if(c<0){var u=0;A.negativeZIndex.some((function(e,t){return c>e.element.container.styles.zIndex.order?(u=t,!1):u>0})),A.negativeZIndex.splice(u,0,h)}else if(c>0){var d=0;A.positiveZIndex.some((function(e,t){return c>=e.element.container.styles.zIndex.order?(d=t+1,!1):d>0})),A.positiveZIndex.splice(d,0,h)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(h)}else r.styles.isFloating()?A.nonPositionedFloats.push(h):A.nonPositionedInlineLevel.push(h);Wm(a,h,o?h:i,l)}else r.styles.isInlineLevel()?t.inlineLevel.push(a):t.nonInlineLevel.push(a),Wm(a,t,i,l);mf(r.flags,8)&&Km(r,l)}))},Km=function(e,t){for(var i=e instanceof mg?e.start:1,s=e instanceof mg&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var s=qm(e),r=Om(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return Pc(this,void 0,void 0,(function(){var i,s,r,o,n,a,l,A,h,c,u,d,p,f,g,m,_,v;return Cc(this,(function(b){switch(b.label){case 0:this.applyEffects(e.getEffects(4)),i=e.container,s=e.curves,r=i.styles,o=0,n=i.textNodes,b.label=1;case 1:return o0&&B>0&&(m=s.ctx.createPattern(p,"repeat"),s.renderRepeat(v,m,P,C))):function(e){return 2===e.type}(i)&&(_=$m(e,t,[null,null,null]),v=_[0],b=_[1],y=_[2],x=_[3],B=_[4],w=0===i.position.length?[vd]:i.position,P=xd(w[0],x),C=xd(w[w.length-1],B),M=function(e,t,i,s,r){var o=0,n=0;switch(e.size){case 0:0===e.shape?o=n=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.min(Math.abs(t),Math.abs(t-s)),n=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)o=n=Math.min(jd(t,i),jd(t,i-r),jd(t-s,i),jd(t-s,i-r));else if(1===e.shape){var a=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-s)),l=Gd(s,r,t,i,!0),A=l[0],h=l[1];n=a*(o=jd(A-t,(h-i)/a))}break;case 1:0===e.shape?o=n=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.max(Math.abs(t),Math.abs(t-s)),n=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)o=n=Math.max(jd(t,i),jd(t,i-r),jd(t-s,i),jd(t-s,i-r));else if(1===e.shape){a=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-s));var c=Gd(s,r,t,i,!1);A=c[0],h=c[1],n=a*(o=jd(A-t,(h-i)/a))}}return Array.isArray(e.size)&&(o=xd(e.size[0],s),n=2===e.size.length?xd(e.size[1],r):o),[o,n]}(i,P,C,x,B),F=M[0],E=M[1],F>0&&E>0&&(I=s.ctx.createRadialGradient(b+P,y+C,0,b+P,y+C,F),Vd(i.stops,2*F).forEach((function(e){return I.addColorStop(e.stop,Ed(e.color))})),s.path(v),s.ctx.fillStyle=I,F!==E?(D=e.bounds.left+.5*e.bounds.width,S=e.bounds.top+.5*e.bounds.height,R=1/(T=E/F),s.ctx.save(),s.ctx.translate(D,S),s.ctx.transform(1,0,0,T,0,0),s.ctx.translate(-D,-S),s.ctx.fillRect(b,R*(y-S)+S,x,B*R),s.ctx.restore()):s.ctx.fill())),L.label=6;case 6:return t--,[2]}}))},s=this,r=0,o=e.styles.backgroundImage.slice(0).reverse(),a.label=1;case 1:return r0?2!==l.style?[3,5]:[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,2)]:[3,11]:[3,13];case 4:return h.sent(),[3,11];case 5:return 3!==l.style?[3,7]:[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,3)];case 6:return h.sent(),[3,11];case 7:return 4!==l.style?[3,9]:[4,this.renderDoubleBorder(l.color,l.width,o,e.curves)];case 8:return h.sent(),[3,11];case 9:return[4,this.renderSolidBorder(l.color,o,e.curves)];case 10:h.sent(),h.label=11;case 11:o++,h.label=12;case 12:return n++,[3,3];case 13:return[2]}}))}))},t.prototype.renderDashedDottedBorder=function(e,t,i,s,r){return Pc(this,void 0,void 0,(function(){var o,n,a,l,A,h,c,u,d,p,f,g,m,_,v,b;return Cc(this,(function(y){return this.ctx.save(),o=function(e,t){switch(t){case 0:return Jm(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Jm(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Jm(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return Jm(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(s,i),n=Xm(s,i),2===r&&(this.path(n),this.ctx.clip()),Rm(n[0])?(a=n[0].start.x,l=n[0].start.y):(a=n[0].x,l=n[0].y),Rm(n[1])?(A=n[1].end.x,h=n[1].end.y):(A=n[1].x,h=n[1].y),c=0===i||2===i?Math.abs(a-A):Math.abs(l-h),this.ctx.beginPath(),3===r?this.formatPath(o):this.formatPath(n.slice(0,2)),u=t<3?3*t:2*t,d=t<3?2*t:t,3===r&&(u=t,d=t),p=!0,c<=2*u?p=!1:c<=2*u+d?(u*=f=c/(2*u+d),d*=f):(g=Math.floor((c+d)/(u+d)),m=(c-g*u)/(g-1),d=(_=(c-(g+1)*u)/g)<=0||Math.abs(d-m){})),I_(this,"_reject",(()=>{})),this.name=e,this.workerThread=t,this.result=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){B_(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){B_(this.isRunning),this.isRunning=!1,this._reject(e)}}class S_{}const T_=new Map;function R_(e){B_(e.source&&!e.url||!e.source&&e.url);let t=T_.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return L_((t=e,"try {\n importScripts('".concat(t,"');\n} catch (error) {\n console.error(error);\n throw error;\n}")));var t}(e.url),T_.set(e.url,t)),e.source&&(t=L_(e.source),T_.set(e.source,t))),B_(t),t}function L_(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function U_(e,t=!0,i){const s=i||new Set;if(e){if(k_(e))s.add(e);else if(k_(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)U_(e[i],t,s)}else;return void 0===i?Array.from(s):[]}function k_(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const O_=()=>{};class N_{static isSupported(){return"undefined"!=typeof Worker&&C_||void 0!==typeof S_}constructor(e){I_(this,"name",void 0),I_(this,"source",void 0),I_(this,"url",void 0),I_(this,"terminated",!1),I_(this,"worker",void 0),I_(this,"onMessage",void 0),I_(this,"onError",void 0),I_(this,"_loadableURL","");const{name:t,source:i,url:s}=e;B_(i||s),this.name=t,this.source=i,this.url=s,this.onMessage=O_,this.onError=e=>console.log(e),this.worker=C_?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=O_,this.onError=O_,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||U_(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+="worker ".concat(this.name," from ").concat(this.url,". "),e.message&&(t+="".concat(e.message," in ")),e.lineno&&(t+=":".concat(e.lineno,":").concat(e.colno)),new Error(t)}_createBrowserWorker(){this._loadableURL=R_({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);e=new S_(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new S_(this.source,{eval:!0})}return e.on("message",(e=>{this.onMessage(e)})),e.on("error",(e=>{this.onError(e)})),e.on("exit",(e=>{})),e}}class Q_{static isSupported(){return N_.isSupported()}constructor(e){I_(this,"name","unnamed"),I_(this,"source",void 0),I_(this,"url",void 0),I_(this,"maxConcurrency",1),I_(this,"maxMobileConcurrency",1),I_(this,"onDebug",(()=>{})),I_(this,"reuseWorkers",!0),I_(this,"props",{}),I_(this,"jobQueue",[]),I_(this,"idleQueue",[]),I_(this,"count",0),I_(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach((e=>e.destroy())),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=((e,t,i)=>e.done(i)),i=((e,t)=>e.error(t))){const s=new Promise((s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this)));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new D_(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class H_{static isSupported(){return N_.isSupported()}static getWorkerFarm(e={}){return H_._workerFarm=H_._workerFarm||new H_({}),H_._workerFarm.setProps(e),H_._workerFarm}constructor(e){I_(this,"props",void 0),I_(this,"workerPools",new Map),this.props={...V_},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:s}=e;let r=this.workerPools.get(t);return r||(r=new Q_({name:t,source:i,url:s}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}I_(H_,"_workerFarm",void 0);var j_=Object.freeze({__proto__:null,default:{}});const G_={};async function z_(e,t=null,i={}){return t&&(e=function(e,t,i){if(e.startsWith("http"))return e;const s=i.modules||{};if(s[e])return s[e];if(!C_)return"modules/".concat(t,"/dist/libs/").concat(e);if(i.CDN)return B_(i.CDN.startsWith("http")),"".concat(i.CDN,"/").concat(t,"@").concat("3.2.6","/dist/libs/").concat(e);if(M_)return"../src/libs/".concat(e);return"modules/".concat(t,"/src/libs/").concat(e)}(e,t,i)),G_[e]=G_[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!C_)try{return j_&&void 0}catch{return null}if(M_)return importScripts(e);const t=await fetch(e);return function(e,t){if(!C_)return;if(M_)return eval.call(P_,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(await t.text(),e)}(e),await G_[e]}async function W_(e,t,i,s,r){const o=e.id,n=function(e,t={}){const i=t[e.id]||{},s="".concat(e.id,"-worker.js");let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r="modules/".concat(e.module,"/dist/").concat(s)),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?"@".concat(t):"";r="https://unpkg.com/@loaders.gl/".concat(e.module).concat(i,"/dist/").concat(s)}return B_(r),r}(e,i),a=H_.getWorkerFarm(i).getWorkerPool({name:o,url:n});i=JSON.parse(JSON.stringify(i)),s=JSON.parse(JSON.stringify(s||{}));const l=await a.startJob("process-on-worker",K_.bind(null,r));l.postMessage("process",{input:t,options:i,context:s});const A=await l.result;return await A.result}async function K_(e,t,i,s){switch(i){case"done":t.done(s);break;case"error":t.error(new Error(s.error));break;case"process":const{id:r,input:o,options:n}=s;try{const i=await e(o,n);t.postMessage("done",{id:r,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:i})}break;default:console.warn("parse-with-worker unknown message ".concat(i))}}function X_(e,t,i){if(e.byteLength<=t+i)return"";const s=new DataView(e);let r="";for(let e=0;e=0),b_(t>0),e+(t-1)&~(t-1)}function ev(e,t,i){let s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;s=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(s,i),i+$_(s.byteLength,4)}async function tv(e){const t=[];for await(const i of e)t.push(i);return function(...e){const t=e.map((e=>e instanceof ArrayBuffer?new Uint8Array(e):e)),i=t.reduce(((e,t)=>e+t.byteLength),0),s=new Uint8Array(i);let r=0;for(const e of t)s.set(e,r),r+=e.byteLength;return s.buffer}(...t)}const iv={};const sv=e=>"function"==typeof e,rv=e=>null!==e&&"object"==typeof e,ov=e=>rv(e)&&e.constructor==={}.constructor,nv=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,av=e=>"undefined"!=typeof Blob&&e instanceof Blob,lv=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||rv(e)&&sv(e.tee)&&sv(e.cancel)&&sv(e.getReader))(e)||(e=>rv(e)&&sv(e.read)&&sv(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e),Av=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,hv=/^([-\w.]+\/[-\w.+]+)/;function cv(e){const t=hv.exec(e);return t?t[1]:e}function uv(e){const t=Av.exec(e);return t?t[1]:""}const dv=/\?.*/;function pv(e){if(nv(e)){const t=fv(e.url||"");return{url:t,type:cv(e.headers.get("content-type")||"")||uv(t)}}return av(e)?{url:fv(e.name||""),type:e.type||""}:"string"==typeof e?{url:fv(e),type:uv(e)}:{url:"",type:""}}function fv(e){return e.replace(dv,"")}async function gv(e){if(nv(e))return e;const t={},i=function(e){return nv(e)?e.headers["content-length"]||-1:av(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const{url:s,type:r}=pv(e);r&&(t["content-type"]=r);const o=await async function(e){const t=5;if("string"==typeof e)return"data:,".concat(e.slice(0,t));if(e instanceof Blob){const t=e.slice(0,5);return await new Promise((e=>{const i=new FileReader;i.onload=t=>{var i;return e(null==t||null===(i=t.target)||void 0===i?void 0:i.result)},i.readAsDataURL(t)}))}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e=0)}();class Bv{constructor(e,t,i="sessionStorage"){this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function wv(e,t,i,s=600){const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));const o=e.width*i,n=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(n/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(n,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(n,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}const Pv={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function Cv(e){return"string"==typeof e?Pv[e.toUpperCase()]||Pv.WHITE:e}function Mv(e,t){if(!e)throw new Error(t||"Assertion failed")}function Fv(){let e;if(xv&&vv.performance)e=vv.performance.now();else if(bv.hrtime){const t=bv.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const Ev={debug:xv&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Iv={enabled:!0,level:0};function Dv(){}const Sv={},Tv={once:!0};function Rv(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}class Lv{constructor({id:e}={id:""}){this.id=e,this.VERSION=yv,this._startTs=Fv(),this._deltaTs=Fv(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new Bv("__probe-".concat(this.id,"__"),Iv),this.userData={},this.timeStamp("".concat(this.id," started")),function(e,t=["constructor"]){const i=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(i);for(const i of s)"function"==typeof e[i]&&(t.find((e=>i===e))||(e[i]=e[i].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Fv()-this._startTs).toPrecision(10))}getDelta(){return Number((Fv()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}assert(e,t){Mv(e,t)}warn(e){return this._getLogFunction(0,e,Ev.warn,arguments,Tv)}error(e){return this._getLogFunction(0,e,Ev.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,Ev.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Ev.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Ev.debug||Ev.info,arguments,Tv)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||Dv,i&&[i],{tag:Rv(t)}):Dv}image({logLevel:e,priority:t,image:i,message:s="",scale:r=1}){return this._shouldLog(e||t)?xv?function({image:e,message:t="",scale:i=1}){if("string"==typeof e){const s=new Image;return s.onload=()=>{const e=wv(s,t,i);console.log(...e)},s.src=e,Dv}const s=e.nodeName||"";if("img"===s.toLowerCase())return console.log(...wv(e,t,i)),Dv;if("canvas"===s.toLowerCase()){const s=new Image;return s.onload=()=>console.log(...wv(s,t,i)),s.src=e.toDataURL(),Dv}return Dv}({image:i,message:s,scale:r}):function({image:e,message:t="",scale:i=1}){let s=null;try{s=module.require("asciify-image")}catch(e){}if(s)return()=>s(e,{fit:"box",width:"".concat(Math.round(80*i),"%")}).then((e=>console.log(e)));return Dv}({image:i,message:s,scale:r}):Dv}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Dv)}group(e,t,i={collapsed:!1}){i=kv({logLevel:e,message:t,opts:i});const{collapsed:s}=i;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Dv)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Uv(e)}_getLogFunction(e,t,i,s=[],r){if(this._shouldLog(e)){r=kv({logLevel:e,message:t,args:s,opts:r}),Mv(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Fv();const o=r.tag||r.message;if(r.once){if(Sv[o])return Dv;Sv[o]=Fv()}return t=function(e,t,i){if("string"==typeof t){const s=i.time?function(e,t=8){const i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),t=function(e,t,i){return xv||"string"!=typeof e||(t&&(t=Cv(t),e="[".concat(t,"m").concat(e,"")),i&&(t=Cv(i),e="[".concat(i+10,"m").concat(e,""))),e}(t,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return Dv}}function Uv(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Mv(Number.isFinite(t)&&t>=0),t}function kv(e){const{logLevel:t,message:i}=e;e.logLevel=Uv(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==i;);switch(e.args=s,typeof t){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return Mv("string"===r||"object"===r),Object.assign(e,e.opts)}Lv.VERSION=yv;const Ov=new Lv({id:"loaders.gl"});class Nv{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const Qv={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){I_(this,"console",void 0),this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:y_,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Vv={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function Hv(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state=e._state||{},e._state}const jv=()=>{const e=Hv();return e.globalOptions=e.globalOptions||{...Qv},e.globalOptions};function Gv(e,t,i,s){return i=i||[],function(e,t){Wv(e,null,Qv,Vv,t);for(const i of t){const s=e&&e[i.id]||{},r=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};Wv(s,i.id,r,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const s={...e.options||{}};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(s,i),null===s.log&&(s.log=new Nv);return Xv(s,jv()),Xv(s,t),s}(t,e,s)}function zv(e,t){const i=jv(),s=e||i;return"function"==typeof s.fetch?s.fetch:rv(s.fetch)?e=>mv(e,s):null!=t&&t.fetch?null==t?void 0:t.fetch:mv}function Wv(e,t,i,s,r){const o=t||"Top level",n=t?"".concat(t,"."):"";for(const a in e){const l=!t&&rv(e[a]),A="baseUri"===a&&!t,h="workerUrl"===a&&t;if(!(a in i)&&!A&&!h)if(a in s)Ov.warn("".concat(o," loader option '").concat(n).concat(a,"' no longer supported, use '").concat(s[a],"'"))();else if(!l){const e=Kv(a,r);Ov.warn("".concat(o," loader option '").concat(n).concat(a,"' not recognized. ").concat(e))()}}}function Kv(e,t){const i=e.toLowerCase();let s="";for(const r of t)for(const t in r.options){if(e===t)return"Did you mean '".concat(r.id,".").concat(t,"'?");const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(s=s||"Did you mean '".concat(r.id,".").concat(t,"'?"))}return s}function Xv(e,t){for(const i in t)if(i in t){const s=t[i];ov(s)&&ov(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function Jv(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function Yv(e){var t,i;let s;return b_(e,"null loader"),b_(Jv(e),"invalid loader"),Array.isArray(e)&&(s=e[1],e=e[0],e={...e,options:{...e.options,...s}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(i=e)&&void 0!==i&&i.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}function Zv(){return(()=>{const e=Hv();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry})()}function qv(){return!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||function(e){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof process&&"object"==typeof process.versions&&Boolean(process.versions.electron))return!0;const t="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,i=e||t;return!!(i&&i.indexOf("Electron")>=0)}()}const $v={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"==typeof process&&process},eb=$v.window||$v.self||$v.global,tb=$v.process||{},ib="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";qv();class sb{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";I_(this,"storage",void 0),I_(this,"id",void 0),I_(this,"config",{}),this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function rb(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));const o=e.width*i,n=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(n/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(n,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(n,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}let ob;function nb(e){return"string"==typeof e?ob[e.toUpperCase()]||ob.WHITE:e}function ab(e,t){if(!e)throw new Error(t||"Assertion failed")}function lb(){let e;var t,i;if(qv&&"performance"in eb)e=null==eb||null===(t=eb.performance)||void 0===t||null===(i=t.now)||void 0===i?void 0:i.call(t);else if("hrtime"in tb){var s;const t=null==tb||null===(s=tb.hrtime)||void 0===s?void 0:s.call(tb);e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(ob||(ob={}));const Ab={debug:qv&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},hb={enabled:!0,level:0};function cb(){}const ub={},db={once:!0};class pb{constructor(){let{id:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};I_(this,"id",void 0),I_(this,"VERSION",ib),I_(this,"_startTs",lb()),I_(this,"_deltaTs",lb()),I_(this,"_storage",void 0),I_(this,"userData",{}),I_(this,"LOG_THROTTLE_TIMEOUT",0),this.id=e,this._storage=new sb("__probe-".concat(this.id,"__"),hb),this.userData={},this.timeStamp("".concat(this.id," started")),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const i=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(i);for(const i of s)"function"==typeof e[i]&&(t.find((e=>i===e))||(e[i]=e[i].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((lb()-this._startTs).toPrecision(10))}getDelta(){return Number((lb()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){ab(e,t)}warn(e){return this._getLogFunction(0,e,Ab.warn,arguments,db)}error(e){return this._getLogFunction(0,e,Ab.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,Ab.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Ab.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){for(var i=arguments.length,s=new Array(i>2?i-2:0),r=2;r{const t=rb(e,i,s);console.log(...t)},e.src=t,cb}const r=t.nodeName||"";if("img"===r.toLowerCase())return console.log(...rb(t,i,s)),cb;if("canvas"===r.toLowerCase()){const e=new Image;return e.onload=()=>console.log(...rb(e,i,s)),e.src=t.toDataURL(),cb}return cb}({image:s,message:r,scale:o}):function(e){let{image:t,message:i="",scale:s=1}=e,r=null;try{r=module.require("asciify-image")}catch(e){}if(r)return()=>r(t,{fit:"box",width:"".concat(Math.round(80*s),"%")}).then((e=>console.log(e)));return cb}({image:s,message:r,scale:o}):cb}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||cb)}group(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const s=gb({logLevel:e,message:t,opts:i}),{collapsed:r}=i;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||cb)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=fb(e)}_getLogFunction(e,t,i,s,r){if(this._shouldLog(e)){r=gb({logLevel:e,message:t,args:s,opts:r}),ab(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=lb();const o=r.tag||r.message;if(r.once){if(ub[o])return cb;ub[o]=lb()}return t=function(e,t,i){if("string"==typeof t){const s=i.time?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),t=function(e,t,i){return qv||"string"!=typeof e||(t&&(t=nb(t),e="[".concat(t,"m").concat(e,"")),i&&(t=nb(i),e="[".concat(i+10,"m").concat(e,""))),e}(t,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return cb}}function fb(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return ab(Number.isFinite(t)&&t>=0),t}function gb(e){const{logLevel:t,message:i}=e;e.logLevel=fb(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return ab("string"===r||"object"===r),Object.assign(e,{args:s},e.opts)}function mb(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}I_(pb,"VERSION",ib);const _b=new pb({id:"loaders.gl"}),vb=/\.([^.]+)$/;function bb(e,t=[],i,s){if(!yb(e))return null;if(t&&!Array.isArray(t))return Yv(t);let r=[];t&&(r=r.concat(t)),null!=i&&i.ignoreRegisteredLoaders||r.push(...Zv()),function(e){for(const t of e)Yv(t)}(r);const o=function(e,t,i,s){const{url:r,type:o}=pv(e),n=r||(null==s?void 0:s.url);let a=null,l="";null!=i&&i.mimeType&&(a=Bb(t,null==i?void 0:i.mimeType),l="match forced by supplied MIME type ".concat(null==i?void 0:i.mimeType));var A;a=a||function(e,t){const i=t&&vb.exec(t),s=i&&i[1];return s?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,s):null}(t,n),l=l||(a?"matched url ".concat(n):""),a=a||Bb(t,o),l=l||(a?"matched MIME type ".concat(o):""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(wb(t,i))return i}else if(ArrayBuffer.isView(t)){if(Pb(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(Pb(t,0,i))return i}return null}(t,e),l=l||(a?"matched initial data ".concat(Cb(e)):""),a=a||Bb(t,null==i?void 0:i.fallbackMimeType),l=l||(a?"matched fallback MIME type ".concat(o):""),l&&_b.log(1,"selectLoader selected ".concat(null===(A=a)||void 0===A?void 0:A.name,": ").concat(l,"."));return a}(e,r,i,s);if(!(o||null!=i&&i.nothrow))throw new Error(xb(e));return o}function yb(e){return!(e instanceof Response&&204===e.status)}function xb(e){const{url:t,type:i}=pv(e);let s="No valid loader found (";s+=t?"".concat(function(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(t+1):""}(t),", "):"no url provided, ",s+="MIME type: ".concat(i?'"'.concat(i,'"'):"not provided",", ");const r=e?Cb(e):"";return s+=r?' first bytes: "'.concat(r,'"'):"first bytes: not available",s+=")",s}function Bb(e,t){for(const i of e){if(i.mimeTypes&&i.mimeTypes.includes(t))return i;if(t==="application/x.".concat(i.id))return i}return null}function wb(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some((t=>e.startsWith(t)))}function Pb(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some((s=>function(e,t,i,s){if(s instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLength60?"".concat(t.slice(0,60),"..."):t}catch(e){}return t}(e);throw new Error(t)}}(i),t.binary?await i.arrayBuffer():await i.text()}if(lv(e)&&(e=Ib(e,i)),(r=e)&&"function"==typeof r[Symbol.iterator]||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return tv(e);var r;throw new Error(Db)}async function Tb(e,t,i,s){B_(!s||"object"==typeof s),!t||Array.isArray(t)||Jv(t)||(s=void 0,i=t,t=void 0),e=await e,i=i||{};const{url:r}=pv(e),o=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:null}(t,s),n=await async function(e,t=[],i,s){if(!yb(e))return null;let r=bb(e,t,{...i,nothrow:!0},s);if(r)return r;if(av(e)&&(r=bb(e=await e.slice(0,10).arrayBuffer(),t,i,s)),!(r||null!=i&&i.nothrow))throw new Error(xb(e));return r}(e,o,i);return n?(s=function(e,t,i=null){if(i)return i;const s={fetch:zv(t,e),...e};return Array.isArray(s.loaders)||(s.loaders=null),s}({url:r,parse:Tb,loaders:o},i=Gv(i,n,o,r),s),await async function(e,t,i,s){if(function(e,t="3.2.6"){B_(e,"no worker provided");const i=e.version}(e),nv(t)){const e=t,{ok:i,redirected:r,status:o,statusText:n,type:a,url:l}=e,A=Object.fromEntries(e.headers.entries());s.response={headers:A,ok:i,redirected:r,status:o,statusText:n,type:a,url:l}}if(t=await Sb(t,e,i),e.parseTextSync&&"string"==typeof t)return i.dataType="text",e.parseTextSync(t,i,s,e);if(function(e,t){return!!H_.isSupported()&&!!(C_||null!=t&&t._nodeWorkers)&&e.worker&&(null==t?void 0:t.worker)}(e,i))return await W_(e,t,i,s,Tb);if(e.parseText&&"string"==typeof t)return await e.parseText(t,i,s,e);if(e.parse)return await e.parse(t,i,s,e);throw B_(!e.parseSync),new Error("".concat(e.id," loader - no parser found and worker is disabled"))}(n,e,i,s)):null}const Rb="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.wasm"),Lb="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.js");let Ub,kb;async function Ob(e){const t=e.modules||{};return t.basis?t.basis:(Ub=Ub||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await z_("basis_transcoder.js","textures",e),await z_("basis_transcoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e(i).then((e=>{const{BasisFile:i,initializeBasis:s}=e;s(),t({BasisFile:i})}))}))}(t,i)}(e),await Ub)}async function Nb(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(kb=kb||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await z_(Lb,"textures",e),await z_(Rb,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e(i).then((e=>{const{BasisFile:i,KTX2File:s,initializeBasis:r,BasisEncoder:o}=e;r(),t({BasisFile:i,KTX2File:s,BasisEncoder:o})}))}))}(t,i)}(e),await kb)}const Qb=33776,Vb=33779,Hb=35840,jb=35842,Gb=36196,zb=37808,Wb=["","WEBKIT_","MOZ_"],Kb={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let Xb=null;function Jb(e){if(!Xb){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Xb=new Set;for(const t of Wb)for(const i in Kb)if(e&&e.getExtension("".concat(t).concat(i))){const e=Kb[i];Xb.add(e)}}return Xb}var Yb,Zb,qb,$b,ey,ty,iy,sy,ry;(ry=Yb||(Yb={}))[ry.NONE=0]="NONE",ry[ry.BASISLZ=1]="BASISLZ",ry[ry.ZSTD=2]="ZSTD",ry[ry.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(Zb||(Zb={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(qb||(qb={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}($b||($b={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(ey||(ey={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(ty||(ty={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(iy||(iy={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(sy||(sy={}));const oy=[171,75,84,88,32,50,48,187,13,10,26,10];const ny={etc1:{basisFormat:0,compressed:!0,format:Gb},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:Qb},bc3:{basisFormat:3,compressed:!0,format:Vb},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:Hb},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:jb},"astc-4x4":{basisFormat:10,compressed:!0,format:zb},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function ay(e,t,i){const s=new e(new Uint8Array(t));try{if(!s.startTranscoding())throw new Error("Failed to start basis transcoding");const e=s.getNumImages(),t=[];for(let r=0;r{try{i.onload=()=>t(i),i.onerror=t=>s(new Error("Could not load image ".concat(e,": ").concat(t)))}catch(e){s(e)}}))}(o||s,t)}finally{o&&r.revokeObjectURL(o)}}const Py={};let Cy=!0;async function My(e,t,i){let s;if(xy(i)){s=await wy(e,t,i)}else s=By(e,i);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||Py)return!1;return!0}(t)&&Cy||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Cy=!1}return await createImageBitmap(e)}(s,r)}function Fy(e){const t=Ey(e);return function(e){const t=Ey(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,false)))return null;return{mimeType:"image/png",width:t.getUint32(16,false),height:t.getUint32(20,false)}}(t)||function(e){const t=Ey(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,false)&&255===t.getUint8(2)))return null;const{tableMarkers:i,sofMarkers:s}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r+9=10&&1195984440===t.getUint32(0,false)))return null;return{mimeType:"image/gif",width:t.getUint16(6,true),height:t.getUint16(8,true)}}(t)||function(e){const t=Ey(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,false)&&t.getUint32(2,true)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,true),height:t.getUint32(22,true)}}(t)}function Ey(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const Iy={id:"image",module:"images",name:"Images",version:"3.2.6",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,i){const s=((t=t||{}).image||{}).type||"auto",{url:r}=i||{};let o;switch(function(e){switch(e){case"auto":case"data":return function(){if(gy)return"imagebitmap";if(fy)return"image";if(_y)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return gy||fy||_y;case"imagebitmap":return gy;case"image":return fy;case"data":return _y;default:throw new Error("@loaders.gl/images: image ".concat(e," not supported in this environment"))}}(e),e}}(s)){case"imagebitmap":o=await My(e,t,r);break;case"image":o=await wy(e,t,r);break;case"data":o=await async function(e,t){const{mimeType:i}=Fy(e)||{},s=globalThis._parseImageNode;return b_(s),await s(e,i)}(e);break;default:b_(!1)}return"data"===s&&(o=function(e){switch(vy(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}(o)),o},tests:[e=>Boolean(Fy(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Dy=["image/png","image/jpeg","image/gif"],Sy={};function Ty(e){return void 0===Sy[e]&&(Sy[e]=function(e){switch(e){case"image/webp":return function(){if(!y_)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch{return!1}}();case"image/svg":return y_;default:if(!y_){const{_parseImageNode:t}=globalThis;return Boolean(t)&&Dy.includes(e)}return!0}}(e)),Sy[e]}function Ry(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function Ly(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error("'baseUri' must be provided to resolve relative url ".concat(e));return i.substr(0,i.lastIndexOf("/")+1)+e}const Uy=["SCALAR","VEC2","VEC3","VEC4"],ky=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Oy=new Map(ky),Ny={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Qy={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Vy={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Hy(e){return Uy[e-1]||Uy[0]}function jy(e){const t=Oy.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Gy(e,t){const i=Vy[e.componentType],s=Ny[e.type],r=Qy[e.componentType],o=e.count*s,n=e.count*s*r;return Ry(n>=0&&n<=t.byteLength),{ArrayType:i,length:o,byteLength:n}}const zy={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class Wy{constructor(e){I_(this,"gltf",void 0),I_(this,"sourceBuffers",void 0),I_(this,"byteLength",void 0),this.gltf=e||{json:{...zy},buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find((t=>t===e)),i=this.json.extensions||{};return t?i[e]||!0:null}getRequiredExtension(e){const t=this.getRequiredExtensions().find((t=>t===e));return t?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error("glTF file error: Could not find ".concat(e,"[").concat(t,"]"));return i}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];Ry(i);const s=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,{ArrayType:s,length:r}=Gy(e,t);return new s(i,t.byteOffset+e.byteOffset,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(i,s,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,i){return e.extensions=e.extensions||{},e.extensions[t]=i,this.registerUsedExtension(t),this}setObjectExtension(e,t,i){(e.extensions||{})[t]=i}removeObjectExtension(e,t){const i=e.extensions||{},s=i[t];return delete i[t],s}addExtension(e,t={}){return Ry(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return Ry(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((t=>t===e))||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((t=>t===e))||this.json.extensionsRequired.push(e)}removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const s={mesh:t};return i&&(s.matrix=i),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:s,mode:r=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(i){const e=this._addIndices(i);o.primitives[0].indices=e}return Number.isFinite(s)&&(o.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=Fy(e),s=t||(null==i?void 0:i.mimeType),r={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e){const t=e.byteLength;Ry(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const i={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=$_(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:Hy(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const i=this.addBufferView(e);let s={min:t.min,max:t.max};s.min&&s.max||(s=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:jy(e),count:Math.round(e.length/t.size),min:s.min,max:s.max};return this.addAccessor(i,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const i=this.byteLength,s=new ArrayBuffer(i),r=new Uint8Array(s);let o=0;for(const e of this.sourceBuffers||[])o=ev(e,r,o);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=i:this.json.buffers=[{byteLength:i}],this.gltf.binary=s,this.sourceBuffers=[s]}_removeStringFromArray(e,t){let i=!0;for(;i;){const s=e.indexOf(t);s>-1?e.splice(s,1):i=!1}}_addAttributes(e={}){const t={};for(const i in e){const s=e[i],r=this._getGltfAttributeName(i),o=this.addBinaryBuffer(s.value,s);t[r]=o}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const i={min:null,max:null};if(e.length96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let i=0;for(let s=0;st[e.name]));return new nx(i,this.metadata)}selectAt(...e){const t=e.map((e=>this.fields[e])).filter(Boolean);return new nx(t,this.metadata)}assign(e){let t,i=this.metadata;if(e instanceof nx){const s=e;t=s.fields,i=ax(ax(new Map,this.metadata),s.metadata)}else t=e;const s=Object.create(null);for(const e of this.fields)s[e.name]=e;for(const e of t)s[e.name]=e;const r=Object.values(s);return new nx(r,i)}}function ax(e,t){return new Map([...e||new Map,...t||new Map])}class lx{constructor(e,t,i=!1,s=new Map){I_(this,"name",void 0),I_(this,"type",void 0),I_(this,"nullable",void 0),I_(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=i,this.metadata=s}get typeId(){return this.type&&this.type.typeId}clone(){return new lx(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}let Ax,hx,cx,ux;!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(Ax||(Ax={}));class dx{static isNull(e){return e&&e.typeId===Ax.Null}static isInt(e){return e&&e.typeId===Ax.Int}static isFloat(e){return e&&e.typeId===Ax.Float}static isBinary(e){return e&&e.typeId===Ax.Binary}static isUtf8(e){return e&&e.typeId===Ax.Utf8}static isBool(e){return e&&e.typeId===Ax.Bool}static isDecimal(e){return e&&e.typeId===Ax.Decimal}static isDate(e){return e&&e.typeId===Ax.Date}static isTime(e){return e&&e.typeId===Ax.Time}static isTimestamp(e){return e&&e.typeId===Ax.Timestamp}static isInterval(e){return e&&e.typeId===Ax.Interval}static isList(e){return e&&e.typeId===Ax.List}static isStruct(e){return e&&e.typeId===Ax.Struct}static isUnion(e){return e&&e.typeId===Ax.Union}static isFixedSizeBinary(e){return e&&e.typeId===Ax.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===Ax.FixedSizeList}static isMap(e){return e&&e.typeId===Ax.Map}static isDictionary(e){return e&&e.typeId===Ax.Dictionary}get typeId(){return Ax.NONE}compareTo(e){return this===e}}hx=Symbol.toStringTag;class px extends dx{constructor(e,t){super(),I_(this,"isSigned",void 0),I_(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return Ax.Int}get[hx](){return"Int"}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}class fx extends px{constructor(){super(!0,8)}}class gx extends px{constructor(){super(!0,16)}}class mx extends px{constructor(){super(!0,32)}}class _x extends px{constructor(){super(!1,8)}}class vx extends px{constructor(){super(!1,16)}}class bx extends px{constructor(){super(!1,32)}}const yx=32,xx=64;cx=Symbol.toStringTag;class Bx extends dx{constructor(e){super(),I_(this,"precision",void 0),this.precision=e}get typeId(){return Ax.Float}get[cx](){return"Float"}toString(){return"Float".concat(this.precision)}}class wx extends Bx{constructor(){super(yx)}}class Px extends Bx{constructor(){super(xx)}}ux=Symbol.toStringTag;class Cx extends dx{constructor(e,t){super(),I_(this,"listSize",void 0),I_(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return Ax.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[ux](){return"FixedSizeList"}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}function Mx(e,t,i){const s=function(e){switch(e.constructor){case Int8Array:return new fx;case Uint8Array:return new _x;case Int16Array:return new gx;case Uint16Array:return new vx;case Int32Array:return new mx;case Uint32Array:return new bx;case Float32Array:return new wx;case Float64Array:return new Px;default:throw new Error("array type not supported")}}(t.value),r=i||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new lx(e,new Cx(t.size,new lx("value",s)),!1,r)}function Fx(e,t,i){return Mx(e,t,i?Ex(i.metadata):void 0)}function Ex(e){const t=new Map;for(const i in e)t.set("".concat(i,".string"),JSON.stringify(e[i]));return t}const Ix={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Dx={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class Sx{constructor(e){I_(this,"draco",void 0),I_(this,"decoder",void 0),I_(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const s=this.decoder.GetEncodedGeometryType(i),r=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(s){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t="DRACO decompression failed: ".concat(e.error_msg());throw new Error(t)}const o=this._getDracoLoaderData(r,s,t),n=this._getMeshData(r,o,t),a=function(e){let t=1/0,i=1/0,s=1/0,r=-1/0,o=-1/0,n=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;er?l:r,o=A>o?A:o,n=h>n?h:n}return[[t,i,s],[r,o,n]]}(n.attributes),l=function(e,t,i){const s=Ex(t.metadata),r=[],o=function(e){const t={};for(const i in e){const s=e[i];t[s.name||"undefined"]=s}return t}(t.attributes);for(const t in e){const i=Fx(t,e[t],o[t]);r.push(i)}if(i){const e=Fx("indices",i);r.push(e)}return new nx(r,s)}(n.attributes,o,n.indices);return{loader:"draco",loaderData:o,header:{vertexCount:r.num_points(),boundingBox:a},...n,schema:l}}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,i){const s=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:r}}_getDracoAttributes(e,t){const i={};for(let s=0;sthis.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map((e=>t.min_value(e)))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,s=e.attribute_type();if(i.map((e=>this.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const Tx="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.js"),Rx="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_wasm_wrapper.js"),Lx="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.wasm");let Ux;async function kx(e){const t=e.modules||{};return Ux=t.draco3d?Ux||t.draco3d.createDecoderModule({}).then((e=>({draco:e}))):Ux||async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await z_(Tx,"draco",e);else[t,i]=await Promise.all([await z_(Rx,"draco",e),await z_(Lx,"draco",e)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e({...i,onModuleLoaded:e=>t({draco:e})})}))}(t,i)}(e),await Ux}const Ox={...ox,parse:async function(e,t){const{draco:i}=await kx(t),s=new Sx(i);try{return s.parseSync(e,null==t?void 0:t.draco)}finally{s.destroy()}}};function Nx(e){const{buffer:t,size:i,count:s}=function(e){let t=e,i=1,s=0;e&&e.value&&(t=e.value,i=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,i=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),s=t.length/i);return{buffer:t,size:i,count:s}}(e);return{value:t,size:i,byteOffset:0,count:s,type:Hy(i),componentType:jy(t)}}async function Qx(e,t,i,s){const r=e.getObjectExtension(t,"KHR_draco_mesh_compression");if(!r)return;const o=e.getTypedArrayForBufferView(r.bufferView),n=q_(o.buffer,o.byteOffset),{parse:a}=s,l={...i};delete l["3d-tiles"];const A=await a(n,Ox,l,s),h=function(e){const t={};for(const i in e){const s=e[i];if("indices"!==i){const e=Nx(s);t[i]=e}}return t}(A.attributes);for(const[i,s]of Object.entries(h))if(i in t.attributes){const r=t.attributes[i],o=e.getAccessor(r);null!=o&&o.min&&null!=o&&o.max&&(s.min=o.min,s.max=o.max)}t.attributes=h,A.indices&&(t.indices=Nx(A.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function Vx(e,t,i=4,s,r){var o;if(!s.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const n=s.DracoWriter.encodeSync({attributes:e}),a=null==r||null===(o=r.parseSync)||void 0===o?void 0:o.call(r,{attributes:e}),l=s._addFauxAttributes(a.attributes);return{primitives:[{attributes:l,mode:i,extensions:{KHR_draco_mesh_compression:{bufferView:s.addBufferView(n),attributes:l}}}]}}function*Hx(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var jx=Object.freeze({__proto__:null,name:"KHR_draco_mesh_compression",preprocess:function(e,t,i){const s=new Wy(e);for(const e of Hx(s))s.getObjectExtension(e,"KHR_draco_mesh_compression")},decode:async function(e,t,i){var s;if(null==t||null===(s=t.gltf)||void 0===s||!s.decompressMeshes)return;const r=new Wy(e),o=[];for(const e of Hx(r))r.getObjectExtension(e,"KHR_draco_mesh_compression")&&o.push(Qx(r,e,t,i));await Promise.all(o),r.removeExtension("KHR_draco_mesh_compression")},encode:function(e,t={}){const i=new Wy(e);for(const e of i.json.meshes||[])Vx(e),i.addRequiredExtension("KHR_draco_mesh_compression")}});var Gx=Object.freeze({__proto__:null,name:"KHR_lights_punctual",decode:async function(e){const t=new Wy(e),{json:i}=t,s=t.getExtension("KHR_lights_punctual");s&&(t.json.lights=s.lights,t.removeExtension("KHR_lights_punctual"));for(const e of i.nodes||[]){const i=t.getObjectExtension(e,"KHR_lights_punctual");i&&(e.light=i.light),t.removeObjectExtension(e,"KHR_lights_punctual")}},encode:async function(e){const t=new Wy(e),{json:i}=t;if(i.lights){const e=t.addExtension("KHR_lights_punctual");Ry(!e.lights),e.lights=i.lights,delete i.lights}if(t.json.lights){for(const e of t.json.lights){const i=e.node;t.addObjectExtension(i,"KHR_lights_punctual",e)}delete t.json.lights}}});function zx(e,t){const i=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach((t=>{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)})),Object.keys(i).forEach((e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))})),i}const Wx=[ix,sx,rx,jx,Gx,Object.freeze({__proto__:null,name:"KHR_materials_unlit",decode:async function(e){const t=new Wy(e),{json:i}=t;t.removeExtension("KHR_materials_unlit");for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,"KHR_materials_unlit")}},encode:function(e){const t=new Wy(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}}),Object.freeze({__proto__:null,name:"KHR_techniques_webgl",decode:async function(e){const t=new Wy(e),{json:i}=t,s=t.getExtension("KHR_techniques_webgl");if(s){const e=function(e,t){const{programs:i=[],shaders:s=[],techniques:r=[]}=e,o=new TextDecoder;return s.forEach((e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))})),i.forEach((e=>{e.fragmentShader=s[e.fragmentShader],e.vertexShader=s[e.vertexShader]})),r.forEach((e=>{e.program=i[e.program]})),r}(s,t);for(const s of i.materials||[]){const i=t.getObjectExtension(s,"KHR_techniques_webgl");i&&(s.technique=Object.assign({},i,e[i.technique]),s.technique.values=zx(s.technique,t)),t.removeObjectExtension(s,"KHR_techniques_webgl")}t.removeExtension("KHR_techniques_webgl")}},encode:async function(e,t){}})];function Kx(e,t){var i;const s=(null==t||null===(i=t.gltf)||void 0===i?void 0:i.excludeExtensions)||{};return!(e in s&&!s[e])}const Xx={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Jx={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class Yx{constructor(){I_(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),I_(this,"json",void 0)}normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version ".concat(i.asset.version))}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new Wy(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,"KHR_binary_glTF");i&&Object.assign(e,i),t.removeObjectExtension(e,"KHR_binary_glTF")}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in Xx)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const s in i){const r=i[s];r.id=r.id||s;const o=e[t].length;e[t].push(r),this.idToIndexMap[t][s]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in Xx)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:s}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),s&&(t.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map((e=>this._convertIdToIndex(e,"node")))),e.meshes&&(e.meshes=e.meshes.map((e=>this._convertIdToIndex(e,"mesh"))))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map((e=>this._convertIdToIndex(e,"node"))))}_convertIdsToIndices(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute ".concat(t)),e[t]=[]);for(const i of e[t])for(const e in i){const t=i[e],s=this._convertIdToIndex(t,e);i[e]=s}}_convertIdToIndex(e,t){const i=Jx[t];if(i in this.idToIndexMap){const s=this.idToIndexMap[i][e];if(!Number.isFinite(s))throw new Error("gltf v1: failed to resolve ".concat(t," with id ").concat(e));return s}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const s of e.materials){var t,i;s.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const r=(null===(t=s.values)||void 0===t?void 0:t.tex)||(null===(i=s.values)||void 0===i?void 0:i.texture2d_0),o=e.textures.findIndex((e=>e.id===r));-1!==o&&(s.pbrMetallicRoughness.baseColorTexture={index:o})}}}const Zx={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qx={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},$x=10240,eB=10241,tB=10242,iB=10243,sB=10497,rB={magFilter:$x,minFilter:eB,wrapS:tB,wrapT:iB},oB={[$x]:9729,[eB]:9986,[tB]:sB,[iB]:sB};class nB{constructor(){I_(this,"baseUri",""),I_(this,"json",{}),I_(this,"buffers",[]),I_(this,"images",[])}postProcess(e,t={}){const{json:i,buffers:s=[],images:r=[],baseUri:o=""}=e;return Ry(i),this.baseUri=o,this.json=i,this.buffers=s,this.images=r,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map(((e,t)=>this._resolveBufferView(e,t)))),e.images&&(e.images=e.images.map(((e,t)=>this._resolveImage(e,t)))),e.samplers&&(e.samplers=e.samplers.map(((e,t)=>this._resolveSampler(e,t)))),e.textures&&(e.textures=e.textures.map(((e,t)=>this._resolveTexture(e,t)))),e.accessors&&(e.accessors=e.accessors.map(((e,t)=>this._resolveAccessor(e,t)))),e.materials&&(e.materials=e.materials.map(((e,t)=>this._resolveMaterial(e,t)))),e.meshes&&(e.meshes=e.meshes.map(((e,t)=>this._resolveMesh(e,t)))),e.nodes&&(e.nodes=e.nodes.map(((e,t)=>this._resolveNode(e,t)))),e.skins&&(e.skins=e.skins.map(((e,t)=>this._resolveSkin(e,t)))),e.scenes&&(e.scenes=e.scenes.map(((e,t)=>this._resolveScene(e,t)))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];return i||console.warn("glTF file error: Could not find ".concat(e,"[").concat(t,"]")),i}_resolveScene(e,t){return e.id=e.id||"scene-".concat(t),e.nodes=(e.nodes||[]).map((e=>this.getNode(e))),e}_resolveNode(e,t){return e.id=e.id||"node-".concat(t),e.children&&(e.children=e.children.map((e=>this.getNode(e)))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce(((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e}),{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-".concat(t),e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-".concat(t),e.primitives&&(e.primitives=e.primitives.map((e=>{const t=(e={...e}).attributes;e.attributes={};for(const i in t)e.attributes[i]=this.getAccessor(t[i]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e}))),e}_resolveMaterial(e,t){if(e.id=e.id||"material-".concat(t),e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var i,s;if(e.id=e.id||"accessor-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(i=e.componentType,qx[i]),e.components=(s=e.type,Zx[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:i,byteLength:s}=Gy(e,e.bufferView),r=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset;let o=t.arrayBuffer.slice(r,r+s);e.bufferView.byteStride&&(o=this._getValueFromInterleavedBuffer(t,r,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new i(o)}return e}_getValueFromInterleavedBuffer(e,t,i,s,r){const o=new Uint8Array(r*s);for(let n=0;n20);const s=t.getUint32(i+0,lB),r=t.getUint32(i+4,lB);return i+=8,b_(0===r),hB(e,t,i,s),i+=s,i+=cB(e,t,i,e.header.byteLength)}(e,r,i);case 2:return function(e,t,i,s){return b_(e.header.byteLength>20),function(e,t,i,s){for(;i+8<=e.header.byteLength;){const r=t.getUint32(i+0,lB),o=t.getUint32(i+4,lB);switch(i+=8,o){case 1313821514:hB(e,t,i,r);break;case 5130562:cB(e,t,i,r);break;case 0:s.strict||hB(e,t,i,r);break;case 1:s.strict||cB(e,t,i,r)}i+=$_(r,4)}}(e,t,i,s),i+e.header.byteLength}(e,r,i,{});default:throw new Error("Invalid GLB version ".concat(e.version,". Only supports v1 and v2."))}}function hB(e,t,i,s){const r=new Uint8Array(t.buffer,i,s),o=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(o),$_(s,4)}function cB(e,t,i,s){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:s,arrayBuffer:t.buffer}),$_(s,4)}async function uB(e,t,i=0,s,r){var o,n,a,l;!function(e,t,i,s){s.uri&&(e.baseUri=s.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,i={}){const s=new DataView(e),{magic:r=aB}=i,o=s.getUint32(t,!1);return o===r||o===aB}(t,i,s)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=J_(t);else if(t instanceof ArrayBuffer){const r={};i=AB(r,t,i,s.glb),Ry("glTF"===r.type,"Invalid GLB magic string ".concat(r.type)),e._glb=r,e.json=r.json}else Ry(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,i,s),function(e,t={}){(new Yx).normalize(e,t)}(e,{normalize:null==s||null===(o=s.gltf)||void 0===o?void 0:o.normalize}),function(e,t={},i){const s=Wx.filter((e=>Kx(e.name,t)));for(const o of s){var r;null===(r=o.preprocess)||void 0===r||r.call(o,e,t,i)}}(e,s,r);const A=[];if(null!=s&&null!==(n=s.gltf)&&void 0!==n&&n.loadBuffers&&e.json.buffers&&await async function(e,t,i){const s=e.json.buffers||[];for(let n=0;nKx(e.name,t)));for(const o of s){var r;await(null===(r=o.decode)||void 0===r?void 0:r.call(o,e,t,i))}}(e,s,r);return A.push(h),await Promise.all(A),null!=s&&null!==(l=s.gltf)&&void 0!==l&&l.postProcess?function(e,t){return(new nB).postProcess(e,t)}(e,s):e}async function dB(e,t,i,s,r){const{fetch:o,parse:n}=r;let a;if(t.uri){const e=Ly(t.uri,s),i=await o(e);a=await i.arrayBuffer()}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const s=e.bufferViews[i];Ry(s);const r=t[s.buffer];Ry(r);const o=(s.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,o,s.byteLength)}(e.json,e.buffers,t.bufferView);a=q_(i.buffer,i.byteOffset,i.byteLength)}Ry(a,"glTF image has no data");let l=await n(a,[Iy,dy],{mimeType:t.mimeType,basis:s.basis||{format:uy()}},r);l&&l[0]&&(l={compressed:!0,mipmaps:!1,width:l[0].width,height:l[0].height,data:l[0]}),e.images=e.images||[],e.images[i]=l}const pB={name:"glTF",id:"gltf",module:"gltf",version:"3.2.6",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},i){(t={...pB.options,...t}).gltf={...pB.options.gltf,...t.gltf};const{byteOffset:s=0}=t;return await uB({},e,s,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};class fB{constructor(e){}load(e,t,i,s,r,o,n){!function(e,t,i,s,r,o,n){const a=e.viewer.scene.canvas.spinner;a.processes++;"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(n=>{s.basePath=mB(t),_B(e,t,n,i,s,r,o),a.processes--}),(e=>{a.processes--,n(e)})):e.dataSource.getGLTF(t,(n=>{s.basePath=mB(t),_B(e,t,n,i,s,r,o),a.processes--}),(e=>{a.processes--,n(e)}))}(e,t,i,s=s||{},r,(function(){M.scheduleTask((function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1)})),o&&o()}),(function(t){e.error(t),n&&n(t),r.fire("error",t)}))}parse(e,t,i,s,r,o,n){_B(e,"",t,i,s=s||{},r,(function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1),o&&o()}))}}function gB(e){const t={},i={},s=e.metaObjects||[],r={};for(let e=0,t=s.length;e{const l={src:t,metaModelCorrections:s?gB(s):null,loadBuffer:r.loadBuffer,basePath:r.basePath,handlenode:r.handlenode,backfaces:!!r.backfaces,gltfData:i,scene:o.scene,plugin:e,sceneModel:o,numObjects:0,nodes:[],nextId:0,log:t=>{e.log(t)}};!function(e){const t=e.gltfData.textures;if(t)for(let i=0,s=t.length;i0)for(let t=0;t0){null==n&&e.log("Warning: 'name' properties not found on glTF scene nodes - will randomly-generate object IDs in XKT");let t=n;if(e.metaModelCorrections){const i=e.metaModelCorrections.eachChildRoot[t];if(i){const t=e.metaModelCorrections.eachRootStats[i.id];t.countChildren++,t.countChildren>=t.numChildren&&(o.createEntity({id:i.id,meshIds:BB}),BB.length=0)}else{e.metaModelCorrections.metaObjectsMap[t]&&(o.createEntity({id:t,meshIds:BB}),BB.length=0)}}else o.createEntity({id:t,meshIds:BB}),BB.length=0}}function PB(e,t){e.plugin.error(t)}const CB={DEFAULT:{}};function MB(e,t,i={}){const s="lightgrey",r=i.hoverColor||"rgba(0,0,0,0.4)",o=i.textColor||"black",n=500,a=n+n/3,l=a/24,A=[{boundary:[6,6,6,6],color:i.frontColor||i.color||"#55FF55"},{boundary:[18,6,6,6],color:i.backColor||i.color||"#55FF55"},{boundary:[12,6,6,6],color:i.rightColor||i.color||"#FF5555"},{boundary:[0,6,6,6],color:i.leftColor||i.color||"#FF5555"},{boundary:[6,0,6,6],color:i.topColor||i.color||"#7777FF"},{boundary:[6,12,6,6],color:i.bottomColor||i.color||"#7777FF"}],h=[{label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,1,0],up:[0,0,1]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,-1,0],up:[0,0,1]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,0,1]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,0,1]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,0,1],up:[0,-1,0]},{boundaries:[[7,5,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,0,-1],up:[1,0,1]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-1,-1],up:[0,-1,1]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,0,-1],up:[-1,0,1]},{boundaries:[[7,11,4,2]],dir:[0,1,1],up:[0,-1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,0,1],up:[-1,0,1]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,-1,1],up:[0,1,1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,0,1],up:[1,0,1]},{boundaries:[[5,7,2,4]],dir:[1,1,0],up:[0,0,1]},{boundaries:[[11,7,2,4]],dir:[-1,1,0],up:[0,0,1]},{boundaries:[[17,7,2,4]],dir:[-1,-1,0],up:[0,0,1]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,-1,0],up:[0,0,1]},{boundaries:[[5,11,2,2]],dir:[1,1,1],up:[-1,-1,1]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[1,-1,1],up:[-1,1,1]},{boundaries:[[5,5,2,2]],dir:[1,1,-1],up:[1,1,1]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-1,-1,1],up:[1,1,1]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-1,-1,-1],up:[-1,-1,1]},{boundaries:[[11,11,2,2]],dir:[-1,1,1],up:[1,-1,1]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[1,-1,-1],up:[1,-1,1]},{boundaries:[[11,5,2,2]],dir:[-1,1,-1],up:[-1,1,1]}];i.frontColor||i.color,i.backColor||i.color,i.rightColor||i.color,i.leftColor||i.color,i.topColor||i.color,i.bottomColor||i.color;const u=[{yUp:"",label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,0,1],up:[0,1,0]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,1,0]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,1,0]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,-1,0],up:[0,0,-1]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,1,0],up:[0,0,1]},{boundaries:[[7,5,4,2]],dir:[0,-.7071,-.7071],up:[0,.7071,-.7071]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,-1,0],up:[1,1,0]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-.7071,.7071],up:[0,.7071,.7071]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,-1,0],up:[-1,1,0]},{boundaries:[[7,11,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,1,0],up:[-1,1,0]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,1,1],up:[0,1,-1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,1,0],up:[1,1,0]},{boundaries:[[5,7,2,4]],dir:[1,0,-1],up:[0,1,0]},{boundaries:[[11,7,2,4]],dir:[-1,0,-1],up:[0,1,0]},{boundaries:[[17,7,2,4]],dir:[-1,0,1],up:[0,1,0]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,0,1],up:[0,1,0]},{boundaries:[[5,11,2,2]],dir:[.5,.7071,-.5],up:[-.5,.7071,.5]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[.5,.7071,.5],up:[-.5,.7071,-.5]},{boundaries:[[5,5,2,2]],dir:[.5,-.7071,-.5],up:[.5,.7071,-.5]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-.5,.7071,.5],up:[.5,.7071,-.5]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-.5,-.7071,.5],up:[-.5,.7071,.5]},{boundaries:[[11,11,2,2]],dir:[-.5,.7071,-.5],up:[.5,.7071,.5]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[.5,-.7071,.5],up:[.5,.7071,.5]},{boundaries:[[11,5,2,2]],dir:[-.5,-.7071,-.5],up:[-.5,.7071,-.5]}];for(let e=0,t=h.length;e=r[0]*l&&t<=(r[0]+r[2])*l&&i>=r[1]*l&&i<=(r[1]+r[3])*l)return s}}return-1},this.setAreaHighlighted=function(e,t){var i=d[e];if(!i)throw"Area not found: "+e;i.highlighted=!!t,g()},this.getAreaDir=function(e){var t=d[e];if(!t)throw"Unknown area: "+e;return t.dir},this.getAreaUp=function(e){var t=d[e];if(!t)throw"Unknown area: "+e;return t.up},this.getImage=function(){return this._textureCanvas},this.destroy=function(){this._textureCanvas&&(this._textureCanvas.parentNode.removeChild(this._textureCanvas),this._textureCanvas=null)}}const FB=c.vec3(),EB=c.vec3();c.mat4();const IB=c.vec3();class DB{load(e,t,i={}){var s=e.scene.canvas.spinner;s.processes++,SB(e,t,(function(t){!function(e,t,i){for(var s=t.basePath,r=Object.keys(t.materialLibraries),o=r.length,n=0,a=o;n=0?i-1:i+t/3)}function r(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function o(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)}function n(e,t,i,s){var r=e.positions,o=e.object.geometry.positions;o.push(r[t+0]),o.push(r[t+1]),o.push(r[t+2]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[i+2]),o.push(r[s+0]),o.push(r[s+1]),o.push(r[s+2])}function a(e,t){var i=e.positions,s=e.object.geometry.positions;s.push(i[t+0]),s.push(i[t+1]),s.push(i[t+2])}function l(e,t,i,s){var r=e.normals,o=e.object.geometry.normals;o.push(r[t+0]),o.push(r[t+1]),o.push(r[t+2]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[i+2]),o.push(r[s+0]),o.push(r[s+1]),o.push(r[s+2])}function A(e,t,i,s){var r=e.uv,o=e.object.geometry.uv;o.push(r[t+0]),o.push(r[t+1]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[s+0]),o.push(r[s+1])}function h(e,t){var i=e.uv,s=e.object.geometry.uv;s.push(i[t+0]),s.push(i[t+1])}function c(e,t,i,a,h,c,u,d,p,f,g,m,_){var v,b=e.positions.length,y=s(t,b),x=s(i,b),B=s(a,b);if(void 0===h?n(e,y,x,B):(n(e,y,x,v=s(h,b)),n(e,x,B,v)),void 0!==c){var w=e.uv.length;y=o(c,w),x=o(u,w),B=o(d,w),void 0===h?A(e,y,x,B):(A(e,y,x,v=o(p,w)),A(e,x,B,v))}if(void 0!==f){var P=e.normals.length;y=r(f,P),x=f===g?y:r(g,P),B=f===m?y:r(m,P),void 0===h?l(e,y,x,B):(l(e,y,x,v=r(_,P)),l(e,x,B,v))}}function u(e,t,i){e.object.geometry.type="Line";for(var r=e.positions.length,n=e.uv.length,l=0,A=t.length;l=0?n.substring(0,a):n).toLowerCase(),A=(A=a>=0?n.substring(a+1):"").trim(),l.toLowerCase()){case"newmtl":i(e,u),u={id:A},d=!0;break;case"ka":u.ambient=s(A);break;case"kd":u.diffuse=s(A);break;case"ks":u.specular=s(A);break;case"map_kd":u.diffuseMap||(u.diffuseMap=t(e,o,A,"sRGB"));break;case"map_ks":u.specularMap||(u.specularMap=t(e,o,A,"linear"));break;case"map_bump":case"bump":u.normalMap||(u.normalMap=t(e,o,A));break;case"ns":u.shininess=parseFloat(A);break;case"d":(h=parseFloat(A))<1&&(u.alpha=h,u.alphaMode="blend");break;case"tr":(h=parseFloat(A))>0&&(u.alpha=1-h,u.alphaMode="blend")}d&&i(e,u)};function t(e,t,i,s){var r={},o=i.split(/\s+/),n=o.indexOf("-bm");return n>=0&&o.splice(n,2),(n=o.indexOf("-s"))>=0&&(r.scale=[parseFloat(o[n+1]),parseFloat(o[n+2])],o.splice(n,4)),(n=o.indexOf("-o"))>=0&&(r.translate=[parseFloat(o[n+1]),parseFloat(o[n+2])],o.splice(n,4)),r.src=t+o.join(" ").trim(),r.flipY=!0,r.encoding=s||"linear",new Bs(e,r).id}function i(e,t){new Vt(e,t)}function s(t){var i=t.split(e,3);return[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])]}}();function UB(e,t){for(var i=0,s=t.objects.length;i0&&(n.normals=o.normals),o.uv.length>0&&(n.uv=o.uv);for(var a=new Array(n.positions.length/3),l=0;l{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),G(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=c.vec3PairToQuaternion(OB,e,NB)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,i=.01;this._rootNode=new as(t,{position:[0,0,0],scale:[5,5,5],isObject:!1});const s=this._rootNode,r={arrowHead:new Ut(s,Ki({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Ut(s,Ki({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),arrowHeadHandle:new Ut(s,Ki({radiusTop:.09,radiusBottom:.09,radialSegments:8,heightSegments:1,height:.37,openEnded:!1})),curve:new Ut(s,Ds({radius:.8,tube:i,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),curveHandle:new Ut(s,Ds({radius:.8,tube:.06,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),hoop:new Ut(s,Ds({radius:.8,tube:i,radialSegments:64,tubeSegments:8,arc:2*Math.PI})),axis:new Ut(s,Ki({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1})),axisHandle:new Ut(s,Ki({radiusTop:.08,radiusBottom:.08,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},o={pickable:new Vt(s,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),red:new Vt(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new jt(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6}),green:new Vt(s,{diffuse:[0,1,0],emissive:[0,1,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightGreen:new jt(s,{edges:!1,fill:!0,fillColor:[0,1,0],fillAlpha:.6}),blue:new Vt(s,{diffuse:[0,0,1],emissive:[0,0,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightBlue:new jt(s,{edges:!1,fill:!0,fillColor:[0,0,1],fillAlpha:.2}),center:new Vt(s,{diffuse:[0,0,0],emissive:[0,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80}),highlightBall:new jt(s,{edges:!1,fill:!0,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1}),highlightPlane:new jt(s,{edges:!0,edgeWidth:3,fill:!1,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1})};this._displayMeshes={plane:s.addChild(new zi(s,{geometry:new Ut(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Vt(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new jt(s,{edges:!1,filled:!0,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:.1,backfaces:!0}),pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1],isObject:!1}),e),planeFrame:s.addChild(new zi(s,{geometry:new Ut(s,Ds({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Vt(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new jt(s,{edges:!1,edgeColor:[0,0,0],filled:!0,fillColor:[.8,.8,.8],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45],isObject:!1}),e),xCurve:s.addChild(new zi(s,{geometry:r.curve,material:o.red,matrix:function(){const e=c.rotationMat4v(90*c.DEGTORAD,[0,1,0],c.identityMat4()),t=c.rotationMat4v(270*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveHandle:s.addChild(new zi(s,{geometry:r.curveHandle,material:o.pickable,matrix:function(){const e=c.rotationMat4v(90*c.DEGTORAD,[0,1,0],c.identityMat4()),t=c.rotationMat4v(270*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveArrow1:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=c.translateMat4c(0,-.07,-.8,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(0*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xCurveArrow2:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=c.translateMat4c(0,-.8,-.07,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurve:s.addChild(new zi(s,{geometry:r.curve,material:o.green,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveHandle:s.addChild(new zi(s,{geometry:r.curveHandle,material:o.pickable,rotation:[-90,0,0],pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveArrow1:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=c.translateMat4c(.07,0,-.8,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurveArrow2:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=c.translateMat4c(.8,0,-.07,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurve:s.addChild(new zi(s,{geometry:r.curve,material:o.blue,matrix:c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4()),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveHandle:s.addChild(new zi(s,{geometry:r.curveHandle,material:o.pickable,matrix:c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4()),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveCurveArrow1:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=c.translateMat4c(.8,-.07,0,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4());return c.mulMat4(e,t,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveArrow2:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=c.translateMat4c(.05,-.8,0,c.identityMat4()),t=c.scaleMat4v([.6,.6,.6],c.identityMat4()),i=c.rotationMat4v(90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(c.mulMat4(e,t,c.identityMat4()),i,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),center:s.addChild(new zi(s,{geometry:new Ut(s,Xi({radius:.05})),material:o.center,pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrowHandle:s.addChild(new zi(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxis:s.addChild(new zi(s,{geometry:r.axis,material:o.red,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisHandle:s.addChild(new zi(s,{geometry:r.axisHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrowHandle:s.addChild(new zi(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,opacity:.2,isObject:!1}),e),yShaft:s.addChild(new zi(s,{geometry:r.axis,material:o.green,position:[0,-.5,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yShaftHandle:s.addChild(new zi(s,{geometry:r.axisHandle,material:o.pickable,position:[0,-.5,0],pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrowHandle:s.addChild(new zi(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zShaft:s.addChild(new zi(s,{geometry:r.axis,material:o.blue,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1,isObject:!1}),e),zAxisHandle:s.addChild(new zi(s,{geometry:r.axisHandle,material:o.pickable,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),clippable:!1,pickable:!0,collidable:!0,visible:!1,isObject:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new zi(s,{geometry:new Ut(s,Ds({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Vt(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new jt(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45],isObject:!1}),e),xHoop:s.addChild(new zi(s,{geometry:r.hoop,material:o.red,highlighted:!0,highlightMaterial:o.highlightRed,matrix:function(){const e=c.rotationMat4v(90*c.DEGTORAD,[0,1,0],c.identityMat4()),t=c.rotationMat4v(270*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yHoop:s.addChild(new zi(s,{geometry:r.hoop,material:o.green,highlighted:!0,highlightMaterial:o.highlightGreen,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zHoop:s.addChild(new zi(s,{geometry:r.hoop,material:o.blue,highlighted:!0,highlightMaterial:o.highlightBlue,matrix:c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4()),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHeadBig,material:o.red,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[0,0,1],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHeadBig,material:o.green,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(180*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHeadBig,material:o.blue,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e)}}_bindEvents(){const e=this;var t=!1;const i=-1,s=0,r=1,o=2,n=3,a=4,l=5,A=this._rootNode;var h=null,u=null;const d=c.vec2(),p=c.vec3([1,0,0]),f=c.vec3([0,1,0]),g=c.vec3([0,0,1]),m=this._viewer.scene.canvas.canvas,_=this._viewer.camera,v=this._viewer.scene;{const e=c.vec3([0,0,0]);let t=-1;this._onCameraViewMatrix=v.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=v.camera.on("projMatrix",(()=>{})),this._onSceneTick=v.on("tick",(()=>{const i=Math.abs(c.lenVec3(c.subVec3(v.camera.eye,this._pos,e)));if(i!==t&&"perspective"===_.projection){const e=.07*(Math.tan(_.perspective.fov*c.DEGTORAD)*i);A.scale=[e,e,e],t=i}if("ortho"===_.projection){const e=_.ortho.scale/10;A.scale=[e,e,e],t=i}}))}const b=function(){const e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),y=function(){const t=c.mat4();return function(i,s){return c.quaternionToMat4(e._rootNode.quaternion,t),c.transformVec3(t,i,s),c.normalizeVec3(s),s}}();var x=function(){const e=c.vec3();return function(t){const i=Math.abs(t[0]);return i>Math.abs(t[1])&&i>Math.abs(t[2])?c.cross3Vec3(t,[0,1,0],e):c.cross3Vec3(t,[1,0,0],e),c.cross3Vec3(e,t,e),c.normalizeVec3(e),e}}();const B=function(){const t=c.vec3(),i=c.vec3(),s=c.vec4();return function(r,o,n){y(r,s);const a=x(s,o,n);P(o,a,t),P(n,a,i),c.subVec3(i,t);const l=c.dotVec3(i,s);e._pos[0]+=s[0]*l,e._pos[1]+=s[1]*l,e._pos[2]+=s[2]*l,e._rootNode.position=e._pos,e._sectionPlane&&(e._sectionPlane.pos=e._pos)}}();var w=function(){const t=c.vec4(),i=c.vec4(),s=c.vec4(),r=c.vec4();return function(o,n,a){y(o,r);if(!(P(n,r,t)&&P(a,r,i))){const e=x(r,n,a);P(n,e,t,1),P(a,e,i,1);var l=c.dotVec3(t,r);t[0]-=l*r[0],t[1]-=l*r[1],t[2]-=l*r[2],l=c.dotVec3(i,r),i[0]-=l*r[0],i[1]-=l*r[1],i[2]-=l*r[2]}c.normalizeVec3(t),c.normalizeVec3(i),l=c.dotVec3(t,i),l=c.clamp(l,-1,1);var A=Math.acos(l)*c.RADTODEG;c.cross3Vec3(t,i,s),c.dotVec3(s,r)<0&&(A=-A),e._rootNode.rotate(o,A),C()}}(),P=function(){const t=c.vec4([0,0,0,1]),i=c.mat4();return function(s,r,o,n){n=n||0,t[0]=s[0]/m.width*2-1,t[1]=-(s[1]/m.height*2-1),t[2]=0,t[3]=1,c.mulMat4(_.projMatrix,_.viewMatrix,i),c.inverseMat4(i),c.transformVec4(i,t,t),c.mulVec4Scalar(t,1/t[3]);var a=_.eye;c.subVec4(t,a,t);const l=e._sectionPlane.pos;var A=-c.dotVec3(l,r)-n,h=c.dotVec3(r,t);if(Math.abs(h)>.005){var u=-(c.dotVec3(r,a)+A)/h;return c.mulVec3Scalar(t,u,o),c.addVec3(o,a),c.subVec3(o,l,o),!0}return!1}}();const C=function(){const t=c.vec3(),i=c.mat4();return function(){e.sectionPlane&&(c.quaternionToMat4(A.quaternion,i),c.transformVec3(i,[0,0,1],t),e._setSectionPlaneDir(t))}}();var M,F=!1;this._onCameraControlHover=this._viewer.cameraControl.on("hoverEnter",(e=>{if(!this._visible)return;if(F)return;var A;t=!1,M&&(M.visible=!1);switch(e.entity.id){case this._displayMeshes.xAxisArrowHandle.id:case this._displayMeshes.xAxisHandle.id:A=this._affordanceMeshes.xAxisArrow,h=s;break;case this._displayMeshes.yAxisArrowHandle.id:case this._displayMeshes.yShaftHandle.id:A=this._affordanceMeshes.yAxisArrow,h=r;break;case this._displayMeshes.zAxisArrowHandle.id:case this._displayMeshes.zAxisHandle.id:A=this._affordanceMeshes.zAxisArrow,h=o;break;case this._displayMeshes.xCurveHandle.id:A=this._affordanceMeshes.xHoop,h=n;break;case this._displayMeshes.yCurveHandle.id:A=this._affordanceMeshes.yHoop,h=a;break;case this._displayMeshes.zCurveHandle.id:A=this._affordanceMeshes.zHoop,h=l;break;default:return void(h=i)}A&&(A.visible=!0),M=A,t=!0})),this._onCameraControlHoverLeave=this._viewer.cameraControl.on("hoverOutEntity",(e=>{this._visible&&(M&&(M.visible=!1),M=null,h=i)})),m.addEventListener("mousedown",this._canvasMouseDownListener=e=>{if(e.preventDefault(),this._visible&&t&&(this._viewer.cameraControl.pointerEnabled=!1,1===e.which)){F=!0;var i=b(e);u=h,d[0]=i[0],d[1]=i[1]}}),m.addEventListener("mousemove",this._canvasMouseMoveListener=e=>{if(!this._visible)return;if(!F)return;var t=b(e);const i=t[0],A=t[1];switch(u){case s:B(p,d,t);break;case r:B(f,d,t);break;case o:B(g,d,t);break;case n:w(p,d,t);break;case a:w(f,d,t);break;case l:w(g,d,t)}d[0]=i,d[1]=A}),m.addEventListener("mouseup",this._canvasMouseUpListener=e=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,F&&(e.which,F=!1,t=!1))}),m.addEventListener("wheel",this._canvasWheelListener=e=>{if(this._visible)Math.max(-1,Math.min(1,40*-e.deltaY))})}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=e.cameraControl;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix),r.off(this._onCameraControlHover),r.off(this._onCameraControlHoverLeave)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class VB{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new zi(t,{id:i.id,geometry:new Ut(t,kt({xSize:.5,ySize:.5,zSize:.001})),material:new Vt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new zt(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new jt(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new jt(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=c.vec3([0,0,0]),t=c.vec3(),i=c.vec3([0,0,1]),s=c.vec4(4),r=c.vec3(),o=()=>{const o=this._sectionPlane.scene.center,n=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];c.subVec3(o,this._sectionPlane.pos,e);const a=-c.dotVec3(n,e);c.normalizeVec3(n),c.mulVec3Scalar(n,a,t);const l=c.vec3PairToQuaternion(i,this._sectionPlane.dir,s);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=l,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",o),this._onSectionPlaneDir=this._sectionPlane.on("dir",o)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class HB{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new ei(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Bt(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Bt(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Bt(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=c.rotationMat4c(-90*c.DEGTORAD,1,0,0),i=c.vec3(),s=c.vec3(),r=c.vec3();this._synchCamera=()=>{const o=this._viewer.camera.eye,n=this._viewer.camera.look,a=this._viewer.camera.up;c.mulVec3Scalar(c.normalizeVec3(c.subVec3(o,n,i)),7),this._zUp?(c.transformVec3(t,i,s),c.transformVec3(t,a,r),e.look=[0,0,0],e.eye=c.transformVec3(t,i,s),e.up=c.transformPoint3(t,a,r)):(e.look=[0,0,0],e.eye=i,e.up=a)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new VB(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const jB=c.AABB3(),GB=c.vec3();class zB{constructor(e,t,i,s,r,o){this.plugin=e,this.storeyId=r,this.modelId=s,this.storeyAABB=i.slice(),this.aabb=this.storeyAABB,this.modelAABB=t.slice(),this.numObjects=o}}class WB{constructor(e,t,i,s,r,o){this.storeyId=e,this.imageData=t,this.format=i,this.width=s,this.height=r}}const KB=c.vec3(),XB=c.mat4();const JB=new Float64Array([0,0,1]),YB=new Float64Array(4);class ZB{constructor(e){this.id=null,this._viewer=e.viewer,this._plugin=e,this._visible=!1,this._pos=c.vec3(),this._origin=c.vec3(),this._rtcPos=c.vec3(),this._baseDir=c.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}_setSectionPlane(e){this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(()=>{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),G(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=c.vec3PairToQuaternion(JB,e,YB)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,i=.01;this._rootNode=new as(t,{position:[0,0,0],scale:[5,5,5]});const s=this._rootNode,r={arrowHead:new Ut(s,Ki({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Ut(s,Ki({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new Ut(s,Ki({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},o={red:new Vt(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new Vt(s,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new Vt(s,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new jt(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:s.addChild(new zi(s,{geometry:new Ut(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Vt(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1]}),e),planeFrame:s.addChild(new zi(s,{geometry:new Ut(s,Ds({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Vt(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45]}),e),center:s.addChild(new zi(s,{geometry:new Ut(s,Xi({radius:.05})),material:o.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:s.addChild(new zi(s,{geometry:r.axis,material:o.blue,matrix:function(){const e=c.translateMat4c(0,.5,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[1,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new zi(s,{geometry:new Ut(s,Ds({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Vt(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new jt(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45]}),e),zAxisArrow:s.addChild(new zi(s,{geometry:r.arrowHeadBig,material:o.blue,matrix:function(){const e=c.translateMat4c(0,1.1,0,c.identityMat4()),t=c.rotationMat4v(-90*c.DEGTORAD,[.8,0,0],c.identityMat4());return c.mulMat4(t,e,c.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}_bindEvents(){const e=this._rootNode,t=c.vec2(),i=this._viewer.camera,s=this._viewer.scene;let r=0,o=!1;{const t=c.vec3([0,0,0]);let n=-1;this._onCameraViewMatrix=s.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=s.camera.on("projMatrix",(()=>{})),this._onSceneTick=s.on("tick",(()=>{o=!1;const l=Math.abs(c.lenVec3(c.subVec3(s.camera.eye,this._pos,t)));if(l!==n&&"perspective"===i.projection){const t=.07*(Math.tan(i.perspective.fov*c.DEGTORAD)*l);e.scale=[t,t,t],n=l}if("ortho"===i.projection){const t=i.ortho.scale/10;e.scale=[t,t,t],n=l}0!==r&&(a(r),r=0)}))}const n=function(){const e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),a=e=>{const t=this._sectionPlane.pos,i=this._sectionPlane.dir;c.addVec3(t,c.mulVec3Scalar(i,.1*e*this._plugin.getDragSensitivity(),c.vec3())),this._sectionPlane.pos=t};{let e=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=i=>{if(i.preventDefault(),this._visible&&(this._viewer.cameraControl.pointerEnabled=!1,1===i.which)){e=!0;var s=n(i);t[0]=s[0],t[1]=s[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=i=>{if(!this._visible)return;if(!e)return;if(o)return;var s=n(i);const r=s[0],l=s[1];a(l-t[1]),t[0]=r,t[1]=l}),this._plugin._controlElement.addEventListener("mouseup",this._canvasMouseUpListener=t=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,e&&(t.which,e=!1))}),this._plugin._controlElement.addEventListener("wheel",this._canvasWheelListener=e=>{this._visible&&(r+=Math.max(-1,Math.min(1,40*-e.deltaY)))})}{let e,t,i=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=t=>{t.stopPropagation(),t.preventDefault(),this._visible&&(e=t.touches[0].clientY,i=e,r=0)}),this._plugin._controlElement.addEventListener("touchmove",this._handleTouchMove=e=>{e.stopPropagation(),e.preventDefault(),this._visible&&(o||(o=!0,t=e.touches[0].clientY,null!==i&&(r+=t-i),i=t))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=i=>{i.stopPropagation(),i.preventDefault(),this._visible&&(e=null,t=null,r=0)})}}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class qB{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new zi(t,{id:i.id,geometry:new Ut(t,kt({xSize:.5,ySize:.5,zSize:.001})),material:new Vt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new zt(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new jt(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new jt(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=c.vec3([0,0,0]),t=c.vec3(),i=c.vec3([0,0,1]),s=c.vec4(4),r=c.vec3(),o=()=>{const o=this._sectionPlane.scene.center,n=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];c.subVec3(o,this._sectionPlane.pos,e);const a=-c.dotVec3(n,e);c.normalizeVec3(n),c.mulVec3Scalar(n,a,t);const l=c.vec3PairToQuaternion(i,this._sectionPlane.dir,s);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=l,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",o),this._onSectionPlaneDir=this._sectionPlane.on("dir",o)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class $B{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new ei(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Bt(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Bt(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Bt(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=c.rotationMat4c(-90*c.DEGTORAD,1,0,0),i=c.vec3(),s=c.vec3(),r=c.vec3();this._synchCamera=()=>{const o=this._viewer.camera.eye,n=this._viewer.camera.look,a=this._viewer.camera.up;c.mulVec3Scalar(c.normalizeVec3(c.subVec3(o,n,i)),7),this._zUp?(c.transformVec3(t,i,s),c.transformVec3(t,a,r),e.look=[0,0,0],e.eye=c.transformVec3(t,i,s),e.up=c.transformPoint3(t,a,r)):(e.look=[0,0,0],e.eye=i,e.up=a)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new qB(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const ew=c.AABB3(),tw=c.vec3();class iw{getSTL(e,t,i){const s=new XMLHttpRequest;s.overrideMimeType("application/json"),s.open("GET",e,!0),s.responseType="arraybuffer",s.onreadystatechange=function(){4===s.readyState&&(200===s.status?t(s.response):i(s.statusText))},s.send(null)}}const sw=c.vec3();class rw{load(e,t,i,s,r,o){s=s||{};const n=e.viewer.scene.canvas.spinner;n.processes++,e.dataSource.getSTL(i,(function(i){!function(e,t,i,s){try{const r=hw(i);ow(r)?nw(e,r,t,s):aw(e,Aw(i),t,s)}catch(e){t.fire("error",e)}}(e,t,i,s);try{const o=hw(i);ow(o)?nw(e,o,t,s):aw(e,Aw(i),t,s),n.processes--,M.scheduleTask((function(){t.fire("loaded",!0,!1)})),r&&r()}catch(i){n.processes--,e.error(i),o&&o(i),t.fire("error",i)}}),(function(i){n.processes--,e.error(i),o&&o(i),t.fire("error",i)}))}parse(e,t,i,s){const r=e.viewer.scene.canvas.spinner;r.processes++;try{const o=hw(i);ow(o)?nw(e,o,t,s):aw(e,Aw(i),t,s),r.processes--,M.scheduleTask((function(){t.fire("loaded",!0,!1)}))}catch(e){r.processes--,t.fire("error",e)}}}function ow(e){const t=new DataView(e);if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;const i=[115,111,108,105,100];for(var s=0;s<5;s++)if(i[s]!==t.getUint8(s,!1))return!0;return!1}function nw(e,t,i,s){const r=new DataView(t),o=r.getUint32(80,!0);let n,a,l,A,h,c,u,d=!1,p=null,f=null,g=null,m=!1;for(let e=0;e<70;e++)1129270351===r.getUint32(e,!1)&&82===r.getUint8(e+4)&&61===r.getUint8(e+5)&&(d=!0,A=[],h=r.getUint8(e+6)/255,c=r.getUint8(e+7)/255,u=r.getUint8(e+8)/255,r.getUint8(e+9));const _=new cs(i,{roughness:.5});let v=[],b=[],y=s.splitMeshes;for(let e=0;e>5&31)/31,l=(e>>10&31)/31):(n=h,a=c,l=u),(y&&n!==p||a!==f||l!==g)&&(null!==p&&(m=!0),p=n,f=a,g=l)}for(let e=1;e<=3;e++){let i=t+12*e;v.push(r.getFloat32(i,!0)),v.push(r.getFloat32(i+4,!0)),v.push(r.getFloat32(i+8,!0)),b.push(o,x,B),d&&A.push(n,a,l,1)}y&&m&&(lw(i,v,b,A,_,s),v=[],b=[],A=A?[]:null,m=!1)}v.length>0&&lw(i,v,b,A,_,s)}function aw(e,t,i,s){const r=/facet([\s\S]*?)endfacet/g;let o=0;const n=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,a=new RegExp("vertex"+n+n+n,"g"),l=new RegExp("normal"+n+n+n,"g"),A=[],h=[];let c,u,d,p,f,g,m;for(;null!==(p=r.exec(t));){for(f=0,g=0,m=p[0];null!==(p=l.exec(m));)c=parseFloat(p[1]),u=parseFloat(p[2]),d=parseFloat(p[3]),g++;for(;null!==(p=a.exec(m));)A.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),h.push(c,u,d),f++;1!==g&&e.error("Error in normal of face "+o),3!==f&&e.error("Error in positions of face "+o),o++}lw(i,A,h,null,new cs(i,{roughness:.5}),s)}function lw(e,t,i,s,r,o){const n=new Int32Array(t.length/3);for(let e=0,t=n.length;e0?i:null,s=s&&s.length>0?s:null,o.smoothNormals&&c.faceToVertexNormals(t,i,o);const a=sw;z(t,t,a);const l=new Ut(e,{primitive:"triangles",positions:t,normals:i,colors:s,indices:n}),A=new zi(e,{origin:0!==a[0]||0!==a[1]||0!==a[2]?a:null,geometry:l,material:r,edges:o.edges});e.addChild(A)}function Aw(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,s=e.length;i0){const i=document.createElement("a");i.href="#",i.id=`switch-${e.nodeId}`,i.textContent="+",i.classList.add("plus"),t&&i.addEventListener("click",t),o.appendChild(i)}const n=document.createElement("input");n.id=`checkbox-${e.nodeId}`,n.type="checkbox",n.checked=e.checked,n.style["pointer-events"]="all",i&&n.addEventListener("change",i),o.appendChild(n);const a=document.createElement("span");return a.textContent=e.title,o.appendChild(a),s&&(a.oncontextmenu=s),r&&(a.onclick=r),o}createDisabledNodeElement(e){const t=document.createElement("li"),i=document.createElement("a");i.href="#",i.textContent="!",i.classList.add("warn"),i.classList.add("warning"),t.appendChild(i);const s=document.createElement("span");return s.textContent=e,t.appendChild(s),t}addChildren(e,t){const i=document.createElement("ul");t.forEach((e=>{i.appendChild(e)})),e.parentElement.appendChild(i)}expand(e,t,i){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",i)}collapse(e,t,i){if(!e)return;const s=e.parentElement;if(!s)return;const r=s.querySelector("ul");r&&(s.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",i),e.addEventListener("click",t))}isExpanded(e){return void 0!==e.parentElement.getElementsByTagName("li")[0]}getId(e){return e.parentElement.id}getIdFromCheckbox(e){return e.id.replace("checkbox-","")}getSwitchElement(e){return document.getElementById(`switch-${e}`)}isChecked(e){return e.checked}setCheckbox(e,t){const i=document.getElementById(`checkbox-${e}`);i&&t!==i.checked&&(i.checked=t)}setXRayed(e,t){const i=document.getElementById(e);i&&(t?i.classList.add("xrayed-node"):i.classList.remove("xrayed-node"))}setHighlighted(e,t){const i=document.getElementById(e);i&&(t?(i.scrollIntoView({block:"center"}),i.classList.add("highlighted-node")):i.classList.remove("highlighted-node"))}}const uw=[];class dw{constructor(e){this._scene=e,this._objects=[],this._objectsViewCulled=[],this._objectsDetailCulled=[],this._objectsChanged=[],this._objectsChangedList=[],this._modelInfos={},this._numObjects=0,this._lenObjectsChangedList=0,this._dirty=!0,this._onModelLoaded=e.on("modelLoaded",(t=>{const i=e.models[t];i&&this._addModel(i)})),this._onTick=e.on("tick",(()=>{this._dirty&&this._build(),this._applyChanges()}))}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._dirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._dirty=!0)}_build(){if(!this._dirty)return;this._applyChanges();const e=this._scene.objects;for(let e=0;e0){for(let e=0;e{t(e)}),(function(e){i(e)}))}getMetaModel(e,t,i){_.loadJSON(e,(e=>{t(e)}),(function(e){i(e)}))}getXKT(e,t,i){var s=()=>{};t=t||s,i=i||s;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var o=r[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),i=new Uint8Array(e);for(var n=0;n=0;)e[t]=0}const i=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),s=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),o=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),n=new Array(576);t(n);const a=new Array(60);t(a);const l=new Array(512);t(l);const A=new Array(256);t(A);const h=new Array(29);t(h);const c=new Array(30);function u(e,t,i,s,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=s,this.max_length=r,this.has_stree=e&&e.length}let d,p,f;function g(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}t(c);const m=e=>e<256?l[e]:l[256+(e>>>7)],_=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},v=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<{v(e,i[2*t],i[2*t+1])},y=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},x=(e,t,i)=>{const s=new Array(16);let r,o,n=0;for(r=1;r<=15;r++)n=n+i[r-1]<<1,s[r]=n;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=y(s[t]++,t))}},B=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},w=e=>{e.bi_valid>8?_(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},P=(e,t,i,s)=>{const r=2*t,o=2*i;return e[r]{const s=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r{let o,n,a,l,u=0;if(0!==e.sym_next)do{o=255&e.pending_buf[e.sym_buf+u++],o+=(255&e.pending_buf[e.sym_buf+u++])<<8,n=e.pending_buf[e.sym_buf+u++],0===o?b(e,n,t):(a=A[n],b(e,a+256+1,t),l=i[a],0!==l&&(n-=h[a],v(e,n,l)),o--,a=m(o),b(e,a,r),l=s[a],0!==l&&(o-=c[a],v(e,o,l)))}while(u{const i=t.dyn_tree,s=t.stat_desc.static_tree,r=t.stat_desc.has_stree,o=t.stat_desc.elems;let n,a,l,A=-1;for(e.heap_len=0,e.heap_max=573,n=0;n>1;n>=1;n--)C(e,i,n);l=o;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],C(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=a,i[2*l]=i[2*n]+i[2*a],e.depth[l]=(e.depth[n]>=e.depth[a]?e.depth[n]:e.depth[a])+1,i[2*n+1]=i[2*a+1]=l,e.heap[1]=l++,C(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,s=t.max_code,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,n=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length;let A,h,c,u,d,p,f=0;for(u=0;u<=15;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,A=e.heap_max+1;A<573;A++)h=e.heap[A],u=i[2*i[2*h+1]+1]+1,u>l&&(u=l,f++),i[2*h+1]=u,h>s||(e.bl_count[u]++,d=0,h>=a&&(d=n[h-a]),p=i[2*h],e.opt_len+=p*(u+d),o&&(e.static_len+=p*(r[2*h+1]+d)));if(0!==f){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,f-=2}while(f>0);for(u=l;0!==u;u--)for(h=e.bl_count[u];0!==h;)c=e.heap[--A],c>s||(i[2*c+1]!==u&&(e.opt_len+=(u-i[2*c+1])*i[2*c],i[2*c+1]=u),h--)}})(e,t),x(i,A,e.bl_count)},E=(e,t,i)=>{let s,r,o=-1,n=t[1],a=0,l=7,A=4;for(0===n&&(l=138,A=3),t[2*(i+1)+1]=65535,s=0;s<=i;s++)r=n,n=t[2*(s+1)+1],++a{let s,r,o=-1,n=t[1],a=0,l=7,A=4;for(0===n&&(l=138,A=3),s=0;s<=i;s++)if(r=n,n=t[2*(s+1)+1],!(++a{v(e,0+(s?1:0),3),w(e),_(e,i),_(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var T={_tr_init:e=>{D||((()=>{let e,t,o,g,m;const _=new Array(16);for(o=0,g=0;g<28;g++)for(h[g]=o,e=0;e<1<>=7;g<30;g++)for(c[g]=m<<7,e=0;e<1<{let r,l,A=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),F(e,e.l_desc),F(e,e.d_desc),A=(e=>{let t;for(E(e,e.dyn_ltree,e.l_desc.max_code),E(e,e.dyn_dtree,e.d_desc.max_code),F(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*o[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,l=e.static_len+3+7>>>3,l<=r&&(r=l)):r=l=i+5,i+4<=r&&-1!==t?S(e,t,i,s):4===e.strategy||l===r?(v(e,2+(s?1:0),3),M(e,n,a)):(v(e,4+(s?1:0),3),((e,t,i,s)=>{let r;for(v(e,t-257,5),v(e,i-1,5),v(e,s-4,4),r=0;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(A[i]+256+1)]++,e.dyn_dtree[2*m(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{v(e,2,3),b(e,256,n),(e=>{16===e.bi_valid?(_(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}},R=(e,t,i,s)=>{let r=65535&e|0,o=e>>>16&65535|0,n=0;for(;0!==i;){n=i>2e3?2e3:i,i-=n;do{r=r+t[s++]|0,o=o+r|0}while(--n);r%=65521,o%=65521}return r|o<<16|0};const L=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var U=(e,t,i,s)=>{const r=L,o=s+i;e^=-1;for(let i=s;i>>8^r[255&(e^t[i])];return-1^e},k={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},O={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:N,_tr_stored_block:Q,_tr_flush_block:V,_tr_tally:H,_tr_align:j}=T,{Z_NO_FLUSH:G,Z_PARTIAL_FLUSH:z,Z_FULL_FLUSH:W,Z_FINISH:K,Z_BLOCK:X,Z_OK:J,Z_STREAM_END:Y,Z_STREAM_ERROR:Z,Z_DATA_ERROR:q,Z_BUF_ERROR:$,Z_DEFAULT_COMPRESSION:ee,Z_FILTERED:te,Z_HUFFMAN_ONLY:ie,Z_RLE:se,Z_FIXED:re,Z_DEFAULT_STRATEGY:oe,Z_UNKNOWN:ne,Z_DEFLATED:ae}=O,le=258,Ae=262,he=42,ce=113,ue=666,de=(e,t)=>(e.msg=k[t],t),pe=e=>2*e-(e>4?9:0),fe=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ge=e=>{let t,i,s,r=e.w_size;t=e.hash_size,s=t;do{i=e.head[--s],e.head[s]=i>=r?i-r:0}while(--t);t=r,s=t;do{i=e.prev[--s],e.prev[s]=i>=r?i-r:0}while(--t)};let me=(e,t,i)=>(t<{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},ve=(e,t)=>{V(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,_e(e.strm)},be=(e,t)=>{e.pending_buf[e.pending++]=t},ye=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},xe=(e,t,i,s)=>{let r=e.avail_in;return r>s&&(r=s),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=R(e.adler,t,r,i):2===e.state.wrap&&(e.adler=U(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},Be=(e,t)=>{let i,s,r=e.max_chain_length,o=e.strstart,n=e.prev_length,a=e.nice_match;const l=e.strstart>e.w_size-Ae?e.strstart-(e.w_size-Ae):0,A=e.window,h=e.w_mask,c=e.prev,u=e.strstart+le;let d=A[o+n-1],p=A[o+n];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,A[i+n]===p&&A[i+n-1]===d&&A[i]===A[o]&&A[++i]===A[o+1]){o+=2,i++;do{}while(A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&on){if(e.match_start=t,n=s,s>=a)break;d=A[o+n-1],p=A[o+n]}}}while((t=c[t&h])>l&&0!=--r);return n<=e.lookahead?n:e.lookahead},we=e=>{const t=e.w_size;let i,s,r;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Ae)&&(e.window.set(e.window.subarray(t,t+t-s),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),ge(e),s+=t),0===e.strm.avail_in)break;if(i=xe(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=i,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=me(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=me(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let i,s,r,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_outs+e.strm.avail_in&&(i=s+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,_e(e.strm),s&&(s>i&&(s=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,i-=s),i&&(xe(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===n);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(xe(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,o=r>e.w_size?e.w_size:r,s=e.strstart-e.block_start,(s>=o||(s||t===K)&&t!==G&&0===e.strm.avail_in&&s<=r)&&(i=s>r?r:s,n=t===K&&0===e.strm.avail_in&&i===s?1:0,Q(e,e.block_start,i,n),e.block_start+=i,_e(e.strm)),n?3:1)},Ce=(e,t)=>{let i,s;for(;;){if(e.lookahead=3&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-Ae&&(e.match_length=Be(e,i)),e.match_length>=3)if(s=H(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=me(e,e.ins_h,e.window[e.strstart+1]);else s=H(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(ve(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===K?(ve(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ve(e,!1),0===e.strm.avail_out)?1:2},Me=(e,t)=>{let i,s,r;for(;;){if(e.lookahead=3&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,s=H(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,s&&(ve(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(s=H(e,0,e.window[e.strstart-1]),s&&ve(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=H(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===K?(ve(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ve(e,!1),0===e.strm.avail_out)?1:2};function Fe(e,t,i,s,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=s,this.func=r}const Ee=[new Fe(0,0,0,0,Pe),new Fe(4,4,8,4,Ce),new Fe(4,5,16,8,Ce),new Fe(4,6,32,32,Ce),new Fe(4,4,16,16,Me),new Fe(8,16,32,32,Me),new Fe(8,16,128,128,Me),new Fe(8,32,128,256,Me),new Fe(32,128,258,1024,Me),new Fe(32,258,258,4096,Me)];function Ie(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ae,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),fe(this.dyn_ltree),fe(this.dyn_dtree),fe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),fe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),fe(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const De=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==he&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ce&&t.status!==ue?1:0},Se=e=>{if(De(e))return de(e,Z);e.total_in=e.total_out=0,e.data_type=ne;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?he:ce,e.adler=2===t.wrap?0:1,t.last_flush=-2,N(t),J},Te=e=>{const t=Se(e);var i;return t===J&&((i=e.state).window_size=2*i.w_size,fe(i.head),i.max_lazy_match=Ee[i.level].max_lazy,i.good_match=Ee[i.level].good_length,i.nice_match=Ee[i.level].nice_length,i.max_chain_length=Ee[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Re=(e,t,i,s,r,o)=>{if(!e)return Z;let n=1;if(t===ee&&(t=6),s<0?(n=0,s=-s):s>15&&(n=2,s-=16),r<1||r>9||i!==ae||s<8||s>15||t<0||t>9||o<0||o>re||8===s&&1!==n)return de(e,Z);8===s&&(s=9);const a=new Ie;return e.state=a,a.strm=e,a.status=he,a.wrap=n,a.gzhead=null,a.w_bits=s,a.w_size=1<De(e)||2!==e.state.wrap?Z:(e.state.gzhead=t,J),ke=(e,t)=>{if(De(e)||t>X||t<0)return e?de(e,Z):Z;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===ue&&t!==K)return de(e,0===e.avail_out?$:Z);const s=i.last_flush;if(i.last_flush=t,0!==i.pending){if(_e(e),0===e.avail_out)return i.last_flush=-1,J}else if(0===e.avail_in&&pe(t)<=pe(s)&&t!==K)return de(e,$);if(i.status===ue&&0!==e.avail_in)return de(e,$);if(i.status===he&&0===i.wrap&&(i.status=ce),i.status===he){let t=ae+(i.w_bits-8<<4)<<8,s=-1;if(s=i.strategy>=ie||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=s<<6,0!==i.strstart&&(t|=32),t+=31-t%31,ye(i,t),0!==i.strstart&&(ye(i,e.adler>>>16),ye(i,65535&e.adler)),e.adler=1,i.status=ce,_e(e),0!==i.pending)return i.last_flush=-1,J}if(57===i.status)if(e.adler=0,be(i,31),be(i,139),be(i,8),i.gzhead)be(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),be(i,255&i.gzhead.time),be(i,i.gzhead.time>>8&255),be(i,i.gzhead.time>>16&255),be(i,i.gzhead.time>>24&255),be(i,9===i.level?2:i.strategy>=ie||i.level<2?4:0),be(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(be(i,255&i.gzhead.extra.length),be(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=U(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(be(i,0),be(i,0),be(i,0),be(i,0),be(i,0),be(i,9===i.level?2:i.strategy>=ie||i.level<2?4:0),be(i,3),i.status=ce,_e(e),0!==i.pending)return i.last_flush=-1,J;if(69===i.status){if(i.gzhead.extra){let t=i.pending,s=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+s>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=U(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,_e(e),0!==i.pending)return i.last_flush=-1,J;t=0,s-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+s),i.pending),i.pending+=s,i.gzhead.hcrc&&i.pending>t&&(e.adler=U(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,s=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>s&&(e.adler=U(e.adler,i.pending_buf,i.pending-s,s)),_e(e),0!==i.pending)return i.last_flush=-1,J;s=0}t=i.gzindexs&&(e.adler=U(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,s=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>s&&(e.adler=U(e.adler,i.pending_buf,i.pending-s,s)),_e(e),0!==i.pending)return i.last_flush=-1,J;s=0}t=i.gzindexs&&(e.adler=U(e.adler,i.pending_buf,i.pending-s,s))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(_e(e),0!==i.pending))return i.last_flush=-1,J;be(i,255&e.adler),be(i,e.adler>>8&255),e.adler=0}if(i.status=ce,_e(e),0!==i.pending)return i.last_flush=-1,J}if(0!==e.avail_in||0!==i.lookahead||t!==G&&i.status!==ue){let s=0===i.level?Pe(i,t):i.strategy===ie?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(we(e),0===e.lookahead)){if(t===G)return 1;break}if(e.match_length=0,i=H(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(ve(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===K?(ve(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ve(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===se?((e,t)=>{let i,s,r,o;const n=e.window;for(;;){if(e.lookahead<=le){if(we(e),e.lookahead<=le&&t===G)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,s=n[r],s===n[++r]&&s===n[++r]&&s===n[++r])){o=e.strstart+le;do{}while(s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=H(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=H(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(ve(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===K?(ve(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ve(e,!1),0===e.strm.avail_out)?1:2})(i,t):Ee[i.level].func(i,t);if(3!==s&&4!==s||(i.status=ue),1===s||3===s)return 0===e.avail_out&&(i.last_flush=-1),J;if(2===s&&(t===z?j(i):t!==X&&(Q(i,0,0,!1),t===W&&(fe(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),_e(e),0===e.avail_out))return i.last_flush=-1,J}return t!==K?J:i.wrap<=0?Y:(2===i.wrap?(be(i,255&e.adler),be(i,e.adler>>8&255),be(i,e.adler>>16&255),be(i,e.adler>>24&255),be(i,255&e.total_in),be(i,e.total_in>>8&255),be(i,e.total_in>>16&255),be(i,e.total_in>>24&255)):(ye(i,e.adler>>>16),ye(i,65535&e.adler)),_e(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?J:Y)},Oe=e=>{if(De(e))return Z;const t=e.state.status;return e.state=null,t===ce?de(e,q):J},Ne=(e,t)=>{let i=t.length;if(De(e))return Z;const s=e.state,r=s.wrap;if(2===r||1===r&&s.status!==he||s.lookahead)return Z;if(1===r&&(e.adler=R(e.adler,t,i,0)),s.wrap=0,i>=s.w_size){0===r&&(fe(s.head),s.strstart=0,s.block_start=0,s.insert=0);let e=new Uint8Array(s.w_size);e.set(t.subarray(i-s.w_size,i),0),t=e,i=s.w_size}const o=e.avail_in,n=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,we(s);s.lookahead>=3;){let e=s.strstart,t=s.lookahead-2;do{s.ins_h=me(s,s.ins_h,s.window[e+3-1]),s.prev[e&s.w_mask]=s.head[s.ins_h],s.head[s.ins_h]=e,e++}while(--t);s.strstart=e,s.lookahead=2,we(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=2,s.match_available=0,e.next_in=n,e.input=a,e.avail_in=o,s.wrap=r,J};const Qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Ve=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Qe(i,t)&&(e[t]=i[t])}}return e},He=e=>{let t=0;for(let i=0,s=e.length;i=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Ge[254]=Ge[254]=1;var ze=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,s,r,o,n=e.length,a=0;for(r=0;r>>6,t[o++]=128|63&i):i<65536?(t[o++]=224|i>>>12,t[o++]=128|i>>>6&63,t[o++]=128|63&i):(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63,t[o++]=128|i>>>6&63,t[o++]=128|63&i);return t},We=(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let s,r;const o=new Array(2*i);for(r=0,s=0;s4)o[r++]=65533,s+=n-1;else{for(t&=2===n?31:3===n?15:7;n>1&&s1?o[r++]=65533:t<65536?o[r++]=t:(t-=65536,o[r++]=55296|t>>10&1023,o[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&je)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let s=0;s{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Ge[e[i]]>t?i:t},Xe=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Je=Object.prototype.toString,{Z_NO_FLUSH:Ye,Z_SYNC_FLUSH:Ze,Z_FULL_FLUSH:qe,Z_FINISH:$e,Z_OK:et,Z_STREAM_END:tt,Z_DEFAULT_COMPRESSION:it,Z_DEFAULT_STRATEGY:st,Z_DEFLATED:rt}=O;function ot(e){this.options=Ve({level:it,method:rt,chunkSize:16384,windowBits:15,memLevel:8,strategy:st},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Xe,this.strm.avail_out=0;let i=Le(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==et)throw new Error(k[i]);if(t.header&&Ue(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?ze(t.dictionary):"[object ArrayBuffer]"===Je.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Ne(this.strm,e),i!==et)throw new Error(k[i]);this._dict_set=!0}}function nt(e,t){const i=new ot(t);if(i.push(e,!0),i.err)throw i.msg||k[i.err];return i.result}ot.prototype.push=function(e,t){const i=this.strm,s=this.options.chunkSize;let r,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?$e:Ye,"string"==typeof e?i.input=ze(e):"[object ArrayBuffer]"===Je.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),(o===Ze||o===qe)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=ke(i,o),r===tt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Oe(this.strm),this.onEnd(r),this.ended=!0,r===et;if(0!==i.avail_out){if(o>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},ot.prototype.onData=function(e){this.chunks.push(e)},ot.prototype.onEnd=function(e){e===et&&(this.result=He(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var at={Deflate:ot,deflate:nt,deflateRaw:function(e,t){return(t=t||{}).raw=!0,nt(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,nt(e,t)},constants:O};const lt=16209;var At=function(e,t){let i,s,r,o,n,a,l,A,h,c,u,d,p,f,g,m,_,v,b,y,x,B,w,P;const C=e.state;i=e.next_in,w=e.input,s=i+(e.avail_in-5),r=e.next_out,P=e.output,o=r-(t-e.avail_out),n=r+(e.avail_out-257),a=C.dmax,l=C.wsize,A=C.whave,h=C.wnext,c=C.window,u=C.hold,d=C.bits,p=C.lencode,f=C.distcode,g=(1<>>24,u>>>=v,d-=v,v=_>>>16&255,0===v)P[r++]=65535&_;else{if(!(16&v)){if(0==(64&v)){_=p[(65535&_)+(u&(1<>>=v,d-=v),d<15&&(u+=w[i++]<>>24,u>>>=v,d-=v,v=_>>>16&255,!(16&v)){if(0==(64&v)){_=f[(65535&_)+(u&(1<a){e.msg="invalid distance too far back",C.mode=lt;break e}if(u>>>=v,d-=v,v=r-o,y>v){if(v=y-v,v>A&&C.sane){e.msg="invalid distance too far back",C.mode=lt;break e}if(x=0,B=c,0===h){if(x+=l-v,v2;)P[r++]=B[x++],P[r++]=B[x++],P[r++]=B[x++],b-=3;b&&(P[r++]=B[x++],b>1&&(P[r++]=B[x++]))}else{x=r-y;do{P[r++]=P[x++],P[r++]=P[x++],P[r++]=P[x++],b-=3}while(b>2);b&&(P[r++]=P[x++],b>1&&(P[r++]=P[x++]))}break}}break}}while(i>3,i-=b,d-=b<<3,u&=(1<{const l=a.bits;let A,h,c,u,d,p,f=0,g=0,m=0,_=0,v=0,b=0,y=0,x=0,B=0,w=0,P=null;const C=new Uint16Array(16),M=new Uint16Array(16);let F,E,I,D=null;for(f=0;f<=15;f++)C[f]=0;for(g=0;g=1&&0===C[_];_--);if(v>_&&(v=_),0===_)return r[o++]=20971520,r[o++]=20971520,a.bits=1,0;for(m=1;m<_&&0===C[m];m++);for(v0&&(0===e||1!==_))return-1;for(M[1]=0,f=1;f<15;f++)M[f+1]=M[f]+C[f];for(g=0;g852||2===e&&B>592)return 1;for(;;){F=f-y,n[g]+1=p?(E=D[n[g]-p],I=P[n[g]-p]):(E=96,I=0),A=1<>y)+h]=F<<24|E<<16|I|0}while(0!==h);for(A=1<>=1;if(0!==A?(w&=A-1,w+=A):w=0,g++,0==--C[f]){if(f===_)break;f=t[i+n[g]]}if(f>v&&(w&u)!==c){for(0===y&&(y=v),d+=m,b=f-y,x=1<852||2===e&&B>592)return 1;c=w&u,r[c]=v<<24|b<<16|d-o|0}}return 0!==w&&(r[d+w]=f-y<<24|64<<16|0),a.bits=v,0};const{Z_FINISH:ft,Z_BLOCK:gt,Z_TREES:mt,Z_OK:_t,Z_STREAM_END:vt,Z_NEED_DICT:bt,Z_STREAM_ERROR:yt,Z_DATA_ERROR:xt,Z_MEM_ERROR:Bt,Z_BUF_ERROR:wt,Z_DEFLATED:Pt}=O,Ct=16180,Mt=16190,Ft=16191,Et=16192,It=16194,Dt=16199,St=16200,Tt=16206,Rt=16209,Lt=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ut(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const kt=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ot=e=>{if(kt(e))return yt;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Ct,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,_t},Nt=e=>{if(kt(e))return yt;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ot(e)},Qt=(e,t)=>{let i;if(kt(e))return yt;const s=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?yt:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,Nt(e))},Vt=(e,t)=>{if(!e)return yt;const i=new Ut;e.state=i,i.strm=e,i.window=null,i.mode=Ct;const s=Qt(e,t);return s!==_t&&(e.state=null),s};let Ht,jt,Gt=!0;const zt=e=>{if(Gt){Ht=new Int32Array(512),jt=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(pt(1,e.lens,0,288,Ht,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;pt(2,e.lens,0,32,jt,0,e.work,{bits:5}),Gt=!1}e.lencode=Ht,e.lenbits=9,e.distcode=jt,e.distbits=5},Wt=(e,t,i,s)=>{let r;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(i-o.wsize,i),0),o.wnext=0,o.whave=o.wsize):(r=o.wsize-o.wnext,r>s&&(r=s),o.window.set(t.subarray(i-s,i-s+r),o.wnext),(s-=r)?(o.window.set(t.subarray(i-s,i),0),o.wnext=s,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave{let i,s,r,o,n,a,l,A,h,c,u,d,p,f,g,m,_,v,b,y,x,B,w=0;const P=new Uint8Array(4);let C,M;const F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(kt(e)||!e.output||!e.input&&0!==e.avail_in)return yt;i=e.state,i.mode===Ft&&(i.mode=Et),n=e.next_out,r=e.output,l=e.avail_out,o=e.next_in,s=e.input,a=e.avail_in,A=i.hold,h=i.bits,c=a,u=l,B=_t;e:for(;;)switch(i.mode){case Ct:if(0===i.wrap){i.mode=Et;break}for(;h<16;){if(0===a)break e;a--,A+=s[o++]<>>8&255,i.check=U(i.check,P,2,0),A=0,h=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&A)<<8)+(A>>8))%31){e.msg="incorrect header check",i.mode=Rt;break}if((15&A)!==Pt){e.msg="unknown compression method",i.mode=Rt;break}if(A>>>=4,h-=4,x=8+(15&A),0===i.wbits&&(i.wbits=x),x>15||x>i.wbits){e.msg="invalid window size",i.mode=Rt;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(P[0]=255&A,P[1]=A>>>8&255,i.check=U(i.check,P,2,0)),A=0,h=0,i.mode=16182;case 16182:for(;h<32;){if(0===a)break e;a--,A+=s[o++]<>>8&255,P[2]=A>>>16&255,P[3]=A>>>24&255,i.check=U(i.check,P,4,0)),A=0,h=0,i.mode=16183;case 16183:for(;h<16;){if(0===a)break e;a--,A+=s[o++]<>8),512&i.flags&&4&i.wrap&&(P[0]=255&A,P[1]=A>>>8&255,i.check=U(i.check,P,2,0)),A=0,h=0,i.mode=16184;case 16184:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,A+=s[o++]<>>8&255,i.check=U(i.check,P,2,0)),A=0,h=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(d=i.length,d>a&&(d=a),d&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(s.subarray(o,o+d),x)),512&i.flags&&4&i.wrap&&(i.check=U(i.check,s,d,o)),a-=d,o+=d,i.length-=d),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;d=0;do{x=s[o+d++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&d>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Ft;break;case 16189:for(;h<32;){if(0===a)break e;a--,A+=s[o++]<>>=7&h,h-=7&h,i.mode=Tt;break}for(;h<3;){if(0===a)break e;a--,A+=s[o++]<>>=1,h-=1,3&A){case 0:i.mode=16193;break;case 1:if(zt(i),i.mode=Dt,t===mt){A>>>=2,h-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=Rt}A>>>=2,h-=2;break;case 16193:for(A>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,A+=s[o++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=Rt;break}if(i.length=65535&A,A=0,h=0,i.mode=It,t===mt)break e;case It:i.mode=16195;case 16195:if(d=i.length,d){if(d>a&&(d=a),d>l&&(d=l),0===d)break e;r.set(s.subarray(o,o+d),n),a-=d,o+=d,l-=d,n+=d,i.length-=d;break}i.mode=Ft;break;case 16196:for(;h<14;){if(0===a)break e;a--,A+=s[o++]<>>=5,h-=5,i.ndist=1+(31&A),A>>>=5,h-=5,i.ncode=4+(15&A),A>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Rt;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[F[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,C={bits:i.lenbits},B=pt(0,i.lens,0,19,i.lencode,0,i.work,C),i.lenbits=C.bits,B){e.msg="invalid code lengths set",i.mode=Rt;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>24,m=w>>>16&255,_=65535&w,!(g<=h);){if(0===a)break e;a--,A+=s[o++]<>>=g,h-=g,i.lens[i.have++]=_;else{if(16===_){for(M=g+2;h>>=g,h-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=Rt;break}x=i.lens[i.have-1],d=3+(3&A),A>>>=2,h-=2}else if(17===_){for(M=g+3;h>>=g,h-=g,x=0,d=3+(7&A),A>>>=3,h-=3}else{for(M=g+7;h>>=g,h-=g,x=0,d=11+(127&A),A>>>=7,h-=7}if(i.have+d>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Rt;break}for(;d--;)i.lens[i.have++]=x}}if(i.mode===Rt)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Rt;break}if(i.lenbits=9,C={bits:i.lenbits},B=pt(1,i.lens,0,i.nlen,i.lencode,0,i.work,C),i.lenbits=C.bits,B){e.msg="invalid literal/lengths set",i.mode=Rt;break}if(i.distbits=6,i.distcode=i.distdyn,C={bits:i.distbits},B=pt(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,C),i.distbits=C.bits,B){e.msg="invalid distances set",i.mode=Rt;break}if(i.mode=Dt,t===mt)break e;case Dt:i.mode=St;case St:if(a>=6&&l>=258){e.next_out=n,e.avail_out=l,e.next_in=o,e.avail_in=a,i.hold=A,i.bits=h,At(e,u),n=e.next_out,r=e.output,l=e.avail_out,o=e.next_in,s=e.input,a=e.avail_in,A=i.hold,h=i.bits,i.mode===Ft&&(i.back=-1);break}for(i.back=0;w=i.lencode[A&(1<>>24,m=w>>>16&255,_=65535&w,!(g<=h);){if(0===a)break e;a--,A+=s[o++]<>v)],g=w>>>24,m=w>>>16&255,_=65535&w,!(v+g<=h);){if(0===a)break e;a--,A+=s[o++]<>>=v,h-=v,i.back+=v}if(A>>>=g,h-=g,i.back+=g,i.length=_,0===m){i.mode=16205;break}if(32&m){i.back=-1,i.mode=Ft;break}if(64&m){e.msg="invalid literal/length code",i.mode=Rt;break}i.extra=15&m,i.mode=16201;case 16201:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;w=i.distcode[A&(1<>>24,m=w>>>16&255,_=65535&w,!(g<=h);){if(0===a)break e;a--,A+=s[o++]<>v)],g=w>>>24,m=w>>>16&255,_=65535&w,!(v+g<=h);){if(0===a)break e;a--,A+=s[o++]<>>=v,h-=v,i.back+=v}if(A>>>=g,h-=g,i.back+=g,64&m){e.msg="invalid distance code",i.mode=Rt;break}i.offset=_,i.extra=15&m,i.mode=16203;case 16203:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Rt;break}i.mode=16204;case 16204:if(0===l)break e;if(d=u-l,i.offset>d){if(d=i.offset-d,d>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Rt;break}d>i.wnext?(d-=i.wnext,p=i.wsize-d):p=i.wnext-d,d>i.length&&(d=i.length),f=i.window}else f=r,p=n-i.offset,d=i.length;d>l&&(d=l),l-=d,i.length-=d;do{r[n++]=f[p++]}while(--d);0===i.length&&(i.mode=St);break;case 16205:if(0===l)break e;r[n++]=i.length,l--,i.mode=St;break;case Tt:if(i.wrap){for(;h<32;){if(0===a)break e;a--,A|=s[o++]<{if(kt(e))return yt;let t=e.state;return t.window&&(t.window=null),e.state=null,_t},Zt=(e,t)=>{if(kt(e))return yt;const i=e.state;return 0==(2&i.wrap)?yt:(i.head=t,t.done=!1,_t)},qt=(e,t)=>{const i=t.length;let s,r,o;return kt(e)?yt:(s=e.state,0!==s.wrap&&s.mode!==Mt?yt:s.mode===Mt&&(r=1,r=R(r,t,i,0),r!==s.check)?xt:(o=Wt(e,t,i,i),o?(s.mode=16210,Bt):(s.havedict=1,_t)))},$t=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ei=Object.prototype.toString,{Z_NO_FLUSH:ti,Z_FINISH:ii,Z_OK:si,Z_STREAM_END:ri,Z_NEED_DICT:oi,Z_STREAM_ERROR:ni,Z_DATA_ERROR:ai,Z_MEM_ERROR:li}=O;function Ai(e){this.options=Ve({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Xe,this.strm.avail_out=0;let i=Xt(this.strm,t.windowBits);if(i!==si)throw new Error(k[i]);if(this.header=new $t,Zt(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=ze(t.dictionary):"[object ArrayBuffer]"===ei.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=qt(this.strm,t.dictionary),i!==si)))throw new Error(k[i])}function hi(e,t){const i=new Ai(t);if(i.push(e),i.err)throw i.msg||k[i.err];return i.result}Ai.prototype.push=function(e,t){const i=this.strm,s=this.options.chunkSize,r=this.options.dictionary;let o,n,a;if(this.ended)return!1;for(n=t===~~t?t:!0===t?ii:ti,"[object ArrayBuffer]"===ei.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),o=Jt(i,n),o===oi&&r&&(o=qt(i,r),o===si?o=Jt(i,n):o===ai&&(o=oi));i.avail_in>0&&o===ri&&i.state.wrap>0&&0!==e[i.next_in];)Kt(i),o=Jt(i,n);switch(o){case ni:case ai:case oi:case li:return this.onEnd(o),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||o===ri))if("string"===this.options.to){let e=Ke(i.output,i.next_out),t=i.next_out-e,r=We(i.output,e);i.next_out=t,i.avail_out=s-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(o!==si||0!==a){if(o===ri)return o=Yt(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ai.prototype.onData=function(e){this.chunks.push(e)},Ai.prototype.onEnd=function(e){e===si&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=He(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ci={Inflate:Ai,inflate:hi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,hi(e,t)},ungzip:hi,constants:O};const{Deflate:ui,deflate:di,deflateRaw:pi,gzip:fi}=at,{Inflate:gi,inflate:mi,inflateRaw:_i,ungzip:vi}=ci;var bi=ui,yi=di,xi=pi,Bi=fi,wi=gi,Pi=mi,Ci=_i,Mi=vi,Fi=O,Ei={Deflate:bi,deflate:yi,deflateRaw:xi,gzip:Bi,Inflate:wi,inflate:Pi,inflateRaw:Ci,ungzip:Mi,constants:Fi};e.Deflate=bi,e.Inflate=wi,e.constants=Fi,e.default=Ei,e.deflate=yi,e.deflateRaw=xi,e.gzip=Bi,e.inflate=Pi,e.inflateRaw=Ci,e.ungzip=Mi,Object.defineProperty(e,"__esModule",{value:!0})}));var mw=Object.freeze({__proto__:null});let _w=window.pako||mw;_w.inflate||(_w=_w.default);const vw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const bw={version:1,parse:function(e,t,i,s,r,o){const n=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],meshPositions:e[4],meshIndices:e[5],meshEdgesIndices:e[6],meshColors:e[7],entityIDs:e[8],entityMeshes:e[9],entityIsObjects:e[10],positionsDecodeMatrix:e[11]}}(i),a=function(e){return{positions:new Uint16Array(_w.inflate(e.positions).buffer),normals:new Int8Array(_w.inflate(e.normals).buffer),indices:new Uint32Array(_w.inflate(e.indices).buffer),edgeIndices:new Uint32Array(_w.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(_w.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(_w.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(_w.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(_w.inflate(e.meshColors).buffer),entityIDs:_w.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(_w.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(_w.inflate(e.entityIsObjects).buffer),positionsDecodeMatrix:new Float32Array(_w.inflate(e.positionsDecodeMatrix).buffer)}}(n);!function(e,t,i,s,r,o){o.getNextId(),s.positionsCompression="precompressed",s.normalsCompression="precompressed";const n=i.positions,a=i.normals,l=i.indices,A=i.edgeIndices,h=i.meshPositions,u=i.meshIndices,d=i.meshEdgesIndices,p=i.meshColors,f=JSON.parse(i.entityIDs),g=i.entityMeshes,m=i.entityIsObjects,v=h.length,b=g.length;for(let r=0;rg[e]g[t]?1:0));for(let e=0;e1||(F[i]=e)}}for(let e=0;e1,o=Fw(m.subarray(4*t,4*t+3)),u=m[4*t+3]/255,v=a.subarray(d[t],i?a.length:d[t+1]),y=l.subarray(d[t],i?l.length:d[t+1]),x=A.subarray(p[t],i?A.length:p[t+1]),w=h.subarray(f[t],i?h.length:f[t+1]),M=c.subarray(g[t],g[t]+16);if(r){const e=`${n}-geometry.${t}`;s.createGeometry({id:e,primitive:"triangles",positionsCompressed:v,normalsCompressed:y,indices:x,edgeIndices:w,positionsDecodeMatrix:M})}else{const e=`${n}-${t}`;b[F[t]];const i={};s.createMesh(_.apply(i,{id:e,primitive:"triangles",positionsCompressed:v,normalsCompressed:y,indices:x,edgeIndices:w,positionsDecodeMatrix:M,color:o,opacity:u}))}}let E=0;for(let e=0;e1){const t={},r=`${n}-instance.${E++}`,o=`${n}-geometry.${i}`,a=16*x[e],A=u.subarray(a,a+16);s.createMesh(_.apply(t,{id:r,geometryId:o,matrix:A})),l.push(r)}else l.push(i)}if(l.length>0){const e={};s.createEntity(_.apply(e,{id:r,isObject:!0,meshIds:l}))}}}(0,0,a,s,0,o)}};let Iw=window.pako||mw;Iw.inflate||(Iw=Iw.default);const Dw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const Sw={version:5,parse:function(e,t,i,s,r,o){const n=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],eachPrimitivePositionsAndNormalsPortion:e[5],eachPrimitiveIndicesPortion:e[6],eachPrimitiveEdgeIndicesPortion:e[7],eachPrimitiveColor:e[8],primitiveInstances:e[9],eachEntityId:e[10],eachEntityPrimitiveInstancesPortion:e[11],eachEntityMatricesPortion:e[12]}}(i),a=function(e){return{positions:new Float32Array(Iw.inflate(e.positions).buffer),normals:new Int8Array(Iw.inflate(e.normals).buffer),indices:new Uint32Array(Iw.inflate(e.indices).buffer),edgeIndices:new Uint32Array(Iw.inflate(e.edgeIndices).buffer),matrices:new Float32Array(Iw.inflate(e.matrices).buffer),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(Iw.inflate(e.eachPrimitivePositionsAndNormalsPortion).buffer),eachPrimitiveIndicesPortion:new Uint32Array(Iw.inflate(e.eachPrimitiveIndicesPortion).buffer),eachPrimitiveEdgeIndicesPortion:new Uint32Array(Iw.inflate(e.eachPrimitiveEdgeIndicesPortion).buffer),eachPrimitiveColor:new Uint8Array(Iw.inflate(e.eachPrimitiveColor).buffer),primitiveInstances:new Uint32Array(Iw.inflate(e.primitiveInstances).buffer),eachEntityId:Iw.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(Iw.inflate(e.eachEntityPrimitiveInstancesPortion).buffer),eachEntityMatricesPortion:new Uint32Array(Iw.inflate(e.eachEntityMatricesPortion).buffer)}}(n);!function(e,t,i,s,r,o){const n=o.getNextId();s.positionsCompression="disabled",s.normalsCompression="precompressed";const a=i.positions,l=i.normals,A=i.indices,h=i.edgeIndices,c=i.matrices,u=i.eachPrimitivePositionsAndNormalsPortion,d=i.eachPrimitiveIndicesPortion,p=i.eachPrimitiveEdgeIndicesPortion,f=i.eachPrimitiveColor,g=i.primitiveInstances,m=JSON.parse(i.eachEntityId),v=i.eachEntityPrimitiveInstancesPortion,b=i.eachEntityMatricesPortion,y=u.length,x=g.length,B=new Uint8Array(y),w=m.length;for(let e=0;e1||(P[i]=e)}}for(let e=0;e1,r=Dw(f.subarray(4*e,4*e+3)),o=f[4*e+3]/255,c=a.subarray(u[e],t?a.length:u[e+1]),g=l.subarray(u[e],t?l.length:u[e+1]),v=A.subarray(d[e],t?A.length:d[e+1]),b=h.subarray(p[e],t?h.length:p[e+1]);if(i){const t=`${n}-geometry.${e}`;s.createGeometry({id:t,primitive:"triangles",positionsCompressed:c,normalsCompressed:g,indices:v,edgeIndices:b})}else{const t=e;m[P[e]];const i={};s.createMesh(_.apply(i,{id:t,primitive:"triangles",positionsCompressed:c,normalsCompressed:g,indices:v,edgeIndices:b,color:r,opacity:o}))}}let C=0;for(let e=0;e1){const t={},r="instance."+C++,o="geometry"+i,n=16*b[e],l=c.subarray(n,n+16);s.createMesh(_.apply(t,{id:r,geometryId:o,matrix:l})),a.push(r)}else a.push(i)}if(a.length>0){const e={};s.createEntity(_.apply(e,{id:r,isObject:!0,meshIds:a}))}}}(0,0,a,s,0,o)}};let Tw=window.pako||mw;Tw.inflate||(Tw=Tw.default);const Rw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const Lw={version:6,parse:function(e,t,i,s,r,o){const n=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],reusedPrimitivesDecodeMatrix:e[5],eachPrimitivePositionsAndNormalsPortion:e[6],eachPrimitiveIndicesPortion:e[7],eachPrimitiveEdgeIndicesPortion:e[8],eachPrimitiveColorAndOpacity:e[9],primitiveInstances:e[10],eachEntityId:e[11],eachEntityPrimitiveInstancesPortion:e[12],eachEntityMatricesPortion:e[13],eachTileAABB:e[14],eachTileEntitiesPortion:e[15]}}(i),a=function(e){function t(e,t){return 0===e.length?[]:Tw.inflate(e,t).buffer}return{positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedPrimitivesDecodeMatrix:new Float32Array(t(e.reusedPrimitivesDecodeMatrix)),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(t(e.eachPrimitivePositionsAndNormalsPortion)),eachPrimitiveIndicesPortion:new Uint32Array(t(e.eachPrimitiveIndicesPortion)),eachPrimitiveEdgeIndicesPortion:new Uint32Array(t(e.eachPrimitiveEdgeIndicesPortion)),eachPrimitiveColorAndOpacity:new Uint8Array(t(e.eachPrimitiveColorAndOpacity)),primitiveInstances:new Uint32Array(t(e.primitiveInstances)),eachEntityId:Tw.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(t(e.eachEntityPrimitiveInstancesPortion)),eachEntityMatricesPortion:new Uint32Array(t(e.eachEntityMatricesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(n);!function(e,t,i,s,r,o){const n=o.getNextId(),a=i.positions,l=i.normals,A=i.indices,h=i.edgeIndices,u=i.matrices,d=i.reusedPrimitivesDecodeMatrix,p=i.eachPrimitivePositionsAndNormalsPortion,f=i.eachPrimitiveIndicesPortion,g=i.eachPrimitiveEdgeIndicesPortion,m=i.eachPrimitiveColorAndOpacity,v=i.primitiveInstances,b=JSON.parse(i.eachEntityId),y=i.eachEntityPrimitiveInstancesPortion,x=i.eachEntityMatricesPortion,B=i.eachTileAABB,w=i.eachTileEntitiesPortion,P=p.length,C=v.length,M=b.length,F=w.length,E=new Uint32Array(P);for(let e=0;e1,c=t===P-1,u=a.subarray(p[t],c?a.length:p[t+1]),b=l.subarray(p[t],c?l.length:p[t+1]),y=A.subarray(f[t],c?A.length:f[t+1]),x=h.subarray(g[t],c?h.length:g[t+1]),B=Rw(m.subarray(4*t,4*t+3)),w=m[4*t+3]/255,C=o.getNextId();if(r){const e=`${n}-geometry.${i}.${t}`;U[e]||(s.createGeometry({id:e,primitive:"triangles",positionsCompressed:u,indices:y,edgeIndices:x,positionsDecodeMatrix:d}),U[e]=!0),s.createMesh(_.apply(N,{id:C,geometryId:e,origin:I,matrix:F,color:B,opacity:w})),R.push(C)}else s.createMesh(_.apply(N,{id:C,origin:I,primitive:"triangles",positionsCompressed:u,normalsCompressed:b,indices:y,edgeIndices:x,positionsDecodeMatrix:L,color:B,opacity:w})),R.push(C)}R.length>0&&s.createEntity(_.apply(O,{id:w,isObject:!0,meshIds:R}))}}}(e,t,a,s,0,o)}};let Uw=window.pako||mw;Uw.inflate||(Uw=Uw.default);const kw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function Ow(e){const t=[];for(let i=0,s=e.length;i1,c=t===E-1,P=kw(w.subarray(6*e,6*e+3)),C=w[6*e+3]/255,M=w[6*e+4]/255,F=w[6*e+5]/255,I=o.getNextId();if(r){const r=B[e],o=d.slice(r,r+16),x=`${n}-geometry.${i}.${t}`;if(!Q[x]){let e,i,r,o,n,d;switch(f[t]){case 0:e="solid",i=a.subarray(g[t],c?a.length:g[t+1]),r=l.subarray(m[t],c?l.length:m[t+1]),n=h.subarray(b[t],c?h.length:b[t+1]),d=u.subarray(y[t],c?u.length:y[t+1]);break;case 1:e="surface",i=a.subarray(g[t],c?a.length:g[t+1]),r=l.subarray(m[t],c?l.length:m[t+1]),n=h.subarray(b[t],c?h.length:b[t+1]),d=u.subarray(y[t],c?u.length:y[t+1]);break;case 2:e="points",i=a.subarray(g[t],c?a.length:g[t+1]),o=Ow(A.subarray(v[t],c?A.length:v[t+1]));break;case 3:e="lines",i=a.subarray(g[t],c?a.length:g[t+1]),n=h.subarray(b[t],c?h.length:b[t+1]);break;default:continue}s.createGeometry({id:x,primitive:e,positionsCompressed:i,normalsCompressed:r,colors:o,indices:n,edgeIndices:d,positionsDecodeMatrix:p}),Q[x]=!0}s.createMesh(_.apply(V,{id:I,geometryId:x,origin:R,matrix:o,color:P,metallic:M,roughness:F,opacity:C})),U.push(I)}else{let e,i,r,o,n,d;switch(f[t]){case 0:e="solid",i=a.subarray(g[t],c?a.length:g[t+1]),r=l.subarray(m[t],c?l.length:m[t+1]),n=h.subarray(b[t],c?h.length:b[t+1]),d=u.subarray(y[t],c?u.length:y[t+1]);break;case 1:e="surface",i=a.subarray(g[t],c?a.length:g[t+1]),r=l.subarray(m[t],c?l.length:m[t+1]),n=h.subarray(b[t],c?h.length:b[t+1]),d=u.subarray(y[t],c?u.length:y[t+1]);break;case 2:e="points",i=a.subarray(g[t],c?a.length:g[t+1]),o=Ow(A.subarray(v[t],c?A.length:v[t+1]));break;case 3:e="lines",i=a.subarray(g[t],c?a.length:g[t+1]),n=h.subarray(b[t],c?h.length:b[t+1]);break;default:continue}s.createMesh(_.apply(V,{id:I,origin:R,primitive:e,positionsCompressed:i,normalsCompressed:r,colors:o,indices:n,edgeIndices:d,positionsDecodeMatrix:N,color:P,metallic:M,roughness:F,opacity:C})),U.push(I)}}U.length>0&&s.createEntity(_.apply(O,{id:F,isObject:!0,meshIds:U}))}}}(e,t,a,s,0,o)}};let Qw=window.pako||mw;Qw.inflate||(Qw=Qw.default);const Vw=c.vec4(),Hw=c.vec4();const jw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function Gw(e){const t=[];for(let i=0,s=e.length;i1,l=r===L-1,A=jw(E.subarray(6*e,6*e+3)),h=E[6*e+3]/255,u=E[6*e+4]/255,I=E[6*e+5]/255,D=o.getNextId();if(a){const o=F[e],a=v.slice(o,o+16),M=`${n}-geometry.${i}.${r}`;let E=H[M];if(!E){E={batchThisMesh:!t.reuseGeometries};let e=!1;switch(y[r]){case 0:E.primitiveName="solid",E.geometryPositions=d.subarray(x[r],l?d.length:x[r+1]),E.geometryNormals=p.subarray(B[r],l?p.length:B[r+1]),E.geometryIndices=g.subarray(P[r],l?g.length:P[r+1]),E.geometryEdgeIndices=m.subarray(C[r],l?m.length:C[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 1:E.primitiveName="surface",E.geometryPositions=d.subarray(x[r],l?d.length:x[r+1]),E.geometryNormals=p.subarray(B[r],l?p.length:B[r+1]),E.geometryIndices=g.subarray(P[r],l?g.length:P[r+1]),E.geometryEdgeIndices=m.subarray(C[r],l?m.length:C[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 2:E.primitiveName="points",E.geometryPositions=d.subarray(x[r],l?d.length:x[r+1]),E.geometryColors=Gw(f.subarray(w[r],l?f.length:w[r+1])),e=E.geometryPositions.length>0;break;case 3:E.primitiveName="lines",E.geometryPositions=d.subarray(x[r],l?d.length:x[r+1]),E.geometryIndices=g.subarray(P[r],l?g.length:P[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;default:continue}if(e||(E=null),E&&(E.geometryPositions.length,E.batchThisMesh)){E.decompressedPositions=new Float32Array(E.geometryPositions.length);const e=E.geometryPositions,t=E.decompressedPositions;for(let i=0,s=e.length;i0&&n.length>0;break;case 1:e="surface",t=d.subarray(x[r],l?d.length:x[r+1]),i=p.subarray(B[r],l?p.length:B[r+1]),n=g.subarray(P[r],l?g.length:P[r+1]),a=m.subarray(C[r],l?m.length:C[r+1]),c=t.length>0&&n.length>0;break;case 2:e="points",t=d.subarray(x[r],l?d.length:x[r+1]),o=Gw(f.subarray(w[r],l?f.length:w[r+1])),c=t.length>0;break;case 3:e="lines",t=d.subarray(x[r],l?d.length:x[r+1]),n=g.subarray(P[r],l?g.length:P[r+1]),c=t.length>0&&n.length>0;break;default:continue}c&&(s.createMesh(_.apply(G,{id:D,origin:Q,primitive:e,positionsCompressed:t,normalsCompressed:i,colorsCompressed:o,indices:n,edgeIndices:a,positionsDecodeMatrix:R,color:A,metallic:u,roughness:I,opacity:h})),T.push(D))}}T.length>0&&s.createEntity(_.apply(j,{id:A,isObject:!0,meshIds:T}))}}}(e,t,a,s,r,o)}};let Ww=window.pako||mw;Ww.inflate||(Ww=Ww.default);const Kw=c.vec4(),Xw=c.vec4();const Jw=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const Yw={version:9,parse:function(e,t,i,s,r,o){const n=function(e){return{metadata:e[0],positions:e[1],normals:e[2],colors:e[3],indices:e[4],edgeIndices:e[5],matrices:e[6],reusedGeometriesDecodeMatrix:e[7],eachGeometryPrimitiveType:e[8],eachGeometryPositionsPortion:e[9],eachGeometryNormalsPortion:e[10],eachGeometryColorsPortion:e[11],eachGeometryIndicesPortion:e[12],eachGeometryEdgeIndicesPortion:e[13],eachMeshGeometriesPortion:e[14],eachMeshMatricesPortion:e[15],eachMeshMaterial:e[16],eachEntityId:e[17],eachEntityMeshesPortion:e[18],eachTileAABB:e[19],eachTileEntitiesPortion:e[20]}}(i),a=function(e){function t(e,t){return 0===e.length?[]:Ww.inflate(e,t).buffer}return{metadata:JSON.parse(Ww.inflate(e.metadata,{to:"string"})),positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshMaterial:new Uint8Array(t(e.eachMeshMaterial)),eachEntityId:JSON.parse(Ww.inflate(e.eachEntityId,{to:"string"})),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(n);!function(e,t,i,s,r,o){const n=o.getNextId(),a=i.metadata,l=i.positions,A=i.normals,h=i.colors,u=i.indices,d=i.edgeIndices,p=i.matrices,f=i.reusedGeometriesDecodeMatrix,g=i.eachGeometryPrimitiveType,m=i.eachGeometryPositionsPortion,v=i.eachGeometryNormalsPortion,b=i.eachGeometryColorsPortion,y=i.eachGeometryIndicesPortion,x=i.eachGeometryEdgeIndicesPortion,B=i.eachMeshGeometriesPortion,w=i.eachMeshMatricesPortion,P=i.eachMeshMaterial,C=i.eachEntityId,M=i.eachEntityMeshesPortion,F=i.eachTileAABB,E=i.eachTileEntitiesPortion,I=m.length,D=B.length,S=M.length,T=E.length;r&&r.loadData(a,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds});const R=new Uint32Array(I);for(let e=0;e1,C=r===I-1,M=Jw(P.subarray(6*e,6*e+3)),F=P[6*e+3]/255,E=P[6*e+4]/255,D=P[6*e+5]/255,S=o.getNextId();if(a){const o=w[e],a=p.slice(o,o+16),B=`${n}-geometry.${i}.${r}`;let P=k[B];if(!P){P={batchThisMesh:!t.reuseGeometries};let e=!1;switch(g[r]){case 0:P.primitiveName="solid",P.geometryPositions=l.subarray(m[r],C?l.length:m[r+1]),P.geometryNormals=A.subarray(v[r],C?A.length:v[r+1]),P.geometryIndices=u.subarray(y[r],C?u.length:y[r+1]),P.geometryEdgeIndices=d.subarray(x[r],C?d.length:x[r+1]),e=P.geometryPositions.length>0&&P.geometryIndices.length>0;break;case 1:P.primitiveName="surface",P.geometryPositions=l.subarray(m[r],C?l.length:m[r+1]),P.geometryNormals=A.subarray(v[r],C?A.length:v[r+1]),P.geometryIndices=u.subarray(y[r],C?u.length:y[r+1]),P.geometryEdgeIndices=d.subarray(x[r],C?d.length:x[r+1]),e=P.geometryPositions.length>0&&P.geometryIndices.length>0;break;case 2:P.primitiveName="points",P.geometryPositions=l.subarray(m[r],C?l.length:m[r+1]),P.geometryColors=h.subarray(b[r],C?h.length:b[r+1]),e=P.geometryPositions.length>0;break;case 3:P.primitiveName="lines",P.geometryPositions=l.subarray(m[r],C?l.length:m[r+1]),P.geometryIndices=u.subarray(y[r],C?u.length:y[r+1]),e=P.geometryPositions.length>0&&P.geometryIndices.length>0;break;default:continue}if(e||(P=null),P&&(P.geometryPositions.length,P.batchThisMesh)){P.decompressedPositions=new Float32Array(P.geometryPositions.length),P.transformedAndRecompressedPositions=new Uint16Array(P.geometryPositions.length);const e=P.geometryPositions,t=P.decompressedPositions;for(let i=0,s=e.length;i0&&n.length>0;break;case 1:e="surface",t=l.subarray(m[r],C?l.length:m[r+1]),i=A.subarray(v[r],C?A.length:v[r+1]),n=u.subarray(y[r],C?u.length:y[r+1]),a=d.subarray(x[r],C?d.length:x[r+1]),c=t.length>0&&n.length>0;break;case 2:e="points",t=l.subarray(m[r],C?l.length:m[r+1]),o=h.subarray(b[r],C?h.length:b[r+1]),c=t.length>0;break;case 3:e="lines",t=l.subarray(m[r],C?l.length:m[r+1]),n=u.subarray(y[r],C?u.length:y[r+1]),c=t.length>0&&n.length>0;break;default:continue}c&&(s.createMesh(_.apply(j,{id:S,origin:L,primitive:e,positionsCompressed:t,normalsCompressed:i,colorsCompressed:o,indices:n,edgeIndices:a,positionsDecodeMatrix:Q,color:M,metallic:E,roughness:D,opacity:F})),O.push(S))}}O.length>0&&s.createEntity(_.apply(H,{id:F,isObject:!0,meshIds:O}))}}}(e,t,a,s,r,o)}};let Zw=window.pako||mw;Zw.inflate||(Zw=Zw.default);const qw=c.vec4(),$w=c.vec4();const eP=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function tP(e,t){const i=[];if(t.length>1)for(let e=0,s=t.length-1;e1)for(let t=0,s=e.length/3-1;t0,a=9*e,c=1===h[a+0],u=h[a+1];h[a+2],h[a+3];const d=h[a+4],p=h[a+5],f=h[a+6],g=h[a+7],m=h[a+8];if(o){const t=new Uint8Array(l.subarray(i,r)).buffer,o=`${n}-texture-${e}`;if(c)s.createTexture({id:o,buffers:[t],minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m});else{const e=new Blob([t],{type:10001===u?"image/jpeg":10002===u?"image/png":"image/gif"}),i=(window.URL||window.webkitURL).createObjectURL(e),r=document.createElement("img");r.src=i,s.createTexture({id:o,image:r,minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m})}}}for(let e=0;e=0?`${n}-texture-${r}`:null,normalsTextureId:a>=0?`${n}-texture-${a}`:null,metallicRoughnessTextureId:o>=0?`${n}-texture-${o}`:null,emissiveTextureId:l>=0?`${n}-texture-${l}`:null,occlusionTextureId:A>=0?`${n}-texture-${A}`:null})}const j=new Uint32Array(N);for(let e=0;e1,l=r===N-1,A=D[e],h=A>=0?`${n}-textureSet-${A}`:null,T=eP(S.subarray(6*e,6*e+3)),R=S[6*e+3]/255,L=S[6*e+4]/255,O=S[6*e+5]/255,Q=o.getNextId();if(a){const o=I[e],a=b.slice(o,o+16),A=`${n}-geometry.${i}.${r}`;let E=W[A];if(!E){E={batchThisMesh:!t.reuseGeometries};let e=!1;switch(x[r]){case 0:E.primitiveName="solid",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryNormals=d.subarray(w[r],l?d.length:w[r+1]),E.geometryUVs=f.subarray(C[r],l?f.length:C[r+1]),E.geometryIndices=g.subarray(M[r],l?g.length:M[r+1]),E.geometryEdgeIndices=m.subarray(F[r],l?m.length:F[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 1:E.primitiveName="surface",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryNormals=d.subarray(w[r],l?d.length:w[r+1]),E.geometryUVs=f.subarray(C[r],l?f.length:C[r+1]),E.geometryIndices=g.subarray(M[r],l?g.length:M[r+1]),E.geometryEdgeIndices=m.subarray(F[r],l?m.length:F[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 2:E.primitiveName="points",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryColors=p.subarray(P[r],l?p.length:P[r+1]),e=E.geometryPositions.length>0;break;case 3:E.primitiveName="lines",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryIndices=g.subarray(M[r],l?g.length:M[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 4:E.primitiveName="lines",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryIndices=tP(E.geometryPositions,g.subarray(M[r],l?g.length:M[r+1])),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;default:continue}if(e||(E=null),E&&(E.geometryPositions.length,E.batchThisMesh)){E.decompressedPositions=new Float32Array(E.geometryPositions.length),E.transformedAndRecompressedPositions=new Uint16Array(E.geometryPositions.length);const e=E.geometryPositions,t=E.decompressedPositions;for(let i=0,s=e.length;i0&&a.length>0;break;case 1:e="surface",t=u.subarray(B[r],l?u.length:B[r+1]),i=d.subarray(w[r],l?d.length:w[r+1]),o=f.subarray(C[r],l?f.length:C[r+1]),a=g.subarray(M[r],l?g.length:M[r+1]),A=m.subarray(F[r],l?m.length:F[r+1]),c=t.length>0&&a.length>0;break;case 2:e="points",t=u.subarray(B[r],l?u.length:B[r+1]),n=p.subarray(P[r],l?p.length:P[r+1]),c=t.length>0;break;case 3:e="lines",t=u.subarray(B[r],l?u.length:B[r+1]),a=g.subarray(M[r],l?g.length:M[r+1]),c=t.length>0&&a.length>0;break;case 4:e="lines",t=u.subarray(B[r],l?u.length:B[r+1]),a=tP(t,g.subarray(M[r],l?g.length:M[r+1])),c=t.length>0&&a.length>0;break;default:continue}c&&(s.createMesh(_.apply(H,{id:Q,textureSetId:h,origin:G,primitive:e,positionsCompressed:t,normalsCompressed:i,uv:o&&o.length>0?o:null,colorsCompressed:n,indices:a,edgeIndices:A,positionsDecodeMatrix:v,color:T,metallic:L,roughness:O,opacity:R})),U.push(Q))}}U.length>0&&s.createEntity(_.apply(Q,{id:l,isObject:!0,meshIds:U}))}}}(e,t,a,s,r,o)}},sP={};sP[bw.version]=bw,sP[Bw.version]=Bw,sP[Cw.version]=Cw,sP[Ew.version]=Ew,sP[Sw.version]=Sw,sP[Lw.version]=Lw,sP[Nw.version]=Nw,sP[zw.version]=zw,sP[Yw.version]=Yw,sP[iP.version]=iP;var rP={};!function(e){var t,i="File format is not recognized.",s="Error while reading zip file.",r="Error while reading file data.",o=524288,n="text/plain";try{t=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function a(){this.crc=-1}function l(){}function A(e,t){var i,s;return i=new ArrayBuffer(e),s=new Uint8Array(i),t&&s.set(t,0),{buffer:i,array:s,view:new DataView(i)}}function h(){}function c(e){var t,i=this;i.size=0,i.init=function(s,r){var o=new Blob([e],{type:n});(t=new d(o)).init((function(){i.size=t.size,s()}),r)},i.readUint8Array=function(e,i,s,r){t.readUint8Array(e,i,s,r)}}function u(t){var i,s=this;s.size=0,s.init=function(e){for(var r=t.length;"="==t.charAt(r-1);)r--;i=t.indexOf(",")+1,s.size=Math.floor(.75*(r-i)),e()},s.readUint8Array=function(s,r,o){var n,a=A(r),l=4*Math.floor(s/3),h=4*Math.ceil((s+r)/3),c=e.atob(t.substring(l+i,h+i)),u=s-3*Math.floor(l/4);for(n=u;ne.size)throw new RangeError("offset:"+t+", length:"+i+", size:"+e.size);return e.slice?e.slice(t,t+i):e.webkitSlice?e.webkitSlice(t,t+i):e.mozSlice?e.mozSlice(t,t+i):e.msSlice?e.msSlice(t,t+i):void 0}(e,t,i))}catch(e){r(e)}}}function p(){}function f(e){var i,s=this;s.init=function(e){i=new Blob([],{type:n}),e()},s.writeUint8Array=function(e,s){i=new Blob([i,t?e:e.buffer],{type:n}),s()},s.getData=function(t,s){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=s,r.readAsText(i,e)}}function g(t){var i=this,s="",r="";i.init=function(e){s+="data:"+(t||"")+";base64,",e()},i.writeUint8Array=function(t,i){var o,n=r.length,a=r;for(r="",o=0;o<3*Math.floor((n+t.length)/3)-n;o++)a+=String.fromCharCode(t[o]);for(;o2?s+=e.btoa(a):r=a,i()},i.getData=function(t){t(s+e.btoa(r))}}function m(e){var i,s=this;s.init=function(t){i=new Blob([],{type:e}),t()},s.writeUint8Array=function(s,r){i=new Blob([i,t?s:s.buffer],{type:e}),r()},s.getData=function(e){e(i)}}function _(e,t,i,s,r,n,a,l,A,h){var c,u,d,p=0,f=t.sn;function g(){e.removeEventListener("message",m,!1),l(u,d)}function m(t){var i=t.data,r=i.data,o=i.error;if(o)return o.toString=function(){return"Error: "+this.message},void A(o);if(i.sn===f)switch("number"==typeof i.codecTime&&(e.codecTime+=i.codecTime),"number"==typeof i.crcTime&&(e.crcTime+=i.crcTime),i.type){case"append":r?(u+=r.length,s.writeUint8Array(r,(function(){_()}),h)):_();break;case"flush":d=i.crc,r?(u+=r.length,s.writeUint8Array(r,(function(){g()}),h)):g();break;case"progress":a&&a(c+i.loaded,n);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",i)}}function _(){(c=p*o)<=n?i.readUint8Array(r+c,Math.min(o,n-c),(function(i){a&&a(c,n);var s=0===c?t:{sn:f};s.type="append",s.data=i;try{e.postMessage(s,[i.buffer])}catch(t){e.postMessage(s)}p++}),A):e.postMessage({sn:f,type:"flush"})}u=0,e.addEventListener("message",m,!1),_()}function v(e,t,i,s,r,n,l,A,h,c){var u,d=0,p=0,f="input"===n,g="output"===n,m=new a;!function n(){var a;if((u=d*o)127?r[i-128]:String.fromCharCode(i);return s}function x(e){return decodeURIComponent(escape(e))}function B(e){var t,i="";for(t=0;t>16,i=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&i)>>11,(2016&i)>>5,2*(31&i),0)}catch(e){}}(e.lastModDateRaw),1!=(1&e.bitFlag)?((s||8!=(8&e.bitFlag))&&(e.crc32=t.view.getUint32(i+10,!0),e.compressedSize=t.view.getUint32(i+14,!0),e.uncompressedSize=t.view.getUint32(i+18,!0)),4294967295!==e.compressedSize&&4294967295!==e.uncompressedSize?(e.filenameLength=t.view.getUint16(i+22,!0),e.extraFieldLength=t.view.getUint16(i+24,!0)):r("File is using Zip64 (4gb+ file size).")):r("File contains encrypted entry.")}function P(t,o,n){var a=0;function l(){}l.prototype.getData=function(s,o,l,h){var c=this;function u(e,t){h&&!function(e){var t=A(4);return t.view.setUint32(0,e),c.crc32==t.view.getUint32(0)}(t)?n("CRC failed."):s.getData((function(e){o(e)}))}function d(e){n(e||r)}function p(e){n(e||"Error while writing file data.")}t.readUint8Array(c.offset,30,(function(r){var o,f=A(r.length,r);1347093252==f.view.getUint32(0)?(w(c,f,4,!1,n),o=c.offset+30+c.filenameLength+c.extraFieldLength,s.init((function(){0===c.compressionMethod?b(c._worker,a++,t,s,o,c.compressedSize,h,u,l,d,p):function(t,i,s,r,o,n,a,l,A,h,c){var u=a?"output":"none";e.zip.useWebWorkers?_(t,{sn:i,codecClass:"Inflater",crcType:u},s,r,o,n,A,l,h,c):v(new e.zip.Inflater,s,r,o,n,u,A,l,h,c)}(c._worker,a++,t,s,o,c.compressedSize,h,u,l,d,p)}),p)):n(i)}),d)};var h={getEntries:function(e){var r=this._worker;!function(e){t.size<22?n(i):r(22,(function(){r(Math.min(65558,t.size),(function(){n(i)}))}));function r(i,r){t.readUint8Array(t.size-i,i,(function(t){for(var i=t.length-22;i>=0;i--)if(80===t[i]&&75===t[i+1]&&5===t[i+2]&&6===t[i+3])return void e(new DataView(t.buffer,i,22));r()}),(function(){n(s)}))}}((function(o){var a,h;a=o.getUint32(16,!0),h=o.getUint16(8,!0),a<0||a>=t.size?n(i):t.readUint8Array(a,t.size-a,(function(t){var s,o,a,c,u=0,d=[],p=A(t.length,t);for(s=0;s>>8^i[255&(t^e[s])];this.crc=t},a.prototype.get=function(){return~this.crc},a.prototype.table=function(){var e,t,i,s=[];for(e=0;e<256;e++){for(i=e,t=0;t<8;t++)1&i?i=i>>>1^3988292384:i>>>=1;s[e]=i}return s}(),l.prototype.append=function(e,t){return e},l.prototype.flush=function(){},c.prototype=new h,c.prototype.constructor=c,u.prototype=new h,u.prototype.constructor=u,d.prototype=new h,d.prototype.constructor=d,p.prototype.getData=function(e){e(this.data)},f.prototype=new p,f.prototype.constructor=f,g.prototype=new p,g.prototype.constructor=g,m.prototype=new p,m.prototype.constructor=m;var E={deflater:["z-worker.js","deflate.js"],inflater:["z-worker.js","inflate.js"]};function I(t,i,s){if(null===e.zip.workerScripts||null===e.zip.workerScriptsPath){var r;if(e.zip.workerScripts){if(r=e.zip.workerScripts[t],!Array.isArray(r))return void s(new Error("zip.workerScripts."+t+" is not an array!"));r=function(e){var t=document.createElement("a");return e.map((function(e){return t.href=e,t.href}))}(r)}else(r=E[t].slice(0))[0]=(e.zip.workerScriptsPath||"")+r[0];var o=new Worker(r[0]);o.codecTime=o.crcTime=0,o.postMessage({type:"importScripts",scripts:r.slice(1)}),o.addEventListener("message",(function e(t){var r=t.data;if(r.error)return o.terminate(),void s(r.error);"importScripts"===r.type&&(o.removeEventListener("message",e),o.removeEventListener("error",n),i(o))})),o.addEventListener("error",n)}else s(new Error("Either zip.workerScripts or zip.workerScriptsPath may be set, not both."));function n(e){o.terminate(),s(e)}}function D(e){console.error(e)}e.zip={Reader:h,Writer:p,BlobReader:d,Data64URIReader:u,TextReader:c,BlobWriter:m,Data64URIWriter:g,TextWriter:f,createReader:function(e,t,i){i=i||D,e.init((function(){P(e,t,i)}),i)},createWriter:function(e,t,i,s){i=i||D,s=!!s,e.init((function(){F(e,t,i,s)}),i)},useWebWorkers:!0,workerScriptsPath:null,workerScripts:null}}(rP);const oP=rP.zip;!function(e){var t,i,s=e.Reader,r=e.Writer;try{i=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function o(e){var t=this;function i(i,s){var r;t.data?i():((r=new XMLHttpRequest).addEventListener("load",(function(){t.size||(t.size=Number(r.getResponseHeader("Content-Length"))||Number(r.response.byteLength)),t.data=new Uint8Array(r.response),i()}),!1),r.addEventListener("error",s,!1),r.open("GET",e),r.responseType="arraybuffer",r.send())}t.size=0,t.init=function(s,r){if(function(e){var t=document.createElement("a");return t.href=e,"http:"===t.protocol||"https:"===t.protocol}(e)){var o=new XMLHttpRequest;o.addEventListener("load",(function(){t.size=Number(o.getResponseHeader("Content-Length")),t.size?s():i(s,r)}),!1),o.addEventListener("error",r,!1),o.open("HEAD",e),o.send()}else i(s,r)},t.readUint8Array=function(e,s,r,o){i((function(){r(new Uint8Array(t.data.subarray(e,e+s)))}),o)}}function n(e){var t=this;t.size=0,t.init=function(i,s){var r=new XMLHttpRequest;r.addEventListener("load",(function(){t.size=Number(r.getResponseHeader("Content-Length")),"bytes"==r.getResponseHeader("Accept-Ranges")?i():s("HTTP Range not supported.")}),!1),r.addEventListener("error",s,!1),r.open("HEAD",e),r.send()},t.readUint8Array=function(t,i,s,r){!function(t,i,s,r){var o=new XMLHttpRequest;o.open("GET",e),o.responseType="arraybuffer",o.setRequestHeader("Range","bytes="+t+"-"+(t+i-1)),o.addEventListener("load",(function(){s(o.response)}),!1),o.addEventListener("error",r,!1),o.send()}(t,i,(function(e){s(new Uint8Array(e))}),r)}}function a(e){var t=this;t.size=0,t.init=function(i,s){t.size=e.byteLength,i()},t.readUint8Array=function(t,i,s,r){s(new Uint8Array(e.slice(t,t+i)))}}function l(){var e,t=this;t.init=function(t,i){e=new Uint8Array,t()},t.writeUint8Array=function(t,i,s){var r=new Uint8Array(e.length+t.length);r.set(e),r.set(t,e.length),e=r,i()},t.getData=function(t){t(e.buffer)}}function A(e,t){var s,r=this;r.init=function(t,i){e.createWriter((function(e){s=e,t()}),i)},r.writeUint8Array=function(e,r,o){var n=new Blob([i?e:e.buffer],{type:t});s.onwrite=function(){s.onwrite=null,r()},s.onerror=o,s.write(n)},r.getData=function(t){e.file(t)}}o.prototype=new s,o.prototype.constructor=o,n.prototype=new s,n.prototype.constructor=n,a.prototype=new s,a.prototype.constructor=a,l.prototype=new r,l.prototype.constructor=l,A.prototype=new r,A.prototype.constructor=A,e.FileWriter=A,e.HttpReader=o,e.HttpRangeReader=n,e.ArrayBufferReader=a,e.ArrayBufferWriter=l,e.fs&&((t=e.fs.ZipDirectoryEntry).prototype.addHttpContent=function(i,s,r){return function(i,s,r,o){if(i.directory)return o?new t(i.fs,s,r,i):new e.fs.ZipFileEntry(i.fs,s,r,i);throw"Parent entry is not a directory."}(this,i,{data:s,Reader:r?n:o})},t.prototype.importHttpContent=function(e,t,i,s){this.importZip(t?new n(e):new o(e),i,s)},e.fs.FS.prototype.importHttpContent=function(e,i,s,r){this.entries=[],this.root=new t(this),this.root.importHttpContent(e,i,s,r)})}(oP);const nP=["4.2"];class aP{constructor(e,t={}){this.supportedSchemas=nP,this._xrayOpacity=.7,this._src=null,this._options=t,this.viewpoint=null,t.workerScriptsPath?(oP.workerScriptsPath=t.workerScriptsPath,this.src=t.src,this.xrayOpacity=.7,this.displayEffect=t.displayEffect,this.createMetaModel=t.createMetaModel):e.error("Config expected: workerScriptsPath")}load(e,t,i,s,r,o){switch(s.materialType){case"MetallicMaterial":t._defaultMaterial=new cs(t,{baseColor:[1,1,1],metallic:.6,roughness:.6});break;case"SpecularMaterial":t._defaultMaterial=new ps(t,{diffuse:[1,1,1],specular:c.vec3([1,1,1]),glossiness:.5});break;default:t._defaultMaterial=new Vt(t,{reflectivity:.75,shiness:100,diffuse:[1,1,1]})}t._wireframeMaterial=new ls(t,{color:[0,0,0],lineWidth:2});var n=t.scene.canvas.spinner;n.processes++,lP(e,t,i,s,(function(){n.processes--,r&&r(),t.fire("loaded",!0,!1)}),(function(e){n.processes--,t.error(e),o&&o(e),t.fire("error",e)}),(function(e){console.log("Error, Will Robinson: "+e)}))}}var lP=function(e,t,i,s,r,o){!function(e,t,i){var s=new gP;s.load(e,(function(){t(s)}),(function(e){i("Error loading ZIP archive: "+e)}))}(i,(function(i){AP(e,i,s,t,r,o)}),o)},AP=function(){return function(t,i,s,r,o){var n={plugin:t,zip:i,edgeThreshold:30,materialType:s.materialType,scene:r.scene,modelNode:r,info:{references:{}},materials:{}};s.createMetaModel&&(n.metaModelData={modelId:r.id,metaObjects:[{name:r.id,type:"Default",id:r.id}]}),r.scene.loading++,function(t,i){t.zip.getFile("Manifest.xml",(function(s,r){for(var o=r.children,n=0,a=o.length;n0){for(var n=o.trim().split(" "),a=new Int16Array(n.length),l=0,A=0,h=n.length;A0){i.primitive="triangles";for(var o=[],n=0,a=r.length;n=t.length)i();else{var a=t[o].id,l=a.lastIndexOf(":");l>0&&(a=a.substring(l+1));var A=a.lastIndexOf("#");A>0&&(a=a.substring(0,A)),s[a]?r(o+1):function(e,t,i){e.zip.getFile(t,(function(t,s){!function(e,t,i){for(var s,r=t.children,o=0,n=r.length;o0)for(var s=0,r=t.length;s{};t=t||s,i=i||s;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var o=r[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),i=new Uint8Array(e);for(var n=0;n{};t=t||s,i=i||s;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var o=r[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),i=new Uint8Array(e);for(var n=0;n{let t=0,i=0,s=0;const r=new DataView(e),o=new Uint8Array(6e3),n=({item:s,format:o,size:n})=>{let a,l;switch(o){case"char":return l=new Uint8Array(e,t,n),t+=n,a=PP(l),[s,a];case"uShort":return a=r.getUint16(t,!0),t+=n,[s,a];case"uLong":return a=r.getUint32(t,!0),"NumberOfVariableLengthRecords"===s&&(i=a),t+=n,[s,a];case"uChar":return a=r.getUint8(t),t+=n,[s,a];case"double":return a=r.getFloat64(t,!0),t+=n,[s,a];default:t+=n}};return(()=>{const e={};yP.forEach((t=>{const i=n({...t});if(void 0!==i){if("FileSignature"===i[0]&&"LASF"!==i[1])throw new Error("Ivalid FileSignature. Is this a LAS/LAZ file");e[i[0]]=i[1]}}));const r=[];let a=i;for(;a--;){const e={};xP.forEach((i=>{const r=n({...i});e[r[0]]=r[1],"UserId"===r[0]&&"LASF_Projection"===r[1]&&(s=t-18+54)})),r.push(e)}const l=(e=>{if(void 0===e)return;const t=s+e.RecordLengthAfterHeader,i=o.slice(s,t),r=wP(i),n=new DataView(r);let a=6,l=Number(n.getUint16(a,!0));const A=[];for(;l--;){const e={};e.key=n.getUint16(a+=2,!0),e.tiffTagLocation=n.getUint16(a+=2,!0),e.count=n.getUint16(a+=2,!0),e.valueOffset=n.getUint16(a+=2,!0),A.push(e)}const h=A.find((e=>3072===e.key));if(h&&h.hasOwnProperty("valueOffset"))return h.valueOffset})(r.find((e=>"LASF_Projection"===e.UserId)));return l&&(e.epsg=l),e})()},wP=e=>{let t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let t=0;t{let t="";return e.forEach((e=>{let i=String.fromCharCode(e);"\0"!==i&&(t+=i)})),t.trim()};function CP(e,t){if(t>=e.length)return e;let i=[];for(let s=0;s{t(e)}),(function(e){i(e)}))}}function FP(e,t,i){i=i||2;var s,r,o,n,a,l,A,h=t&&t.length,c=h?t[0]*i:e.length,u=EP(e,0,c,i,!0),d=[];if(!u||u.next===u.prev)return d;if(h&&(u=function(e,t,i,s){var r,o,n,a=[];for(r=0,o=t.length;r80*i){s=o=e[0],r=n=e[1];for(var p=i;po&&(o=a),l>n&&(n=l);A=0!==(A=Math.max(o-s,n-r))?1/A:0}return DP(u,d,i,s,r,A),d}function EP(e,t,i,s,r){var o,n;if(r===$P(e,t,i,s)>0)for(o=t;o=t;o-=s)n=YP(o,e[o],e[o+1],n);return n&&GP(n,n.next)&&(ZP(n),n=n.next),n}function IP(e,t){if(!e)return e;t||(t=e);var i,s=e;do{if(i=!1,s.steiner||!GP(s,s.next)&&0!==jP(s.prev,s,s.next))s=s.next;else{if(ZP(s),(s=t=s.prev)===s.next)break;i=!0}}while(i||s!==t);return t}function DP(e,t,i,s,r,o,n){if(e){!n&&o&&function(e,t,i,s){var r=e;do{null===r.z&&(r.z=NP(r.x,r.y,t,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,i,s,r,o,n,a,l,A=1;do{for(i=e,e=null,o=null,n=0;i;){for(n++,s=i,a=0,t=0;t0||l>0&&s;)0!==a&&(0===l||!s||i.z<=s.z)?(r=i,i=i.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=s}o.nextZ=null,A*=2}while(n>1)}(r)}(e,s,r,o);for(var a,l,A=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?TP(e,s,r,o):SP(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),ZP(e),e=l.next,A=l.next;else if((e=l)===A){n?1===n?DP(e=RP(IP(e),t,i),t,i,s,r,o,2):2===n&&LP(e,t,i,s,r,o):DP(IP(e),t,i,s,r,o,1);break}}}function SP(e){var t=e.prev,i=e,s=e.next;if(jP(t,i,s)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(VP(t.x,t.y,i.x,i.y,s.x,s.y,r.x,r.y)&&jP(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function TP(e,t,i,s){var r=e.prev,o=e,n=e.next;if(jP(r,o,n)>=0)return!1;for(var a=r.xo.x?r.x>n.x?r.x:n.x:o.x>n.x?o.x:n.x,h=r.y>o.y?r.y>n.y?r.y:n.y:o.y>n.y?o.y:n.y,c=NP(a,l,t,i,s),u=NP(A,h,t,i,s),d=e.prevZ,p=e.nextZ;d&&d.z>=c&&p&&p.z<=u;){if(d!==e.prev&&d!==e.next&&VP(r.x,r.y,o.x,o.y,n.x,n.y,d.x,d.y)&&jP(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&&VP(r.x,r.y,o.x,o.y,n.x,n.y,p.x,p.y)&&jP(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=c;){if(d!==e.prev&&d!==e.next&&VP(r.x,r.y,o.x,o.y,n.x,n.y,d.x,d.y)&&jP(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==e.prev&&p!==e.next&&VP(r.x,r.y,o.x,o.y,n.x,n.y,p.x,p.y)&&jP(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function RP(e,t,i){var s=e;do{var r=s.prev,o=s.next.next;!GP(r,o)&&zP(r,s,s.next,o)&&XP(r,o)&&XP(o,r)&&(t.push(r.i/i),t.push(s.i/i),t.push(o.i/i),ZP(s),ZP(s.next),s=e=o),s=s.next}while(s!==e);return IP(s)}function LP(e,t,i,s,r,o){var n=e;do{for(var a=n.next.next;a!==n.prev;){if(n.i!==a.i&&HP(n,a)){var l=JP(n,a);return n=IP(n,n.next),l=IP(l,l.next),DP(n,t,i,s,r,o),void DP(l,t,i,s,r,o)}a=a.next}n=n.next}while(n!==e)}function UP(e,t){return e.x-t.x}function kP(e,t){if(t=function(e,t){var i,s=t,r=e.x,o=e.y,n=-1/0;do{if(o<=s.y&&o>=s.next.y&&s.next.y!==s.y){var a=s.x+(o-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(a<=r&&a>n){if(n=a,a===r){if(o===s.y)return s;if(o===s.next.y)return s.next}i=s.x=s.x&&s.x>=h&&r!==s.x&&VP(oi.x||s.x===i.x&&OP(i,s)))&&(i=s,u=l)),s=s.next}while(s!==A);return i}(e,t),t){var i=JP(t,e);IP(t,t.next),IP(i,i.next)}}function OP(e,t){return jP(e.prev,e,t.prev)<0&&jP(t.next,e,e.next)<0}function NP(e,t,i,s,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function QP(e){var t=e,i=e;do{(t.x=0&&(e-n)*(s-a)-(i-n)*(t-a)>=0&&(i-n)*(o-a)-(r-n)*(s-a)>=0}function HP(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&zP(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(XP(e,t)&&XP(t,e)&&function(e,t){var i=e,s=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==e);return s}(e,t)&&(jP(e.prev,e,t.prev)||jP(e,t.prev,t))||GP(e,t)&&jP(e.prev,e,e.next)>0&&jP(t.prev,t,t.next)>0)}function jP(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function GP(e,t){return e.x===t.x&&e.y===t.y}function zP(e,t,i,s){var r=KP(jP(e,t,i)),o=KP(jP(e,t,s)),n=KP(jP(i,s,e)),a=KP(jP(i,s,t));return r!==o&&n!==a||(!(0!==r||!WP(e,i,t))||(!(0!==o||!WP(e,s,t))||(!(0!==n||!WP(i,e,s))||!(0!==a||!WP(i,t,s)))))}function WP(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function KP(e){return e>0?1:e<0?-1:0}function XP(e,t){return jP(e.prev,e,e.next)<0?jP(e,t,e.next)>=0&&jP(e,e.prev,t)>=0:jP(e,t,e.prev)<0||jP(e,e.next,t)<0}function JP(e,t){var i=new qP(e.i,e.x,e.y),s=new qP(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,s.next=i,i.prev=s,o.next=s,s.prev=o,s}function YP(e,t,i,s){var r=new qP(e,t,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function ZP(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function qP(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function $P(e,t,i,s){for(var r=0,o=t,n=i-s;o0&&(s+=e[r-1].length,i.holes.push(s))}return i};const eC=c.vec2(),tC=c.vec3(),iC=c.vec3(),sC=c.vec3();exports.AlphaFormat=1021,exports.AmbientLight=wt,exports.AngleMeasurementsControl=pe,exports.AngleMeasurementsMouseControl=fe,exports.AngleMeasurementsPlugin=class extends V{constructor(e,t={}){super("AngleMeasurements",e),this._container=t.container||document.body,this._defaultControl=null,this._measurements={},this.defaultColor=void 0!==t.defaultColor?t.defaultColor:"#00BBFF",this.defaultLabelsVisible=!1!==t.defaultLabelsVisible,this.zIndex=t.zIndex||1e4,this._onMouseOver=(e,t)=>{this.fire("mouseOver",{plugin:this,angleMeasurement:t,measurement:t,event:e})},this._onMouseLeave=(e,t)=>{this.fire("mouseLeave",{plugin:this,angleMeasurement:t,measurement:t,event:e})},this._onContextMenu=(e,t)=>{this.fire("contextMenu",{plugin:this,angleMeasurement:t,measurement:t,event:e})}}getContainerElement(){return this._container}send(e,t){}get control(){return this._defaultControl||(this._defaultControl=new fe(this,{})),this._defaultControl}get measurements(){return this._measurements}createMeasurement(e={}){this.viewer.scene.components[e.id]&&(this.error("Viewer scene component with this ID already exists: "+e.id),delete e.id);const t=e.origin,i=e.corner,s=e.target,r=new de(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},corner:{entity:i.entity,worldPos:i.worldPos},target:{entity:s.entity,worldPos:s.worldPos},visible:e.visible,originVisible:!0,originWireVisible:!0,cornerVisible:!0,targetWireVisible:!0,targetVisible:!0,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[r.id]=r,r.on("destroyed",(()=>{delete this._measurements[r.id]})),r.clickable=!0,this.fire("measurementCreated",r),r}destroyMeasurement(e){const t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("AngleMeasurement not found: "+e)}setLabelsShown(e){for(const[t,i]of Object.entries(this.measurements))i.labelShown=e}clear(){const e=Object.keys(this._measurements);for(var t=0,i=e.length;t{this.plugin.viewer.cameraControl.active=!1},u=()=>{this.plugin.viewer.cameraControl.active=!0},d=()=>{o&&(clearTimeout(o),o=null),this._currentAngleMeasurement&&(this._currentAngleMeasurement.destroy(),this._currentAngleMeasurement=null),u(),this._touchState=0};i.addEventListener("touchstart",this._onCanvasTouchStart=i=>{const l=i.touches.length;if(1!==l)return void(o&&(clearTimeout(o),o=null));const u=i.touches[0],p=u.clientX,f=u.clientY;switch(n.set([p,f]),a.set([p,f]),this._touchState){case 0:if(1!==l&&null!==o)return void d();const i=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge});if(i&&i.snapped)s.set(i.worldPos),this.pointerCircle.start(i.snappedCanvasPos);else{const e=t.pick({canvasPos:a,pickSurface:!0});if(!e||!e.worldPos)return;s.set(e.worldPos),this.pointerCircle.start(e.canvasPos)}o=setTimeout((()=>{1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{if(o=null,1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{if(o=null,1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{this.pointerCircle.stop();const i=e.touches.length;if(1!==i||1!==e.changedTouches.length)return void(o&&(clearTimeout(o),o=null));const r=e.touches[0],n=r.clientX,l=r.clientY;if(r.identifier!==A)return;let h,c;switch(a.set([n,l]),this._touchState){case 2:this.pointerLens&&(this.pointerLens.canvasPos=a),h=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),h&&h.snapped?(this.pointerLens&&(this.pointerLens.snappedCanvasPos=h.snappedCanvasPos,this.pointerLens.snapped=!0),s.set(h.worldPos),this._currentAngleMeasurement.origin.worldPos=h.worldPos):(c=t.pick({canvasPos:a,pickSurface:!0}),c&&c.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=c.canvasPos,this.pointerLens.snapped=!1),s.set(c.worldPos),this._currentAngleMeasurement.origin.worldPos=c.worldPos):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)),this._touchState=2;break;case 5:if(1!==i&&null!==o)return clearTimeout(o),o=null,this.pointerLens&&(this.pointerLens.visible=!1),void(this._touchState=7);this.pointerLens&&(this.pointerLens.canvasPos=a),h=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),h&&h.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=h.snappedCanvasPos,this.pointerLens.snapped=!0),this._currentAngleMeasurement.corner.worldPos=h.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1):(c=t.pick({canvasPos:a,pickSurface:!0}),c&&c.worldPos&&(this.pointerLens&&(this.pointerLens.cursorPos=c.canvasPos,this.pointerLens.snapped=!1),this._currentAngleMeasurement.corner.worldPos=c.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!1,this._currentAngleMeasurement.targetVisible=!1,this._currentAngleMeasurement.targetWireVisible=!1,this._currentAngleMeasurement.angleVisible=!1)),this._touchState=5;break;case 8:if(1!==i&&null!==o)return clearTimeout(o),o=null,this.pointerLens&&(this.pointerLens.visible=!1),void(this._touchState=7);this.pointerLens&&(this.pointerLens.canvasPos=a),h=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),h&&h.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=h.snappedCanvasPos,this.pointerLens.snapped=!0),this._currentAngleMeasurement.target.worldPos=h.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.angleVisible=!0):(c=t.pick({canvasPos:a,pickSurface:!0}),c&&c.worldPos&&(this.pointerLens&&(this.pointerLens.cursorPos=c.canvasPos,this.pointerLens.snapped=!1),this._currentAngleMeasurement.target.worldPos=c.worldPos,this._currentAngleMeasurement.originVisible=!0,this._currentAngleMeasurement.originWireVisible=!0,this._currentAngleMeasurement.cornerVisible=!0,this._currentAngleMeasurement.cornerWireVisible=!0,this._currentAngleMeasurement.targetVisible=!0,this._currentAngleMeasurement.targetWireVisible=!0,this._currentAngleMeasurement.angleVisible=!0)),this._touchState=8}}),{passive:!0}),i.addEventListener("touchend",this._onCanvasTouchEnd=i=>{this.pointerCircle.stop();const s=i.changedTouches.length;if(1!==s)return;const h=i.changedTouches[0],d=h.clientX,p=h.clientY;if(h.identifier===A)switch(o&&(clearTimeout(o),o=null),l.set([d,p]),this._touchState){case 1:{if(1!==s||d>n[0]+r||dn[1]+r||pn[0]+r||dn[1]+r||pn[0]+r||dn[1]+r||p",this._markerHTML=t.markerHTML||"
",this._container=t.container||document.body,this._values=t.values||{},this.annotations={},this.surfaceOffset=t.surfaceOffset}getContainerElement(){return this._container}send(e,t){if("clearAnnotations"===e)this.clear()}set surfaceOffset(e){null==e&&(e=.3),this._surfaceOffset=e}get surfaceOffset(){return this._surfaceOffset}createAnnotation(e){var t,i;if(this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id),e.pickResult=e.pickResult||e.pickRecord,e.pickResult){const s=e.pickResult;if(s.worldPos&&s.worldNormal){const e=c.normalizeVec3(s.worldNormal,me),r=c.mulVec3Scalar(e,this._surfaceOffset,_e);t=c.addVec3(s.worldPos,r,ve),i=s.entity}else this.error("Param 'pickResult' does not have both worldPos and worldNormal")}else t=e.worldPos,i=e.entity;var s=null;e.markerElementId&&((s=document.getElementById(e.markerElementId))||this.error("Can't find DOM element for 'markerElementId' value '"+e.markerElementId+"' - defaulting to internally-generated empty DIV"));var r=null;e.labelElementId&&((r=document.getElementById(e.labelElementId))||this.error("Can't find DOM element for 'labelElementId' value '"+e.labelElementId+"' - defaulting to internally-generated empty DIV"));const o=new ge(this.viewer.scene,{id:e.id,plugin:this,entity:i,worldPos:t,container:this._container,markerElement:s,labelElement:r,markerHTML:e.markerHTML||this._markerHTML,labelHTML:e.labelHTML||this._labelHTML,occludable:e.occludable,values:_.apply(e.values,_.apply(this._values,{})),markerShown:e.markerShown,labelShown:e.labelShown,eye:e.eye,look:e.look,up:e.up,projection:e.projection,visible:!1!==e.visible});return this.annotations[o.id]=o,o.on("destroyed",(()=>{delete this.annotations[o.id],this.fire("annotationDestroyed",o.id)})),this.fire("annotationCreated",o.id),o}destroyAnnotation(e){var t=this.annotations[e];t?t.destroy():this.log("Annotation not found: "+e)}clear(){const e=Object.keys(this.annotations);for(var t=0,i=e.length;tp.has(e.id)||g.has(e.id)||f.has(e.id))).reduce(((e,i)=>{let s,r=function(e){let t="";return t+=Math.round(255*e[0]).toString(16).padStart(2,"0"),t+=Math.round(255*e[1]).toString(16).padStart(2,"0"),t+=Math.round(255*e[2]).toString(16).padStart(2,"0"),t}(i.colorize);i.xrayed?(s=0===t.xrayMaterial.fillAlpha&&0!==t.xrayMaterial.edgeAlpha?.1:t.xrayMaterial.fillAlpha,s=Math.round(255*s).toString(16).padStart(2,"0"),r=s+r):p.has(i.id)&&(s=Math.round(255*i.opacity).toString(16).padStart(2,"0"),r=s+r),e[r]||(e[r]=[]);const o=i.id,n=i.originalSystemId,a={ifc_guid:n,originating_system:this.originatingSystem};return n!==o&&(a.authoring_tool_id=o),e[r].push(a),e}),{}),_=Object.entries(m).map((([e,t])=>({color:e,components:t})));o.components.coloring=_;const v=t.objectIds,b=t.visibleObjects,y=t.visibleObjectIds,x=v.filter((e=>!b[e])),B=t.selectedObjectIds;return e.defaultInvisible||y.length0&&e.clipping_planes.forEach((function(e){let t=qA(e.location,KA),i=qA(e.direction,KA);A&&c.negateVec3(i),c.subVec3(t,l),r.yUp&&(t=eh(t),i=eh(i)),new Zi(s,{pos:t,dir:i})})),s.clearLines(),e.lines&&e.lines.length>0){const t=[],i=[];let r=0;e.lines.forEach((e=>{e.start_point&&e.end_point&&(t.push(e.start_point.x),t.push(e.start_point.y),t.push(e.start_point.z),t.push(e.end_point.x),t.push(e.end_point.y),t.push(e.end_point.z),i.push(r++),i.push(r++))})),new WA(s,{positions:t,indices:i,clippable:!1,collidable:!0})}if(s.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){const t=e.bitmap_type||"jpg",i=e.bitmap_data;let o=qA(e.location,XA),n=qA(e.normal,JA),a=qA(e.up,YA),l=e.height||1;t&&i&&o&&n&&a&&(r.yUp&&(o=eh(o),n=eh(n),a=eh(a)),new Ts(s,{src:i,type:t,pos:o,normal:n,up:a,clippable:!1,collidable:!0,height:l}))})),a&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),s.setObjectsHighlighted(s.highlightedObjectIds,!1),s.setObjectsSelected(s.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(s.setObjectsVisible(s.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!1))))):(s.setObjectsVisible(s.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!0)))));const r=e.components.visibility.view_setup_hints;r&&(!1===r.spaces_visible&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcSpace"),!0),void 0!==r.spaces_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcSpace"),!0),r.space_boundaries_visible,!1===r.openings_visible&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcOpening"),!0),r.space_boundaries_translucent,void 0!==r.openings_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(s.setObjectsSelected(s.selectedObjectIds,!1),e.components.selection.forEach((e=>this._withBCFComponent(t,e,(e=>e.selected=!0))))),e.components.translucency&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),e.components.translucency.forEach((e=>this._withBCFComponent(t,e,(e=>e.xrayed=!0))))),e.components.coloring&&e.components.coloring.forEach((e=>{let i=e.color,s=0,r=!1;8===i.length&&(s=parseInt(i.substring(0,2),16)/256,s<=1&&s>=.95&&(s=1),i=i.substring(2),r=!0);const o=[parseInt(i.substring(0,2),16)/256,parseInt(i.substring(2,4),16)/256,parseInt(i.substring(4,6),16)/256];e.components.map((e=>this._withBCFComponent(t,e,(e=>{e.colorize=o,r&&(e.opacity=s)}))))}))}if(e.perspective_camera||e.orthogonal_camera){let a,A,h,u;if(e.perspective_camera?(a=qA(e.perspective_camera.camera_view_point,KA),A=qA(e.perspective_camera.camera_direction,KA),h=qA(e.perspective_camera.camera_up_vector,KA),r.perspective.fov=e.perspective_camera.field_of_view,u="perspective"):(a=qA(e.orthogonal_camera.camera_view_point,KA),A=qA(e.orthogonal_camera.camera_direction,KA),h=qA(e.orthogonal_camera.camera_up_vector,KA),r.ortho.scale=e.orthogonal_camera.view_to_world_scale,u="ortho"),c.subVec3(a,l),r.yUp&&(a=eh(a),A=eh(A),h=eh(h)),o){const e=s.pick({pickSurface:!0,origin:a,direction:A});A=e?e.worldPos:c.addVec3(a,A,KA)}else A=c.addVec3(a,A,KA);n?(r.eye=a,r.look=A,r.up=h,r.projection=u):i.cameraFlight.flyTo({eye:a,look:A,up:h,duration:t.duration,projection:u})}}_withBCFComponent(e,t,i){const s=this.viewer,r=s.scene;if(t.authoring_tool_id&&t.originating_system===this.originatingSystem){const o=t.authoring_tool_id,n=r.objects[o];if(n)return void i(n);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[o])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(o),i)}}if(t.ifc_guid){const o=t.ifc_guid,n=r.objects[o];if(n)return void i(n);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[o])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(o),i)}Object.keys(r.models).forEach((t=>{const n=c.globalizeObjectId(t,o),a=r.objects[n];if(a)i(a);else if(e.updateCompositeObjects){s.metaScene.metaObjects[n]&&r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}}))}}destroy(){super.destroy()}},exports.Bitmap=Ts,exports.ByteType=1010,exports.CameraMemento=Fh,exports.CameraPath=class extends D{get type(){return"CameraPath"}constructor(e,t={}){super(e,t),this._frames=[],this._eyeCurve=new ch(this),this._lookCurve=new ch(this),this._upCurve=new ch(this),t.frames&&(this.addFrames(t.frames),this.smoothFrameTimes(1))}get frames(){return this._frames}get eyeCurve(){return this._eyeCurve}get lookCurve(){return this._lookCurve}get upCurve(){return this._upCurve}saveFrame(e){const t=this.scene.camera;this.addFrame(e,t.eye,t.look,t.up)}addFrame(e,t,i,s){const r={t:e,eye:t.slice(0),look:i.slice(0),up:s.slice(0)};this._frames.push(r),this._eyeCurve.points.push(r.eye),this._lookCurve.points.push(r.look),this._upCurve.points.push(r.up)}addFrames(e){let t;for(let i=0,s=e.length;i1?1:e,t.eye=this._eyeCurve.getPoint(e,uh),t.look=this._lookCurve.getPoint(e,uh),t.up=this._upCurve.getPoint(e,uh)}sampleFrame(e,t,i,s){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,s)}smoothFrameTimes(e){if(0===this._frames.length)return;const t=c.vec3();var i=0;this._frames[0].t=0;const s=[];for(let e=1,o=this._frames.length;e{this._parseModel(e,t,i,s),r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){if(s.destroyed)return;const r=e.transform?this._transformVertices(e.vertices,e.transform,i.rotateX):e.vertices,o=t.stats||{};o.sourceFormat=e.type||"CityJSON",o.schemaVersion=e.version||"",o.title="",o.author="",o.created="",o.numMetaObjects=0,o.numPropertySets=0,o.numObjects=0,o.numGeometries=0,o.numTriangles=0,o.numVertices=0;const n=!1!==t.loadMetadata,a=n?{id:c.createUUID(),name:"Model",type:"Model"}:null,l=n?{id:"",projectId:"",author:"",createdAt:"",schema:e.version||"",creatingApplication:"",metaObjects:[a],propertySets:[]}:null,A={data:e,vertices:r,sceneModel:s,loadMetadata:n,metadata:l,rootMetaObject:a,nextId:0,stats:o};if(this._parseCityJSON(A),s.finalize(),n){const e=s.id;this.viewer.metaScene.createMetaModel(e,A.metadata,i)}s.scene.once("tick",(()=>{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}_transformVertices(e,t,i){const s=[],r=t.scale||c.vec3([1,1,1]),o=t.translate||c.vec3([0,0,0]);for(let t=0,n=0;t0))return;const o=[];for(let i=0,s=t.geometry.length;i0){const r=t[s[0]];if(void 0!==r.value)n=e[r.value];else{const t=r.values;if(t){a=[];for(let s=0,r=t.length;s0&&(s.createEntity({id:i,meshIds:o,isObject:!0}),e.stats.numObjects++)}_parseGeometrySurfacesWithOwnMaterials(e,t,i,s){switch(t.type){case"MultiPoint":case"MultiLineString":break;case"MultiSurface":case"CompositeSurface":const r=t.boundaries;this._parseSurfacesWithOwnMaterials(e,i,r,s);break;case"Solid":const o=t.boundaries;for(let t=0;t0&&h.push(A.length);const i=this._extractLocalIndices(e,a[t],u,d);A.push(...i)}if(3===A.length)d.indices.push(A[0]),d.indices.push(A[1]),d.indices.push(A[2]);else if(A.length>3){const e=[];for(let t=0;t0&&n.indices.length>0){const t=""+e.nextId++;r.createMesh({id:t,primitive:"triangles",positions:n.positions,indices:n.indices,color:i&&i.diffuseColor?i.diffuseColor:[.8,.8,.8],opacity:1}),s.push(t),e.stats.numGeometries++,e.stats.numVertices+=n.positions.length/3,e.stats.numTriangles+=n.indices.length/3}}_parseSurfacesWithSharedMaterial(e,t,i,s){const r=e.vertices;for(let o=0;o0&&a.push(n.length);const l=this._extractLocalIndices(e,t[o][r],i,s);n.push(...l)}if(3===n.length)s.indices.push(n[0]),s.indices.push(n[1]),s.indices.push(n[2]);else if(n.length>3){let e=[];for(let t=0;t{e.target.classList.contains("xeokit-context-menu-item")||this.hide()})),document.addEventListener("touchstart",this._canvasTouchStartHandler=e=>{e.target.classList.contains("xeokit-context-menu-item")||this.hide()})),e.items&&(this.items=e.items),this._hideOnAction=!1!==e.hideOnAction,this.context=e.context,this.enabled=!1!==e.enabled,this.hide()}on(e,t){let i=this._eventSubs[e];i||(i=[],this._eventSubs[e]=i),i.push(t)}fire(e,t){const i=this._eventSubs[e];if(i)for(let e=0,s=i.length;e{const o=this._getNextId(),n=new i(o);for(let i=0,o=e.length;i0,A=this._getNextId(),h=i.getTitle||(()=>i.title||""),c=i.doAction||i.callback||(()=>{}),u=i.getEnabled||(()=>!0),d=i.getShown||(()=>!0),p=new r(A,h,c,u,d);if(p.parentMenu=n,a.items.push(p),l){const e=t(s);p.subMenu=e,e.parentItem=p}this._itemList.push(p),this._itemMap[p.id]=p}}return this._menuList.push(n),this._menuMap[n.id]=n,n};this._rootMenu=t(e)}_getNextId(){return"ContextMenu_"+this._id+"_"+this._nextId++}_createUI(){const e=t=>{this._createMenuUI(t);const i=t.groups;for(let t=0,s=i.length;t'),i.push("
    "),t)for(let e=0,s=t.length;e'+l+" [MORE]"):i.push('
  • '+l+"
  • ")}}i.push("
"),i.push("");const s=i.join("");document.body.insertAdjacentHTML("beforeend",s);const r=document.querySelector("."+e.id);e.menuElement=r,r.style["border-radius"]="4px",r.style.display="none",r.style["z-index"]=3e5,r.style.background="white",r.style.border="1px solid black",r.style["box-shadow"]="0 4px 5px 0 gray",r.oncontextmenu=e=>{e.preventDefault()};const o=this;let n=null;if(t)for(let e=0,i=t.length;e{e.preventDefault();const i=t.subMenu;if(!i)return void(n&&(o._hideMenu(n.id),n=null));if(n&&n.id!==i.id&&(o._hideMenu(n.id),n=null),!1===t.enabled)return;const s=t.itemElement,r=i.menuElement,a=s.getBoundingClientRect();r.getBoundingClientRect();a.right+200>window.innerWidth?o._showMenu(i.id,a.left-200,a.top-1):o._showMenu(i.id,a.right-5,a.top-1),n=i})),s||(t.itemElement.addEventListener("click",(e=>{e.preventDefault(),o._context&&!1!==t.enabled&&(t.doAction&&t.doAction(o._context),this._hideOnAction?o.hide():(o._updateItemsTitles(),o._updateItemsEnabledStatus()))})),t.itemElement.addEventListener("mouseenter",(e=>{e.preventDefault(),!1!==t.enabled&&t.doHover&&t.doHover(o._context)})))):console.error("ContextMenu item element not found: "+t.id)}}}_updateItemsTitles(){if(this._context)for(let e=0,t=this._itemList.length;ewindow.innerHeight&&(i=window.innerHeight-s),t+r>window.innerWidth&&(t=window.innerWidth-r),e.style.left=t+"px",e.style.top=i+"px"}_hideMenuElement(e){e.style.display="none"}},exports.CubicBezierCurve=class extends hh{constructor(e,t={}){super(e,t),this.v0=t.v0,this.v1=t.v1,this.v2=t.v2,this.v3=t.v3,this.t=t.t}set v0(e){this._v0=e||c.vec3([0,0,0])}get v0(){return this._v0}set v1(e){this._v1=e||c.vec3([0,0,0])}get v1(){return this._v1}set v2(e){this._v2=e||c.vec3([0,0,0])}get v2(){return this._v2}set v3(e){this.fire("v3",this._v3=e||c.vec3([0,0,0]))}get v3(){return this._v3}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=c.vec3();return t[0]=c.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),t[1]=c.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),t[2]=c.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),t}getJSON(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}},exports.Curve=hh,exports.DefaultLoadingManager=hA,exports.DepthFormat=1026,exports.DepthStencilFormat=1027,exports.DirLight=Bt,exports.DistanceMeasurementsControl=rh,exports.DistanceMeasurementsMouseControl=oh,exports.DistanceMeasurementsPlugin=class extends V{constructor(e,t={}){super("DistanceMeasurements",e),this._pointerLens=t.pointerLens,this._container=t.container||document.body,this._defaultControl=null,this._measurements={},this.labelMinAxisLength=t.labelMinAxisLength,this.defaultVisible=!1!==t.defaultVisible,this.defaultOriginVisible=!1!==t.defaultOriginVisible,this.defaultTargetVisible=!1!==t.defaultTargetVisible,this.defaultWireVisible=!1!==t.defaultWireVisible,this.defaultLabelsVisible=!1!==t.defaultLabelsVisible,this.defaultAxisVisible=!1!==t.defaultAxisVisible,this.defaultXAxisVisible=!1!==t.defaultXAxisVisible,this.defaultYAxisVisible=!1!==t.defaultYAxisVisible,this.defaultZAxisVisible=!1!==t.defaultZAxisVisible,this.defaultColor=void 0!==t.defaultColor?t.defaultColor:"#00BBFF",this.zIndex=t.zIndex||1e4,this.defaultLabelsOnWires=!1!==t.defaultLabelsOnWires,this._onMouseOver=(e,t)=>{this.fire("mouseOver",{plugin:this,distanceMeasurement:t,measurement:t,event:e})},this._onMouseLeave=(e,t)=>{this.fire("mouseLeave",{plugin:this,distanceMeasurement:t,measurement:t,event:e})},this._onContextMenu=(e,t)=>{this.fire("contextMenu",{plugin:this,distanceMeasurement:t,measurement:t,event:e})}}getContainerElement(){return this._container}send(e,t){}get pointerLens(){return this._pointerLens}get control(){return this._defaultControl||(this._defaultControl=new oh(this,{})),this._defaultControl}get measurements(){return this._measurements}set labelMinAxisLength(e){e<1&&(this.error("labelMinAxisLength must be >= 1; defaulting to 25"),e=25),this._labelMinAxisLength=e||25}get labelMinAxisLength(){return this._labelMinAxisLength}createMeasurement(e={}){this.viewer.scene.components[e.id]&&(this.error("Viewer scene component with this ID already exists: "+e.id),delete e.id);const t=e.origin,i=e.target,s=new sh(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},target:{entity:i.entity,worldPos:i.worldPos},visible:e.visible,wireVisible:e.wireVisible,axisVisible:!1!==e.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==e.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==e.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==e.zAxisVisible&&!1!==this.defaultZAxisVisible,labelsVisible:!1!==e.labelsVisible&&!1!==this.defaultLabelsVisible,originVisible:e.originVisible,targetVisible:e.targetVisible,color:e.color,labelsOnWires:!1!==e.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[s.id]=s,s.on("destroyed",(()=>{delete this._measurements[s.id]})),this.fire("measurementCreated",s),s}destroyMeasurement(e){const t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("DistanceMeasurement not found: "+e)}setLabelsShown(e){for(const[t,i]of Object.entries(this.measurements))i.labelShown=e}setAxisVisible(e){for(const[t,i]of Object.entries(this.measurements))i.axisVisible=e;this.defaultAxisVisible=e}getAxisVisible(){return this.defaultAxisVisible}clear(){const e=Object.keys(this._measurements);for(var t=0,i=e.length;t{this.plugin.viewer.cameraControl.active=!1},u=()=>{this.plugin.viewer.cameraControl.active=!0},d=()=>{o&&(clearTimeout(o),o=null),this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),u(),this._touchState=0};i.addEventListener("touchstart",this._onCanvasTouchStart=i=>{const l=i.touches.length;if(1!==l)return void(o&&(clearTimeout(o),o=null));const u=i.touches[0],p=u.clientX,f=u.clientY;switch(n.set([p,f]),a.set([p,f]),this._touchState){case 0:if(1!==l&&null!==o)return void d();const i=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge});if(i&&i.snapped)s.set(i.worldPos),this.pointerCircle.start(i.snappedCanvasPos);else{const e=t.pick({canvasPos:a,pickSurface:!0});if(!e||!e.worldPos)return;s.set(e.worldPos),this.pointerCircle.start(e.canvasPos)}o=setTimeout((()=>{1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{if(o=null,1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{this.pointerCircle.stop();const r=i.touches.length;if(1!==r||1!==i.changedTouches.length)return void(o&&(clearTimeout(o),o=null));const n=i.touches[0],l=n.clientX,h=n.clientY;if(n.identifier!==A)return;let u,d;switch(a.set([l,h]),this._touchState){case 2:this.pointerLens&&(this.pointerLens.canvasPos=a),u=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),u&&u.snapped?(this.pointerLens&&(this.pointerLens.snappedCanvasPos=u.snappedCanvasPos,this.pointerLens.snapped=!0),s.set(u.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=u.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:c.createUUID(),origin:{worldPos:u.worldPos,entity:u.entity},target:{worldPos:u.worldPos,entity:u.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):(d=t.pick({canvasPos:a,pickSurface:!0}),d&&d.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=d.canvasPos,this.pointerLens.snapped=!1),s.set(d.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=d.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:c.createUUID(),origin:{worldPos:d.worldPos,entity:d.entity},target:{worldPos:d.worldPos,entity:d.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)),this._touchState=2;break;case 5:if(1!==r&&null!==o)return clearTimeout(o),o=null,this.pointerLens&&(this.pointerLens.visible=!1),void(this._touchState=7);this.pointerLens&&(this.pointerLens.canvasPos=a),u=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),u&&u.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=u.snappedCanvasPos,this.pointerLens.snapped=!0),this._currentDistanceMeasurement.target.worldPos=u.worldPos,this._currentDistanceMeasurement.target.entity=u.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0):(d=t.pick({canvasPos:a,pickSurface:!0}),d&&d.worldPos&&(this.pointerLens&&(this.pointerLens.cursorPos=d.canvasPos,this.pointerLens.snapped=!1),this._currentDistanceMeasurement.target.worldPos=d.worldPos,this._currentDistanceMeasurement.target.entity=d.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0)),this._touchState=5}}),{passive:!0}),i.addEventListener("touchend",this._onCanvasTouchEnd=i=>{this.pointerCircle.stop();const s=i.changedTouches.length;if(1!==s)return;const h=i.changedTouches[0],d=h.clientX,p=h.clientY;if(h.identifier===A)switch(o&&(clearTimeout(o),o=null),l.set([d,p]),this._touchState){case 1:{if(1!==s||d>n[0]+r||dn[1]+r||pn[0]+r||dn[1]+r||p{this._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:e=>{this._overview.setPlaneHighlighted(e,!1)},onClickedPlane:e=>{if(this.getShownControl()===e)return void this.hideControl();this.showControl(e);const t=this.sectionPlanes[e].pos;ew.set(this.viewer.scene.aabb),c.getAABB3Center(ew,tw),ew[0]+=t[0]-tw[0],ew[1]+=t[1]-tw[1],ew[2]+=t[2]-tw[2],ew[3]+=t[0]-tw[0],ew[4]+=t[1]-tw[1],ew[5]+=t[2]-tw[2],this.viewer.cameraFlight.flyTo({aabb:ew,fitFOV:65})},onClickedNothing:()=>{this.hideControl()}}):this.warn("Can't find overview canvas: '"+t.overviewCanvasId+"' - will create plugin without overview")}null===t.controlElementId||void 0===t.controlElementId?this.error("Parameter expected: controlElementId"):(this._controlElement=document.getElementById(t.controlElementId),this._controlElement||this.warn("Can't find control element: '"+t.controlElementId+"' - will create plugin without control element")),this._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(e=>{this._sectionPlaneCreated(e)}))}setDragSensitivity(e){this._dragSensitivity=e||1}getDragSensitivity(){return this._dragSensitivity}setOverviewVisible(e){this._overview&&this._overview.setVisible(e)}getOverviewVisible(){if(this._overview)return this._overview.getVisible()}get sectionPlanes(){return this._sectionPlanes}createSectionPlane(e={}){void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);return new Zi(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0})}_sectionPlaneCreated(e){const t=this._freeControls.length>0?this._freeControls.pop():new ZB(this);t._setSectionPlane(e),t.setVisible(!1),this._controls[e.id]=t,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(()=>{this._sectionPlaneDestroyed(e)}))}flipSectionPlanes(){const e=this.viewer.scene.sectionPlanes;for(let t in e){e[t].flipDir()}}showControl(e){const t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}getShownControl(){return this._shownControlId}hideControl(){for(let e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}destroySectionPlane(e){let t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}_sectionPlaneDestroyed(e){this._overview&&this._overview.removeSectionPlane(e);const t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}clear(){const e=Object.keys(this._sectionPlanes);for(let t=0,i=e.length;t{i=1e3*this._delayBeforeRestoreSeconds,s||(e.scene._renderer.setColorTextureEnabled(!this._hideColorTexture),e.scene._renderer.setPBREnabled(!this._hidePBR),e.scene._renderer.setSAOEnabled(!this._hideSAO),e.scene._renderer.setTransparentEnabled(!this._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!this._hideEdges),this._scaleCanvasResolution?e.scene.canvas.resolutionScale=this._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=this._defaultScaleCanvasResolutionFactor,s=!0)},o=()=>{e.scene.canvas.resolutionScale=this._defaultScaleCanvasResolutionFactor,e.scene._renderer.setEdgesEnabled(!0),e.scene._renderer.setColorTextureEnabled(!0),e.scene._renderer.setPBREnabled(!0),e.scene._renderer.setSAOEnabled(!0),e.scene._renderer.setTransparentEnabled(!0),s=!1};this._onCanvasBoundary=e.scene.canvas.on("boundary",r),this._onCameraMatrix=e.scene.camera.on("matrix",r),this._onSceneTick=e.scene.on("tick",(e=>{s&&(i-=e.deltaTime,(!this._delayBeforeRestore||i<=0)&&o())}));let n=!1;this._onSceneMouseDown=e.scene.input.on("mousedown",(()=>{n=!0})),this._onSceneMouseUp=e.scene.input.on("mouseup",(()=>{n=!1})),this._onSceneMouseMove=e.scene.input.on("mousemove",(()=>{n&&r()}))}get hideColorTexture(){return this._hideColorTexture}set hideColorTexture(e){this._hideColorTexture=e}get hidePBR(){return this._hidePBR}set hidePBR(e){this._hidePBR=e}get hideSAO(){return this._hideSAO}set hideSAO(e){this._hideSAO=e}get hideEdges(){return this._hideEdges}set hideEdges(e){this._hideEdges=e}get hideTransparentObjects(){return this._hideTransparentObjects}set hideTransparentObjects(e){this._hideTransparentObjects=!1!==e}get scaleCanvasResolution(){return this._scaleCanvasResolution}set scaleCanvasResolution(e){this._scaleCanvasResolution=e}get defaultScaleCanvasResolutionFactor(){return this._defaultScaleCanvasResolutionFactor}set defaultScaleCanvasResolutionFactor(e){this._defaultScaleCanvasResolutionFactor=e||1}get scaleCanvasResolutionFactor(){return this._scaleCanvasResolutionFactor}set scaleCanvasResolutionFactor(e){this._scaleCanvasResolutionFactor=e||.6}get delayBeforeRestore(){return this._delayBeforeRestore}set delayBeforeRestore(e){this._delayBeforeRestore=e}get delayBeforeRestoreSeconds(){return this._delayBeforeRestoreSeconds}set delayBeforeRestoreSeconds(e){this._delayBeforeRestoreSeconds=null!=e?e:.5}send(e,t){}destroy(){this.viewer.scene.camera.off(this._onCameraMatrix),this.viewer.scene.canvas.off(this._onCanvasBoundary),this.viewer.scene.input.off(this._onSceneMouseDown),this.viewer.scene.input.off(this._onSceneMouseUp),this.viewer.scene.input.off(this._onSceneMouseMove),this.viewer.scene.off(this._onSceneTick),super.destroy()}},exports.FloatType=1015,exports.Fresnel=class extends D{get type(){return"Fresnel"}constructor(e,t={}){super(e,t),this._state=new et({edgeColor:c.vec3([0,0,0]),centerColor:c.vec3([1,1,1]),edgeBias:0,centerBias:1,power:1}),this.edgeColor=t.edgeColor,this.centerColor=t.centerColor,this.edgeBias=t.edgeBias,this.centerBias=t.centerBias,this.power=t.power}set edgeColor(e){this._state.edgeColor.set(e||[0,0,0]),this.glRedraw()}get edgeColor(){return this._state.edgeColor}set centerColor(e){this._state.centerColor.set(e||[1,1,1]),this.glRedraw()}get centerColor(){return this._state.centerColor}set edgeBias(e){this._state.edgeBias=e||0,this.glRedraw()}get edgeBias(){return this._state.edgeBias}set centerBias(e){this._state.centerBias=null!=e?e:1,this.glRedraw()}get centerBias(){return this._state.centerBias}set power(e){this._state.power=null!=e?e:1,this.glRedraw()}get power(){return this._state.power}destroy(){super.destroy(),this._state.destroy()}},exports.Frustum=U,exports.FrustumPlane=L,exports.GIFMediaType=1e4,exports.GLTFDefaultDataSource=nh,exports.GLTFLoaderPlugin=class extends V{constructor(e,t={}){super("GLTFLoader",e,t),this._sceneModelLoader=new fB(this,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new nh}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||CB}get objectDefaults(){return this._objectDefaults}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new GA(this.viewer.scene,_.apply(e,{isModel:!0,dtxEnabled:e.dtxEnabled})),i=t.id;if(!e.src&&!e.gltf)return this.error("load() param expected: src or gltf"),t;if(e.metaModelSrc||e.metaModelJSON){const s=e.objectDefaults||this._objectDefaults||CB,r=r=>{let o;if(this.viewer.metaScene.createMetaModel(i,r,{includeTypes:e.includeTypes,excludeTypes:e.excludeTypes}),this.viewer.scene.canvas.spinner.processes--,e.includeTypes){o={};for(let t=0,i=e.includeTypes.length;t{const r=t.name;if(!r)return!0;const o=r,n=this.viewer.metaScene.metaObjects[o],a=(n?n.type:"DEFAULT")||"DEFAULT";i.createEntity={id:o,isObject:!0};const l=s[a];return l&&(!1===l.visible&&(i.createEntity.visible=!1),l.colorize&&(i.createEntity.colorize=l.colorize),!1===l.pickable&&(i.createEntity.pickable=!1),void 0!==l.opacity&&null!==l.opacity&&(i.createEntity.opacity=l.opacity)),!0},e.src?this._sceneModelLoader.load(this,e.src,r,e,t):this._sceneModelLoader.parse(this,e.gltf,r,e,t)};if(e.metaModelSrc){const t=e.metaModelSrc;this.viewer.scene.canvas.spinner.processes++,this._dataSource.getMetaModel(t,(e=>{this.viewer.scene.canvas.spinner.processes--,r(e)}),(e=>{this.error(`load(): Failed to load model metadata for model '${i} from '${t}' - ${e}`),this.viewer.scene.canvas.spinner.processes--}))}else e.metaModelJSON&&r(e.metaModelJSON)}else e.handleGLTFNode=(e,t,i)=>{const s=t.name;if(!s)return!0;const r=s;return i.createEntity={id:r,isObject:!0},!0},e.src?this._sceneModelLoader.load(this,e.src,null,e,t):this._sceneModelLoader.parse(this,e.gltf,null,e,t);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}},exports.HalfFloatType=1016,exports.ImagePlane=class extends D{constructor(e,t={}){super(e,t),this._src=null,this._image=null,this._pos=c.vec3(),this._origin=c.vec3(),this._rtcPos=c.vec3(),this._dir=c.vec3(),this._size=1,this._imageSize=c.vec2(),this._texture=new Bs(this),this._plane=new zi(this,{geometry:new Ut(this,Is({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new Vt(this,{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:this._texture,emissiveMap:this._texture,backfaces:!0}),clippable:t.clippable}),this._grid=new zi(this,{geometry:new Ut(this,Es({size:1,divisions:10})),material:new Vt(this,{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:t.clippable}),this._node=new as(this,{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[this._plane,this._grid]}),this._gridVisible=!1,this.visible=!0,this.gridVisible=t.gridVisible,this.position=t.position,this.rotation=t.rotation,this.dir=t.dir,this.size=t.size,this.collidable=t.collidable,this.clippable=t.clippable,this.pickable=t.pickable,this.opacity=t.opacity,t.image?this.image=t.image:this.src=t.src}set visible(e){this._plane.visible=e,this._grid.visible=this._gridVisible&&e}get visible(){return this._plane.visible}set gridVisible(e){e=!1!==e,this._gridVisible=e,this._grid.visible=this._gridVisible&&this.visible}get gridVisible(){return this._gridVisible}set image(e){this._image=e,this._image&&(this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}get image(){return this._image}set src(e){if(this._src=e,this._src){this._image=null;const e=new Image;e.onload=()=>{this._texture.image=e,this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage()},e.src=this._src}}get src(){return this._src}set position(e){this._pos.set(e||[0,0,0]),G(this._pos,this._origin,this._rtcPos),this._node.origin=this._origin,this._node.position=this._rtcPos}get position(){return this._pos}set rotation(e){this._node.rotation=e}get rotation(){return this._node.rotation}set size(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}get size(){return this._size}set dir(e){if(this._dir.set(e||[0,0,-1]),e){const t=this.scene.center,i=[-this._dir[0],-this._dir[1],-this._dir[2]];c.subVec3(t,this.position,bh);const s=-c.dotVec3(i,bh);c.normalizeVec3(i),c.mulVec3Scalar(i,s,yh),c.vec3PairToQuaternion(xh,e,Bh),this._node.quaternion=Bh}}get dir(){return this._dir}set collidable(e){this._node.collidable=!1!==e}get collidable(){return this._node.collidable}set clippable(e){this._node.clippable=!1!==e}get clippable(){return this._node.clippable}set pickable(e){this._node.pickable=!1!==e}get pickable(){return this._node.pickable}set opacity(e){this._node.opacity=e}get opacity(){return this._node.opacity}destroy(){super.destroy()}_updatePlaneSizeFromImage(){const e=this._size,t=this._imageSize[0],i=this._imageSize[1];if(t>i){const s=i/t;this._node.scale=[e,1,e*s]}else{const s=t/i;this._node.scale=[e*s,1,e]}}},exports.IntType=1013,exports.JPEGMediaType=10001,exports.KTX2TextureTranscoder=gA,exports.LASLoaderPlugin=class extends V{constructor(e,t={}){super("lasLoader",e,t),this.dataSource=t.dataSource,this.skip=t.skip,this.fp64=t.fp64,this.colorDepth=t.colorDepth}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new vP}get skip(){return this._skip}set skip(e){this._skip=e||1}get fp64(){return this._fp64}set fp64(e){this._fp64=!!e}get colorDepth(){return this._colorDepth}set colorDepth(e){this._colorDepth=e||"auto"}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new GA(this.viewer.scene,_.apply(e,{isModel:!0}));if(!e.src&&!e.las)return this.error("load() param expected: src or las"),t;const i={las:{skip:this._skip,fp64:this._fp64,colorDepth:this._colorDepth}};if(e.src)this._loadModel(e.src,e,i,t);else{const s=this.viewer.scene.canvas.spinner;s.processes++,this._parseModel(e.las,e,i,t).then((()=>{s.processes--}),(e=>{s.processes--,this.error(e),t.fire("error",e)}))}return t}_loadModel(e,t,i,s){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getLAS(t.src,(e=>{this._parseModel(e,t,i,s).then((()=>{r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){function r(e){const i=e.value;if(t.rotateX&&i)for(let e=0,t=i.length;e{if(s.destroyed)return void l();const A=t.stats||{};A.sourceFormat="LAS",A.schemaVersion="",A.title="",A.author="",A.created="",A.numMetaObjects=0,A.numPropertySets=0,A.numObjects=0,A.numGeometries=0,A.numTriangles=0,A.numVertices=0;try{const A=BP(e);Tb(e,bP,i).then((e=>{const h=e.attributes,u=e.loaderData,d=void 0!==u.pointsFormatId?u.pointsFormatId:-1;if(!h.POSITION)return s.finalize(),void l("No positions found in file");let p,f;switch(d){case 0:p=r(h.POSITION),f=n(h.intensity);break;case 1:if(!h.intensity)return s.finalize(),void l("No positions found in file");p=r(h.POSITION),f=n(h.intensity);break;case 2:case 3:if(!h.intensity)return s.finalize(),void l("No positions found in file");p=r(h.POSITION),f=o(h.COLOR_0,h.intensity)}const g=CP(p,15e5),m=CP(f,2e6),_=[];for(let e=0,t=g.length;e{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))})),a()}))}catch(e){s.finalize(),l(e)}}))}},exports.LambertMaterial=ls,exports.LightMap=class extends Mh{get type(){return"LightMap"}constructor(e,t={}){super(e,t),this.scene._lightMapCreated(this)}destroy(){super.destroy(),this.scene._lightMapDestroyed(this)}},exports.LineSet=WA,exports.LinearEncoding=3e3,exports.LinearFilter=1006,exports.LinearMipMapLinearFilter=1008,exports.LinearMipMapNearestFilter=1007,exports.LinearMipmapLinearFilter=1008,exports.LinearMipmapNearestFilter=1007,exports.Loader=cA,exports.LoadingManager=AA,exports.LocaleService=ah,exports.LuminanceAlphaFormat=1025,exports.LuminanceFormat=1024,exports.Map=e,exports.Marker=ae,exports.MarqueePicker=N,exports.MarqueePickerMouseControl=class extends D{constructor(e){super(e.marqueePicker,e);const t=e.marqueePicker,i=t.viewer.scene.canvas.canvas;let s,r,o,n,a,l,A,h=!1,c=!1,u=!1;i.addEventListener("mousedown",(e=>{this.getActive()&&0===e.button&&(A=setTimeout((function(){const o=t.viewer.scene.input;o.keyDown[o.KEY_CTRL]||t.clear(),s=e.pageX,r=e.pageY,a=e.offsetX,t.setMarqueeCorner1([s,r]),h=!0,t.viewer.cameraControl.pointerEnabled=!1,t.setMarqueeVisible(!0),i.style.cursor="crosshair"}),400),c=!0)})),i.addEventListener("mouseup",(e=>{if(!this.getActive())return;if(!h&&!u)return;if(0!==e.button)return;clearTimeout(A),o=e.pageX,n=e.pageY;const i=Math.abs(o-s),a=Math.abs(n-r);h=!1,t.viewer.cameraControl.pointerEnabled=!0,u&&(u=!1),(i>3||a>3)&&t.pick()})),document.addEventListener("mouseup",(e=>{this.getActive()&&0===e.button&&(clearTimeout(A),h&&(t.setMarqueeVisible(!1),h=!1,c=!1,u=!0,t.viewer.cameraControl.pointerEnabled=!0))}),!0),i.addEventListener("mousemove",(e=>{this.getActive()&&0===e.button&&c&&(clearTimeout(A),h&&(o=e.pageX,n=e.pageY,l=e.offsetX,t.setMarqueeVisible(!0),t.setMarqueeCorner2([o,n]),t.setPickMode(a{e.camera.zUp?(this._zUp=!0,this._cubeTextureCanvas.setZUp(),this._repaint(),this._synchCamera()):e.camera.yUp&&(this._zUp=!1,this._cubeTextureCanvas.setYUp(),this._repaint(),this._synchCamera())})),this._onCameraFOV=e.camera.perspective.on("fov",(e=>{this._synchProjection&&(this._navCubeCamera.perspective.fov=e)})),this._onCameraProjection=e.camera.on("projection",(e=>{this._synchProjection&&(this._navCubeCamera.projection="ortho"===e||"perspective"===e?e:"perspective")}));var o=-1;function n(e){var t=[0,0];if(e){for(var i=e.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t}var a,l,A=null,h=null,u=!1,d=!1,p=.5;s._navCubeCanvas.addEventListener("mouseenter",s._onMouseEnter=function(e){d=!0}),s._navCubeCanvas.addEventListener("mouseleave",s._onMouseLeave=function(e){d=!1}),s._navCubeCanvas.addEventListener("mousedown",s._onMouseDown=function(e){if(1===e.which){A=e.x,h=e.y,a=e.clientX,l=e.clientY;var t=n(e),s=i.pick({canvasPos:t});u=!!s}}),document.addEventListener("mouseup",s._onMouseUp=function(e){if(1===e.which&&(u=!1,null!==A)){var t=n(e),a=i.pick({canvasPos:t,pickSurface:!0});if(a&&a.uv){var l=s._cubeTextureCanvas.getArea(a.uv);if(l>=0&&(document.body.style.cursor="pointer",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),l>=0)){if(s._cubeTextureCanvas.setAreaHighlighted(l,!0),o=l,s._repaint(),e.xA+3||e.yh+3)return;var c=s._cubeTextureCanvas.getAreaDir(l);if(c){var d=s._cubeTextureCanvas.getAreaUp(l);s._isProjectNorth&&s._projectNorthOffsetAngle&&(c=r(1,c,FB),d=r(1,d,EB)),f(c,d,(function(){o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),document.body.style.cursor="pointer",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),l>=0&&(s._cubeTextureCanvas.setAreaHighlighted(l,!1),o=-1,s._repaint())}))}}}}}),document.addEventListener("mousemove",s._onMouseMove=function(t){if(o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),1!==t.buttons||u){if(u){var r=t.clientX,A=t.clientY;return document.body.style.cursor="move",void function(t,i){var s=(t-a)*-p,r=(i-l)*-p;e.camera.orbitYaw(s),e.camera.orbitPitch(-r),a=t,l=i}(r,A)}if(d){var h=n(t),c=i.pick({canvasPos:h,pickSurface:!0});if(c){if(c.uv){document.body.style.cursor="pointer";var f=s._cubeTextureCanvas.getArea(c.uv);if(f===o)return;o>=0&&s._cubeTextureCanvas.setAreaHighlighted(o,!1),f>=0&&(s._cubeTextureCanvas.setAreaHighlighted(f,!0),s._repaint(),o=f)}}else document.body.style.cursor="default",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1)}}});var f=function(){var t=c.vec3();return function(i,r,o){var n=s._fitVisible?e.scene.getAABB(e.scene.visibleObjectIds):e.scene.aabb,a=c.getAABB3Diag(n);c.getAABB3Center(n,t);var l=Math.abs(a/Math.tan(s._cameraFitFOV*c.DEGTORAD));e.cameraControl.pivotPos=t,s._cameraFly?e.cameraFlight.flyTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:r||[0,1,0],orthoScale:1.1*a,fitFOV:s._cameraFitFOV,duration:s._cameraFlyDuration},o):e.cameraFlight.jumpTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:r||[0,1,0],orthoScale:1.1*a,fitFOV:s._cameraFitFOV},o)}}();this._onUpdated=e.localeService.on("updated",(()=>{this._cubeTextureCanvas.clear(),this._repaint()})),this.setVisible(t.visible),this.setCameraFitFOV(t.cameraFitFOV),this.setCameraFly(t.cameraFly),this.setCameraFlyDuration(t.cameraFlyDuration),this.setFitVisible(t.fitVisible),this.setSynchProjection(t.synchProjection)}send(e,t){if("language"===e)this._cubeTextureCanvas.clear(),this._repaint()}_repaint(){const e=this._cubeTextureCanvas.getImage();this._cubeMesh.material.diffuseMap.image=e,this._cubeMesh.material.emissiveMap.image=e}setVisible(e=!0){this._navCubeCanvas&&(this._cubeMesh.visible=e,this._shadow&&(this._shadow.visible=e),this._navCubeCanvas.style.visibility=e?"visible":"hidden")}getVisible(){return!!this._navCubeCanvas&&this._cubeMesh.visible}setFitVisible(e=!1){this._fitVisible=e}getFitVisible(){return this._fitVisible}setCameraFly(e=!0){this._cameraFly=e}getCameraFly(){return this._cameraFly}setCameraFitFOV(e=45){this._cameraFitFOV=e}getCameraFitFOV(){return this._cameraFitFOV}setCameraFlyDuration(e=.5){this._cameraFlyDuration=e}getCameraFlyDuration(){return this._cameraFlyDuration}setSynchProjection(e=!1){this._synchProjection=e}getSynchProjection(){return this._synchProjection}setIsProjectNorth(e=!1){this._isProjectNorth=e}getIsProjectNorth(){return this._isProjectNorth}setProjectNorthOffsetAngle(e){this._projectNorthOffsetAngle=e}getProjectNorthOffsetAngle(){return this._projectNorthOffsetAngle}destroy(){this._navCubeCanvas&&(this.viewer.localeService.off(this._onUpdated),this.viewer.camera.off(this._onCameraMatrix),this.viewer.camera.off(this._onCameraWorldAxis),this.viewer.camera.perspective.off(this._onCameraFOV),this.viewer.camera.off(this._onCameraProjection),this._navCubeCanvas.removeEventListener("mouseenter",this._onMouseEnter),this._navCubeCanvas.removeEventListener("mouseleave",this._onMouseLeave),this._navCubeCanvas.removeEventListener("mousedown",this._onMouseDown),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._navCubeCanvas=null,this._cubeTextureCanvas.destroy(),this._cubeTextureCanvas=null,this._onMouseEnter=null,this._onMouseLeave=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null),this._navCubeScene.destroy(),this._navCubeScene=null,this._cubeMesh=null,this._shadow=null,super.destroy()}},exports.NearestFilter=1003,exports.NearestMipMapLinearFilter=1005,exports.NearestMipMapNearestFilter=1004,exports.NearestMipmapLinearFilter=1005,exports.NearestMipmapNearestFilter=1004,exports.Node=as,exports.OBJLoaderPlugin=class extends V{constructor(e,t){super("OBJLoader",e,t),this._sceneGraphLoader=new DB}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new as(this.viewer.scene,_.apply(e,{isModel:!0}));const i=t.id,s=e.src;if(!s)return this.error("load() param expected: src"),t;if(e.metaModelSrc){const r=e.metaModelSrc;_.loadJSON(r,(r=>{this.viewer.metaScene.createMetaModel(i,r),this._sceneGraphLoader.load(t,s,e)}),(e=>{this.error(`load(): Failed to load model modelMetadata for model '${i} from '${r}' - ${e}`)}))}else this._sceneGraphLoader.load(t,s,e);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}},exports.ObjectsKdTree3=class{constructor(e){if(!e)throw"Parameter expected: cfg";if(!e.viewer)throw"Parameter expected: cfg.viewer";this.viewer=e.viewer,this._maxTreeDepth=e.maxTreeDepth||15,this._root=null,this._needsRebuild=!0,this._onModelLoaded=this.viewer.scene.on("modelLoaded",(e=>{this._needsRebuild=!0})),this._onModelUnloaded=this.viewer.scene.on("modelUnloaded",(e=>{this._needsRebuild=!0}))}get root(){return this._needsRebuild&&this._rebuild(),this._root}_rebuild(){const e=this.viewer.scene;this._root={aabb:e.getAABB()};for(let t in e.objects){const i=e.objects[t];this._insertEntity(this._root,i,1)}this._needsRebuild=!1}_insertEntity(e,t,i){const s=t.aabb;if(i>=this._maxTreeDepth)return e.entities=e.entities||[],void e.entities.push(t);if(e.left&&c.containsAABB3(e.left.aabb,s))return void this._insertEntity(e.left,t,i+1);if(e.right&&c.containsAABB3(e.right.aabb,s))return void this._insertEntity(e.right,t,i+1);const r=e.aabb;u[0]=r[3]-r[0],u[1]=r[4]-r[1],u[2]=r[5]-r[2];let o=0;if(u[1]>u[o]&&(o=1),u[2]>u[o]&&(o=2),!e.left){const n=r.slice();if(n[o+3]=(r[o]+r[o+3])/2,e.left={aabb:n},c.containsAABB3(n,s))return void this._insertEntity(e.left,t,i+1)}if(!e.right){const n=r.slice();if(n[o]=(r[o]+r[o+3])/2,e.right={aabb:n},c.containsAABB3(n,s))return void this._insertEntity(e.right,t,i+1)}e.entities=e.entities||[],e.entities.push(t)}destroy(){const e=this.viewer.scene;e.off(this._onModelLoaded),e.off(this._onModelUnloaded),this._root=null,this._needsRebuild=!0}},exports.ObjectsMemento=Dh,exports.PNGMediaType=10002,exports.Path=class extends hh{constructor(e,t={}){super(e,t),this._cachedLengths=[],this._dirty=!0,this._curves=[],this._t=0,this._dirtySubs=[],this._destroyedSubs=[],this.curves=t.curves||[],this.t=t.t}addCurve(e){this._curves.push(e),this._dirty=!0}set curves(e){var t,i,s;for(e=e||[],i=0,s=this._curves.length;i1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}get length(){var e=this._getCurveLengths();return e[e.length-1]}getPoint(e){for(var t,i=e*this.length,s=this._getCurveLengths(),r=0;r=i){var o=1-(s[r]-i)/(t=this._curves[r]).length;return t.getPointAt(o)}r++}return null}_getCurveLengths(){if(!this._dirty)return this._cachedLengths;var e,t=[],i=0,s=this._curves.length;for(e=0;e{this._shadowViewMatrixDirty=!0})),this._onCameraProjMatrix=s.on("projMatrix",(()=>{this._shadowProjMatrixDirty=!0})),this._onCanvasBoundary=r.on("boundary",(()=>{this._shadowProjMatrixDirty=!0})),this._state=new et({type:"point",pos:c.vec3([1,1,1]),color:c.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:t.space||"view",castsShadow:!1,getShadowViewMatrix:()=>{if(i._shadowViewMatrixDirty){i._shadowViewMatrix||(i._shadowViewMatrix=c.identityMat4());const e=i._state.pos,t=s.look,r=s.up;c.lookAtMat4v(e,t,r,i._shadowViewMatrix),i._shadowViewMatrixDirty=!1}return i._shadowViewMatrix},getShadowProjMatrix:()=>{if(i._shadowProjMatrixDirty){i._shadowProjMatrix||(i._shadowProjMatrix=c.identityMat4());const e=i.scene.canvas.canvas;c.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,i._shadowProjMatrix),i._shadowProjMatrixDirty=!1}return i._shadowProjMatrix},getShadowRenderBuf:()=>(i._shadowRenderBuf||(i._shadowRenderBuf=new Xe(i.scene.canvas.canvas,i.scene.canvas.gl,{size:[1024,1024]})),i._shadowRenderBuf)}),this.pos=t.pos,this.color=t.color,this.intensity=t.intensity,this.constantAttenuation=t.constantAttenuation,this.linearAttenuation=t.linearAttenuation,this.quadraticAttenuation=t.quadraticAttenuation,this.castsShadow=t.castsShadow,this.scene._lightCreated(this)}set pos(e){this._state.pos.set(e||[1,1,1]),this._shadowViewMatrixDirty=!0,this.glRedraw()}get pos(){return this._state.pos}set color(e){this._state.color.set(e||[.7,.7,.8]),this.glRedraw()}get color(){return this._state.color}set intensity(e){e=void 0!==e?e:1,this._state.intensity=e,this.glRedraw()}get intensity(){return this._state.intensity}set constantAttenuation(e){this._state.attenuation[0]=e||0,this.glRedraw()}get constantAttenuation(){return this._state.attenuation[0]}set linearAttenuation(e){this._state.attenuation[1]=e||0,this.glRedraw()}get linearAttenuation(){return this._state.attenuation[1]}set quadraticAttenuation(e){this._state.attenuation[2]=e||0,this.glRedraw()}get quadraticAttenuation(){return this._state.attenuation[2]}set castsShadow(e){e=!!e,this._state.castsShadow!==e&&(this._state.castsShadow=e,this._shadowViewMatrixDirty=!0,this.glRedraw())}get castsShadow(){return this._state.castsShadow}destroy(){const e=this.scene.camera,t=this.scene.canvas;e.off(this._onCameraViewMatrix),e.off(this._onCameraProjMatrix),t.off(this._onCanvasBoundary),super.destroy(),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}},exports.PointerCircle=Q,exports.PointerLens=class{constructor(e,t={}){this.viewer=e,this.scene=this.viewer.scene,this._lensCursorDiv=document.createElement("div"),this.viewer.scene.canvas.canvas.parentNode.insertBefore(this._lensCursorDiv,this.viewer.scene.canvas.canvas),this._lensCursorDiv.style.background="pink",this._lensCursorDiv.style.border="2px solid red",this._lensCursorDiv.style.borderRadius="20px",this._lensCursorDiv.style.width="10px",this._lensCursorDiv.style.height="10px",this._lensCursorDiv.style.margin="-200px -200px",this._lensCursorDiv.style.zIndex="100000",this._lensCursorDiv.style.position="absolute",this._lensCursorDiv.style.pointerEvents="none",this._lensContainer=document.createElement("div"),this._lensContainer.style.border="1px solid black",this._lensContainer.style.background="white",this._lensContainer.style.borderRadius="50%",this._lensContainer.style.width="300px",this._lensContainer.style.height="300px",this._lensContainer.style.marginTop="85px",this._lensContainer.style.marginLeft="25px",this._lensContainer.style.zIndex="15000",this._lensContainer.style.position="absolute",this._lensContainer.style.pointerEvents="none",this._lensContainer.style.visibility="hidden",this._lensCanvas=document.createElement("canvas"),this._lensCanvas.style.borderRadius="50%",this._lensCanvas.style.width="300px",this._lensCanvas.style.height="300px",this._lensCanvas.style.zIndex="15000",this._lensCanvas.style.pointerEvents="none",document.body.appendChild(this._lensContainer),this._lensContainer.appendChild(this._lensCanvas),this._lensCanvasContext=this._lensCanvas.getContext("2d"),this._canvasElement=this.viewer.scene.canvas.canvas,this._canvasPos=null,this._snappedCanvasPos=null,this._lensPosToggle=!0,this._zoomLevel=t.zoomLevel||2,this._active=!1!==t.active,this._visible=!1,this._snapped=!1,this._onViewerRendering=this.viewer.scene.on("rendering",(()=>{this._active&&this._visible&&this.update()}))}update(){if(!this._active||!this._visible)return;if(!this._canvasPos)return;const e=this._lensContainer.getBoundingClientRect(),t=this._canvasElement.getBoundingClientRect(),i=this._canvasPos[0]e.left&&this._canvasPos[1]e.top;this._lensContainer.style.marginLeft="25px",i&&(this._lensPosToggle?this._lensContainer.style.marginTop=t.bottom-t.top-this._lensCanvas.height-85+"px":this._lensContainer.style.marginTop="85px",this._lensPosToggle=!this._lensPosToggle),this._lensCanvasContext.clearRect(0,0,this._lensCanvas.width,this._lensCanvas.height);const s=Math.max(this._lensCanvas.width,this._lensCanvas.height)/this._zoomLevel;this._lensCanvasContext.drawImage(this._canvasElement,this._canvasPos[0]-s/2,this._canvasPos[1]-s/2,s,s,0,0,this._lensCanvas.width,this._lensCanvas.height);const r=[(e.left+e.right)/2,(e.top+e.bottom)/2];if(this._snappedCanvasPos){const e=this._snappedCanvasPos[0]-this._canvasPos[0],t=this._snappedCanvasPos[1]-this._canvasPos[1];this._lensCursorDiv.style.marginLeft=r[0]+e*this._zoomLevel-10+"px",this._lensCursorDiv.style.marginTop=r[1]+t*this._zoomLevel-10+"px"}else this._lensCursorDiv.style.marginLeft=r[0]-10+"px",this._lensCursorDiv.style.marginTop=r[1]-10+"px"}set zoomFactor(e){this._zoomFactor=e,this.update()}get zoomFactor(){return this._zoomFactor}set canvasPos(e){this._canvasPos=e,this.update()}get canvasPos(){return this._canvasPos}set snappedCanvasPos(e){this._snappedCanvasPos=e,this.update()}get snappedCanvasPos(){return this._snappedCanvasPos}set snapped(e){this._snapped=e,e?(this._lensCursorDiv.style.background="greenyellow",this._lensCursorDiv.style.border="2px solid green"):(this._lensCursorDiv.style.background="pink",this._lensCursorDiv.style.border="2px solid red")}get snapped(){return this._snapped}set active(e){this._active=e,this._lensContainer.style.visibility=e&&this._visible?"visible":"hidden",e&&this._visible||(this._lensCursorDiv.style.marginLeft="-100px",this._lensCursorDiv.style.marginTop="-100px"),this.update()}get active(){return this._active}set visible(e){this._visible=e,this._lensContainer.style.visibility=e&&this._active?"visible":"hidden",e&&this._active||(this._lensCursorDiv.style.marginLeft="-100px",this._lensCursorDiv.style.marginTop="-100px"),this.update()}get visible(){return this._visible}destroy(){this._destroyed||(this.viewer.scene.off(this._onViewerRendering),this._lensContainer.removeChild(this._lensCanvas),document.body.removeChild(this._lensContainer),this._destroyed=!0)}},exports.QuadraticBezierCurve=class extends hh{constructor(e,t={}){super(e,t),this.v0=t.v0,this.v1=t.v1,this.v2=t.v2,this.t=t.t}set v0(e){this._v0=e||c.vec3([0,0,0])}get v0(){return this._v0}set v1(e){this._v1=e||c.vec3([0,0,0])}get v1(){return this._v1}set v2(e){this._v2=e||c.vec3([0,0,0])}get v2(){return this._v2}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=c.vec3();return t[0]=c.b2(e,this._v0[0],this._v1[0],this._v2[0]),t[1]=c.b2(e,this._v0[1],this._v1[1],this._v2[1]),t[2]=c.b2(e,this._v0[2],this._v1[2],this._v2[2]),t}getJSON(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}},exports.Queue=d,exports.RGBAFormat=1023,exports.RGBAIntegerFormat=1033,exports.RGBA_ASTC_10x10_Format=37819,exports.RGBA_ASTC_10x5_Format=37816,exports.RGBA_ASTC_10x6_Format=37817,exports.RGBA_ASTC_10x8_Format=37818,exports.RGBA_ASTC_12x10_Format=37820,exports.RGBA_ASTC_12x12_Format=37821,exports.RGBA_ASTC_4x4_Format=37808,exports.RGBA_ASTC_5x4_Format=37809,exports.RGBA_ASTC_5x5_Format=37810,exports.RGBA_ASTC_6x5_Format=37811,exports.RGBA_ASTC_6x6_Format=37812,exports.RGBA_ASTC_8x5_Format=37813,exports.RGBA_ASTC_8x6_Format=37814,exports.RGBA_ASTC_8x8_Format=37815,exports.RGBA_BPTC_Format=36492,exports.RGBA_ETC2_EAC_Format=37496,exports.RGBA_PVRTC_2BPPV1_Format=35843,exports.RGBA_PVRTC_4BPPV1_Format=35842,exports.RGBA_S3TC_DXT1_Format=33777,exports.RGBA_S3TC_DXT3_Format=33778,exports.RGBA_S3TC_DXT5_Format=33779,exports.RGBFormat=1022,exports.RGB_ETC1_Format=36196,exports.RGB_ETC2_Format=37492,exports.RGB_PVRTC_2BPPV1_Format=35841,exports.RGB_PVRTC_4BPPV1_Format=35840,exports.RGB_S3TC_DXT1_Format=33776,exports.RGFormat=1030,exports.RGIntegerFormat=1031,exports.ReadableGeometry=Ut,exports.RedFormat=1028,exports.RedIntegerFormat=1029,exports.ReflectionMap=class extends Mh{get type(){return"ReflectionMap"}constructor(e,t={}){super(e,t),this.scene._lightsState.addReflectionMap(this._state),this.scene._reflectionMapCreated(this)}destroy(){super.destroy(),this.scene._reflectionMapDestroyed(this)}},exports.RepeatWrapping=1e3,exports.STLDefaultDataSource=iw,exports.STLLoaderPlugin=class extends V{constructor(e,t={}){super("STLLoader",e,t),this._sceneGraphLoader=new rw,this.dataSource=t.dataSource}set dataSource(e){this._dataSource=e||new iw}get dataSource(){return this._dataSource}load(e){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new as(this.viewer.scene,_.apply(e,{isModel:!0})),i=e.src,s=e.stl;return i||s?(i?this._sceneGraphLoader.load(this,t,i,e):this._sceneGraphLoader.parse(this,t,s,e),t):(this.error("load() param expected: either 'src' or 'stl'"),t)}},exports.SceneModel=GA,exports.SceneModelMesh=ks,exports.SceneModelTransform=LA,exports.SectionPlane=Zi,exports.SectionPlanesPlugin=class extends V{constructor(e,t={}){if(super("SectionPlanes",e),this._freeControls=[],this._sectionPlanes=e.scene.sectionPlanes,this._controls={},this._shownControlId=null,null!==t.overviewCanvasId&&void 0!==t.overviewCanvasId){const e=document.getElementById(t.overviewCanvasId);e?this._overview=new HB(this,{overviewCanvas:e,visible:t.overviewVisible,onHoverEnterPlane:e=>{this._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:e=>{this._overview.setPlaneHighlighted(e,!1)},onClickedPlane:e=>{if(this.getShownControl()===e)return void this.hideControl();this.showControl(e);const t=this.sectionPlanes[e].pos;jB.set(this.viewer.scene.aabb),c.getAABB3Center(jB,GB),jB[0]+=t[0]-GB[0],jB[1]+=t[1]-GB[1],jB[2]+=t[2]-GB[2],jB[3]+=t[0]-GB[0],jB[4]+=t[1]-GB[1],jB[5]+=t[2]-GB[2],this.viewer.cameraFlight.flyTo({aabb:jB,fitFOV:65})},onClickedNothing:()=>{this.hideControl()}}):this.warn("Can't find overview canvas: '"+t.overviewCanvasId+"' - will create plugin without overview")}this._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(e=>{this._sectionPlaneCreated(e)}))}setOverviewVisible(e){this._overview&&this._overview.setVisible(e)}getOverviewVisible(){if(this._overview)return this._overview.getVisible()}get sectionPlanes(){return this._sectionPlanes}createSectionPlane(e={}){void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);return new Zi(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0})}_sectionPlaneCreated(e){const t=this._freeControls.length>0?this._freeControls.pop():new QB(this);t._setSectionPlane(e),t.setVisible(!1),this._controls[e.id]=t,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(()=>{this._sectionPlaneDestroyed(e)}))}flipSectionPlanes(){const e=this.viewer.scene.sectionPlanes;for(let t in e){e[t].flipDir()}}showControl(e){const t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}getShownControl(){return this._shownControlId}hideControl(){for(var e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}destroySectionPlane(e){var t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}_sectionPlaneDestroyed(e){this._overview&&this._overview.removeSectionPlane(e);const t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}clear(){const e=Object.keys(this._sectionPlanes);for(var t=0,i=e.length;t{this._texture.image=e,this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage()},e.src=this._src}}get src(){return this._src}set size(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}get size(){return this._size}set collidable(e){this._mesh.collidable=!1!==e}get collidable(){return this._mesh.collidable}set clippable(e){this._mesh.clippable=!1!==e}get clippable(){return this._mesh.clippable}set pickable(e){this._mesh.pickable=!1!==e}get pickable(){return this._mesh.pickable}set opacity(e){this._mesh.opacity=e}get opacity(){return this._mesh.opacity}_updatePlaneSizeFromImage(){const e=.5*this._size,t=this._imageSize[0],i=this._imageSize[1],s=i/t;this._geometry.positions=t>i?[e,e*s,0,-e,e*s,0,-e,-e*s,0,e,-e*s,0]:[e/s,e,0,-e/s,e,0,-e/s,-e,0,e/s,-e,0]}},exports.StoreyViewsPlugin=class extends V{constructor(e,t={}){super("StoreyViews",e),this._objectsMemento=new Dh,this._cameraMemento=new Fh,this.storeys={},this.modelStoreys={},this._fitStoreyMaps=!!t.fitStoreyMaps,this._onModelLoaded=this.viewer.scene.on("modelLoaded",(e=>{this._registerModelStoreys(e),this.fire("storeys",this.storeys)}))}_registerModelStoreys(e){const t=this.viewer,i=t.scene,s=t.metaScene,r=s.metaModels[e],o=i.models[e];if(!r||!r.rootMetaObjects)return;const n=r.rootMetaObjects;for(let t=0,r=n.length;t.5?a.length:0,h=new zB(this,o.aabb,l,e,n,A);h._onModelDestroyed=o.once("destroyed",(()=>{this._deregisterModelStoreys(e),this.fire("storeys",this.storeys)})),this.storeys[n]=h,this.modelStoreys[e]||(this.modelStoreys[e]={}),this.modelStoreys[e][n]=h}}}_deregisterModelStoreys(e){const t=this.modelStoreys[e];if(t){const i=this.viewer.scene;for(let e in t)if(t.hasOwnProperty(e)){const s=t[e],r=i.models[s.modelId];r&&r.off(s._onModelDestroyed),delete this.storeys[e]}delete this.modelStoreys[e]}}get fitStoreyMaps(){return this._fitStoreyMaps}gotoStoreyCamera(e,t={}){const i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),void(t.done&&t.done());const s=this.viewer,r=s.scene.camera,o=i.storeyAABB;if(o[3]{t.done()})):(s.cameraFlight.jumpTo(_.apply(t,{eye:h,look:n,up:u,orthoScale:A})),s.camera.ortho.scale=A)}showStoreyObjects(e,t={}){if(!this.storeys[e])return void this.error("IfcBuildingStorey not found with this ID: "+e);const i=this.viewer,s=i.scene;i.metaScene.metaObjects[e]&&(t.hideOthers&&s.setObjectsVisible(i.scene.visibleObjectIds,!1),this.withStoreyObjects(e,((e,t)=>{e&&(e.visible=!0)})))}withStoreyObjects(e,t){const i=this.viewer,s=i.scene,r=i.metaScene,o=r.metaObjects[e];if(!o)return;const n=o.getObjectIDsInSubtree();for(var a=0,l=n.length;au[1]&&u[0]>u[2],p=!d&&u[1]>u[0]&&u[1]>u[2];!d&&!p&&u[2]>u[0]&&(u[2],u[1]);const f=e.width/A,g=p?e.height/c:e.height/h;return i[0]=Math.floor(e.width-(t[0]-n)*f),i[1]=Math.floor(e.height-(t[2]-l)*g),i[0]>=0&&i[0]=0&&i[1]<=e.height}worldDirToStoreyMap(e,t,i){const s=this.viewer.camera,r=s.eye,o=s.look,n=c.subVec3(o,r,KB),a=s.worldUp,l=a[0]>a[1]&&a[0]>a[2],A=!l&&a[1]>a[0]&&a[1]>a[2];!l&&!A&&a[2]>a[0]&&(a[2],a[1]),l?(i[0]=n[1],i[1]=n[2]):A?(i[0]=n[0],i[1]=n[2]):(i[0]=n[0],i[1]=n[1]),c.normalizeVec2(i)}destroy(){this.viewer.scene.off(this._onModelLoaded),super.destroy()}},exports.Texture=Bs,exports.TextureTranscoder=class{transcode(e,t,i={}){}destroy(){}},exports.TreeViewPlugin=class extends V{constructor(e,t={}){super("TreeViewPlugin",e),this.errors=[],this.valid=!0;const i=t.containerElement||document.getElementById(t.containerElementId);if(i instanceof HTMLElement){for(let e=0;;e++)if(!uw[e]){uw[e]=this,this._index=e,this._id=`tree-${e}`;break}if(this._containerElement=i,this._metaModels={},this._autoAddModels=!1!==t.autoAddModels,this._autoExpandDepth=t.autoExpandDepth||0,this._sortNodes=!1!==t.sortNodes,this._viewer=e,this._rootElement=null,this._muteSceneEvents=!1,this._muteTreeEvents=!1,this._rootNodes=[],this._objectNodes={},this._nodeNodes={},this._rootNames={},this._sortNodes=t.sortNodes,this._pruneEmptyNodes=t.pruneEmptyNodes,this._showListItemElementId=null,this._renderService=t.renderService||new cw,!this._renderService)throw new Error("TreeViewPlugin: no render service set");if(this._containerElement.oncontextmenu=e=>{e.preventDefault()},this._onObjectVisibility=this._viewer.scene.on("objectVisibility",(e=>{if(this._muteSceneEvents)return;const t=e.id,i=this._objectNodes[t];if(!i)return;const s=e.visible;if(!(s!==i.checked))return;this._muteTreeEvents=!0,i.checked=s,s?i.numVisibleEntities++:i.numVisibleEntities--,this._renderService.setCheckbox(i.nodeId,s);let r=i.parent;for(;r;)r.checked=s,s?r.numVisibleEntities++:r.numVisibleEntities--,this._renderService.setCheckbox(r.nodeId,r.numVisibleEntities>0),r=r.parent;this._muteTreeEvents=!1})),this._onObjectXrayed=this._viewer.scene.on("objectXRayed",(e=>{if(this._muteSceneEvents)return;const t=e.id,i=this._objectNodes[t];if(!i)return;this._muteTreeEvents=!0;const s=e.xrayed;s!==i.xrayed&&(i.xrayed=s,this._renderService.setXRayed(i.nodeId,s),this._muteTreeEvents=!1)})),this._switchExpandHandler=e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this._expandSwitchElement(t)},this._switchCollapseHandler=e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this._collapseSwitchElement(t)},this._checkboxChangeHandler=e=>{if(this._muteTreeEvents)return;this._muteSceneEvents=!0;const t=e.target,i=this._renderService.isChecked(t),s=this._renderService.getIdFromCheckbox(t),r=this._nodeNodes[s],o=this._viewer.scene.objects;let n=0;this._withNodeTree(r,(e=>{const t=e.objectId,s=o[t],r=0===e.children.length;e.numVisibleEntities=i?e.numEntities:0,r&&i!==e.checked&&n++,e.checked=i,this._renderService.setCheckbox(e.nodeId,i),s&&(s.visible=i)}));let a=r.parent;for(;a;)a.checked=i,i?a.numVisibleEntities+=n:a.numVisibleEntities-=n,this._renderService.setCheckbox(a.nodeId,a.numVisibleEntities>0),a=a.parent;this._muteSceneEvents=!1},this._hierarchy=t.hierarchy||"containment",this._autoExpandDepth=t.autoExpandDepth||0,this._autoAddModels){const e=Object.keys(this.viewer.metaScene.metaModels);for(let t=0,i=e.length;t{this.viewer.metaScene.metaModels[e]&&this.addModel(e)}))}this.hierarchy=t.hierarchy}else this.error("Mandatory config expected: valid containerElementId or containerElement")}set hierarchy(e){"containment"!==(e=e||"containment")&&"storeys"!==e&&"types"!==e&&(this.error("Unsupported value for `hierarchy' - defaulting to 'containment'"),e="containment"),this._hierarchy!==e&&(this._hierarchy=e,this._createNodes())}get hierarchy(){return this._hierarchy}addModel(e,t={}){if(!this._containerElement)return;const i=this.viewer.scene.models[e];if(!i)throw"Model not found: "+e;const s=this.viewer.metaScene.metaModels[e];s?this._metaModels[e]?this.warn("Model already added: "+e):(this._metaModels[e]=s,t&&t.rootName&&(this._rootNames[e]=t.rootName),i.on("destroyed",(()=>{this.removeModel(i.id)})),this._createNodes()):this.error("MetaModel not found: "+e)}removeModel(e){if(!this._containerElement)return;this._metaModels[e]&&(this._rootNames[e]&&delete this._rootNames[e],delete this._metaModels[e],this._createNodes())}showNode(e){this.unShowNode();const t=this._objectNodes[e];if(!t)return;const i=t.nodeId,s=this._renderService.getSwitchElement(i);if(s)return this._expandSwitchElement(s),s.scrollIntoView(),!0;const r=[];r.unshift(t);let o=t.parent;for(;o;)r.unshift(o),o=o.parent;for(let e=0,t=r.length;e{if(s===e)return;const r=this._renderService.getSwitchElement(i.nodeId);if(r){this._expandSwitchElement(r);const e=i.children;for(var o=0,n=e.length;o0;return this.valid}_validateMetaModelForStoreysHierarchy(e=0,t,i){return!0}_createEnabledNodes(){switch(this._pruneEmptyNodes&&this._findEmptyNodes(),this._hierarchy){case"storeys":this._createStoreysNodes(),0===this._rootNodes.length&&this.error("Failed to build storeys hierarchy");break;case"types":this._createTypesNodes();break;default:this._createContainmentNodes()}this._sortNodes&&this._doSortNodes(),this._synchNodesToEntities(),this._createTrees(),this.expandToDepth(this._autoExpandDepth)}_createDisabledNodes(){const e=this._renderService.createRootNode();this._rootElement=e,this._containerElement.appendChild(e);const t=this._viewer.metaScene.rootMetaObjects;for(let i in t){const s=t[i],r=s.type,o=s.name,n=o&&""!==o&&"Undefined"!==o&&"Default"!==o?o:r,a=this._renderService.createDisabledNodeElement(n);e.appendChild(a)}}_findEmptyNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._findEmptyNodes2(e[t])}_findEmptyNodes2(e,t=0){const i=this.viewer.scene,s=e.children,r=e.id,o=i.objects[r];if(e._countEntities=0,o&&e._countEntities++,s)for(let t=0,i=s.length;t{e.aabb&&r.aabb||(e.aabb||(e.aabb=t.getAABB(s.getObjectIDsInSubtree(e.objectId))),r.aabb||(r.aabb=t.getAABB(s.getObjectIDsInSubtree(r.objectId))));let o=0;return o=i.xUp?0:i.yUp?1:2,e.aabb[o]>r.aabb[o]?-1:e.aabb[o]s?1:0}_synchNodesToEntities(){const e=Object.keys(this.viewer.metaScene.metaObjects),t=this._viewer.metaScene.metaObjects,i=this._viewer.scene.objects;for(let s=0,r=e.length;sthis._createNodeElement(e))),t=this._renderService.createRootNode();e.forEach((e=>{t.appendChild(e)})),this._containerElement.appendChild(t),this._rootElement=t}_createNodeElement(e){return this._renderService.createNodeElement(e,this._switchExpandHandler,this._checkboxChangeHandler,(t=>{this.fire("contextmenu",{event:t,viewer:this._viewer,treeViewPlugin:this,treeViewNode:e}),t.preventDefault()}),(t=>{this.fire("nodeTitleClicked",{event:t,viewer:this._viewer,treeViewPlugin:this,treeViewNode:e}),t.preventDefault()}))}_expandSwitchElement(e){if(this._renderService.isExpanded(e))return;const t=this._renderService.getId(e),i=this._nodeNodes[t].children.map((e=>this._createNodeElement(e)));this._renderService.addChildren(e,i),this._renderService.expand(e,this._switchExpandHandler,this._switchCollapseHandler)}_collapseNode(e){const t=this._renderService.getSwitchElement(e);this._collapseSwitchElement(t)}_collapseSwitchElement(e){this._renderService.collapse(e,this._switchExpandHandler,this._switchCollapseHandler)}},exports.UnsignedByteType=1009,exports.UnsignedInt248Type=1020,exports.UnsignedIntType=1014,exports.UnsignedShort4444Type=1017,exports.UnsignedShort5551Type=1018,exports.UnsignedShortType=1012,exports.VBOGeometry=Cs,exports.ViewCullPlugin=class extends V{constructor(e,t={}){super("ViewCull",e),this._objectCullStates=function(e){const t=e.id;let i=pw[t];return i||(i=new dw(e),pw[t]=i,e.on("destroyed",(()=>{delete pw[t],i._destroy()}))),i}(e.scene),this._maxTreeDepth=t.maxTreeDepth||8,this._modelInfos={},this._frustum=new U,this._kdRoot=null,this._frustumDirty=!1,this._kdTreeDirty=!1,this._onViewMatrix=e.scene.camera.on("viewMatrix",(()=>{this._frustumDirty=!0})),this._onProjMatrix=e.scene.camera.on("projMatMatrix",(()=>{this._frustumDirty=!0})),this._onModelLoaded=e.scene.on("modelLoaded",(e=>{const t=this.viewer.scene.models[e];t&&this._addModel(t)})),this._onSceneTick=e.scene.on("tick",(()=>{this._doCull()}))}set enabled(e){this._enabled=e}get enabled(){return this._enabled}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._kdTreeDirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._kdTreeDirty=!0)}_doCull(){const e=this._frustumDirty||this._kdTreeDirty;if(this._frustumDirty&&this._buildFrustum(),this._kdTreeDirty&&this._buildKDTree(),e){const e=this._kdRoot;e&&this._visitKDNode(e)}}_buildFrustum(){const e=this.viewer.scene.camera;k(this._frustum,e.viewMatrix,e.projMatrix),this._frustumDirty=!1}_buildKDTree(){const e=this.viewer.scene;this._kdRoot,this._kdRoot={aabb:e.getAABB(),intersection:U.INTERSECT};for(let e=0,t=this._objectCullStates.numObjects;e=this._maxTreeDepth)return e.objects=e.objects||[],e.objects.push(i),void c.expandAABB3(e.aabb,r);if(e.left&&c.containsAABB3(e.left.aabb,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1);if(e.right&&c.containsAABB3(e.right.aabb,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1);const o=e.aabb;fw[0]=o[3]-o[0],fw[1]=o[4]-o[1],fw[2]=o[5]-o[2];let n=0;if(fw[1]>fw[n]&&(n=1),fw[2]>fw[n]&&(n=2),!e.left){const a=o.slice();if(a[n+3]=(o[n]+o[n+3])/2,e.left={aabb:a,intersection:U.INTERSECT},c.containsAABB3(a,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1)}if(!e.right){const a=o.slice();if(a[n]=(o[n]+o[n+3])/2,e.right={aabb:a,intersection:U.INTERSECT},c.containsAABB3(a,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1)}e.objects=e.objects||[],e.objects.push(i),c.expandAABB3(e.aabb,r)}_visitKDNode(e,t=U.INTERSECT){if(t!==U.INTERSECT&&e.intersects===t)return;t===U.INTERSECT&&(t=O(this._frustum,e.aabb),e.intersects=t);const i=t===U.OUTSIDE,s=e.objects;if(s&&s.length>0)for(let e=0,t=s.length;e{this._parseModel(e,t,i,s),r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){if(s.destroyed)return;const r=t.stats||{};if(r.sourceFormat="IFC",r.schemaVersion="",r.title="",r.author="",r.created="",r.numMetaObjects=0,r.numPropertySets=0,r.numObjects=0,r.numGeometries=0,r.numTriangles=0,r.numVertices=0,!this._ifcAPI)throw"WebIFCLoaderPlugin has no WebIFC instance configured - please inject via WebIFCLoaderPlugin constructor";const o=new Uint8Array(e),n=this._ifcAPI.OpenModel(o),a=this._ifcAPI.GetModelSchema(n),l=this._ifcAPI.GetLineIDsWithType(n,this._webIFC.IFCPROJECT).get(0),A=!1!==t.loadMetadata,h={modelID:n,modelSchema:a,sceneModel:s,loadMetadata:A,metadata:A?{id:"",projectId:""+l,author:"",createdAt:"",schema:"",creatingApplication:"",metaObjects:[],propertySets:[]}:null,metaObjects:{},options:i,log:function(e){},nextId:0,stats:r};if(A){if(i.includeTypes){h.includeTypes={};for(let e=0,t=i.includeTypes.length;e{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}_parseMetaObjects(e){const t=this._ifcAPI.GetLineIDsWithType(e.modelID,this._webIFC.IFCPROJECT).get(0),i=this._ifcAPI.GetLine(e.modelID,t);this._parseSpatialChildren(e,i)}_parseSpatialChildren(e,t,i){const s=this._ifcAPI.GetNameFromTypeCode(t.type);if(e.includeTypes&&!e.includeTypes[s])return;if(e.excludeTypes&&e.excludeTypes[s])return;this._createMetaObject(e,t,i);const r=t.GlobalId.value;this._parseRelatedItemsOfType(e,t.expressID,"RelatingObject","RelatedObjects",this._webIFC.IFCRELAGGREGATES,r),this._parseRelatedItemsOfType(e,t.expressID,"RelatingStructure","RelatedElements",this._webIFC.IFCRELCONTAINEDINSPATIALSTRUCTURE,r)}_createMetaObject(e,t,i){const s=t.GlobalId.value,r=this._ifcAPI.GetNameFromTypeCode(t.type),o={id:s,name:t.Name&&""!==t.Name.value?t.Name.value:r,type:r,parent:i};e.metadata.metaObjects.push(o),e.metaObjects[s]=o,e.stats.numMetaObjects++}_parseRelatedItemsOfType(e,t,i,s,r,o){const n=this._ifcAPI.GetLineIDsWithType(e.modelID,r);for(let r=0;re.value)).includes(t)}else h=A.value===t;if(h){const t=l[s];if(Array.isArray(t))t.forEach((t=>{const i=this._ifcAPI.GetLine(e.modelID,t.value);this._parseSpatialChildren(e,i,o)}));else{const i=this._ifcAPI.GetLine(e.modelID,t.value);this._parseSpatialChildren(e,i,o)}}}}_parsePropertySets(e){const t=this._ifcAPI.GetLineIDsWithType(e.modelID,this._webIFC.IFCRELDEFINESBYPROPERTIES);for(let i=0;i0){const o="Default",n=t.Name.value,a=[];for(let e=0,t=s.length;e{const i=t.expressID,s=t.geometries,r=[],o=this._ifcAPI.GetLine(e.modelID,i).GlobalId.value;if(e.loadMetadata){const t=o,i=e.metaObjects[t];if(e.includeTypes&&(!i||!e.includeTypes[i.type]))return;if(e.excludeTypes&&(!i||e.excludeTypes[i.type]))return}const n=c.mat4(),a=c.vec3();for(let t=0,i=s.size();t{o.finalize(),a.finalize(),this.viewer.scene.canvas.spinner.processes--,o.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(a.id)})),this.scheduleTask((()=>{o.destroyed||(o.scene.fire("modelLoaded",o.id),o.fire("loaded",!0,!1))}))},A=e=>{this.viewer.scene.canvas.spinner.processes--,this.error(e),o.fire("error",e)};let h=0;const c={getNextId:()=>`${n}.${h++}`};if(e.metaModelSrc||e.metaModelData)if(e.metaModelSrc){const r=e.metaModelSrc;this._dataSource.getMetaModel(r,(r=>{o.destroyed||(a.loadData(r,{includeTypes:i,excludeTypes:s,globalizeObjectIds:t.globalizeObjectIds}),e.src?this._loadModel(e.src,e,t,o,null,c,l,A):(this._parseModel(e.xkt,e,t,o,null,c),l()))}),(e=>{A(`load(): Failed to load model metadata for model '${n} from '${r}' - ${e}`)}))}else e.metaModelData&&(a.loadData(e.metaModelData,{includeTypes:i,excludeTypes:s,globalizeObjectIds:t.globalizeObjectIds}),e.src?this._loadModel(e.src,e,t,o,null,c,l,A):(this._parseModel(e.xkt,e,t,o,null,c),l()));else if(e.src)this._loadModel(e.src,e,t,o,a,c,l,A);else if(e.xkt)this._parseModel(e.xkt,e,t,o,a,c),l();else if(e.manifestSrc||e.manifest){const r=e.manifestSrc?function(e){const t=e.split("/");return t.pop(),t.join("/")+"/"}(e.manifestSrc):"",n=(e,o,n)=>{let l=0;const A=()=>{l>=e.length?o():this._dataSource.getMetaModel(`${r}${e[l]}`,(e=>{a.loadData(e,{includeTypes:i,excludeTypes:s,globalizeObjectIds:t.globalizeObjectIds}),l++,this.scheduleTask(A,100)}),n)};A()},h=(i,s,n)=>{let a=0;const l=()=>{a>=i.length?s():this._dataSource.getXKT(`${r}${i[a]}`,(i=>{this._parseModel(i,e,t,o,null,c),a++,this.scheduleTask(l,100)}),n)};l()},u=(i,s,n)=>{let l=0;const A=()=>{l>=i.length?s():this._dataSource.getXKT(`${r}${i[l]}`,(i=>{this._parseModel(i,e,t,o,a,c),l++,this.scheduleTask(A,100)}),n)};A()};if(e.manifest){const t=e.manifest,i=t.xktFiles;if(!i||0===i.length)return void A("load(): Failed to load model manifest - manifest not valid");const s=t.metaModelFiles;s?n(s,(()=>{h(i,l,A)}),A):u(i,l,A)}else this._dataSource.getManifest(e.manifestSrc,(e=>{if(o.destroyed)return;const t=e.xktFiles;if(!t||0===t.length)return void A("load(): Failed to load model manifest - manifest not valid");const i=e.metaModelFiles;i?n(i,(()=>{h(t,l,A)}),A):u(t,l,A)}),A)}return o}_loadModel(e,t,i,s,r,o,n,a){this._dataSource.getXKT(t.src,(e=>{this._parseModel(e,t,i,s,r,o),n()}),a)}_parseModel(e,t,i,s,r,o){if(s.destroyed)return;const n=new DataView(e),a=new Uint8Array(e),l=n.getUint32(0,!0),A=sP[l];if(!A)return void this.error("Unsupported .XKT file version: "+l+" - this XKTLoaderPlugin supports versions "+Object.keys(sP));this.log("Loading .xkt V"+l);const h=n.getUint32(4,!0),c=[];let u=4*(h+2);for(let e=0;e[...e])).flat();return Ss({id:e.id,points:t})},exports.buildSphereGeometry=Xi,exports.buildTorusGeometry=Ds,exports.buildVectorTextGeometry=Yi,exports.createRTCViewMat=j,exports.frustumIntersectsAABB3=O,exports.getKTX2TextureTranscoder=_A,exports.getPlaneRTCPos=W,exports.load3DSGeometry=function(e,t={}){return new Promise((function(i,s){t.src||(console.error("load3DSGeometry: Parameter expected: src"),s());var r=e.canvas.spinner;r.processes++,_.loadArraybuffer(t.src,(function(e){e.byteLength||(console.error("load3DSGeometry: no data loaded"),r.processes--,s());var o=Ms.parse.from3DS(e).edit.objects[0].mesh,n=o.vertices,a=o.uvt,l=o.indices;r.processes--,i(_.apply(t,{primitive:"triangles",positions:n,normals:null,uv:a,indices:l}))}),(function(e){console.error("load3DSGeometry: "+e),r.processes--,s()}))}))},exports.loadOBJGeometry=function(e,t={}){return new Promise((function(i,s){t.src||(console.error("loadOBJGeometry: Parameter expected: src"),s());var r=e.canvas.spinner;r.processes++,_.loadArraybuffer(t.src,(function(e){e.byteLength||(console.error("loadOBJGeometry: no data loaded"),r.processes--,s());for(var o=Ms.parse.fromOBJ(e),n=Ms.edit.unwrap(o.i_verts,o.c_verts,3),a=Ms.edit.unwrap(o.i_norms,o.c_norms,3),l=Ms.edit.unwrap(o.i_uvt,o.c_uvt,2),A=new Int32Array(o.i_verts.length),h=0;h0?a:null,autoNormals:0===a.length,uv:l,indices:A}))}),(function(e){console.error("loadOBJGeometry: "+e),r.processes--,s()}))}))},exports.math=c,exports.rtcToWorldPos=function(e,t,i){return i[0]=e[0]+t[0],i[1]=e[1]+t[1],i[2]=e[2]+t[2],i},exports.sRGBEncoding=3001,exports.setFrustum=k,exports.stats=p,exports.utils=_,exports.worldToRTCPos=G,exports.worldToRTCPositions=z; diff --git a/dist/xeokit-sdk.min.es.js b/dist/xeokit-sdk.min.es.js index ac1b044e17..0b661464da 100644 --- a/dist/xeokit-sdk.min.es.js +++ b/dist/xeokit-sdk.min.es.js @@ -14,7 +14,7 @@ class e{constructor(e,t){this.items=e||[],this._lastUniqueId=(t||0)+1}addItem(){ /** * @author https://github.com/tmarti, with support from https://tribia.com/ * @license MIT - **/let Zh=null;function qh(e,t){const i=3*e,s=3*t;let r,o,n,a,l,A;const h=Math.min(r=Zh[i],o=Zh[i+1],n=Zh[i+2]),c=Math.min(a=Zh[s],l=Zh[s+1],A=Zh[s+2]);if(h!==c)return h-c;const u=Math.max(r,o,n),d=Math.max(a,l,A);return u!==d?u-d:0}let $h=null;function ec(e,t){let i=$h[2*e]-$h[2*t];return 0!==i?i:$h[2*e+1]-$h[2*t+1]}function tc(e,t,i=!1){const s=e.positionsCompressed||[],r=function(e,t){const i=new Int32Array(e.length/3);for(let e=0,t=i.length;e>t;i.sort(qh);const s=new Int32Array(e.length);for(let t=0,r=i.length;te[t+1]){let i=e[t];e[t]=e[t+1],e[t+1]=i}$h=new Int32Array(e),t.sort(ec);const i=new Int32Array(e.length);for(let s=0,r=t.length;st){let i=e;e=t,t=i}function i(i,s){return i!==e?e-i:s!==t?t-s:0}let s=0,r=(o.length>>1)-1;for(;s<=r;){const e=r+s>>1,t=i(o[2*e],o[2*e+1]);if(t>0)s=e+1;else{if(!(t<0))return e;r=e-1}}return-s-1}const a=new Int32Array(o.length/2);a.fill(0);const l=s.length/3;if(l>8*(1<u.maxNumPositions&&(u=c()),u.bucketNumber>8)return[e];let p;-1===A[l]&&(A[l]=u.numPositions++,u.positionsCompressed.push(s[3*l]),u.positionsCompressed.push(s[3*l+1]),u.positionsCompressed.push(s[3*l+2])),-1===A[h]&&(A[h]=u.numPositions++,u.positionsCompressed.push(s[3*h]),u.positionsCompressed.push(s[3*h+1]),u.positionsCompressed.push(s[3*h+2])),-1===A[d]&&(A[d]=u.numPositions++,u.positionsCompressed.push(s[3*d]),u.positionsCompressed.push(s[3*d+1]),u.positionsCompressed.push(s[3*d+2])),u.indices.push(A[l]),u.indices.push(A[h]),u.indices.push(A[d]),(p=n(l,h))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]])),(p=n(l,d))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]])),(p=n(h,d))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]]))}const d=t/8*2,p=t/8,f=2*s.length+(r.length+o.length)*d;let g=0,m=-s.length/3;return h.forEach((e=>{g+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*p,m+=e.positionsCompressed.length/3})),g>f?[e]:(i&&function(e,t){const i={},s={};let r=0;e.forEach((e=>{const t=e.indices,o=e.edgeIndices,n=e.positionsCompressed;for(let e=0,s=t.length;e0){const e=t._meshes;for(let t=0,i=e.length;t0){const e=this._meshes;for(let t=0,i=e.length;t{this._viewMatrixDirty=!0})),this._meshesWithDirtyMatrices=[],this._numMeshesWithDirtyMatrices=0,this._onTick=this.scene.on("tick",(()=>{for(;this._numMeshesWithDirtyMatrices>0;)this._meshesWithDirtyMatrices[--this._numMeshesWithDirtyMatrices]._updateMatrix()})),this._createDefaultTextureSet(),this.visible=t.visible,this.culled=t.culled,this.pickable=t.pickable,this.clippable=t.clippable,this.collidable=t.collidable,this.castsShadow=t.castsShadow,this.receivesShadow=t.receivesShadow,this.xrayed=t.xrayed,this.highlighted=t.highlighted,this.selected=t.selected,this.edges=t.edges,this.colorize=t.colorize,this.opacity=t.opacity,this.backfaces=t.backfaces}_meshMatrixDirty(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}_createDefaultTextureSet(){const e=new Lh({id:"defaultColorTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),t=new Lh({id:"defaultMetalRoughTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),i=new Lh({id:"defaultNormalsTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),s=new Lh({id:"defaultEmissiveTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),r=new Lh({id:"defaultOcclusionTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures.defaultColorTexture=e,this._textures.defaultMetalRoughTexture=t,this._textures.defaultNormalsTexture=i,this._textures.defaultEmissiveTexture=s,this._textures.defaultOcclusionTexture=r,this._textureSets.defaultTextureSet=new Rh({id:"defaultTextureSet",model:this,colorTexture:e,metallicRoughnessTexture:t,normalsTexture:i,emissiveTexture:s,occlusionTexture:r})}get isPerformanceModel(){return!0}get transforms(){return this._transforms}get textures(){return this._textures}get textureSets(){return this._textureSets}get meshes(){return this._meshes}get objects(){return this._entities}get origin(){return this._origin}set position(e){this._position.set(e||[0,0,0]),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get position(){return this._position}set rotation(e){this._rotation.set(e||[0,0,0]),d.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get rotation(){return this._rotation}set quaternion(e){this._quaternion.set(e||[0,0,0,1]),d.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get quaternion(){return this._quaternion}set scale(e){}get scale(){return this._scale}set matrix(e){this._matrix.set(e||gc),d.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),d.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),d.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),d.translateMat4v(this._position,this._matrix),this._matrixDirty=!1,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get matrix(){return this._matrixDirty&&this._rebuildMatrices(),this._matrix}get rotationMatrix(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrix}_rebuildMatrices(){this._matrixDirty&&(d.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),d.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),d.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),d.translateMat4v(this._position,this._matrix),this._matrixDirty=!1)}get rotationMatrixConjugate(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrixConjugate}_setWorldMatrixDirty(){this._matrixDirty=!0,this._aabbDirty=!0}_transformDirty(){this._matrixDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0}_sceneModelDirty(){this.scene._aabbDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._matrixDirty=!0;for(let e=0,t=this._entityList.length;e0}set visible(e){e=!1!==e,this._visible=e;for(let t=0,i=this._entityList.length;t0}set xrayed(e){e=!!e,this._xrayed=e;for(let t=0,i=this._entityList.length;t0}set highlighted(e){e=!!e,this._highlighted=e;for(let t=0,i=this._entityList.length;t0}set selected(e){e=!!e,this._selected=e;for(let t=0,i=this._entityList.length;t0}set edges(e){e=!!e,this._edges=e;for(let t=0,i=this._entityList.length;t0}set pickable(e){e=!1!==e,this._pickable=e;for(let t=0,i=this._entityList.length;t0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){const t=e.colors,i=new Uint8Array(t.length);for(let e=0,s=t.length;e{l.setImage(A,{minFilter:i,magFilter:s,wrapS:r,wrapT:o,wrapR:n,flipY:e.flipY,encoding:a}),this.glRedraw()},A.src=e.src;break;default:this._textureTranscoder?y.loadArraybuffer(e.src,(e=>{e.byteLength?this._textureTranscoder.transcode([e],l).then((()=>{this.glRedraw()})):this.error("[createTexture] Can't create texture from 'src': file data is zero length")}),(function(e){this.error(`[createTexture] Can't create texture from 'src': ${e}`)})):this.error(`[createTexture] Can't create texture from 'src' - SceneModel needs to be configured with a TextureTranscoder for this file type ('${t}')`)}}else e.buffers&&(this._textureTranscoder?this._textureTranscoder.transcode(e.buffers,l).then((()=>{this.glRedraw()})):this.error("[createTexture] Can't create texture from 'buffers' - SceneModel needs to be configured with a TextureTranscoder for this option"));this._textures[t]=new Lh({id:t,texture:l})}createTextureSet(e){const t=e.id;if(null==t)return void this.error("[createTextureSet] Config missing: id");if(this._textureSets[t])return void this.error(`[createTextureSet] Texture set already created: ${t}`);let i,s,r,o,n;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(i=this._textures[e.colorTextureId],!i)return void this.error(`[createTextureSet] Texture not found: ${e.colorTextureId} - ensure that you create it first with createTexture()`)}else i=this._textures.defaultColorTexture;if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(s=this._textures[e.metallicRoughnessTextureId],!s)return void this.error(`[createTextureSet] Texture not found: ${e.metallicRoughnessTextureId} - ensure that you create it first with createTexture()`)}else s=this._textures.defaultMetalRoughTexture;if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(r=this._textures[e.normalsTextureId],!r)return void this.error(`[createTextureSet] Texture not found: ${e.normalsTextureId} - ensure that you create it first with createTexture()`)}else r=this._textures.defaultNormalsTexture;if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(o=this._textures[e.emissiveTextureId],!o)return void this.error(`[createTextureSet] Texture not found: ${e.emissiveTextureId} - ensure that you create it first with createTexture()`)}else o=this._textures.defaultEmissiveTexture;if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(n=this._textures[e.occlusionTextureId],!n)return void this.error(`[createTextureSet] Texture not found: ${e.occlusionTextureId} - ensure that you create it first with createTexture()`)}else n=this._textures.defaultOcclusionTexture;const a=new Rh({id:t,model:this,colorTexture:i,metallicRoughnessTexture:s,normalsTexture:r,emissiveTexture:o,occlusionTexture:n});return this._textureSets[t]=a,a}createTransform(e){if(void 0===e.id||null===e.id)return void this.error("[createTransform] SceneModel.createTransform() config missing: id");if(this._transforms[e.id])return void this.error(`[createTransform] SceneModel already has a transform with this ID: ${e.id}`);let t;if(e.parentTransformId&&(t=this._transforms[e.parentTransformId],!t))return void this.error("[createTransform] SceneModel.createTransform() config missing: id");const i=new Ac({id:e.id,model:this,parent:t,matrix:e.matrix,position:e.position,scale:e.scale,rotation:e.rotation,quaternion:e.quaternion});return this._transforms[i.id]=i,i}createMesh(e){if(void 0===e.id||null===e.id)return this.error("[createMesh] SceneModel.createMesh() config missing: id"),!1;if(this._meshes[e.id])return this.error(`[createMesh] SceneModel already has a mesh with this ID: ${e.id}`),!1;if(!(void 0!==e.geometryId)){if(void 0!==e.primitive&&null!==e.primitive||(e.primitive="triangles"),"points"!==e.primitive&&"lines"!==e.primitive&&"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)return this.error(`Unsupported value for 'primitive': '${primitive}' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.`),!1;if(!e.positions&&!e.positionsCompressed&&!e.buckets)return this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)"),!1;if(e.positions&&(e.positionsDecodeMatrix||e.positionsDecodeBoundary))return this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.positionsCompressed&&!e.positionsDecodeMatrix&&!e.positionsDecodeBoundary)return this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.uvCompressed&&!e.uvDecodeMatrix)return this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)"),!1;if(!(e.buckets||e.indices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)){const t=(e.positions||e.positionsCompressed).length/3;e.indices=this._createDefaultIndices(t)}if(!e.buckets&&!e.indices&&"points"!==e.primitive)return e.indices=this._createDefaultIndices(numIndices),this.error(`Param expected: indices (required for '${e.primitive}' primitive type)`),!1;if((e.matrix||e.position||e.rotation||e.scale)&&(e.positionsCompressed||e.positionsDecodeBoundary))return this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'"),!1;const t=!(!this._dtxEnabled||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||e.textureSetId);if(e.origin=e.origin?d.addVec3(this._origin,e.origin,d.vec3()):this._origin,e.matrix)e.meshMatrix=e.matrix;else if(e.scale||e.rotation||e.position){const t=e.scale||uc,i=e.position||dc,s=e.rotation||pc;d.eulerToQuaternion(s,"XYZ",fc),e.meshMatrix=d.composeMat4(i,fc,t,d.mat4())}if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=An(e.positionsDecodeBoundary,d.mat4())),t){if(e.type=2,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):mc,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.positions){const t=d.vec3(),i=[];J(e.positions,i,t)&&(e.positions=i,e.origin=d.addVec3(e.origin,t,t))}if(e.positions){const t=d.collapseAABB3();e.positionsDecodeMatrix=d.mat4(),d.expandAABB3Points3(t,e.positions),e.positionsCompressed=ln(e.positions,t,e.positionsDecodeMatrix),e.aabb=t}else if(e.positionsCompressed){const t=d.collapseAABB3();d.expandAABB3Points3(t,e.positionsCompressed),Vt.decompressAABB(t,e.positionsDecodeMatrix),e.aabb=t}if(e.buckets){const t=d.collapseAABB3();for(let i=0,s=e.buckets.length;i>24&255,r=i>>16&255,o=i>>8&255,n=255&i;switch(e.pickColor=new Uint8Array([n,o,r,s]),e.solid="solid"===e.primitive,t.origin=d.vec3(e.origin),e.type){case 2:t.layer=this._getDTXLayer(e),t.aabb=e.aabb;break;case 1:t.layer=this._getVBOBatchingLayer(e),t.aabb=e.aabb;break;case 0:t.layer=this._getVBOInstancingLayer(e),t.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),t.portionId=t.layer.createPortion(t,e),this._meshes[e.id]=t,this._unusedMeshes[e.id]=t,this._meshList.push(t),t}_getNumPrimitives(e){let t=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(let i=0,s=e.buckets.length;i>>0).toString(16)}_getVBOInstancingLayer(e){const t=this,i=e.origin,s=e.textureSetId||"-",r=e.geometryId,o=`${Math.round(i[0])}.${Math.round(i[1])}.${Math.round(i[2])}.${s}.${r}`;let n=this._vboInstancingLayers[o];if(n)return n;let a=e.textureSet;const l=e.geometry;for(;!n;)switch(l.primitive){case"triangles":case"surface":n=new da({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!1});break;case"solid":n=new da({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!0});break;case"lines":n=new qa({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0});break;case"points":n=new zl({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0})}return this._vboInstancingLayers[o]=n,this.layerList.push(n),n}createEntity(e){if(void 0===e.id?e.id=d.createUUID():this.scene.components[e.id]&&(this.error(`Scene already has a Component with this ID: ${e.id} - will assign random ID`),e.id=d.createUUID()),void 0===e.meshIds)return void this.error("Config missing: meshIds");let t=0;this._visible&&!1!==e.visible&&(t|=q),this._pickable&&!1!==e.pickable&&(t|=ee),this._culled&&!1!==e.culled&&(t|=$),this._clippable&&!1!==e.clippable&&(t|=te),this._collidable&&!1!==e.collidable&&(t|=ie),this._edges&&!1!==e.edges&&(t|=ne),this._xrayed&&!1!==e.xrayed&&(t|=se),this._highlighted&&!1!==e.highlighted&&(t|=re),this._selected&&!1!==e.selected&&(t|=oe),e.flags=t,this._createEntity(e)}_createEntity(e){let t=[];for(let i=0,s=e.meshIds.length;ie.sortIdt.sortId?1:0));for(let e=0,t=this.layerList.length;e0&&0===this.renderFlags.numVisibleLayers?this.renderFlags.culled=!0:this._updateRenderFlags()}_updateRenderFlagsVisibleLayers(){const e=this.renderFlags;e.numLayers=this.layerList.length,e.numVisibleLayers=0;for(let t=0,i=this.layerList.length;t0){const t=`${this.id}-dummyEntityForUnusedMeshes`;this.warn(`Creating dummy SceneModelEntity "${t}" for unused SceneMeshes: [${e.join(",")}]`),this.createEntity({id:t,meshIds:e,isObject:!0})}this._unusedMeshes={}}_getActiveSectionPlanesForLayer(e){const t=this.renderFlags,i=this.scene._sectionPlanesState.sectionPlanes,s=i.length,r=e.layerIndex*s;if(s>0)for(let e=0;e0&&(e.colorTransparent=!0),this.numXRayedLayerPortions>0){const t=this.scene.xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}if(this.numEdgesLayerPortions>0){this.scene.edgeMaterial._state.edges&&(e.edgesOpaque=this.numTransparentLayerPortions0&&(e.edgesTransparent=!0))}if(this.numSelectedLayerPortions>0){const t=this.scene.selectedMaterial._state;t.fill&&(t.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){const t=this.scene.highlightMaterial._state;t.fill&&(t.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}drawColorOpaque(e){const t=this.renderFlags;for(let i=0,s=t.visibleLayers.length;i65536?16:8)}else n=[{positionsCompressed:s,indices:r,edgeIndices:o}];return n}class bc extends R{constructor(e,t={}){if(super(e,t),this._positions=t.positions||[],t.indices)this._indices=t.indices;else{this._indices=[];for(let e=0,t=this._positions.length/3-1;ep.has(e.id)||g.has(e.id)||f.has(e.id))).reduce(((e,i)=>{let s,r=function(e){let t="";return t+=Math.round(255*e[0]).toString(16).padStart(2,"0"),t+=Math.round(255*e[1]).toString(16).padStart(2,"0"),t+=Math.round(255*e[2]).toString(16).padStart(2,"0"),t}(i.colorize);i.xrayed?(s=0===t.xrayMaterial.fillAlpha&&0!==t.xrayMaterial.edgeAlpha?.1:t.xrayMaterial.fillAlpha,s=Math.round(255*s).toString(16).padStart(2,"0"),r=s+r):p.has(i.id)&&(s=Math.round(255*i.opacity).toString(16).padStart(2,"0"),r=s+r),e[r]||(e[r]=[]);const o=i.id,n=i.originalSystemId,a={ifc_guid:n,originating_system:this.originatingSystem};return n!==o&&(a.authoring_tool_id=o),e[r].push(a),e}),{}),_=Object.entries(m).map((([e,t])=>({color:e,components:t})));o.components.coloring=_;const v=t.objectIds,b=t.visibleObjects,y=t.visibleObjectIds,B=v.filter((e=>!b[e])),x=t.selectedObjectIds;return e.defaultInvisible||y.length0&&e.clipping_planes.forEach((function(e){let t=Mc(e.location,yc),i=Mc(e.direction,yc);A&&d.negateVec3(i),d.subVec3(t,l),r.yUp&&(t=Ec(t),i=Ec(i)),new br(s,{pos:t,dir:i})})),s.clearLines(),e.lines&&e.lines.length>0){const t=[],i=[];let r=0;e.lines.forEach((e=>{e.start_point&&e.end_point&&(t.push(e.start_point.x),t.push(e.start_point.y),t.push(e.start_point.z),t.push(e.end_point.x),t.push(e.end_point.y),t.push(e.end_point.z),i.push(r++),i.push(r++))})),new bc(s,{positions:t,indices:i,clippable:!1,collidable:!0})}if(s.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){const t=e.bitmap_type||"jpg",i=e.bitmap_data;let o=Mc(e.location,Bc),n=Mc(e.normal,xc),a=Mc(e.up,wc),l=e.height||1;t&&i&&o&&n&&a&&(r.yUp&&(o=Ec(o),n=Ec(n),a=Ec(a)),new ao(s,{src:i,type:t,pos:o,normal:n,up:a,clippable:!1,collidable:!0,height:l}))})),a&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),s.setObjectsHighlighted(s.highlightedObjectIds,!1),s.setObjectsSelected(s.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(s.setObjectsVisible(s.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!1))))):(s.setObjectsVisible(s.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!0)))));const r=e.components.visibility.view_setup_hints;r&&(!1===r.spaces_visible&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcSpace"),!0),void 0!==r.spaces_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcSpace"),!0),r.space_boundaries_visible,!1===r.openings_visible&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcOpening"),!0),r.space_boundaries_translucent,void 0!==r.openings_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(s.setObjectsSelected(s.selectedObjectIds,!1),e.components.selection.forEach((e=>this._withBCFComponent(t,e,(e=>e.selected=!0))))),e.components.translucency&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),e.components.translucency.forEach((e=>this._withBCFComponent(t,e,(e=>e.xrayed=!0))))),e.components.coloring&&e.components.coloring.forEach((e=>{let i=e.color,s=0,r=!1;8===i.length&&(s=parseInt(i.substring(0,2),16)/256,s<=1&&s>=.95&&(s=1),i=i.substring(2),r=!0);const o=[parseInt(i.substring(0,2),16)/256,parseInt(i.substring(2,4),16)/256,parseInt(i.substring(4,6),16)/256];e.components.map((e=>this._withBCFComponent(t,e,(e=>{e.colorize=o,r&&(e.opacity=s)}))))}))}if(e.perspective_camera||e.orthogonal_camera){let a,A,h,c;if(e.perspective_camera?(a=Mc(e.perspective_camera.camera_view_point,yc),A=Mc(e.perspective_camera.camera_direction,yc),h=Mc(e.perspective_camera.camera_up_vector,yc),r.perspective.fov=e.perspective_camera.field_of_view,c="perspective"):(a=Mc(e.orthogonal_camera.camera_view_point,yc),A=Mc(e.orthogonal_camera.camera_direction,yc),h=Mc(e.orthogonal_camera.camera_up_vector,yc),r.ortho.scale=e.orthogonal_camera.view_to_world_scale,c="ortho"),d.subVec3(a,l),r.yUp&&(a=Ec(a),A=Ec(A),h=Ec(h)),o){const e=s.pick({pickSurface:!0,origin:a,direction:A});A=e?e.worldPos:d.addVec3(a,A,yc)}else A=d.addVec3(a,A,yc);n?(r.eye=a,r.look=A,r.up=h,r.projection=c):i.cameraFlight.flyTo({eye:a,look:A,up:h,duration:t.duration,projection:c})}}_withBCFComponent(e,t,i){const s=this.viewer,r=s.scene;if(t.authoring_tool_id&&t.originating_system===this.originatingSystem){const o=t.authoring_tool_id,n=r.objects[o];if(n)return void i(n);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[o])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(o),i)}}if(t.ifc_guid){const o=t.ifc_guid,n=r.objects[o];if(n)return void i(n);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[o])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(o),i)}Object.keys(r.models).forEach((t=>{const n=d.globalizeObjectId(t,o),a=r.objects[n];if(a)i(a);else if(e.updateCompositeObjects){s.metaScene.metaObjects[n]&&r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}}))}}destroy(){super.destroy()}}function Cc(e){return{x:e[0],y:e[1],z:e[2]}}function Mc(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function Fc(e){return new Float64Array([e[0],-e[2],e[1]])}function Ec(e){return new Float64Array([e[0],e[2],-e[1]])}const Ic=d.vec3(),Dc=(e,t,i,s)=>{var r=e-i,o=t-s;return Math.sqrt(r*r+o*o)};class Sc extends R{constructor(e,t={}){if(super(e.viewer.scene,t),this.plugin=e,this._container=t.container,!this._container)throw"config missing: container";this._eventSubs={};var i=this.plugin.viewer.scene;this._originMarker=new ue(i,t.origin),this._targetMarker=new ue(i,t.target),this._originWorld=d.vec3(),this._targetWorld=d.vec3(),this._wp=new Float64Array(24),this._vp=new Float64Array(24),this._pp=new Float64Array(24),this._cp=new Float64Array(8),this._xAxisLabelCulled=!1,this._yAxisLabelCulled=!1,this._zAxisLabelCulled=!1,this._color=t.color||this.plugin.defaultColor;const s=t.onMouseOver?e=>{t.onMouseOver(e,this),this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,r=t.onMouseLeave?e=>{t.onMouseLeave(e,this),this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,o=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},n=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},a=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},l=t.onContextMenu?e=>{t.onContextMenu(e,this)}:null,A=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};this._originDot=new pe(this._container,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._targetDot=new pe(this._container,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._lengthWire=new de(this._container,{color:this._color,thickness:2,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._xAxisWire=new de(this._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._yAxisWire=new de(this._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._zAxisWire=new de(this._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._lengthLabel=new fe(this._container,{fillColor:this._color,prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._xAxisLabel=new fe(this._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._yAxisLabel=new fe(this._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._zAxisLabel=new fe(this._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._wpDirty=!1,this._vpDirty=!1,this._cpDirty=!1,this._sectionPlanesDirty=!0,this._visible=!1,this._originVisible=!1,this._targetVisible=!1,this._wireVisible=!1,this._axisVisible=!1,this._xAxisVisible=!1,this._yAxisVisible=!1,this._zAxisVisible=!1,this._axisEnabled=!0,this._labelsVisible=!1,this._labelsOnWires=!1,this._clickable=!1,this._originMarker.on("worldPos",(e=>{this._originWorld.set(e||[0,0,0]),this._wpDirty=!0,this._needUpdate(0)})),this._targetMarker.on("worldPos",(e=>{this._targetWorld.set(e||[0,0,0]),this._wpDirty=!0,this._needUpdate(0)})),this._onViewMatrix=i.camera.on("viewMatrix",(()=>{this._vpDirty=!0,this._needUpdate(0)})),this._onProjMatrix=i.camera.on("projMatrix",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onCanvasBoundary=i.canvas.on("boundary",(()=>{this._cpDirty=!0,this._needUpdate(0)})),this._onMetricsUnits=i.metrics.on("units",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onMetricsScale=i.metrics.on("scale",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onMetricsOrigin=i.metrics.on("origin",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onSectionPlaneUpdated=i.on("sectionPlaneUpdated",(()=>{this._sectionPlanesDirty=!0,this._needUpdate()})),this.approximate=t.approximate,this.visible=t.visible,this.originVisible=t.originVisible,this.targetVisible=t.targetVisible,this.wireVisible=t.wireVisible,this.axisVisible=t.axisVisible,this.xAxisVisible=t.xAxisVisible,this.yAxisVisible=t.yAxisVisible,this.zAxisVisible=t.zAxisVisible,this.labelsVisible=t.labelsVisible,this.labelsOnWires=t.labelsOnWires}_update(){if(!this._visible)return;const e=this.plugin.viewer.scene;if(this._wpDirty&&(this._wp[0]=this._originWorld[0],this._wp[1]=this._originWorld[1],this._wp[2]=this._originWorld[2],this._wp[3]=1,this._wp[4]=this._targetWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._targetWorld[0],this._wp[9]=this._targetWorld[1],this._wp[10]=this._originWorld[2],this._wp[11]=1,this._wp[12]=this._targetWorld[0],this._wp[13]=this._targetWorld[1],this._wp[14]=this._targetWorld[2],this._wp[15]=1,this._wpDirty=!1,this._vpDirty=!0),this._vpDirty&&(d.transformPositions4(e.camera.viewMatrix,this._wp,this._vp),this._vp[3]=1,this._vp[7]=1,this._vp[11]=1,this._vp[15]=1,this._vpDirty=!1,this._cpDirty=!0),this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld))return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setCulled(!0),this._yAxisWire.setCulled(!0),this._zAxisWire.setCulled(!0),this._lengthWire.setCulled(!0),this._originDot.setCulled(!0),void this._targetDot.setCulled(!0);this._xAxisLabel.setCulled(!1),this._yAxisLabel.setCulled(!1),this._zAxisLabel.setCulled(!1),this._lengthLabel.setCulled(!1),this._xAxisWire.setCulled(!1),this._yAxisWire.setCulled(!1),this._zAxisWire.setCulled(!1),this._lengthWire.setCulled(!1),this._originDot.setCulled(!1),this._targetDot.setCulled(!1),this._sectionPlanesDirty=!0}const t=this._originMarker.viewPos[2],i=this._targetMarker.viewPos[2];if(t>-.3||i>-.3)return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setVisible(!1),this._yAxisWire.setVisible(!1),this._zAxisWire.setVisible(!1),this._lengthWire.setVisible(!1),this._originDot.setVisible(!1),void this._targetDot.setVisible(!1);if(this._cpDirty){d.transformPositions4(e.camera.project.matrix,this._vp,this._pp);var s=this._pp,r=this._cp,o=e.canvas.canvas.getBoundingClientRect();const t=this._container.getBoundingClientRect();var n=o.top-t.top,a=o.left-t.left,l=e.canvas.boundary,A=l[2],h=l[3],c=0;const i=this.plugin.viewer.scene.metrics,f=i.scale,g=i.units,m=i.unitsInfo[g].abbrev;for(var u=0,p=s.length;ue.offsetTop+(e.offsetParent&&h(e.offsetParent)),c=e=>e.offsetLeft+(e.offsetParent&&c(e.offsetParent)),u=d.vec2();this._onCameraControlHoverSnapOrSurface=i.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(e=>{const t=e.snappedCanvasPos||e.canvasPos;r=!0,o.set(e.worldPos),n.set(e.canvasPos),0===this._mouseState?(this._canvasToPagePos?(this._canvasToPagePos(s,t,u),this._markerDiv.style.left=u[0]-5+"px",this._markerDiv.style.top=u[1]-5+"px"):(this._markerDiv.style.left=c(s)+t[0]-5+"px",this._markerDiv.style.top=h(s)+t[1]-5+"px"),this._markerDiv.style.background="pink",e.snappedToVertex||e.snappedToEdge?(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,this.pointerLens.snapped=!0),this._markerDiv.style.background="greenyellow",this._markerDiv.style.border="2px solid green"):(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.canvasPos,this.pointerLens.snapped=!1),this._markerDiv.style.background="pink",this._markerDiv.style.border="2px solid red"),A=e.entity):(this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px"),s.style.cursor="pointer",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=this._currentDistanceMeasurementInitState.wireVisible,this._currentDistanceMeasurement.axisVisible=this._currentDistanceMeasurementInitState.axisVisible&&this.distanceMeasurementsPlugin.defaultAxisVisible,this._currentDistanceMeasurement.xAxisVisible=this._currentDistanceMeasurementInitState.xAxisVisible&&this.distanceMeasurementsPlugin.defaultXAxisVisible,this._currentDistanceMeasurement.yAxisVisible=this._currentDistanceMeasurementInitState.yAxisVisible&&this.distanceMeasurementsPlugin.defaultYAxisVisible,this._currentDistanceMeasurement.zAxisVisible=this._currentDistanceMeasurementInitState.zAxisVisible&&this.distanceMeasurementsPlugin.defaultZAxisVisible,this._currentDistanceMeasurement.targetVisible=this._currentDistanceMeasurementInitState.targetVisible,this._currentDistanceMeasurement.target.worldPos=o.slice(),this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px")})),s.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(a=e.clientX,l=e.clientY)}),s.addEventListener("mouseup",this._onMouseUp=t=>{1===t.which&&(t.clientX>a+20||t.clientXl+20||t.clientY{this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos),r=!1,this._markerDiv.style.left="-100px",this._markerDiv.style.top="-100px",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.axisVisible=!1),s.style.cursor="default"})),this._active=!0}deactivate(){if(!this._active)return;this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1),this._markerDiv&&this._destroyMarkerDiv(),this.reset();const e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);const t=this.distanceMeasurementsPlugin.viewer.cameraControl;t.off(this._onCameraControlHoverSnapOrSurface),t.off(this._onCameraControlHoverSnapOrSurfaceOff),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._active=!1}reset(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null))}destroy(){this.deactivate(),super.destroy()}}class Lc extends z{constructor(e,t={}){super("DistanceMeasurements",e),this._pointerLens=t.pointerLens,this._container=t.container||document.body,this._defaultControl=null,this._measurements={},this.labelMinAxisLength=t.labelMinAxisLength,this.defaultVisible=!1!==t.defaultVisible,this.defaultOriginVisible=!1!==t.defaultOriginVisible,this.defaultTargetVisible=!1!==t.defaultTargetVisible,this.defaultWireVisible=!1!==t.defaultWireVisible,this.defaultLabelsVisible=!1!==t.defaultLabelsVisible,this.defaultAxisVisible=!1!==t.defaultAxisVisible,this.defaultXAxisVisible=!1!==t.defaultXAxisVisible,this.defaultYAxisVisible=!1!==t.defaultYAxisVisible,this.defaultZAxisVisible=!1!==t.defaultZAxisVisible,this.defaultColor=void 0!==t.defaultColor?t.defaultColor:"#00BBFF",this.zIndex=t.zIndex||1e4,this.defaultLabelsOnWires=!1!==t.defaultLabelsOnWires,this._onMouseOver=(e,t)=>{this.fire("mouseOver",{plugin:this,distanceMeasurement:t,measurement:t,event:e})},this._onMouseLeave=(e,t)=>{this.fire("mouseLeave",{plugin:this,distanceMeasurement:t,measurement:t,event:e})},this._onContextMenu=(e,t)=>{this.fire("contextMenu",{plugin:this,distanceMeasurement:t,measurement:t,event:e})}}getContainerElement(){return this._container}send(e,t){}get pointerLens(){return this._pointerLens}get control(){return this._defaultControl||(this._defaultControl=new Rc(this,{})),this._defaultControl}get measurements(){return this._measurements}set labelMinAxisLength(e){e<1&&(this.error("labelMinAxisLength must be >= 1; defaulting to 25"),e=25),this._labelMinAxisLength=e||25}get labelMinAxisLength(){return this._labelMinAxisLength}createMeasurement(e={}){this.viewer.scene.components[e.id]&&(this.error("Viewer scene component with this ID already exists: "+e.id),delete e.id);const t=e.origin,i=e.target,s=new Sc(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},target:{entity:i.entity,worldPos:i.worldPos},visible:e.visible,wireVisible:e.wireVisible,axisVisible:!1!==e.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==e.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==e.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==e.zAxisVisible&&!1!==this.defaultZAxisVisible,labelsVisible:!1!==e.labelsVisible&&!1!==this.defaultLabelsVisible,originVisible:e.originVisible,targetVisible:e.targetVisible,color:e.color,labelsOnWires:!1!==e.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[s.id]=s,s.on("destroyed",(()=>{delete this._measurements[s.id]})),this.fire("measurementCreated",s),s}destroyMeasurement(e){const t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("DistanceMeasurement not found: "+e)}setLabelsShown(e){for(const[t,i]of Object.entries(this.measurements))i.labelShown=e}setAxisVisible(e){for(const[t,i]of Object.entries(this.measurements))i.axisVisible=e;this.defaultAxisVisible=e}getAxisVisible(){return this.defaultAxisVisible}clear(){const e=Object.keys(this._measurements);for(var t=0,i=e.length;t{this.plugin.viewer.cameraControl.active=!1},c=()=>{this.plugin.viewer.cameraControl.active=!0},u=()=>{o&&(clearTimeout(o),o=null),this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),c(),this._touchState=0};i.addEventListener("touchstart",this._onCanvasTouchStart=i=>{const l=i.touches.length;if(1!==l)return void(o&&(clearTimeout(o),o=null));const c=i.touches[0],p=c.clientX,f=c.clientY;switch(n.set([p,f]),a.set([p,f]),this._touchState){case 0:if(1!==l&&null!==o)return void u();const i=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge});if(i&&i.snapped)s.set(i.worldPos),this.pointerCircle.start(i.snappedCanvasPos);else{const e=t.pick({canvasPos:a,pickSurface:!0});if(!e||!e.worldPos)return;s.set(e.worldPos),this.pointerCircle.start(e.canvasPos)}o=setTimeout((()=>{1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{if(o=null,1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{this.pointerCircle.stop();const r=i.touches.length;if(1!==r||1!==i.changedTouches.length)return void(o&&(clearTimeout(o),o=null));const n=i.touches[0],l=n.clientX,h=n.clientY;if(n.identifier!==A)return;let c,u;switch(a.set([l,h]),this._touchState){case 2:this.pointerLens&&(this.pointerLens.canvasPos=a),c=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),c&&c.snapped?(this.pointerLens&&(this.pointerLens.snappedCanvasPos=c.snappedCanvasPos,this.pointerLens.snapped=!0),s.set(c.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=c.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:d.createUUID(),origin:{worldPos:c.worldPos,entity:c.entity},target:{worldPos:c.worldPos,entity:c.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):(u=t.pick({canvasPos:a,pickSurface:!0}),u&&u.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=u.canvasPos,this.pointerLens.snapped=!1),s.set(u.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=u.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:d.createUUID(),origin:{worldPos:u.worldPos,entity:u.entity},target:{worldPos:u.worldPos,entity:u.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)),this._touchState=2;break;case 5:if(1!==r&&null!==o)return clearTimeout(o),o=null,this.pointerLens&&(this.pointerLens.visible=!1),void(this._touchState=7);this.pointerLens&&(this.pointerLens.canvasPos=a),c=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),c&&c.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=c.snappedCanvasPos,this.pointerLens.snapped=!0),this._currentDistanceMeasurement.target.worldPos=c.worldPos,this._currentDistanceMeasurement.target.entity=c.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0):(u=t.pick({canvasPos:a,pickSurface:!0}),u&&u.worldPos&&(this.pointerLens&&(this.pointerLens.cursorPos=u.canvasPos,this.pointerLens.snapped=!1),this._currentDistanceMeasurement.target.worldPos=u.worldPos,this._currentDistanceMeasurement.target.entity=u.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0)),this._touchState=5}}),{passive:!0}),i.addEventListener("touchend",this._onCanvasTouchEnd=i=>{this.pointerCircle.stop();const s=i.changedTouches.length;if(1!==s)return;const h=i.changedTouches[0],u=h.clientX,p=h.clientY;if(h.identifier===A)switch(o&&(clearTimeout(o),o=null),l.set([u,p]),this._touchState){case 1:{if(1!==s||u>n[0]+r||un[1]+r||pn[0]+r||un[1]+r||p{i=1e3*this._delayBeforeRestoreSeconds,s||(e.scene._renderer.setColorTextureEnabled(!this._hideColorTexture),e.scene._renderer.setPBREnabled(!this._hidePBR),e.scene._renderer.setSAOEnabled(!this._hideSAO),e.scene._renderer.setTransparentEnabled(!this._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!this._hideEdges),this._scaleCanvasResolution?e.scene.canvas.resolutionScale=this._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=this._defaultScaleCanvasResolutionFactor,s=!0)},o=()=>{e.scene.canvas.resolutionScale=this._defaultScaleCanvasResolutionFactor,e.scene._renderer.setEdgesEnabled(!0),e.scene._renderer.setColorTextureEnabled(!0),e.scene._renderer.setPBREnabled(!0),e.scene._renderer.setSAOEnabled(!0),e.scene._renderer.setTransparentEnabled(!0),s=!1};this._onCanvasBoundary=e.scene.canvas.on("boundary",r),this._onCameraMatrix=e.scene.camera.on("matrix",r),this._onSceneTick=e.scene.on("tick",(e=>{s&&(i-=e.deltaTime,(!this._delayBeforeRestore||i<=0)&&o())}));let n=!1;this._onSceneMouseDown=e.scene.input.on("mousedown",(()=>{n=!0})),this._onSceneMouseUp=e.scene.input.on("mouseup",(()=>{n=!1})),this._onSceneMouseMove=e.scene.input.on("mousemove",(()=>{n&&r()}))}get hideColorTexture(){return this._hideColorTexture}set hideColorTexture(e){this._hideColorTexture=e}get hidePBR(){return this._hidePBR}set hidePBR(e){this._hidePBR=e}get hideSAO(){return this._hideSAO}set hideSAO(e){this._hideSAO=e}get hideEdges(){return this._hideEdges}set hideEdges(e){this._hideEdges=e}get hideTransparentObjects(){return this._hideTransparentObjects}set hideTransparentObjects(e){this._hideTransparentObjects=!1!==e}get scaleCanvasResolution(){return this._scaleCanvasResolution}set scaleCanvasResolution(e){this._scaleCanvasResolution=e}get defaultScaleCanvasResolutionFactor(){return this._defaultScaleCanvasResolutionFactor}set defaultScaleCanvasResolutionFactor(e){this._defaultScaleCanvasResolutionFactor=e||1}get scaleCanvasResolutionFactor(){return this._scaleCanvasResolutionFactor}set scaleCanvasResolutionFactor(e){this._scaleCanvasResolutionFactor=e||.6}get delayBeforeRestore(){return this._delayBeforeRestore}set delayBeforeRestore(e){this._delayBeforeRestore=e}get delayBeforeRestoreSeconds(){return this._delayBeforeRestoreSeconds}set delayBeforeRestoreSeconds(e){this._delayBeforeRestoreSeconds=null!=e?e:.5}send(e,t){}destroy(){this.viewer.scene.camera.off(this._onCameraMatrix),this.viewer.scene.canvas.off(this._onCanvasBoundary),this.viewer.scene.input.off(this._onSceneMouseDown),this.viewer.scene.input.off(this._onSceneMouseUp),this.viewer.scene.input.off(this._onSceneMouseMove),this.viewer.scene.off(this._onSceneTick),super.destroy()}}class Oc{constructor(){}getMetaModel(e,t,i){y.loadJSON(e,(e=>{t(e)}),(function(e){i(e)}))}getGLTF(e,t,i){y.loadArraybuffer(e,(e=>{t(e)}),(function(e){i(e)}))}getGLB(e,t,i){y.loadArraybuffer(e,(e=>{t(e)}),(function(e){i(e)}))}getArrayBuffer(e,t,i,s){!function(e,t,i,s){var r=()=>{};i=i||r,s=s||r;const o=/^data:(.*?)(;base64)?,(.*)$/,n=t.match(o);if(n){const e=!!n[2];var a=n[3];a=window.decodeURIComponent(a),e&&(a=window.atob(a));try{const e=new ArrayBuffer(a.length),t=new Uint8Array(e);for(var l=0;l{i(e)}),(function(e){s(e)}))}}class Nc{constructor(e={}){this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=e.messages,this.locale=e.locale}set messages(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}loadMessages(e={}){for(let t in e)this._messages[t]=e[t];this.messages=this._messages}clearMessages(){this.messages={}}get locales(){return this._locales}set locale(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}get locale(){return this._locale}translate(e,t){const i=this._messages[this._locale];if(!i)return null;const s=Qc(e,i);return s?t?Vc(s,t):s:null}translatePlurals(e,t,i){const s=this._messages[this._locale];if(!s)return null;let r=Qc(e,s);return r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one,r?(r=Vc(r,[t]),i&&(r=Vc(r,i)),r):null}fire(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);const s=this._eventSubs[e];if(s)for(const e in s)if(s.hasOwnProperty(e)){s[e].callback(t)}}on(t,i){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new e),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});let s=this._eventSubs[t];s||(s={},this._eventSubs[t]=s);const r=this._eventSubIDMap.addItem();s[r]={callback:i},this._eventSubEvents[r]=t;const o=this._events[t];return void 0!==o&&i(o),r}off(e){if(null==e)return;if(!this._eventSubEvents)return;const t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];const i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}function Qc(e,t){if(t[e])return t[e];const i=e.split(".");let s=t;for(let e=0,t=i.length;s&&e1?1:e}get t(){return this._t}get tangent(){return this.getTangent(this._t)}get length(){var e=this._getLengths();return e[e.length-1]}getTangent(e){var t=1e-4;void 0===e&&(e=this._t);var i=e-t,s=e+t;i<0&&(i=0),s>1&&(s=1);var r=this.getPoint(i),o=this.getPoint(s),n=d.subVec3(o,r,[]);return d.normalizeVec3(n,[])}getPointAt(e){var t=this.getUToTMapping(e);return this.getPoint(t)}getPoints(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}_getLengths(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,s=[],r=this.getPoint(0),o=0;for(s.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),o+=d.lenVec3(d.subVec3(t,r,[])),s.push(o),r=t;return this.cacheArcLengths=s,s}_updateArcLengths(){this.needsUpdate=!0,this._getLengths()}getUToTMapping(e,t){var i,s=this._getLengths(),r=0,o=s.length;i=t||e*s[o-1];for(var n,a=0,l=o-1;a<=l;)if((n=s[r=Math.floor(a+(l-a)/2)]-i)<0)a=r+1;else{if(!(n>0)){l=r;break}l=r-1}if(s[r=l]===i)return r/(o-1);var A=s[r];return(r+(i-A)/(s[r+1]-A))/(o-1)}}class jc extends Hc{constructor(e,t={}){super(e,t),this.points=t.points,this.t=t.t}set points(e){this._points=e||[]}get points(){return this._points}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=this.points;if(!(t.length<3)){var i=(t.length-1)*e,s=Math.floor(i),r=i-s,o=t[0===s?s:s-1],n=t[s],a=t[s>t.length-2?t.length-1:s+1],l=t[s>t.length-3?t.length-1:s+2],A=d.vec3();return A[0]=d.catmullRomInterpolate(o[0],n[0],a[0],l[0],r),A[1]=d.catmullRomInterpolate(o[1],n[1],a[1],l[1],r),A[2]=d.catmullRomInterpolate(o[2],n[2],a[2],l[2],r),A}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}getJSON(){return{points:points,t:this._t}}}const Gc=d.vec3();class zc extends R{get type(){return"CameraPath"}constructor(e,t={}){super(e,t),this._frames=[],this._eyeCurve=new jc(this),this._lookCurve=new jc(this),this._upCurve=new jc(this),t.frames&&(this.addFrames(t.frames),this.smoothFrameTimes(1))}get frames(){return this._frames}get eyeCurve(){return this._eyeCurve}get lookCurve(){return this._lookCurve}get upCurve(){return this._upCurve}saveFrame(e){const t=this.scene.camera;this.addFrame(e,t.eye,t.look,t.up)}addFrame(e,t,i,s){const r={t:e,eye:t.slice(0),look:i.slice(0),up:s.slice(0)};this._frames.push(r),this._eyeCurve.points.push(r.eye),this._lookCurve.points.push(r.look),this._upCurve.points.push(r.up)}addFrames(e){let t;for(let i=0,s=e.length;i1?1:e,t.eye=this._eyeCurve.getPoint(e,Gc),t.look=this._lookCurve.getPoint(e,Gc),t.up=this._upCurve.getPoint(e,Gc)}sampleFrame(e,t,i,s){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,s)}smoothFrameTimes(e){if(0===this._frames.length)return;const t=d.vec3();var i=0;this._frames[0].t=0;const s=[];for(let e=1,o=this._frames.length;e=1;e>1&&(e=1);const i=this.easing?Zc._ease(e,0,1,1):e,s=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(d.subVec3(s.eye,s.look,Yc),s.eye=d.lerpVec3(i,0,1,this._eye1,this._eye2,Xc),s.look=d.subVec3(Xc,Yc,Kc)):this._flyingLook&&(s.look=d.lerpVec3(i,0,1,this._look1,this._look2,Kc),s.up=d.lerpVec3(i,0,1,this._up1,this._up2,Jc)):this._flyingEyeLookUp&&(s.eye=d.lerpVec3(i,0,1,this._eye1,this._eye2,Xc),s.look=d.lerpVec3(i,0,1,this._look1,this._look2,Kc),s.up=d.lerpVec3(i,0,1,this._up1,this._up2,Jc)),this._projection2){const t="ortho"===this._projection2?Zc._easeOutExpo(e,0,1,1):Zc._easeInCubic(e,0,1,1);s.customProjection.matrix=d.lerpMat4(t,0,1,this._projMatrix1,this._projMatrix2)}else s.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return s.ortho.scale=this._orthoScale2,void this.stop();I.scheduleTask(this._update,this)}static _ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}static _easeInCubic(e,t,i,s){return i*(e/=s)*e*e+t}static _easeOutExpo(e,t,i,s){return i*(1-Math.pow(2,-10*e/s))+t}stop(){if(!this._flying)return;this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);const e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}cancel(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}set duration(e){this._duration=e?1e3*e:500,this.stop()}get duration(){return this._duration/1e3}set fit(e){this._fit=!1!==e}get fit(){return this._fit}set fitFOV(e){this._fitFOV=e||45}get fitFOV(){return this._fitFOV}set trail(e){this._trail=!!e}get trail(){return this._trail}destroy(){this.stop(),super.destroy()}}class qc extends R{get type(){return"CameraPathAnimation"}constructor(e,t={}){super(e,t),this._cameraFlightAnimation=new Zc(this),this._t=0,this.state=qc.SCRUBBING,this._playingFromT=0,this._playingToT=0,this._playingRate=t.playingRate||1,this._playingDir=1,this._lastTime=null,this.cameraPath=t.cameraPath,this._tick=this.scene.on("tick",this._updateT,this)}_updateT(){const e=this._cameraPath;if(!e)return;let t,i;const s=performance.now(),r=this._lastTime?.001*(s-this._lastTime):0;if(this._lastTime=s,0!==r)switch(this.state){case qc.SCRUBBING:return;case qc.PLAYING:if(this._t+=this._playingRate*r,t=this._cameraPath.frames.length,0===t||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=qc.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case qc.PLAYING_TO:i=this._t+this._playingRate*r*this._playingDir,(this._playingDir<0&&i<=this._playingToT||this._playingDir>0&&i>=this._playingToT)&&(i=this._playingToT,this.state=qc.SCRUBBING,this.fire("stopped")),this._t=i,e.loadFrame(this._t)}}_ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}set cameraPath(e){this._cameraPath=e}get cameraPath(){return this._cameraPath}set rate(e){this._playingRate=e}get rate(){return this._playingRate}play(){this._cameraPath&&(this._lastTime=null,this.state=qc.PLAYING)}playToT(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=qc.PLAYING_TO)}playToFrame(e){const t=this._cameraPath;if(!t)return;const i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}flyToFrame(e,t){const i=this._cameraPath;if(!i)return;const s=i.frames[e];s?(this.state=qc.SCRUBBING,this._cameraFlightAnimation.flyTo(s,t)):this.error("flyToFrame - frame index out of range: "+e)}scrubToT(e){const t=this._cameraPath;if(!t)return;this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=qc.SCRUBBING)}scrubToFrame(e){const t=this._cameraPath;if(!t)return;if(!this.scene.camera)return;t.frames[e]?(t.loadFrame(this._t),this.state=qc.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)}stop(){this.state=qc.SCRUBBING,this.fire("stopped")}destroy(){super.destroy(),this.scene.off(this._tick)}}qc.STOPPED=0,qc.SCRUBBING=1,qc.PLAYING=2,qc.PLAYING_TO=3;const $c=d.vec3(),eu=d.vec3();d.vec3();const tu=d.vec3([0,-1,0]),iu=d.vec4([0,0,0,1]);class su extends R{constructor(e,t={}){super(e,t),this._src=null,this._image=null,this._pos=d.vec3(),this._origin=d.vec3(),this._rtcPos=d.vec3(),this._dir=d.vec3(),this._size=1,this._imageSize=d.vec2(),this._texture=new Wr(this),this._plane=new dr(this,{geometry:new Gt(this,so({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new Jt(this,{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:this._texture,emissiveMap:this._texture,backfaces:!0}),clippable:t.clippable}),this._grid=new dr(this,{geometry:new Gt(this,io({size:1,divisions:10})),material:new Jt(this,{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:t.clippable}),this._node=new Ir(this,{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[this._plane,this._grid]}),this._gridVisible=!1,this.visible=!0,this.gridVisible=t.gridVisible,this.position=t.position,this.rotation=t.rotation,this.dir=t.dir,this.size=t.size,this.collidable=t.collidable,this.clippable=t.clippable,this.pickable=t.pickable,this.opacity=t.opacity,t.image?this.image=t.image:this.src=t.src}set visible(e){this._plane.visible=e,this._grid.visible=this._gridVisible&&e}get visible(){return this._plane.visible}set gridVisible(e){e=!1!==e,this._gridVisible=e,this._grid.visible=this._gridVisible&&this.visible}get gridVisible(){return this._gridVisible}set image(e){this._image=e,this._image&&(this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}get image(){return this._image}set src(e){if(this._src=e,this._src){this._image=null;const e=new Image;e.onload=()=>{this._texture.image=e,this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage()},e.src=this._src}}get src(){return this._src}set position(e){this._pos.set(e||[0,0,0]),X(this._pos,this._origin,this._rtcPos),this._node.origin=this._origin,this._node.position=this._rtcPos}get position(){return this._pos}set rotation(e){this._node.rotation=e}get rotation(){return this._node.rotation}set size(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}get size(){return this._size}set dir(e){if(this._dir.set(e||[0,0,-1]),e){const t=this.scene.center,i=[-this._dir[0],-this._dir[1],-this._dir[2]];d.subVec3(t,this.position,$c);const s=-d.dotVec3(i,$c);d.normalizeVec3(i),d.mulVec3Scalar(i,s,eu),d.vec3PairToQuaternion(tu,e,iu),this._node.quaternion=iu}}get dir(){return this._dir}set collidable(e){this._node.collidable=!1!==e}get collidable(){return this._node.collidable}set clippable(e){this._node.clippable=!1!==e}get clippable(){return this._node.clippable}set pickable(e){this._node.pickable=!1!==e}get pickable(){return this._node.pickable}set opacity(e){this._node.opacity=e}get opacity(){return this._node.opacity}destroy(){super.destroy()}_updatePlaneSizeFromImage(){const e=this._size,t=this._imageSize[0],i=this._imageSize[1];if(t>i){const s=i/t;this._node.scale=[e,1,e*s]}else{const s=t/i;this._node.scale=[e*s,1,e]}}}class ru extends It{get type(){return"PointLight"}constructor(e,t={}){super(e,t);const i=this;this._shadowRenderBuf=null,this._shadowViewMatrix=null,this._shadowProjMatrix=null,this._shadowViewMatrixDirty=!0,this._shadowProjMatrixDirty=!0;const s=this.scene.camera,r=this.scene.canvas;this._onCameraViewMatrix=s.on("viewMatrix",(()=>{this._shadowViewMatrixDirty=!0})),this._onCameraProjMatrix=s.on("projMatrix",(()=>{this._shadowProjMatrixDirty=!0})),this._onCanvasBoundary=r.on("boundary",(()=>{this._shadowProjMatrixDirty=!0})),this._state=new lt({type:"point",pos:d.vec3([1,1,1]),color:d.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:t.space||"view",castsShadow:!1,getShadowViewMatrix:()=>{if(i._shadowViewMatrixDirty){i._shadowViewMatrix||(i._shadowViewMatrix=d.identityMat4());const e=i._state.pos,t=s.look,r=s.up;d.lookAtMat4v(e,t,r,i._shadowViewMatrix),i._shadowViewMatrixDirty=!1}return i._shadowViewMatrix},getShadowProjMatrix:()=>{if(i._shadowProjMatrixDirty){i._shadowProjMatrix||(i._shadowProjMatrix=d.identityMat4());const e=i.scene.canvas.canvas;d.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,i._shadowProjMatrix),i._shadowProjMatrixDirty=!1}return i._shadowProjMatrix},getShadowRenderBuf:()=>(i._shadowRenderBuf||(i._shadowRenderBuf=new it(i.scene.canvas.canvas,i.scene.canvas.gl,{size:[1024,1024]})),i._shadowRenderBuf)}),this.pos=t.pos,this.color=t.color,this.intensity=t.intensity,this.constantAttenuation=t.constantAttenuation,this.linearAttenuation=t.linearAttenuation,this.quadraticAttenuation=t.quadraticAttenuation,this.castsShadow=t.castsShadow,this.scene._lightCreated(this)}set pos(e){this._state.pos.set(e||[1,1,1]),this._shadowViewMatrixDirty=!0,this.glRedraw()}get pos(){return this._state.pos}set color(e){this._state.color.set(e||[.7,.7,.8]),this.glRedraw()}get color(){return this._state.color}set intensity(e){e=void 0!==e?e:1,this._state.intensity=e,this.glRedraw()}get intensity(){return this._state.intensity}set constantAttenuation(e){this._state.attenuation[0]=e||0,this.glRedraw()}get constantAttenuation(){return this._state.attenuation[0]}set linearAttenuation(e){this._state.attenuation[1]=e||0,this.glRedraw()}get linearAttenuation(){return this._state.attenuation[1]}set quadraticAttenuation(e){this._state.attenuation[2]=e||0,this.glRedraw()}get quadraticAttenuation(){return this._state.attenuation[2]}set castsShadow(e){e=!!e,this._state.castsShadow!==e&&(this._state.castsShadow=e,this._shadowViewMatrixDirty=!0,this.glRedraw())}get castsShadow(){return this._state.castsShadow}destroy(){const e=this.scene.camera,t=this.scene.canvas;e.off(this._onCameraViewMatrix),e.off(this._onCameraProjMatrix),t.off(this._onCanvasBoundary),super.destroy(),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}}function ou(e){if(!nu(e.width)||!nu(e.height)){const t=document.createElement("canvas");t.width=au(e.width),t.height=au(e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}function nu(e){return 0==(e&e-1)}function au(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}class lu extends R{get type(){return"CubeTexture"}constructor(e,t={}){super(e,t);const i=this.scene.canvas.gl;this._state=new lt({texture:new Qr({gl:i,target:i.TEXTURE_CUBE_MAP}),flipY:this._checkFlipY(t.minFilter),encoding:this._checkEncoding(t.encoding),minFilter:1008,magFilter:1006,wrapS:1001,wrapT:1001,mipmaps:!0}),this._src=t.src,this._images=[],this._loadSrc(t.src),m.memory.textures++}_checkFlipY(e){return!!e}_checkEncoding(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),e}_webglContextRestored(){this.scene.canvas.gl,this._state.texture=null,this._src&&this._loadSrc(this._src)}_loadSrc(e){const t=this,i=this.scene.canvas.gl;this._images=[];let s=!1,r=0;for(let o=0;o{this._texture.image=e,this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage()},e.src=this._src}}get src(){return this._src}set size(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}get size(){return this._size}set collidable(e){this._mesh.collidable=!1!==e}get collidable(){return this._mesh.collidable}set clippable(e){this._mesh.clippable=!1!==e}get clippable(){return this._mesh.clippable}set pickable(e){this._mesh.pickable=!1!==e}get pickable(){return this._mesh.pickable}set opacity(e){this._mesh.opacity=e}get opacity(){return this._mesh.opacity}_updatePlaneSizeFromImage(){const e=.5*this._size,t=this._imageSize[0],i=this._imageSize[1],s=i/t;this._geometry.positions=t>i?[e,e*s,0,-e,e*s,0,-e,-e*s,0,e,-e*s,0]:[e/s,e,0,-e/s,e,0,-e/s,-e,0,e/s,-e,0]}}class uu{constructor(e){this._eye=d.vec3(),this._look=d.vec3(),this._up=d.vec3(),this._projection={},e&&this.saveCamera(e)}saveCamera(e){const t=e.camera,i=t.project;switch(this._eye.set(t.eye),this._look.set(t.look),this._up.set(t.up),t.projection){case"perspective":this._projection={projection:"perspective",fov:i.fov,fovAxis:i.fovAxis,near:i.near,far:i.far};break;case"ortho":this._projection={projection:"ortho",scale:i.scale,near:i.near,far:i.far};break;case"frustum":this._projection={projection:"frustum",left:i.left,right:i.right,top:i.top,bottom:i.bottom,near:i.near,far:i.far};break;case"custom":this._projection={projection:"custom",matrix:i.matrix.slice()}}}restoreCamera(e,t){const i=e.camera,s=this._projection;function r(){switch(s.type){case"perspective":i.perspective.fov=s.fov,i.perspective.fovAxis=s.fovAxis,i.perspective.near=s.near,i.perspective.far=s.far;break;case"ortho":i.ortho.scale=s.scale,i.ortho.near=s.near,i.ortho.far=s.far;break;case"frustum":i.frustum.left=s.left,i.frustum.right=s.right,i.frustum.top=s.top,i.frustum.bottom=s.bottom,i.frustum.near=s.near,i.frustum.far=s.far;break;case"custom":i.customProjection.matrix=s.matrix}}t?e.viewer.cameraFlight.flyTo({eye:this._eye,look:this._look,up:this._up,orthoScale:s.scale,projection:s.projection},(()=>{r(),t()})):(i.eye=this._eye,i.look=this._look,i.up=this._up,r(),i.projection=s.projection)}}const du=d.vec3();class pu{constructor(e){if(this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,e){const t=e.metaScene.scene;this.saveObjects(t,e)}}saveObjects(e,t,i){this.numObjects=0,this._mask=i?y.apply(i,{}):null;const s=!i||i.visible,r=!i||i.edges,o=!i||i.xrayed,n=!i||i.highlighted,a=!i||i.selected,l=!i||i.clippable,A=!i||i.pickable,h=!i||i.colorize,c=!i||i.opacity,u=t.metaObjects,d=e.objects;for(let e=0,t=u.length;e1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=d.vec3();return t[0]=d.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),t[1]=d.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),t[2]=d.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),t}getJSON(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}}class _u extends Hc{constructor(e,t={}){super(e,t),this._cachedLengths=[],this._dirty=!0,this._curves=[],this._t=0,this._dirtySubs=[],this._destroyedSubs=[],this.curves=t.curves||[],this.t=t.t}addCurve(e){this._curves.push(e),this._dirty=!0}set curves(e){var t,i,s;for(e=e||[],i=0,s=this._curves.length;i1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}get length(){var e=this._getCurveLengths();return e[e.length-1]}getPoint(e){for(var t,i=e*this.length,s=this._getCurveLengths(),r=0;r=i){var o=1-(s[r]-i)/(t=this._curves[r]).length;return t.getPointAt(o)}r++}return null}_getCurveLengths(){if(!this._dirty)return this._cachedLengths;var e,t=[],i=0,s=this._curves.length;for(e=0;e1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=d.vec3();return t[0]=d.b2(e,this._v0[0],this._v1[0],this._v2[0]),t[1]=d.b2(e,this._v0[1],this._v1[1],this._v2[1]),t[2]=d.b2(e,this._v0[2],this._v1[2],this._v2[2]),t}getJSON(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}}class bu extends _c{constructor(e,t={}){super(e,t)}}class yu extends R{constructor(e,t={}){super(e,t),this._skyboxMesh=new dr(this,{geometry:new Gt(this,{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[2e3,2e3,2e3],rotation:[0,-90,0],material:new Jt(this,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Wr(this,{src:t.src,flipY:!0,wrapS:"clampToEdge",wrapT:"clampToEdge",encoding:t.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),this.size=t.size,this.active=t.active}set size(e){this._size=e||1e3,this._skyboxMesh.scale=[this._size,this._size,this._size]}get size(){return this._size}set active(e){this._skyboxMesh.visible=e}get active(){return this._skyboxMesh.visible}}class Bu{transcode(e,t,i={}){}destroy(){}}const xu=d.vec4(),wu=d.vec4(),Pu=d.vec3(),Cu=d.vec3(),Mu=d.vec3(),Fu=d.vec4(),Eu=d.vec4(),Iu=d.vec4();class Du{constructor(e){this._scene=e}dollyToCanvasPos(e,t,i){let s=!1;const r=this._scene.camera;if(e){const t=d.subVec3(e,r.eye,Pu);s=d.lenVec3(t){this._cameraDirty=!0})),this._onProjMatrix=this._scene.camera.on("projMatrix",(()=>{this._cameraDirty=!0})),this._onTick=this._scene.on("tick",(()=>{this.updatePivotElement(),this.updatePivotSphere()}))}createPivotSphere(){const e=this.getPivotPos(),t=d.vec3();d.decomposeMat4(d.inverseMat4(this._scene.viewer.camera.viewMatrix,d.mat4()),t,d.vec4(),d.vec3());const i=d.distVec3(t,e);let s=Math.tan(Math.PI/500)*i*this._pivotSphereSize;"ortho"==this._scene.camera.projection&&(s/=this._scene.camera.ortho.scale/2),X(e,this._rtcCenter,this._rtcPos),this._pivotSphereGeometry=new Yr(this._scene,gr({radius:s})),this._pivotSphere=new dr(this._scene,{geometry:this._pivotSphereGeometry,material:this._pivotSphereMaterial,pickable:!1,position:this._rtcPos,rtcCenter:this._rtcCenter})}destroyPivotSphere(){this._pivotSphere&&(this._pivotSphere.destroy(),this._pivotSphere=null),this._pivotSphereGeometry&&(this._pivotSphereGeometry.destroy(),this._pivotSphereGeometry=null)}updatePivotElement(){const e=this._scene.camera,t=this._scene.canvas;if(this._pivoting&&this._cameraDirty){d.transformPoint3(e.viewMatrix,this.getPivotPos(),this._pivotViewPos),this._pivotViewPos[3]=1,d.transformPoint4(e.projMatrix,this._pivotViewPos,this._pivotProjPos);const i=t.boundary,s=i[2],r=i[3];this._pivotCanvasPos[0]=Math.floor((1+this._pivotProjPos[0]/this._pivotProjPos[3])*s/2),this._pivotCanvasPos[1]=Math.floor((1-this._pivotProjPos[1]/this._pivotProjPos[3])*r/2);let o=t._lastBoundingClientRect;if(!o||t._canvasSizeChanged){const e=t.canvas;o=t._lastBoundingClientRect=e.getBoundingClientRect()}this._pivotElement&&(this._pivotElement.style.left=Math.floor(o.left+this._pivotCanvasPos[0])-this._pivotElement.clientWidth/2+window.scrollX+"px",this._pivotElement.style.top=Math.floor(o.top+this._pivotCanvasPos[1])-this._pivotElement.clientHeight/2+window.scrollY+"px"),this._cameraDirty=!1}}updatePivotSphere(){this._pivoting&&this._pivotSphere&&(X(this.getPivotPos(),this._rtcCenter,this._rtcPos),d.compareVec3(this._rtcPos,this._pivotSphere.position)||(this.destroyPivotSphere(),this.createPivotSphere()))}setPivotElement(e){this._pivotElement=e}enablePivotSphere(e={}){this.destroyPivotSphere(),this._pivotSphereEnabled=!0,e.size&&(this._pivotSphereSize=e.size);const t=e.color||[1,0,0];this._pivotSphereMaterial=new Jt(this._scene,{emissive:t,ambient:t,specular:[0,0,0],diffuse:[0,0,0]})}disablePivotSphere(){this.destroyPivotSphere(),this._pivotSphereEnabled=!1}startPivot(){if(this._cameraLookingDownwards())return this._pivoting=!1,!1;const e=this._scene.camera;let t=d.lookAtMat4v(e.eye,e.look,e.worldUp);d.transformPoint3(t,this.getPivotPos(),this._cameraOffset);const i=this.getPivotPos();this._cameraOffset[2]+=d.distVec3(e.eye,i),t=d.inverseMat4(t);const s=d.transformVec3(t,this._cameraOffset),r=d.vec3();if(d.subVec3(e.eye,i,r),d.addVec3(r,s),e.zUp){const e=r[1];r[1]=r[2],r[2]=e}this._radius=d.lenVec3(r),this._polar=Math.acos(r[1]/this._radius),this._azimuth=Math.atan2(r[0],r[2]),this._pivoting=!0}_cameraLookingDownwards(){const e=this._scene.camera,t=d.normalizeVec3(d.subVec3(e.look,e.eye,Su)),i=d.cross3Vec3(t,e.worldUp,Tu);return d.sqLenVec3(i)<=1e-4}getPivoting(){return this._pivoting}setPivotPos(e){this._pivotWorldPos.set(e),this._pivotPosSet=!0}setCanvasPivotPos(e){const t=this._scene.camera,i=Math.abs(d.distVec3(this._scene.center,t.eye)),s=t.project.transposedMatrix,r=s.subarray(8,12),o=s.subarray(12),n=[0,0,-1,1],a=d.dotVec4(n,r)/d.dotVec4(n,o),l=Lu;t.project.unproject(e,a,Uu,ku,l);const A=d.normalizeVec3(d.subVec3(l,t.eye,Su)),h=d.addVec3(t.eye,d.mulVec3Scalar(A,i,Tu),Ru);this.setPivotPos(h)}getPivotPos(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}continuePivot(e,t){if(!this._pivoting)return;if(0===e&&0===t)return;const i=this._scene.camera;var s=-e;const r=-t;1===i.worldUp[2]&&(s=-s),this._azimuth+=.01*-s,this._polar+=.01*r,this._polar=d.clamp(this._polar,.001,Math.PI-.001);const o=[this._radius*Math.sin(this._polar)*Math.sin(this._azimuth),this._radius*Math.cos(this._polar),this._radius*Math.sin(this._polar)*Math.cos(this._azimuth)];if(1===i.worldUp[2]){const e=o[1];o[1]=o[2],o[2]=e}const n=d.lenVec3(d.subVec3(i.look,i.eye,d.vec3())),a=this.getPivotPos();d.addVec3(o,a);let l=d.lookAtMat4v(o,a,i.worldUp);l=d.inverseMat4(l);const A=d.transformVec3(l,this._cameraOffset);l[12]-=A[0],l[13]-=A[1],l[14]-=A[2];const h=[l[8],l[9],l[10]];i.eye=[l[12],l[13],l[14]],d.subVec3(i.eye,d.mulVec3Scalar(h,n),i.look),i.up=[l[4],l[5],l[6]],this.showPivot()}showPivot(){this._shown||(this._pivotElement&&(this.updatePivotElement(),this._pivotElement.style.visibility="visible"),this._pivotSphereEnabled&&(this.destroyPivotSphere(),this.createPivotSphere()),this._shown=!0)}hidePivot(){this._shown&&(this._pivotElement&&(this._pivotElement.style.visibility="hidden"),this._pivotSphereEnabled&&this.destroyPivotSphere(),this._shown=!1)}endPivot(){this._pivoting=!1}destroy(){this.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}class Nu{constructor(e,t){this._scene=e.scene,this._cameraControl=e,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=t,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=d.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}update(){if(!this._configs.pointerEnabled)return;if(!this.schedulePickEntity&&!this.schedulePickSurface)return;const e=`${~~this.pickCursorPos[0]}-${~~this.pickCursorPos[1]}-${this.scheduleSnapOrPick}-${this.schedulePickSurface}-${this.schedulePickEntity}`;if(this._lastHash===e)return;this.picked=!1,this.pickedSurface=!1,this.snappedOrPicked=!1,this.hoveredSnappedOrSurfaceOff=!1;const t=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){const e=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});e&&(e.snappedToEdge||e.snappedToVertex)?(this.snapPickResult=e,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){const e=this.pickResult.canvasPos;if(e[0]===this.pickCursorPos[0]&&e[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=t?1:0,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.hoveredSnappedOrSurfaceOff=!0,void(this.scheduleSnapOrPick=!1)}if(this.schedulePickEntity&&this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){const e=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(e[0]===this.pickCursorPos[0]&&e[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!1,this.schedulePickEntity=!1,void(this.schedulePickSurface=!1)}this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult?(this.pickResult=this._scene.pick({pickSurface:!0,pickSurfaceNormal:!1,canvasPos:this.pickCursorPos}),this.pickResult?(this.picked=!0,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.pickedSurface=!0,this._needFireEvents++):this.scheduleSnapOrPick&&(this.hoveredSnappedOrSurfaceOff=!0,this._needFireEvents++)):(this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos}),this.pickResult&&(this.picked=!0,this.pickedSurface=!1,this._needFireEvents++)),this.scheduleSnapOrPick=!1,this.schedulePickEntity=!1,this.schedulePickSurface=!1}fireEvents(){if(0!==this._needFireEvents){if(this.hoveredSnappedOrSurfaceOff&&this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},!0),this.snappedOrPicked)if(this.snapPickResult){const e=new Re;e.entity=this.snapPickResult.entity,e.snappedToVertex=this.snapPickResult.snappedToVertex,e.snappedToEdge=this.snapPickResult.snappedToEdge,e.worldPos=this.snapPickResult.worldPos,e.canvasPos=this.pickCursorPos,e.snappedCanvasPos=this.snapPickResult.snappedCanvasPos,this._cameraControl.fire("hoverSnapOrSurface",e,!0),this.snapPickResult=null}else this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,!0);if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){const e=this.pickResult.entity.id;this._lastPickedEntityId!==e&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=e)}this._cameraControl.fire("hover",this.pickResult,!0),this.pickResult.worldPos&&(this.pickedSurface=!0,this._cameraControl.fire("hoverSurface",this.pickResult,!0))}else void 0!==this._lastPickedEntityId&&(this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},!0);this.pickResult=null,this._needFireEvents=0}}}const Qu=d.vec2();class Vu{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController;let n,a,l,A=0,h=0,c=0,u=0,p=!1;const f=d.vec3();let g=!0;const m=this._scene.canvas.canvas,_=[];function v(e=!0){m.style.cursor="move",A=s.pointerCanvasPos[0],h=s.pointerCanvasPos[1],c=s.pointerCanvasPos[0],u=s.pointerCanvasPos[1],e&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickSurface=!0,o.update(),o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(p=!0,f.set(o.pickResult.worldPos)):p=!1)}document.addEventListener("keydown",this._documentKeyDownHandler=t=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;const s=t.keyCode;_[s]=!0}),document.addEventListener("keyup",this._documentKeyUpHandler=t=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;const s=t.keyCode;_[s]=!1}),m.addEventListener("mousedown",this._mouseDownHandler=t=>{if(i.active&&i.pointerEnabled)switch(t.which){case 1:_[e.input.KEY_SHIFT]||i.planView?(n=!0,v()):(n=!0,v(!1));break;case 2:a=!0,v();break;case 3:l=!0,i.panRightClick&&v()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(!n&&!a&&!l)return;const o=e.canvas.boundary,c=o[2],u=o[3],g=s.pointerCanvasPos[0],m=s.pointerCanvasPos[1],v=_[e.input.KEY_SHIFT]||i.planView||!i.panRightClick&&a||i.panRightClick&&l,b=document.pointerLockElement?t.movementX:g-A,y=document.pointerLockElement?t.movementY:m-h;if(v){const t=e.camera;if("perspective"===t.projection){const i=Math.abs(p?d.lenVec3(d.subVec3(f,e.camera.eye,[])):e.camera.eyeLookDist)*Math.tan(t.perspective.fov/2*Math.PI/180);r.panDeltaX+=1.5*b*i/u,r.panDeltaY+=1.5*y*i/u}else r.panDeltaX+=.5*t.ortho.scale*(b/u),r.panDeltaY+=.5*t.ortho.scale*(y/u)}else!n||a||l||i.planView||(i.firstPerson?(r.rotateDeltaY-=b/c*i.dragRotationRate/2,r.rotateDeltaX+=y/u*(i.dragRotationRate/4)):(r.rotateDeltaY-=b/c*(1.5*i.dragRotationRate),r.rotateDeltaX+=y/u*(1.5*i.dragRotationRate)));A=g,h=m}),m.addEventListener("mousemove",this._canvasMouseMoveHandler=e=>{i.active&&i.pointerEnabled&&s.mouseover&&(g=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=e=>{if(i.active&&i.pointerEnabled)switch(e.which){case 1:case 2:case 3:n=!1,a=!1,l=!1}}),m.addEventListener("mouseup",this._mouseUpHandler=e=>{if(i.active&&i.pointerEnabled){if(3===e.which){!function(e,t){if(e){let i=e.target,s=0,r=0,o=0,n=0;for(;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,o+=i.scrollLeft,n+=i.scrollTop,i=i.offsetParent;t[0]=e.pageX+o-s,t[1]=e.pageY+n-r}else e=window.event,t[0]=e.x,t[1]=e.y}(e,Qu);const i=Qu[0],s=Qu[1];Math.abs(i-c)<3&&Math.abs(s-u)<3&&t.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Qu,event:e},!0)}m.style.removeProperty("cursor")}}),m.addEventListener("mouseenter",this._mouseEnterHandler=()=>{i.active&&i.pointerEnabled});const b=1/60;let y=null;m.addEventListener("wheel",this._mouseWheelHandler=e=>{if(!i.active||!i.pointerEnabled)return;const t=performance.now()/1e3;var o=null!==y?t-y:0;y=t,o>.05&&(o=.05),o{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;if(!s.mouseover)return;const n=r._isKeyDownForAction(r.AXIS_VIEW_RIGHT),a=r._isKeyDownForAction(r.AXIS_VIEW_BACK),l=r._isKeyDownForAction(r.AXIS_VIEW_LEFT),A=r._isKeyDownForAction(r.AXIS_VIEW_FRONT),h=r._isKeyDownForAction(r.AXIS_VIEW_TOP),c=r._isKeyDownForAction(r.AXIS_VIEW_BOTTOM);if(!(n||a||l||A||h||c))return;const u=e.aabb,p=d.getAABB3Diag(u);d.getAABB3Center(u,Hu);const f=Math.abs(p/Math.tan(t.cameraFlight.fitFOV*d.DEGTORAD)),g=1.1*p;Ku.orthoScale=g,n?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldRight,f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(o.worldUp)):a?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldForward,f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(o.worldUp)):l?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldRight,-f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(o.worldUp)):A?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldForward,-f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(o.worldUp)):h?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldUp,f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(d.normalizeVec3(d.mulVec3Scalar(o.worldForward,1,Gu),zu))):c&&(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldUp,-f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(d.normalizeVec3(d.mulVec3Scalar(o.worldForward,-1,Gu)))),!i.firstPerson&&i.followPointer&&t.pivotController.setPivotPos(Hu),t.cameraFlight.duration>0?t.cameraFlight.flyTo(Ku,(()=>{t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot()})):(t.cameraFlight.jumpTo(Ku),t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot())}))}reset(){}destroy(){this._scene.input.off(this._onSceneKeyDown)}}class Ju{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController,n=t.pivotController,a=t.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;let l=!1,A=!1;const h=this._scene.canvas.canvas,c=i=>{let s;i&&i.worldPos&&(s=i.worldPos);const r=i&&i.entity?i.entity.aabb:e.aabb;if(s){const i=e.camera;d.subVec3(i.eye,i.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})},u=e.tickify(this._canvasMouseMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(l||A)return;const r=a.hasSubs("hover"),n=a.hasSubs("hoverEnter"),h=a.hasSubs("hoverOut"),c=a.hasSubs("hoverOff"),u=a.hasSubs("hoverSurface"),d=a.hasSubs("hoverSnapOrSurface");if(r||n||h||c||u||d)if(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=!0,o.schedulePickSurface=u,o.scheduleSnapOrPick=d,o.update(),o.pickResult){if(o.pickResult.entity){const t=o.pickResult.entity.id;this._lastPickedEntityId!==t&&(void 0!==this._lastPickedEntityId&&a.fire("hoverOut",{entity:e.objects[this._lastPickedEntityId]},!0),a.fire("hoverEnter",o.pickResult,!0),this._lastPickedEntityId=t)}a.fire("hover",o.pickResult,!0),(o.pickResult.worldPos||o.pickResult.snappedWorldPos)&&a.fire("hoverSurface",o.pickResult,!0)}else void 0!==this._lastPickedEntityId&&(a.fire("hoverOut",{entity:e.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),a.fire("hoverOff",{canvasPos:o.pickCursorPos},!0)});h.addEventListener("mousemove",u),h.addEventListener("mousedown",this._canvasMouseDownHandler=t=>{1===t.which&&(l=!0),3===t.which&&(A=!0);if(1===t.which&&i.active&&i.pointerEnabled&&(s.mouseDownClientX=t.clientX,s.mouseDownClientY=t.clientY,s.mouseDownCursorX=s.pointerCanvasPos[0],s.mouseDownCursorY=s.pointerCanvasPos[1],!i.firstPerson&&i.followPointer&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickSurface=!0,o.update(),1===t.which))){const t=o.pickResult;t&&t.worldPos?(n.setPivotPos(t.worldPos),n.startPivot()):(i.smartPivot?n.setCanvasPivotPos(s.pointerCanvasPos):n.setPivotPos(e.camera.look),n.startPivot())}}),document.addEventListener("mouseup",this._documentMouseUpHandler=e=>{1===e.which&&(l=!1),3===e.which&&(A=!1),n.getPivoting()&&n.endPivot()}),h.addEventListener("mouseup",this._canvasMouseUpHandler=r=>{if(!i.active||!i.pointerEnabled)return;if(!(1===r.which))return;if(n.hidePivot(),Math.abs(r.clientX-s.mouseDownClientX)>3||Math.abs(r.clientY-s.mouseDownClientY)>3)return;const l=a.hasSubs("picked"),A=a.hasSubs("pickedNothing"),h=a.hasSubs("pickedSurface"),u=a.hasSubs("doublePicked"),p=a.hasSubs("doublePickedSurface"),f=a.hasSubs("doublePickedNothing");if(!(i.doublePickFlyTo||u||p||f))return(l||A||h)&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=!0,o.schedulePickSurface=h,o.update(),o.pickResult?(a.fire("picked",o.pickResult,!0),o.pickedSurface&&a.fire("pickedSurface",o.pickResult,!0)):a.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0)),void(this._clicks=0);if(this._clicks++,1===this._clicks){o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=i.doublePickFlyTo,o.schedulePickSurface=h,o.update();const e=o.pickResult,r=o.pickedSurface;this._timeout=setTimeout((()=>{e?(a.fire("picked",e,!0),r&&(a.fire("pickedSurface",e,!0),!i.firstPerson&&i.followPointer&&(t.pivotController.setPivotPos(e.worldPos),t.pivotController.startPivot()&&t.pivotController.showPivot()))):a.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0),this._clicks=0}),i.doubleClickTimeFrame)}else{if(null!==this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null),o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=i.doublePickFlyTo||u||p,o.schedulePickSurface=o.schedulePickEntity&&p,o.update(),o.pickResult){if(a.fire("doublePicked",o.pickResult,!0),o.pickedSurface&&a.fire("doublePickedSurface",o.pickResult,!0),i.doublePickFlyTo&&(c(o.pickResult),!i.firstPerson&&i.followPointer)){const e=o.pickResult.entity.aabb,i=d.getAABB3Center(e);t.pivotController.setPivotPos(i),t.pivotController.startPivot()&&t.pivotController.showPivot()}}else if(a.fire("doublePickedNothing",{canvasPos:s.pointerCanvasPos},!0),i.doublePickFlyTo&&(c(),!i.firstPerson&&i.followPointer)){const i=e.aabb,s=d.getAABB3Center(i);t.pivotController.setPivotPos(s),t.pivotController.startPivot()&&t.pivotController.showPivot()}this._clicks=0}},!1)}reset(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}destroy(){const e=this._scene.canvas.canvas;e.removeEventListener("mousemove",this._canvasMouseMoveHandler),e.removeEventListener("mousedown",this._canvasMouseDownHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._canvasMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}class Yu{constructor(e,t,i,s,r){this._scene=e;const o=e.input,n=[],a=e.canvas.canvas;let l=!0;this._onSceneMouseMove=o.on("mousemove",(()=>{l=!0})),this._onSceneKeyDown=o.on("keydown",(t=>{i.active&&i.pointerEnabled&&e.input.keyboardEnabled&&s.mouseover&&(n[t]=!0,t===o.KEY_SHIFT&&(a.style.cursor="move"))})),this._onSceneKeyUp=o.on("keyup",(s=>{i.active&&i.pointerEnabled&&e.input.keyboardEnabled&&(n[s]=!1,s===o.KEY_SHIFT&&(a.style.cursor=null),t.pivotController.getPivoting()&&t.pivotController.endPivot())})),this._onTick=e.on("tick",(a=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;if(!s.mouseover)return;const A=t.cameraControl,h=a.deltaTime/1e3;if(!i.planView){const e=A._isKeyDownForAction(A.ROTATE_Y_POS,n),s=A._isKeyDownForAction(A.ROTATE_Y_NEG,n),o=A._isKeyDownForAction(A.ROTATE_X_POS,n),a=A._isKeyDownForAction(A.ROTATE_X_NEG,n),l=h*i.keyboardRotationRate;(e||s||o||a)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),e?r.rotateDeltaY+=l:s&&(r.rotateDeltaY-=l),o?r.rotateDeltaX+=l:a&&(r.rotateDeltaX-=l),!i.firstPerson&&i.followPointer&&t.pivotController.startPivot())}if(!n[o.KEY_CTRL]&&!n[o.KEY_ALT]){const e=A._isKeyDownForAction(A.DOLLY_BACKWARDS,n),o=A._isKeyDownForAction(A.DOLLY_FORWARDS,n);if(e||o){const n=h*i.keyboardDollyRate;!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),o?r.dollyDelta-=n:e&&(r.dollyDelta+=n),l&&(s.followPointerDirty=!0,l=!1)}}const c=A._isKeyDownForAction(A.PAN_FORWARDS,n),u=A._isKeyDownForAction(A.PAN_BACKWARDS,n),d=A._isKeyDownForAction(A.PAN_LEFT,n),p=A._isKeyDownForAction(A.PAN_RIGHT,n),f=A._isKeyDownForAction(A.PAN_UP,n),g=A._isKeyDownForAction(A.PAN_DOWN,n),m=(n[o.KEY_ALT]?.3:1)*h*i.keyboardPanRate;(c||u||d||p||f||g)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),g?r.panDeltaY+=m:f&&(r.panDeltaY+=-m),p?r.panDeltaX+=-m:d&&(r.panDeltaX+=m),u?r.panDeltaZ+=m:c&&(r.panDeltaZ+=-m))}))}reset(){}destroy(){this._scene.off(this._onTick),this._scene.input.off(this._onSceneMouseMove),this._scene.input.off(this._onSceneKeyDown),this._scene.input.off(this._onSceneKeyUp)}}const Zu=d.vec3();class qu{constructor(e,t,i,s,r){this._scene=e;const o=e.camera,n=t.pickController,a=t.pivotController,l=t.panController;let A=1,h=1,c=null;this._onTick=e.on("tick",(()=>{if(!i.active||!i.pointerEnabled)return;let t="default";if(Math.abs(r.dollyDelta)<.001&&(r.dollyDelta=0),Math.abs(r.rotateDeltaX)<.001&&(r.rotateDeltaX=0),Math.abs(r.rotateDeltaY)<.001&&(r.rotateDeltaY=0),0===r.rotateDeltaX&&0===r.rotateDeltaY||(r.dollyDelta=0),i.followPointer){if(--A<=0&&(A=1,0!==r.dollyDelta)){if(0===r.rotateDeltaY&&0===r.rotateDeltaX&&i.followPointer&&s.followPointerDirty&&(n.pickCursorPos=s.pointerCanvasPos,n.schedulePickSurface=!0,n.update(),n.pickResult&&n.pickResult.worldPos?c=n.pickResult.worldPos:(h=1,c=null),s.followPointerDirty=!1),c){const t=Math.abs(d.lenVec3(d.subVec3(c,e.camera.eye,Zu)));h=t/i.dollyProximityThreshold}h{s.mouseover=!0}),o.addEventListener("mouseleave",this._mouseLeaveHandler=()=>{s.mouseover=!1,o.style.cursor=null}),document.addEventListener("mousemove",this._mouseMoveHandler=e=>{ed(e,o,s.pointerCanvasPos)}),o.addEventListener("mousedown",this._mouseDownHandler=e=>{i.active&&i.pointerEnabled&&(ed(e,o,s.pointerCanvasPos),s.mouseover=!0)}),o.addEventListener("mouseup",this._mouseUpHandler=e=>{i.active&&i.pointerEnabled})}reset(){}destroy(){const e=this._scene.canvas.canvas;document.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseenter",this._mouseEnterHandler),e.removeEventListener("mouseleave",this._mouseLeaveHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mouseup",this._mouseUpHandler)}}function ed(e,t,i){if(e){const{left:s,top:r}=t.getBoundingClientRect();i[0]=e.clientX-s-window.scrollX,i[1]=e.clientY-r-window.scrollY}else e=window.event,i[0]=e.x,i[1]=e.y;return i}const td=function(e,t){if(e){let i=e.target,s=0,r=0;for(;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t};class id{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController,n=t.pivotController,a=d.vec2(),l=d.vec2(),A=d.vec2(),h=d.vec2(),c=[],u=this._scene.canvas.canvas;let p=0,f=!1;this._onTick=e.on("tick",(()=>{f=!1})),u.addEventListener("touchstart",this._canvasTouchStartHandler=t=>{if(!i.active||!i.pointerEnabled)return;t.preventDefault();const r=t.touches,l=t.changedTouches;for(s.touchStartTime=Date.now(),1===r.length&&1===l.length&&(td(r[0],a),i.followPointer&&(o.pickCursorPos=a,o.schedulePickSurface=!0,o.update(),i.planView||(o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(n.setPivotPos(o.pickResult.worldPos),!i.firstPerson&&n.startPivot()&&n.showPivot()):(i.smartPivot?n.setCanvasPivotPos(s.pointerCanvasPos):n.setPivotPos(e.camera.look),!i.firstPerson&&n.startPivot()&&n.showPivot()))));c.length{n.getPivoting()&&n.endPivot()}),u.addEventListener("touchmove",this._canvasTouchMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(t.stopPropagation(),t.preventDefault(),f)return;f=!0;const n=e.canvas.boundary,a=n[2],u=n[3],g=t.touches;if(t.touches.length===p){if(1===p){td(g[0],l),d.subVec2(l,c[0],h);const t=h[0],o=h[1];if(null!==s.longTouchTimeout&&(Math.abs(t)>i.longTapRadius||Math.abs(o)>i.longTapRadius)&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),i.planView){const s=e.camera;if("perspective"===s.projection){const n=Math.abs(e.camera.eyeLookDist)*Math.tan(s.perspective.fov/2*Math.PI/180);r.panDeltaX+=t*n/u*i.touchPanRate,r.panDeltaY+=o*n/u*i.touchPanRate}else r.panDeltaX+=.5*s.ortho.scale*(t/u)*i.touchPanRate,r.panDeltaY+=.5*s.ortho.scale*(o/u)*i.touchPanRate}else r.rotateDeltaY-=t/a*(1*i.dragRotationRate),r.rotateDeltaX+=o/u*(1.5*i.dragRotationRate)}else if(2===p){const t=g[0],n=g[1];td(t,l),td(n,A);const a=d.geometricMeanVec2(c[0],c[1]),h=d.geometricMeanVec2(l,A),p=d.vec2();d.subVec2(a,h,p);const f=p[0],m=p[1],_=e.camera,v=d.distVec2([t.pageX,t.pageY],[n.pageX,n.pageY]),b=(d.distVec2(c[0],c[1])-v)*i.touchDollyRate;if(r.dollyDelta=b,Math.abs(b)<1)if("perspective"===_.projection){const t=o.pickResult?o.pickResult.worldPos:e.center,s=Math.abs(d.lenVec3(d.subVec3(t,e.camera.eye,[])))*Math.tan(_.perspective.fov/2*Math.PI/180);r.panDeltaX-=f*s/u*i.touchPanRate,r.panDeltaY-=m*s/u*i.touchPanRate}else r.panDeltaX-=.5*_.ortho.scale*(f/u)*i.touchPanRate,r.panDeltaY-=.5*_.ortho.scale*(m/u)*i.touchPanRate;s.pointerCanvasPos=h}for(let e=0;e{let s;i&&i.worldPos&&(s=i.worldPos);const r=i?i.entity.aabb:e.aabb;if(s){const i=e.camera;d.subVec3(i.eye,i.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})};u.addEventListener("touchstart",this._canvasTouchStartHandler=e=>{if(!i.active||!i.pointerEnabled)return;null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null);const r=e.touches,o=e.changedTouches;if(a=Date.now(),1===r.length&&1===o.length){h=a,sd(r[0],A);const o=A[0],n=A[1],l=r[0].pageX,c=r[0].pageY;s.longTouchTimeout=setTimeout((()=>{t.cameraControl.fire("rightClick",{pagePos:[Math.round(l),Math.round(c)],canvasPos:[Math.round(o),Math.round(n)],event:e},!0),s.longTouchTimeout=null}),i.longTapTimeout)}else h=-1;for(;l.length{if(!i.active||!i.pointerEnabled)return;const t=Date.now(),r=e.touches,a=e.changedTouches,u=n.hasSubs("pickedSurface");null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),0===r.length&&1===a.length&&h>-1&&t-h<150&&(c>-1&&h-c<325?(sd(a[0],o.pickCursorPos),o.schedulePickEntity=!0,o.schedulePickSurface=u,o.update(),o.pickResult?(o.pickResult.touchInput=!0,n.fire("doublePicked",o.pickResult),o.pickedSurface&&n.fire("doublePickedSurface",o.pickResult),i.doublePickFlyTo&&p(o.pickResult)):(n.fire("doublePickedNothing"),i.doublePickFlyTo&&p()),c=-1):d.distVec2(l[0],A)<4&&(sd(a[0],o.pickCursorPos),o.schedulePickEntity=!0,o.schedulePickSurface=u,o.update(),o.pickResult?(o.pickResult.touchInput=!0,n.fire("picked",o.pickResult),o.pickedSurface&&n.fire("pickedSurface",o.pickResult)):n.fire("pickedNothing"),c=t),h=-1),l.length=r.length;for(let e=0,t=r.length;e{e.preventDefault()},this._configs={longTapTimeout:600,longTapRadius:5,active:!0,keyboardLayout:"qwerty",navMode:"orbit",planView:!1,firstPerson:!1,followPointer:!0,doublePickFlyTo:!0,panRightClick:!0,showPivot:!1,pointerEnabled:!0,constrainVertical:!1,smartPivot:!1,doubleClickTimeFrame:250,snapToVertex:true,snapToEdge:true,snapRadius:30,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},this._states={pointerCanvasPos:d.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:d.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},this._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};const i=this.scene;this._controllers={cameraControl:this,pickController:new Nu(this,this._configs),pivotController:new Ou(i,this._configs),panController:new Du(i),cameraFlight:new Zc(this,{duration:.5})},this._handlers=[new $u(this.scene,this._controllers,this._configs,this._states,this._updates),new id(this.scene,this._controllers,this._configs,this._states,this._updates),new Vu(this.scene,this._controllers,this._configs,this._states,this._updates),new Xu(this.scene,this._controllers,this._configs,this._states,this._updates),new Ju(this.scene,this._controllers,this._configs,this._states,this._updates),new rd(this.scene,this._controllers,this._configs,this._states,this._updates),new Yu(this.scene,this._controllers,this._configs,this._states,this._updates)],this._cameraUpdater=new qu(this.scene,this._controllers,this._configs,this._states,this._updates),this.navMode=t.navMode,t.planView&&(this.planView=t.planView),this.constrainVertical=t.constrainVertical,t.keyboardLayout?this.keyboardLayout=t.keyboardLayout:this.keyMap=t.keyMap,this.doublePickFlyTo=t.doublePickFlyTo,this.panRightClick=t.panRightClick,this.active=t.active,this.followPointer=t.followPointer,this.rotationInertia=t.rotationInertia,this.keyboardPanRate=t.keyboardPanRate,this.touchPanRate=t.touchPanRate,this.keyboardRotationRate=t.keyboardRotationRate,this.dragRotationRate=t.dragRotationRate,this.touchDollyRate=t.touchDollyRate,this.dollyInertia=t.dollyInertia,this.dollyProximityThreshold=t.dollyProximityThreshold,this.dollyMinSpeed=t.dollyMinSpeed,this.panInertia=t.panInertia,this.pointerEnabled=!0,this.keyboardDollyRate=t.keyboardDollyRate,this.mouseWheelDollyRate=t.mouseWheelDollyRate}set keyMap(e){if(e=e||"qwerty",y.isString(e)){const t=this.scene.input,i={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":i[this.PAN_LEFT]=[t.KEY_A],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_Z],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_W,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_Q,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6];break;case"azerty":i[this.PAN_LEFT]=[t.KEY_Q],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_W],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_Z,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_A,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6]}this._keyMap=i}else{const t=e;this._keyMap=t}}get keyMap(){return this._keyMap}_isKeyDownForAction(e,t){const i=this._keyMap[e];if(!i)return!1;t||(t=this.scene.input.keyDown);for(let e=0,s=i.length;e0?cd(t):null,n=i&&i.length>0?cd(i):null,a=e=>{if(!e)return;var t=!0;(n&&n[e.type]||o&&!o[e.type])&&(t=!1),t&&s.push(e.id);const i=e.children;if(i)for(var r=0,l=i.length;r>t;i.sort(qh);const s=new Int32Array(e.length);for(let t=0,r=i.length;te[t+1]){let i=e[t];e[t]=e[t+1],e[t+1]=i}$h=new Int32Array(e),t.sort(ec);const i=new Int32Array(e.length);for(let s=0,r=t.length;st){let i=e;e=t,t=i}function i(i,s){return i!==e?e-i:s!==t?t-s:0}let s=0,r=(o.length>>1)-1;for(;s<=r;){const e=r+s>>1,t=i(o[2*e],o[2*e+1]);if(t>0)s=e+1;else{if(!(t<0))return e;r=e-1}}return-s-1}const a=new Int32Array(o.length/2);a.fill(0);const l=s.length/3;if(l>8*(1<u.maxNumPositions&&(u=c()),u.bucketNumber>8)return[e];let p;-1===A[l]&&(A[l]=u.numPositions++,u.positionsCompressed.push(s[3*l]),u.positionsCompressed.push(s[3*l+1]),u.positionsCompressed.push(s[3*l+2])),-1===A[h]&&(A[h]=u.numPositions++,u.positionsCompressed.push(s[3*h]),u.positionsCompressed.push(s[3*h+1]),u.positionsCompressed.push(s[3*h+2])),-1===A[d]&&(A[d]=u.numPositions++,u.positionsCompressed.push(s[3*d]),u.positionsCompressed.push(s[3*d+1]),u.positionsCompressed.push(s[3*d+2])),u.indices.push(A[l]),u.indices.push(A[h]),u.indices.push(A[d]),(p=n(l,h))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]])),(p=n(l,d))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]])),(p=n(h,d))>=0&&0===a[p]&&(a[p]=1,u.edgeIndices.push(A[o[2*p]]),u.edgeIndices.push(A[o[2*p+1]]))}const d=t/8*2,p=t/8,f=2*s.length+(r.length+o.length)*d;let g=0,m=-s.length/3;return h.forEach((e=>{g+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*p,m+=e.positionsCompressed.length/3})),g>f?[e]:(i&&function(e,t){const i={},s={};let r=0;e.forEach((e=>{const t=e.indices,o=e.edgeIndices,n=e.positionsCompressed;for(let e=0,s=t.length;e0){const e=t._meshes;for(let t=0,i=e.length;t0){const e=this._meshes;for(let t=0,i=e.length;t{this._viewMatrixDirty=!0})),this._meshesWithDirtyMatrices=[],this._numMeshesWithDirtyMatrices=0,this._onTick=this.scene.on("tick",(()=>{for(;this._numMeshesWithDirtyMatrices>0;)this._meshesWithDirtyMatrices[--this._numMeshesWithDirtyMatrices]._updateMatrix()})),this._createDefaultTextureSet(),this.visible=t.visible,this.culled=t.culled,this.pickable=t.pickable,this.clippable=t.clippable,this.collidable=t.collidable,this.castsShadow=t.castsShadow,this.receivesShadow=t.receivesShadow,this.xrayed=t.xrayed,this.highlighted=t.highlighted,this.selected=t.selected,this.edges=t.edges,this.colorize=t.colorize,this.opacity=t.opacity,this.backfaces=t.backfaces}_meshMatrixDirty(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}_createDefaultTextureSet(){const e=new Lh({id:"defaultColorTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),t=new Lh({id:"defaultMetalRoughTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),i=new Lh({id:"defaultNormalsTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),s=new Lh({id:"defaultEmissiveTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),r=new Lh({id:"defaultOcclusionTexture",texture:new Qr({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures.defaultColorTexture=e,this._textures.defaultMetalRoughTexture=t,this._textures.defaultNormalsTexture=i,this._textures.defaultEmissiveTexture=s,this._textures.defaultOcclusionTexture=r,this._textureSets.defaultTextureSet=new Rh({id:"defaultTextureSet",model:this,colorTexture:e,metallicRoughnessTexture:t,normalsTexture:i,emissiveTexture:s,occlusionTexture:r})}get isPerformanceModel(){return!0}get transforms(){return this._transforms}get textures(){return this._textures}get textureSets(){return this._textureSets}get meshes(){return this._meshes}get objects(){return this._entities}get origin(){return this._origin}set position(e){this._position.set(e||[0,0,0]),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get position(){return this._position}set rotation(e){this._rotation.set(e||[0,0,0]),d.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get rotation(){return this._rotation}set quaternion(e){this._quaternion.set(e||[0,0,0,1]),d.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get quaternion(){return this._quaternion}set scale(e){}get scale(){return this._scale}set matrix(e){this._matrix.set(e||gc),d.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),d.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),d.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),d.translateMat4v(this._position,this._matrix),this._matrixDirty=!1,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}get matrix(){return this._matrixDirty&&this._rebuildMatrices(),this._matrix}get rotationMatrix(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrix}_rebuildMatrices(){this._matrixDirty&&(d.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),d.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),d.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),d.translateMat4v(this._position,this._matrix),this._matrixDirty=!1)}get rotationMatrixConjugate(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrixConjugate}_setWorldMatrixDirty(){this._matrixDirty=!0,this._aabbDirty=!0}_transformDirty(){this._matrixDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0}_sceneModelDirty(){this.scene._aabbDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._matrixDirty=!0;for(let e=0,t=this._entityList.length;e0}set visible(e){e=!1!==e,this._visible=e;for(let t=0,i=this._entityList.length;t0}set xrayed(e){e=!!e,this._xrayed=e;for(let t=0,i=this._entityList.length;t0}set highlighted(e){e=!!e,this._highlighted=e;for(let t=0,i=this._entityList.length;t0}set selected(e){e=!!e,this._selected=e;for(let t=0,i=this._entityList.length;t0}set edges(e){e=!!e,this._edges=e;for(let t=0,i=this._entityList.length;t0}set pickable(e){e=!1!==e,this._pickable=e;for(let t=0,i=this._entityList.length;t0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){const t=e.colors,i=new Uint8Array(t.length);for(let e=0,s=t.length;e{l.setImage(A,{minFilter:i,magFilter:s,wrapS:r,wrapT:o,wrapR:n,flipY:e.flipY,encoding:a}),this.glRedraw()},A.src=e.src;break;default:this._textureTranscoder?y.loadArraybuffer(e.src,(e=>{e.byteLength?this._textureTranscoder.transcode([e],l).then((()=>{this.glRedraw()})):this.error("[createTexture] Can't create texture from 'src': file data is zero length")}),(function(e){this.error(`[createTexture] Can't create texture from 'src': ${e}`)})):this.error(`[createTexture] Can't create texture from 'src' - SceneModel needs to be configured with a TextureTranscoder for this file type ('${t}')`)}}else e.buffers&&(this._textureTranscoder?this._textureTranscoder.transcode(e.buffers,l).then((()=>{this.glRedraw()})):this.error("[createTexture] Can't create texture from 'buffers' - SceneModel needs to be configured with a TextureTranscoder for this option"));this._textures[t]=new Lh({id:t,texture:l})}createTextureSet(e){const t=e.id;if(null==t)return void this.error("[createTextureSet] Config missing: id");if(this._textureSets[t])return void this.error(`[createTextureSet] Texture set already created: ${t}`);let i,s,r,o,n;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(i=this._textures[e.colorTextureId],!i)return void this.error(`[createTextureSet] Texture not found: ${e.colorTextureId} - ensure that you create it first with createTexture()`)}else i=this._textures.defaultColorTexture;if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(s=this._textures[e.metallicRoughnessTextureId],!s)return void this.error(`[createTextureSet] Texture not found: ${e.metallicRoughnessTextureId} - ensure that you create it first with createTexture()`)}else s=this._textures.defaultMetalRoughTexture;if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(r=this._textures[e.normalsTextureId],!r)return void this.error(`[createTextureSet] Texture not found: ${e.normalsTextureId} - ensure that you create it first with createTexture()`)}else r=this._textures.defaultNormalsTexture;if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(o=this._textures[e.emissiveTextureId],!o)return void this.error(`[createTextureSet] Texture not found: ${e.emissiveTextureId} - ensure that you create it first with createTexture()`)}else o=this._textures.defaultEmissiveTexture;if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(n=this._textures[e.occlusionTextureId],!n)return void this.error(`[createTextureSet] Texture not found: ${e.occlusionTextureId} - ensure that you create it first with createTexture()`)}else n=this._textures.defaultOcclusionTexture;const a=new Rh({id:t,model:this,colorTexture:i,metallicRoughnessTexture:s,normalsTexture:r,emissiveTexture:o,occlusionTexture:n});return this._textureSets[t]=a,a}createTransform(e){if(void 0===e.id||null===e.id)return void this.error("[createTransform] SceneModel.createTransform() config missing: id");if(this._transforms[e.id])return void this.error(`[createTransform] SceneModel already has a transform with this ID: ${e.id}`);let t;if(e.parentTransformId&&(t=this._transforms[e.parentTransformId],!t))return void this.error("[createTransform] SceneModel.createTransform() config missing: id");const i=new Ac({id:e.id,model:this,parent:t,matrix:e.matrix,position:e.position,scale:e.scale,rotation:e.rotation,quaternion:e.quaternion});return this._transforms[i.id]=i,i}createMesh(e){if(void 0===e.id||null===e.id)return this.error("[createMesh] SceneModel.createMesh() config missing: id"),!1;if(this._meshes[e.id])return this.error(`[createMesh] SceneModel already has a mesh with this ID: ${e.id}`),!1;if(!(void 0!==e.geometryId)){if(void 0!==e.primitive&&null!==e.primitive||(e.primitive="triangles"),"points"!==e.primitive&&"lines"!==e.primitive&&"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)return this.error(`Unsupported value for 'primitive': '${primitive}' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.`),!1;if(!e.positions&&!e.positionsCompressed&&!e.buckets)return this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)"),!1;if(e.positions&&(e.positionsDecodeMatrix||e.positionsDecodeBoundary))return this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.positionsCompressed&&!e.positionsDecodeMatrix&&!e.positionsDecodeBoundary)return this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)"),!1;if(e.uvCompressed&&!e.uvDecodeMatrix)return this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)"),!1;if(!(e.buckets||e.indices||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive)){const t=(e.positions||e.positionsCompressed).length/3;e.indices=this._createDefaultIndices(t)}if(!e.buckets&&!e.indices&&"points"!==e.primitive)return e.indices=this._createDefaultIndices(numIndices),this.error(`Param expected: indices (required for '${e.primitive}' primitive type)`),!1;if((e.matrix||e.position||e.rotation||e.scale)&&(e.positionsCompressed||e.positionsDecodeBoundary))return this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'"),!1;const t=!(!this._dtxEnabled||"triangles"!==e.primitive&&"solid"!==e.primitive&&"surface"!==e.primitive||e.textureSetId);if(e.origin=e.origin?d.addVec3(this._origin,e.origin,d.vec3()):this._origin,e.matrix)e.meshMatrix=e.matrix;else if(e.scale||e.rotation||e.position){const t=e.scale||uc,i=e.position||dc,s=e.rotation||pc;d.eulerToQuaternion(s,"XYZ",fc),e.meshMatrix=d.composeMat4(i,fc,t,d.mat4())}if(e.positionsDecodeBoundary&&(e.positionsDecodeMatrix=An(e.positionsDecodeBoundary,d.mat4())),t){if(e.type=2,e.color=e.color?new Uint8Array([Math.floor(255*e.color[0]),Math.floor(255*e.color[1]),Math.floor(255*e.color[2])]):mc,e.opacity=void 0!==e.opacity&&null!==e.opacity?Math.floor(255*e.opacity):255,e.positions){const t=d.vec3(),i=[];J(e.positions,i,t)&&(e.positions=i,e.origin=d.addVec3(e.origin,t,t))}if(e.positions){const t=d.collapseAABB3();e.positionsDecodeMatrix=d.mat4(),d.expandAABB3Points3(t,e.positions),e.positionsCompressed=ln(e.positions,t,e.positionsDecodeMatrix),e.aabb=t}else if(e.positionsCompressed){const t=d.collapseAABB3();d.expandAABB3Points3(t,e.positionsCompressed),Vt.decompressAABB(t,e.positionsDecodeMatrix),e.aabb=t}if(e.buckets){const t=d.collapseAABB3();for(let i=0,s=e.buckets.length;i>24&255,r=i>>16&255,o=i>>8&255,n=255&i;switch(e.pickColor=new Uint8Array([n,o,r,s]),e.solid="solid"===e.primitive,t.origin=d.vec3(e.origin),e.type){case 2:t.layer=this._getDTXLayer(e),t.aabb=e.aabb;break;case 1:t.layer=this._getVBOBatchingLayer(e),t.aabb=e.aabb;break;case 0:t.layer=this._getVBOInstancingLayer(e),t.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),t.portionId=t.layer.createPortion(t,e),this._meshes[e.id]=t,this._unusedMeshes[e.id]=t,this._meshList.push(t),t}_getNumPrimitives(e){let t=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(let i=0,s=e.buckets.length;i>>0).toString(16)}_getVBOInstancingLayer(e){const t=this,i=e.origin,s=e.textureSetId||"-",r=e.geometryId,o=`${Math.round(i[0])}.${Math.round(i[1])}.${Math.round(i[2])}.${s}.${r}`;let n=this._vboInstancingLayers[o];if(n)return n;let a=e.textureSet;const l=e.geometry;for(;!n;)switch(l.primitive){case"triangles":case"surface":n=new da({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!1});break;case"solid":n=new da({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!0});break;case"lines":n=new qa({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0});break;case"points":n=new zl({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0})}return this._vboInstancingLayers[o]=n,this.layerList.push(n),n}createEntity(e){if(void 0===e.id?e.id=d.createUUID():this.scene.components[e.id]&&(this.error(`Scene already has a Component with this ID: ${e.id} - will assign random ID`),e.id=d.createUUID()),void 0===e.meshIds)return void this.error("Config missing: meshIds");let t=0;this._visible&&!1!==e.visible&&(t|=q),this._pickable&&!1!==e.pickable&&(t|=ee),this._culled&&!1!==e.culled&&(t|=$),this._clippable&&!1!==e.clippable&&(t|=te),this._collidable&&!1!==e.collidable&&(t|=ie),this._edges&&!1!==e.edges&&(t|=ne),this._xrayed&&!1!==e.xrayed&&(t|=se),this._highlighted&&!1!==e.highlighted&&(t|=re),this._selected&&!1!==e.selected&&(t|=oe),e.flags=t,this._createEntity(e)}_createEntity(e){let t=[];for(let i=0,s=e.meshIds.length;ie.sortIdt.sortId?1:0));for(let e=0,t=this.layerList.length;e0&&0===this.renderFlags.numVisibleLayers?this.renderFlags.culled=!0:this._updateRenderFlags()}_updateRenderFlagsVisibleLayers(){const e=this.renderFlags;e.numLayers=this.layerList.length,e.numVisibleLayers=0;for(let t=0,i=this.layerList.length;t0){const t=`${this.id}-dummyEntityForUnusedMeshes`;this.warn(`Creating dummy SceneModelEntity "${t}" for unused SceneMeshes: [${e.join(",")}]`),this.createEntity({id:t,meshIds:e,isObject:!0})}this._unusedMeshes={}}_getActiveSectionPlanesForLayer(e){const t=this.renderFlags,i=this.scene._sectionPlanesState.sectionPlanes,s=i.length,r=e.layerIndex*s;if(s>0)for(let e=0;e0&&(e.colorTransparent=!0),this.numXRayedLayerPortions>0){const t=this.scene.xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}if(this.numEdgesLayerPortions>0){this.scene.edgeMaterial._state.edges&&(e.edgesOpaque=this.numTransparentLayerPortions0&&(e.edgesTransparent=!0))}if(this.numSelectedLayerPortions>0){const t=this.scene.selectedMaterial._state;t.fill&&(t.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){const t=this.scene.highlightMaterial._state;t.fill&&(t.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}drawColorOpaque(e){const t=this.renderFlags;for(let i=0,s=t.visibleLayers.length;i65536?16:8)}else n=[{positionsCompressed:s,indices:r,edgeIndices:o}];return n}class bc extends R{constructor(e,t={}){if(super(e,t),this._positions=t.positions||[],t.indices)this._indices=t.indices;else{this._indices=[];for(let e=0,t=this._positions.length/3-1;ep.has(e.id)||g.has(e.id)||f.has(e.id))).reduce(((e,i)=>{let s,r=function(e){let t="";return t+=Math.round(255*e[0]).toString(16).padStart(2,"0"),t+=Math.round(255*e[1]).toString(16).padStart(2,"0"),t+=Math.round(255*e[2]).toString(16).padStart(2,"0"),t}(i.colorize);i.xrayed?(s=0===t.xrayMaterial.fillAlpha&&0!==t.xrayMaterial.edgeAlpha?.1:t.xrayMaterial.fillAlpha,s=Math.round(255*s).toString(16).padStart(2,"0"),r=s+r):p.has(i.id)&&(s=Math.round(255*i.opacity).toString(16).padStart(2,"0"),r=s+r),e[r]||(e[r]=[]);const o=i.id,n=i.originalSystemId,a={ifc_guid:n,originating_system:this.originatingSystem};return n!==o&&(a.authoring_tool_id=o),e[r].push(a),e}),{}),_=Object.entries(m).map((([e,t])=>({color:e,components:t})));o.components.coloring=_;const v=t.objectIds,b=t.visibleObjects,y=t.visibleObjectIds,B=v.filter((e=>!b[e])),x=t.selectedObjectIds;return e.defaultInvisible||y.length0&&e.clipping_planes.forEach((function(e){let t=Mc(e.location,yc),i=Mc(e.direction,yc);A&&d.negateVec3(i),d.subVec3(t,l),r.yUp&&(t=Ec(t),i=Ec(i)),new br(s,{pos:t,dir:i})})),s.clearLines(),e.lines&&e.lines.length>0){const t=[],i=[];let r=0;e.lines.forEach((e=>{e.start_point&&e.end_point&&(t.push(e.start_point.x),t.push(e.start_point.y),t.push(e.start_point.z),t.push(e.end_point.x),t.push(e.end_point.y),t.push(e.end_point.z),i.push(r++),i.push(r++))})),new bc(s,{positions:t,indices:i,clippable:!1,collidable:!0})}if(s.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){const t=e.bitmap_type||"jpg",i=e.bitmap_data;let o=Mc(e.location,Bc),n=Mc(e.normal,xc),a=Mc(e.up,wc),l=e.height||1;t&&i&&o&&n&&a&&(r.yUp&&(o=Ec(o),n=Ec(n),a=Ec(a)),new ao(s,{src:i,type:t,pos:o,normal:n,up:a,clippable:!1,collidable:!0,height:l}))})),a&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),s.setObjectsHighlighted(s.highlightedObjectIds,!1),s.setObjectsSelected(s.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(s.setObjectsVisible(s.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!1))))):(s.setObjectsVisible(s.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((e=>this._withBCFComponent(t,e,(e=>e.visible=!0)))));const r=e.components.visibility.view_setup_hints;r&&(!1===r.spaces_visible&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcSpace"),!0),void 0!==r.spaces_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcSpace"),!0),r.space_boundaries_visible,!1===r.openings_visible&&s.setObjectsVisible(i.metaScene.getObjectIDsByType("IfcOpening"),!0),r.space_boundaries_translucent,void 0!==r.openings_translucent&&s.setObjectsXRayed(i.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(s.setObjectsSelected(s.selectedObjectIds,!1),e.components.selection.forEach((e=>this._withBCFComponent(t,e,(e=>e.selected=!0))))),e.components.translucency&&(s.setObjectsXRayed(s.xrayedObjectIds,!1),e.components.translucency.forEach((e=>this._withBCFComponent(t,e,(e=>e.xrayed=!0))))),e.components.coloring&&e.components.coloring.forEach((e=>{let i=e.color,s=0,r=!1;8===i.length&&(s=parseInt(i.substring(0,2),16)/256,s<=1&&s>=.95&&(s=1),i=i.substring(2),r=!0);const o=[parseInt(i.substring(0,2),16)/256,parseInt(i.substring(2,4),16)/256,parseInt(i.substring(4,6),16)/256];e.components.map((e=>this._withBCFComponent(t,e,(e=>{e.colorize=o,r&&(e.opacity=s)}))))}))}if(e.perspective_camera||e.orthogonal_camera){let a,A,h,c;if(e.perspective_camera?(a=Mc(e.perspective_camera.camera_view_point,yc),A=Mc(e.perspective_camera.camera_direction,yc),h=Mc(e.perspective_camera.camera_up_vector,yc),r.perspective.fov=e.perspective_camera.field_of_view,c="perspective"):(a=Mc(e.orthogonal_camera.camera_view_point,yc),A=Mc(e.orthogonal_camera.camera_direction,yc),h=Mc(e.orthogonal_camera.camera_up_vector,yc),r.ortho.scale=e.orthogonal_camera.view_to_world_scale,c="ortho"),d.subVec3(a,l),r.yUp&&(a=Ec(a),A=Ec(A),h=Ec(h)),o){const e=s.pick({pickSurface:!0,origin:a,direction:A});A=e?e.worldPos:d.addVec3(a,A,yc)}else A=d.addVec3(a,A,yc);n?(r.eye=a,r.look=A,r.up=h,r.projection=c):i.cameraFlight.flyTo({eye:a,look:A,up:h,duration:t.duration,projection:c})}}_withBCFComponent(e,t,i){const s=this.viewer,r=s.scene;if(t.authoring_tool_id&&t.originating_system===this.originatingSystem){const o=t.authoring_tool_id,n=r.objects[o];if(n)return void i(n);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[o])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(o),i)}}if(t.ifc_guid){const o=t.ifc_guid,n=r.objects[o];if(n)return void i(n);if(e.updateCompositeObjects){if(s.metaScene.metaObjects[o])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(o),i)}Object.keys(r.models).forEach((t=>{const n=d.globalizeObjectId(t,o),a=r.objects[n];if(a)i(a);else if(e.updateCompositeObjects){s.metaScene.metaObjects[n]&&r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}}))}}destroy(){super.destroy()}}function Cc(e){return{x:e[0],y:e[1],z:e[2]}}function Mc(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function Fc(e){return new Float64Array([e[0],-e[2],e[1]])}function Ec(e){return new Float64Array([e[0],e[2],-e[1]])}const Ic=d.vec3(),Dc=(e,t,i,s)=>{var r=e-i,o=t-s;return Math.sqrt(r*r+o*o)};class Sc extends R{constructor(e,t={}){if(super(e.viewer.scene,t),this.plugin=e,this._container=t.container,!this._container)throw"config missing: container";this._eventSubs={};var i=this.plugin.viewer.scene;this._originMarker=new ue(i,t.origin),this._targetMarker=new ue(i,t.target),this._originWorld=d.vec3(),this._targetWorld=d.vec3(),this._wp=new Float64Array(24),this._vp=new Float64Array(24),this._pp=new Float64Array(24),this._cp=new Float64Array(8),this._xAxisLabelCulled=!1,this._yAxisLabelCulled=!1,this._zAxisLabelCulled=!1,this._color=t.color||this.plugin.defaultColor;const s=t.onMouseOver?e=>{t.onMouseOver(e,this),this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,r=t.onMouseLeave?e=>{t.onMouseLeave(e,this),this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,o=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},n=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},a=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},l=t.onContextMenu?e=>{t.onContextMenu(e,this)}:null,A=e=>{this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};this._originDot=new pe(this._container,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._targetDot=new pe(this._container,{fillColor:this._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._lengthWire=new de(this._container,{color:this._color,thickness:2,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._xAxisWire=new de(this._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._yAxisWire=new de(this._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._zAxisWire=new de(this._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._lengthLabel=new fe(this._container,{fillColor:this._color,prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._xAxisLabel=new fe(this._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._yAxisLabel=new fe(this._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._zAxisLabel=new fe(this._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:s,onMouseLeave:r,onMouseWheel:A,onMouseDown:o,onMouseUp:n,onMouseMove:a,onContextMenu:l}),this._wpDirty=!1,this._vpDirty=!1,this._cpDirty=!1,this._sectionPlanesDirty=!0,this._visible=!1,this._originVisible=!1,this._targetVisible=!1,this._wireVisible=!1,this._axisVisible=!1,this._xAxisVisible=!1,this._yAxisVisible=!1,this._zAxisVisible=!1,this._axisEnabled=!0,this._labelsVisible=!1,this._labelsOnWires=!1,this._clickable=!1,this._originMarker.on("worldPos",(e=>{this._originWorld.set(e||[0,0,0]),this._wpDirty=!0,this._needUpdate(0)})),this._targetMarker.on("worldPos",(e=>{this._targetWorld.set(e||[0,0,0]),this._wpDirty=!0,this._needUpdate(0)})),this._onViewMatrix=i.camera.on("viewMatrix",(()=>{this._vpDirty=!0,this._needUpdate(0)})),this._onProjMatrix=i.camera.on("projMatrix",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onCanvasBoundary=i.canvas.on("boundary",(()=>{this._cpDirty=!0,this._needUpdate(0)})),this._onMetricsUnits=i.metrics.on("units",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onMetricsScale=i.metrics.on("scale",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onMetricsOrigin=i.metrics.on("origin",(()=>{this._cpDirty=!0,this._needUpdate()})),this._onSectionPlaneUpdated=i.on("sectionPlaneUpdated",(()=>{this._sectionPlanesDirty=!0,this._needUpdate()})),this.approximate=t.approximate,this.visible=t.visible,this.originVisible=t.originVisible,this.targetVisible=t.targetVisible,this.wireVisible=t.wireVisible,this.axisVisible=t.axisVisible,this.xAxisVisible=t.xAxisVisible,this.yAxisVisible=t.yAxisVisible,this.zAxisVisible=t.zAxisVisible,this.labelsVisible=t.labelsVisible,this.labelsOnWires=t.labelsOnWires}_update(){if(!this._visible)return;const e=this.plugin.viewer.scene;if(this._wpDirty&&(this._wp[0]=this._originWorld[0],this._wp[1]=this._originWorld[1],this._wp[2]=this._originWorld[2],this._wp[3]=1,this._wp[4]=this._targetWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._targetWorld[0],this._wp[9]=this._targetWorld[1],this._wp[10]=this._originWorld[2],this._wp[11]=1,this._wp[12]=this._targetWorld[0],this._wp[13]=this._targetWorld[1],this._wp[14]=this._targetWorld[2],this._wp[15]=1,this._wpDirty=!1,this._vpDirty=!0),this._vpDirty&&(d.transformPositions4(e.camera.viewMatrix,this._wp,this._vp),this._vp[3]=1,this._vp[7]=1,this._vp[11]=1,this._vp[15]=1,this._vpDirty=!1,this._cpDirty=!0),this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld))return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setCulled(!0),this._yAxisWire.setCulled(!0),this._zAxisWire.setCulled(!0),this._lengthWire.setCulled(!0),this._originDot.setCulled(!0),void this._targetDot.setCulled(!0);this._xAxisLabel.setCulled(!1),this._yAxisLabel.setCulled(!1),this._zAxisLabel.setCulled(!1),this._lengthLabel.setCulled(!1),this._xAxisWire.setCulled(!1),this._yAxisWire.setCulled(!1),this._zAxisWire.setCulled(!1),this._lengthWire.setCulled(!1),this._originDot.setCulled(!1),this._targetDot.setCulled(!1),this._sectionPlanesDirty=!0}const t=this._originMarker.viewPos[2],i=this._targetMarker.viewPos[2];if(t>-.3||i>-.3)return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setVisible(!1),this._yAxisWire.setVisible(!1),this._zAxisWire.setVisible(!1),this._lengthWire.setVisible(!1),this._originDot.setVisible(!1),void this._targetDot.setVisible(!1);if(this._cpDirty){d.transformPositions4(e.camera.project.matrix,this._vp,this._pp);var s=this._pp,r=this._cp,o=e.canvas.canvas.getBoundingClientRect();const t=this._container.getBoundingClientRect();var n=o.top-t.top,a=o.left-t.left,l=e.canvas.boundary,A=l[2],h=l[3],c=0;const i=this.plugin.viewer.scene.metrics,f=i.scale,g=i.units,m=i.unitsInfo[g].abbrev;for(var u=0,p=s.length;ue.offsetTop+(e.offsetParent&&h(e.offsetParent)),c=e=>e.offsetLeft+(e.offsetParent&&c(e.offsetParent)),u=d.vec2();this._onCameraControlHoverSnapOrSurface=i.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(e=>{const t=e.snappedCanvasPos||e.canvasPos;r=!0,o.set(e.worldPos),n.set(e.canvasPos),0===this._mouseState?(this._canvasToPagePos?(this._canvasToPagePos(s,t,u),this._markerDiv.style.left=u[0]-5+"px",this._markerDiv.style.top=u[1]-5+"px"):(this._markerDiv.style.left=c(s)+t[0]-5+"px",this._markerDiv.style.top=h(s)+t[1]-5+"px"),this._markerDiv.style.background="pink",e.snappedToVertex||e.snappedToEdge?(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos,this.pointerLens.snapped=!0),this._markerDiv.style.background="greenyellow",this._markerDiv.style.border="2px solid green"):(this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.canvasPos,this.pointerLens.snapped=!1),this._markerDiv.style.background="pink",this._markerDiv.style.border="2px solid red"),A=e.entity):(this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px"),s.style.cursor="pointer",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=this._currentDistanceMeasurementInitState.wireVisible,this._currentDistanceMeasurement.axisVisible=this._currentDistanceMeasurementInitState.axisVisible&&this.distanceMeasurementsPlugin.defaultAxisVisible,this._currentDistanceMeasurement.xAxisVisible=this._currentDistanceMeasurementInitState.xAxisVisible&&this.distanceMeasurementsPlugin.defaultXAxisVisible,this._currentDistanceMeasurement.yAxisVisible=this._currentDistanceMeasurementInitState.yAxisVisible&&this.distanceMeasurementsPlugin.defaultYAxisVisible,this._currentDistanceMeasurement.zAxisVisible=this._currentDistanceMeasurementInitState.zAxisVisible&&this.distanceMeasurementsPlugin.defaultZAxisVisible,this._currentDistanceMeasurement.targetVisible=this._currentDistanceMeasurementInitState.targetVisible,this._currentDistanceMeasurement.target.worldPos=o.slice(),this._markerDiv.style.left="-10000px",this._markerDiv.style.top="-10000px")})),s.addEventListener("mousedown",this._onMouseDown=e=>{1===e.which&&(a=e.clientX,l=e.clientY)}),s.addEventListener("mouseup",this._onMouseUp=t=>{1===t.which&&(t.clientX>a+20||t.clientXl+20||t.clientY{this.pointerLens&&(this.pointerLens.visible=!0,this.pointerLens.canvasPos=e.canvasPos,this.pointerLens.snappedCanvasPos=e.snappedCanvasPos||e.canvasPos),r=!1,this._markerDiv.style.left="-100px",this._markerDiv.style.top="-100px",this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.axisVisible=!1),s.style.cursor="default"})),this._active=!0}deactivate(){if(!this._active)return;this.fire("activated",!1),this.pointerLens&&(this.pointerLens.visible=!1),this._markerDiv&&this._destroyMarkerDiv(),this.reset();const e=this.scene.canvas.canvas;e.removeEventListener("mousedown",this._onMouseDown),e.removeEventListener("mouseup",this._onMouseUp);const t=this.distanceMeasurementsPlugin.viewer.cameraControl;t.off(this._onCameraControlHoverSnapOrSurface),t.off(this._onCameraControlHoverSnapOrSurfaceOff),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),this._active=!1}reset(){this._active&&(this._destroyMarkerDiv(),this._initMarkerDiv(),this._currentDistanceMeasurement&&(this.distanceMeasurementsPlugin.fire("measurementCancel",this._currentDistanceMeasurement),this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null))}destroy(){this.deactivate(),super.destroy()}}class Lc extends z{constructor(e,t={}){super("DistanceMeasurements",e),this._pointerLens=t.pointerLens,this._container=t.container||document.body,this._defaultControl=null,this._measurements={},this.labelMinAxisLength=t.labelMinAxisLength,this.defaultVisible=!1!==t.defaultVisible,this.defaultOriginVisible=!1!==t.defaultOriginVisible,this.defaultTargetVisible=!1!==t.defaultTargetVisible,this.defaultWireVisible=!1!==t.defaultWireVisible,this.defaultLabelsVisible=!1!==t.defaultLabelsVisible,this.defaultAxisVisible=!1!==t.defaultAxisVisible,this.defaultXAxisVisible=!1!==t.defaultXAxisVisible,this.defaultYAxisVisible=!1!==t.defaultYAxisVisible,this.defaultZAxisVisible=!1!==t.defaultZAxisVisible,this.defaultColor=void 0!==t.defaultColor?t.defaultColor:"#00BBFF",this.zIndex=t.zIndex||1e4,this.defaultLabelsOnWires=!1!==t.defaultLabelsOnWires,this._onMouseOver=(e,t)=>{this.fire("mouseOver",{plugin:this,distanceMeasurement:t,measurement:t,event:e})},this._onMouseLeave=(e,t)=>{this.fire("mouseLeave",{plugin:this,distanceMeasurement:t,measurement:t,event:e})},this._onContextMenu=(e,t)=>{this.fire("contextMenu",{plugin:this,distanceMeasurement:t,measurement:t,event:e})}}getContainerElement(){return this._container}send(e,t){}get pointerLens(){return this._pointerLens}get control(){return this._defaultControl||(this._defaultControl=new Rc(this,{})),this._defaultControl}get measurements(){return this._measurements}set labelMinAxisLength(e){e<1&&(this.error("labelMinAxisLength must be >= 1; defaulting to 25"),e=25),this._labelMinAxisLength=e||25}get labelMinAxisLength(){return this._labelMinAxisLength}createMeasurement(e={}){this.viewer.scene.components[e.id]&&(this.error("Viewer scene component with this ID already exists: "+e.id),delete e.id);const t=e.origin,i=e.target,s=new Sc(this,{id:e.id,plugin:this,container:this._container,origin:{entity:t.entity,worldPos:t.worldPos},target:{entity:i.entity,worldPos:i.worldPos},visible:e.visible,wireVisible:e.wireVisible,axisVisible:!1!==e.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==e.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==e.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==e.zAxisVisible&&!1!==this.defaultZAxisVisible,labelsVisible:!1!==e.labelsVisible&&!1!==this.defaultLabelsVisible,originVisible:e.originVisible,targetVisible:e.targetVisible,color:e.color,labelsOnWires:!1!==e.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[s.id]=s,s.on("destroyed",(()=>{delete this._measurements[s.id]})),this.fire("measurementCreated",s),s}destroyMeasurement(e){const t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("DistanceMeasurement not found: "+e)}setLabelsShown(e){for(const[t,i]of Object.entries(this.measurements))i.labelShown=e}setAxisVisible(e){for(const[t,i]of Object.entries(this.measurements))i.axisVisible=e;this.defaultAxisVisible=e}getAxisVisible(){return this.defaultAxisVisible}clear(){const e=Object.keys(this._measurements);for(var t=0,i=e.length;t{this.plugin.viewer.cameraControl.active=!1},c=()=>{this.plugin.viewer.cameraControl.active=!0},u=()=>{o&&(clearTimeout(o),o=null),this._currentDistanceMeasurement&&(this._currentDistanceMeasurement.destroy(),this._currentDistanceMeasurement=null),c(),this._touchState=0};i.addEventListener("touchstart",this._onCanvasTouchStart=i=>{const l=i.touches.length;if(1!==l)return void(o&&(clearTimeout(o),o=null));const c=i.touches[0],p=c.clientX,f=c.clientY;switch(n.set([p,f]),a.set([p,f]),this._touchState){case 0:if(1!==l&&null!==o)return void u();const i=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge});if(i&&i.snapped)s.set(i.worldPos),this.pointerCircle.start(i.snappedCanvasPos);else{const e=t.pick({canvasPos:a,pickSurface:!0});if(!e||!e.worldPos)return;s.set(e.worldPos),this.pointerCircle.start(e.canvasPos)}o=setTimeout((()=>{1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{if(o=null,1!==l||a[0]>n[0]+r||a[0]n[1]+r||a[1]{this.pointerCircle.stop();const r=i.touches.length;if(1!==r||1!==i.changedTouches.length)return void(o&&(clearTimeout(o),o=null));const n=i.touches[0],l=n.clientX,h=n.clientY;if(n.identifier!==A)return;let c,u;switch(a.set([l,h]),this._touchState){case 2:this.pointerLens&&(this.pointerLens.canvasPos=a),c=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),c&&c.snapped?(this.pointerLens&&(this.pointerLens.snappedCanvasPos=c.snappedCanvasPos,this.pointerLens.snapped=!0),s.set(c.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=c.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:d.createUUID(),origin:{worldPos:c.worldPos,entity:c.entity},target:{worldPos:c.worldPos,entity:c.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):(u=t.pick({canvasPos:a,pickSurface:!0}),u&&u.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=u.canvasPos,this.pointerLens.snapped=!1),s.set(u.worldPos),this._currentDistanceMeasurement?this._currentDistanceMeasurement.origin.worldPos=u.worldPos:(this._currentDistanceMeasurement=e.createMeasurement({id:d.createUUID(),origin:{worldPos:u.worldPos,entity:u.entity},target:{worldPos:u.worldPos,entity:u.entity}}),this._currentDistanceMeasurement.labelsVisible=!1,this._currentDistanceMeasurement.xAxisVisible=!1,this._currentDistanceMeasurement.yAxisVisible=!1,this._currentDistanceMeasurement.zAxisVisible=!1,this._currentDistanceMeasurement.wireVisible=!1,this._currentDistanceMeasurement.originVisible=!0,this._currentDistanceMeasurement.targetVisible=!1,this._currentDistanceMeasurement.clickable=!1),this.distanceMeasurementsPlugin.fire("measurementStart",this._currentDistanceMeasurement)):this.pointerLens&&(this.pointerLens.cursorPos=null,this.pointerLens.snapped=!1)),this._touchState=2;break;case 5:if(1!==r&&null!==o)return clearTimeout(o),o=null,this.pointerLens&&(this.pointerLens.visible=!1),void(this._touchState=7);this.pointerLens&&(this.pointerLens.canvasPos=a),c=t.pick({canvasPos:a,snapToVertex:this._snapToVertex,snapToEdge:this._snapToEdge}),c&&c.worldPos?(this.pointerLens&&(this.pointerLens.cursorPos=c.snappedCanvasPos,this.pointerLens.snapped=!0),this._currentDistanceMeasurement.target.worldPos=c.worldPos,this._currentDistanceMeasurement.target.entity=c.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0):(u=t.pick({canvasPos:a,pickSurface:!0}),u&&u.worldPos&&(this.pointerLens&&(this.pointerLens.cursorPos=u.canvasPos,this.pointerLens.snapped=!1),this._currentDistanceMeasurement.target.worldPos=u.worldPos,this._currentDistanceMeasurement.target.entity=u.entity,this._currentDistanceMeasurement.targetVisible=!0,this._currentDistanceMeasurement.wireVisible=!0,this._currentDistanceMeasurement.labelsVisible=!0)),this._touchState=5}}),{passive:!0}),i.addEventListener("touchend",this._onCanvasTouchEnd=i=>{this.pointerCircle.stop();const s=i.changedTouches.length;if(1!==s)return;const h=i.changedTouches[0],u=h.clientX,p=h.clientY;if(h.identifier===A)switch(o&&(clearTimeout(o),o=null),l.set([u,p]),this._touchState){case 1:{if(1!==s||u>n[0]+r||un[1]+r||pn[0]+r||un[1]+r||p{i=1e3*this._delayBeforeRestoreSeconds,s||(e.scene._renderer.setColorTextureEnabled(!this._hideColorTexture),e.scene._renderer.setPBREnabled(!this._hidePBR),e.scene._renderer.setSAOEnabled(!this._hideSAO),e.scene._renderer.setTransparentEnabled(!this._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!this._hideEdges),this._scaleCanvasResolution?e.scene.canvas.resolutionScale=this._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=this._defaultScaleCanvasResolutionFactor,s=!0)},o=()=>{e.scene.canvas.resolutionScale=this._defaultScaleCanvasResolutionFactor,e.scene._renderer.setEdgesEnabled(!0),e.scene._renderer.setColorTextureEnabled(!0),e.scene._renderer.setPBREnabled(!0),e.scene._renderer.setSAOEnabled(!0),e.scene._renderer.setTransparentEnabled(!0),s=!1};this._onCanvasBoundary=e.scene.canvas.on("boundary",r),this._onCameraMatrix=e.scene.camera.on("matrix",r),this._onSceneTick=e.scene.on("tick",(e=>{s&&(i-=e.deltaTime,(!this._delayBeforeRestore||i<=0)&&o())}));let n=!1;this._onSceneMouseDown=e.scene.input.on("mousedown",(()=>{n=!0})),this._onSceneMouseUp=e.scene.input.on("mouseup",(()=>{n=!1})),this._onSceneMouseMove=e.scene.input.on("mousemove",(()=>{n&&r()}))}get hideColorTexture(){return this._hideColorTexture}set hideColorTexture(e){this._hideColorTexture=e}get hidePBR(){return this._hidePBR}set hidePBR(e){this._hidePBR=e}get hideSAO(){return this._hideSAO}set hideSAO(e){this._hideSAO=e}get hideEdges(){return this._hideEdges}set hideEdges(e){this._hideEdges=e}get hideTransparentObjects(){return this._hideTransparentObjects}set hideTransparentObjects(e){this._hideTransparentObjects=!1!==e}get scaleCanvasResolution(){return this._scaleCanvasResolution}set scaleCanvasResolution(e){this._scaleCanvasResolution=e}get defaultScaleCanvasResolutionFactor(){return this._defaultScaleCanvasResolutionFactor}set defaultScaleCanvasResolutionFactor(e){this._defaultScaleCanvasResolutionFactor=e||1}get scaleCanvasResolutionFactor(){return this._scaleCanvasResolutionFactor}set scaleCanvasResolutionFactor(e){this._scaleCanvasResolutionFactor=e||.6}get delayBeforeRestore(){return this._delayBeforeRestore}set delayBeforeRestore(e){this._delayBeforeRestore=e}get delayBeforeRestoreSeconds(){return this._delayBeforeRestoreSeconds}set delayBeforeRestoreSeconds(e){this._delayBeforeRestoreSeconds=null!=e?e:.5}send(e,t){}destroy(){this.viewer.scene.camera.off(this._onCameraMatrix),this.viewer.scene.canvas.off(this._onCanvasBoundary),this.viewer.scene.input.off(this._onSceneMouseDown),this.viewer.scene.input.off(this._onSceneMouseUp),this.viewer.scene.input.off(this._onSceneMouseMove),this.viewer.scene.off(this._onSceneTick),super.destroy()}}class Oc{constructor(){}getMetaModel(e,t,i){y.loadJSON(e,(e=>{t(e)}),(function(e){i(e)}))}getGLTF(e,t,i){y.loadArraybuffer(e,(e=>{t(e)}),(function(e){i(e)}))}getGLB(e,t,i){y.loadArraybuffer(e,(e=>{t(e)}),(function(e){i(e)}))}getArrayBuffer(e,t,i,s){!function(e,t,i,s){var r=()=>{};i=i||r,s=s||r;const o=/^data:(.*?)(;base64)?,(.*)$/,n=t.match(o);if(n){const e=!!n[2];var a=n[3];a=window.decodeURIComponent(a),e&&(a=window.atob(a));try{const e=new ArrayBuffer(a.length),t=new Uint8Array(e);for(var l=0;l{i(e)}),(function(e){s(e)}))}}class Nc{constructor(e={}){this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=e.messages,this.locale=e.locale}set messages(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}loadMessages(e={}){for(let t in e)this._messages[t]=e[t];this.messages=this._messages}clearMessages(){this.messages={}}get locales(){return this._locales}set locale(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}get locale(){return this._locale}translate(e,t){const i=this._messages[this._locale];if(!i)return null;const s=Qc(e,i);return s?t?Vc(s,t):s:null}translatePlurals(e,t,i){const s=this._messages[this._locale];if(!s)return null;let r=Qc(e,s);return r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one,r?(r=Vc(r,[t]),i&&(r=Vc(r,i)),r):null}fire(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);const s=this._eventSubs[e];if(s)for(const e in s)if(s.hasOwnProperty(e)){s[e].callback(t)}}on(t,i){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new e),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});let s=this._eventSubs[t];s||(s={},this._eventSubs[t]=s);const r=this._eventSubIDMap.addItem();s[r]={callback:i},this._eventSubEvents[r]=t;const o=this._events[t];return void 0!==o&&i(o),r}off(e){if(null==e)return;if(!this._eventSubEvents)return;const t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];const i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}function Qc(e,t){if(t[e])return t[e];const i=e.split(".");let s=t;for(let e=0,t=i.length;s&&e1?1:e}get t(){return this._t}get tangent(){return this.getTangent(this._t)}get length(){var e=this._getLengths();return e[e.length-1]}getTangent(e){var t=1e-4;void 0===e&&(e=this._t);var i=e-t,s=e+t;i<0&&(i=0),s>1&&(s=1);var r=this.getPoint(i),o=this.getPoint(s),n=d.subVec3(o,r,[]);return d.normalizeVec3(n,[])}getPointAt(e){var t=this.getUToTMapping(e);return this.getPoint(t)}getPoints(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}_getLengths(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,s=[],r=this.getPoint(0),o=0;for(s.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),o+=d.lenVec3(d.subVec3(t,r,[])),s.push(o),r=t;return this.cacheArcLengths=s,s}_updateArcLengths(){this.needsUpdate=!0,this._getLengths()}getUToTMapping(e,t){var i,s=this._getLengths(),r=0,o=s.length;i=t||e*s[o-1];for(var n,a=0,l=o-1;a<=l;)if((n=s[r=Math.floor(a+(l-a)/2)]-i)<0)a=r+1;else{if(!(n>0)){l=r;break}l=r-1}if(s[r=l]===i)return r/(o-1);var A=s[r];return(r+(i-A)/(s[r+1]-A))/(o-1)}}class jc extends Hc{constructor(e,t={}){super(e,t),this.points=t.points,this.t=t.t}set points(e){this._points=e||[]}get points(){return this._points}set t(e){e=e||0,this._t=e<0?0:e>1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=this.points;if(!(t.length<3)){var i=(t.length-1)*e,s=Math.floor(i),r=i-s,o=t[0===s?s:s-1],n=t[s],a=t[s>t.length-2?t.length-1:s+1],l=t[s>t.length-3?t.length-1:s+2],A=d.vec3();return A[0]=d.catmullRomInterpolate(o[0],n[0],a[0],l[0],r),A[1]=d.catmullRomInterpolate(o[1],n[1],a[1],l[1],r),A[2]=d.catmullRomInterpolate(o[2],n[2],a[2],l[2],r),A}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}getJSON(){return{points:points,t:this._t}}}const Gc=d.vec3();class zc extends R{get type(){return"CameraPath"}constructor(e,t={}){super(e,t),this._frames=[],this._eyeCurve=new jc(this),this._lookCurve=new jc(this),this._upCurve=new jc(this),t.frames&&(this.addFrames(t.frames),this.smoothFrameTimes(1))}get frames(){return this._frames}get eyeCurve(){return this._eyeCurve}get lookCurve(){return this._lookCurve}get upCurve(){return this._upCurve}saveFrame(e){const t=this.scene.camera;this.addFrame(e,t.eye,t.look,t.up)}addFrame(e,t,i,s){const r={t:e,eye:t.slice(0),look:i.slice(0),up:s.slice(0)};this._frames.push(r),this._eyeCurve.points.push(r.eye),this._lookCurve.points.push(r.look),this._upCurve.points.push(r.up)}addFrames(e){let t;for(let i=0,s=e.length;i1?1:e,t.eye=this._eyeCurve.getPoint(e,Gc),t.look=this._lookCurve.getPoint(e,Gc),t.up=this._upCurve.getPoint(e,Gc)}sampleFrame(e,t,i,s){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,s)}smoothFrameTimes(e){if(0===this._frames.length)return;const t=d.vec3();var i=0;this._frames[0].t=0;const s=[];for(let e=1,o=this._frames.length;e=1;e>1&&(e=1);const i=this.easing?Zc._ease(e,0,1,1):e,s=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?(d.subVec3(s.eye,s.look,Yc),s.eye=d.lerpVec3(i,0,1,this._eye1,this._eye2,Xc),s.look=d.subVec3(Xc,Yc,Kc)):this._flyingLook&&(s.look=d.lerpVec3(i,0,1,this._look1,this._look2,Kc),s.up=d.lerpVec3(i,0,1,this._up1,this._up2,Jc)):this._flyingEyeLookUp&&(s.eye=d.lerpVec3(i,0,1,this._eye1,this._eye2,Xc),s.look=d.lerpVec3(i,0,1,this._look1,this._look2,Kc),s.up=d.lerpVec3(i,0,1,this._up1,this._up2,Jc)),this._projection2){const t="ortho"===this._projection2?Zc._easeOutExpo(e,0,1,1):Zc._easeInCubic(e,0,1,1);s.customProjection.matrix=d.lerpMat4(t,0,1,this._projMatrix1,this._projMatrix2)}else s.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return s.ortho.scale=this._orthoScale2,void this.stop();I.scheduleTask(this._update,this)}static _ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}static _easeInCubic(e,t,i,s){return i*(e/=s)*e*e+t}static _easeOutExpo(e,t,i,s){return i*(1-Math.pow(2,-10*e/s))+t}stop(){if(!this._flying)return;this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);const e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}cancel(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}set duration(e){this._duration=e?1e3*e:500,this.stop()}get duration(){return this._duration/1e3}set fit(e){this._fit=!1!==e}get fit(){return this._fit}set fitFOV(e){this._fitFOV=e||45}get fitFOV(){return this._fitFOV}set trail(e){this._trail=!!e}get trail(){return this._trail}destroy(){this.stop(),super.destroy()}}class qc extends R{get type(){return"CameraPathAnimation"}constructor(e,t={}){super(e,t),this._cameraFlightAnimation=new Zc(this),this._t=0,this.state=qc.SCRUBBING,this._playingFromT=0,this._playingToT=0,this._playingRate=t.playingRate||1,this._playingDir=1,this._lastTime=null,this.cameraPath=t.cameraPath,this._tick=this.scene.on("tick",this._updateT,this)}_updateT(){const e=this._cameraPath;if(!e)return;let t,i;const s=performance.now(),r=this._lastTime?.001*(s-this._lastTime):0;if(this._lastTime=s,0!==r)switch(this.state){case qc.SCRUBBING:return;case qc.PLAYING:if(this._t+=this._playingRate*r,t=this._cameraPath.frames.length,0===t||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=qc.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case qc.PLAYING_TO:i=this._t+this._playingRate*r*this._playingDir,(this._playingDir<0&&i<=this._playingToT||this._playingDir>0&&i>=this._playingToT)&&(i=this._playingToT,this.state=qc.SCRUBBING,this.fire("stopped")),this._t=i,e.loadFrame(this._t)}}_ease(e,t,i,s){return-i*(e/=s)*(e-2)+t}set cameraPath(e){this._cameraPath=e}get cameraPath(){return this._cameraPath}set rate(e){this._playingRate=e}get rate(){return this._playingRate}play(){this._cameraPath&&(this._lastTime=null,this.state=qc.PLAYING)}playToT(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=qc.PLAYING_TO)}playToFrame(e){const t=this._cameraPath;if(!t)return;const i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}flyToFrame(e,t){const i=this._cameraPath;if(!i)return;const s=i.frames[e];s?(this.state=qc.SCRUBBING,this._cameraFlightAnimation.flyTo(s,t)):this.error("flyToFrame - frame index out of range: "+e)}scrubToT(e){const t=this._cameraPath;if(!t)return;this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=qc.SCRUBBING)}scrubToFrame(e){const t=this._cameraPath;if(!t)return;if(!this.scene.camera)return;t.frames[e]?(t.loadFrame(this._t),this.state=qc.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)}stop(){this.state=qc.SCRUBBING,this.fire("stopped")}destroy(){super.destroy(),this.scene.off(this._tick)}}qc.STOPPED=0,qc.SCRUBBING=1,qc.PLAYING=2,qc.PLAYING_TO=3;const $c=d.vec3(),eu=d.vec3();d.vec3();const tu=d.vec3([0,-1,0]),iu=d.vec4([0,0,0,1]);class su extends R{constructor(e,t={}){super(e,t),this._src=null,this._image=null,this._pos=d.vec3(),this._origin=d.vec3(),this._rtcPos=d.vec3(),this._dir=d.vec3(),this._size=1,this._imageSize=d.vec2(),this._texture=new Wr(this),this._plane=new dr(this,{geometry:new Gt(this,so({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new Jt(this,{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:this._texture,emissiveMap:this._texture,backfaces:!0}),clippable:t.clippable}),this._grid=new dr(this,{geometry:new Gt(this,io({size:1,divisions:10})),material:new Jt(this,{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:t.clippable}),this._node=new Ir(this,{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[this._plane,this._grid]}),this._gridVisible=!1,this.visible=!0,this.gridVisible=t.gridVisible,this.position=t.position,this.rotation=t.rotation,this.dir=t.dir,this.size=t.size,this.collidable=t.collidable,this.clippable=t.clippable,this.pickable=t.pickable,this.opacity=t.opacity,t.image?this.image=t.image:this.src=t.src}set visible(e){this._plane.visible=e,this._grid.visible=this._gridVisible&&e}get visible(){return this._plane.visible}set gridVisible(e){e=!1!==e,this._gridVisible=e,this._grid.visible=this._gridVisible&&this.visible}get gridVisible(){return this._gridVisible}set image(e){this._image=e,this._image&&(this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}get image(){return this._image}set src(e){if(this._src=e,this._src){this._image=null;const e=new Image;e.onload=()=>{this._texture.image=e,this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage()},e.src=this._src}}get src(){return this._src}set position(e){this._pos.set(e||[0,0,0]),X(this._pos,this._origin,this._rtcPos),this._node.origin=this._origin,this._node.position=this._rtcPos}get position(){return this._pos}set rotation(e){this._node.rotation=e}get rotation(){return this._node.rotation}set size(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}get size(){return this._size}set dir(e){if(this._dir.set(e||[0,0,-1]),e){const t=this.scene.center,i=[-this._dir[0],-this._dir[1],-this._dir[2]];d.subVec3(t,this.position,$c);const s=-d.dotVec3(i,$c);d.normalizeVec3(i),d.mulVec3Scalar(i,s,eu),d.vec3PairToQuaternion(tu,e,iu),this._node.quaternion=iu}}get dir(){return this._dir}set collidable(e){this._node.collidable=!1!==e}get collidable(){return this._node.collidable}set clippable(e){this._node.clippable=!1!==e}get clippable(){return this._node.clippable}set pickable(e){this._node.pickable=!1!==e}get pickable(){return this._node.pickable}set opacity(e){this._node.opacity=e}get opacity(){return this._node.opacity}destroy(){super.destroy()}_updatePlaneSizeFromImage(){const e=this._size,t=this._imageSize[0],i=this._imageSize[1];if(t>i){const s=i/t;this._node.scale=[e,1,e*s]}else{const s=t/i;this._node.scale=[e*s,1,e]}}}class ru extends It{get type(){return"PointLight"}constructor(e,t={}){super(e,t);const i=this;this._shadowRenderBuf=null,this._shadowViewMatrix=null,this._shadowProjMatrix=null,this._shadowViewMatrixDirty=!0,this._shadowProjMatrixDirty=!0;const s=this.scene.camera,r=this.scene.canvas;this._onCameraViewMatrix=s.on("viewMatrix",(()=>{this._shadowViewMatrixDirty=!0})),this._onCameraProjMatrix=s.on("projMatrix",(()=>{this._shadowProjMatrixDirty=!0})),this._onCanvasBoundary=r.on("boundary",(()=>{this._shadowProjMatrixDirty=!0})),this._state=new lt({type:"point",pos:d.vec3([1,1,1]),color:d.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:t.space||"view",castsShadow:!1,getShadowViewMatrix:()=>{if(i._shadowViewMatrixDirty){i._shadowViewMatrix||(i._shadowViewMatrix=d.identityMat4());const e=i._state.pos,t=s.look,r=s.up;d.lookAtMat4v(e,t,r,i._shadowViewMatrix),i._shadowViewMatrixDirty=!1}return i._shadowViewMatrix},getShadowProjMatrix:()=>{if(i._shadowProjMatrixDirty){i._shadowProjMatrix||(i._shadowProjMatrix=d.identityMat4());const e=i.scene.canvas.canvas;d.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,i._shadowProjMatrix),i._shadowProjMatrixDirty=!1}return i._shadowProjMatrix},getShadowRenderBuf:()=>(i._shadowRenderBuf||(i._shadowRenderBuf=new it(i.scene.canvas.canvas,i.scene.canvas.gl,{size:[1024,1024]})),i._shadowRenderBuf)}),this.pos=t.pos,this.color=t.color,this.intensity=t.intensity,this.constantAttenuation=t.constantAttenuation,this.linearAttenuation=t.linearAttenuation,this.quadraticAttenuation=t.quadraticAttenuation,this.castsShadow=t.castsShadow,this.scene._lightCreated(this)}set pos(e){this._state.pos.set(e||[1,1,1]),this._shadowViewMatrixDirty=!0,this.glRedraw()}get pos(){return this._state.pos}set color(e){this._state.color.set(e||[.7,.7,.8]),this.glRedraw()}get color(){return this._state.color}set intensity(e){e=void 0!==e?e:1,this._state.intensity=e,this.glRedraw()}get intensity(){return this._state.intensity}set constantAttenuation(e){this._state.attenuation[0]=e||0,this.glRedraw()}get constantAttenuation(){return this._state.attenuation[0]}set linearAttenuation(e){this._state.attenuation[1]=e||0,this.glRedraw()}get linearAttenuation(){return this._state.attenuation[1]}set quadraticAttenuation(e){this._state.attenuation[2]=e||0,this.glRedraw()}get quadraticAttenuation(){return this._state.attenuation[2]}set castsShadow(e){e=!!e,this._state.castsShadow!==e&&(this._state.castsShadow=e,this._shadowViewMatrixDirty=!0,this.glRedraw())}get castsShadow(){return this._state.castsShadow}destroy(){const e=this.scene.camera,t=this.scene.canvas;e.off(this._onCameraViewMatrix),e.off(this._onCameraProjMatrix),t.off(this._onCanvasBoundary),super.destroy(),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}}function ou(e){if(!nu(e.width)||!nu(e.height)){const t=document.createElement("canvas");t.width=au(e.width),t.height=au(e.height);t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}function nu(e){return 0==(e&e-1)}function au(e){--e;for(let t=1;t<32;t<<=1)e|=e>>t;return e+1}class lu extends R{get type(){return"CubeTexture"}constructor(e,t={}){super(e,t);const i=this.scene.canvas.gl;this._state=new lt({texture:new Qr({gl:i,target:i.TEXTURE_CUBE_MAP}),flipY:this._checkFlipY(t.minFilter),encoding:this._checkEncoding(t.encoding),minFilter:1008,magFilter:1006,wrapS:1001,wrapT:1001,mipmaps:!0}),this._src=t.src,this._images=[],this._loadSrc(t.src),m.memory.textures++}_checkFlipY(e){return!!e}_checkEncoding(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),e}_webglContextRestored(){this.scene.canvas.gl,this._state.texture=null,this._src&&this._loadSrc(this._src)}_loadSrc(e){const t=this,i=this.scene.canvas.gl;this._images=[];let s=!1,r=0;for(let o=0;o{this._texture.image=e,this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage()},e.src=this._src}}get src(){return this._src}set size(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}get size(){return this._size}set collidable(e){this._mesh.collidable=!1!==e}get collidable(){return this._mesh.collidable}set clippable(e){this._mesh.clippable=!1!==e}get clippable(){return this._mesh.clippable}set pickable(e){this._mesh.pickable=!1!==e}get pickable(){return this._mesh.pickable}set opacity(e){this._mesh.opacity=e}get opacity(){return this._mesh.opacity}_updatePlaneSizeFromImage(){const e=.5*this._size,t=this._imageSize[0],i=this._imageSize[1],s=i/t;this._geometry.positions=t>i?[e,e*s,0,-e,e*s,0,-e,-e*s,0,e,-e*s,0]:[e/s,e,0,-e/s,e,0,-e/s,-e,0,e/s,-e,0]}}class uu{constructor(e){this._eye=d.vec3(),this._look=d.vec3(),this._up=d.vec3(),this._projection={},e&&this.saveCamera(e)}saveCamera(e){const t=e.camera,i=t.project;switch(this._eye.set(t.eye),this._look.set(t.look),this._up.set(t.up),t.projection){case"perspective":this._projection={projection:"perspective",fov:i.fov,fovAxis:i.fovAxis,near:i.near,far:i.far};break;case"ortho":this._projection={projection:"ortho",scale:i.scale,near:i.near,far:i.far};break;case"frustum":this._projection={projection:"frustum",left:i.left,right:i.right,top:i.top,bottom:i.bottom,near:i.near,far:i.far};break;case"custom":this._projection={projection:"custom",matrix:i.matrix.slice()}}}restoreCamera(e,t){const i=e.camera,s=this._projection;function r(){switch(s.type){case"perspective":i.perspective.fov=s.fov,i.perspective.fovAxis=s.fovAxis,i.perspective.near=s.near,i.perspective.far=s.far;break;case"ortho":i.ortho.scale=s.scale,i.ortho.near=s.near,i.ortho.far=s.far;break;case"frustum":i.frustum.left=s.left,i.frustum.right=s.right,i.frustum.top=s.top,i.frustum.bottom=s.bottom,i.frustum.near=s.near,i.frustum.far=s.far;break;case"custom":i.customProjection.matrix=s.matrix}}t?e.viewer.cameraFlight.flyTo({eye:this._eye,look:this._look,up:this._up,orthoScale:s.scale,projection:s.projection},(()=>{r(),t()})):(i.eye=this._eye,i.look=this._look,i.up=this._up,r(),i.projection=s.projection)}}const du=d.vec3();class pu{constructor(e){if(this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,e){const t=e.metaScene.scene;this.saveObjects(t,e)}}saveObjects(e,t,i){this.numObjects=0,this._mask=i?y.apply(i,{}):null;const s=!i||i.visible,r=!i||i.edges,o=!i||i.xrayed,n=!i||i.highlighted,a=!i||i.selected,l=!i||i.clippable,A=!i||i.pickable,h=!i||i.colorize,c=!i||i.opacity,u=t.metaObjects,d=e.objects;for(let e=0,t=u.length;e1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=d.vec3();return t[0]=d.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),t[1]=d.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),t[2]=d.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),t}getJSON(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}}class _u extends Hc{constructor(e,t={}){super(e,t),this._cachedLengths=[],this._dirty=!0,this._curves=[],this._t=0,this._dirtySubs=[],this._destroyedSubs=[],this.curves=t.curves||[],this.t=t.t}addCurve(e){this._curves.push(e),this._dirty=!0}set curves(e){var t,i,s;for(e=e||[],i=0,s=this._curves.length;i1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}get length(){var e=this._getCurveLengths();return e[e.length-1]}getPoint(e){for(var t,i=e*this.length,s=this._getCurveLengths(),r=0;r=i){var o=1-(s[r]-i)/(t=this._curves[r]).length;return t.getPointAt(o)}r++}return null}_getCurveLengths(){if(!this._dirty)return this._cachedLengths;var e,t=[],i=0,s=this._curves.length;for(e=0;e1?1:e}get t(){return this._t}get point(){return this.getPoint(this._t)}getPoint(e){var t=d.vec3();return t[0]=d.b2(e,this._v0[0],this._v1[0],this._v2[0]),t[1]=d.b2(e,this._v0[1],this._v1[1],this._v2[1]),t[2]=d.b2(e,this._v0[2],this._v1[2],this._v2[2]),t}getJSON(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}}class bu extends _c{constructor(e,t={}){super(e,t)}}class yu extends R{constructor(e,t={}){super(e,t),this._skyboxMesh=new dr(this,{geometry:new Gt(this,{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[2e3,2e3,2e3],rotation:[0,-90,0],material:new Jt(this,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Wr(this,{src:t.src,flipY:!0,wrapS:"clampToEdge",wrapT:"clampToEdge",encoding:t.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),this.size=t.size,this.active=t.active}set size(e){this._size=e||1e3,this._skyboxMesh.scale=[this._size,this._size,this._size]}get size(){return this._size}set active(e){this._skyboxMesh.visible=e}get active(){return this._skyboxMesh.visible}}class Bu{transcode(e,t,i={}){}destroy(){}}const xu=d.vec4(),wu=d.vec4(),Pu=d.vec3(),Cu=d.vec3(),Mu=d.vec3(),Fu=d.vec4(),Eu=d.vec4(),Iu=d.vec4();class Du{constructor(e){this._scene=e}dollyToCanvasPos(e,t,i){let s=!1;const r=this._scene.camera;if(e){const t=d.subVec3(e,r.eye,Pu);s=d.lenVec3(t){this._cameraDirty=!0})),this._onProjMatrix=this._scene.camera.on("projMatrix",(()=>{this._cameraDirty=!0})),this._onTick=this._scene.on("tick",(()=>{this.updatePivotElement(),this.updatePivotSphere()}))}createPivotSphere(){const e=this.getPivotPos(),t=d.vec3();d.decomposeMat4(d.inverseMat4(this._scene.viewer.camera.viewMatrix,d.mat4()),t,d.vec4(),d.vec3());const i=d.distVec3(t,e);let s=Math.tan(Math.PI/500)*i*this._pivotSphereSize;"ortho"==this._scene.camera.projection&&(s/=this._scene.camera.ortho.scale/2),X(e,this._rtcCenter,this._rtcPos),this._pivotSphereGeometry=new Yr(this._scene,gr({radius:s})),this._pivotSphere=new dr(this._scene,{geometry:this._pivotSphereGeometry,material:this._pivotSphereMaterial,pickable:!1,position:this._rtcPos,rtcCenter:this._rtcCenter})}destroyPivotSphere(){this._pivotSphere&&(this._pivotSphere.destroy(),this._pivotSphere=null),this._pivotSphereGeometry&&(this._pivotSphereGeometry.destroy(),this._pivotSphereGeometry=null)}updatePivotElement(){const e=this._scene.camera,t=this._scene.canvas;if(this._pivoting&&this._cameraDirty){d.transformPoint3(e.viewMatrix,this.getPivotPos(),this._pivotViewPos),this._pivotViewPos[3]=1,d.transformPoint4(e.projMatrix,this._pivotViewPos,this._pivotProjPos);const i=t.boundary,s=i[2],r=i[3];this._pivotCanvasPos[0]=Math.floor((1+this._pivotProjPos[0]/this._pivotProjPos[3])*s/2),this._pivotCanvasPos[1]=Math.floor((1-this._pivotProjPos[1]/this._pivotProjPos[3])*r/2);let o=t._lastBoundingClientRect;if(!o||t._canvasSizeChanged){const e=t.canvas;o=t._lastBoundingClientRect=e.getBoundingClientRect()}this._pivotElement&&(this._pivotElement.style.left=Math.floor(o.left+this._pivotCanvasPos[0])-this._pivotElement.clientWidth/2+window.scrollX+"px",this._pivotElement.style.top=Math.floor(o.top+this._pivotCanvasPos[1])-this._pivotElement.clientHeight/2+window.scrollY+"px"),this._cameraDirty=!1}}updatePivotSphere(){this._pivoting&&this._pivotSphere&&(X(this.getPivotPos(),this._rtcCenter,this._rtcPos),d.compareVec3(this._rtcPos,this._pivotSphere.position)||(this.destroyPivotSphere(),this.createPivotSphere()))}setPivotElement(e){this._pivotElement=e}enablePivotSphere(e={}){this.destroyPivotSphere(),this._pivotSphereEnabled=!0,e.size&&(this._pivotSphereSize=e.size);const t=e.color||[1,0,0];this._pivotSphereMaterial=new Jt(this._scene,{emissive:t,ambient:t,specular:[0,0,0],diffuse:[0,0,0]})}disablePivotSphere(){this.destroyPivotSphere(),this._pivotSphereEnabled=!1}startPivot(){if(this._cameraLookingDownwards())return this._pivoting=!1,!1;const e=this._scene.camera;let t=d.lookAtMat4v(e.eye,e.look,e.worldUp);d.transformPoint3(t,this.getPivotPos(),this._cameraOffset);const i=this.getPivotPos();this._cameraOffset[2]+=d.distVec3(e.eye,i),t=d.inverseMat4(t);const s=d.transformVec3(t,this._cameraOffset),r=d.vec3();if(d.subVec3(e.eye,i,r),d.addVec3(r,s),e.zUp){const e=r[1];r[1]=r[2],r[2]=e}this._radius=d.lenVec3(r),this._polar=Math.acos(r[1]/this._radius),this._azimuth=Math.atan2(r[0],r[2]),this._pivoting=!0}_cameraLookingDownwards(){const e=this._scene.camera,t=d.normalizeVec3(d.subVec3(e.look,e.eye,Su)),i=d.cross3Vec3(t,e.worldUp,Tu);return d.sqLenVec3(i)<=1e-4}getPivoting(){return this._pivoting}setPivotPos(e){this._pivotWorldPos.set(e),this._pivotPosSet=!0}setCanvasPivotPos(e){const t=this._scene.camera,i=Math.abs(d.distVec3(this._scene.center,t.eye)),s=t.project.transposedMatrix,r=s.subarray(8,12),o=s.subarray(12),n=[0,0,-1,1],a=d.dotVec4(n,r)/d.dotVec4(n,o),l=Lu;t.project.unproject(e,a,Uu,ku,l);const A=d.normalizeVec3(d.subVec3(l,t.eye,Su)),h=d.addVec3(t.eye,d.mulVec3Scalar(A,i,Tu),Ru);this.setPivotPos(h)}getPivotPos(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}continuePivot(e,t){if(!this._pivoting)return;if(0===e&&0===t)return;const i=this._scene.camera;var s=-e;const r=-t;1===i.worldUp[2]&&(s=-s),this._azimuth+=.01*-s,this._polar+=.01*r,this._polar=d.clamp(this._polar,.001,Math.PI-.001);const o=[this._radius*Math.sin(this._polar)*Math.sin(this._azimuth),this._radius*Math.cos(this._polar),this._radius*Math.sin(this._polar)*Math.cos(this._azimuth)];if(1===i.worldUp[2]){const e=o[1];o[1]=o[2],o[2]=e}const n=d.lenVec3(d.subVec3(i.look,i.eye,d.vec3())),a=this.getPivotPos();d.addVec3(o,a);let l=d.lookAtMat4v(o,a,i.worldUp);l=d.inverseMat4(l);const A=d.transformVec3(l,this._cameraOffset);l[12]-=A[0],l[13]-=A[1],l[14]-=A[2];const h=[l[8],l[9],l[10]];i.eye=[l[12],l[13],l[14]],d.subVec3(i.eye,d.mulVec3Scalar(h,n),i.look),i.up=[l[4],l[5],l[6]],this.showPivot()}showPivot(){this._shown||(this._pivotElement&&(this.updatePivotElement(),this._pivotElement.style.visibility="visible"),this._pivotSphereEnabled&&(this.destroyPivotSphere(),this.createPivotSphere()),this._shown=!0)}hidePivot(){this._shown&&(this._pivotElement&&(this._pivotElement.style.visibility="hidden"),this._pivotSphereEnabled&&this.destroyPivotSphere(),this._shown=!1)}endPivot(){this._pivoting=!1}destroy(){this.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}class Nu{constructor(e,t){this._scene=e.scene,this._cameraControl=e,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=t,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=d.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}update(){if(!this._configs.pointerEnabled)return;if(!this.schedulePickEntity&&!this.schedulePickSurface)return;const e=`${~~this.pickCursorPos[0]}-${~~this.pickCursorPos[1]}-${this.scheduleSnapOrPick}-${this.schedulePickSurface}-${this.schedulePickEntity}`;if(this._lastHash===e)return;this.picked=!1,this.pickedSurface=!1,this.snappedOrPicked=!1,this.hoveredSnappedOrSurfaceOff=!1;const t=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){const e=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});e&&(e.snappedToEdge||e.snappedToVertex)?(this.snapPickResult=e,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){const e=this.pickResult.canvasPos;if(e[0]===this.pickCursorPos[0]&&e[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=t?1:0,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.hoveredSnappedOrSurfaceOff=!0,void(this.scheduleSnapOrPick=!1)}if(this.schedulePickEntity&&this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){const e=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(e[0]===this.pickCursorPos[0]&&e[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!1,this.schedulePickEntity=!1,void(this.schedulePickSurface=!1)}this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult?(this.pickResult=this._scene.pick({pickSurface:!0,pickSurfaceNormal:!1,canvasPos:this.pickCursorPos}),this.pickResult?(this.picked=!0,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.pickedSurface=!0,this._needFireEvents++):this.scheduleSnapOrPick&&(this.hoveredSnappedOrSurfaceOff=!0,this._needFireEvents++)):(this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos}),this.pickResult&&(this.picked=!0,this.pickedSurface=!1,this._needFireEvents++)),this.scheduleSnapOrPick=!1,this.schedulePickEntity=!1,this.schedulePickSurface=!1}fireEvents(){if(0!==this._needFireEvents){if(this.hoveredSnappedOrSurfaceOff&&this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},!0),this.snappedOrPicked)if(this.snapPickResult){const e=new Re;e.entity=this.snapPickResult.entity,e.snappedToVertex=this.snapPickResult.snappedToVertex,e.snappedToEdge=this.snapPickResult.snappedToEdge,e.worldPos=this.snapPickResult.worldPos,e.canvasPos=this.pickCursorPos,e.snappedCanvasPos=this.snapPickResult.snappedCanvasPos,this._cameraControl.fire("hoverSnapOrSurface",e,!0),this.snapPickResult=null}else this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,!0);if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){const e=this.pickResult.entity.id;this._lastPickedEntityId!==e&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=e)}this._cameraControl.fire("hover",this.pickResult,!0),this.pickResult.worldPos&&(this.pickedSurface=!0,this._cameraControl.fire("hoverSurface",this.pickResult,!0))}else void 0!==this._lastPickedEntityId&&(this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},!0);this.pickResult=null,this._needFireEvents=0}}}const Qu=d.vec2();class Vu{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController;let n,a,l,A=0,h=0,c=0,u=0,p=!1;const f=d.vec3();let g=!0;const m=this._scene.canvas.canvas,_=[];function v(e=!0){m.style.cursor="move",A=s.pointerCanvasPos[0],h=s.pointerCanvasPos[1],c=s.pointerCanvasPos[0],u=s.pointerCanvasPos[1],e&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickSurface=!0,o.update(),o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(p=!0,f.set(o.pickResult.worldPos)):p=!1)}document.addEventListener("keydown",this._documentKeyDownHandler=t=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;const s=t.keyCode;_[s]=!0}),document.addEventListener("keyup",this._documentKeyUpHandler=t=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;const s=t.keyCode;_[s]=!1}),m.addEventListener("mousedown",this._mouseDownHandler=t=>{if(i.active&&i.pointerEnabled)switch(t.which){case 1:_[e.input.KEY_SHIFT]||i.planView?(n=!0,v()):(n=!0,v(!1));break;case 2:a=!0,v();break;case 3:l=!0,i.panRightClick&&v()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(!n&&!a&&!l)return;const o=e.canvas.boundary,c=o[2],u=o[3],g=s.pointerCanvasPos[0],m=s.pointerCanvasPos[1],v=_[e.input.KEY_SHIFT]||i.planView||!i.panRightClick&&a||i.panRightClick&&l,b=document.pointerLockElement?t.movementX:g-A,y=document.pointerLockElement?t.movementY:m-h;if(v){const t=e.camera;if("perspective"===t.projection){const i=Math.abs(p?d.lenVec3(d.subVec3(f,e.camera.eye,[])):e.camera.eyeLookDist)*Math.tan(t.perspective.fov/2*Math.PI/180);r.panDeltaX+=1.5*b*i/u,r.panDeltaY+=1.5*y*i/u}else r.panDeltaX+=.5*t.ortho.scale*(b/u),r.panDeltaY+=.5*t.ortho.scale*(y/u)}else!n||a||l||i.planView||(i.firstPerson?(r.rotateDeltaY-=b/c*i.dragRotationRate/2,r.rotateDeltaX+=y/u*(i.dragRotationRate/4)):(r.rotateDeltaY-=b/c*(1.5*i.dragRotationRate),r.rotateDeltaX+=y/u*(1.5*i.dragRotationRate)));A=g,h=m}),m.addEventListener("mousemove",this._canvasMouseMoveHandler=e=>{i.active&&i.pointerEnabled&&s.mouseover&&(g=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=e=>{if(i.active&&i.pointerEnabled)switch(e.which){case 1:case 2:case 3:n=!1,a=!1,l=!1}}),m.addEventListener("mouseup",this._mouseUpHandler=e=>{if(i.active&&i.pointerEnabled){if(3===e.which){!function(e,t){if(e){let i=e.target,s=0,r=0,o=0,n=0;for(;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,o+=i.scrollLeft,n+=i.scrollTop,i=i.offsetParent;t[0]=e.pageX+o-s,t[1]=e.pageY+n-r}else e=window.event,t[0]=e.x,t[1]=e.y}(e,Qu);const i=Qu[0],s=Qu[1];Math.abs(i-c)<3&&Math.abs(s-u)<3&&t.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Qu,event:e},!0)}m.style.removeProperty("cursor")}}),m.addEventListener("mouseenter",this._mouseEnterHandler=()=>{i.active&&i.pointerEnabled});const b=1/60;let y=null;m.addEventListener("wheel",this._mouseWheelHandler=e=>{if(!i.active||!i.pointerEnabled)return;const t=performance.now()/1e3;var o=null!==y?t-y:0;y=t,o>.05&&(o=.05),o{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;if(!s.mouseover)return;const n=r._isKeyDownForAction(r.AXIS_VIEW_RIGHT),a=r._isKeyDownForAction(r.AXIS_VIEW_BACK),l=r._isKeyDownForAction(r.AXIS_VIEW_LEFT),A=r._isKeyDownForAction(r.AXIS_VIEW_FRONT),h=r._isKeyDownForAction(r.AXIS_VIEW_TOP),c=r._isKeyDownForAction(r.AXIS_VIEW_BOTTOM);if(!(n||a||l||A||h||c))return;const u=e.aabb,p=d.getAABB3Diag(u);d.getAABB3Center(u,Hu);const f=Math.abs(p/Math.tan(t.cameraFlight.fitFOV*d.DEGTORAD)),g=1.1*p;Ku.orthoScale=g,n?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldRight,f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(o.worldUp)):a?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldForward,f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(o.worldUp)):l?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldRight,-f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(o.worldUp)):A?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldForward,-f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(o.worldUp)):h?(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldUp,f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(d.normalizeVec3(d.mulVec3Scalar(o.worldForward,1,Gu),zu))):c&&(Ku.eye.set(d.addVec3(Hu,d.mulVec3Scalar(o.worldUp,-f,ju),Wu)),Ku.look.set(Hu),Ku.up.set(d.normalizeVec3(d.mulVec3Scalar(o.worldForward,-1,Gu)))),!i.firstPerson&&i.followPointer&&t.pivotController.setPivotPos(Hu),t.cameraFlight.duration>0?t.cameraFlight.flyTo(Ku,(()=>{t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot()})):(t.cameraFlight.jumpTo(Ku),t.pivotController.getPivoting()&&i.followPointer&&t.pivotController.showPivot())}))}reset(){}destroy(){this._scene.input.off(this._onSceneKeyDown)}}class Ju{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController,n=t.pivotController,a=t.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;let l=!1,A=!1;const h=this._scene.canvas.canvas,c=i=>{let s;i&&i.worldPos&&(s=i.worldPos);const r=i&&i.entity?i.entity.aabb:e.aabb;if(s){const i=e.camera;d.subVec3(i.eye,i.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})},u=e.tickify(this._canvasMouseMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(l||A)return;const r=a.hasSubs("hover"),n=a.hasSubs("hoverEnter"),h=a.hasSubs("hoverOut"),c=a.hasSubs("hoverOff"),u=a.hasSubs("hoverSurface"),d=a.hasSubs("hoverSnapOrSurface");if(r||n||h||c||u||d)if(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=!0,o.schedulePickSurface=u,o.scheduleSnapOrPick=d,o.update(),o.pickResult){if(o.pickResult.entity){const t=o.pickResult.entity.id;this._lastPickedEntityId!==t&&(void 0!==this._lastPickedEntityId&&a.fire("hoverOut",{entity:e.objects[this._lastPickedEntityId]},!0),a.fire("hoverEnter",o.pickResult,!0),this._lastPickedEntityId=t)}a.fire("hover",o.pickResult,!0),(o.pickResult.worldPos||o.pickResult.snappedWorldPos)&&a.fire("hoverSurface",o.pickResult,!0)}else void 0!==this._lastPickedEntityId&&(a.fire("hoverOut",{entity:e.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),a.fire("hoverOff",{canvasPos:o.pickCursorPos},!0)});h.addEventListener("mousemove",u),h.addEventListener("mousedown",this._canvasMouseDownHandler=t=>{1===t.which&&(l=!0),3===t.which&&(A=!0);if(1===t.which&&i.active&&i.pointerEnabled&&(s.mouseDownClientX=t.clientX,s.mouseDownClientY=t.clientY,s.mouseDownCursorX=s.pointerCanvasPos[0],s.mouseDownCursorY=s.pointerCanvasPos[1],!i.firstPerson&&i.followPointer&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickSurface=!0,o.update(),1===t.which))){const t=o.pickResult;t&&t.worldPos?(n.setPivotPos(t.worldPos),n.startPivot()):(i.smartPivot?n.setCanvasPivotPos(s.pointerCanvasPos):n.setPivotPos(e.camera.look),n.startPivot())}}),document.addEventListener("mouseup",this._documentMouseUpHandler=e=>{1===e.which&&(l=!1),3===e.which&&(A=!1),n.getPivoting()&&n.endPivot()}),h.addEventListener("mouseup",this._canvasMouseUpHandler=r=>{if(!i.active||!i.pointerEnabled)return;if(!(1===r.which))return;if(n.hidePivot(),Math.abs(r.clientX-s.mouseDownClientX)>3||Math.abs(r.clientY-s.mouseDownClientY)>3)return;const l=a.hasSubs("picked"),A=a.hasSubs("pickedNothing"),h=a.hasSubs("pickedSurface"),u=a.hasSubs("doublePicked"),p=a.hasSubs("doublePickedSurface"),f=a.hasSubs("doublePickedNothing");if(!(i.doublePickFlyTo||u||p||f))return(l||A||h)&&(o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=!0,o.schedulePickSurface=h,o.update(),o.pickResult?(a.fire("picked",o.pickResult,!0),o.pickedSurface&&a.fire("pickedSurface",o.pickResult,!0)):a.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0)),void(this._clicks=0);if(this._clicks++,1===this._clicks){o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=i.doublePickFlyTo,o.schedulePickSurface=h,o.update();const e=o.pickResult,r=o.pickedSurface;this._timeout=setTimeout((()=>{e?(a.fire("picked",e,!0),r&&(a.fire("pickedSurface",e,!0),!i.firstPerson&&i.followPointer&&(t.pivotController.setPivotPos(e.worldPos),t.pivotController.startPivot()&&t.pivotController.showPivot()))):a.fire("pickedNothing",{canvasPos:s.pointerCanvasPos},!0),this._clicks=0}),i.doubleClickTimeFrame)}else{if(null!==this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null),o.pickCursorPos=s.pointerCanvasPos,o.schedulePickEntity=i.doublePickFlyTo||u||p,o.schedulePickSurface=o.schedulePickEntity&&p,o.update(),o.pickResult){if(a.fire("doublePicked",o.pickResult,!0),o.pickedSurface&&a.fire("doublePickedSurface",o.pickResult,!0),i.doublePickFlyTo&&(c(o.pickResult),!i.firstPerson&&i.followPointer)){const e=o.pickResult.entity.aabb,i=d.getAABB3Center(e);t.pivotController.setPivotPos(i),t.pivotController.startPivot()&&t.pivotController.showPivot()}}else if(a.fire("doublePickedNothing",{canvasPos:s.pointerCanvasPos},!0),i.doublePickFlyTo&&(c(),!i.firstPerson&&i.followPointer)){const i=e.aabb,s=d.getAABB3Center(i);t.pivotController.setPivotPos(s),t.pivotController.startPivot()&&t.pivotController.showPivot()}this._clicks=0}},!1)}reset(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}destroy(){const e=this._scene.canvas.canvas;e.removeEventListener("mousemove",this._canvasMouseMoveHandler),e.removeEventListener("mousedown",this._canvasMouseDownHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._canvasMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}class Yu{constructor(e,t,i,s,r){this._scene=e;const o=e.input,n=[],a=e.canvas.canvas;let l=!0;this._onSceneMouseMove=o.on("mousemove",(()=>{l=!0})),this._onSceneKeyDown=o.on("keydown",(t=>{i.active&&i.pointerEnabled&&e.input.keyboardEnabled&&s.mouseover&&(n[t]=!0,t===o.KEY_SHIFT&&(a.style.cursor="move"))})),this._onSceneKeyUp=o.on("keyup",(s=>{i.active&&i.pointerEnabled&&e.input.keyboardEnabled&&(n[s]=!1,s===o.KEY_SHIFT&&(a.style.cursor=null),t.pivotController.getPivoting()&&t.pivotController.endPivot())})),this._onTick=e.on("tick",(a=>{if(!i.active||!i.pointerEnabled||!e.input.keyboardEnabled)return;if(!s.mouseover)return;const A=t.cameraControl,h=a.deltaTime/1e3;if(!i.planView){const e=A._isKeyDownForAction(A.ROTATE_Y_POS,n),s=A._isKeyDownForAction(A.ROTATE_Y_NEG,n),o=A._isKeyDownForAction(A.ROTATE_X_POS,n),a=A._isKeyDownForAction(A.ROTATE_X_NEG,n),l=h*i.keyboardRotationRate;(e||s||o||a)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),e?r.rotateDeltaY+=l:s&&(r.rotateDeltaY-=l),o?r.rotateDeltaX+=l:a&&(r.rotateDeltaX-=l),!i.firstPerson&&i.followPointer&&t.pivotController.startPivot())}if(!n[o.KEY_CTRL]&&!n[o.KEY_ALT]){const e=A._isKeyDownForAction(A.DOLLY_BACKWARDS,n),o=A._isKeyDownForAction(A.DOLLY_FORWARDS,n);if(e||o){const n=h*i.keyboardDollyRate;!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),o?r.dollyDelta-=n:e&&(r.dollyDelta+=n),l&&(s.followPointerDirty=!0,l=!1)}}const c=A._isKeyDownForAction(A.PAN_FORWARDS,n),u=A._isKeyDownForAction(A.PAN_BACKWARDS,n),d=A._isKeyDownForAction(A.PAN_LEFT,n),p=A._isKeyDownForAction(A.PAN_RIGHT,n),f=A._isKeyDownForAction(A.PAN_UP,n),g=A._isKeyDownForAction(A.PAN_DOWN,n),m=(n[o.KEY_ALT]?.3:1)*h*i.keyboardPanRate;(c||u||d||p||f||g)&&(!i.firstPerson&&i.followPointer&&t.pivotController.startPivot(),g?r.panDeltaY+=m:f&&(r.panDeltaY+=-m),p?r.panDeltaX+=-m:d&&(r.panDeltaX+=m),u?r.panDeltaZ+=m:c&&(r.panDeltaZ+=-m))}))}reset(){}destroy(){this._scene.off(this._onTick),this._scene.input.off(this._onSceneMouseMove),this._scene.input.off(this._onSceneKeyDown),this._scene.input.off(this._onSceneKeyUp)}}const Zu=d.vec3();class qu{constructor(e,t,i,s,r){this._scene=e;const o=e.camera,n=t.pickController,a=t.pivotController,l=t.panController;let A=1,h=1,c=null;this._onTick=e.on("tick",(()=>{if(!i.active||!i.pointerEnabled)return;let t="default";if(Math.abs(r.dollyDelta)<.001&&(r.dollyDelta=0),Math.abs(r.rotateDeltaX)<.001&&(r.rotateDeltaX=0),Math.abs(r.rotateDeltaY)<.001&&(r.rotateDeltaY=0),0===r.rotateDeltaX&&0===r.rotateDeltaY||(r.dollyDelta=0),i.followPointer){if(--A<=0&&(A=1,0!==r.dollyDelta)){if(0===r.rotateDeltaY&&0===r.rotateDeltaX&&i.followPointer&&s.followPointerDirty&&(n.pickCursorPos=s.pointerCanvasPos,n.schedulePickSurface=!0,n.update(),n.pickResult&&n.pickResult.worldPos?c=n.pickResult.worldPos:(h=1,c=null),s.followPointerDirty=!1),c){const t=Math.abs(d.lenVec3(d.subVec3(c,e.camera.eye,Zu)));h=t/i.dollyProximityThreshold}h{s.mouseover=!0}),o.addEventListener("mouseleave",this._mouseLeaveHandler=()=>{s.mouseover=!1,o.style.cursor=null}),document.addEventListener("mousemove",this._mouseMoveHandler=e=>{ed(e,o,s.pointerCanvasPos)}),o.addEventListener("mousedown",this._mouseDownHandler=e=>{i.active&&i.pointerEnabled&&(ed(e,o,s.pointerCanvasPos),s.mouseover=!0)}),o.addEventListener("mouseup",this._mouseUpHandler=e=>{i.active&&i.pointerEnabled})}reset(){}destroy(){const e=this._scene.canvas.canvas;document.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseenter",this._mouseEnterHandler),e.removeEventListener("mouseleave",this._mouseLeaveHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mouseup",this._mouseUpHandler)}}function ed(e,t,i){if(e){const{left:s,top:r}=t.getBoundingClientRect();i[0]=e.clientX-s-window.scrollX,i[1]=e.clientY-r-window.scrollY}else e=window.event,i[0]=e.x,i[1]=e.y;return i}const td=function(e,t){if(e){let i=e.target,s=0,r=0;for(;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t};class id{constructor(e,t,i,s,r){this._scene=e;const o=t.pickController,n=t.pivotController,a=d.vec2(),l=d.vec2(),A=d.vec2(),h=d.vec2(),c=[],u=this._scene.canvas.canvas;let p=0,f=!1;this._onTick=e.on("tick",(()=>{f=!1})),u.addEventListener("touchstart",this._canvasTouchStartHandler=t=>{if(!i.active||!i.pointerEnabled)return;t.preventDefault();const r=t.touches,l=t.changedTouches;for(s.touchStartTime=Date.now(),1===r.length&&1===l.length&&(td(r[0],a),i.followPointer&&(o.pickCursorPos=a,o.schedulePickSurface=!0,o.update(),i.planView||(o.picked&&o.pickedSurface&&o.pickResult&&o.pickResult.worldPos?(n.setPivotPos(o.pickResult.worldPos),!i.firstPerson&&n.startPivot()&&n.showPivot()):(i.smartPivot?n.setCanvasPivotPos(s.pointerCanvasPos):n.setPivotPos(e.camera.look),!i.firstPerson&&n.startPivot()&&n.showPivot()))));c.length{n.getPivoting()&&n.endPivot()}),u.addEventListener("touchmove",this._canvasTouchMoveHandler=t=>{if(!i.active||!i.pointerEnabled)return;if(t.stopPropagation(),t.preventDefault(),f)return;f=!0;const n=e.canvas.boundary,a=n[2],u=n[3],g=t.touches;if(t.touches.length===p){if(1===p){td(g[0],l),d.subVec2(l,c[0],h);const t=h[0],o=h[1];if(null!==s.longTouchTimeout&&(Math.abs(t)>i.longTapRadius||Math.abs(o)>i.longTapRadius)&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),i.planView){const s=e.camera;if("perspective"===s.projection){const n=Math.abs(e.camera.eyeLookDist)*Math.tan(s.perspective.fov/2*Math.PI/180);r.panDeltaX+=t*n/u*i.touchPanRate,r.panDeltaY+=o*n/u*i.touchPanRate}else r.panDeltaX+=.5*s.ortho.scale*(t/u)*i.touchPanRate,r.panDeltaY+=.5*s.ortho.scale*(o/u)*i.touchPanRate}else r.rotateDeltaY-=t/a*(1*i.dragRotationRate),r.rotateDeltaX+=o/u*(1.5*i.dragRotationRate)}else if(2===p){const t=g[0],n=g[1];td(t,l),td(n,A);const a=d.geometricMeanVec2(c[0],c[1]),h=d.geometricMeanVec2(l,A),p=d.vec2();d.subVec2(a,h,p);const f=p[0],m=p[1],_=e.camera,v=d.distVec2([t.pageX,t.pageY],[n.pageX,n.pageY]),b=(d.distVec2(c[0],c[1])-v)*i.touchDollyRate;if(r.dollyDelta=b,Math.abs(b)<1)if("perspective"===_.projection){const t=o.pickResult?o.pickResult.worldPos:e.center,s=Math.abs(d.lenVec3(d.subVec3(t,e.camera.eye,[])))*Math.tan(_.perspective.fov/2*Math.PI/180);r.panDeltaX-=f*s/u*i.touchPanRate,r.panDeltaY-=m*s/u*i.touchPanRate}else r.panDeltaX-=.5*_.ortho.scale*(f/u)*i.touchPanRate,r.panDeltaY-=.5*_.ortho.scale*(m/u)*i.touchPanRate;s.pointerCanvasPos=h}for(let e=0;e{let s;i&&i.worldPos&&(s=i.worldPos);const r=i?i.entity.aabb:e.aabb;if(s){const i=e.camera;d.subVec3(i.eye,i.look,[]),t.cameraFlight.flyTo({aabb:r})}else t.cameraFlight.flyTo({aabb:r})};u.addEventListener("touchstart",this._canvasTouchStartHandler=e=>{if(!i.active||!i.pointerEnabled)return;null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null);const r=e.touches,o=e.changedTouches;if(a=Date.now(),1===r.length&&1===o.length){h=a,sd(r[0],A);const o=A[0],n=A[1],l=r[0].pageX,c=r[0].pageY;s.longTouchTimeout=setTimeout((()=>{t.cameraControl.fire("rightClick",{pagePos:[Math.round(l),Math.round(c)],canvasPos:[Math.round(o),Math.round(n)],event:e},!0),s.longTouchTimeout=null}),i.longTapTimeout)}else h=-1;for(;l.length{if(!i.active||!i.pointerEnabled)return;const t=Date.now(),r=e.touches,a=e.changedTouches,u=n.hasSubs("pickedSurface");null!==s.longTouchTimeout&&(clearTimeout(s.longTouchTimeout),s.longTouchTimeout=null),0===r.length&&1===a.length&&h>-1&&t-h<150&&(c>-1&&h-c<325?(sd(a[0],o.pickCursorPos),o.schedulePickEntity=!0,o.schedulePickSurface=u,o.update(),o.pickResult?(o.pickResult.touchInput=!0,n.fire("doublePicked",o.pickResult),o.pickedSurface&&n.fire("doublePickedSurface",o.pickResult),i.doublePickFlyTo&&p(o.pickResult)):(n.fire("doublePickedNothing"),i.doublePickFlyTo&&p()),c=-1):d.distVec2(l[0],A)<4&&(sd(a[0],o.pickCursorPos),o.schedulePickEntity=!0,o.schedulePickSurface=u,o.update(),o.pickResult?(o.pickResult.touchInput=!0,n.fire("picked",o.pickResult),o.pickedSurface&&n.fire("pickedSurface",o.pickResult)):n.fire("pickedNothing"),c=t),h=-1),l.length=r.length;for(let e=0,t=r.length;e{e.preventDefault()},this._configs={longTapTimeout:600,longTapRadius:5,active:!0,keyboardLayout:"qwerty",navMode:"orbit",planView:!1,firstPerson:!1,followPointer:!0,doublePickFlyTo:!0,panRightClick:!0,showPivot:!1,pointerEnabled:!0,constrainVertical:!1,smartPivot:!1,doubleClickTimeFrame:250,snapToVertex:true,snapToEdge:true,snapRadius:30,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},this._states={pointerCanvasPos:d.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:d.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},this._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};const i=this.scene;this._controllers={cameraControl:this,pickController:new Nu(this,this._configs),pivotController:new Ou(i,this._configs),panController:new Du(i),cameraFlight:new Zc(this,{duration:.5})},this._handlers=[new $u(this.scene,this._controllers,this._configs,this._states,this._updates),new id(this.scene,this._controllers,this._configs,this._states,this._updates),new Vu(this.scene,this._controllers,this._configs,this._states,this._updates),new Xu(this.scene,this._controllers,this._configs,this._states,this._updates),new Ju(this.scene,this._controllers,this._configs,this._states,this._updates),new rd(this.scene,this._controllers,this._configs,this._states,this._updates),new Yu(this.scene,this._controllers,this._configs,this._states,this._updates)],this._cameraUpdater=new qu(this.scene,this._controllers,this._configs,this._states,this._updates),this.navMode=t.navMode,t.planView&&(this.planView=t.planView),this.constrainVertical=t.constrainVertical,t.keyboardLayout?this.keyboardLayout=t.keyboardLayout:this.keyMap=t.keyMap,this.doublePickFlyTo=t.doublePickFlyTo,this.panRightClick=t.panRightClick,this.active=t.active,this.followPointer=t.followPointer,this.rotationInertia=t.rotationInertia,this.keyboardPanRate=t.keyboardPanRate,this.touchPanRate=t.touchPanRate,this.keyboardRotationRate=t.keyboardRotationRate,this.dragRotationRate=t.dragRotationRate,this.touchDollyRate=t.touchDollyRate,this.dollyInertia=t.dollyInertia,this.dollyProximityThreshold=t.dollyProximityThreshold,this.dollyMinSpeed=t.dollyMinSpeed,this.panInertia=t.panInertia,this.pointerEnabled=!0,this.keyboardDollyRate=t.keyboardDollyRate,this.mouseWheelDollyRate=t.mouseWheelDollyRate}set keyMap(e){if(e=e||"qwerty",y.isString(e)){const t=this.scene.input,i={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":i[this.PAN_LEFT]=[t.KEY_A],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_Z],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_W,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_Q,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6];break;case"azerty":i[this.PAN_LEFT]=[t.KEY_Q],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_W],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_Z,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_A,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6]}this._keyMap=i}else{const t=e;this._keyMap=t}}get keyMap(){return this._keyMap}_isKeyDownForAction(e,t){const i=this._keyMap[e];if(!i)return!1;t||(t=this.scene.input.keyDown);for(let e=0,s=i.length;e0?cd(t):null,n=i&&i.length>0?cd(i):null,a=e=>{if(!e)return;var t=!0;(n&&n[e.type]||o&&!o[e.type])&&(t=!1),t&&s.push(e.id);const i=e.children;if(i)for(var r=0,l=i.length;r * Copyright (c) 2022 Niklas von Hertzen @@ -33,5 +33,5 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var ud=function(e,t){return ud=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},ud(e,t)};function dd(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}ud(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var pd=function(){return pd=Object.assign||function(e){for(var t,i=1,s=arguments.length;i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=55296&&r<=56319&&i>10),n%1024+56320)),(r+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Bd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xd="undefined"==typeof Uint8Array?[]:new Uint8Array(256),wd=0;wd=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Id="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Dd="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Sd=0;Sd>4,h[l++]=(15&s)<<4|r>>2,h[l++]=(3&r)<<6|63&o;return A}(e),n=Array.isArray(o)?function(e){for(var t=e.length,i=[],s=0;s0;){var n=s[--o];if(Array.isArray(e)?-1!==e.indexOf(n):e===n)for(var a=i;a<=s.length;){var l;if((l=s[++a])===t)return!0;if(l!==Td)break}if(n!==Td)break}return!1},dp=function(e,t){for(var i=e;i>=0;){var s=t[i];if(s!==Td)return s;i--}return 0},pp=function(e,t,i,s,r){if(0===i[s])return"×";var o=s-1;if(Array.isArray(r)&&!0===r[o])return"×";var n=o-1,a=o+1,l=t[o],A=n>=0?t[n]:0,h=t[a];if(2===l&&3===h)return"×";if(-1!==np.indexOf(l))return"!";if(-1!==np.indexOf(h))return"×";if(-1!==ap.indexOf(h))return"×";if(8===dp(o,t))return"÷";if(11===rp.get(e[o]))return"×";if((l===Xd||l===Jd)&&11===rp.get(e[a]))return"×";if(7===l||7===h)return"×";if(9===l)return"×";if(-1===[Td,Rd,Ld].indexOf(l)&&9===h)return"×";if(-1!==[Ud,kd,Od,Hd,Wd].indexOf(h))return"×";if(dp(o,t)===Vd)return"×";if(up(23,Vd,o,t))return"×";if(up([Ud,kd],Qd,o,t))return"×";if(up(12,12,o,t))return"×";if(l===Td)return"÷";if(23===l||23===h)return"×";if(16===h||16===l)return"÷";if(-1!==[Rd,Ld,Qd].indexOf(h)||14===l)return"×";if(36===A&&-1!==cp.indexOf(l))return"×";if(l===Wd&&36===h)return"×";if(h===Nd)return"×";if(-1!==op.indexOf(h)&&l===jd||-1!==op.indexOf(l)&&h===jd)return"×";if(l===zd&&-1!==[qd,Xd,Jd].indexOf(h)||-1!==[qd,Xd,Jd].indexOf(l)&&h===Gd)return"×";if(-1!==op.indexOf(l)&&-1!==lp.indexOf(h)||-1!==lp.indexOf(l)&&-1!==op.indexOf(h))return"×";if(-1!==[zd,Gd].indexOf(l)&&(h===jd||-1!==[Vd,Ld].indexOf(h)&&t[a+1]===jd)||-1!==[Vd,Ld].indexOf(l)&&h===jd||l===jd&&-1!==[jd,Wd,Hd].indexOf(h))return"×";if(-1!==[jd,Wd,Hd,Ud,kd].indexOf(h))for(var c=o;c>=0;){if((u=t[c])===jd)return"×";if(-1===[Wd,Hd].indexOf(u))break;c--}if(-1!==[zd,Gd].indexOf(h))for(c=-1!==[Ud,kd].indexOf(l)?n:o;c>=0;){var u;if((u=t[c])===jd)return"×";if(-1===[Wd,Hd].indexOf(u))break;c--}if($d===l&&-1!==[$d,ep,Yd,Zd].indexOf(h)||-1!==[ep,Yd].indexOf(l)&&-1!==[ep,tp].indexOf(h)||-1!==[tp,Zd].indexOf(l)&&h===tp)return"×";if(-1!==hp.indexOf(l)&&-1!==[Nd,Gd].indexOf(h)||-1!==hp.indexOf(h)&&l===zd)return"×";if(-1!==op.indexOf(l)&&-1!==op.indexOf(h))return"×";if(l===Hd&&-1!==op.indexOf(h))return"×";if(-1!==op.concat(jd).indexOf(l)&&h===Vd&&-1===sp.indexOf(e[a])||-1!==op.concat(jd).indexOf(h)&&l===kd)return"×";if(41===l&&41===h){for(var d=i[o],p=1;d>0&&41===t[--d];)p++;if(p%2!=0)return"×"}return l===Xd&&h===Jd?"×":"÷"},fp=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=function(e,t){void 0===t&&(t="strict");var i=[],s=[],r=[];return e.forEach((function(e,o){var n=rp.get(e);if(n>50?(r.push(!0),n-=50):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return s.push(o),i.push(16);if(4===n||11===n){if(0===o)return s.push(o),i.push(Kd);var a=i[o-1];return-1===Ap.indexOf(a)?(s.push(s[o-1]),i.push(a)):(s.push(o),i.push(Kd))}return s.push(o),31===n?i.push("strict"===t?Qd:qd):n===ip||29===n?i.push(Kd):43===n?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(qd):i.push(Kd):void i.push(n)})),[s,i,r]}(e,t.lineBreak),s=i[0],r=i[1],o=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[jd,Kd,ip].indexOf(e)?qd:e})));var n="keep-all"===t.wordBreak?o.map((function(t,i){return t&&e[i]>=19968&&e[i]<=40959})):void 0;return[s,r,n]},gp=function(){function e(e,t,i,s){this.codePoints=e,this.required="!"===t,this.start=i,this.end=s}return e.prototype.slice=function(){return yd.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),mp=function(e){return e>=48&&e<=57},_p=function(e){return mp(e)||e>=65&&e<=70||e>=97&&e<=102},vp=function(e){return 10===e||9===e||32===e},bp=function(e){return function(e){return function(e){return e>=97&&e<=122}(e)||function(e){return e>=65&&e<=90}(e)}(e)||function(e){return e>=128}(e)||95===e},yp=function(e){return bp(e)||mp(e)||45===e},Bp=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},xp=function(e,t){return 92===e&&10!==t},wp=function(e,t,i){return 45===e?bp(t)||xp(t,i):!!bp(e)||!(92!==e||!xp(e,t))},Pp=function(e,t,i){return 43===e||45===e?!!mp(t)||46===t&&mp(i):mp(46===e?t:e)},Cp=function(e){var t=0,i=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(i=-1),t++);for(var s=[];mp(e[t]);)s.push(e[t++]);var r=s.length?parseInt(yd.apply(void 0,s),10):0;46===e[t]&&t++;for(var o=[];mp(e[t]);)o.push(e[t++]);var n=o.length,a=n?parseInt(yd.apply(void 0,o),10):0;69!==e[t]&&101!==e[t]||t++;var l=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(l=-1),t++);for(var A=[];mp(e[t]);)A.push(e[t++]);var h=A.length?parseInt(yd.apply(void 0,A),10):0;return i*(r+a*Math.pow(10,-n))*Math.pow(10,l*h)},Mp={type:2},Fp={type:3},Ep={type:4},Ip={type:13},Dp={type:8},Sp={type:21},Tp={type:9},Rp={type:10},Lp={type:11},Up={type:12},kp={type:14},Op={type:23},Np={type:1},Qp={type:25},Vp={type:24},Hp={type:26},jp={type:27},Gp={type:28},zp={type:29},Wp={type:31},Kp={type:32},Xp=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(bd(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==Kp;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(yp(t)||xp(i,s)){var r=wp(t,i,s)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Ip;break;case 39:return this.consumeStringToken(39);case 40:return Mp;case 41:return Fp;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),kp;break;case 43:if(Pp(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return Ep;case 45:var o=e,n=this.peekCodePoint(0),a=this.peekCodePoint(1);if(Pp(o,n,a))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(wp(o,n,a))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===n&&62===a)return this.consumeCodePoint(),this.consumeCodePoint(),Vp;break;case 46:if(Pp(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(42===l&&47===(l=this.consumeCodePoint()))return this.consumeToken();if(-1===l)return this.consumeToken()}break;case 58:return Hp;case 59:return jp;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),Qp;break;case 64:var A=this.peekCodePoint(0),h=this.peekCodePoint(1),c=this.peekCodePoint(2);if(wp(A,h,c))return{type:7,value:this.consumeName()};break;case 91:return Gp;case 92:if(xp(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return zp;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Dp;break;case 123:return Lp;case 125:return Up;case 117:case 85:var u=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==u||!_p(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Tp;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),Sp;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Rp;break;case-1:return Kp}return vp(e)?(this.consumeWhiteSpace(),Wp):mp(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):bp(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:yd(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();_p(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(yd.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(yd.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var s=parseInt(yd.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&_p(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];_p(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:s,end:parseInt(yd.apply(void 0,r),16)}}return{type:30,start:s,end:s}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var t=this.peekCodePoint(0);if(39===t||34===t){var i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),Op)}for(;;){var s=this.consumeCodePoint();if(-1===s||41===s)return{type:22,value:yd.apply(void 0,e)};if(vp(s))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:yd.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Op);if(34===s||39===s||40===s||Bp(s))return this.consumeBadUrlRemnants(),Op;if(92===s){if(!xp(s,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),Op;e.push(this.consumeEscapedCodePoint())}else e.push(s)}},e.prototype.consumeWhiteSpace=function(){for(;vp(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;xp(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var i=Math.min(5e4,e);t+=yd.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var s=this._value[i];if(-1===s||void 0===s||s===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(10===s)return this._value.splice(0,i),Np;if(92===s){var r=this._value[i+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):xp(s,r)&&(t+=this.consumeStringSlice(i),t+=yd(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=4,i=this.peekCodePoint(0);for(43!==i&&45!==i||e.push(this.consumeCodePoint());mp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var s=this.peekCodePoint(1);if(46===i&&mp(s))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;mp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),s=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===i||101===i)&&((43===s||45===s)&&mp(r)||mp(s)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;mp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Cp(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],s=this.peekCodePoint(0),r=this.peekCodePoint(1),o=this.peekCodePoint(2);return wp(s,r,o)?{type:15,number:t,flags:i,unit:this.consumeName()}:37===s?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(_p(e)){for(var t=yd(e);_p(this.peekCodePoint(0))&&t.length<6;)t+=yd(this.consumeCodePoint());vp(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||function(e){return e>=55296&&e<=57343}(i)||i>1114111?65533:i}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(yp(t))e+=yd(t);else{if(!xp(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=yd(this.consumeEscapedCodePoint())}}},e}(),Jp=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new Xp;return i.write(t),new e(i.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(32===i.type||of(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?Kp:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),Yp=function(e){return 15===e.type},Zp=function(e){return 17===e.type},qp=function(e){return 20===e.type},$p=function(e){return 0===e.type},ef=function(e,t){return qp(e)&&e.value===t},tf=function(e){return 31!==e.type},sf=function(e){return 31!==e.type&&4!==e.type},rf=function(e){var t=[],i=[];return e.forEach((function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)})),i.length&&t.push(i),t},of=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},nf=function(e){return 17===e.type||15===e.type},af=function(e){return 16===e.type||nf(e)},lf=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},Af={type:17,number:0,flags:4},hf={type:16,number:50,flags:4},cf={type:16,number:100,flags:4},uf=function(e,t,i){var s=e[0],r=e[1];return[df(s,t),df(void 0!==r?r:s,i)]},df=function(e,t){if(16===e.type)return e.number/100*t;if(Yp(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},pf=function(e,t){if(15===t.type)switch(t.unit){case"deg":return Math.PI*t.number/180;case"grad":return Math.PI/200*t.number;case"rad":return t.number;case"turn":return 2*Math.PI*t.number}throw new Error("Unsupported angle type")},ff=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},gf=function(e){switch(e.filter(qp).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Af,Af];case"to top":case"bottom":return mf(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Af,cf];case"to right":case"left":return mf(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[cf,cf];case"to bottom":case"top":return mf(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[cf,Af];case"to left":case"right":return mf(270)}return 0},mf=function(e){return Math.PI*e/180},_f=function(e,t){if(18===t.type){var i=Cf[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var s=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);return yf(parseInt(s+s,16),parseInt(r+r,16),parseInt(o+o,16),1)}if(4===t.value.length){s=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);var n=t.value.substring(3,4);return yf(parseInt(s+s,16),parseInt(r+r,16),parseInt(o+o,16),parseInt(n+n,16)/255)}if(6===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6);return yf(parseInt(s,16),parseInt(r,16),parseInt(o,16),1)}if(8===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6),n=t.value.substring(6,8);return yf(parseInt(s,16),parseInt(r,16),parseInt(o,16),parseInt(n,16)/255)}}if(20===t.type){var a=Ff[t.value.toUpperCase()];if(void 0!==a)return a}return Ff.TRANSPARENT},vf=function(e){return 0==(255&e)},bf=function(e){var t=255&e,i=255&e>>8,s=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+s+","+i+","+t/255+")":"rgb("+r+","+s+","+i+")"},yf=function(e,t,i,s){return(e<<24|t<<16|i<<8|Math.round(255*s)<<0)>>>0},Bf=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},xf=function(e,t){var i=t.filter(sf);if(3===i.length){var s=i.map(Bf),r=s[0],o=s[1],n=s[2];return yf(r,o,n,1)}if(4===i.length){var a=i.map(Bf),l=(r=a[0],o=a[1],n=a[2],a[3]);return yf(r,o,n,l)}return 0};function wf(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var Pf=function(e,t){var i=t.filter(sf),s=i[0],r=i[1],o=i[2],n=i[3],a=(17===s.type?mf(s.number):pf(e,s))/(2*Math.PI),l=af(r)?r.number/100:0,A=af(o)?o.number/100:0,h=void 0!==n&&af(n)?df(n,1):1;if(0===l)return yf(255*A,255*A,255*A,1);var c=A<=.5?A*(l+1):A+l-A*l,u=2*A-c,d=wf(u,c,a+1/3),p=wf(u,c,a),f=wf(u,c,a-1/3);return yf(255*d,255*p,255*f,h)},Cf={hsl:Pf,hsla:Pf,rgb:xf,rgba:xf},Mf=function(e,t){return _f(e,Jp.create(t).parseComponentValue())},Ff={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Ef={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(qp(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},If={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Df=function(e,t){var i=_f(e,t[0]),s=t[1];return s&&af(s)?{color:i,stop:s}:{color:i,stop:null}},Sf=function(e,t){var i=e[0],s=e[e.length-1];null===i.stop&&(i.stop=Af),null===s.stop&&(s.stop=cf);for(var r=[],o=0,n=0;no?r.push(l):r.push(o),o=l}else r.push(null)}var A=null;for(n=0;ne.optimumDistance)?{optimumCorner:t,optimumDistance:a}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},Uf=function(e,t){var i=mf(180),s=[];return rf(t).forEach((function(t,r){if(0===r){var o=t[0];if(20===o.type&&-1!==["top","left","right","bottom"].indexOf(o.value))return void(i=gf(t));if(ff(o))return void(i=(pf(e,o)+mf(270))%mf(360))}var n=Df(e,t);s.push(n)})),{angle:i,stops:s,type:1}},kf=function(e,t){var i=0,s=3,r=[],o=[];return rf(t).forEach((function(t,n){var a=!0;if(0===n?a=t.reduce((function(e,t){if(qp(t))switch(t.value){case"center":return o.push(hf),!1;case"top":case"left":return o.push(Af),!1;case"right":case"bottom":return o.push(cf),!1}else if(af(t)||nf(t))return o.push(t),!1;return e}),a):1===n&&(a=t.reduce((function(e,t){if(qp(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"contain":case"closest-side":return s=0,!1;case"farthest-side":return s=1,!1;case"closest-corner":return s=2,!1;case"cover":case"farthest-corner":return s=3,!1}else if(nf(t)||af(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)),a){var l=Df(e,t);r.push(l)}})),{size:s,shape:i,stops:r,position:o,type:2}},Of=function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var s=Qf[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(e,t.values)}throw new Error("Unsupported image type "+t.type)};var Nf,Qf={"linear-gradient":function(e,t){var i=mf(180),s=[];return rf(t).forEach((function(t,r){if(0===r){var o=t[0];if(20===o.type&&"to"===o.value)return void(i=gf(t));if(ff(o))return void(i=pf(e,o))}var n=Df(e,t);s.push(n)})),{angle:i,stops:s,type:1}},"-moz-linear-gradient":Uf,"-ms-linear-gradient":Uf,"-o-linear-gradient":Uf,"-webkit-linear-gradient":Uf,"radial-gradient":function(e,t){var i=0,s=3,r=[],o=[];return rf(t).forEach((function(t,n){var a=!0;if(0===n){var l=!1;a=t.reduce((function(e,t){if(l)if(qp(t))switch(t.value){case"center":return o.push(hf),e;case"top":case"left":return o.push(Af),e;case"right":case"bottom":return o.push(cf),e}else(af(t)||nf(t))&&o.push(t);else if(qp(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"at":return l=!0,!1;case"closest-side":return s=0,!1;case"cover":case"farthest-side":return s=1,!1;case"contain":case"closest-corner":return s=2,!1;case"farthest-corner":return s=3,!1}else if(nf(t)||af(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)}if(a){var A=Df(e,t);r.push(A)}})),{size:s,shape:i,stops:r,position:o,type:2}},"-moz-radial-gradient":kf,"-ms-radial-gradient":kf,"-o-radial-gradient":kf,"-webkit-radial-gradient":kf,"-webkit-gradient":function(e,t){var i=mf(180),s=[],r=1;return rf(t).forEach((function(t,i){var o=t[0];if(0===i){if(qp(o)&&"linear"===o.value)return void(r=1);if(qp(o)&&"radial"===o.value)return void(r=2)}if(18===o.type)if("from"===o.name){var n=_f(e,o.values[0]);s.push({stop:Af,color:n})}else if("to"===o.name){n=_f(e,o.values[0]);s.push({stop:cf,color:n})}else if("color-stop"===o.name){var a=o.values.filter(sf);if(2===a.length){n=_f(e,a[1]);var l=a[0];Zp(l)&&s.push({stop:{type:16,number:100*l.number,flags:l.flags},color:n})}}})),1===r?{angle:(i+mf(180))%mf(360),stops:s,type:r}:{size:3,shape:0,stops:s,position:[],type:r}}},Vf={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter((function(e){return sf(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Qf[e.name])}(e)})).map((function(t){return Of(e,t)}))}},Hf={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(qp(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},jf={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return rf(t).map((function(e){return e.filter(af)})).map(lf)}},Gf={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return rf(t).map((function(e){return e.filter(qp).map((function(e){return e.value})).join(" ")})).map(zf)}},zf=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Nf||(Nf={}));var Wf,Kf={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return rf(t).map((function(e){return e.filter(Xf)}))}},Xf=function(e){return qp(e)||af(e)},Jf=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},Yf=Jf("top"),Zf=Jf("right"),qf=Jf("bottom"),$f=Jf("left"),eg=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return lf(t.filter(af))}}},tg=eg("top-left"),ig=eg("top-right"),sg=eg("bottom-right"),rg=eg("bottom-left"),og=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},ng=og("top"),ag=og("right"),lg=og("bottom"),Ag=og("left"),hg=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return Yp(t)?t.number:0}}},cg=hg("top"),ug=hg("right"),dg=hg("bottom"),pg=hg("left"),fg={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},gg={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},mg={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(qp).reduce((function(e,t){return e|_g(t.value)}),0)}},_g=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},vg={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},bg={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(Wf||(Wf={}));var yg,Bg={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?Wf.STRICT:Wf.NORMAL}},xg={name:"line-height",initialValue:"normal",prefix:!1,type:4},wg=function(e,t){return qp(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:af(e)?df(e,t):t},Pg={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:Of(e,t)}},Cg={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Mg={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},Fg=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},Eg=Fg("top"),Ig=Fg("right"),Dg=Fg("bottom"),Sg=Fg("left"),Tg={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(qp).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},Rg={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Lg=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Ug=Lg("top"),kg=Lg("right"),Og=Lg("bottom"),Ng=Lg("left"),Qg={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Vg={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Hg={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&ef(t[0],"none")?[]:rf(t).map((function(t){for(var i={color:Ff.TRANSPARENT,offsetX:Af,offsetY:Af,blur:Af},s=0,r=0;r1?1:0],this.overflowWrap=ym(e,Rg,t.overflowWrap),this.paddingTop=ym(e,Ug,t.paddingTop),this.paddingRight=ym(e,kg,t.paddingRight),this.paddingBottom=ym(e,Og,t.paddingBottom),this.paddingLeft=ym(e,Ng,t.paddingLeft),this.paintOrder=ym(e,fm,t.paintOrder),this.position=ym(e,Vg,t.position),this.textAlign=ym(e,Qg,t.textAlign),this.textDecorationColor=ym(e,em,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=ym(e,tm,null!==(s=t.textDecorationLine)&&void 0!==s?s:t.textDecoration),this.textShadow=ym(e,Hg,t.textShadow),this.textTransform=ym(e,jg,t.textTransform),this.transform=ym(e,Gg,t.transform),this.transformOrigin=ym(e,Xg,t.transformOrigin),this.visibility=ym(e,Jg,t.visibility),this.webkitTextStrokeColor=ym(e,gm,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=ym(e,mm,t.webkitTextStrokeWidth),this.wordBreak=ym(e,Yg,t.wordBreak),this.zIndex=ym(e,Zg,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return vf(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return am(this.display,4)||am(this.display,33554432)||am(this.display,268435456)||am(this.display,536870912)||am(this.display,67108864)||am(this.display,134217728)},e}(),vm=function(e,t){this.content=ym(e,lm,t.content),this.quotes=ym(e,um,t.quotes)},bm=function(e,t){this.counterIncrement=ym(e,Am,t.counterIncrement),this.counterReset=ym(e,hm,t.counterReset)},ym=function(e,t,i){var s=new Xp,r=null!=i?i.toString():t.initialValue;s.write(r);var o=new Jp(s.read());switch(t.type){case 2:var n=o.parseComponentValue();return t.parse(e,qp(n)?n.value:t.initialValue);case 0:return t.parse(e,o.parseComponentValue());case 1:return t.parse(e,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case"angle":return pf(e,o.parseComponentValue());case"color":return _f(e,o.parseComponentValue());case"image":return Of(e,o.parseComponentValue());case"length":var a=o.parseComponentValue();return nf(a)?a:Af;case"length-percentage":var l=o.parseComponentValue();return af(l)?l:Af;case"time":return qg(e,o.parseComponentValue())}}},Bm=function(e,t){var i=function(e){switch(e.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(e);return 1===i||t===i},xm=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Bm(t,3),this.styles=new _m(e,window.getComputedStyle(t,null)),x_(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=vd(this.context,t),Bm(t,4)&&(this.flags|=16)},wm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Pm="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Cm=0;Cm=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Em="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Im="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Dm=0;Dm>10),n%1024+56320)),(r+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Om=function(e,t){var i,s,r,o=function(e){var t,i,s,r,o,n=.75*e.length,a=e.length,l=0;"="===e[e.length-1]&&(n--,"="===e[e.length-2]&&n--);var A="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(n):new Array(n),h=Array.isArray(A)?A:new Uint8Array(A);for(t=0;t>4,h[l++]=(15&s)<<4|r>>2,h[l++]=(3&r)<<6|63&o;return A}(e),n=Array.isArray(o)?function(e){for(var t=e.length,i=[],s=0;s=55296&&r<=56319&&i=i)return{done:!0,value:null};for(var e="×";sn.x||r.y>n.y;return n=r,0===t||a}));return e.body.removeChild(t),a}(document);return Object.defineProperty(zm,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,i=e.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,";try{s.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(zm,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?function(e){var t=e.createElement("canvas"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var r=new Image,o=t.toDataURL();r.src=o;var n=jm(i,i,0,0,r);return s.fillStyle="red",s.fillRect(0,0,i,i),Gm(n).then((function(t){s.drawImage(t,0,0);var r=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var n=e.createElement("div");return n.style.backgroundImage="url("+o+")",n.style.height="100px",Hm(r)?Gm(jm(i,i,0,0,n)):Promise.reject(!1)})).then((function(e){return s.drawImage(e,0,0),Hm(s.getImageData(0,0,i,i).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(zm,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(zm,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(zm,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(zm,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(zm,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Wm=function(e,t){this.text=e,this.bounds=t},Km=function(e,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(s,t);var o=vd(e,s);return s.firstChild&&r.replaceChild(s.firstChild,s),o}}return _d.EMPTY},Xm=function(e,t,i){var s=e.ownerDocument;if(!s)throw new Error("Node has no owner document");var r=s.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},Jm=function(e){if(zm.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return function(e){for(var t,i=Vm(e),s=[];!(t=i.next()).done;)t.value&&s.push(t.value.slice());return s}(e)},Ym=function(e,t){return 0!==t.letterSpacing?Jm(e):function(e,t){if(zm.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map((function(e){return e.segment}))}return qm(e,t)}(e,t)},Zm=[32,160,4961,65792,65793,4153,4241],qm=function(e,t){for(var i,s=function(e,t){var i=bd(e),s=fp(i,t),r=s[0],o=s[1],n=s[2],a=i.length,l=0,A=0;return{next:function(){if(A>=a)return{done:!0,value:null};for(var e="×";A0)if(zm.SUPPORT_RANGE_BOUNDS){var r=Xm(s,n,t.length).getClientRects();if(r.length>1){var a=Jm(t),l=0;a.forEach((function(t){o.push(new Wm(t,_d.fromDOMRectList(e,Xm(s,l+n,t.length).getClientRects()))),l+=t.length}))}else o.push(new Wm(t,_d.fromDOMRectList(e,r)))}else{var A=s.splitText(t.length);o.push(new Wm(t,Km(e,s))),s=A}else zm.SUPPORT_RANGE_BOUNDS||(s=s.splitText(t.length));n+=t.length})),o}(e,this.text,i,t)},e_=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(t_,i_);case 2:return e.toUpperCase();default:return e}},t_=/(^|\s|:|-|\(|\))([a-z])/g,i_=function(e,t,i){return e.length>0?t+i.toUpperCase():e},s_=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.src=i.currentSrc||i.src,s.intrinsicWidth=i.naturalWidth,s.intrinsicHeight=i.naturalHeight,s.context.cache.addImage(s.src),s}return dd(t,e),t}(xm),r_=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i,s.intrinsicWidth=i.width,s.intrinsicHeight=i.height,s}return dd(t,e),t}(xm),o_=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=new XMLSerializer,o=vd(t,i);return i.setAttribute("width",o.width+"px"),i.setAttribute("height",o.height+"px"),s.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),s.intrinsicWidth=i.width.baseVal.value,s.intrinsicHeight=i.height.baseVal.value,s.context.cache.addImage(s.svg),s}return dd(t,e),t}(xm),n_=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return dd(t,e),t}(xm),a_=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.start=i.start,s.reversed="boolean"==typeof i.reversed&&!0===i.reversed,s}return dd(t,e),t}(xm),l_=[{type:15,flags:0,unit:"px",number:3}],A_=[{type:16,flags:0,number:50}],h_="password",c_=function(e){function t(t,i){var s,r=e.call(this,t,i)||this;switch(r.type=i.type.toLowerCase(),r.checked=i.checked,r.value=function(e){var t=e.type===h_?new Array(e.value.length+1).join("•"):e.value;return 0===t.length?e.placeholder||"":t}(i),"checkbox"!==r.type&&"radio"!==r.type||(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=(s=r.bounds).width>s.height?new _d(s.left+(s.width-s.height)/2,s.top,s.height,s.height):s.width0)i.textNodes.push(new $m(e,r,i.styles));else if(B_(r))if(k_(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return g_(e,t,i,s)}));else{var n=m_(e,r);n.styles.isVisible()&&(v_(r,n,s)?n.flags|=4:b_(n.styles)&&(n.flags|=2),-1!==f_.indexOf(r.tagName)&&(n.flags|=8),i.elements.push(n),r.slot,r.shadowRoot?g_(e,r.shadowRoot,n,s):L_(r)||F_(r)||U_(r)||g_(e,r,n,s))}},m_=function(e,t){return S_(t)?new s_(e,t):I_(t)?new r_(e,t):F_(t)?new o_(e,t):P_(t)?new n_(e,t):C_(t)?new a_(e,t):M_(t)?new c_(e,t):U_(t)?new u_(e,t):L_(t)?new d_(e,t):T_(t)?new p_(e,t):new xm(e,t)},__=function(e,t){var i=m_(e,t);return i.flags|=4,g_(e,t,i,i),i},v_=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||E_(e)&&i.styles.isTransparent()},b_=function(e){return e.isPositioned()||e.isFloating()},y_=function(e){return e.nodeType===Node.TEXT_NODE},B_=function(e){return e.nodeType===Node.ELEMENT_NODE},x_=function(e){return B_(e)&&void 0!==e.style&&!w_(e)},w_=function(e){return"object"==typeof e.className},P_=function(e){return"LI"===e.tagName},C_=function(e){return"OL"===e.tagName},M_=function(e){return"INPUT"===e.tagName},F_=function(e){return"svg"===e.tagName},E_=function(e){return"BODY"===e.tagName},I_=function(e){return"CANVAS"===e.tagName},D_=function(e){return"VIDEO"===e.tagName},S_=function(e){return"IMG"===e.tagName},T_=function(e){return"IFRAME"===e.tagName},R_=function(e){return"STYLE"===e.tagName},L_=function(e){return"TEXTAREA"===e.tagName},U_=function(e){return"SELECT"===e.tagName},k_=function(e){return"SLOT"===e.tagName},O_=function(e){return e.tagName.indexOf("-")>0},N_=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,i=e.counterIncrement,s=e.counterReset,r=!0;null!==i&&i.forEach((function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)}));var o=[];return r&&s.forEach((function(e){var i=t.counters[e.counter];o.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)})),o},e}(),Q_={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},V_={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},H_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},j_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},G_=function(e,t,i,s,r,o){return ei?J_(e,r,o.length>0):s.integers.reduce((function(t,i,r){for(;e>=i;)e-=i,t+=s.values[r];return t}),"")+o},z_=function(e,t,i,s){var r="";do{i||e--,r=s(e)+r,e/=t}while(e*t>=t);return r},W_=function(e,t,i,s,r){var o=i-t+1;return(e<0?"-":"")+(z_(Math.abs(e),o,s,(function(e){return yd(Math.floor(e%o)+t)}))+r)},K_=function(e,t,i){void 0===i&&(i=". ");var s=t.length;return z_(Math.abs(e),s,!1,(function(e){return t[Math.floor(e%s)]}))+i},X_=function(e,t,i,s,r,o){if(e<-9999||e>9999)return J_(e,4,r.length>0);var n=Math.abs(e),a=r;if(0===n)return t[0]+a;for(var l=0;n>0&&l<=4;l++){var A=n%10;0===A&&am(o,1)&&""!==a?a=t[A]+a:A>1||1===A&&0===l||1===A&&1===l&&am(o,2)||1===A&&1===l&&am(o,4)&&e>100||1===A&&l>1&&am(o,8)?a=t[A]+(l>0?i[l-1]:"")+a:1===A&&l>0&&(a=i[l-1]+a),n=Math.floor(n/10)}return(e<0?s:"")+a},J_=function(e,t,i){var s=i?". ":"",r=i?"、":"",o=i?", ":"",n=i?" ":"";switch(t){case 0:return"•"+n;case 1:return"◦"+n;case 2:return"◾"+n;case 5:var a=W_(e,48,57,!0,s);return a.length<4?"0"+a:a;case 4:return K_(e,"〇一二三四五六七八九",r);case 6:return G_(e,1,3999,Q_,3,s).toLowerCase();case 7:return G_(e,1,3999,Q_,3,s);case 8:return W_(e,945,969,!1,s);case 9:return W_(e,97,122,!1,s);case 10:return W_(e,65,90,!1,s);case 11:return W_(e,1632,1641,!0,s);case 12:case 49:return G_(e,1,9999,V_,3,s);case 35:return G_(e,1,9999,V_,3,s).toLowerCase();case 13:return W_(e,2534,2543,!0,s);case 14:case 30:return W_(e,6112,6121,!0,s);case 15:return K_(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return K_(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return X_(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return X_(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return X_(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return X_(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return X_(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return X_(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return X_(e,"영일이삼사오육칠팔구","십백천만","마이너스",o,7);case 33:return X_(e,"零一二三四五六七八九","十百千萬","마이너스",o,0);case 32:return X_(e,"零壹貳參四五六七八九","拾百千","마이너스",o,7);case 18:return W_(e,2406,2415,!0,s);case 20:return G_(e,1,19999,j_,3,s);case 21:return W_(e,2790,2799,!0,s);case 22:return W_(e,2662,2671,!0,s);case 22:return G_(e,1,10999,H_,3,s);case 23:return K_(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return K_(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return W_(e,3302,3311,!0,s);case 28:return K_(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return K_(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return W_(e,3792,3801,!0,s);case 37:return W_(e,6160,6169,!0,s);case 38:return W_(e,4160,4169,!0,s);case 39:return W_(e,2918,2927,!0,s);case 40:return W_(e,1776,1785,!0,s);case 43:return W_(e,3046,3055,!0,s);case 44:return W_(e,3174,3183,!0,s);case 45:return W_(e,3664,3673,!0,s);case 46:return W_(e,3872,3881,!0,s);default:return W_(e,48,57,!0,s)}},Y_=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new N_,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var i=this,s=q_(e,t);if(!s.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,o=e.defaultView.pageYOffset,n=s.contentWindow,a=n.document,l=tv(s).then((function(){return fd(i,void 0,void 0,(function(){var e,i;return gd(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(nv),n&&(n.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||n.scrollY===t.top&&n.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(n.scrollX-t.left,n.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(i=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:a.fonts&&a.fonts.ready?[4,a.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,ev(a)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(a,i)})).then((function(){return s}))]:[2,s]}}))}))}));return a.open(),a.write(rv(document.doctype)+""),ov(this.referenceElement.ownerDocument,r,o),a.replaceChild(a.adoptNode(this.documentElement),a.documentElement),a.close(),l},e.prototype.createElementClone=function(e){if(Bm(e,2),I_(e))return this.createCanvasClone(e);if(D_(e))return this.createVideoClone(e);if(R_(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return S_(t)&&(S_(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),O_(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return sv(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),s=e.cloneNode(!1);return s.textContent=i,s}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var s=e.cloneNode(!1);try{s.width=e.width,s.height=e.height;var r=e.getContext("2d"),o=s.getContext("2d");if(o)if(!this.options.allowTaint&&r)o.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var n=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(n){var a=n.getContextAttributes();!1===(null==a?void 0:a.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}o.drawImage(e,0,0)}return s}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return s},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var s=e.ownerDocument.createElement("canvas");return s.width=e.offsetWidth,s.height=e.offsetHeight,s},e.prototype.appendChildNode=function(e,t,i){B_(t)&&(function(e){return"SCRIPT"===e.tagName}(t)||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&B_(t)&&R_(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var s=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(B_(r)&&k_(r)&&"function"==typeof r.assignedNodes){var o=r.assignedNodes();o.length&&o.forEach((function(e){return s.appendChildNode(t,e,i)}))}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(y_(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&B_(e)&&(x_(e)||w_(e))){var s=this.createElementClone(e);s.style.transitionProperty="none";var r=i.getComputedStyle(e),o=i.getComputedStyle(e,":before"),n=i.getComputedStyle(e,":after");this.referenceElement===e&&x_(s)&&(this.clonedReferenceElement=s),E_(s)&&Av(s);var a=this.counters.parse(new bm(this.context,r)),l=this.resolvePseudoContent(e,s,o,Sm.BEFORE);O_(e)&&(t=!0),D_(e)||this.cloneChildNodes(e,s,t),l&&s.insertBefore(l,s.firstChild);var A=this.resolvePseudoContent(e,s,n,Sm.AFTER);return A&&s.appendChild(A),this.counters.pop(a),(r&&(this.options.copyStyles||w_(e))&&!T_(e)||t)&&sv(r,s),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([s,e.scrollLeft,e.scrollTop]),(L_(e)||U_(e))&&(L_(s)||U_(s))&&(s.value=e.value),s}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,s){var r=this;if(i){var o=i.content,n=t.ownerDocument;if(n&&o&&"none"!==o&&"-moz-alt-content"!==o&&"none"!==i.display){this.counters.parse(new bm(this.context,i));var a=new vm(this.context,i),l=n.createElement("html2canvaspseudoelement");sv(i,l),a.content.forEach((function(t){if(0===t.type)l.appendChild(n.createTextNode(t.value));else if(22===t.type){var i=n.createElement("img");i.src=t.value,i.style.opacity="1",l.appendChild(i)}else if(18===t.type){if("attr"===t.name){var s=t.values.filter(qp);s.length&&l.appendChild(n.createTextNode(e.getAttribute(s[0].value)||""))}else if("counter"===t.name){var o=t.values.filter(sf),A=o[0],h=o[1];if(A&&qp(A)){var c=r.counters.getCounterValue(A.value),u=h&&qp(h)?Mg.parse(r.context,h.value):3;l.appendChild(n.createTextNode(J_(c,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(sf),p=(A=d[0],d[1]);h=d[2];if(A&&qp(A)){var f=r.counters.getCounterValues(A.value),g=h&&qp(h)?Mg.parse(r.context,h.value):3,m=p&&0===p.type?p.value:"",_=f.map((function(e){return J_(e,g,!1)})).join(m);l.appendChild(n.createTextNode(_))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(n.createTextNode(dm(a.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(n.createTextNode(dm(a.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(n.createTextNode(t.value))}})),l.className=av+" "+lv;var A=s===Sm.BEFORE?" "+av:" "+lv;return w_(t)?t.className.baseValue+=A:t.className+=A,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(Sm||(Sm={}));var Z_,q_=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(i),i},$_=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},ev=function(e){return Promise.all([].slice.call(e.images,0).map($_))},tv=function(e){return new Promise((function(t,i){var s=e.contentWindow;if(!s)return i("No window assigned for iframe");var r=s.document;s.onload=e.onload=function(){s.onload=e.onload=null;var i=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))}),50)}}))},iv=["all","d","content"],sv=function(e,t){for(var i=e.length-1;i>=0;i--){var s=e.item(i);-1===iv.indexOf(s)&&t.style.setProperty(s,e.getPropertyValue(s))}return t},rv=function(e){var t="";return e&&(t+=""),t},ov=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},nv=function(e){var t=e[0],i=e[1],s=e[2];t.scrollLeft=i,t.scrollTop=s},av="___html2canvas___pseudoelement_before",lv="___html2canvas___pseudoelement_after",Av=function(e){hv(e,"."+av+':before{\n content: "" !important;\n display: none !important;\n}\n .'+lv+':after{\n content: "" !important;\n display: none !important;\n}')},hv=function(e,t){var i=e.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,e.appendChild(s)}},cv=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),uv=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:vv(e)||gv(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return fd(this,void 0,void 0,(function(){var t,i,s,r,o=this;return gd(this,(function(n){switch(n.label){case 0:return t=cv.isSameOrigin(e),i=!mv(e)&&!0===this._options.useCORS&&zm.SUPPORT_CORS_IMAGES&&!t,s=!mv(e)&&!t&&!vv(e)&&"string"==typeof this._options.proxy&&zm.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||mv(e)||vv(e)||s||i?(r=e,s?[4,this.proxy(r)]:[3,2]):[2];case 1:r=n.sent(),n.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var s=new Image;s.onload=function(){return e(s)},s.onerror=t,(_v(r)||i)&&(s.crossOrigin="anonymous"),s.src=r,!0===s.complete&&setTimeout((function(){return e(s)}),500),o._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+o._options.imageTimeout+"ms) loading image")}),o._options.imageTimeout)}))];case 3:return[2,n.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var s=e.substring(0,256);return new Promise((function(r,o){var n=zm.SUPPORT_RESPONSE_TYPE?"blob":"text",a=new XMLHttpRequest;a.onload=function(){if(200===a.status)if("text"===n)r(a.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return o(e)}),!1),e.readAsDataURL(a.response)}else o("Failed to proxy resource "+s+" with status code "+a.status)},a.onerror=o;var l=i.indexOf("?")>-1?"&":"?";if(a.open("GET",""+i+l+"url="+encodeURIComponent(e)+"&responseType="+n),"text"!==n&&a instanceof XMLHttpRequest&&(a.responseType=n),t._options.imageTimeout){var A=t._options.imageTimeout;a.timeout=A,a.ontimeout=function(){return o("Timed out ("+A+"ms) proxying "+s)}}a.send()}))},e}(),dv=/^data:image\/svg\+xml/i,pv=/^data:image\/.*;base64,/i,fv=/^data:image\/.*/i,gv=function(e){return zm.SUPPORT_SVG_DRAWING||!bv(e)},mv=function(e){return fv.test(e)},_v=function(e){return pv.test(e)},vv=function(e){return"blob"===e.substr(0,4)},bv=function(e){return"svg"===e.substr(-3).toLowerCase()||dv.test(e)},yv=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),Bv=function(e,t,i){return new yv(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},xv=function(){function e(e,t,i,s){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=s}return e.prototype.subdivide=function(t,i){var s=Bv(this.start,this.startControl,t),r=Bv(this.startControl,this.endControl,t),o=Bv(this.endControl,this.end,t),n=Bv(s,r,t),a=Bv(r,o,t),l=Bv(n,a,t);return i?new e(this.start,s,n,l):new e(l,a,o,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),wv=function(e){return 1===e.type},Pv=function(e){var t=e.styles,i=e.bounds,s=uf(t.borderTopLeftRadius,i.width,i.height),r=s[0],o=s[1],n=uf(t.borderTopRightRadius,i.width,i.height),a=n[0],l=n[1],A=uf(t.borderBottomRightRadius,i.width,i.height),h=A[0],c=A[1],u=uf(t.borderBottomLeftRadius,i.width,i.height),d=u[0],p=u[1],f=[];f.push((r+a)/i.width),f.push((d+h)/i.width),f.push((o+p)/i.height),f.push((l+c)/i.height);var g=Math.max.apply(Math,f);g>1&&(r/=g,o/=g,a/=g,l/=g,h/=g,c/=g,d/=g,p/=g);var m=i.width-a,_=i.height-c,v=i.width-h,b=i.height-p,y=t.borderTopWidth,B=t.borderRightWidth,x=t.borderBottomWidth,w=t.borderLeftWidth,P=df(t.paddingTop,e.bounds.width),C=df(t.paddingRight,e.bounds.width),M=df(t.paddingBottom,e.bounds.width),F=df(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||o>0?Cv(i.left+w/3,i.top+y/3,r-w/3,o-y/3,Z_.TOP_LEFT):new yv(i.left+w/3,i.top+y/3),this.topRightBorderDoubleOuterBox=r>0||o>0?Cv(i.left+m,i.top+y/3,a-B/3,l-y/3,Z_.TOP_RIGHT):new yv(i.left+i.width-B/3,i.top+y/3),this.bottomRightBorderDoubleOuterBox=h>0||c>0?Cv(i.left+v,i.top+_,h-B/3,c-x/3,Z_.BOTTOM_RIGHT):new yv(i.left+i.width-B/3,i.top+i.height-x/3),this.bottomLeftBorderDoubleOuterBox=d>0||p>0?Cv(i.left+w/3,i.top+b,d-w/3,p-x/3,Z_.BOTTOM_LEFT):new yv(i.left+w/3,i.top+i.height-x/3),this.topLeftBorderDoubleInnerBox=r>0||o>0?Cv(i.left+2*w/3,i.top+2*y/3,r-2*w/3,o-2*y/3,Z_.TOP_LEFT):new yv(i.left+2*w/3,i.top+2*y/3),this.topRightBorderDoubleInnerBox=r>0||o>0?Cv(i.left+m,i.top+2*y/3,a-2*B/3,l-2*y/3,Z_.TOP_RIGHT):new yv(i.left+i.width-2*B/3,i.top+2*y/3),this.bottomRightBorderDoubleInnerBox=h>0||c>0?Cv(i.left+v,i.top+_,h-2*B/3,c-2*x/3,Z_.BOTTOM_RIGHT):new yv(i.left+i.width-2*B/3,i.top+i.height-2*x/3),this.bottomLeftBorderDoubleInnerBox=d>0||p>0?Cv(i.left+2*w/3,i.top+b,d-2*w/3,p-2*x/3,Z_.BOTTOM_LEFT):new yv(i.left+2*w/3,i.top+i.height-2*x/3),this.topLeftBorderStroke=r>0||o>0?Cv(i.left+w/2,i.top+y/2,r-w/2,o-y/2,Z_.TOP_LEFT):new yv(i.left+w/2,i.top+y/2),this.topRightBorderStroke=r>0||o>0?Cv(i.left+m,i.top+y/2,a-B/2,l-y/2,Z_.TOP_RIGHT):new yv(i.left+i.width-B/2,i.top+y/2),this.bottomRightBorderStroke=h>0||c>0?Cv(i.left+v,i.top+_,h-B/2,c-x/2,Z_.BOTTOM_RIGHT):new yv(i.left+i.width-B/2,i.top+i.height-x/2),this.bottomLeftBorderStroke=d>0||p>0?Cv(i.left+w/2,i.top+b,d-w/2,p-x/2,Z_.BOTTOM_LEFT):new yv(i.left+w/2,i.top+i.height-x/2),this.topLeftBorderBox=r>0||o>0?Cv(i.left,i.top,r,o,Z_.TOP_LEFT):new yv(i.left,i.top),this.topRightBorderBox=a>0||l>0?Cv(i.left+m,i.top,a,l,Z_.TOP_RIGHT):new yv(i.left+i.width,i.top),this.bottomRightBorderBox=h>0||c>0?Cv(i.left+v,i.top+_,h,c,Z_.BOTTOM_RIGHT):new yv(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=d>0||p>0?Cv(i.left,i.top+b,d,p,Z_.BOTTOM_LEFT):new yv(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||o>0?Cv(i.left+w,i.top+y,Math.max(0,r-w),Math.max(0,o-y),Z_.TOP_LEFT):new yv(i.left+w,i.top+y),this.topRightPaddingBox=a>0||l>0?Cv(i.left+Math.min(m,i.width-B),i.top+y,m>i.width+B?0:Math.max(0,a-B),Math.max(0,l-y),Z_.TOP_RIGHT):new yv(i.left+i.width-B,i.top+y),this.bottomRightPaddingBox=h>0||c>0?Cv(i.left+Math.min(v,i.width-w),i.top+Math.min(_,i.height-x),Math.max(0,h-B),Math.max(0,c-x),Z_.BOTTOM_RIGHT):new yv(i.left+i.width-B,i.top+i.height-x),this.bottomLeftPaddingBox=d>0||p>0?Cv(i.left+w,i.top+Math.min(b,i.height-x),Math.max(0,d-w),Math.max(0,p-x),Z_.BOTTOM_LEFT):new yv(i.left+w,i.top+i.height-x),this.topLeftContentBox=r>0||o>0?Cv(i.left+w+F,i.top+y+P,Math.max(0,r-(w+F)),Math.max(0,o-(y+P)),Z_.TOP_LEFT):new yv(i.left+w+F,i.top+y+P),this.topRightContentBox=a>0||l>0?Cv(i.left+Math.min(m,i.width+w+F),i.top+y+P,m>i.width+w+F?0:a-w+F,l-(y+P),Z_.TOP_RIGHT):new yv(i.left+i.width-(B+C),i.top+y+P),this.bottomRightContentBox=h>0||c>0?Cv(i.left+Math.min(v,i.width-(w+F)),i.top+Math.min(_,i.height+y+P),Math.max(0,h-(B+C)),c-(x+M),Z_.BOTTOM_RIGHT):new yv(i.left+i.width-(B+C),i.top+i.height-(x+M)),this.bottomLeftContentBox=d>0||p>0?Cv(i.left+w+F,i.top+b,Math.max(0,d-(w+F)),p-(x+M),Z_.BOTTOM_LEFT):new yv(i.left+w+F,i.top+i.height-(x+M))};!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(Z_||(Z_={}));var Cv=function(e,t,i,s,r){var o=(Math.sqrt(2)-1)/3*4,n=i*o,a=s*o,l=e+i,A=t+s;switch(r){case Z_.TOP_LEFT:return new xv(new yv(e,A),new yv(e,A-a),new yv(l-n,t),new yv(l,t));case Z_.TOP_RIGHT:return new xv(new yv(e,t),new yv(e+n,t),new yv(l,A-a),new yv(l,A));case Z_.BOTTOM_RIGHT:return new xv(new yv(l,t),new yv(l,t+a),new yv(e+n,A),new yv(e,A));case Z_.BOTTOM_LEFT:default:return new xv(new yv(l,A),new yv(l-n,A),new yv(e,t+a),new yv(e,t))}},Mv=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Fv=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},Ev=function(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6},Iv=function(e,t){this.path=e,this.target=t,this.type=1},Dv=function(e){this.opacity=e,this.type=2,this.target=6},Sv=function(e){return 1===e.type},Tv=function(e,t){return e.length===t.length&&e.some((function(e,i){return e===t[i]}))},Rv=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},Lv=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Pv(this.container),this.container.styles.opacity<1&&this.effects.push(new Dv(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,s=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new Ev(i,s,r))}if(0!==this.container.styles.overflowX){var o=Mv(this.curves),n=Fv(this.curves);Tv(o,n)?this.effects.push(new Iv(o,6)):(this.effects.push(new Iv(o,2)),this.effects.push(new Iv(n,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,s=this.effects.slice(0);i;){var r=i.effects.filter((function(e){return!Sv(e)}));if(t||0!==i.container.styles.position||!i.parent){if(s.unshift.apply(s,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var o=Mv(i.curves),n=Fv(i.curves);Tv(o,n)||s.unshift(new Iv(n,6))}}else s.unshift.apply(s,r);i=i.parent}return s.filter((function(t){return am(t.target,e)}))},e}(),Uv=function(e,t,i,s){e.container.elements.forEach((function(r){var o=am(r.flags,4),n=am(r.flags,2),a=new Lv(r,e);am(r.styles.display,2048)&&s.push(a);var l=am(r.flags,8)?[]:s;if(o||n){var A=o||r.styles.isPositioned()?i:t,h=new Rv(a);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var c=r.styles.zIndex.order;if(c<0){var u=0;A.negativeZIndex.some((function(e,t){return c>e.element.container.styles.zIndex.order?(u=t,!1):u>0})),A.negativeZIndex.splice(u,0,h)}else if(c>0){var d=0;A.positiveZIndex.some((function(e,t){return c>=e.element.container.styles.zIndex.order?(d=t+1,!1):d>0})),A.positiveZIndex.splice(d,0,h)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(h)}else r.styles.isFloating()?A.nonPositionedFloats.push(h):A.nonPositionedInlineLevel.push(h);Uv(a,h,o?h:i,l)}else r.styles.isInlineLevel()?t.inlineLevel.push(a):t.nonInlineLevel.push(a),Uv(a,t,i,l);am(r.flags,8)&&kv(r,l)}))},kv=function(e,t){for(var i=e instanceof a_?e.start:1,s=e instanceof a_&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var s=Hv(e),r=Fv(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return fd(this,void 0,void 0,(function(){var i,s,r,o,n,a,l,A,h,c,u,d,p,f,g,m,_,v;return gd(this,(function(b){switch(b.label){case 0:this.applyEffects(e.getEffects(4)),i=e.container,s=e.curves,r=i.styles,o=0,n=i.textNodes,b.label=1;case 1:return o0&&x>0&&(m=s.ctx.createPattern(p,"repeat"),s.renderRepeat(v,m,P,C))):function(e){return 2===e.type}(i)&&(_=jv(e,t,[null,null,null]),v=_[0],b=_[1],y=_[2],B=_[3],x=_[4],w=0===i.position.length?[hf]:i.position,P=df(w[0],B),C=df(w[w.length-1],x),M=function(e,t,i,s,r){var o=0,n=0;switch(e.size){case 0:0===e.shape?o=n=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.min(Math.abs(t),Math.abs(t-s)),n=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)o=n=Math.min(Rf(t,i),Rf(t,i-r),Rf(t-s,i),Rf(t-s,i-r));else if(1===e.shape){var a=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-s)),l=Lf(s,r,t,i,!0),A=l[0],h=l[1];n=a*(o=Rf(A-t,(h-i)/a))}break;case 1:0===e.shape?o=n=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.max(Math.abs(t),Math.abs(t-s)),n=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)o=n=Math.max(Rf(t,i),Rf(t,i-r),Rf(t-s,i),Rf(t-s,i-r));else if(1===e.shape){a=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-s));var c=Lf(s,r,t,i,!1);A=c[0],h=c[1],n=a*(o=Rf(A-t,(h-i)/a))}}return Array.isArray(e.size)&&(o=df(e.size[0],s),n=2===e.size.length?df(e.size[1],r):o),[o,n]}(i,P,C,B,x),F=M[0],E=M[1],F>0&&E>0&&(I=s.ctx.createRadialGradient(b+P,y+C,0,b+P,y+C,F),Sf(i.stops,2*F).forEach((function(e){return I.addColorStop(e.stop,bf(e.color))})),s.path(v),s.ctx.fillStyle=I,F!==E?(D=e.bounds.left+.5*e.bounds.width,S=e.bounds.top+.5*e.bounds.height,R=1/(T=E/F),s.ctx.save(),s.ctx.translate(D,S),s.ctx.transform(1,0,0,T,0,0),s.ctx.translate(-D,-S),s.ctx.fillRect(b,R*(y-S)+S,B,x*R),s.ctx.restore()):s.ctx.fill())),L.label=6;case 6:return t--,[2]}}))},s=this,r=0,o=e.styles.backgroundImage.slice(0).reverse(),a.label=1;case 1:return r0?2!==l.style?[3,5]:[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,2)]:[3,11]:[3,13];case 4:return h.sent(),[3,11];case 5:return 3!==l.style?[3,7]:[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,3)];case 6:return h.sent(),[3,11];case 7:return 4!==l.style?[3,9]:[4,this.renderDoubleBorder(l.color,l.width,o,e.curves)];case 8:return h.sent(),[3,11];case 9:return[4,this.renderSolidBorder(l.color,o,e.curves)];case 10:h.sent(),h.label=11;case 11:o++,h.label=12;case 12:return n++,[3,3];case 13:return[2]}}))}))},t.prototype.renderDashedDottedBorder=function(e,t,i,s,r){return fd(this,void 0,void 0,(function(){var o,n,a,l,A,h,c,u,d,p,f,g,m,_,v,b;return gd(this,(function(y){return this.ctx.save(),o=function(e,t){switch(t){case 0:return Nv(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Nv(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Nv(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return Nv(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(s,i),n=Ov(s,i),2===r&&(this.path(n),this.ctx.clip()),wv(n[0])?(a=n[0].start.x,l=n[0].start.y):(a=n[0].x,l=n[0].y),wv(n[1])?(A=n[1].end.x,h=n[1].end.y):(A=n[1].x,h=n[1].y),c=0===i||2===i?Math.abs(a-A):Math.abs(l-h),this.ctx.beginPath(),3===r?this.formatPath(o):this.formatPath(n.slice(0,2)),u=t<3?3*t:2*t,d=t<3?2*t:t,3===r&&(u=t,d=t),p=!0,c<=2*u?p=!1:c<=2*u+d?(u*=f=c/(2*u+d),d*=f):(g=Math.floor((c+d)/(u+d)),m=(c-g*u)/(g-1),d=(_=(c-(g+1)*u)/g)<=0||Math.abs(d-m){})),yb(this,"_reject",(()=>{})),this.name=e,this.workerThread=t,this.result=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){pb(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){pb(this.isRunning),this.isRunning=!1,this._reject(e)}}class xb{}const wb=new Map;function Pb(e){pb(e.source&&!e.url||!e.source&&e.url);let t=wb.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return Cb((t=e,"try {\n importScripts('".concat(t,"');\n} catch (error) {\n console.error(error);\n throw error;\n}")));var t}(e.url),wb.set(e.url,t)),e.source&&(t=Cb(e.source),wb.set(e.source,t))),pb(t),t}function Cb(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function Mb(e,t=!0,i){const s=i||new Set;if(e){if(Fb(e))s.add(e);else if(Fb(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)Mb(e[i],t,s)}else;return void 0===i?Array.from(s):[]}function Fb(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const Eb=()=>{};class Ib{static isSupported(){return"undefined"!=typeof Worker&&mb||void 0!==typeof xb}constructor(e){yb(this,"name",void 0),yb(this,"source",void 0),yb(this,"url",void 0),yb(this,"terminated",!1),yb(this,"worker",void 0),yb(this,"onMessage",void 0),yb(this,"onError",void 0),yb(this,"_loadableURL","");const{name:t,source:i,url:s}=e;pb(i||s),this.name=t,this.source=i,this.url=s,this.onMessage=Eb,this.onError=e=>console.log(e),this.worker=mb?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Eb,this.onError=Eb,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||Mb(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+="worker ".concat(this.name," from ").concat(this.url,". "),e.message&&(t+="".concat(e.message," in ")),e.lineno&&(t+=":".concat(e.lineno,":").concat(e.colno)),new Error(t)}_createBrowserWorker(){this._loadableURL=Pb({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);e=new xb(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new xb(this.source,{eval:!0})}return e.on("message",(e=>{this.onMessage(e)})),e.on("error",(e=>{this.onError(e)})),e.on("exit",(e=>{})),e}}class Db{static isSupported(){return Ib.isSupported()}constructor(e){yb(this,"name","unnamed"),yb(this,"source",void 0),yb(this,"url",void 0),yb(this,"maxConcurrency",1),yb(this,"maxMobileConcurrency",1),yb(this,"onDebug",(()=>{})),yb(this,"reuseWorkers",!0),yb(this,"props",{}),yb(this,"jobQueue",[]),yb(this,"idleQueue",[]),yb(this,"count",0),yb(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach((e=>e.destroy())),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=((e,t,i)=>e.done(i)),i=((e,t)=>e.error(t))){const s=new Promise((s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this)));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new Bb(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class Tb{static isSupported(){return Ib.isSupported()}static getWorkerFarm(e={}){return Tb._workerFarm=Tb._workerFarm||new Tb({}),Tb._workerFarm.setProps(e),Tb._workerFarm}constructor(e){yb(this,"props",void 0),yb(this,"workerPools",new Map),this.props={...Sb},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:s}=e;let r=this.workerPools.get(t);return r||(r=new Db({name:t,source:i,url:s}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}yb(Tb,"_workerFarm",void 0);var Rb=Object.freeze({__proto__:null,default:{}});const Lb={};async function Ub(e,t=null,i={}){return t&&(e=function(e,t,i){if(e.startsWith("http"))return e;const s=i.modules||{};if(s[e])return s[e];if(!mb)return"modules/".concat(t,"/dist/libs/").concat(e);if(i.CDN)return pb(i.CDN.startsWith("http")),"".concat(i.CDN,"/").concat(t,"@").concat("3.2.6","/dist/libs/").concat(e);if(_b)return"../src/libs/".concat(e);return"modules/".concat(t,"/src/libs/").concat(e)}(e,t,i)),Lb[e]=Lb[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!mb)try{return Rb&&void 0}catch{return null}if(_b)return importScripts(e);const t=await fetch(e);return function(e,t){if(!mb)return;if(_b)return eval.call(gb,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(await t.text(),e)}(e),await Lb[e]}async function kb(e,t,i,s,r){const o=e.id,n=function(e,t={}){const i=t[e.id]||{},s="".concat(e.id,"-worker.js");let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r="modules/".concat(e.module,"/dist/").concat(s)),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?"@".concat(t):"";r="https://unpkg.com/@loaders.gl/".concat(e.module).concat(i,"/dist/").concat(s)}return pb(r),r}(e,i),a=Tb.getWorkerFarm(i).getWorkerPool({name:o,url:n});i=JSON.parse(JSON.stringify(i)),s=JSON.parse(JSON.stringify(s||{}));const l=await a.startJob("process-on-worker",Ob.bind(null,r));l.postMessage("process",{input:t,options:i,context:s});const A=await l.result;return await A.result}async function Ob(e,t,i,s){switch(i){case"done":t.done(s);break;case"error":t.error(new Error(s.error));break;case"process":const{id:r,input:o,options:n}=s;try{const i=await e(o,n);t.postMessage("done",{id:r,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:i})}break;default:console.warn("parse-with-worker unknown message ".concat(i))}}function Nb(e,t,i){if(e.byteLength<=t+i)return"";const s=new DataView(e);let r="";for(let e=0;e=0),cb(t>0),e+(t-1)&~(t-1)}function zb(e,t,i){let s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;s=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(s,i),i+Gb(s.byteLength,4)}async function Wb(e){const t=[];for await(const i of e)t.push(i);return function(...e){const t=e.map((e=>e instanceof ArrayBuffer?new Uint8Array(e):e)),i=t.reduce(((e,t)=>e+t.byteLength),0),s=new Uint8Array(i);let r=0;for(const e of t)s.set(e,r),r+=e.byteLength;return s.buffer}(...t)}const Kb={};const Xb=e=>"function"==typeof e,Jb=e=>null!==e&&"object"==typeof e,Yb=e=>Jb(e)&&e.constructor==={}.constructor,Zb=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,qb=e=>"undefined"!=typeof Blob&&e instanceof Blob,$b=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||Jb(e)&&Xb(e.tee)&&Xb(e.cancel)&&Xb(e.getReader))(e)||(e=>Jb(e)&&Xb(e.read)&&Xb(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e),ey=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ty=/^([-\w.]+\/[-\w.+]+)/;function iy(e){const t=ty.exec(e);return t?t[1]:e}function sy(e){const t=ey.exec(e);return t?t[1]:""}const ry=/\?.*/;function oy(e){if(Zb(e)){const t=ny(e.url||"");return{url:t,type:iy(e.headers.get("content-type")||"")||sy(t)}}return qb(e)?{url:ny(e.name||""),type:e.type||""}:"string"==typeof e?{url:ny(e),type:sy(e)}:{url:"",type:""}}function ny(e){return e.replace(ry,"")}async function ay(e){if(Zb(e))return e;const t={},i=function(e){return Zb(e)?e.headers["content-length"]||-1:qb(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const{url:s,type:r}=oy(e);r&&(t["content-type"]=r);const o=await async function(e){const t=5;if("string"==typeof e)return"data:,".concat(e.slice(0,t));if(e instanceof Blob){const t=e.slice(0,5);return await new Promise((e=>{const i=new FileReader;i.onload=t=>{var i;return e(null==t||null===(i=t.target)||void 0===i?void 0:i.result)},i.readAsDataURL(t)}))}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e=0)}();class py{constructor(e,t,i="sessionStorage"){this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function fy(e,t,i,s=600){const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));const o=e.width*i,n=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(n/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(n,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(n,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}const gy={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function my(e){return"string"==typeof e?gy[e.toUpperCase()]||gy.WHITE:e}function _y(e,t){if(!e)throw new Error(t||"Assertion failed")}function vy(){let e;if(dy&&hy.performance)e=hy.performance.now();else if(cy.hrtime){const t=cy.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const by={debug:dy&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},yy={enabled:!0,level:0};function By(){}const xy={},wy={once:!0};function Py(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}class Cy{constructor({id:e}={id:""}){this.id=e,this.VERSION=uy,this._startTs=vy(),this._deltaTs=vy(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new py("__probe-".concat(this.id,"__"),yy),this.userData={},this.timeStamp("".concat(this.id," started")),function(e,t=["constructor"]){const i=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(i);for(const i of s)"function"==typeof e[i]&&(t.find((e=>i===e))||(e[i]=e[i].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((vy()-this._startTs).toPrecision(10))}getDelta(){return Number((vy()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}assert(e,t){_y(e,t)}warn(e){return this._getLogFunction(0,e,by.warn,arguments,wy)}error(e){return this._getLogFunction(0,e,by.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,by.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,by.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,by.debug||by.info,arguments,wy)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||By,i&&[i],{tag:Py(t)}):By}image({logLevel:e,priority:t,image:i,message:s="",scale:r=1}){return this._shouldLog(e||t)?dy?function({image:e,message:t="",scale:i=1}){if("string"==typeof e){const s=new Image;return s.onload=()=>{const e=fy(s,t,i);console.log(...e)},s.src=e,By}const s=e.nodeName||"";if("img"===s.toLowerCase())return console.log(...fy(e,t,i)),By;if("canvas"===s.toLowerCase()){const s=new Image;return s.onload=()=>console.log(...fy(s,t,i)),s.src=e.toDataURL(),By}return By}({image:i,message:s,scale:r}):function({image:e,message:t="",scale:i=1}){let s=null;try{s=module.require("asciify-image")}catch(e){}if(s)return()=>s(e,{fit:"box",width:"".concat(Math.round(80*i),"%")}).then((e=>console.log(e)));return By}({image:i,message:s,scale:r}):By}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||By)}group(e,t,i={collapsed:!1}){i=Fy({logLevel:e,message:t,opts:i});const{collapsed:s}=i;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||By)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=My(e)}_getLogFunction(e,t,i,s=[],r){if(this._shouldLog(e)){r=Fy({logLevel:e,message:t,args:s,opts:r}),_y(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=vy();const o=r.tag||r.message;if(r.once){if(xy[o])return By;xy[o]=vy()}return t=function(e,t,i){if("string"==typeof t){const s=i.time?function(e,t=8){const i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),t=function(e,t,i){return dy||"string"!=typeof e||(t&&(t=my(t),e="[".concat(t,"m").concat(e,"")),i&&(t=my(i),e="[".concat(i+10,"m").concat(e,""))),e}(t,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return By}}function My(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return _y(Number.isFinite(t)&&t>=0),t}function Fy(e){const{logLevel:t,message:i}=e;e.logLevel=My(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==i;);switch(e.args=s,typeof t){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return _y("string"===r||"object"===r),Object.assign(e,e.opts)}Cy.VERSION=uy;const Ey=new Cy({id:"loaders.gl"});class Iy{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const Dy={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){yb(this,"console",void 0),this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:ub,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Sy={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function Ty(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state=e._state||{},e._state}const Ry=()=>{const e=Ty();return e.globalOptions=e.globalOptions||{...Dy},e.globalOptions};function Ly(e,t,i,s){return i=i||[],function(e,t){ky(e,null,Dy,Sy,t);for(const i of t){const s=e&&e[i.id]||{},r=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};ky(s,i.id,r,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const s={...e.options||{}};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(s,i),null===s.log&&(s.log=new Iy);return Ny(s,Ry()),Ny(s,t),s}(t,e,s)}function Uy(e,t){const i=Ry(),s=e||i;return"function"==typeof s.fetch?s.fetch:Jb(s.fetch)?e=>ly(e,s):null!=t&&t.fetch?null==t?void 0:t.fetch:ly}function ky(e,t,i,s,r){const o=t||"Top level",n=t?"".concat(t,"."):"";for(const a in e){const l=!t&&Jb(e[a]),A="baseUri"===a&&!t,h="workerUrl"===a&&t;if(!(a in i)&&!A&&!h)if(a in s)Ey.warn("".concat(o," loader option '").concat(n).concat(a,"' no longer supported, use '").concat(s[a],"'"))();else if(!l){const e=Oy(a,r);Ey.warn("".concat(o," loader option '").concat(n).concat(a,"' not recognized. ").concat(e))()}}}function Oy(e,t){const i=e.toLowerCase();let s="";for(const r of t)for(const t in r.options){if(e===t)return"Did you mean '".concat(r.id,".").concat(t,"'?");const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(s=s||"Did you mean '".concat(r.id,".").concat(t,"'?"))}return s}function Ny(e,t){for(const i in t)if(i in t){const s=t[i];Yb(s)&&Yb(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function Qy(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function Vy(e){var t,i;let s;return cb(e,"null loader"),cb(Qy(e),"invalid loader"),Array.isArray(e)&&(s=e[1],e=e[0],e={...e,options:{...e.options,...s}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(i=e)&&void 0!==i&&i.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}function Hy(){return(()=>{const e=Ty();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry})()}function jy(){return!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||function(e){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof process&&"object"==typeof process.versions&&Boolean(process.versions.electron))return!0;const t="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,i=e||t;return!!(i&&i.indexOf("Electron")>=0)}()}const Gy={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"==typeof process&&process},zy=Gy.window||Gy.self||Gy.global,Wy=Gy.process||{},Ky="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";jy();class Xy{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";yb(this,"storage",void 0),yb(this,"id",void 0),yb(this,"config",{}),this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function Jy(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));const o=e.width*i,n=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(n/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(n,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(n,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}let Yy;function Zy(e){return"string"==typeof e?Yy[e.toUpperCase()]||Yy.WHITE:e}function qy(e,t){if(!e)throw new Error(t||"Assertion failed")}function $y(){let e;var t,i;if(jy&&"performance"in zy)e=null==zy||null===(t=zy.performance)||void 0===t||null===(i=t.now)||void 0===i?void 0:i.call(t);else if("hrtime"in Wy){var s;const t=null==Wy||null===(s=Wy.hrtime)||void 0===s?void 0:s.call(Wy);e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(Yy||(Yy={}));const eB={debug:jy&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},tB={enabled:!0,level:0};function iB(){}const sB={},rB={once:!0};class oB{constructor(){let{id:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};yb(this,"id",void 0),yb(this,"VERSION",Ky),yb(this,"_startTs",$y()),yb(this,"_deltaTs",$y()),yb(this,"_storage",void 0),yb(this,"userData",{}),yb(this,"LOG_THROTTLE_TIMEOUT",0),this.id=e,this._storage=new Xy("__probe-".concat(this.id,"__"),tB),this.userData={},this.timeStamp("".concat(this.id," started")),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const i=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(i);for(const i of s)"function"==typeof e[i]&&(t.find((e=>i===e))||(e[i]=e[i].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number(($y()-this._startTs).toPrecision(10))}getDelta(){return Number(($y()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){qy(e,t)}warn(e){return this._getLogFunction(0,e,eB.warn,arguments,rB)}error(e){return this._getLogFunction(0,e,eB.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,eB.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,eB.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){for(var i=arguments.length,s=new Array(i>2?i-2:0),r=2;r{const t=Jy(e,i,s);console.log(...t)},e.src=t,iB}const r=t.nodeName||"";if("img"===r.toLowerCase())return console.log(...Jy(t,i,s)),iB;if("canvas"===r.toLowerCase()){const e=new Image;return e.onload=()=>console.log(...Jy(e,i,s)),e.src=t.toDataURL(),iB}return iB}({image:s,message:r,scale:o}):function(e){let{image:t,message:i="",scale:s=1}=e,r=null;try{r=module.require("asciify-image")}catch(e){}if(r)return()=>r(t,{fit:"box",width:"".concat(Math.round(80*s),"%")}).then((e=>console.log(e)));return iB}({image:s,message:r,scale:o}):iB}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||iB)}group(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const s=aB({logLevel:e,message:t,opts:i}),{collapsed:r}=i;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||iB)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=nB(e)}_getLogFunction(e,t,i,s,r){if(this._shouldLog(e)){r=aB({logLevel:e,message:t,args:s,opts:r}),qy(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=$y();const o=r.tag||r.message;if(r.once){if(sB[o])return iB;sB[o]=$y()}return t=function(e,t,i){if("string"==typeof t){const s=i.time?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),t=function(e,t,i){return jy||"string"!=typeof e||(t&&(t=Zy(t),e="[".concat(t,"m").concat(e,"")),i&&(t=Zy(i),e="[".concat(i+10,"m").concat(e,""))),e}(t,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return iB}}function nB(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return qy(Number.isFinite(t)&&t>=0),t}function aB(e){const{logLevel:t,message:i}=e;e.logLevel=nB(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return qy("string"===r||"object"===r),Object.assign(e,{args:s},e.opts)}function lB(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}yb(oB,"VERSION",Ky);const AB=new oB({id:"loaders.gl"}),hB=/\.([^.]+)$/;function cB(e,t=[],i,s){if(!uB(e))return null;if(t&&!Array.isArray(t))return Vy(t);let r=[];t&&(r=r.concat(t)),null!=i&&i.ignoreRegisteredLoaders||r.push(...Hy()),function(e){for(const t of e)Vy(t)}(r);const o=function(e,t,i,s){const{url:r,type:o}=oy(e),n=r||(null==s?void 0:s.url);let a=null,l="";null!=i&&i.mimeType&&(a=pB(t,null==i?void 0:i.mimeType),l="match forced by supplied MIME type ".concat(null==i?void 0:i.mimeType));var A;a=a||function(e,t){const i=t&&hB.exec(t),s=i&&i[1];return s?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,s):null}(t,n),l=l||(a?"matched url ".concat(n):""),a=a||pB(t,o),l=l||(a?"matched MIME type ".concat(o):""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(fB(t,i))return i}else if(ArrayBuffer.isView(t)){if(gB(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(gB(t,0,i))return i}return null}(t,e),l=l||(a?"matched initial data ".concat(mB(e)):""),a=a||pB(t,null==i?void 0:i.fallbackMimeType),l=l||(a?"matched fallback MIME type ".concat(o):""),l&&AB.log(1,"selectLoader selected ".concat(null===(A=a)||void 0===A?void 0:A.name,": ").concat(l,"."));return a}(e,r,i,s);if(!(o||null!=i&&i.nothrow))throw new Error(dB(e));return o}function uB(e){return!(e instanceof Response&&204===e.status)}function dB(e){const{url:t,type:i}=oy(e);let s="No valid loader found (";s+=t?"".concat(function(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(t+1):""}(t),", "):"no url provided, ",s+="MIME type: ".concat(i?'"'.concat(i,'"'):"not provided",", ");const r=e?mB(e):"";return s+=r?' first bytes: "'.concat(r,'"'):"first bytes: not available",s+=")",s}function pB(e,t){for(const i of e){if(i.mimeTypes&&i.mimeTypes.includes(t))return i;if(t==="application/x.".concat(i.id))return i}return null}function fB(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some((t=>e.startsWith(t)))}function gB(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some((s=>function(e,t,i,s){if(s instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLength60?"".concat(t.slice(0,60),"..."):t}catch(e){}return t}(e);throw new Error(t)}}(i),t.binary?await i.arrayBuffer():await i.text()}if($b(e)&&(e=yB(e,i)),(r=e)&&"function"==typeof r[Symbol.iterator]||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return Wb(e);var r;throw new Error(BB)}async function wB(e,t,i,s){pb(!s||"object"==typeof s),!t||Array.isArray(t)||Qy(t)||(s=void 0,i=t,t=void 0),e=await e,i=i||{};const{url:r}=oy(e),o=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:null}(t,s),n=await async function(e,t=[],i,s){if(!uB(e))return null;let r=cB(e,t,{...i,nothrow:!0},s);if(r)return r;if(qb(e)&&(r=cB(e=await e.slice(0,10).arrayBuffer(),t,i,s)),!(r||null!=i&&i.nothrow))throw new Error(dB(e));return r}(e,o,i);return n?(s=function(e,t,i=null){if(i)return i;const s={fetch:Uy(t,e),...e};return Array.isArray(s.loaders)||(s.loaders=null),s}({url:r,parse:wB,loaders:o},i=Ly(i,n,o,r),s),await async function(e,t,i,s){if(function(e,t="3.2.6"){pb(e,"no worker provided");const i=e.version}(e),Zb(t)){const e=t,{ok:i,redirected:r,status:o,statusText:n,type:a,url:l}=e,A=Object.fromEntries(e.headers.entries());s.response={headers:A,ok:i,redirected:r,status:o,statusText:n,type:a,url:l}}if(t=await xB(t,e,i),e.parseTextSync&&"string"==typeof t)return i.dataType="text",e.parseTextSync(t,i,s,e);if(function(e,t){return!!Tb.isSupported()&&!!(mb||null!=t&&t._nodeWorkers)&&e.worker&&(null==t?void 0:t.worker)}(e,i))return await kb(e,t,i,s,wB);if(e.parseText&&"string"==typeof t)return await e.parseText(t,i,s,e);if(e.parse)return await e.parse(t,i,s,e);throw pb(!e.parseSync),new Error("".concat(e.id," loader - no parser found and worker is disabled"))}(n,e,i,s)):null}const PB="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.wasm"),CB="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.js");let MB,FB;async function EB(e){const t=e.modules||{};return t.basis?t.basis:(MB=MB||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await Ub("basis_transcoder.js","textures",e),await Ub("basis_transcoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e(i).then((e=>{const{BasisFile:i,initializeBasis:s}=e;s(),t({BasisFile:i})}))}))}(t,i)}(e),await MB)}async function IB(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(FB=FB||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await Ub(CB,"textures",e),await Ub(PB,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e(i).then((e=>{const{BasisFile:i,KTX2File:s,initializeBasis:r,BasisEncoder:o}=e;r(),t({BasisFile:i,KTX2File:s,BasisEncoder:o})}))}))}(t,i)}(e),await FB)}const DB=33776,SB=33779,TB=35840,RB=35842,LB=36196,UB=37808,kB=["","WEBKIT_","MOZ_"],OB={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let NB=null;function QB(e){if(!NB){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,NB=new Set;for(const t of kB)for(const i in OB)if(e&&e.getExtension("".concat(t).concat(i))){const e=OB[i];NB.add(e)}}return NB}var VB,HB,jB,GB,zB,WB,KB,XB,JB;(JB=VB||(VB={}))[JB.NONE=0]="NONE",JB[JB.BASISLZ=1]="BASISLZ",JB[JB.ZSTD=2]="ZSTD",JB[JB.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(HB||(HB={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(jB||(jB={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(GB||(GB={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(zB||(zB={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(WB||(WB={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(KB||(KB={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(XB||(XB={}));const YB=[171,75,84,88,32,50,48,187,13,10,26,10];const ZB={etc1:{basisFormat:0,compressed:!0,format:LB},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:DB},bc3:{basisFormat:3,compressed:!0,format:SB},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:TB},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:RB},"astc-4x4":{basisFormat:10,compressed:!0,format:UB},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function qB(e,t,i){const s=new e(new Uint8Array(t));try{if(!s.startTranscoding())throw new Error("Failed to start basis transcoding");const e=s.getNumImages(),t=[];for(let r=0;r{try{i.onload=()=>t(i),i.onerror=t=>s(new Error("Could not load image ".concat(e,": ").concat(t)))}catch(e){s(e)}}))}(o||s,t)}finally{o&&r.revokeObjectURL(o)}}const gx={};let mx=!0;async function _x(e,t,i){let s;if(dx(i)){s=await fx(e,t,i)}else s=px(e,i);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||gx)return!1;return!0}(t)&&mx||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),mx=!1}return await createImageBitmap(e)}(s,r)}function vx(e){const t=bx(e);return function(e){const t=bx(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,false)))return null;return{mimeType:"image/png",width:t.getUint32(16,false),height:t.getUint32(20,false)}}(t)||function(e){const t=bx(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,false)&&255===t.getUint8(2)))return null;const{tableMarkers:i,sofMarkers:s}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r+9=10&&1195984440===t.getUint32(0,false)))return null;return{mimeType:"image/gif",width:t.getUint16(6,true),height:t.getUint16(8,true)}}(t)||function(e){const t=bx(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,false)&&t.getUint32(2,true)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,true),height:t.getUint32(22,true)}}(t)}function bx(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const yx={id:"image",module:"images",name:"Images",version:"3.2.6",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,i){const s=((t=t||{}).image||{}).type||"auto",{url:r}=i||{};let o;switch(function(e){switch(e){case"auto":case"data":return function(){if(ax)return"imagebitmap";if(nx)return"image";if(Ax)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return ax||nx||Ax;case"imagebitmap":return ax;case"image":return nx;case"data":return Ax;default:throw new Error("@loaders.gl/images: image ".concat(e," not supported in this environment"))}}(e),e}}(s)){case"imagebitmap":o=await _x(e,t,r);break;case"image":o=await fx(e,t,r);break;case"data":o=await async function(e,t){const{mimeType:i}=vx(e)||{},s=globalThis._parseImageNode;return cb(s),await s(e,i)}(e);break;default:cb(!1)}return"data"===s&&(o=function(e){switch(hx(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}(o)),o},tests:[e=>Boolean(vx(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Bx=["image/png","image/jpeg","image/gif"],xx={};function wx(e){return void 0===xx[e]&&(xx[e]=function(e){switch(e){case"image/webp":return function(){if(!ub)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch{return!1}}();case"image/svg":return ub;default:if(!ub){const{_parseImageNode:t}=globalThis;return Boolean(t)&&Bx.includes(e)}return!0}}(e)),xx[e]}function Px(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function Cx(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error("'baseUri' must be provided to resolve relative url ".concat(e));return i.substr(0,i.lastIndexOf("/")+1)+e}const Mx=["SCALAR","VEC2","VEC3","VEC4"],Fx=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Ex=new Map(Fx),Ix={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Dx={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Sx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Tx(e){return Mx[e-1]||Mx[0]}function Rx(e){const t=Ex.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Lx(e,t){const i=Sx[e.componentType],s=Ix[e.type],r=Dx[e.componentType],o=e.count*s,n=e.count*s*r;return Px(n>=0&&n<=t.byteLength),{ArrayType:i,length:o,byteLength:n}}const Ux={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class kx{constructor(e){yb(this,"gltf",void 0),yb(this,"sourceBuffers",void 0),yb(this,"byteLength",void 0),this.gltf=e||{json:{...Ux},buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find((t=>t===e)),i=this.json.extensions||{};return t?i[e]||!0:null}getRequiredExtension(e){const t=this.getRequiredExtensions().find((t=>t===e));return t?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error("glTF file error: Could not find ".concat(e,"[").concat(t,"]"));return i}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];Px(i);const s=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,{ArrayType:s,length:r}=Lx(e,t);return new s(i,t.byteOffset+e.byteOffset,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(i,s,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,i){return e.extensions=e.extensions||{},e.extensions[t]=i,this.registerUsedExtension(t),this}setObjectExtension(e,t,i){(e.extensions||{})[t]=i}removeObjectExtension(e,t){const i=e.extensions||{},s=i[t];return delete i[t],s}addExtension(e,t={}){return Px(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return Px(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((t=>t===e))||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((t=>t===e))||this.json.extensionsRequired.push(e)}removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const s={mesh:t};return i&&(s.matrix=i),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:s,mode:r=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(i){const e=this._addIndices(i);o.primitives[0].indices=e}return Number.isFinite(s)&&(o.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=vx(e),s=t||(null==i?void 0:i.mimeType),r={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e){const t=e.byteLength;Px(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const i={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=Gb(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:Tx(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const i=this.addBufferView(e);let s={min:t.min,max:t.max};s.min&&s.max||(s=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:Rx(e),count:Math.round(e.length/t.size),min:s.min,max:s.max};return this.addAccessor(i,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const i=this.byteLength,s=new ArrayBuffer(i),r=new Uint8Array(s);let o=0;for(const e of this.sourceBuffers||[])o=zb(e,r,o);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=i:this.json.buffers=[{byteLength:i}],this.gltf.binary=s,this.sourceBuffers=[s]}_removeStringFromArray(e,t){let i=!0;for(;i;){const s=e.indexOf(t);s>-1?e.splice(s,1):i=!1}}_addAttributes(e={}){const t={};for(const i in e){const s=e[i],r=this._getGltfAttributeName(i),o=this.addBinaryBuffer(s.value,s);t[r]=o}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const i={min:null,max:null};if(e.length96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let i=0;for(let s=0;st[e.name]));return new Zx(i,this.metadata)}selectAt(...e){const t=e.map((e=>this.fields[e])).filter(Boolean);return new Zx(t,this.metadata)}assign(e){let t,i=this.metadata;if(e instanceof Zx){const s=e;t=s.fields,i=qx(qx(new Map,this.metadata),s.metadata)}else t=e;const s=Object.create(null);for(const e of this.fields)s[e.name]=e;for(const e of t)s[e.name]=e;const r=Object.values(s);return new Zx(r,i)}}function qx(e,t){return new Map([...e||new Map,...t||new Map])}class $x{constructor(e,t,i=!1,s=new Map){yb(this,"name",void 0),yb(this,"type",void 0),yb(this,"nullable",void 0),yb(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=i,this.metadata=s}get typeId(){return this.type&&this.type.typeId}clone(){return new $x(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}let ew,tw,iw,sw;!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(ew||(ew={}));class rw{static isNull(e){return e&&e.typeId===ew.Null}static isInt(e){return e&&e.typeId===ew.Int}static isFloat(e){return e&&e.typeId===ew.Float}static isBinary(e){return e&&e.typeId===ew.Binary}static isUtf8(e){return e&&e.typeId===ew.Utf8}static isBool(e){return e&&e.typeId===ew.Bool}static isDecimal(e){return e&&e.typeId===ew.Decimal}static isDate(e){return e&&e.typeId===ew.Date}static isTime(e){return e&&e.typeId===ew.Time}static isTimestamp(e){return e&&e.typeId===ew.Timestamp}static isInterval(e){return e&&e.typeId===ew.Interval}static isList(e){return e&&e.typeId===ew.List}static isStruct(e){return e&&e.typeId===ew.Struct}static isUnion(e){return e&&e.typeId===ew.Union}static isFixedSizeBinary(e){return e&&e.typeId===ew.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===ew.FixedSizeList}static isMap(e){return e&&e.typeId===ew.Map}static isDictionary(e){return e&&e.typeId===ew.Dictionary}get typeId(){return ew.NONE}compareTo(e){return this===e}}tw=Symbol.toStringTag;class ow extends rw{constructor(e,t){super(),yb(this,"isSigned",void 0),yb(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return ew.Int}get[tw](){return"Int"}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}class nw extends ow{constructor(){super(!0,8)}}class aw extends ow{constructor(){super(!0,16)}}class lw extends ow{constructor(){super(!0,32)}}class Aw extends ow{constructor(){super(!1,8)}}class hw extends ow{constructor(){super(!1,16)}}class cw extends ow{constructor(){super(!1,32)}}const uw=32,dw=64;iw=Symbol.toStringTag;class pw extends rw{constructor(e){super(),yb(this,"precision",void 0),this.precision=e}get typeId(){return ew.Float}get[iw](){return"Float"}toString(){return"Float".concat(this.precision)}}class fw extends pw{constructor(){super(uw)}}class gw extends pw{constructor(){super(dw)}}sw=Symbol.toStringTag;class mw extends rw{constructor(e,t){super(),yb(this,"listSize",void 0),yb(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return ew.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[sw](){return"FixedSizeList"}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}function _w(e,t,i){const s=function(e){switch(e.constructor){case Int8Array:return new nw;case Uint8Array:return new Aw;case Int16Array:return new aw;case Uint16Array:return new hw;case Int32Array:return new lw;case Uint32Array:return new cw;case Float32Array:return new fw;case Float64Array:return new gw;default:throw new Error("array type not supported")}}(t.value),r=i||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new $x(e,new mw(t.size,new $x("value",s)),!1,r)}function vw(e,t,i){return _w(e,t,i?bw(i.metadata):void 0)}function bw(e){const t=new Map;for(const i in e)t.set("".concat(i,".string"),JSON.stringify(e[i]));return t}const yw={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Bw={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class xw{constructor(e){yb(this,"draco",void 0),yb(this,"decoder",void 0),yb(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const s=this.decoder.GetEncodedGeometryType(i),r=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(s){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t="DRACO decompression failed: ".concat(e.error_msg());throw new Error(t)}const o=this._getDracoLoaderData(r,s,t),n=this._getMeshData(r,o,t),a=function(e){let t=1/0,i=1/0,s=1/0,r=-1/0,o=-1/0,n=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;er?l:r,o=A>o?A:o,n=h>n?h:n}return[[t,i,s],[r,o,n]]}(n.attributes),l=function(e,t,i){const s=bw(t.metadata),r=[],o=function(e){const t={};for(const i in e){const s=e[i];t[s.name||"undefined"]=s}return t}(t.attributes);for(const t in e){const i=vw(t,e[t],o[t]);r.push(i)}if(i){const e=vw("indices",i);r.push(e)}return new Zx(r,s)}(n.attributes,o,n.indices);return{loader:"draco",loaderData:o,header:{vertexCount:r.num_points(),boundingBox:a},...n,schema:l}}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,i){const s=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:r}}_getDracoAttributes(e,t){const i={};for(let s=0;sthis.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map((e=>t.min_value(e)))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,s=e.attribute_type();if(i.map((e=>this.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const ww="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.js"),Pw="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_wasm_wrapper.js"),Cw="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.wasm");let Mw;async function Fw(e){const t=e.modules||{};return Mw=t.draco3d?Mw||t.draco3d.createDecoderModule({}).then((e=>({draco:e}))):Mw||async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await Ub(ww,"draco",e);else[t,i]=await Promise.all([await Ub(Pw,"draco",e),await Ub(Cw,"draco",e)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e({...i,onModuleLoaded:e=>t({draco:e})})}))}(t,i)}(e),await Mw}const Ew={...Yx,parse:async function(e,t){const{draco:i}=await Fw(t),s=new xw(i);try{return s.parseSync(e,null==t?void 0:t.draco)}finally{s.destroy()}}};function Iw(e){const{buffer:t,size:i,count:s}=function(e){let t=e,i=1,s=0;e&&e.value&&(t=e.value,i=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,i=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),s=t.length/i);return{buffer:t,size:i,count:s}}(e);return{value:t,size:i,byteOffset:0,count:s,type:Tx(i),componentType:Rx(t)}}async function Dw(e,t,i,s){const r=e.getObjectExtension(t,"KHR_draco_mesh_compression");if(!r)return;const o=e.getTypedArrayForBufferView(r.bufferView),n=jb(o.buffer,o.byteOffset),{parse:a}=s,l={...i};delete l["3d-tiles"];const A=await a(n,Ew,l,s),h=function(e){const t={};for(const i in e){const s=e[i];if("indices"!==i){const e=Iw(s);t[i]=e}}return t}(A.attributes);for(const[i,s]of Object.entries(h))if(i in t.attributes){const r=t.attributes[i],o=e.getAccessor(r);null!=o&&o.min&&null!=o&&o.max&&(s.min=o.min,s.max=o.max)}t.attributes=h,A.indices&&(t.indices=Iw(A.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function Sw(e,t,i=4,s,r){var o;if(!s.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const n=s.DracoWriter.encodeSync({attributes:e}),a=null==r||null===(o=r.parseSync)||void 0===o?void 0:o.call(r,{attributes:e}),l=s._addFauxAttributes(a.attributes);return{primitives:[{attributes:l,mode:i,extensions:{KHR_draco_mesh_compression:{bufferView:s.addBufferView(n),attributes:l}}}]}}function*Tw(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var Rw=Object.freeze({__proto__:null,name:"KHR_draco_mesh_compression",preprocess:function(e,t,i){const s=new kx(e);for(const e of Tw(s))s.getObjectExtension(e,"KHR_draco_mesh_compression")},decode:async function(e,t,i){var s;if(null==t||null===(s=t.gltf)||void 0===s||!s.decompressMeshes)return;const r=new kx(e),o=[];for(const e of Tw(r))r.getObjectExtension(e,"KHR_draco_mesh_compression")&&o.push(Dw(r,e,t,i));await Promise.all(o),r.removeExtension("KHR_draco_mesh_compression")},encode:function(e,t={}){const i=new kx(e);for(const e of i.json.meshes||[])Sw(e),i.addRequiredExtension("KHR_draco_mesh_compression")}});var Lw=Object.freeze({__proto__:null,name:"KHR_lights_punctual",decode:async function(e){const t=new kx(e),{json:i}=t,s=t.getExtension("KHR_lights_punctual");s&&(t.json.lights=s.lights,t.removeExtension("KHR_lights_punctual"));for(const e of i.nodes||[]){const i=t.getObjectExtension(e,"KHR_lights_punctual");i&&(e.light=i.light),t.removeObjectExtension(e,"KHR_lights_punctual")}},encode:async function(e){const t=new kx(e),{json:i}=t;if(i.lights){const e=t.addExtension("KHR_lights_punctual");Px(!e.lights),e.lights=i.lights,delete i.lights}if(t.json.lights){for(const e of t.json.lights){const i=e.node;t.addObjectExtension(i,"KHR_lights_punctual",e)}delete t.json.lights}}});function Uw(e,t){const i=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach((t=>{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)})),Object.keys(i).forEach((e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))})),i}const kw=[Kx,Xx,Jx,Rw,Lw,Object.freeze({__proto__:null,name:"KHR_materials_unlit",decode:async function(e){const t=new kx(e),{json:i}=t;t.removeExtension("KHR_materials_unlit");for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,"KHR_materials_unlit")}},encode:function(e){const t=new kx(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}}),Object.freeze({__proto__:null,name:"KHR_techniques_webgl",decode:async function(e){const t=new kx(e),{json:i}=t,s=t.getExtension("KHR_techniques_webgl");if(s){const e=function(e,t){const{programs:i=[],shaders:s=[],techniques:r=[]}=e,o=new TextDecoder;return s.forEach((e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))})),i.forEach((e=>{e.fragmentShader=s[e.fragmentShader],e.vertexShader=s[e.vertexShader]})),r.forEach((e=>{e.program=i[e.program]})),r}(s,t);for(const s of i.materials||[]){const i=t.getObjectExtension(s,"KHR_techniques_webgl");i&&(s.technique=Object.assign({},i,e[i.technique]),s.technique.values=Uw(s.technique,t)),t.removeObjectExtension(s,"KHR_techniques_webgl")}t.removeExtension("KHR_techniques_webgl")}},encode:async function(e,t){}})];function Ow(e,t){var i;const s=(null==t||null===(i=t.gltf)||void 0===i?void 0:i.excludeExtensions)||{};return!(e in s&&!s[e])}const Nw={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Qw={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class Vw{constructor(){yb(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),yb(this,"json",void 0)}normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version ".concat(i.asset.version))}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new kx(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,"KHR_binary_glTF");i&&Object.assign(e,i),t.removeObjectExtension(e,"KHR_binary_glTF")}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in Nw)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const s in i){const r=i[s];r.id=r.id||s;const o=e[t].length;e[t].push(r),this.idToIndexMap[t][s]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in Nw)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:s}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),s&&(t.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map((e=>this._convertIdToIndex(e,"node")))),e.meshes&&(e.meshes=e.meshes.map((e=>this._convertIdToIndex(e,"mesh"))))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map((e=>this._convertIdToIndex(e,"node"))))}_convertIdsToIndices(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute ".concat(t)),e[t]=[]);for(const i of e[t])for(const e in i){const t=i[e],s=this._convertIdToIndex(t,e);i[e]=s}}_convertIdToIndex(e,t){const i=Qw[t];if(i in this.idToIndexMap){const s=this.idToIndexMap[i][e];if(!Number.isFinite(s))throw new Error("gltf v1: failed to resolve ".concat(t," with id ").concat(e));return s}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const s of e.materials){var t,i;s.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const r=(null===(t=s.values)||void 0===t?void 0:t.tex)||(null===(i=s.values)||void 0===i?void 0:i.texture2d_0),o=e.textures.findIndex((e=>e.id===r));-1!==o&&(s.pbrMetallicRoughness.baseColorTexture={index:o})}}}const Hw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jw={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Gw=10240,zw=10241,Ww=10242,Kw=10243,Xw=10497,Jw={magFilter:Gw,minFilter:zw,wrapS:Ww,wrapT:Kw},Yw={[Gw]:9729,[zw]:9986,[Ww]:Xw,[Kw]:Xw};class Zw{constructor(){yb(this,"baseUri",""),yb(this,"json",{}),yb(this,"buffers",[]),yb(this,"images",[])}postProcess(e,t={}){const{json:i,buffers:s=[],images:r=[],baseUri:o=""}=e;return Px(i),this.baseUri=o,this.json=i,this.buffers=s,this.images=r,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map(((e,t)=>this._resolveBufferView(e,t)))),e.images&&(e.images=e.images.map(((e,t)=>this._resolveImage(e,t)))),e.samplers&&(e.samplers=e.samplers.map(((e,t)=>this._resolveSampler(e,t)))),e.textures&&(e.textures=e.textures.map(((e,t)=>this._resolveTexture(e,t)))),e.accessors&&(e.accessors=e.accessors.map(((e,t)=>this._resolveAccessor(e,t)))),e.materials&&(e.materials=e.materials.map(((e,t)=>this._resolveMaterial(e,t)))),e.meshes&&(e.meshes=e.meshes.map(((e,t)=>this._resolveMesh(e,t)))),e.nodes&&(e.nodes=e.nodes.map(((e,t)=>this._resolveNode(e,t)))),e.skins&&(e.skins=e.skins.map(((e,t)=>this._resolveSkin(e,t)))),e.scenes&&(e.scenes=e.scenes.map(((e,t)=>this._resolveScene(e,t)))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];return i||console.warn("glTF file error: Could not find ".concat(e,"[").concat(t,"]")),i}_resolveScene(e,t){return e.id=e.id||"scene-".concat(t),e.nodes=(e.nodes||[]).map((e=>this.getNode(e))),e}_resolveNode(e,t){return e.id=e.id||"node-".concat(t),e.children&&(e.children=e.children.map((e=>this.getNode(e)))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce(((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e}),{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-".concat(t),e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-".concat(t),e.primitives&&(e.primitives=e.primitives.map((e=>{const t=(e={...e}).attributes;e.attributes={};for(const i in t)e.attributes[i]=this.getAccessor(t[i]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e}))),e}_resolveMaterial(e,t){if(e.id=e.id||"material-".concat(t),e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var i,s;if(e.id=e.id||"accessor-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(i=e.componentType,jw[i]),e.components=(s=e.type,Hw[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:i,byteLength:s}=Lx(e,e.bufferView),r=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset;let o=t.arrayBuffer.slice(r,r+s);e.bufferView.byteStride&&(o=this._getValueFromInterleavedBuffer(t,r,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new i(o)}return e}_getValueFromInterleavedBuffer(e,t,i,s,r){const o=new Uint8Array(r*s);for(let n=0;n20);const s=t.getUint32(i+0,$w),r=t.getUint32(i+4,$w);return i+=8,cb(0===r),tP(e,t,i,s),i+=s,i+=iP(e,t,i,e.header.byteLength)}(e,r,i);case 2:return function(e,t,i,s){return cb(e.header.byteLength>20),function(e,t,i,s){for(;i+8<=e.header.byteLength;){const r=t.getUint32(i+0,$w),o=t.getUint32(i+4,$w);switch(i+=8,o){case 1313821514:tP(e,t,i,r);break;case 5130562:iP(e,t,i,r);break;case 0:s.strict||tP(e,t,i,r);break;case 1:s.strict||iP(e,t,i,r)}i+=Gb(r,4)}}(e,t,i,s),i+e.header.byteLength}(e,r,i,{});default:throw new Error("Invalid GLB version ".concat(e.version,". Only supports v1 and v2."))}}function tP(e,t,i,s){const r=new Uint8Array(t.buffer,i,s),o=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(o),Gb(s,4)}function iP(e,t,i,s){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:s,arrayBuffer:t.buffer}),Gb(s,4)}async function sP(e,t,i=0,s,r){var o,n,a,l;!function(e,t,i,s){s.uri&&(e.baseUri=s.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,i={}){const s=new DataView(e),{magic:r=qw}=i,o=s.getUint32(t,!1);return o===r||o===qw}(t,i,s)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=Qb(t);else if(t instanceof ArrayBuffer){const r={};i=eP(r,t,i,s.glb),Px("glTF"===r.type,"Invalid GLB magic string ".concat(r.type)),e._glb=r,e.json=r.json}else Px(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,i,s),function(e,t={}){(new Vw).normalize(e,t)}(e,{normalize:null==s||null===(o=s.gltf)||void 0===o?void 0:o.normalize}),function(e,t={},i){const s=kw.filter((e=>Ow(e.name,t)));for(const o of s){var r;null===(r=o.preprocess)||void 0===r||r.call(o,e,t,i)}}(e,s,r);const A=[];if(null!=s&&null!==(n=s.gltf)&&void 0!==n&&n.loadBuffers&&e.json.buffers&&await async function(e,t,i){const s=e.json.buffers||[];for(let n=0;nOw(e.name,t)));for(const o of s){var r;await(null===(r=o.decode)||void 0===r?void 0:r.call(o,e,t,i))}}(e,s,r);return A.push(h),await Promise.all(A),null!=s&&null!==(l=s.gltf)&&void 0!==l&&l.postProcess?function(e,t){return(new Zw).postProcess(e,t)}(e,s):e}async function rP(e,t,i,s,r){const{fetch:o,parse:n}=r;let a;if(t.uri){const e=Cx(t.uri,s),i=await o(e);a=await i.arrayBuffer()}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const s=e.bufferViews[i];Px(s);const r=t[s.buffer];Px(r);const o=(s.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,o,s.byteLength)}(e.json,e.buffers,t.bufferView);a=jb(i.buffer,i.byteOffset,i.byteLength)}Px(a,"glTF image has no data");let l=await n(a,[yx,rx],{mimeType:t.mimeType,basis:s.basis||{format:sx()}},r);l&&l[0]&&(l={compressed:!0,mipmaps:!1,width:l[0].width,height:l[0].height,data:l[0]}),e.images=e.images||[],e.images[i]=l}const oP={name:"glTF",id:"gltf",module:"gltf",version:"3.2.6",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},i){(t={...oP.options,...t}).gltf={...oP.options.gltf,...t.gltf};const{byteOffset:s=0}=t;return await sP({},e,s,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};class nP{constructor(e){}load(e,t,i,s,r,o,n){!function(e,t,i,s,r,o,n){const a=e.viewer.scene.canvas.spinner;a.processes++;"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(n=>{s.basePath=lP(t),AP(e,t,n,i,s,r,o),a.processes--}),(e=>{a.processes--,n(e)})):e.dataSource.getGLTF(t,(n=>{s.basePath=lP(t),AP(e,t,n,i,s,r,o),a.processes--}),(e=>{a.processes--,n(e)}))}(e,t,i,s=s||{},r,(function(){I.scheduleTask((function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1)})),o&&o()}),(function(t){e.error(t),n&&n(t),r.fire("error",t)}))}parse(e,t,i,s,r,o,n){AP(e,"",t,i,s=s||{},r,(function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1),o&&o()}))}}function aP(e){const t={},i={},s=e.metaObjects||[],r={};for(let e=0,t=s.length;e{const l={src:t,metaModelCorrections:s?aP(s):null,loadBuffer:r.loadBuffer,basePath:r.basePath,handlenode:r.handlenode,backfaces:!!r.backfaces,gltfData:i,scene:o.scene,plugin:e,sceneModel:o,numObjects:0,nodes:[],nextId:0,log:t=>{e.log(t)}};!function(e){const t=e.gltfData.textures;if(t)for(let i=0,s=t.length;i0)for(let t=0;t0){null==n&&e.log("Warning: 'name' properties not found on glTF scene nodes - will randomly-generate object IDs in XKT");let t=n;if(e.metaModelCorrections){const i=e.metaModelCorrections.eachChildRoot[t];if(i){const t=e.metaModelCorrections.eachRootStats[i.id];t.countChildren++,t.countChildren>=t.numChildren&&(o.createEntity({id:i.id,meshIds:pP}),pP.length=0)}else{e.metaModelCorrections.metaObjectsMap[t]&&(o.createEntity({id:t,meshIds:pP}),pP.length=0)}}else o.createEntity({id:t,meshIds:pP}),pP.length=0}}function gP(e,t){e.plugin.error(t)}const mP={DEFAULT:{}};class _P extends z{constructor(e,t={}){super("GLTFLoader",e,t),this._sceneModelLoader=new nP(this,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new Oc}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||mP}get objectDefaults(){return this._objectDefaults}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new _c(this.viewer.scene,y.apply(e,{isModel:!0,dtxEnabled:e.dtxEnabled})),i=t.id;if(!e.src&&!e.gltf)return this.error("load() param expected: src or gltf"),t;if(e.metaModelSrc||e.metaModelJSON){const s=e.objectDefaults||this._objectDefaults||mP,r=r=>{let o;if(this.viewer.metaScene.createMetaModel(i,r,{includeTypes:e.includeTypes,excludeTypes:e.excludeTypes}),this.viewer.scene.canvas.spinner.processes--,e.includeTypes){o={};for(let t=0,i=e.includeTypes.length;t{const r=t.name;if(!r)return!0;const o=r,n=this.viewer.metaScene.metaObjects[o],a=(n?n.type:"DEFAULT")||"DEFAULT";i.createEntity={id:o,isObject:!0};const l=s[a];return l&&(!1===l.visible&&(i.createEntity.visible=!1),l.colorize&&(i.createEntity.colorize=l.colorize),!1===l.pickable&&(i.createEntity.pickable=!1),void 0!==l.opacity&&null!==l.opacity&&(i.createEntity.opacity=l.opacity)),!0},e.src?this._sceneModelLoader.load(this,e.src,r,e,t):this._sceneModelLoader.parse(this,e.gltf,r,e,t)};if(e.metaModelSrc){const t=e.metaModelSrc;this.viewer.scene.canvas.spinner.processes++,this._dataSource.getMetaModel(t,(e=>{this.viewer.scene.canvas.spinner.processes--,r(e)}),(e=>{this.error(`load(): Failed to load model metadata for model '${i} from '${t}' - ${e}`),this.viewer.scene.canvas.spinner.processes--}))}else e.metaModelJSON&&r(e.metaModelJSON)}else e.handleGLTFNode=(e,t,i)=>{const s=t.name;if(!s)return!0;const r=s;return i.createEntity={id:r,isObject:!0},!0},e.src?this._sceneModelLoader.load(this,e.src,null,e,t):this._sceneModelLoader.parse(this,e.gltf,null,e,t);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}}function vP(e,t,i={}){const s="lightgrey",r=i.hoverColor||"rgba(0,0,0,0.4)",o=i.textColor||"black",n=500,a=n+n/3,l=a/24,A=[{boundary:[6,6,6,6],color:i.frontColor||i.color||"#55FF55"},{boundary:[18,6,6,6],color:i.backColor||i.color||"#55FF55"},{boundary:[12,6,6,6],color:i.rightColor||i.color||"#FF5555"},{boundary:[0,6,6,6],color:i.leftColor||i.color||"#FF5555"},{boundary:[6,0,6,6],color:i.topColor||i.color||"#7777FF"},{boundary:[6,12,6,6],color:i.bottomColor||i.color||"#7777FF"}],h=[{label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,1,0],up:[0,0,1]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,-1,0],up:[0,0,1]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,0,1]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,0,1]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,0,1],up:[0,-1,0]},{boundaries:[[7,5,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,0,-1],up:[1,0,1]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-1,-1],up:[0,-1,1]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,0,-1],up:[-1,0,1]},{boundaries:[[7,11,4,2]],dir:[0,1,1],up:[0,-1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,0,1],up:[-1,0,1]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,-1,1],up:[0,1,1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,0,1],up:[1,0,1]},{boundaries:[[5,7,2,4]],dir:[1,1,0],up:[0,0,1]},{boundaries:[[11,7,2,4]],dir:[-1,1,0],up:[0,0,1]},{boundaries:[[17,7,2,4]],dir:[-1,-1,0],up:[0,0,1]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,-1,0],up:[0,0,1]},{boundaries:[[5,11,2,2]],dir:[1,1,1],up:[-1,-1,1]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[1,-1,1],up:[-1,1,1]},{boundaries:[[5,5,2,2]],dir:[1,1,-1],up:[1,1,1]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-1,-1,1],up:[1,1,1]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-1,-1,-1],up:[-1,-1,1]},{boundaries:[[11,11,2,2]],dir:[-1,1,1],up:[1,-1,1]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[1,-1,-1],up:[1,-1,1]},{boundaries:[[11,5,2,2]],dir:[-1,1,-1],up:[-1,1,1]}];i.frontColor||i.color,i.backColor||i.color,i.rightColor||i.color,i.leftColor||i.color,i.topColor||i.color,i.bottomColor||i.color;const c=[{yUp:"",label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,0,1],up:[0,1,0]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,1,0]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,1,0]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,-1,0],up:[0,0,-1]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,1,0],up:[0,0,1]},{boundaries:[[7,5,4,2]],dir:[0,-.7071,-.7071],up:[0,.7071,-.7071]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,-1,0],up:[1,1,0]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-.7071,.7071],up:[0,.7071,.7071]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,-1,0],up:[-1,1,0]},{boundaries:[[7,11,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,1,0],up:[-1,1,0]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,1,1],up:[0,1,-1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,1,0],up:[1,1,0]},{boundaries:[[5,7,2,4]],dir:[1,0,-1],up:[0,1,0]},{boundaries:[[11,7,2,4]],dir:[-1,0,-1],up:[0,1,0]},{boundaries:[[17,7,2,4]],dir:[-1,0,1],up:[0,1,0]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,0,1],up:[0,1,0]},{boundaries:[[5,11,2,2]],dir:[.5,.7071,-.5],up:[-.5,.7071,.5]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[.5,.7071,.5],up:[-.5,.7071,-.5]},{boundaries:[[5,5,2,2]],dir:[.5,-.7071,-.5],up:[.5,.7071,-.5]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-.5,.7071,.5],up:[.5,.7071,-.5]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-.5,-.7071,.5],up:[-.5,.7071,.5]},{boundaries:[[11,11,2,2]],dir:[-.5,.7071,-.5],up:[.5,.7071,.5]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[.5,-.7071,.5],up:[.5,.7071,.5]},{boundaries:[[11,5,2,2]],dir:[-.5,-.7071,-.5],up:[-.5,.7071,-.5]}];for(let e=0,t=h.length;e=r[0]*l&&t<=(r[0]+r[2])*l&&i>=r[1]*l&&i<=(r[1]+r[3])*l)return s}}return-1},this.setAreaHighlighted=function(e,t){var i=u[e];if(!i)throw"Area not found: "+e;i.highlighted=!!t,g()},this.getAreaDir=function(e){var t=u[e];if(!t)throw"Unknown area: "+e;return t.dir},this.getAreaUp=function(e){var t=u[e];if(!t)throw"Unknown area: "+e;return t.up},this.getImage=function(){return this._textureCanvas},this.destroy=function(){this._textureCanvas&&(this._textureCanvas.parentNode.removeChild(this._textureCanvas),this._textureCanvas=null)}}const bP=d.vec3(),yP=d.vec3();d.mat4();class BP extends z{constructor(e,t={}){super("NavCube",e,t),e.navCube=this;try{this._navCubeScene=new li(e,{canvasId:t.canvasId,canvasElement:t.canvasElement,transparent:!0}),this._navCubeCanvas=this._navCubeScene.canvas.canvas,this._navCubeScene.input.keyboardEnabled=!1}catch(e){return void this.error(e)}const i=this._navCubeScene;i.clearLights(),new Dt(i,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Dt(i,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Dt(i,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._navCubeCamera=i.camera,this._navCubeCamera.ortho.scale=7,this._navCubeCamera.ortho.near=.1,this._navCubeCamera.ortho.far=2e3,i.edgeMaterial.edgeColor=[.2,.2,.2],i.edgeMaterial.edgeAlpha=.6,this._zUp=Boolean(e.camera.zUp);var s=this;this.setIsProjectNorth(t.isProjectNorth),this.setProjectNorthOffsetAngle(t.projectNorthOffsetAngle);const r=function(){const e=d.mat4();return function(t,i,r){return d.identityMat4(e),d.rotationMat4v(t*s._projectNorthOffsetAngle*d.DEGTORAD,[0,1,0],e),d.transformVec3(e,i,r)}}();this._synchCamera=function(){var t=d.rotationMat4c(-90*d.DEGTORAD,1,0,0),i=d.vec3(),o=d.vec3(),n=d.vec3();return function(){var a=e.camera.eye,l=e.camera.look,A=e.camera.up;i=d.mulVec3Scalar(d.normalizeVec3(d.subVec3(a,l,i)),5),s._isProjectNorth&&s._projectNorthOffsetAngle&&(i=r(-1,i,bP),A=r(-1,A,yP)),s._zUp?(d.transformVec3(t,i,o),d.transformVec3(t,A,n),s._navCubeCamera.look=[0,0,0],s._navCubeCamera.eye=d.transformVec3(t,i,o),s._navCubeCamera.up=d.transformPoint3(t,A,n)):(s._navCubeCamera.look=[0,0,0],s._navCubeCamera.eye=i,s._navCubeCamera.up=A)}}(),this._cubeTextureCanvas=new vP(e,i,t),this._cubeSampler=new Wr(i,{image:this._cubeTextureCanvas.getImage(),flipY:!0,wrapS:1001,wrapT:1001}),this._cubeMesh=new dr(i,{geometry:new Gt(i,{primitive:"triangles",normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),material:new Jt(i,{diffuse:[.4,.4,.4],specular:[.4,.4,.4],emissive:[.6,.6,.6],diffuseMap:this._cubeSampler,emissiveMap:this._cubeSampler}),visible:!0,edges:!0}),this._shadow=!1===t.shadowVisible?null:new dr(i,{geometry:new Gt(i,fr({center:[0,0,0],radiusTop:.001,radiusBottom:1.4,height:.01,radialSegments:20,heightSegments:1,openEnded:!0})),material:new Jt(i,{diffuse:[0,0,0],specular:[0,0,0],emissive:[0,0,0],alpha:.5}),position:[0,-1.5,0],visible:!0,pickable:!1,backfaces:!1}),this._onCameraMatrix=e.camera.on("matrix",this._synchCamera),this._onCameraWorldAxis=e.camera.on("worldAxis",(()=>{e.camera.zUp?(this._zUp=!0,this._cubeTextureCanvas.setZUp(),this._repaint(),this._synchCamera()):e.camera.yUp&&(this._zUp=!1,this._cubeTextureCanvas.setYUp(),this._repaint(),this._synchCamera())})),this._onCameraFOV=e.camera.perspective.on("fov",(e=>{this._synchProjection&&(this._navCubeCamera.perspective.fov=e)})),this._onCameraProjection=e.camera.on("projection",(e=>{this._synchProjection&&(this._navCubeCamera.projection="ortho"===e||"perspective"===e?e:"perspective")}));var o=-1;function n(e){var t=[0,0];if(e){for(var i=e.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t}var a,l,A=null,h=null,c=!1,u=!1,p=.5;s._navCubeCanvas.addEventListener("mouseenter",s._onMouseEnter=function(e){u=!0}),s._navCubeCanvas.addEventListener("mouseleave",s._onMouseLeave=function(e){u=!1}),s._navCubeCanvas.addEventListener("mousedown",s._onMouseDown=function(e){if(1===e.which){A=e.x,h=e.y,a=e.clientX,l=e.clientY;var t=n(e),s=i.pick({canvasPos:t});c=!!s}}),document.addEventListener("mouseup",s._onMouseUp=function(e){if(1===e.which&&(c=!1,null!==A)){var t=n(e),a=i.pick({canvasPos:t,pickSurface:!0});if(a&&a.uv){var l=s._cubeTextureCanvas.getArea(a.uv);if(l>=0&&(document.body.style.cursor="pointer",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),l>=0)){if(s._cubeTextureCanvas.setAreaHighlighted(l,!0),o=l,s._repaint(),e.xA+3||e.yh+3)return;var u=s._cubeTextureCanvas.getAreaDir(l);if(u){var d=s._cubeTextureCanvas.getAreaUp(l);s._isProjectNorth&&s._projectNorthOffsetAngle&&(u=r(1,u,bP),d=r(1,d,yP)),f(u,d,(function(){o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),document.body.style.cursor="pointer",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),l>=0&&(s._cubeTextureCanvas.setAreaHighlighted(l,!1),o=-1,s._repaint())}))}}}}}),document.addEventListener("mousemove",s._onMouseMove=function(t){if(o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),1!==t.buttons||c){if(c){var r=t.clientX,A=t.clientY;return document.body.style.cursor="move",void function(t,i){var s=(t-a)*-p,r=(i-l)*-p;e.camera.orbitYaw(s),e.camera.orbitPitch(-r),a=t,l=i}(r,A)}if(u){var h=n(t),d=i.pick({canvasPos:h,pickSurface:!0});if(d){if(d.uv){document.body.style.cursor="pointer";var f=s._cubeTextureCanvas.getArea(d.uv);if(f===o)return;o>=0&&s._cubeTextureCanvas.setAreaHighlighted(o,!1),f>=0&&(s._cubeTextureCanvas.setAreaHighlighted(f,!0),s._repaint(),o=f)}}else document.body.style.cursor="default",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1)}}});var f=function(){var t=d.vec3();return function(i,r,o){var n=s._fitVisible?e.scene.getAABB(e.scene.visibleObjectIds):e.scene.aabb,a=d.getAABB3Diag(n);d.getAABB3Center(n,t);var l=Math.abs(a/Math.tan(s._cameraFitFOV*d.DEGTORAD));e.cameraControl.pivotPos=t,s._cameraFly?e.cameraFlight.flyTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:r||[0,1,0],orthoScale:1.1*a,fitFOV:s._cameraFitFOV,duration:s._cameraFlyDuration},o):e.cameraFlight.jumpTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:r||[0,1,0],orthoScale:1.1*a,fitFOV:s._cameraFitFOV},o)}}();this._onUpdated=e.localeService.on("updated",(()=>{this._cubeTextureCanvas.clear(),this._repaint()})),this.setVisible(t.visible),this.setCameraFitFOV(t.cameraFitFOV),this.setCameraFly(t.cameraFly),this.setCameraFlyDuration(t.cameraFlyDuration),this.setFitVisible(t.fitVisible),this.setSynchProjection(t.synchProjection)}send(e,t){if("language"===e)this._cubeTextureCanvas.clear(),this._repaint()}_repaint(){const e=this._cubeTextureCanvas.getImage();this._cubeMesh.material.diffuseMap.image=e,this._cubeMesh.material.emissiveMap.image=e}setVisible(e=!0){this._navCubeCanvas&&(this._cubeMesh.visible=e,this._shadow&&(this._shadow.visible=e),this._navCubeCanvas.style.visibility=e?"visible":"hidden")}getVisible(){return!!this._navCubeCanvas&&this._cubeMesh.visible}setFitVisible(e=!1){this._fitVisible=e}getFitVisible(){return this._fitVisible}setCameraFly(e=!0){this._cameraFly=e}getCameraFly(){return this._cameraFly}setCameraFitFOV(e=45){this._cameraFitFOV=e}getCameraFitFOV(){return this._cameraFitFOV}setCameraFlyDuration(e=.5){this._cameraFlyDuration=e}getCameraFlyDuration(){return this._cameraFlyDuration}setSynchProjection(e=!1){this._synchProjection=e}getSynchProjection(){return this._synchProjection}setIsProjectNorth(e=!1){this._isProjectNorth=e}getIsProjectNorth(){return this._isProjectNorth}setProjectNorthOffsetAngle(e){this._projectNorthOffsetAngle=e}getProjectNorthOffsetAngle(){return this._projectNorthOffsetAngle}destroy(){this._navCubeCanvas&&(this.viewer.localeService.off(this._onUpdated),this.viewer.camera.off(this._onCameraMatrix),this.viewer.camera.off(this._onCameraWorldAxis),this.viewer.camera.perspective.off(this._onCameraFOV),this.viewer.camera.off(this._onCameraProjection),this._navCubeCanvas.removeEventListener("mouseenter",this._onMouseEnter),this._navCubeCanvas.removeEventListener("mouseleave",this._onMouseLeave),this._navCubeCanvas.removeEventListener("mousedown",this._onMouseDown),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._navCubeCanvas=null,this._cubeTextureCanvas.destroy(),this._cubeTextureCanvas=null,this._onMouseEnter=null,this._onMouseLeave=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null),this._navCubeScene.destroy(),this._navCubeScene=null,this._cubeMesh=null,this._shadow=null,super.destroy()}}const xP=d.vec3();class wP{load(e,t,i={}){var s=e.scene.canvas.spinner;s.processes++,PP(e,t,(function(t){!function(e,t,i){for(var s=t.basePath,r=Object.keys(t.materialLibraries),o=r.length,n=0,a=o;n=0?i-1:i+t/3)}function r(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function o(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)}function n(e,t,i,s){var r=e.positions,o=e.object.geometry.positions;o.push(r[t+0]),o.push(r[t+1]),o.push(r[t+2]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[i+2]),o.push(r[s+0]),o.push(r[s+1]),o.push(r[s+2])}function a(e,t){var i=e.positions,s=e.object.geometry.positions;s.push(i[t+0]),s.push(i[t+1]),s.push(i[t+2])}function l(e,t,i,s){var r=e.normals,o=e.object.geometry.normals;o.push(r[t+0]),o.push(r[t+1]),o.push(r[t+2]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[i+2]),o.push(r[s+0]),o.push(r[s+1]),o.push(r[s+2])}function A(e,t,i,s){var r=e.uv,o=e.object.geometry.uv;o.push(r[t+0]),o.push(r[t+1]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[s+0]),o.push(r[s+1])}function h(e,t){var i=e.uv,s=e.object.geometry.uv;s.push(i[t+0]),s.push(i[t+1])}function c(e,t,i,a,h,c,u,d,p,f,g,m,_){var v,b=e.positions.length,y=s(t,b),B=s(i,b),x=s(a,b);if(void 0===h?n(e,y,B,x):(n(e,y,B,v=s(h,b)),n(e,B,x,v)),void 0!==c){var w=e.uv.length;y=o(c,w),B=o(u,w),x=o(d,w),void 0===h?A(e,y,B,x):(A(e,y,B,v=o(p,w)),A(e,B,x,v))}if(void 0!==f){var P=e.normals.length;y=r(f,P),B=f===g?y:r(g,P),x=f===m?y:r(m,P),void 0===h?l(e,y,B,x):(l(e,y,B,v=r(_,P)),l(e,B,x,v))}}function u(e,t,i){e.object.geometry.type="Line";for(var r=e.positions.length,n=e.uv.length,l=0,A=t.length;l=0?n.substring(0,a):n).toLowerCase(),A=(A=a>=0?n.substring(a+1):"").trim(),l.toLowerCase()){case"newmtl":i(e,u),u={id:A},d=!0;break;case"ka":u.ambient=s(A);break;case"kd":u.diffuse=s(A);break;case"ks":u.specular=s(A);break;case"map_kd":u.diffuseMap||(u.diffuseMap=t(e,o,A,"sRGB"));break;case"map_ks":u.specularMap||(u.specularMap=t(e,o,A,"linear"));break;case"map_bump":case"bump":u.normalMap||(u.normalMap=t(e,o,A));break;case"ns":u.shininess=parseFloat(A);break;case"d":(h=parseFloat(A))<1&&(u.alpha=h,u.alphaMode="blend");break;case"tr":(h=parseFloat(A))>0&&(u.alpha=1-h,u.alphaMode="blend")}d&&i(e,u)};function t(e,t,i,s){var r={},o=i.split(/\s+/),n=o.indexOf("-bm");return n>=0&&o.splice(n,2),(n=o.indexOf("-s"))>=0&&(r.scale=[parseFloat(o[n+1]),parseFloat(o[n+2])],o.splice(n,4)),(n=o.indexOf("-o"))>=0&&(r.translate=[parseFloat(o[n+1]),parseFloat(o[n+2])],o.splice(n,4)),r.src=t+o.join(" ").trim(),r.flipY=!0,r.encoding=s||"linear",new Wr(e,r).id}function i(e,t){new Jt(e,t)}function s(t){var i=t.split(e,3);return[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])]}}();function EP(e,t){for(var i=0,s=t.objects.length;i0&&(n.normals=o.normals),o.uv.length>0&&(n.uv=o.uv);for(var a=new Array(n.positions.length/3),l=0;l{this.viewer.metaScene.createMetaModel(i,r),this._sceneGraphLoader.load(t,s,e)}),(e=>{this.error(`load(): Failed to load model modelMetadata for model '${i} from '${r}' - ${e}`)}))}else this._sceneGraphLoader.load(t,s,e);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}}const SP=new Float64Array([0,0,1]),TP=new Float64Array(4);class RP{constructor(e){this.id=null,this._viewer=e.viewer,this._visible=!1,this._pos=d.vec3(),this._origin=d.vec3(),this._rtcPos=d.vec3(),this._baseDir=d.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}_setSectionPlane(e){this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(()=>{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),X(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=d.vec3PairToQuaternion(SP,e,TP)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,i=.01;this._rootNode=new Ir(t,{position:[0,0,0],scale:[5,5,5],isObject:!1});const s=this._rootNode,r={arrowHead:new Gt(s,fr({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Gt(s,fr({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),arrowHeadHandle:new Gt(s,fr({radiusTop:.09,radiusBottom:.09,radialSegments:8,heightSegments:1,height:.37,openEnded:!1})),curve:new Gt(s,ro({radius:.8,tube:i,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),curveHandle:new Gt(s,ro({radius:.8,tube:.06,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),hoop:new Gt(s,ro({radius:.8,tube:i,radialSegments:64,tubeSegments:8,arc:2*Math.PI})),axis:new Gt(s,fr({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1})),axisHandle:new Gt(s,fr({radiusTop:.08,radiusBottom:.08,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},o={pickable:new Jt(s,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),red:new Jt(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Zt(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6}),green:new Jt(s,{diffuse:[0,1,0],emissive:[0,1,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightGreen:new Zt(s,{edges:!1,fill:!0,fillColor:[0,1,0],fillAlpha:.6}),blue:new Jt(s,{diffuse:[0,0,1],emissive:[0,0,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightBlue:new Zt(s,{edges:!1,fill:!0,fillColor:[0,0,1],fillAlpha:.2}),center:new Jt(s,{diffuse:[0,0,0],emissive:[0,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80}),highlightBall:new Zt(s,{edges:!1,fill:!0,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1}),highlightPlane:new Zt(s,{edges:!0,edgeWidth:3,fill:!1,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1})};this._displayMeshes={plane:s.addChild(new dr(s,{geometry:new Gt(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Jt(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new Zt(s,{edges:!1,filled:!0,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:.1,backfaces:!0}),pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1],isObject:!1}),e),planeFrame:s.addChild(new dr(s,{geometry:new Gt(s,ro({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Jt(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new Zt(s,{edges:!1,edgeColor:[0,0,0],filled:!0,fillColor:[.8,.8,.8],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45],isObject:!1}),e),xCurve:s.addChild(new dr(s,{geometry:r.curve,material:o.red,matrix:function(){const e=d.rotationMat4v(90*d.DEGTORAD,[0,1,0],d.identityMat4()),t=d.rotationMat4v(270*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveHandle:s.addChild(new dr(s,{geometry:r.curveHandle,material:o.pickable,matrix:function(){const e=d.rotationMat4v(90*d.DEGTORAD,[0,1,0],d.identityMat4()),t=d.rotationMat4v(270*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveArrow1:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=d.translateMat4c(0,-.07,-.8,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(0*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xCurveArrow2:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=d.translateMat4c(0,-.8,-.07,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurve:s.addChild(new dr(s,{geometry:r.curve,material:o.green,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveHandle:s.addChild(new dr(s,{geometry:r.curveHandle,material:o.pickable,rotation:[-90,0,0],pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveArrow1:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=d.translateMat4c(.07,0,-.8,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurveArrow2:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=d.translateMat4c(.8,0,-.07,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurve:s.addChild(new dr(s,{geometry:r.curve,material:o.blue,matrix:d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4()),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveHandle:s.addChild(new dr(s,{geometry:r.curveHandle,material:o.pickable,matrix:d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4()),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveCurveArrow1:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=d.translateMat4c(.8,-.07,0,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4());return d.mulMat4(e,t,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveArrow2:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=d.translateMat4c(.05,-.8,0,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),center:s.addChild(new dr(s,{geometry:new Gt(s,gr({radius:.05})),material:o.center,pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrowHandle:s.addChild(new dr(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxis:s.addChild(new dr(s,{geometry:r.axis,material:o.red,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisHandle:s.addChild(new dr(s,{geometry:r.axisHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrowHandle:s.addChild(new dr(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,opacity:.2,isObject:!1}),e),yShaft:s.addChild(new dr(s,{geometry:r.axis,material:o.green,position:[0,-.5,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yShaftHandle:s.addChild(new dr(s,{geometry:r.axisHandle,material:o.pickable,position:[0,-.5,0],pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrowHandle:s.addChild(new dr(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zShaft:s.addChild(new dr(s,{geometry:r.axis,material:o.blue,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1,isObject:!1}),e),zAxisHandle:s.addChild(new dr(s,{geometry:r.axisHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),clippable:!1,pickable:!0,collidable:!0,visible:!1,isObject:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new dr(s,{geometry:new Gt(s,ro({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Jt(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Zt(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45],isObject:!1}),e),xHoop:s.addChild(new dr(s,{geometry:r.hoop,material:o.red,highlighted:!0,highlightMaterial:o.highlightRed,matrix:function(){const e=d.rotationMat4v(90*d.DEGTORAD,[0,1,0],d.identityMat4()),t=d.rotationMat4v(270*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yHoop:s.addChild(new dr(s,{geometry:r.hoop,material:o.green,highlighted:!0,highlightMaterial:o.highlightGreen,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zHoop:s.addChild(new dr(s,{geometry:r.hoop,material:o.blue,highlighted:!0,highlightMaterial:o.highlightBlue,matrix:d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4()),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHeadBig,material:o.red,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHeadBig,material:o.green,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHeadBig,material:o.blue,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e)}}_bindEvents(){const e=this;var t=!1;const i=-1,s=0,r=1,o=2,n=3,a=4,l=5,A=this._rootNode;var h=null,c=null;const u=d.vec2(),p=d.vec3([1,0,0]),f=d.vec3([0,1,0]),g=d.vec3([0,0,1]),m=this._viewer.scene.canvas.canvas,_=this._viewer.camera,v=this._viewer.scene;{const e=d.vec3([0,0,0]);let t=-1;this._onCameraViewMatrix=v.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=v.camera.on("projMatrix",(()=>{})),this._onSceneTick=v.on("tick",(()=>{const i=Math.abs(d.lenVec3(d.subVec3(v.camera.eye,this._pos,e)));if(i!==t&&"perspective"===_.projection){const e=.07*(Math.tan(_.perspective.fov*d.DEGTORAD)*i);A.scale=[e,e,e],t=i}if("ortho"===_.projection){const e=_.ortho.scale/10;A.scale=[e,e,e],t=i}}))}const b=function(){const e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),y=function(){const t=d.mat4();return function(i,s){return d.quaternionToMat4(e._rootNode.quaternion,t),d.transformVec3(t,i,s),d.normalizeVec3(s),s}}();var B=function(){const e=d.vec3();return function(t){const i=Math.abs(t[0]);return i>Math.abs(t[1])&&i>Math.abs(t[2])?d.cross3Vec3(t,[0,1,0],e):d.cross3Vec3(t,[1,0,0],e),d.cross3Vec3(e,t,e),d.normalizeVec3(e),e}}();const x=function(){const t=d.vec3(),i=d.vec3(),s=d.vec4();return function(r,o,n){y(r,s);const a=B(s,o,n);P(o,a,t),P(n,a,i),d.subVec3(i,t);const l=d.dotVec3(i,s);e._pos[0]+=s[0]*l,e._pos[1]+=s[1]*l,e._pos[2]+=s[2]*l,e._rootNode.position=e._pos,e._sectionPlane&&(e._sectionPlane.pos=e._pos)}}();var w=function(){const t=d.vec4(),i=d.vec4(),s=d.vec4(),r=d.vec4();return function(o,n,a){y(o,r);if(!(P(n,r,t)&&P(a,r,i))){const e=B(r,n,a);P(n,e,t,1),P(a,e,i,1);var l=d.dotVec3(t,r);t[0]-=l*r[0],t[1]-=l*r[1],t[2]-=l*r[2],l=d.dotVec3(i,r),i[0]-=l*r[0],i[1]-=l*r[1],i[2]-=l*r[2]}d.normalizeVec3(t),d.normalizeVec3(i),l=d.dotVec3(t,i),l=d.clamp(l,-1,1);var A=Math.acos(l)*d.RADTODEG;d.cross3Vec3(t,i,s),d.dotVec3(s,r)<0&&(A=-A),e._rootNode.rotate(o,A),C()}}(),P=function(){const t=d.vec4([0,0,0,1]),i=d.mat4();return function(s,r,o,n){n=n||0,t[0]=s[0]/m.width*2-1,t[1]=-(s[1]/m.height*2-1),t[2]=0,t[3]=1,d.mulMat4(_.projMatrix,_.viewMatrix,i),d.inverseMat4(i),d.transformVec4(i,t,t),d.mulVec4Scalar(t,1/t[3]);var a=_.eye;d.subVec4(t,a,t);const l=e._sectionPlane.pos;var A=-d.dotVec3(l,r)-n,h=d.dotVec3(r,t);if(Math.abs(h)>.005){var c=-(d.dotVec3(r,a)+A)/h;return d.mulVec3Scalar(t,c,o),d.addVec3(o,a),d.subVec3(o,l,o),!0}return!1}}();const C=function(){const t=d.vec3(),i=d.mat4();return function(){e.sectionPlane&&(d.quaternionToMat4(A.quaternion,i),d.transformVec3(i,[0,0,1],t),e._setSectionPlaneDir(t))}}();var M,F=!1;this._onCameraControlHover=this._viewer.cameraControl.on("hoverEnter",(e=>{if(!this._visible)return;if(F)return;var A;t=!1,M&&(M.visible=!1);switch(e.entity.id){case this._displayMeshes.xAxisArrowHandle.id:case this._displayMeshes.xAxisHandle.id:A=this._affordanceMeshes.xAxisArrow,h=s;break;case this._displayMeshes.yAxisArrowHandle.id:case this._displayMeshes.yShaftHandle.id:A=this._affordanceMeshes.yAxisArrow,h=r;break;case this._displayMeshes.zAxisArrowHandle.id:case this._displayMeshes.zAxisHandle.id:A=this._affordanceMeshes.zAxisArrow,h=o;break;case this._displayMeshes.xCurveHandle.id:A=this._affordanceMeshes.xHoop,h=n;break;case this._displayMeshes.yCurveHandle.id:A=this._affordanceMeshes.yHoop,h=a;break;case this._displayMeshes.zCurveHandle.id:A=this._affordanceMeshes.zHoop,h=l;break;default:return void(h=i)}A&&(A.visible=!0),M=A,t=!0})),this._onCameraControlHoverLeave=this._viewer.cameraControl.on("hoverOutEntity",(e=>{this._visible&&(M&&(M.visible=!1),M=null,h=i)})),m.addEventListener("mousedown",this._canvasMouseDownListener=e=>{if(e.preventDefault(),this._visible&&t&&(this._viewer.cameraControl.pointerEnabled=!1,1===e.which)){F=!0;var i=b(e);c=h,u[0]=i[0],u[1]=i[1]}}),m.addEventListener("mousemove",this._canvasMouseMoveListener=e=>{if(!this._visible)return;if(!F)return;var t=b(e);const i=t[0],A=t[1];switch(c){case s:x(p,u,t);break;case r:x(f,u,t);break;case o:x(g,u,t);break;case n:w(p,u,t);break;case a:w(f,u,t);break;case l:w(g,u,t)}u[0]=i,u[1]=A}),m.addEventListener("mouseup",this._canvasMouseUpListener=e=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,F&&(e.which,F=!1,t=!1))}),m.addEventListener("wheel",this._canvasWheelListener=e=>{if(this._visible)Math.max(-1,Math.min(1,40*-e.deltaY))})}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=e.cameraControl;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix),r.off(this._onCameraControlHover),r.off(this._onCameraControlHoverLeave)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class LP{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new dr(t,{id:i.id,geometry:new Gt(t,zt({xSize:.5,ySize:.5,zSize:.001})),material:new Jt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new $t(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Zt(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Zt(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=d.vec3([0,0,0]),t=d.vec3(),i=d.vec3([0,0,1]),s=d.vec4(4),r=d.vec3(),o=()=>{const o=this._sectionPlane.scene.center,n=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];d.subVec3(o,this._sectionPlane.pos,e);const a=-d.dotVec3(n,e);d.normalizeVec3(n),d.mulVec3Scalar(n,a,t);const l=d.vec3PairToQuaternion(i,this._sectionPlane.dir,s);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=l,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",o),this._onSectionPlaneDir=this._sectionPlane.on("dir",o)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class UP{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new li(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Dt(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Dt(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Dt(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=d.rotationMat4c(-90*d.DEGTORAD,1,0,0),i=d.vec3(),s=d.vec3(),r=d.vec3();this._synchCamera=()=>{const o=this._viewer.camera.eye,n=this._viewer.camera.look,a=this._viewer.camera.up;d.mulVec3Scalar(d.normalizeVec3(d.subVec3(o,n,i)),7),this._zUp?(d.transformVec3(t,i,s),d.transformVec3(t,a,r),e.look=[0,0,0],e.eye=d.transformVec3(t,i,s),e.up=d.transformPoint3(t,a,r)):(e.look=[0,0,0],e.eye=i,e.up=a)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new LP(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const kP=d.AABB3(),OP=d.vec3();class NP extends z{constructor(e,t={}){if(super("SectionPlanes",e),this._freeControls=[],this._sectionPlanes=e.scene.sectionPlanes,this._controls={},this._shownControlId=null,null!==t.overviewCanvasId&&void 0!==t.overviewCanvasId){const e=document.getElementById(t.overviewCanvasId);e?this._overview=new UP(this,{overviewCanvas:e,visible:t.overviewVisible,onHoverEnterPlane:e=>{this._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:e=>{this._overview.setPlaneHighlighted(e,!1)},onClickedPlane:e=>{if(this.getShownControl()===e)return void this.hideControl();this.showControl(e);const t=this.sectionPlanes[e].pos;kP.set(this.viewer.scene.aabb),d.getAABB3Center(kP,OP),kP[0]+=t[0]-OP[0],kP[1]+=t[1]-OP[1],kP[2]+=t[2]-OP[2],kP[3]+=t[0]-OP[0],kP[4]+=t[1]-OP[1],kP[5]+=t[2]-OP[2],this.viewer.cameraFlight.flyTo({aabb:kP,fitFOV:65})},onClickedNothing:()=>{this.hideControl()}}):this.warn("Can't find overview canvas: '"+t.overviewCanvasId+"' - will create plugin without overview")}this._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(e=>{this._sectionPlaneCreated(e)}))}setOverviewVisible(e){this._overview&&this._overview.setVisible(e)}getOverviewVisible(){if(this._overview)return this._overview.getVisible()}get sectionPlanes(){return this._sectionPlanes}createSectionPlane(e={}){void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);return new br(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0})}_sectionPlaneCreated(e){const t=this._freeControls.length>0?this._freeControls.pop():new RP(this);t._setSectionPlane(e),t.setVisible(!1),this._controls[e.id]=t,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(()=>{this._sectionPlaneDestroyed(e)}))}flipSectionPlanes(){const e=this.viewer.scene.sectionPlanes;for(let t in e){e[t].flipDir()}}showControl(e){const t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}getShownControl(){return this._shownControlId}hideControl(){for(var e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}destroySectionPlane(e){var t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}_sectionPlaneDestroyed(e){this._overview&&this._overview.removeSectionPlane(e);const t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}clear(){const e=Object.keys(this._sectionPlanes);for(var t=0,i=e.length;t{this._registerModelStoreys(e),this.fire("storeys",this.storeys)}))}_registerModelStoreys(e){const t=this.viewer,i=t.scene,s=t.metaScene,r=s.metaModels[e],o=i.models[e];if(!r||!r.rootMetaObjects)return;const n=r.rootMetaObjects;for(let t=0,r=n.length;t.5?a.length:0,h=new QP(this,o.aabb,l,e,n,A);h._onModelDestroyed=o.once("destroyed",(()=>{this._deregisterModelStoreys(e),this.fire("storeys",this.storeys)})),this.storeys[n]=h,this.modelStoreys[e]||(this.modelStoreys[e]={}),this.modelStoreys[e][n]=h}}}_deregisterModelStoreys(e){const t=this.modelStoreys[e];if(t){const i=this.viewer.scene;for(let e in t)if(t.hasOwnProperty(e)){const s=t[e],r=i.models[s.modelId];r&&r.off(s._onModelDestroyed),delete this.storeys[e]}delete this.modelStoreys[e]}}get fitStoreyMaps(){return this._fitStoreyMaps}gotoStoreyCamera(e,t={}){const i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),void(t.done&&t.done());const s=this.viewer,r=s.scene.camera,o=i.storeyAABB;if(o[3]{t.done()})):(s.cameraFlight.jumpTo(y.apply(t,{eye:h,look:n,up:c,orthoScale:A})),s.camera.ortho.scale=A)}showStoreyObjects(e,t={}){if(!this.storeys[e])return void this.error("IfcBuildingStorey not found with this ID: "+e);const i=this.viewer,s=i.scene;i.metaScene.metaObjects[e]&&(t.hideOthers&&s.setObjectsVisible(i.scene.visibleObjectIds,!1),this.withStoreyObjects(e,((e,t)=>{e&&(e.visible=!0)})))}withStoreyObjects(e,t){const i=this.viewer,s=i.scene,r=i.metaScene,o=r.metaObjects[e];if(!o)return;const n=o.getObjectIDsInSubtree();for(var a=0,l=n.length;au[1]&&u[0]>u[2],p=!d&&u[1]>u[0]&&u[1]>u[2];!d&&!p&&u[2]>u[0]&&(u[2],u[1]);const f=e.width/A,g=p?e.height/c:e.height/h;return i[0]=Math.floor(e.width-(t[0]-n)*f),i[1]=Math.floor(e.height-(t[2]-l)*g),i[0]>=0&&i[0]=0&&i[1]<=e.height}worldDirToStoreyMap(e,t,i){const s=this.viewer.camera,r=s.eye,o=s.look,n=d.subVec3(o,r,HP),a=s.worldUp,l=a[0]>a[1]&&a[0]>a[2],A=!l&&a[1]>a[0]&&a[1]>a[2];!l&&!A&&a[2]>a[0]&&(a[2],a[1]),l?(i[0]=n[1],i[1]=n[2]):A?(i[0]=n[0],i[1]=n[2]):(i[0]=n[0],i[1]=n[1]),d.normalizeVec2(i)}destroy(){this.viewer.scene.off(this._onModelLoaded),super.destroy()}}const zP=new Float64Array([0,0,1]),WP=new Float64Array(4);class KP{constructor(e){this.id=null,this._viewer=e.viewer,this._plugin=e,this._visible=!1,this._pos=d.vec3(),this._origin=d.vec3(),this._rtcPos=d.vec3(),this._baseDir=d.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}_setSectionPlane(e){this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(()=>{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),X(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=d.vec3PairToQuaternion(zP,e,WP)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,i=.01;this._rootNode=new Ir(t,{position:[0,0,0],scale:[5,5,5]});const s=this._rootNode,r={arrowHead:new Gt(s,fr({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Gt(s,fr({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new Gt(s,fr({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},o={red:new Jt(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new Jt(s,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new Jt(s,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Zt(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:s.addChild(new dr(s,{geometry:new Gt(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Jt(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1]}),e),planeFrame:s.addChild(new dr(s,{geometry:new Gt(s,ro({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Jt(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45]}),e),center:s.addChild(new dr(s,{geometry:new Gt(s,gr({radius:.05})),material:o.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:s.addChild(new dr(s,{geometry:r.axis,material:o.blue,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new dr(s,{geometry:new Gt(s,ro({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Jt(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Zt(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45]}),e),zAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHeadBig,material:o.blue,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}_bindEvents(){const e=this._rootNode,t=d.vec2(),i=this._viewer.camera,s=this._viewer.scene;let r=0,o=!1;{const t=d.vec3([0,0,0]);let n=-1;this._onCameraViewMatrix=s.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=s.camera.on("projMatrix",(()=>{})),this._onSceneTick=s.on("tick",(()=>{o=!1;const l=Math.abs(d.lenVec3(d.subVec3(s.camera.eye,this._pos,t)));if(l!==n&&"perspective"===i.projection){const t=.07*(Math.tan(i.perspective.fov*d.DEGTORAD)*l);e.scale=[t,t,t],n=l}if("ortho"===i.projection){const t=i.ortho.scale/10;e.scale=[t,t,t],n=l}0!==r&&(a(r),r=0)}))}const n=function(){const e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),a=e=>{const t=this._sectionPlane.pos,i=this._sectionPlane.dir;d.addVec3(t,d.mulVec3Scalar(i,.1*e*this._plugin.getDragSensitivity(),d.vec3())),this._sectionPlane.pos=t};{let e=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=i=>{if(i.preventDefault(),this._visible&&(this._viewer.cameraControl.pointerEnabled=!1,1===i.which)){e=!0;var s=n(i);t[0]=s[0],t[1]=s[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=i=>{if(!this._visible)return;if(!e)return;if(o)return;var s=n(i);const r=s[0],l=s[1];a(l-t[1]),t[0]=r,t[1]=l}),this._plugin._controlElement.addEventListener("mouseup",this._canvasMouseUpListener=t=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,e&&(t.which,e=!1))}),this._plugin._controlElement.addEventListener("wheel",this._canvasWheelListener=e=>{this._visible&&(r+=Math.max(-1,Math.min(1,40*-e.deltaY)))})}{let e,t,i=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=t=>{t.stopPropagation(),t.preventDefault(),this._visible&&(e=t.touches[0].clientY,i=e,r=0)}),this._plugin._controlElement.addEventListener("touchmove",this._handleTouchMove=e=>{e.stopPropagation(),e.preventDefault(),this._visible&&(o||(o=!0,t=e.touches[0].clientY,null!==i&&(r+=t-i),i=t))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=i=>{i.stopPropagation(),i.preventDefault(),this._visible&&(e=null,t=null,r=0)})}}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class XP{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new dr(t,{id:i.id,geometry:new Gt(t,zt({xSize:.5,ySize:.5,zSize:.001})),material:new Jt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new $t(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Zt(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Zt(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=d.vec3([0,0,0]),t=d.vec3(),i=d.vec3([0,0,1]),s=d.vec4(4),r=d.vec3(),o=()=>{const o=this._sectionPlane.scene.center,n=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];d.subVec3(o,this._sectionPlane.pos,e);const a=-d.dotVec3(n,e);d.normalizeVec3(n),d.mulVec3Scalar(n,a,t);const l=d.vec3PairToQuaternion(i,this._sectionPlane.dir,s);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=l,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",o),this._onSectionPlaneDir=this._sectionPlane.on("dir",o)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class JP{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new li(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Dt(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Dt(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Dt(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=d.rotationMat4c(-90*d.DEGTORAD,1,0,0),i=d.vec3(),s=d.vec3(),r=d.vec3();this._synchCamera=()=>{const o=this._viewer.camera.eye,n=this._viewer.camera.look,a=this._viewer.camera.up;d.mulVec3Scalar(d.normalizeVec3(d.subVec3(o,n,i)),7),this._zUp?(d.transformVec3(t,i,s),d.transformVec3(t,a,r),e.look=[0,0,0],e.eye=d.transformVec3(t,i,s),e.up=d.transformPoint3(t,a,r)):(e.look=[0,0,0],e.eye=i,e.up=a)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new XP(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const YP=d.AABB3(),ZP=d.vec3();class qP extends z{constructor(e,t={}){if(super("FaceAlignedSectionPlanesPlugin",e),this._freeControls=[],this._sectionPlanes=e.scene.sectionPlanes,this._controls={},this._shownControlId=null,this._dragSensitivity=t.dragSensitivity||1,null!==t.overviewCanvasId&&void 0!==t.overviewCanvasId){const e=document.getElementById(t.overviewCanvasId);e?this._overview=new JP(this,{overviewCanvas:e,visible:t.overviewVisible,onHoverEnterPlane:e=>{this._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:e=>{this._overview.setPlaneHighlighted(e,!1)},onClickedPlane:e=>{if(this.getShownControl()===e)return void this.hideControl();this.showControl(e);const t=this.sectionPlanes[e].pos;YP.set(this.viewer.scene.aabb),d.getAABB3Center(YP,ZP),YP[0]+=t[0]-ZP[0],YP[1]+=t[1]-ZP[1],YP[2]+=t[2]-ZP[2],YP[3]+=t[0]-ZP[0],YP[4]+=t[1]-ZP[1],YP[5]+=t[2]-ZP[2],this.viewer.cameraFlight.flyTo({aabb:YP,fitFOV:65})},onClickedNothing:()=>{this.hideControl()}}):this.warn("Can't find overview canvas: '"+t.overviewCanvasId+"' - will create plugin without overview")}null===t.controlElementId||void 0===t.controlElementId?this.error("Parameter expected: controlElementId"):(this._controlElement=document.getElementById(t.controlElementId),this._controlElement||this.warn("Can't find control element: '"+t.controlElementId+"' - will create plugin without control element")),this._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(e=>{this._sectionPlaneCreated(e)}))}setDragSensitivity(e){this._dragSensitivity=e||1}getDragSensitivity(){return this._dragSensitivity}setOverviewVisible(e){this._overview&&this._overview.setVisible(e)}getOverviewVisible(){if(this._overview)return this._overview.getVisible()}get sectionPlanes(){return this._sectionPlanes}createSectionPlane(e={}){void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);return new br(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0})}_sectionPlaneCreated(e){const t=this._freeControls.length>0?this._freeControls.pop():new KP(this);t._setSectionPlane(e),t.setVisible(!1),this._controls[e.id]=t,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(()=>{this._sectionPlaneDestroyed(e)}))}flipSectionPlanes(){const e=this.viewer.scene.sectionPlanes;for(let t in e){e[t].flipDir()}}showControl(e){const t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}getShownControl(){return this._shownControlId}hideControl(){for(let e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}destroySectionPlane(e){let t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}_sectionPlaneDestroyed(e){this._overview&&this._overview.removeSectionPlane(e);const t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}clear(){const e=Object.keys(this._sectionPlanes);for(let t=0,i=e.length;t>5&31)/31,l=(e>>10&31)/31):(n=h,a=c,l=u),(y&&n!==p||a!==f||l!==g)&&(null!==p&&(m=!0),p=n,f=a,g=l)}for(let e=1;e<=3;e++){let i=t+12*e;v.push(r.getFloat32(i,!0)),v.push(r.getFloat32(i+4,!0)),v.push(r.getFloat32(i+8,!0)),b.push(o,B,x),d&&A.push(n,a,l,1)}y&&m&&(nC(i,v,b,A,_,s),v=[],b=[],A=A?[]:null,m=!1)}v.length>0&&nC(i,v,b,A,_,s)}function oC(e,t,i,s){const r=/facet([\s\S]*?)endfacet/g;let o=0;const n=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,a=new RegExp("vertex"+n+n+n,"g"),l=new RegExp("normal"+n+n+n,"g"),A=[],h=[];let c,u,d,p,f,g,m;for(;null!==(p=r.exec(t));){for(f=0,g=0,m=p[0];null!==(p=l.exec(m));)c=parseFloat(p[1]),u=parseFloat(p[2]),d=parseFloat(p[3]),g++;for(;null!==(p=a.exec(m));)A.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),h.push(c,u,d),f++;1!==g&&e.error("Error in normal of face "+o),3!==f&&e.error("Error in positions of face "+o),o++}nC(i,A,h,null,new Rr(i,{roughness:.5}),s)}function nC(e,t,i,s,r,o){const n=new Int32Array(t.length/3);for(let e=0,t=n.length;e0?i:null,s=s&&s.length>0?s:null,o.smoothNormals&&d.faceToVertexNormals(t,i,o);const a=tC;J(t,t,a);const l=new Gt(e,{primitive:"triangles",positions:t,normals:i,colors:s,indices:n}),A=new dr(e,{origin:0!==a[0]||0!==a[1]||0!==a[2]?a:null,geometry:l,material:r,edges:o.edges});e.addChild(A)}function aC(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,s=e.length;i0){const i=document.createElement("a");i.href="#",i.id=`switch-${e.nodeId}`,i.textContent="+",i.classList.add("plus"),t&&i.addEventListener("click",t),o.appendChild(i)}const n=document.createElement("input");n.id=`checkbox-${e.nodeId}`,n.type="checkbox",n.checked=e.checked,n.style["pointer-events"]="all",i&&n.addEventListener("change",i),o.appendChild(n);const a=document.createElement("span");return a.textContent=e.title,o.appendChild(a),s&&(a.oncontextmenu=s),r&&(a.onclick=r),o}createDisabledNodeElement(e){const t=document.createElement("li"),i=document.createElement("a");i.href="#",i.textContent="!",i.classList.add("warn"),i.classList.add("warning"),t.appendChild(i);const s=document.createElement("span");return s.textContent=e,t.appendChild(s),t}addChildren(e,t){const i=document.createElement("ul");t.forEach((e=>{i.appendChild(e)})),e.parentElement.appendChild(i)}expand(e,t,i){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",i)}collapse(e,t,i){if(!e)return;const s=e.parentElement;if(!s)return;const r=s.querySelector("ul");r&&(s.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",i),e.addEventListener("click",t))}isExpanded(e){return void 0!==e.parentElement.getElementsByTagName("li")[0]}getId(e){return e.parentElement.id}getIdFromCheckbox(e){return e.id.replace("checkbox-","")}getSwitchElement(e){return document.getElementById(`switch-${e}`)}isChecked(e){return e.checked}setCheckbox(e,t){const i=document.getElementById(`checkbox-${e}`);i&&t!==i.checked&&(i.checked=t)}setXRayed(e,t){const i=document.getElementById(e);i&&(t?i.classList.add("xrayed-node"):i.classList.remove("xrayed-node"))}setHighlighted(e,t){const i=document.getElementById(e);i&&(t?(i.scrollIntoView({block:"center"}),i.classList.add("highlighted-node")):i.classList.remove("highlighted-node"))}}const cC=[];class uC extends z{constructor(e,t={}){super("TreeViewPlugin",e),this.errors=[],this.valid=!0;const i=t.containerElement||document.getElementById(t.containerElementId);if(i instanceof HTMLElement){for(let e=0;;e++)if(!cC[e]){cC[e]=this,this._index=e,this._id=`tree-${e}`;break}if(this._containerElement=i,this._metaModels={},this._autoAddModels=!1!==t.autoAddModels,this._autoExpandDepth=t.autoExpandDepth||0,this._sortNodes=!1!==t.sortNodes,this._viewer=e,this._rootElement=null,this._muteSceneEvents=!1,this._muteTreeEvents=!1,this._rootNodes=[],this._objectNodes={},this._nodeNodes={},this._rootNames={},this._sortNodes=t.sortNodes,this._pruneEmptyNodes=t.pruneEmptyNodes,this._showListItemElementId=null,this._renderService=t.renderService||new hC,!this._renderService)throw new Error("TreeViewPlugin: no render service set");if(this._containerElement.oncontextmenu=e=>{e.preventDefault()},this._onObjectVisibility=this._viewer.scene.on("objectVisibility",(e=>{if(this._muteSceneEvents)return;const t=e.id,i=this._objectNodes[t];if(!i)return;const s=e.visible;if(!(s!==i.checked))return;this._muteTreeEvents=!0,i.checked=s,s?i.numVisibleEntities++:i.numVisibleEntities--,this._renderService.setCheckbox(i.nodeId,s);let r=i.parent;for(;r;)r.checked=s,s?r.numVisibleEntities++:r.numVisibleEntities--,this._renderService.setCheckbox(r.nodeId,r.numVisibleEntities>0),r=r.parent;this._muteTreeEvents=!1})),this._onObjectXrayed=this._viewer.scene.on("objectXRayed",(e=>{if(this._muteSceneEvents)return;const t=e.id,i=this._objectNodes[t];if(!i)return;this._muteTreeEvents=!0;const s=e.xrayed;s!==i.xrayed&&(i.xrayed=s,this._renderService.setXRayed(i.nodeId,s),this._muteTreeEvents=!1)})),this._switchExpandHandler=e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this._expandSwitchElement(t)},this._switchCollapseHandler=e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this._collapseSwitchElement(t)},this._checkboxChangeHandler=e=>{if(this._muteTreeEvents)return;this._muteSceneEvents=!0;const t=e.target,i=this._renderService.isChecked(t),s=this._renderService.getIdFromCheckbox(t),r=this._nodeNodes[s],o=this._viewer.scene.objects;let n=0;this._withNodeTree(r,(e=>{const t=e.objectId,s=o[t],r=0===e.children.length;e.numVisibleEntities=i?e.numEntities:0,r&&i!==e.checked&&n++,e.checked=i,this._renderService.setCheckbox(e.nodeId,i),s&&(s.visible=i)}));let a=r.parent;for(;a;)a.checked=i,i?a.numVisibleEntities+=n:a.numVisibleEntities-=n,this._renderService.setCheckbox(a.nodeId,a.numVisibleEntities>0),a=a.parent;this._muteSceneEvents=!1},this._hierarchy=t.hierarchy||"containment",this._autoExpandDepth=t.autoExpandDepth||0,this._autoAddModels){const e=Object.keys(this.viewer.metaScene.metaModels);for(let t=0,i=e.length;t{this.viewer.metaScene.metaModels[e]&&this.addModel(e)}))}this.hierarchy=t.hierarchy}else this.error("Mandatory config expected: valid containerElementId or containerElement")}set hierarchy(e){"containment"!==(e=e||"containment")&&"storeys"!==e&&"types"!==e&&(this.error("Unsupported value for `hierarchy' - defaulting to 'containment'"),e="containment"),this._hierarchy!==e&&(this._hierarchy=e,this._createNodes())}get hierarchy(){return this._hierarchy}addModel(e,t={}){if(!this._containerElement)return;const i=this.viewer.scene.models[e];if(!i)throw"Model not found: "+e;const s=this.viewer.metaScene.metaModels[e];s?this._metaModels[e]?this.warn("Model already added: "+e):(this._metaModels[e]=s,t&&t.rootName&&(this._rootNames[e]=t.rootName),i.on("destroyed",(()=>{this.removeModel(i.id)})),this._createNodes()):this.error("MetaModel not found: "+e)}removeModel(e){if(!this._containerElement)return;this._metaModels[e]&&(this._rootNames[e]&&delete this._rootNames[e],delete this._metaModels[e],this._createNodes())}showNode(e){this.unShowNode();const t=this._objectNodes[e];if(!t)return;const i=t.nodeId,s=this._renderService.getSwitchElement(i);if(s)return this._expandSwitchElement(s),s.scrollIntoView(),!0;const r=[];r.unshift(t);let o=t.parent;for(;o;)r.unshift(o),o=o.parent;for(let e=0,t=r.length;e{if(s===e)return;const r=this._renderService.getSwitchElement(i.nodeId);if(r){this._expandSwitchElement(r);const e=i.children;for(var o=0,n=e.length;o0;return this.valid}_validateMetaModelForStoreysHierarchy(e=0,t,i){return!0}_createEnabledNodes(){switch(this._pruneEmptyNodes&&this._findEmptyNodes(),this._hierarchy){case"storeys":this._createStoreysNodes(),0===this._rootNodes.length&&this.error("Failed to build storeys hierarchy");break;case"types":this._createTypesNodes();break;default:this._createContainmentNodes()}this._sortNodes&&this._doSortNodes(),this._synchNodesToEntities(),this._createTrees(),this.expandToDepth(this._autoExpandDepth)}_createDisabledNodes(){const e=this._renderService.createRootNode();this._rootElement=e,this._containerElement.appendChild(e);const t=this._viewer.metaScene.rootMetaObjects;for(let i in t){const s=t[i],r=s.type,o=s.name,n=o&&""!==o&&"Undefined"!==o&&"Default"!==o?o:r,a=this._renderService.createDisabledNodeElement(n);e.appendChild(a)}}_findEmptyNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._findEmptyNodes2(e[t])}_findEmptyNodes2(e,t=0){const i=this.viewer.scene,s=e.children,r=e.id,o=i.objects[r];if(e._countEntities=0,o&&e._countEntities++,s)for(let t=0,i=s.length;t{e.aabb&&r.aabb||(e.aabb||(e.aabb=t.getAABB(s.getObjectIDsInSubtree(e.objectId))),r.aabb||(r.aabb=t.getAABB(s.getObjectIDsInSubtree(r.objectId))));let o=0;return o=i.xUp?0:i.yUp?1:2,e.aabb[o]>r.aabb[o]?-1:e.aabb[o]s?1:0}_synchNodesToEntities(){const e=Object.keys(this.viewer.metaScene.metaObjects),t=this._viewer.metaScene.metaObjects,i=this._viewer.scene.objects;for(let s=0,r=e.length;sthis._createNodeElement(e))),t=this._renderService.createRootNode();e.forEach((e=>{t.appendChild(e)})),this._containerElement.appendChild(t),this._rootElement=t}_createNodeElement(e){return this._renderService.createNodeElement(e,this._switchExpandHandler,this._checkboxChangeHandler,(t=>{this.fire("contextmenu",{event:t,viewer:this._viewer,treeViewPlugin:this,treeViewNode:e}),t.preventDefault()}),(t=>{this.fire("nodeTitleClicked",{event:t,viewer:this._viewer,treeViewPlugin:this,treeViewNode:e}),t.preventDefault()}))}_expandSwitchElement(e){if(this._renderService.isExpanded(e))return;const t=this._renderService.getId(e),i=this._nodeNodes[t].children.map((e=>this._createNodeElement(e)));this._renderService.addChildren(e,i),this._renderService.expand(e,this._switchExpandHandler,this._switchCollapseHandler)}_collapseNode(e){const t=this._renderService.getSwitchElement(e);this._collapseSwitchElement(t)}_collapseSwitchElement(e){this._renderService.collapse(e,this._switchExpandHandler,this._switchCollapseHandler)}}class dC{constructor(e){this._scene=e,this._objects=[],this._objectsViewCulled=[],this._objectsDetailCulled=[],this._objectsChanged=[],this._objectsChangedList=[],this._modelInfos={},this._numObjects=0,this._lenObjectsChangedList=0,this._dirty=!0,this._onModelLoaded=e.on("modelLoaded",(t=>{const i=e.models[t];i&&this._addModel(i)})),this._onTick=e.on("tick",(()=>{this._dirty&&this._build(),this._applyChanges()}))}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._dirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._dirty=!0)}_build(){if(!this._dirty)return;this._applyChanges();const e=this._scene.objects;for(let e=0;e0){for(let e=0;e{delete pC[t],i._destroy()}))),i}(e.scene),this._maxTreeDepth=t.maxTreeDepth||8,this._modelInfos={},this._frustum=new N,this._kdRoot=null,this._frustumDirty=!1,this._kdTreeDirty=!1,this._onViewMatrix=e.scene.camera.on("viewMatrix",(()=>{this._frustumDirty=!0})),this._onProjMatrix=e.scene.camera.on("projMatMatrix",(()=>{this._frustumDirty=!0})),this._onModelLoaded=e.scene.on("modelLoaded",(e=>{const t=this.viewer.scene.models[e];t&&this._addModel(t)})),this._onSceneTick=e.scene.on("tick",(()=>{this._doCull()}))}set enabled(e){this._enabled=e}get enabled(){return this._enabled}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._kdTreeDirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._kdTreeDirty=!0)}_doCull(){const e=this._frustumDirty||this._kdTreeDirty;if(this._frustumDirty&&this._buildFrustum(),this._kdTreeDirty&&this._buildKDTree(),e){const e=this._kdRoot;e&&this._visitKDNode(e)}}_buildFrustum(){const e=this.viewer.scene.camera;Q(this._frustum,e.viewMatrix,e.projMatrix),this._frustumDirty=!1}_buildKDTree(){const e=this.viewer.scene;this._kdRoot,this._kdRoot={aabb:e.getAABB(),intersection:N.INTERSECT};for(let e=0,t=this._objectCullStates.numObjects;e=this._maxTreeDepth)return e.objects=e.objects||[],e.objects.push(i),void d.expandAABB3(e.aabb,r);if(e.left&&d.containsAABB3(e.left.aabb,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1);if(e.right&&d.containsAABB3(e.right.aabb,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1);const o=e.aabb;fC[0]=o[3]-o[0],fC[1]=o[4]-o[1],fC[2]=o[5]-o[2];let n=0;if(fC[1]>fC[n]&&(n=1),fC[2]>fC[n]&&(n=2),!e.left){const a=o.slice();if(a[n+3]=(o[n]+o[n+3])/2,e.left={aabb:a,intersection:N.INTERSECT},d.containsAABB3(a,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1)}if(!e.right){const a=o.slice();if(a[n]=(o[n]+o[n+3])/2,e.right={aabb:a,intersection:N.INTERSECT},d.containsAABB3(a,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1)}e.objects=e.objects||[],e.objects.push(i),d.expandAABB3(e.aabb,r)}_visitKDNode(e,t=N.INTERSECT){if(t!==N.INTERSECT&&e.intersects===t)return;t===N.INTERSECT&&(t=V(this._frustum,e.aabb),e.intersects=t);const i=t===N.OUTSIDE,s=e.objects;if(s&&s.length>0)for(let e=0,t=s.length;e{t(e)}),(function(e){i(e)}))}getMetaModel(e,t,i){y.loadJSON(e,(e=>{t(e)}),(function(e){i(e)}))}getXKT(e,t,i){var s=()=>{};t=t||s,i=i||s;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var o=r[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),i=new Uint8Array(e);for(var n=0;n0&&r[r.length-1])||6!==o[0]&&2!==o[0])){n=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=55296&&r<=56319&&i>10),n%1024+56320)),(r+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Bd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",xd="undefined"==typeof Uint8Array?[]:new Uint8Array(256),wd=0;wd=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Id="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Dd="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Sd=0;Sd>4,h[l++]=(15&s)<<4|r>>2,h[l++]=(3&r)<<6|63&o;return A}(e),n=Array.isArray(o)?function(e){for(var t=e.length,i=[],s=0;s0;){var n=s[--o];if(Array.isArray(e)?-1!==e.indexOf(n):e===n)for(var a=i;a<=s.length;){var l;if((l=s[++a])===t)return!0;if(l!==Td)break}if(n!==Td)break}return!1},dp=function(e,t){for(var i=e;i>=0;){var s=t[i];if(s!==Td)return s;i--}return 0},pp=function(e,t,i,s,r){if(0===i[s])return"×";var o=s-1;if(Array.isArray(r)&&!0===r[o])return"×";var n=o-1,a=o+1,l=t[o],A=n>=0?t[n]:0,h=t[a];if(2===l&&3===h)return"×";if(-1!==np.indexOf(l))return"!";if(-1!==np.indexOf(h))return"×";if(-1!==ap.indexOf(h))return"×";if(8===dp(o,t))return"÷";if(11===rp.get(e[o]))return"×";if((l===Xd||l===Jd)&&11===rp.get(e[a]))return"×";if(7===l||7===h)return"×";if(9===l)return"×";if(-1===[Td,Rd,Ld].indexOf(l)&&9===h)return"×";if(-1!==[Ud,kd,Od,Hd,Wd].indexOf(h))return"×";if(dp(o,t)===Vd)return"×";if(up(23,Vd,o,t))return"×";if(up([Ud,kd],Qd,o,t))return"×";if(up(12,12,o,t))return"×";if(l===Td)return"÷";if(23===l||23===h)return"×";if(16===h||16===l)return"÷";if(-1!==[Rd,Ld,Qd].indexOf(h)||14===l)return"×";if(36===A&&-1!==cp.indexOf(l))return"×";if(l===Wd&&36===h)return"×";if(h===Nd)return"×";if(-1!==op.indexOf(h)&&l===jd||-1!==op.indexOf(l)&&h===jd)return"×";if(l===zd&&-1!==[qd,Xd,Jd].indexOf(h)||-1!==[qd,Xd,Jd].indexOf(l)&&h===Gd)return"×";if(-1!==op.indexOf(l)&&-1!==lp.indexOf(h)||-1!==lp.indexOf(l)&&-1!==op.indexOf(h))return"×";if(-1!==[zd,Gd].indexOf(l)&&(h===jd||-1!==[Vd,Ld].indexOf(h)&&t[a+1]===jd)||-1!==[Vd,Ld].indexOf(l)&&h===jd||l===jd&&-1!==[jd,Wd,Hd].indexOf(h))return"×";if(-1!==[jd,Wd,Hd,Ud,kd].indexOf(h))for(var c=o;c>=0;){if((u=t[c])===jd)return"×";if(-1===[Wd,Hd].indexOf(u))break;c--}if(-1!==[zd,Gd].indexOf(h))for(c=-1!==[Ud,kd].indexOf(l)?n:o;c>=0;){var u;if((u=t[c])===jd)return"×";if(-1===[Wd,Hd].indexOf(u))break;c--}if($d===l&&-1!==[$d,ep,Yd,Zd].indexOf(h)||-1!==[ep,Yd].indexOf(l)&&-1!==[ep,tp].indexOf(h)||-1!==[tp,Zd].indexOf(l)&&h===tp)return"×";if(-1!==hp.indexOf(l)&&-1!==[Nd,Gd].indexOf(h)||-1!==hp.indexOf(h)&&l===zd)return"×";if(-1!==op.indexOf(l)&&-1!==op.indexOf(h))return"×";if(l===Hd&&-1!==op.indexOf(h))return"×";if(-1!==op.concat(jd).indexOf(l)&&h===Vd&&-1===sp.indexOf(e[a])||-1!==op.concat(jd).indexOf(h)&&l===kd)return"×";if(41===l&&41===h){for(var d=i[o],p=1;d>0&&41===t[--d];)p++;if(p%2!=0)return"×"}return l===Xd&&h===Jd?"×":"÷"},fp=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=function(e,t){void 0===t&&(t="strict");var i=[],s=[],r=[];return e.forEach((function(e,o){var n=rp.get(e);if(n>50?(r.push(!0),n-=50):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return s.push(o),i.push(16);if(4===n||11===n){if(0===o)return s.push(o),i.push(Kd);var a=i[o-1];return-1===Ap.indexOf(a)?(s.push(s[o-1]),i.push(a)):(s.push(o),i.push(Kd))}return s.push(o),31===n?i.push("strict"===t?Qd:qd):n===ip||29===n?i.push(Kd):43===n?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(qd):i.push(Kd):void i.push(n)})),[s,i,r]}(e,t.lineBreak),s=i[0],r=i[1],o=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[jd,Kd,ip].indexOf(e)?qd:e})));var n="keep-all"===t.wordBreak?o.map((function(t,i){return t&&e[i]>=19968&&e[i]<=40959})):void 0;return[s,r,n]},gp=function(){function e(e,t,i,s){this.codePoints=e,this.required="!"===t,this.start=i,this.end=s}return e.prototype.slice=function(){return yd.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),mp=function(e){return e>=48&&e<=57},_p=function(e){return mp(e)||e>=65&&e<=70||e>=97&&e<=102},vp=function(e){return 10===e||9===e||32===e},bp=function(e){return function(e){return function(e){return e>=97&&e<=122}(e)||function(e){return e>=65&&e<=90}(e)}(e)||function(e){return e>=128}(e)||95===e},yp=function(e){return bp(e)||mp(e)||45===e},Bp=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},xp=function(e,t){return 92===e&&10!==t},wp=function(e,t,i){return 45===e?bp(t)||xp(t,i):!!bp(e)||!(92!==e||!xp(e,t))},Pp=function(e,t,i){return 43===e||45===e?!!mp(t)||46===t&&mp(i):mp(46===e?t:e)},Cp=function(e){var t=0,i=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(i=-1),t++);for(var s=[];mp(e[t]);)s.push(e[t++]);var r=s.length?parseInt(yd.apply(void 0,s),10):0;46===e[t]&&t++;for(var o=[];mp(e[t]);)o.push(e[t++]);var n=o.length,a=n?parseInt(yd.apply(void 0,o),10):0;69!==e[t]&&101!==e[t]||t++;var l=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(l=-1),t++);for(var A=[];mp(e[t]);)A.push(e[t++]);var h=A.length?parseInt(yd.apply(void 0,A),10):0;return i*(r+a*Math.pow(10,-n))*Math.pow(10,l*h)},Mp={type:2},Fp={type:3},Ep={type:4},Ip={type:13},Dp={type:8},Sp={type:21},Tp={type:9},Rp={type:10},Lp={type:11},Up={type:12},kp={type:14},Op={type:23},Np={type:1},Qp={type:25},Vp={type:24},Hp={type:26},jp={type:27},Gp={type:28},zp={type:29},Wp={type:31},Kp={type:32},Xp=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(bd(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==Kp;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(yp(t)||xp(i,s)){var r=wp(t,i,s)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Ip;break;case 39:return this.consumeStringToken(39);case 40:return Mp;case 41:return Fp;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),kp;break;case 43:if(Pp(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return Ep;case 45:var o=e,n=this.peekCodePoint(0),a=this.peekCodePoint(1);if(Pp(o,n,a))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(wp(o,n,a))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===n&&62===a)return this.consumeCodePoint(),this.consumeCodePoint(),Vp;break;case 46:if(Pp(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(42===l&&47===(l=this.consumeCodePoint()))return this.consumeToken();if(-1===l)return this.consumeToken()}break;case 58:return Hp;case 59:return jp;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),Qp;break;case 64:var A=this.peekCodePoint(0),h=this.peekCodePoint(1),c=this.peekCodePoint(2);if(wp(A,h,c))return{type:7,value:this.consumeName()};break;case 91:return Gp;case 92:if(xp(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return zp;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Dp;break;case 123:return Lp;case 125:return Up;case 117:case 85:var u=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==u||!_p(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Tp;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),Sp;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Rp;break;case-1:return Kp}return vp(e)?(this.consumeWhiteSpace(),Wp):mp(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):bp(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:yd(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();_p(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(yd.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(yd.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var s=parseInt(yd.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&_p(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];_p(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:s,end:parseInt(yd.apply(void 0,r),16)}}return{type:30,start:s,end:s}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var t=this.peekCodePoint(0);if(39===t||34===t){var i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),Op)}for(;;){var s=this.consumeCodePoint();if(-1===s||41===s)return{type:22,value:yd.apply(void 0,e)};if(vp(s))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:yd.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Op);if(34===s||39===s||40===s||Bp(s))return this.consumeBadUrlRemnants(),Op;if(92===s){if(!xp(s,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),Op;e.push(this.consumeEscapedCodePoint())}else e.push(s)}},e.prototype.consumeWhiteSpace=function(){for(;vp(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;xp(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var i=Math.min(5e4,e);t+=yd.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var s=this._value[i];if(-1===s||void 0===s||s===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(10===s)return this._value.splice(0,i),Np;if(92===s){var r=this._value[i+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):xp(s,r)&&(t+=this.consumeStringSlice(i),t+=yd(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=4,i=this.peekCodePoint(0);for(43!==i&&45!==i||e.push(this.consumeCodePoint());mp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var s=this.peekCodePoint(1);if(46===i&&mp(s))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;mp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),s=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===i||101===i)&&((43===s||45===s)&&mp(r)||mp(s)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;mp(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[Cp(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],s=this.peekCodePoint(0),r=this.peekCodePoint(1),o=this.peekCodePoint(2);return wp(s,r,o)?{type:15,number:t,flags:i,unit:this.consumeName()}:37===s?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(_p(e)){for(var t=yd(e);_p(this.peekCodePoint(0))&&t.length<6;)t+=yd(this.consumeCodePoint());vp(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||function(e){return e>=55296&&e<=57343}(i)||i>1114111?65533:i}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(yp(t))e+=yd(t);else{if(!xp(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=yd(this.consumeEscapedCodePoint())}}},e}(),Jp=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new Xp;return i.write(t),new e(i.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(32===i.type||of(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?Kp:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),Yp=function(e){return 15===e.type},Zp=function(e){return 17===e.type},qp=function(e){return 20===e.type},$p=function(e){return 0===e.type},ef=function(e,t){return qp(e)&&e.value===t},tf=function(e){return 31!==e.type},sf=function(e){return 31!==e.type&&4!==e.type},rf=function(e){var t=[],i=[];return e.forEach((function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)})),i.length&&t.push(i),t},of=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},nf=function(e){return 17===e.type||15===e.type},af=function(e){return 16===e.type||nf(e)},lf=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},Af={type:17,number:0,flags:4},hf={type:16,number:50,flags:4},cf={type:16,number:100,flags:4},uf=function(e,t,i){var s=e[0],r=e[1];return[df(s,t),df(void 0!==r?r:s,i)]},df=function(e,t){if(16===e.type)return e.number/100*t;if(Yp(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},pf=function(e,t){if(15===t.type)switch(t.unit){case"deg":return Math.PI*t.number/180;case"grad":return Math.PI/200*t.number;case"rad":return t.number;case"turn":return 2*Math.PI*t.number}throw new Error("Unsupported angle type")},ff=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},gf=function(e){switch(e.filter(qp).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Af,Af];case"to top":case"bottom":return mf(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Af,cf];case"to right":case"left":return mf(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[cf,cf];case"to bottom":case"top":return mf(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[cf,Af];case"to left":case"right":return mf(270)}return 0},mf=function(e){return Math.PI*e/180},_f=function(e,t){if(18===t.type){var i=Cf[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var s=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);return yf(parseInt(s+s,16),parseInt(r+r,16),parseInt(o+o,16),1)}if(4===t.value.length){s=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);var n=t.value.substring(3,4);return yf(parseInt(s+s,16),parseInt(r+r,16),parseInt(o+o,16),parseInt(n+n,16)/255)}if(6===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6);return yf(parseInt(s,16),parseInt(r,16),parseInt(o,16),1)}if(8===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6),n=t.value.substring(6,8);return yf(parseInt(s,16),parseInt(r,16),parseInt(o,16),parseInt(n,16)/255)}}if(20===t.type){var a=Ff[t.value.toUpperCase()];if(void 0!==a)return a}return Ff.TRANSPARENT},vf=function(e){return 0==(255&e)},bf=function(e){var t=255&e,i=255&e>>8,s=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+s+","+i+","+t/255+")":"rgb("+r+","+s+","+i+")"},yf=function(e,t,i,s){return(e<<24|t<<16|i<<8|Math.round(255*s)<<0)>>>0},Bf=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},xf=function(e,t){var i=t.filter(sf);if(3===i.length){var s=i.map(Bf),r=s[0],o=s[1],n=s[2];return yf(r,o,n,1)}if(4===i.length){var a=i.map(Bf),l=(r=a[0],o=a[1],n=a[2],a[3]);return yf(r,o,n,l)}return 0};function wf(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var Pf=function(e,t){var i=t.filter(sf),s=i[0],r=i[1],o=i[2],n=i[3],a=(17===s.type?mf(s.number):pf(e,s))/(2*Math.PI),l=af(r)?r.number/100:0,A=af(o)?o.number/100:0,h=void 0!==n&&af(n)?df(n,1):1;if(0===l)return yf(255*A,255*A,255*A,1);var c=A<=.5?A*(l+1):A+l-A*l,u=2*A-c,d=wf(u,c,a+1/3),p=wf(u,c,a),f=wf(u,c,a-1/3);return yf(255*d,255*p,255*f,h)},Cf={hsl:Pf,hsla:Pf,rgb:xf,rgba:xf},Mf=function(e,t){return _f(e,Jp.create(t).parseComponentValue())},Ff={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Ef={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(qp(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},If={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Df=function(e,t){var i=_f(e,t[0]),s=t[1];return s&&af(s)?{color:i,stop:s}:{color:i,stop:null}},Sf=function(e,t){var i=e[0],s=e[e.length-1];null===i.stop&&(i.stop=Af),null===s.stop&&(s.stop=cf);for(var r=[],o=0,n=0;no?r.push(l):r.push(o),o=l}else r.push(null)}var A=null;for(n=0;ne.optimumDistance)?{optimumCorner:t,optimumDistance:a}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},Uf=function(e,t){var i=mf(180),s=[];return rf(t).forEach((function(t,r){if(0===r){var o=t[0];if(20===o.type&&-1!==["top","left","right","bottom"].indexOf(o.value))return void(i=gf(t));if(ff(o))return void(i=(pf(e,o)+mf(270))%mf(360))}var n=Df(e,t);s.push(n)})),{angle:i,stops:s,type:1}},kf=function(e,t){var i=0,s=3,r=[],o=[];return rf(t).forEach((function(t,n){var a=!0;if(0===n?a=t.reduce((function(e,t){if(qp(t))switch(t.value){case"center":return o.push(hf),!1;case"top":case"left":return o.push(Af),!1;case"right":case"bottom":return o.push(cf),!1}else if(af(t)||nf(t))return o.push(t),!1;return e}),a):1===n&&(a=t.reduce((function(e,t){if(qp(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"contain":case"closest-side":return s=0,!1;case"farthest-side":return s=1,!1;case"closest-corner":return s=2,!1;case"cover":case"farthest-corner":return s=3,!1}else if(nf(t)||af(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)),a){var l=Df(e,t);r.push(l)}})),{size:s,shape:i,stops:r,position:o,type:2}},Of=function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var s=Qf[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(e,t.values)}throw new Error("Unsupported image type "+t.type)};var Nf,Qf={"linear-gradient":function(e,t){var i=mf(180),s=[];return rf(t).forEach((function(t,r){if(0===r){var o=t[0];if(20===o.type&&"to"===o.value)return void(i=gf(t));if(ff(o))return void(i=pf(e,o))}var n=Df(e,t);s.push(n)})),{angle:i,stops:s,type:1}},"-moz-linear-gradient":Uf,"-ms-linear-gradient":Uf,"-o-linear-gradient":Uf,"-webkit-linear-gradient":Uf,"radial-gradient":function(e,t){var i=0,s=3,r=[],o=[];return rf(t).forEach((function(t,n){var a=!0;if(0===n){var l=!1;a=t.reduce((function(e,t){if(l)if(qp(t))switch(t.value){case"center":return o.push(hf),e;case"top":case"left":return o.push(Af),e;case"right":case"bottom":return o.push(cf),e}else(af(t)||nf(t))&&o.push(t);else if(qp(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"at":return l=!0,!1;case"closest-side":return s=0,!1;case"cover":case"farthest-side":return s=1,!1;case"contain":case"closest-corner":return s=2,!1;case"farthest-corner":return s=3,!1}else if(nf(t)||af(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)}if(a){var A=Df(e,t);r.push(A)}})),{size:s,shape:i,stops:r,position:o,type:2}},"-moz-radial-gradient":kf,"-ms-radial-gradient":kf,"-o-radial-gradient":kf,"-webkit-radial-gradient":kf,"-webkit-gradient":function(e,t){var i=mf(180),s=[],r=1;return rf(t).forEach((function(t,i){var o=t[0];if(0===i){if(qp(o)&&"linear"===o.value)return void(r=1);if(qp(o)&&"radial"===o.value)return void(r=2)}if(18===o.type)if("from"===o.name){var n=_f(e,o.values[0]);s.push({stop:Af,color:n})}else if("to"===o.name){n=_f(e,o.values[0]);s.push({stop:cf,color:n})}else if("color-stop"===o.name){var a=o.values.filter(sf);if(2===a.length){n=_f(e,a[1]);var l=a[0];Zp(l)&&s.push({stop:{type:16,number:100*l.number,flags:l.flags},color:n})}}})),1===r?{angle:(i+mf(180))%mf(360),stops:s,type:r}:{size:3,shape:0,stops:s,position:[],type:r}}},Vf={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter((function(e){return sf(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Qf[e.name])}(e)})).map((function(t){return Of(e,t)}))}},Hf={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(qp(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},jf={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return rf(t).map((function(e){return e.filter(af)})).map(lf)}},Gf={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return rf(t).map((function(e){return e.filter(qp).map((function(e){return e.value})).join(" ")})).map(zf)}},zf=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Nf||(Nf={}));var Wf,Kf={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return rf(t).map((function(e){return e.filter(Xf)}))}},Xf=function(e){return qp(e)||af(e)},Jf=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},Yf=Jf("top"),Zf=Jf("right"),qf=Jf("bottom"),$f=Jf("left"),eg=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return lf(t.filter(af))}}},tg=eg("top-left"),ig=eg("top-right"),sg=eg("bottom-right"),rg=eg("bottom-left"),og=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},ng=og("top"),ag=og("right"),lg=og("bottom"),Ag=og("left"),hg=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return Yp(t)?t.number:0}}},cg=hg("top"),ug=hg("right"),dg=hg("bottom"),pg=hg("left"),fg={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},gg={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},mg={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(qp).reduce((function(e,t){return e|_g(t.value)}),0)}},_g=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},vg={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},bg={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(Wf||(Wf={}));var yg,Bg={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?Wf.STRICT:Wf.NORMAL}},xg={name:"line-height",initialValue:"normal",prefix:!1,type:4},wg=function(e,t){return qp(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:af(e)?df(e,t):t},Pg={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:Of(e,t)}},Cg={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Mg={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},Fg=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},Eg=Fg("top"),Ig=Fg("right"),Dg=Fg("bottom"),Sg=Fg("left"),Tg={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(qp).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},Rg={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Lg=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Ug=Lg("top"),kg=Lg("right"),Og=Lg("bottom"),Ng=Lg("left"),Qg={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Vg={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Hg={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&ef(t[0],"none")?[]:rf(t).map((function(t){for(var i={color:Ff.TRANSPARENT,offsetX:Af,offsetY:Af,blur:Af},s=0,r=0;r1?1:0],this.overflowWrap=ym(e,Rg,t.overflowWrap),this.paddingTop=ym(e,Ug,t.paddingTop),this.paddingRight=ym(e,kg,t.paddingRight),this.paddingBottom=ym(e,Og,t.paddingBottom),this.paddingLeft=ym(e,Ng,t.paddingLeft),this.paintOrder=ym(e,fm,t.paintOrder),this.position=ym(e,Vg,t.position),this.textAlign=ym(e,Qg,t.textAlign),this.textDecorationColor=ym(e,em,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=ym(e,tm,null!==(s=t.textDecorationLine)&&void 0!==s?s:t.textDecoration),this.textShadow=ym(e,Hg,t.textShadow),this.textTransform=ym(e,jg,t.textTransform),this.transform=ym(e,Gg,t.transform),this.transformOrigin=ym(e,Xg,t.transformOrigin),this.visibility=ym(e,Jg,t.visibility),this.webkitTextStrokeColor=ym(e,gm,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=ym(e,mm,t.webkitTextStrokeWidth),this.wordBreak=ym(e,Yg,t.wordBreak),this.zIndex=ym(e,Zg,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return vf(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return am(this.display,4)||am(this.display,33554432)||am(this.display,268435456)||am(this.display,536870912)||am(this.display,67108864)||am(this.display,134217728)},e}(),vm=function(e,t){this.content=ym(e,lm,t.content),this.quotes=ym(e,um,t.quotes)},bm=function(e,t){this.counterIncrement=ym(e,Am,t.counterIncrement),this.counterReset=ym(e,hm,t.counterReset)},ym=function(e,t,i){var s=new Xp,r=null!=i?i.toString():t.initialValue;s.write(r);var o=new Jp(s.read());switch(t.type){case 2:var n=o.parseComponentValue();return t.parse(e,qp(n)?n.value:t.initialValue);case 0:return t.parse(e,o.parseComponentValue());case 1:return t.parse(e,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case"angle":return pf(e,o.parseComponentValue());case"color":return _f(e,o.parseComponentValue());case"image":return Of(e,o.parseComponentValue());case"length":var a=o.parseComponentValue();return nf(a)?a:Af;case"length-percentage":var l=o.parseComponentValue();return af(l)?l:Af;case"time":return qg(e,o.parseComponentValue())}}},Bm=function(e,t){var i=function(e){switch(e.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(e);return 1===i||t===i},xm=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Bm(t,3),this.styles=new _m(e,window.getComputedStyle(t,null)),x_(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=vd(this.context,t),Bm(t,4)&&(this.flags|=16)},wm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Pm="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Cm=0;Cm=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Em="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Im="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Dm=0;Dm>10),n%1024+56320)),(r+1===i||s.length>16384)&&(o+=String.fromCharCode.apply(String,s),s.length=0)}return o},Om=function(e,t){var i,s,r,o=function(e){var t,i,s,r,o,n=.75*e.length,a=e.length,l=0;"="===e[e.length-1]&&(n--,"="===e[e.length-2]&&n--);var A="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(n):new Array(n),h=Array.isArray(A)?A:new Uint8Array(A);for(t=0;t>4,h[l++]=(15&s)<<4|r>>2,h[l++]=(3&r)<<6|63&o;return A}(e),n=Array.isArray(o)?function(e){for(var t=e.length,i=[],s=0;s=55296&&r<=56319&&i=i)return{done:!0,value:null};for(var e="×";sn.x||r.y>n.y;return n=r,0===t||a}));return e.body.removeChild(t),a}(document);return Object.defineProperty(zm,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,i=e.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,";try{s.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(zm,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?function(e){var t=e.createElement("canvas"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var r=new Image,o=t.toDataURL();r.src=o;var n=jm(i,i,0,0,r);return s.fillStyle="red",s.fillRect(0,0,i,i),Gm(n).then((function(t){s.drawImage(t,0,0);var r=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var n=e.createElement("div");return n.style.backgroundImage="url("+o+")",n.style.height="100px",Hm(r)?Gm(jm(i,i,0,0,n)):Promise.reject(!1)})).then((function(e){return s.drawImage(e,0,0),Hm(s.getImageData(0,0,i,i).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(zm,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(zm,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(zm,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(zm,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(zm,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Wm=function(e,t){this.text=e,this.bounds=t},Km=function(e,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(s,t);var o=vd(e,s);return s.firstChild&&r.replaceChild(s.firstChild,s),o}}return _d.EMPTY},Xm=function(e,t,i){var s=e.ownerDocument;if(!s)throw new Error("Node has no owner document");var r=s.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},Jm=function(e){if(zm.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return function(e){for(var t,i=Vm(e),s=[];!(t=i.next()).done;)t.value&&s.push(t.value.slice());return s}(e)},Ym=function(e,t){return 0!==t.letterSpacing?Jm(e):function(e,t){if(zm.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map((function(e){return e.segment}))}return qm(e,t)}(e,t)},Zm=[32,160,4961,65792,65793,4153,4241],qm=function(e,t){for(var i,s=function(e,t){var i=bd(e),s=fp(i,t),r=s[0],o=s[1],n=s[2],a=i.length,l=0,A=0;return{next:function(){if(A>=a)return{done:!0,value:null};for(var e="×";A0)if(zm.SUPPORT_RANGE_BOUNDS){var r=Xm(s,n,t.length).getClientRects();if(r.length>1){var a=Jm(t),l=0;a.forEach((function(t){o.push(new Wm(t,_d.fromDOMRectList(e,Xm(s,l+n,t.length).getClientRects()))),l+=t.length}))}else o.push(new Wm(t,_d.fromDOMRectList(e,r)))}else{var A=s.splitText(t.length);o.push(new Wm(t,Km(e,s))),s=A}else zm.SUPPORT_RANGE_BOUNDS||(s=s.splitText(t.length));n+=t.length})),o}(e,this.text,i,t)},e_=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(t_,i_);case 2:return e.toUpperCase();default:return e}},t_=/(^|\s|:|-|\(|\))([a-z])/g,i_=function(e,t,i){return e.length>0?t+i.toUpperCase():e},s_=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.src=i.currentSrc||i.src,s.intrinsicWidth=i.naturalWidth,s.intrinsicHeight=i.naturalHeight,s.context.cache.addImage(s.src),s}return dd(t,e),t}(xm),r_=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i,s.intrinsicWidth=i.width,s.intrinsicHeight=i.height,s}return dd(t,e),t}(xm),o_=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=new XMLSerializer,o=vd(t,i);return i.setAttribute("width",o.width+"px"),i.setAttribute("height",o.height+"px"),s.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),s.intrinsicWidth=i.width.baseVal.value,s.intrinsicHeight=i.height.baseVal.value,s.context.cache.addImage(s.svg),s}return dd(t,e),t}(xm),n_=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return dd(t,e),t}(xm),a_=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.start=i.start,s.reversed="boolean"==typeof i.reversed&&!0===i.reversed,s}return dd(t,e),t}(xm),l_=[{type:15,flags:0,unit:"px",number:3}],A_=[{type:16,flags:0,number:50}],h_="password",c_=function(e){function t(t,i){var s,r=e.call(this,t,i)||this;switch(r.type=i.type.toLowerCase(),r.checked=i.checked,r.value=function(e){var t=e.type===h_?new Array(e.value.length+1).join("•"):e.value;return 0===t.length?e.placeholder||"":t}(i),"checkbox"!==r.type&&"radio"!==r.type||(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=(s=r.bounds).width>s.height?new _d(s.left+(s.width-s.height)/2,s.top,s.height,s.height):s.width0)i.textNodes.push(new $m(e,r,i.styles));else if(B_(r))if(k_(r)&&r.assignedNodes)r.assignedNodes().forEach((function(t){return g_(e,t,i,s)}));else{var n=m_(e,r);n.styles.isVisible()&&(v_(r,n,s)?n.flags|=4:b_(n.styles)&&(n.flags|=2),-1!==f_.indexOf(r.tagName)&&(n.flags|=8),i.elements.push(n),r.slot,r.shadowRoot?g_(e,r.shadowRoot,n,s):L_(r)||F_(r)||U_(r)||g_(e,r,n,s))}},m_=function(e,t){return S_(t)?new s_(e,t):I_(t)?new r_(e,t):F_(t)?new o_(e,t):P_(t)?new n_(e,t):C_(t)?new a_(e,t):M_(t)?new c_(e,t):U_(t)?new u_(e,t):L_(t)?new d_(e,t):T_(t)?new p_(e,t):new xm(e,t)},__=function(e,t){var i=m_(e,t);return i.flags|=4,g_(e,t,i,i),i},v_=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||E_(e)&&i.styles.isTransparent()},b_=function(e){return e.isPositioned()||e.isFloating()},y_=function(e){return e.nodeType===Node.TEXT_NODE},B_=function(e){return e.nodeType===Node.ELEMENT_NODE},x_=function(e){return B_(e)&&void 0!==e.style&&!w_(e)},w_=function(e){return"object"==typeof e.className},P_=function(e){return"LI"===e.tagName},C_=function(e){return"OL"===e.tagName},M_=function(e){return"INPUT"===e.tagName},F_=function(e){return"svg"===e.tagName},E_=function(e){return"BODY"===e.tagName},I_=function(e){return"CANVAS"===e.tagName},D_=function(e){return"VIDEO"===e.tagName},S_=function(e){return"IMG"===e.tagName},T_=function(e){return"IFRAME"===e.tagName},R_=function(e){return"STYLE"===e.tagName},L_=function(e){return"TEXTAREA"===e.tagName},U_=function(e){return"SELECT"===e.tagName},k_=function(e){return"SLOT"===e.tagName},O_=function(e){return e.tagName.indexOf("-")>0},N_=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,i=e.counterIncrement,s=e.counterReset,r=!0;null!==i&&i.forEach((function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)}));var o=[];return r&&s.forEach((function(e){var i=t.counters[e.counter];o.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)})),o},e}(),Q_={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},V_={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},H_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},j_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},G_=function(e,t,i,s,r,o){return ei?J_(e,r,o.length>0):s.integers.reduce((function(t,i,r){for(;e>=i;)e-=i,t+=s.values[r];return t}),"")+o},z_=function(e,t,i,s){var r="";do{i||e--,r=s(e)+r,e/=t}while(e*t>=t);return r},W_=function(e,t,i,s,r){var o=i-t+1;return(e<0?"-":"")+(z_(Math.abs(e),o,s,(function(e){return yd(Math.floor(e%o)+t)}))+r)},K_=function(e,t,i){void 0===i&&(i=". ");var s=t.length;return z_(Math.abs(e),s,!1,(function(e){return t[Math.floor(e%s)]}))+i},X_=function(e,t,i,s,r,o){if(e<-9999||e>9999)return J_(e,4,r.length>0);var n=Math.abs(e),a=r;if(0===n)return t[0]+a;for(var l=0;n>0&&l<=4;l++){var A=n%10;0===A&&am(o,1)&&""!==a?a=t[A]+a:A>1||1===A&&0===l||1===A&&1===l&&am(o,2)||1===A&&1===l&&am(o,4)&&e>100||1===A&&l>1&&am(o,8)?a=t[A]+(l>0?i[l-1]:"")+a:1===A&&l>0&&(a=i[l-1]+a),n=Math.floor(n/10)}return(e<0?s:"")+a},J_=function(e,t,i){var s=i?". ":"",r=i?"、":"",o=i?", ":"",n=i?" ":"";switch(t){case 0:return"•"+n;case 1:return"◦"+n;case 2:return"◾"+n;case 5:var a=W_(e,48,57,!0,s);return a.length<4?"0"+a:a;case 4:return K_(e,"〇一二三四五六七八九",r);case 6:return G_(e,1,3999,Q_,3,s).toLowerCase();case 7:return G_(e,1,3999,Q_,3,s);case 8:return W_(e,945,969,!1,s);case 9:return W_(e,97,122,!1,s);case 10:return W_(e,65,90,!1,s);case 11:return W_(e,1632,1641,!0,s);case 12:case 49:return G_(e,1,9999,V_,3,s);case 35:return G_(e,1,9999,V_,3,s).toLowerCase();case 13:return W_(e,2534,2543,!0,s);case 14:case 30:return W_(e,6112,6121,!0,s);case 15:return K_(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return K_(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return X_(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return X_(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return X_(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return X_(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return X_(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return X_(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return X_(e,"영일이삼사오육칠팔구","십백천만","마이너스",o,7);case 33:return X_(e,"零一二三四五六七八九","十百千萬","마이너스",o,0);case 32:return X_(e,"零壹貳參四五六七八九","拾百千","마이너스",o,7);case 18:return W_(e,2406,2415,!0,s);case 20:return G_(e,1,19999,j_,3,s);case 21:return W_(e,2790,2799,!0,s);case 22:return W_(e,2662,2671,!0,s);case 22:return G_(e,1,10999,H_,3,s);case 23:return K_(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return K_(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return W_(e,3302,3311,!0,s);case 28:return K_(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return K_(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return W_(e,3792,3801,!0,s);case 37:return W_(e,6160,6169,!0,s);case 38:return W_(e,4160,4169,!0,s);case 39:return W_(e,2918,2927,!0,s);case 40:return W_(e,1776,1785,!0,s);case 43:return W_(e,3046,3055,!0,s);case 44:return W_(e,3174,3183,!0,s);case 45:return W_(e,3664,3673,!0,s);case 46:return W_(e,3872,3881,!0,s);default:return W_(e,48,57,!0,s)}},Y_=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new N_,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var i=this,s=q_(e,t);if(!s.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,o=e.defaultView.pageYOffset,n=s.contentWindow,a=n.document,l=tv(s).then((function(){return fd(i,void 0,void 0,(function(){var e,i;return gd(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(nv),n&&(n.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||n.scrollY===t.top&&n.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(n.scrollX-t.left,n.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(i=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:a.fonts&&a.fonts.ready?[4,a.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,ev(a)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(a,i)})).then((function(){return s}))]:[2,s]}}))}))}));return a.open(),a.write(rv(document.doctype)+""),ov(this.referenceElement.ownerDocument,r,o),a.replaceChild(a.adoptNode(this.documentElement),a.documentElement),a.close(),l},e.prototype.createElementClone=function(e){if(Bm(e,2),I_(e))return this.createCanvasClone(e);if(D_(e))return this.createVideoClone(e);if(R_(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return S_(t)&&(S_(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),O_(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return sv(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),s=e.cloneNode(!1);return s.textContent=i,s}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var s=e.cloneNode(!1);try{s.width=e.width,s.height=e.height;var r=e.getContext("2d"),o=s.getContext("2d");if(o)if(!this.options.allowTaint&&r)o.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var n=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(n){var a=n.getContextAttributes();!1===(null==a?void 0:a.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}o.drawImage(e,0,0)}return s}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return s},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var s=e.ownerDocument.createElement("canvas");return s.width=e.offsetWidth,s.height=e.offsetHeight,s},e.prototype.appendChildNode=function(e,t,i){B_(t)&&(function(e){return"SCRIPT"===e.tagName}(t)||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&B_(t)&&R_(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var s=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(B_(r)&&k_(r)&&"function"==typeof r.assignedNodes){var o=r.assignedNodes();o.length&&o.forEach((function(e){return s.appendChildNode(t,e,i)}))}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(y_(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&B_(e)&&(x_(e)||w_(e))){var s=this.createElementClone(e);s.style.transitionProperty="none";var r=i.getComputedStyle(e),o=i.getComputedStyle(e,":before"),n=i.getComputedStyle(e,":after");this.referenceElement===e&&x_(s)&&(this.clonedReferenceElement=s),E_(s)&&Av(s);var a=this.counters.parse(new bm(this.context,r)),l=this.resolvePseudoContent(e,s,o,Sm.BEFORE);O_(e)&&(t=!0),D_(e)||this.cloneChildNodes(e,s,t),l&&s.insertBefore(l,s.firstChild);var A=this.resolvePseudoContent(e,s,n,Sm.AFTER);return A&&s.appendChild(A),this.counters.pop(a),(r&&(this.options.copyStyles||w_(e))&&!T_(e)||t)&&sv(r,s),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([s,e.scrollLeft,e.scrollTop]),(L_(e)||U_(e))&&(L_(s)||U_(s))&&(s.value=e.value),s}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,s){var r=this;if(i){var o=i.content,n=t.ownerDocument;if(n&&o&&"none"!==o&&"-moz-alt-content"!==o&&"none"!==i.display){this.counters.parse(new bm(this.context,i));var a=new vm(this.context,i),l=n.createElement("html2canvaspseudoelement");sv(i,l),a.content.forEach((function(t){if(0===t.type)l.appendChild(n.createTextNode(t.value));else if(22===t.type){var i=n.createElement("img");i.src=t.value,i.style.opacity="1",l.appendChild(i)}else if(18===t.type){if("attr"===t.name){var s=t.values.filter(qp);s.length&&l.appendChild(n.createTextNode(e.getAttribute(s[0].value)||""))}else if("counter"===t.name){var o=t.values.filter(sf),A=o[0],h=o[1];if(A&&qp(A)){var c=r.counters.getCounterValue(A.value),u=h&&qp(h)?Mg.parse(r.context,h.value):3;l.appendChild(n.createTextNode(J_(c,u,!1)))}}else if("counters"===t.name){var d=t.values.filter(sf),p=(A=d[0],d[1]);h=d[2];if(A&&qp(A)){var f=r.counters.getCounterValues(A.value),g=h&&qp(h)?Mg.parse(r.context,h.value):3,m=p&&0===p.type?p.value:"",_=f.map((function(e){return J_(e,g,!1)})).join(m);l.appendChild(n.createTextNode(_))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(n.createTextNode(dm(a.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(n.createTextNode(dm(a.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(n.createTextNode(t.value))}})),l.className=av+" "+lv;var A=s===Sm.BEFORE?" "+av:" "+lv;return w_(t)?t.className.baseValue+=A:t.className+=A,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(Sm||(Sm={}));var Z_,q_=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(i),i},$_=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},ev=function(e){return Promise.all([].slice.call(e.images,0).map($_))},tv=function(e){return new Promise((function(t,i){var s=e.contentWindow;if(!s)return i("No window assigned for iframe");var r=s.document;s.onload=e.onload=function(){s.onload=e.onload=null;var i=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))}),50)}}))},iv=["all","d","content"],sv=function(e,t){for(var i=e.length-1;i>=0;i--){var s=e.item(i);-1===iv.indexOf(s)&&t.style.setProperty(s,e.getPropertyValue(s))}return t},rv=function(e){var t="";return e&&(t+=""),t},ov=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},nv=function(e){var t=e[0],i=e[1],s=e[2];t.scrollLeft=i,t.scrollTop=s},av="___html2canvas___pseudoelement_before",lv="___html2canvas___pseudoelement_after",Av=function(e){hv(e,"."+av+':before{\n content: "" !important;\n display: none !important;\n}\n .'+lv+':after{\n content: "" !important;\n display: none !important;\n}')},hv=function(e,t){var i=e.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,e.appendChild(s)}},cv=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),uv=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:vv(e)||gv(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return fd(this,void 0,void 0,(function(){var t,i,s,r,o=this;return gd(this,(function(n){switch(n.label){case 0:return t=cv.isSameOrigin(e),i=!mv(e)&&!0===this._options.useCORS&&zm.SUPPORT_CORS_IMAGES&&!t,s=!mv(e)&&!t&&!vv(e)&&"string"==typeof this._options.proxy&&zm.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||mv(e)||vv(e)||s||i?(r=e,s?[4,this.proxy(r)]:[3,2]):[2];case 1:r=n.sent(),n.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var s=new Image;s.onload=function(){return e(s)},s.onerror=t,(_v(r)||i)&&(s.crossOrigin="anonymous"),s.src=r,!0===s.complete&&setTimeout((function(){return e(s)}),500),o._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+o._options.imageTimeout+"ms) loading image")}),o._options.imageTimeout)}))];case 3:return[2,n.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var s=e.substring(0,256);return new Promise((function(r,o){var n=zm.SUPPORT_RESPONSE_TYPE?"blob":"text",a=new XMLHttpRequest;a.onload=function(){if(200===a.status)if("text"===n)r(a.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return o(e)}),!1),e.readAsDataURL(a.response)}else o("Failed to proxy resource "+s+" with status code "+a.status)},a.onerror=o;var l=i.indexOf("?")>-1?"&":"?";if(a.open("GET",""+i+l+"url="+encodeURIComponent(e)+"&responseType="+n),"text"!==n&&a instanceof XMLHttpRequest&&(a.responseType=n),t._options.imageTimeout){var A=t._options.imageTimeout;a.timeout=A,a.ontimeout=function(){return o("Timed out ("+A+"ms) proxying "+s)}}a.send()}))},e}(),dv=/^data:image\/svg\+xml/i,pv=/^data:image\/.*;base64,/i,fv=/^data:image\/.*/i,gv=function(e){return zm.SUPPORT_SVG_DRAWING||!bv(e)},mv=function(e){return fv.test(e)},_v=function(e){return pv.test(e)},vv=function(e){return"blob"===e.substr(0,4)},bv=function(e){return"svg"===e.substr(-3).toLowerCase()||dv.test(e)},yv=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),Bv=function(e,t,i){return new yv(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},xv=function(){function e(e,t,i,s){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=s}return e.prototype.subdivide=function(t,i){var s=Bv(this.start,this.startControl,t),r=Bv(this.startControl,this.endControl,t),o=Bv(this.endControl,this.end,t),n=Bv(s,r,t),a=Bv(r,o,t),l=Bv(n,a,t);return i?new e(this.start,s,n,l):new e(l,a,o,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),wv=function(e){return 1===e.type},Pv=function(e){var t=e.styles,i=e.bounds,s=uf(t.borderTopLeftRadius,i.width,i.height),r=s[0],o=s[1],n=uf(t.borderTopRightRadius,i.width,i.height),a=n[0],l=n[1],A=uf(t.borderBottomRightRadius,i.width,i.height),h=A[0],c=A[1],u=uf(t.borderBottomLeftRadius,i.width,i.height),d=u[0],p=u[1],f=[];f.push((r+a)/i.width),f.push((d+h)/i.width),f.push((o+p)/i.height),f.push((l+c)/i.height);var g=Math.max.apply(Math,f);g>1&&(r/=g,o/=g,a/=g,l/=g,h/=g,c/=g,d/=g,p/=g);var m=i.width-a,_=i.height-c,v=i.width-h,b=i.height-p,y=t.borderTopWidth,B=t.borderRightWidth,x=t.borderBottomWidth,w=t.borderLeftWidth,P=df(t.paddingTop,e.bounds.width),C=df(t.paddingRight,e.bounds.width),M=df(t.paddingBottom,e.bounds.width),F=df(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||o>0?Cv(i.left+w/3,i.top+y/3,r-w/3,o-y/3,Z_.TOP_LEFT):new yv(i.left+w/3,i.top+y/3),this.topRightBorderDoubleOuterBox=r>0||o>0?Cv(i.left+m,i.top+y/3,a-B/3,l-y/3,Z_.TOP_RIGHT):new yv(i.left+i.width-B/3,i.top+y/3),this.bottomRightBorderDoubleOuterBox=h>0||c>0?Cv(i.left+v,i.top+_,h-B/3,c-x/3,Z_.BOTTOM_RIGHT):new yv(i.left+i.width-B/3,i.top+i.height-x/3),this.bottomLeftBorderDoubleOuterBox=d>0||p>0?Cv(i.left+w/3,i.top+b,d-w/3,p-x/3,Z_.BOTTOM_LEFT):new yv(i.left+w/3,i.top+i.height-x/3),this.topLeftBorderDoubleInnerBox=r>0||o>0?Cv(i.left+2*w/3,i.top+2*y/3,r-2*w/3,o-2*y/3,Z_.TOP_LEFT):new yv(i.left+2*w/3,i.top+2*y/3),this.topRightBorderDoubleInnerBox=r>0||o>0?Cv(i.left+m,i.top+2*y/3,a-2*B/3,l-2*y/3,Z_.TOP_RIGHT):new yv(i.left+i.width-2*B/3,i.top+2*y/3),this.bottomRightBorderDoubleInnerBox=h>0||c>0?Cv(i.left+v,i.top+_,h-2*B/3,c-2*x/3,Z_.BOTTOM_RIGHT):new yv(i.left+i.width-2*B/3,i.top+i.height-2*x/3),this.bottomLeftBorderDoubleInnerBox=d>0||p>0?Cv(i.left+2*w/3,i.top+b,d-2*w/3,p-2*x/3,Z_.BOTTOM_LEFT):new yv(i.left+2*w/3,i.top+i.height-2*x/3),this.topLeftBorderStroke=r>0||o>0?Cv(i.left+w/2,i.top+y/2,r-w/2,o-y/2,Z_.TOP_LEFT):new yv(i.left+w/2,i.top+y/2),this.topRightBorderStroke=r>0||o>0?Cv(i.left+m,i.top+y/2,a-B/2,l-y/2,Z_.TOP_RIGHT):new yv(i.left+i.width-B/2,i.top+y/2),this.bottomRightBorderStroke=h>0||c>0?Cv(i.left+v,i.top+_,h-B/2,c-x/2,Z_.BOTTOM_RIGHT):new yv(i.left+i.width-B/2,i.top+i.height-x/2),this.bottomLeftBorderStroke=d>0||p>0?Cv(i.left+w/2,i.top+b,d-w/2,p-x/2,Z_.BOTTOM_LEFT):new yv(i.left+w/2,i.top+i.height-x/2),this.topLeftBorderBox=r>0||o>0?Cv(i.left,i.top,r,o,Z_.TOP_LEFT):new yv(i.left,i.top),this.topRightBorderBox=a>0||l>0?Cv(i.left+m,i.top,a,l,Z_.TOP_RIGHT):new yv(i.left+i.width,i.top),this.bottomRightBorderBox=h>0||c>0?Cv(i.left+v,i.top+_,h,c,Z_.BOTTOM_RIGHT):new yv(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=d>0||p>0?Cv(i.left,i.top+b,d,p,Z_.BOTTOM_LEFT):new yv(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||o>0?Cv(i.left+w,i.top+y,Math.max(0,r-w),Math.max(0,o-y),Z_.TOP_LEFT):new yv(i.left+w,i.top+y),this.topRightPaddingBox=a>0||l>0?Cv(i.left+Math.min(m,i.width-B),i.top+y,m>i.width+B?0:Math.max(0,a-B),Math.max(0,l-y),Z_.TOP_RIGHT):new yv(i.left+i.width-B,i.top+y),this.bottomRightPaddingBox=h>0||c>0?Cv(i.left+Math.min(v,i.width-w),i.top+Math.min(_,i.height-x),Math.max(0,h-B),Math.max(0,c-x),Z_.BOTTOM_RIGHT):new yv(i.left+i.width-B,i.top+i.height-x),this.bottomLeftPaddingBox=d>0||p>0?Cv(i.left+w,i.top+Math.min(b,i.height-x),Math.max(0,d-w),Math.max(0,p-x),Z_.BOTTOM_LEFT):new yv(i.left+w,i.top+i.height-x),this.topLeftContentBox=r>0||o>0?Cv(i.left+w+F,i.top+y+P,Math.max(0,r-(w+F)),Math.max(0,o-(y+P)),Z_.TOP_LEFT):new yv(i.left+w+F,i.top+y+P),this.topRightContentBox=a>0||l>0?Cv(i.left+Math.min(m,i.width+w+F),i.top+y+P,m>i.width+w+F?0:a-w+F,l-(y+P),Z_.TOP_RIGHT):new yv(i.left+i.width-(B+C),i.top+y+P),this.bottomRightContentBox=h>0||c>0?Cv(i.left+Math.min(v,i.width-(w+F)),i.top+Math.min(_,i.height+y+P),Math.max(0,h-(B+C)),c-(x+M),Z_.BOTTOM_RIGHT):new yv(i.left+i.width-(B+C),i.top+i.height-(x+M)),this.bottomLeftContentBox=d>0||p>0?Cv(i.left+w+F,i.top+b,Math.max(0,d-(w+F)),p-(x+M),Z_.BOTTOM_LEFT):new yv(i.left+w+F,i.top+i.height-(x+M))};!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(Z_||(Z_={}));var Cv=function(e,t,i,s,r){var o=(Math.sqrt(2)-1)/3*4,n=i*o,a=s*o,l=e+i,A=t+s;switch(r){case Z_.TOP_LEFT:return new xv(new yv(e,A),new yv(e,A-a),new yv(l-n,t),new yv(l,t));case Z_.TOP_RIGHT:return new xv(new yv(e,t),new yv(e+n,t),new yv(l,A-a),new yv(l,A));case Z_.BOTTOM_RIGHT:return new xv(new yv(l,t),new yv(l,t+a),new yv(e+n,A),new yv(e,A));case Z_.BOTTOM_LEFT:default:return new xv(new yv(l,A),new yv(l-n,A),new yv(e,t+a),new yv(e,t))}},Mv=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Fv=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},Ev=function(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6},Iv=function(e,t){this.path=e,this.target=t,this.type=1},Dv=function(e){this.opacity=e,this.type=2,this.target=6},Sv=function(e){return 1===e.type},Tv=function(e,t){return e.length===t.length&&e.some((function(e,i){return e===t[i]}))},Rv=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},Lv=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Pv(this.container),this.container.styles.opacity<1&&this.effects.push(new Dv(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,s=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new Ev(i,s,r))}if(0!==this.container.styles.overflowX){var o=Mv(this.curves),n=Fv(this.curves);Tv(o,n)?this.effects.push(new Iv(o,6)):(this.effects.push(new Iv(o,2)),this.effects.push(new Iv(n,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,s=this.effects.slice(0);i;){var r=i.effects.filter((function(e){return!Sv(e)}));if(t||0!==i.container.styles.position||!i.parent){if(s.unshift.apply(s,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var o=Mv(i.curves),n=Fv(i.curves);Tv(o,n)||s.unshift(new Iv(n,6))}}else s.unshift.apply(s,r);i=i.parent}return s.filter((function(t){return am(t.target,e)}))},e}(),Uv=function(e,t,i,s){e.container.elements.forEach((function(r){var o=am(r.flags,4),n=am(r.flags,2),a=new Lv(r,e);am(r.styles.display,2048)&&s.push(a);var l=am(r.flags,8)?[]:s;if(o||n){var A=o||r.styles.isPositioned()?i:t,h=new Rv(a);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var c=r.styles.zIndex.order;if(c<0){var u=0;A.negativeZIndex.some((function(e,t){return c>e.element.container.styles.zIndex.order?(u=t,!1):u>0})),A.negativeZIndex.splice(u,0,h)}else if(c>0){var d=0;A.positiveZIndex.some((function(e,t){return c>=e.element.container.styles.zIndex.order?(d=t+1,!1):d>0})),A.positiveZIndex.splice(d,0,h)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(h)}else r.styles.isFloating()?A.nonPositionedFloats.push(h):A.nonPositionedInlineLevel.push(h);Uv(a,h,o?h:i,l)}else r.styles.isInlineLevel()?t.inlineLevel.push(a):t.nonInlineLevel.push(a),Uv(a,t,i,l);am(r.flags,8)&&kv(r,l)}))},kv=function(e,t){for(var i=e instanceof a_?e.start:1,s=e instanceof a_&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var s=Hv(e),r=Fv(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return fd(this,void 0,void 0,(function(){var i,s,r,o,n,a,l,A,h,c,u,d,p,f,g,m,_,v;return gd(this,(function(b){switch(b.label){case 0:this.applyEffects(e.getEffects(4)),i=e.container,s=e.curves,r=i.styles,o=0,n=i.textNodes,b.label=1;case 1:return o0&&x>0&&(m=s.ctx.createPattern(p,"repeat"),s.renderRepeat(v,m,P,C))):function(e){return 2===e.type}(i)&&(_=jv(e,t,[null,null,null]),v=_[0],b=_[1],y=_[2],B=_[3],x=_[4],w=0===i.position.length?[hf]:i.position,P=df(w[0],B),C=df(w[w.length-1],x),M=function(e,t,i,s,r){var o=0,n=0;switch(e.size){case 0:0===e.shape?o=n=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.min(Math.abs(t),Math.abs(t-s)),n=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)o=n=Math.min(Rf(t,i),Rf(t,i-r),Rf(t-s,i),Rf(t-s,i-r));else if(1===e.shape){var a=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-s)),l=Lf(s,r,t,i,!0),A=l[0],h=l[1];n=a*(o=Rf(A-t,(h-i)/a))}break;case 1:0===e.shape?o=n=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.max(Math.abs(t),Math.abs(t-s)),n=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)o=n=Math.max(Rf(t,i),Rf(t,i-r),Rf(t-s,i),Rf(t-s,i-r));else if(1===e.shape){a=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-s));var c=Lf(s,r,t,i,!1);A=c[0],h=c[1],n=a*(o=Rf(A-t,(h-i)/a))}}return Array.isArray(e.size)&&(o=df(e.size[0],s),n=2===e.size.length?df(e.size[1],r):o),[o,n]}(i,P,C,B,x),F=M[0],E=M[1],F>0&&E>0&&(I=s.ctx.createRadialGradient(b+P,y+C,0,b+P,y+C,F),Sf(i.stops,2*F).forEach((function(e){return I.addColorStop(e.stop,bf(e.color))})),s.path(v),s.ctx.fillStyle=I,F!==E?(D=e.bounds.left+.5*e.bounds.width,S=e.bounds.top+.5*e.bounds.height,R=1/(T=E/F),s.ctx.save(),s.ctx.translate(D,S),s.ctx.transform(1,0,0,T,0,0),s.ctx.translate(-D,-S),s.ctx.fillRect(b,R*(y-S)+S,B,x*R),s.ctx.restore()):s.ctx.fill())),L.label=6;case 6:return t--,[2]}}))},s=this,r=0,o=e.styles.backgroundImage.slice(0).reverse(),a.label=1;case 1:return r0?2!==l.style?[3,5]:[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,2)]:[3,11]:[3,13];case 4:return h.sent(),[3,11];case 5:return 3!==l.style?[3,7]:[4,this.renderDashedDottedBorder(l.color,l.width,o,e.curves,3)];case 6:return h.sent(),[3,11];case 7:return 4!==l.style?[3,9]:[4,this.renderDoubleBorder(l.color,l.width,o,e.curves)];case 8:return h.sent(),[3,11];case 9:return[4,this.renderSolidBorder(l.color,o,e.curves)];case 10:h.sent(),h.label=11;case 11:o++,h.label=12;case 12:return n++,[3,3];case 13:return[2]}}))}))},t.prototype.renderDashedDottedBorder=function(e,t,i,s,r){return fd(this,void 0,void 0,(function(){var o,n,a,l,A,h,c,u,d,p,f,g,m,_,v,b;return gd(this,(function(y){return this.ctx.save(),o=function(e,t){switch(t){case 0:return Nv(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Nv(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Nv(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return Nv(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(s,i),n=Ov(s,i),2===r&&(this.path(n),this.ctx.clip()),wv(n[0])?(a=n[0].start.x,l=n[0].start.y):(a=n[0].x,l=n[0].y),wv(n[1])?(A=n[1].end.x,h=n[1].end.y):(A=n[1].x,h=n[1].y),c=0===i||2===i?Math.abs(a-A):Math.abs(l-h),this.ctx.beginPath(),3===r?this.formatPath(o):this.formatPath(n.slice(0,2)),u=t<3?3*t:2*t,d=t<3?2*t:t,3===r&&(u=t,d=t),p=!0,c<=2*u?p=!1:c<=2*u+d?(u*=f=c/(2*u+d),d*=f):(g=Math.floor((c+d)/(u+d)),m=(c-g*u)/(g-1),d=(_=(c-(g+1)*u)/g)<=0||Math.abs(d-m){})),yb(this,"_reject",(()=>{})),this.name=e,this.workerThread=t,this.result=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){pb(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){pb(this.isRunning),this.isRunning=!1,this._reject(e)}}class xb{}const wb=new Map;function Pb(e){pb(e.source&&!e.url||!e.source&&e.url);let t=wb.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return Cb((t=e,"try {\n importScripts('".concat(t,"');\n} catch (error) {\n console.error(error);\n throw error;\n}")));var t}(e.url),wb.set(e.url,t)),e.source&&(t=Cb(e.source),wb.set(e.source,t))),pb(t),t}function Cb(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function Mb(e,t=!0,i){const s=i||new Set;if(e){if(Fb(e))s.add(e);else if(Fb(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)Mb(e[i],t,s)}else;return void 0===i?Array.from(s):[]}function Fb(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const Eb=()=>{};class Ib{static isSupported(){return"undefined"!=typeof Worker&&mb||void 0!==typeof xb}constructor(e){yb(this,"name",void 0),yb(this,"source",void 0),yb(this,"url",void 0),yb(this,"terminated",!1),yb(this,"worker",void 0),yb(this,"onMessage",void 0),yb(this,"onError",void 0),yb(this,"_loadableURL","");const{name:t,source:i,url:s}=e;pb(i||s),this.name=t,this.source=i,this.url=s,this.onMessage=Eb,this.onError=e=>console.log(e),this.worker=mb?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Eb,this.onError=Eb,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||Mb(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+="worker ".concat(this.name," from ").concat(this.url,". "),e.message&&(t+="".concat(e.message," in ")),e.lineno&&(t+=":".concat(e.lineno,":").concat(e.colno)),new Error(t)}_createBrowserWorker(){this._loadableURL=Pb({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);e=new xb(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new xb(this.source,{eval:!0})}return e.on("message",(e=>{this.onMessage(e)})),e.on("error",(e=>{this.onError(e)})),e.on("exit",(e=>{})),e}}class Db{static isSupported(){return Ib.isSupported()}constructor(e){yb(this,"name","unnamed"),yb(this,"source",void 0),yb(this,"url",void 0),yb(this,"maxConcurrency",1),yb(this,"maxMobileConcurrency",1),yb(this,"onDebug",(()=>{})),yb(this,"reuseWorkers",!0),yb(this,"props",{}),yb(this,"jobQueue",[]),yb(this,"idleQueue",[]),yb(this,"count",0),yb(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach((e=>e.destroy())),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=((e,t,i)=>e.done(i)),i=((e,t)=>e.error(t))){const s=new Promise((s=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:s}),this)));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new Bb(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class Tb{static isSupported(){return Ib.isSupported()}static getWorkerFarm(e={}){return Tb._workerFarm=Tb._workerFarm||new Tb({}),Tb._workerFarm.setProps(e),Tb._workerFarm}constructor(e){yb(this,"props",void 0),yb(this,"workerPools",new Map),this.props={...Sb},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:s}=e;let r=this.workerPools.get(t);return r||(r=new Db({name:t,source:i,url:s}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}yb(Tb,"_workerFarm",void 0);var Rb=Object.freeze({__proto__:null,default:{}});const Lb={};async function Ub(e,t=null,i={}){return t&&(e=function(e,t,i){if(e.startsWith("http"))return e;const s=i.modules||{};if(s[e])return s[e];if(!mb)return"modules/".concat(t,"/dist/libs/").concat(e);if(i.CDN)return pb(i.CDN.startsWith("http")),"".concat(i.CDN,"/").concat(t,"@").concat("3.2.6","/dist/libs/").concat(e);if(_b)return"../src/libs/".concat(e);return"modules/".concat(t,"/src/libs/").concat(e)}(e,t,i)),Lb[e]=Lb[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!mb)try{return Rb&&void 0}catch{return null}if(_b)return importScripts(e);const t=await fetch(e);return function(e,t){if(!mb)return;if(_b)return eval.call(gb,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(await t.text(),e)}(e),await Lb[e]}async function kb(e,t,i,s,r){const o=e.id,n=function(e,t={}){const i=t[e.id]||{},s="".concat(e.id,"-worker.js");let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r="modules/".concat(e.module,"/dist/").concat(s)),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?"@".concat(t):"";r="https://unpkg.com/@loaders.gl/".concat(e.module).concat(i,"/dist/").concat(s)}return pb(r),r}(e,i),a=Tb.getWorkerFarm(i).getWorkerPool({name:o,url:n});i=JSON.parse(JSON.stringify(i)),s=JSON.parse(JSON.stringify(s||{}));const l=await a.startJob("process-on-worker",Ob.bind(null,r));l.postMessage("process",{input:t,options:i,context:s});const A=await l.result;return await A.result}async function Ob(e,t,i,s){switch(i){case"done":t.done(s);break;case"error":t.error(new Error(s.error));break;case"process":const{id:r,input:o,options:n}=s;try{const i=await e(o,n);t.postMessage("done",{id:r,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:i})}break;default:console.warn("parse-with-worker unknown message ".concat(i))}}function Nb(e,t,i){if(e.byteLength<=t+i)return"";const s=new DataView(e);let r="";for(let e=0;e=0),cb(t>0),e+(t-1)&~(t-1)}function zb(e,t,i){let s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;s=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(s,i),i+Gb(s.byteLength,4)}async function Wb(e){const t=[];for await(const i of e)t.push(i);return function(...e){const t=e.map((e=>e instanceof ArrayBuffer?new Uint8Array(e):e)),i=t.reduce(((e,t)=>e+t.byteLength),0),s=new Uint8Array(i);let r=0;for(const e of t)s.set(e,r),r+=e.byteLength;return s.buffer}(...t)}const Kb={};const Xb=e=>"function"==typeof e,Jb=e=>null!==e&&"object"==typeof e,Yb=e=>Jb(e)&&e.constructor==={}.constructor,Zb=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,qb=e=>"undefined"!=typeof Blob&&e instanceof Blob,$b=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||Jb(e)&&Xb(e.tee)&&Xb(e.cancel)&&Xb(e.getReader))(e)||(e=>Jb(e)&&Xb(e.read)&&Xb(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e),ey=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ty=/^([-\w.]+\/[-\w.+]+)/;function iy(e){const t=ty.exec(e);return t?t[1]:e}function sy(e){const t=ey.exec(e);return t?t[1]:""}const ry=/\?.*/;function oy(e){if(Zb(e)){const t=ny(e.url||"");return{url:t,type:iy(e.headers.get("content-type")||"")||sy(t)}}return qb(e)?{url:ny(e.name||""),type:e.type||""}:"string"==typeof e?{url:ny(e),type:sy(e)}:{url:"",type:""}}function ny(e){return e.replace(ry,"")}async function ay(e){if(Zb(e))return e;const t={},i=function(e){return Zb(e)?e.headers["content-length"]||-1:qb(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const{url:s,type:r}=oy(e);r&&(t["content-type"]=r);const o=await async function(e){const t=5;if("string"==typeof e)return"data:,".concat(e.slice(0,t));if(e instanceof Blob){const t=e.slice(0,5);return await new Promise((e=>{const i=new FileReader;i.onload=t=>{var i;return e(null==t||null===(i=t.target)||void 0===i?void 0:i.result)},i.readAsDataURL(t)}))}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e=0)}();class py{constructor(e,t,i="sessionStorage"){this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function fy(e,t,i,s=600){const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));const o=e.width*i,n=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(n/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(n,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(n,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}const gy={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function my(e){return"string"==typeof e?gy[e.toUpperCase()]||gy.WHITE:e}function _y(e,t){if(!e)throw new Error(t||"Assertion failed")}function vy(){let e;if(dy&&hy.performance)e=hy.performance.now();else if(cy.hrtime){const t=cy.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const by={debug:dy&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},yy={enabled:!0,level:0};function By(){}const xy={},wy={once:!0};function Py(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}class Cy{constructor({id:e}={id:""}){this.id=e,this.VERSION=uy,this._startTs=vy(),this._deltaTs=vy(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new py("__probe-".concat(this.id,"__"),yy),this.userData={},this.timeStamp("".concat(this.id," started")),function(e,t=["constructor"]){const i=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(i);for(const i of s)"function"==typeof e[i]&&(t.find((e=>i===e))||(e[i]=e[i].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((vy()-this._startTs).toPrecision(10))}getDelta(){return Number((vy()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}assert(e,t){_y(e,t)}warn(e){return this._getLogFunction(0,e,by.warn,arguments,wy)}error(e){return this._getLogFunction(0,e,by.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,by.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,by.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,by.debug||by.info,arguments,wy)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||By,i&&[i],{tag:Py(t)}):By}image({logLevel:e,priority:t,image:i,message:s="",scale:r=1}){return this._shouldLog(e||t)?dy?function({image:e,message:t="",scale:i=1}){if("string"==typeof e){const s=new Image;return s.onload=()=>{const e=fy(s,t,i);console.log(...e)},s.src=e,By}const s=e.nodeName||"";if("img"===s.toLowerCase())return console.log(...fy(e,t,i)),By;if("canvas"===s.toLowerCase()){const s=new Image;return s.onload=()=>console.log(...fy(s,t,i)),s.src=e.toDataURL(),By}return By}({image:i,message:s,scale:r}):function({image:e,message:t="",scale:i=1}){let s=null;try{s=module.require("asciify-image")}catch(e){}if(s)return()=>s(e,{fit:"box",width:"".concat(Math.round(80*i),"%")}).then((e=>console.log(e)));return By}({image:i,message:s,scale:r}):By}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||By)}group(e,t,i={collapsed:!1}){i=Fy({logLevel:e,message:t,opts:i});const{collapsed:s}=i;return i.method=(s?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||By)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=My(e)}_getLogFunction(e,t,i,s=[],r){if(this._shouldLog(e)){r=Fy({logLevel:e,message:t,args:s,opts:r}),_y(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=vy();const o=r.tag||r.message;if(r.once){if(xy[o])return By;xy[o]=vy()}return t=function(e,t,i){if("string"==typeof t){const s=i.time?function(e,t=8){const i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),t=function(e,t,i){return dy||"string"!=typeof e||(t&&(t=my(t),e="[".concat(t,"m").concat(e,"")),i&&(t=my(i),e="[".concat(i+10,"m").concat(e,""))),e}(t,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return By}}function My(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return _y(Number.isFinite(t)&&t>=0),t}function Fy(e){const{logLevel:t,message:i}=e;e.logLevel=My(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==i;);switch(e.args=s,typeof t){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return _y("string"===r||"object"===r),Object.assign(e,e.opts)}Cy.VERSION=uy;const Ey=new Cy({id:"loaders.gl"});class Iy{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const Dy={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){yb(this,"console",void 0),this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:ub,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Sy={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function Ty(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state=e._state||{},e._state}const Ry=()=>{const e=Ty();return e.globalOptions=e.globalOptions||{...Dy},e.globalOptions};function Ly(e,t,i,s){return i=i||[],function(e,t){ky(e,null,Dy,Sy,t);for(const i of t){const s=e&&e[i.id]||{},r=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};ky(s,i.id,r,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const s={...e.options||{}};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(s,i),null===s.log&&(s.log=new Iy);return Ny(s,Ry()),Ny(s,t),s}(t,e,s)}function Uy(e,t){const i=Ry(),s=e||i;return"function"==typeof s.fetch?s.fetch:Jb(s.fetch)?e=>ly(e,s):null!=t&&t.fetch?null==t?void 0:t.fetch:ly}function ky(e,t,i,s,r){const o=t||"Top level",n=t?"".concat(t,"."):"";for(const a in e){const l=!t&&Jb(e[a]),A="baseUri"===a&&!t,h="workerUrl"===a&&t;if(!(a in i)&&!A&&!h)if(a in s)Ey.warn("".concat(o," loader option '").concat(n).concat(a,"' no longer supported, use '").concat(s[a],"'"))();else if(!l){const e=Oy(a,r);Ey.warn("".concat(o," loader option '").concat(n).concat(a,"' not recognized. ").concat(e))()}}}function Oy(e,t){const i=e.toLowerCase();let s="";for(const r of t)for(const t in r.options){if(e===t)return"Did you mean '".concat(r.id,".").concat(t,"'?");const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(s=s||"Did you mean '".concat(r.id,".").concat(t,"'?"))}return s}function Ny(e,t){for(const i in t)if(i in t){const s=t[i];Yb(s)&&Yb(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function Qy(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function Vy(e){var t,i;let s;return cb(e,"null loader"),cb(Qy(e),"invalid loader"),Array.isArray(e)&&(s=e[1],e=e[0],e={...e,options:{...e.options,...s}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(i=e)&&void 0!==i&&i.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}function Hy(){return(()=>{const e=Ty();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry})()}function jy(){return!("object"==typeof process&&"[object process]"===String(process)&&!process.browser)||function(e){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof process&&"object"==typeof process.versions&&Boolean(process.versions.electron))return!0;const t="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,i=e||t;return!!(i&&i.indexOf("Electron")>=0)}()}const Gy={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"==typeof process&&process},zy=Gy.window||Gy.self||Gy.global,Wy=Gy.process||{},Ky="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";jy();class Xy{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";yb(this,"storage",void 0),yb(this,"id",void 0),yb(this,"config",{}),this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function Jy(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));const o=e.width*i,n=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(n/2),"px ").concat(Math.floor(o/2),"px;"),"line-height:".concat(n,"px;"),"background:url(".concat(r,");"),"background-size:".concat(o,"px ").concat(n,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}let Yy;function Zy(e){return"string"==typeof e?Yy[e.toUpperCase()]||Yy.WHITE:e}function qy(e,t){if(!e)throw new Error(t||"Assertion failed")}function $y(){let e;var t,i;if(jy&&"performance"in zy)e=null==zy||null===(t=zy.performance)||void 0===t||null===(i=t.now)||void 0===i?void 0:i.call(t);else if("hrtime"in Wy){var s;const t=null==Wy||null===(s=Wy.hrtime)||void 0===s?void 0:s.call(Wy);e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(Yy||(Yy={}));const eB={debug:jy&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},tB={enabled:!0,level:0};function iB(){}const sB={},rB={once:!0};class oB{constructor(){let{id:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};yb(this,"id",void 0),yb(this,"VERSION",Ky),yb(this,"_startTs",$y()),yb(this,"_deltaTs",$y()),yb(this,"_storage",void 0),yb(this,"userData",{}),yb(this,"LOG_THROTTLE_TIMEOUT",0),this.id=e,this._storage=new Xy("__probe-".concat(this.id,"__"),tB),this.userData={},this.timeStamp("".concat(this.id," started")),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const i=Object.getPrototypeOf(e),s=Object.getOwnPropertyNames(i);for(const i of s)"function"==typeof e[i]&&(t.find((e=>i===e))||(e[i]=e[i].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number(($y()-this._startTs).toPrecision(10))}getDelta(){return Number(($y()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){qy(e,t)}warn(e){return this._getLogFunction(0,e,eB.warn,arguments,rB)}error(e){return this._getLogFunction(0,e,eB.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,eB.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,eB.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){for(var i=arguments.length,s=new Array(i>2?i-2:0),r=2;r{const t=Jy(e,i,s);console.log(...t)},e.src=t,iB}const r=t.nodeName||"";if("img"===r.toLowerCase())return console.log(...Jy(t,i,s)),iB;if("canvas"===r.toLowerCase()){const e=new Image;return e.onload=()=>console.log(...Jy(e,i,s)),e.src=t.toDataURL(),iB}return iB}({image:s,message:r,scale:o}):function(e){let{image:t,message:i="",scale:s=1}=e,r=null;try{r=module.require("asciify-image")}catch(e){}if(r)return()=>r(t,{fit:"box",width:"".concat(Math.round(80*s),"%")}).then((e=>console.log(e)));return iB}({image:s,message:r,scale:o}):iB}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||iB)}group(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const s=aB({logLevel:e,message:t,opts:i}),{collapsed:r}=i;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||iB)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=nB(e)}_getLogFunction(e,t,i,s,r){if(this._shouldLog(e)){r=aB({logLevel:e,message:t,args:s,opts:r}),qy(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=$y();const o=r.tag||r.message;if(r.once){if(sB[o])return iB;sB[o]=$y()}return t=function(e,t,i){if("string"==typeof t){const s=i.time?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(i.total)):"";t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),t=function(e,t,i){return jy||"string"!=typeof e||(t&&(t=Zy(t),e="[".concat(t,"m").concat(e,"")),i&&(t=Zy(i),e="[".concat(i+10,"m").concat(e,""))),e}(t,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return iB}}function nB(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return qy(Number.isFinite(t)&&t>=0),t}function aB(e){const{logLevel:t,message:i}=e;e.logLevel=nB(t);const s=e.args?Array.from(e.args):[];for(;s.length&&s.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return qy("string"===r||"object"===r),Object.assign(e,{args:s},e.opts)}function lB(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}yb(oB,"VERSION",Ky);const AB=new oB({id:"loaders.gl"}),hB=/\.([^.]+)$/;function cB(e,t=[],i,s){if(!uB(e))return null;if(t&&!Array.isArray(t))return Vy(t);let r=[];t&&(r=r.concat(t)),null!=i&&i.ignoreRegisteredLoaders||r.push(...Hy()),function(e){for(const t of e)Vy(t)}(r);const o=function(e,t,i,s){const{url:r,type:o}=oy(e),n=r||(null==s?void 0:s.url);let a=null,l="";null!=i&&i.mimeType&&(a=pB(t,null==i?void 0:i.mimeType),l="match forced by supplied MIME type ".concat(null==i?void 0:i.mimeType));var A;a=a||function(e,t){const i=t&&hB.exec(t),s=i&&i[1];return s?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,s):null}(t,n),l=l||(a?"matched url ".concat(n):""),a=a||pB(t,o),l=l||(a?"matched MIME type ".concat(o):""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(fB(t,i))return i}else if(ArrayBuffer.isView(t)){if(gB(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(gB(t,0,i))return i}return null}(t,e),l=l||(a?"matched initial data ".concat(mB(e)):""),a=a||pB(t,null==i?void 0:i.fallbackMimeType),l=l||(a?"matched fallback MIME type ".concat(o):""),l&&AB.log(1,"selectLoader selected ".concat(null===(A=a)||void 0===A?void 0:A.name,": ").concat(l,"."));return a}(e,r,i,s);if(!(o||null!=i&&i.nothrow))throw new Error(dB(e));return o}function uB(e){return!(e instanceof Response&&204===e.status)}function dB(e){const{url:t,type:i}=oy(e);let s="No valid loader found (";s+=t?"".concat(function(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(t+1):""}(t),", "):"no url provided, ",s+="MIME type: ".concat(i?'"'.concat(i,'"'):"not provided",", ");const r=e?mB(e):"";return s+=r?' first bytes: "'.concat(r,'"'):"first bytes: not available",s+=")",s}function pB(e,t){for(const i of e){if(i.mimeTypes&&i.mimeTypes.includes(t))return i;if(t==="application/x.".concat(i.id))return i}return null}function fB(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some((t=>e.startsWith(t)))}function gB(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some((s=>function(e,t,i,s){if(s instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLength60?"".concat(t.slice(0,60),"..."):t}catch(e){}return t}(e);throw new Error(t)}}(i),t.binary?await i.arrayBuffer():await i.text()}if($b(e)&&(e=yB(e,i)),(r=e)&&"function"==typeof r[Symbol.iterator]||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return Wb(e);var r;throw new Error(BB)}async function wB(e,t,i,s){pb(!s||"object"==typeof s),!t||Array.isArray(t)||Qy(t)||(s=void 0,i=t,t=void 0),e=await e,i=i||{};const{url:r}=oy(e),o=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:null}(t,s),n=await async function(e,t=[],i,s){if(!uB(e))return null;let r=cB(e,t,{...i,nothrow:!0},s);if(r)return r;if(qb(e)&&(r=cB(e=await e.slice(0,10).arrayBuffer(),t,i,s)),!(r||null!=i&&i.nothrow))throw new Error(dB(e));return r}(e,o,i);return n?(s=function(e,t,i=null){if(i)return i;const s={fetch:Uy(t,e),...e};return Array.isArray(s.loaders)||(s.loaders=null),s}({url:r,parse:wB,loaders:o},i=Ly(i,n,o,r),s),await async function(e,t,i,s){if(function(e,t="3.2.6"){pb(e,"no worker provided");const i=e.version}(e),Zb(t)){const e=t,{ok:i,redirected:r,status:o,statusText:n,type:a,url:l}=e,A=Object.fromEntries(e.headers.entries());s.response={headers:A,ok:i,redirected:r,status:o,statusText:n,type:a,url:l}}if(t=await xB(t,e,i),e.parseTextSync&&"string"==typeof t)return i.dataType="text",e.parseTextSync(t,i,s,e);if(function(e,t){return!!Tb.isSupported()&&!!(mb||null!=t&&t._nodeWorkers)&&e.worker&&(null==t?void 0:t.worker)}(e,i))return await kb(e,t,i,s,wB);if(e.parseText&&"string"==typeof t)return await e.parseText(t,i,s,e);if(e.parse)return await e.parse(t,i,s,e);throw pb(!e.parseSync),new Error("".concat(e.id," loader - no parser found and worker is disabled"))}(n,e,i,s)):null}const PB="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.wasm"),CB="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.js");let MB,FB;async function EB(e){const t=e.modules||{};return t.basis?t.basis:(MB=MB||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await Ub("basis_transcoder.js","textures",e),await Ub("basis_transcoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e(i).then((e=>{const{BasisFile:i,initializeBasis:s}=e;s(),t({BasisFile:i})}))}))}(t,i)}(e),await MB)}async function IB(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(FB=FB||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await Ub(CB,"textures",e),await Ub(PB,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e(i).then((e=>{const{BasisFile:i,KTX2File:s,initializeBasis:r,BasisEncoder:o}=e;r(),t({BasisFile:i,KTX2File:s,BasisEncoder:o})}))}))}(t,i)}(e),await FB)}const DB=33776,SB=33779,TB=35840,RB=35842,LB=36196,UB=37808,kB=["","WEBKIT_","MOZ_"],OB={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let NB=null;function QB(e){if(!NB){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,NB=new Set;for(const t of kB)for(const i in OB)if(e&&e.getExtension("".concat(t).concat(i))){const e=OB[i];NB.add(e)}}return NB}var VB,HB,jB,GB,zB,WB,KB,XB,JB;(JB=VB||(VB={}))[JB.NONE=0]="NONE",JB[JB.BASISLZ=1]="BASISLZ",JB[JB.ZSTD=2]="ZSTD",JB[JB.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(HB||(HB={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(jB||(jB={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(GB||(GB={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(zB||(zB={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(WB||(WB={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(KB||(KB={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(XB||(XB={}));const YB=[171,75,84,88,32,50,48,187,13,10,26,10];const ZB={etc1:{basisFormat:0,compressed:!0,format:LB},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:DB},bc3:{basisFormat:3,compressed:!0,format:SB},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:TB},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:RB},"astc-4x4":{basisFormat:10,compressed:!0,format:UB},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function qB(e,t,i){const s=new e(new Uint8Array(t));try{if(!s.startTranscoding())throw new Error("Failed to start basis transcoding");const e=s.getNumImages(),t=[];for(let r=0;r{try{i.onload=()=>t(i),i.onerror=t=>s(new Error("Could not load image ".concat(e,": ").concat(t)))}catch(e){s(e)}}))}(o||s,t)}finally{o&&r.revokeObjectURL(o)}}const gx={};let mx=!0;async function _x(e,t,i){let s;if(dx(i)){s=await fx(e,t,i)}else s=px(e,i);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||gx)return!1;return!0}(t)&&mx||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),mx=!1}return await createImageBitmap(e)}(s,r)}function vx(e){const t=bx(e);return function(e){const t=bx(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,false)))return null;return{mimeType:"image/png",width:t.getUint32(16,false),height:t.getUint32(20,false)}}(t)||function(e){const t=bx(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,false)&&255===t.getUint8(2)))return null;const{tableMarkers:i,sofMarkers:s}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r+9=10&&1195984440===t.getUint32(0,false)))return null;return{mimeType:"image/gif",width:t.getUint16(6,true),height:t.getUint16(8,true)}}(t)||function(e){const t=bx(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,false)&&t.getUint32(2,true)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,true),height:t.getUint32(22,true)}}(t)}function bx(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const yx={id:"image",module:"images",name:"Images",version:"3.2.6",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,i){const s=((t=t||{}).image||{}).type||"auto",{url:r}=i||{};let o;switch(function(e){switch(e){case"auto":case"data":return function(){if(ax)return"imagebitmap";if(nx)return"image";if(Ax)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return ax||nx||Ax;case"imagebitmap":return ax;case"image":return nx;case"data":return Ax;default:throw new Error("@loaders.gl/images: image ".concat(e," not supported in this environment"))}}(e),e}}(s)){case"imagebitmap":o=await _x(e,t,r);break;case"image":o=await fx(e,t,r);break;case"data":o=await async function(e,t){const{mimeType:i}=vx(e)||{},s=globalThis._parseImageNode;return cb(s),await s(e,i)}(e);break;default:cb(!1)}return"data"===s&&(o=function(e){switch(hx(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}(o)),o},tests:[e=>Boolean(vx(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Bx=["image/png","image/jpeg","image/gif"],xx={};function wx(e){return void 0===xx[e]&&(xx[e]=function(e){switch(e){case"image/webp":return function(){if(!ub)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch{return!1}}();case"image/svg":return ub;default:if(!ub){const{_parseImageNode:t}=globalThis;return Boolean(t)&&Bx.includes(e)}return!0}}(e)),xx[e]}function Px(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function Cx(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error("'baseUri' must be provided to resolve relative url ".concat(e));return i.substr(0,i.lastIndexOf("/")+1)+e}const Mx=["SCALAR","VEC2","VEC3","VEC4"],Fx=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Ex=new Map(Fx),Ix={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Dx={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Sx={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Tx(e){return Mx[e-1]||Mx[0]}function Rx(e){const t=Ex.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Lx(e,t){const i=Sx[e.componentType],s=Ix[e.type],r=Dx[e.componentType],o=e.count*s,n=e.count*s*r;return Px(n>=0&&n<=t.byteLength),{ArrayType:i,length:o,byteLength:n}}const Ux={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class kx{constructor(e){yb(this,"gltf",void 0),yb(this,"sourceBuffers",void 0),yb(this,"byteLength",void 0),this.gltf=e||{json:{...Ux},buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find((t=>t===e)),i=this.json.extensions||{};return t?i[e]||!0:null}getRequiredExtension(e){const t=this.getRequiredExtensions().find((t=>t===e));return t?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error("glTF file error: Could not find ".concat(e,"[").concat(t,"]"));return i}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];Px(i);const s=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,{ArrayType:s,length:r}=Lx(e,t);return new s(i,t.byteOffset+e.byteOffset,r)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(i,s,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,i){return e.extensions=e.extensions||{},e.extensions[t]=i,this.registerUsedExtension(t),this}setObjectExtension(e,t,i){(e.extensions||{})[t]=i}removeObjectExtension(e,t){const i=e.extensions||{},s=i[t];return delete i[t],s}addExtension(e,t={}){return Px(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return Px(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((t=>t===e))||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((t=>t===e))||this.json.extensionsRequired.push(e)}removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const s={mesh:t};return i&&(s.matrix=i),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:s,mode:r=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(i){const e=this._addIndices(i);o.primitives[0].indices=e}return Number.isFinite(s)&&(o.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=vx(e),s=t||(null==i?void 0:i.mimeType),r={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e){const t=e.byteLength;Px(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const i={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=Gb(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:Tx(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const i=this.addBufferView(e);let s={min:t.min,max:t.max};s.min&&s.max||(s=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:Rx(e),count:Math.round(e.length/t.size),min:s.min,max:s.max};return this.addAccessor(i,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const i=this.byteLength,s=new ArrayBuffer(i),r=new Uint8Array(s);let o=0;for(const e of this.sourceBuffers||[])o=zb(e,r,o);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=i:this.json.buffers=[{byteLength:i}],this.gltf.binary=s,this.sourceBuffers=[s]}_removeStringFromArray(e,t){let i=!0;for(;i;){const s=e.indexOf(t);s>-1?e.splice(s,1):i=!1}}_addAttributes(e={}){const t={};for(const i in e){const s=e[i],r=this._getGltfAttributeName(i),o=this.addBinaryBuffer(s.value,s);t[r]=o}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const i={min:null,max:null};if(e.length96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let i=0;for(let s=0;st[e.name]));return new Zx(i,this.metadata)}selectAt(...e){const t=e.map((e=>this.fields[e])).filter(Boolean);return new Zx(t,this.metadata)}assign(e){let t,i=this.metadata;if(e instanceof Zx){const s=e;t=s.fields,i=qx(qx(new Map,this.metadata),s.metadata)}else t=e;const s=Object.create(null);for(const e of this.fields)s[e.name]=e;for(const e of t)s[e.name]=e;const r=Object.values(s);return new Zx(r,i)}}function qx(e,t){return new Map([...e||new Map,...t||new Map])}class $x{constructor(e,t,i=!1,s=new Map){yb(this,"name",void 0),yb(this,"type",void 0),yb(this,"nullable",void 0),yb(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=i,this.metadata=s}get typeId(){return this.type&&this.type.typeId}clone(){return new $x(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}let ew,tw,iw,sw;!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(ew||(ew={}));class rw{static isNull(e){return e&&e.typeId===ew.Null}static isInt(e){return e&&e.typeId===ew.Int}static isFloat(e){return e&&e.typeId===ew.Float}static isBinary(e){return e&&e.typeId===ew.Binary}static isUtf8(e){return e&&e.typeId===ew.Utf8}static isBool(e){return e&&e.typeId===ew.Bool}static isDecimal(e){return e&&e.typeId===ew.Decimal}static isDate(e){return e&&e.typeId===ew.Date}static isTime(e){return e&&e.typeId===ew.Time}static isTimestamp(e){return e&&e.typeId===ew.Timestamp}static isInterval(e){return e&&e.typeId===ew.Interval}static isList(e){return e&&e.typeId===ew.List}static isStruct(e){return e&&e.typeId===ew.Struct}static isUnion(e){return e&&e.typeId===ew.Union}static isFixedSizeBinary(e){return e&&e.typeId===ew.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===ew.FixedSizeList}static isMap(e){return e&&e.typeId===ew.Map}static isDictionary(e){return e&&e.typeId===ew.Dictionary}get typeId(){return ew.NONE}compareTo(e){return this===e}}tw=Symbol.toStringTag;class ow extends rw{constructor(e,t){super(),yb(this,"isSigned",void 0),yb(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return ew.Int}get[tw](){return"Int"}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}class nw extends ow{constructor(){super(!0,8)}}class aw extends ow{constructor(){super(!0,16)}}class lw extends ow{constructor(){super(!0,32)}}class Aw extends ow{constructor(){super(!1,8)}}class hw extends ow{constructor(){super(!1,16)}}class cw extends ow{constructor(){super(!1,32)}}const uw=32,dw=64;iw=Symbol.toStringTag;class pw extends rw{constructor(e){super(),yb(this,"precision",void 0),this.precision=e}get typeId(){return ew.Float}get[iw](){return"Float"}toString(){return"Float".concat(this.precision)}}class fw extends pw{constructor(){super(uw)}}class gw extends pw{constructor(){super(dw)}}sw=Symbol.toStringTag;class mw extends rw{constructor(e,t){super(),yb(this,"listSize",void 0),yb(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return ew.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[sw](){return"FixedSizeList"}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}function _w(e,t,i){const s=function(e){switch(e.constructor){case Int8Array:return new nw;case Uint8Array:return new Aw;case Int16Array:return new aw;case Uint16Array:return new hw;case Int32Array:return new lw;case Uint32Array:return new cw;case Float32Array:return new fw;case Float64Array:return new gw;default:throw new Error("array type not supported")}}(t.value),r=i||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new $x(e,new mw(t.size,new $x("value",s)),!1,r)}function vw(e,t,i){return _w(e,t,i?bw(i.metadata):void 0)}function bw(e){const t=new Map;for(const i in e)t.set("".concat(i,".string"),JSON.stringify(e[i]));return t}const yw={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Bw={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class xw{constructor(e){yb(this,"draco",void 0),yb(this,"decoder",void 0),yb(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const s=this.decoder.GetEncodedGeometryType(i),r=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(s){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t="DRACO decompression failed: ".concat(e.error_msg());throw new Error(t)}const o=this._getDracoLoaderData(r,s,t),n=this._getMeshData(r,o,t),a=function(e){let t=1/0,i=1/0,s=1/0,r=-1/0,o=-1/0,n=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;er?l:r,o=A>o?A:o,n=h>n?h:n}return[[t,i,s],[r,o,n]]}(n.attributes),l=function(e,t,i){const s=bw(t.metadata),r=[],o=function(e){const t={};for(const i in e){const s=e[i];t[s.name||"undefined"]=s}return t}(t.attributes);for(const t in e){const i=vw(t,e[t],o[t]);r.push(i)}if(i){const e=vw("indices",i);r.push(e)}return new Zx(r,s)}(n.attributes,o,n.indices);return{loader:"draco",loaderData:o,header:{vertexCount:r.num_points(),boundingBox:a},...n,schema:l}}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,i){const s=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:r}}_getDracoAttributes(e,t){const i={};for(let s=0;sthis.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map((e=>t.min_value(e)))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,s=e.attribute_type();if(i.map((e=>this.decoder[e])).includes(s)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const ww="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.js"),Pw="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_wasm_wrapper.js"),Cw="https://www.gstatic.com/draco/versioned/decoders/".concat("1.4.1","/draco_decoder.wasm");let Mw;async function Fw(e){const t=e.modules||{};return Mw=t.draco3d?Mw||t.draco3d.createDecoderModule({}).then((e=>({draco:e}))):Mw||async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await Ub(ww,"draco",e);else[t,i]=await Promise.all([await Ub(Pw,"draco",e),await Ub(Cw,"draco",e)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise((t=>{e({...i,onModuleLoaded:e=>t({draco:e})})}))}(t,i)}(e),await Mw}const Ew={...Yx,parse:async function(e,t){const{draco:i}=await Fw(t),s=new xw(i);try{return s.parseSync(e,null==t?void 0:t.draco)}finally{s.destroy()}}};function Iw(e){const{buffer:t,size:i,count:s}=function(e){let t=e,i=1,s=0;e&&e.value&&(t=e.value,i=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,i=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),s=t.length/i);return{buffer:t,size:i,count:s}}(e);return{value:t,size:i,byteOffset:0,count:s,type:Tx(i),componentType:Rx(t)}}async function Dw(e,t,i,s){const r=e.getObjectExtension(t,"KHR_draco_mesh_compression");if(!r)return;const o=e.getTypedArrayForBufferView(r.bufferView),n=jb(o.buffer,o.byteOffset),{parse:a}=s,l={...i};delete l["3d-tiles"];const A=await a(n,Ew,l,s),h=function(e){const t={};for(const i in e){const s=e[i];if("indices"!==i){const e=Iw(s);t[i]=e}}return t}(A.attributes);for(const[i,s]of Object.entries(h))if(i in t.attributes){const r=t.attributes[i],o=e.getAccessor(r);null!=o&&o.min&&null!=o&&o.max&&(s.min=o.min,s.max=o.max)}t.attributes=h,A.indices&&(t.indices=Iw(A.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function Sw(e,t,i=4,s,r){var o;if(!s.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const n=s.DracoWriter.encodeSync({attributes:e}),a=null==r||null===(o=r.parseSync)||void 0===o?void 0:o.call(r,{attributes:e}),l=s._addFauxAttributes(a.attributes);return{primitives:[{attributes:l,mode:i,extensions:{KHR_draco_mesh_compression:{bufferView:s.addBufferView(n),attributes:l}}}]}}function*Tw(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var Rw=Object.freeze({__proto__:null,name:"KHR_draco_mesh_compression",preprocess:function(e,t,i){const s=new kx(e);for(const e of Tw(s))s.getObjectExtension(e,"KHR_draco_mesh_compression")},decode:async function(e,t,i){var s;if(null==t||null===(s=t.gltf)||void 0===s||!s.decompressMeshes)return;const r=new kx(e),o=[];for(const e of Tw(r))r.getObjectExtension(e,"KHR_draco_mesh_compression")&&o.push(Dw(r,e,t,i));await Promise.all(o),r.removeExtension("KHR_draco_mesh_compression")},encode:function(e,t={}){const i=new kx(e);for(const e of i.json.meshes||[])Sw(e),i.addRequiredExtension("KHR_draco_mesh_compression")}});var Lw=Object.freeze({__proto__:null,name:"KHR_lights_punctual",decode:async function(e){const t=new kx(e),{json:i}=t,s=t.getExtension("KHR_lights_punctual");s&&(t.json.lights=s.lights,t.removeExtension("KHR_lights_punctual"));for(const e of i.nodes||[]){const i=t.getObjectExtension(e,"KHR_lights_punctual");i&&(e.light=i.light),t.removeObjectExtension(e,"KHR_lights_punctual")}},encode:async function(e){const t=new kx(e),{json:i}=t;if(i.lights){const e=t.addExtension("KHR_lights_punctual");Px(!e.lights),e.lights=i.lights,delete i.lights}if(t.json.lights){for(const e of t.json.lights){const i=e.node;t.addObjectExtension(i,"KHR_lights_punctual",e)}delete t.json.lights}}});function Uw(e,t){const i=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach((t=>{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)})),Object.keys(i).forEach((e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))})),i}const kw=[Kx,Xx,Jx,Rw,Lw,Object.freeze({__proto__:null,name:"KHR_materials_unlit",decode:async function(e){const t=new kx(e),{json:i}=t;t.removeExtension("KHR_materials_unlit");for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,"KHR_materials_unlit")}},encode:function(e){const t=new kx(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}}),Object.freeze({__proto__:null,name:"KHR_techniques_webgl",decode:async function(e){const t=new kx(e),{json:i}=t,s=t.getExtension("KHR_techniques_webgl");if(s){const e=function(e,t){const{programs:i=[],shaders:s=[],techniques:r=[]}=e,o=new TextDecoder;return s.forEach((e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))})),i.forEach((e=>{e.fragmentShader=s[e.fragmentShader],e.vertexShader=s[e.vertexShader]})),r.forEach((e=>{e.program=i[e.program]})),r}(s,t);for(const s of i.materials||[]){const i=t.getObjectExtension(s,"KHR_techniques_webgl");i&&(s.technique=Object.assign({},i,e[i.technique]),s.technique.values=Uw(s.technique,t)),t.removeObjectExtension(s,"KHR_techniques_webgl")}t.removeExtension("KHR_techniques_webgl")}},encode:async function(e,t){}})];function Ow(e,t){var i;const s=(null==t||null===(i=t.gltf)||void 0===i?void 0:i.excludeExtensions)||{};return!(e in s&&!s[e])}const Nw={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Qw={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class Vw{constructor(){yb(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),yb(this,"json",void 0)}normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version ".concat(i.asset.version))}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new kx(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,"KHR_binary_glTF");i&&Object.assign(e,i),t.removeObjectExtension(e,"KHR_binary_glTF")}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in Nw)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const s in i){const r=i[s];r.id=r.id||s;const o=e[t].length;e[t].push(r),this.idToIndexMap[t][s]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in Nw)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:s}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),s&&(t.material=this._convertIdToIndex(s,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map((e=>this._convertIdToIndex(e,"node")))),e.meshes&&(e.meshes=e.meshes.map((e=>this._convertIdToIndex(e,"mesh"))))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map((e=>this._convertIdToIndex(e,"node"))))}_convertIdsToIndices(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute ".concat(t)),e[t]=[]);for(const i of e[t])for(const e in i){const t=i[e],s=this._convertIdToIndex(t,e);i[e]=s}}_convertIdToIndex(e,t){const i=Qw[t];if(i in this.idToIndexMap){const s=this.idToIndexMap[i][e];if(!Number.isFinite(s))throw new Error("gltf v1: failed to resolve ".concat(t," with id ").concat(e));return s}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const s of e.materials){var t,i;s.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const r=(null===(t=s.values)||void 0===t?void 0:t.tex)||(null===(i=s.values)||void 0===i?void 0:i.texture2d_0),o=e.textures.findIndex((e=>e.id===r));-1!==o&&(s.pbrMetallicRoughness.baseColorTexture={index:o})}}}const Hw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jw={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Gw=10240,zw=10241,Ww=10242,Kw=10243,Xw=10497,Jw={magFilter:Gw,minFilter:zw,wrapS:Ww,wrapT:Kw},Yw={[Gw]:9729,[zw]:9986,[Ww]:Xw,[Kw]:Xw};class Zw{constructor(){yb(this,"baseUri",""),yb(this,"json",{}),yb(this,"buffers",[]),yb(this,"images",[])}postProcess(e,t={}){const{json:i,buffers:s=[],images:r=[],baseUri:o=""}=e;return Px(i),this.baseUri=o,this.json=i,this.buffers=s,this.images=r,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map(((e,t)=>this._resolveBufferView(e,t)))),e.images&&(e.images=e.images.map(((e,t)=>this._resolveImage(e,t)))),e.samplers&&(e.samplers=e.samplers.map(((e,t)=>this._resolveSampler(e,t)))),e.textures&&(e.textures=e.textures.map(((e,t)=>this._resolveTexture(e,t)))),e.accessors&&(e.accessors=e.accessors.map(((e,t)=>this._resolveAccessor(e,t)))),e.materials&&(e.materials=e.materials.map(((e,t)=>this._resolveMaterial(e,t)))),e.meshes&&(e.meshes=e.meshes.map(((e,t)=>this._resolveMesh(e,t)))),e.nodes&&(e.nodes=e.nodes.map(((e,t)=>this._resolveNode(e,t)))),e.skins&&(e.skins=e.skins.map(((e,t)=>this._resolveSkin(e,t)))),e.scenes&&(e.scenes=e.scenes.map(((e,t)=>this._resolveScene(e,t)))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];return i||console.warn("glTF file error: Could not find ".concat(e,"[").concat(t,"]")),i}_resolveScene(e,t){return e.id=e.id||"scene-".concat(t),e.nodes=(e.nodes||[]).map((e=>this.getNode(e))),e}_resolveNode(e,t){return e.id=e.id||"node-".concat(t),e.children&&(e.children=e.children.map((e=>this.getNode(e)))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce(((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e}),{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-".concat(t),e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-".concat(t),e.primitives&&(e.primitives=e.primitives.map((e=>{const t=(e={...e}).attributes;e.attributes={};for(const i in t)e.attributes[i]=this.getAccessor(t[i]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e}))),e}_resolveMaterial(e,t){if(e.id=e.id||"material-".concat(t),e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var i,s;if(e.id=e.id||"accessor-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(i=e.componentType,jw[i]),e.components=(s=e.type,Hw[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:i,byteLength:s}=Lx(e,e.bufferView),r=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset;let o=t.arrayBuffer.slice(r,r+s);e.bufferView.byteStride&&(o=this._getValueFromInterleavedBuffer(t,r,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new i(o)}return e}_getValueFromInterleavedBuffer(e,t,i,s,r){const o=new Uint8Array(r*s);for(let n=0;n20);const s=t.getUint32(i+0,$w),r=t.getUint32(i+4,$w);return i+=8,cb(0===r),tP(e,t,i,s),i+=s,i+=iP(e,t,i,e.header.byteLength)}(e,r,i);case 2:return function(e,t,i,s){return cb(e.header.byteLength>20),function(e,t,i,s){for(;i+8<=e.header.byteLength;){const r=t.getUint32(i+0,$w),o=t.getUint32(i+4,$w);switch(i+=8,o){case 1313821514:tP(e,t,i,r);break;case 5130562:iP(e,t,i,r);break;case 0:s.strict||tP(e,t,i,r);break;case 1:s.strict||iP(e,t,i,r)}i+=Gb(r,4)}}(e,t,i,s),i+e.header.byteLength}(e,r,i,{});default:throw new Error("Invalid GLB version ".concat(e.version,". Only supports v1 and v2."))}}function tP(e,t,i,s){const r=new Uint8Array(t.buffer,i,s),o=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(o),Gb(s,4)}function iP(e,t,i,s){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:s,arrayBuffer:t.buffer}),Gb(s,4)}async function sP(e,t,i=0,s,r){var o,n,a,l;!function(e,t,i,s){s.uri&&(e.baseUri=s.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,i={}){const s=new DataView(e),{magic:r=qw}=i,o=s.getUint32(t,!1);return o===r||o===qw}(t,i,s)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=Qb(t);else if(t instanceof ArrayBuffer){const r={};i=eP(r,t,i,s.glb),Px("glTF"===r.type,"Invalid GLB magic string ".concat(r.type)),e._glb=r,e.json=r.json}else Px(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,i,s),function(e,t={}){(new Vw).normalize(e,t)}(e,{normalize:null==s||null===(o=s.gltf)||void 0===o?void 0:o.normalize}),function(e,t={},i){const s=kw.filter((e=>Ow(e.name,t)));for(const o of s){var r;null===(r=o.preprocess)||void 0===r||r.call(o,e,t,i)}}(e,s,r);const A=[];if(null!=s&&null!==(n=s.gltf)&&void 0!==n&&n.loadBuffers&&e.json.buffers&&await async function(e,t,i){const s=e.json.buffers||[];for(let n=0;nOw(e.name,t)));for(const o of s){var r;await(null===(r=o.decode)||void 0===r?void 0:r.call(o,e,t,i))}}(e,s,r);return A.push(h),await Promise.all(A),null!=s&&null!==(l=s.gltf)&&void 0!==l&&l.postProcess?function(e,t){return(new Zw).postProcess(e,t)}(e,s):e}async function rP(e,t,i,s,r){const{fetch:o,parse:n}=r;let a;if(t.uri){const e=Cx(t.uri,s),i=await o(e);a=await i.arrayBuffer()}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const s=e.bufferViews[i];Px(s);const r=t[s.buffer];Px(r);const o=(s.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,o,s.byteLength)}(e.json,e.buffers,t.bufferView);a=jb(i.buffer,i.byteOffset,i.byteLength)}Px(a,"glTF image has no data");let l=await n(a,[yx,rx],{mimeType:t.mimeType,basis:s.basis||{format:sx()}},r);l&&l[0]&&(l={compressed:!0,mipmaps:!1,width:l[0].width,height:l[0].height,data:l[0]}),e.images=e.images||[],e.images[i]=l}const oP={name:"glTF",id:"gltf",module:"gltf",version:"3.2.6",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},i){(t={...oP.options,...t}).gltf={...oP.options.gltf,...t.gltf};const{byteOffset:s=0}=t;return await sP({},e,s,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};class nP{constructor(e){}load(e,t,i,s,r,o,n){!function(e,t,i,s,r,o,n){const a=e.viewer.scene.canvas.spinner;a.processes++;"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(n=>{s.basePath=lP(t),AP(e,t,n,i,s,r,o),a.processes--}),(e=>{a.processes--,n(e)})):e.dataSource.getGLTF(t,(n=>{s.basePath=lP(t),AP(e,t,n,i,s,r,o),a.processes--}),(e=>{a.processes--,n(e)}))}(e,t,i,s=s||{},r,(function(){I.scheduleTask((function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1)})),o&&o()}),(function(t){e.error(t),n&&n(t),r.fire("error",t)}))}parse(e,t,i,s,r,o,n){AP(e,"",t,i,s=s||{},r,(function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1),o&&o()}))}}function aP(e){const t={},i={},s=e.metaObjects||[],r={};for(let e=0,t=s.length;e{const l={src:t,metaModelCorrections:s?aP(s):null,loadBuffer:r.loadBuffer,basePath:r.basePath,handlenode:r.handlenode,backfaces:!!r.backfaces,gltfData:i,scene:o.scene,plugin:e,sceneModel:o,numObjects:0,nodes:[],nextId:0,log:t=>{e.log(t)}};!function(e){const t=e.gltfData.textures;if(t)for(let i=0,s=t.length;i0)for(let t=0;t0){null==n&&e.log("Warning: 'name' properties not found on glTF scene nodes - will randomly-generate object IDs in XKT");let t=n;if(e.metaModelCorrections){const i=e.metaModelCorrections.eachChildRoot[t];if(i){const t=e.metaModelCorrections.eachRootStats[i.id];t.countChildren++,t.countChildren>=t.numChildren&&(o.createEntity({id:i.id,meshIds:pP}),pP.length=0)}else{e.metaModelCorrections.metaObjectsMap[t]&&(o.createEntity({id:t,meshIds:pP}),pP.length=0)}}else o.createEntity({id:t,meshIds:pP}),pP.length=0}}function gP(e,t){e.plugin.error(t)}const mP={DEFAULT:{}};class _P extends z{constructor(e,t={}){super("GLTFLoader",e,t),this._sceneModelLoader=new nP(this,t),this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults}set dataSource(e){this._dataSource=e||new Oc}get dataSource(){return this._dataSource}set objectDefaults(e){this._objectDefaults=e||mP}get objectDefaults(){return this._objectDefaults}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new _c(this.viewer.scene,y.apply(e,{isModel:!0,dtxEnabled:e.dtxEnabled})),i=t.id;if(!e.src&&!e.gltf)return this.error("load() param expected: src or gltf"),t;if(e.metaModelSrc||e.metaModelJSON){const s=e.objectDefaults||this._objectDefaults||mP,r=r=>{let o;if(this.viewer.metaScene.createMetaModel(i,r,{includeTypes:e.includeTypes,excludeTypes:e.excludeTypes}),this.viewer.scene.canvas.spinner.processes--,e.includeTypes){o={};for(let t=0,i=e.includeTypes.length;t{const r=t.name;if(!r)return!0;const o=r,n=this.viewer.metaScene.metaObjects[o],a=(n?n.type:"DEFAULT")||"DEFAULT";i.createEntity={id:o,isObject:!0};const l=s[a];return l&&(!1===l.visible&&(i.createEntity.visible=!1),l.colorize&&(i.createEntity.colorize=l.colorize),!1===l.pickable&&(i.createEntity.pickable=!1),void 0!==l.opacity&&null!==l.opacity&&(i.createEntity.opacity=l.opacity)),!0},e.src?this._sceneModelLoader.load(this,e.src,r,e,t):this._sceneModelLoader.parse(this,e.gltf,r,e,t)};if(e.metaModelSrc){const t=e.metaModelSrc;this.viewer.scene.canvas.spinner.processes++,this._dataSource.getMetaModel(t,(e=>{this.viewer.scene.canvas.spinner.processes--,r(e)}),(e=>{this.error(`load(): Failed to load model metadata for model '${i} from '${t}' - ${e}`),this.viewer.scene.canvas.spinner.processes--}))}else e.metaModelJSON&&r(e.metaModelJSON)}else e.handleGLTFNode=(e,t,i)=>{const s=t.name;if(!s)return!0;const r=s;return i.createEntity={id:r,isObject:!0},!0},e.src?this._sceneModelLoader.load(this,e.src,null,e,t):this._sceneModelLoader.parse(this,e.gltf,null,e,t);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}}function vP(e,t,i={}){const s="lightgrey",r=i.hoverColor||"rgba(0,0,0,0.4)",o=i.textColor||"black",n=500,a=n+n/3,l=a/24,A=[{boundary:[6,6,6,6],color:i.frontColor||i.color||"#55FF55"},{boundary:[18,6,6,6],color:i.backColor||i.color||"#55FF55"},{boundary:[12,6,6,6],color:i.rightColor||i.color||"#FF5555"},{boundary:[0,6,6,6],color:i.leftColor||i.color||"#FF5555"},{boundary:[6,0,6,6],color:i.topColor||i.color||"#7777FF"},{boundary:[6,12,6,6],color:i.bottomColor||i.color||"#7777FF"}],h=[{label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,1,0],up:[0,0,1]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,-1,0],up:[0,0,1]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,0,1]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,0,1]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,0,1],up:[0,-1,0]},{boundaries:[[7,5,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,0,-1],up:[1,0,1]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-1,-1],up:[0,-1,1]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,0,-1],up:[-1,0,1]},{boundaries:[[7,11,4,2]],dir:[0,1,1],up:[0,-1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,0,1],up:[-1,0,1]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,-1,1],up:[0,1,1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,0,1],up:[1,0,1]},{boundaries:[[5,7,2,4]],dir:[1,1,0],up:[0,0,1]},{boundaries:[[11,7,2,4]],dir:[-1,1,0],up:[0,0,1]},{boundaries:[[17,7,2,4]],dir:[-1,-1,0],up:[0,0,1]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,-1,0],up:[0,0,1]},{boundaries:[[5,11,2,2]],dir:[1,1,1],up:[-1,-1,1]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[1,-1,1],up:[-1,1,1]},{boundaries:[[5,5,2,2]],dir:[1,1,-1],up:[1,1,1]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-1,-1,1],up:[1,1,1]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-1,-1,-1],up:[-1,-1,1]},{boundaries:[[11,11,2,2]],dir:[-1,1,1],up:[1,-1,1]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[1,-1,-1],up:[1,-1,1]},{boundaries:[[11,5,2,2]],dir:[-1,1,-1],up:[-1,1,1]}];i.frontColor||i.color,i.backColor||i.color,i.rightColor||i.color,i.leftColor||i.color,i.topColor||i.color,i.bottomColor||i.color;const c=[{yUp:"",label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,0,1],up:[0,1,0]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,1,0]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,1,0]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,-1,0],up:[0,0,-1]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,1,0],up:[0,0,1]},{boundaries:[[7,5,4,2]],dir:[0,-.7071,-.7071],up:[0,.7071,-.7071]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,-1,0],up:[1,1,0]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-.7071,.7071],up:[0,.7071,.7071]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,-1,0],up:[-1,1,0]},{boundaries:[[7,11,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,1,0],up:[-1,1,0]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,1,1],up:[0,1,-1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,1,0],up:[1,1,0]},{boundaries:[[5,7,2,4]],dir:[1,0,-1],up:[0,1,0]},{boundaries:[[11,7,2,4]],dir:[-1,0,-1],up:[0,1,0]},{boundaries:[[17,7,2,4]],dir:[-1,0,1],up:[0,1,0]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,0,1],up:[0,1,0]},{boundaries:[[5,11,2,2]],dir:[.5,.7071,-.5],up:[-.5,.7071,.5]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[.5,.7071,.5],up:[-.5,.7071,-.5]},{boundaries:[[5,5,2,2]],dir:[.5,-.7071,-.5],up:[.5,.7071,-.5]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-.5,.7071,.5],up:[.5,.7071,-.5]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-.5,-.7071,.5],up:[-.5,.7071,.5]},{boundaries:[[11,11,2,2]],dir:[-.5,.7071,-.5],up:[.5,.7071,.5]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[.5,-.7071,.5],up:[.5,.7071,.5]},{boundaries:[[11,5,2,2]],dir:[-.5,-.7071,-.5],up:[-.5,.7071,-.5]}];for(let e=0,t=h.length;e=r[0]*l&&t<=(r[0]+r[2])*l&&i>=r[1]*l&&i<=(r[1]+r[3])*l)return s}}return-1},this.setAreaHighlighted=function(e,t){var i=u[e];if(!i)throw"Area not found: "+e;i.highlighted=!!t,g()},this.getAreaDir=function(e){var t=u[e];if(!t)throw"Unknown area: "+e;return t.dir},this.getAreaUp=function(e){var t=u[e];if(!t)throw"Unknown area: "+e;return t.up},this.getImage=function(){return this._textureCanvas},this.destroy=function(){this._textureCanvas&&(this._textureCanvas.parentNode.removeChild(this._textureCanvas),this._textureCanvas=null)}}const bP=d.vec3(),yP=d.vec3();d.mat4();class BP extends z{constructor(e,t={}){super("NavCube",e,t),e.navCube=this;try{this._navCubeScene=new li(e,{canvasId:t.canvasId,canvasElement:t.canvasElement,transparent:!0}),this._navCubeCanvas=this._navCubeScene.canvas.canvas,this._navCubeScene.input.keyboardEnabled=!1}catch(e){return void this.error(e)}const i=this._navCubeScene;i.clearLights(),new Dt(i,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Dt(i,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Dt(i,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._navCubeCamera=i.camera,this._navCubeCamera.ortho.scale=7,this._navCubeCamera.ortho.near=.1,this._navCubeCamera.ortho.far=2e3,i.edgeMaterial.edgeColor=[.2,.2,.2],i.edgeMaterial.edgeAlpha=.6,this._zUp=Boolean(e.camera.zUp);var s=this;this.setIsProjectNorth(t.isProjectNorth),this.setProjectNorthOffsetAngle(t.projectNorthOffsetAngle);const r=function(){const e=d.mat4();return function(t,i,r){return d.identityMat4(e),d.rotationMat4v(t*s._projectNorthOffsetAngle*d.DEGTORAD,[0,1,0],e),d.transformVec3(e,i,r)}}();this._synchCamera=function(){var t=d.rotationMat4c(-90*d.DEGTORAD,1,0,0),i=d.vec3(),o=d.vec3(),n=d.vec3();return function(){var a=e.camera.eye,l=e.camera.look,A=e.camera.up;i=d.mulVec3Scalar(d.normalizeVec3(d.subVec3(a,l,i)),5),s._isProjectNorth&&s._projectNorthOffsetAngle&&(i=r(-1,i,bP),A=r(-1,A,yP)),s._zUp?(d.transformVec3(t,i,o),d.transformVec3(t,A,n),s._navCubeCamera.look=[0,0,0],s._navCubeCamera.eye=d.transformVec3(t,i,o),s._navCubeCamera.up=d.transformPoint3(t,A,n)):(s._navCubeCamera.look=[0,0,0],s._navCubeCamera.eye=i,s._navCubeCamera.up=A)}}(),this._cubeTextureCanvas=new vP(e,i,t),this._cubeSampler=new Wr(i,{image:this._cubeTextureCanvas.getImage(),flipY:!0,wrapS:1001,wrapT:1001}),this._cubeMesh=new dr(i,{geometry:new Gt(i,{primitive:"triangles",normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),material:new Jt(i,{diffuse:[.4,.4,.4],specular:[.4,.4,.4],emissive:[.6,.6,.6],diffuseMap:this._cubeSampler,emissiveMap:this._cubeSampler}),visible:!0,edges:!0}),this._shadow=!1===t.shadowVisible?null:new dr(i,{geometry:new Gt(i,fr({center:[0,0,0],radiusTop:.001,radiusBottom:1.4,height:.01,radialSegments:20,heightSegments:1,openEnded:!0})),material:new Jt(i,{diffuse:[0,0,0],specular:[0,0,0],emissive:[0,0,0],alpha:.5}),position:[0,-1.5,0],visible:!0,pickable:!1,backfaces:!1}),this._onCameraMatrix=e.camera.on("matrix",this._synchCamera),this._onCameraWorldAxis=e.camera.on("worldAxis",(()=>{e.camera.zUp?(this._zUp=!0,this._cubeTextureCanvas.setZUp(),this._repaint(),this._synchCamera()):e.camera.yUp&&(this._zUp=!1,this._cubeTextureCanvas.setYUp(),this._repaint(),this._synchCamera())})),this._onCameraFOV=e.camera.perspective.on("fov",(e=>{this._synchProjection&&(this._navCubeCamera.perspective.fov=e)})),this._onCameraProjection=e.camera.on("projection",(e=>{this._synchProjection&&(this._navCubeCamera.projection="ortho"===e||"perspective"===e?e:"perspective")}));var o=-1;function n(e){var t=[0,0];if(e){for(var i=e.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t}var a,l,A=null,h=null,c=!1,u=!1,p=.5;s._navCubeCanvas.addEventListener("mouseenter",s._onMouseEnter=function(e){u=!0}),s._navCubeCanvas.addEventListener("mouseleave",s._onMouseLeave=function(e){u=!1}),s._navCubeCanvas.addEventListener("mousedown",s._onMouseDown=function(e){if(1===e.which){A=e.x,h=e.y,a=e.clientX,l=e.clientY;var t=n(e),s=i.pick({canvasPos:t});c=!!s}}),document.addEventListener("mouseup",s._onMouseUp=function(e){if(1===e.which&&(c=!1,null!==A)){var t=n(e),a=i.pick({canvasPos:t,pickSurface:!0});if(a&&a.uv){var l=s._cubeTextureCanvas.getArea(a.uv);if(l>=0&&(document.body.style.cursor="pointer",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),l>=0)){if(s._cubeTextureCanvas.setAreaHighlighted(l,!0),o=l,s._repaint(),e.xA+3||e.yh+3)return;var u=s._cubeTextureCanvas.getAreaDir(l);if(u){var d=s._cubeTextureCanvas.getAreaUp(l);s._isProjectNorth&&s._projectNorthOffsetAngle&&(u=r(1,u,bP),d=r(1,d,yP)),f(u,d,(function(){o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),document.body.style.cursor="pointer",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),l>=0&&(s._cubeTextureCanvas.setAreaHighlighted(l,!1),o=-1,s._repaint())}))}}}}}),document.addEventListener("mousemove",s._onMouseMove=function(t){if(o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1),1!==t.buttons||c){if(c){var r=t.clientX,A=t.clientY;return document.body.style.cursor="move",void function(t,i){var s=(t-a)*-p,r=(i-l)*-p;e.camera.orbitYaw(s),e.camera.orbitPitch(-r),a=t,l=i}(r,A)}if(u){var h=n(t),d=i.pick({canvasPos:h,pickSurface:!0});if(d){if(d.uv){document.body.style.cursor="pointer";var f=s._cubeTextureCanvas.getArea(d.uv);if(f===o)return;o>=0&&s._cubeTextureCanvas.setAreaHighlighted(o,!1),f>=0&&(s._cubeTextureCanvas.setAreaHighlighted(f,!0),s._repaint(),o=f)}}else document.body.style.cursor="default",o>=0&&(s._cubeTextureCanvas.setAreaHighlighted(o,!1),s._repaint(),o=-1)}}});var f=function(){var t=d.vec3();return function(i,r,o){var n=s._fitVisible?e.scene.getAABB(e.scene.visibleObjectIds):e.scene.aabb,a=d.getAABB3Diag(n);d.getAABB3Center(n,t);var l=Math.abs(a/Math.tan(s._cameraFitFOV*d.DEGTORAD));e.cameraControl.pivotPos=t,s._cameraFly?e.cameraFlight.flyTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:r||[0,1,0],orthoScale:1.1*a,fitFOV:s._cameraFitFOV,duration:s._cameraFlyDuration},o):e.cameraFlight.jumpTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:r||[0,1,0],orthoScale:1.1*a,fitFOV:s._cameraFitFOV},o)}}();this._onUpdated=e.localeService.on("updated",(()=>{this._cubeTextureCanvas.clear(),this._repaint()})),this.setVisible(t.visible),this.setCameraFitFOV(t.cameraFitFOV),this.setCameraFly(t.cameraFly),this.setCameraFlyDuration(t.cameraFlyDuration),this.setFitVisible(t.fitVisible),this.setSynchProjection(t.synchProjection)}send(e,t){if("language"===e)this._cubeTextureCanvas.clear(),this._repaint()}_repaint(){const e=this._cubeTextureCanvas.getImage();this._cubeMesh.material.diffuseMap.image=e,this._cubeMesh.material.emissiveMap.image=e}setVisible(e=!0){this._navCubeCanvas&&(this._cubeMesh.visible=e,this._shadow&&(this._shadow.visible=e),this._navCubeCanvas.style.visibility=e?"visible":"hidden")}getVisible(){return!!this._navCubeCanvas&&this._cubeMesh.visible}setFitVisible(e=!1){this._fitVisible=e}getFitVisible(){return this._fitVisible}setCameraFly(e=!0){this._cameraFly=e}getCameraFly(){return this._cameraFly}setCameraFitFOV(e=45){this._cameraFitFOV=e}getCameraFitFOV(){return this._cameraFitFOV}setCameraFlyDuration(e=.5){this._cameraFlyDuration=e}getCameraFlyDuration(){return this._cameraFlyDuration}setSynchProjection(e=!1){this._synchProjection=e}getSynchProjection(){return this._synchProjection}setIsProjectNorth(e=!1){this._isProjectNorth=e}getIsProjectNorth(){return this._isProjectNorth}setProjectNorthOffsetAngle(e){this._projectNorthOffsetAngle=e}getProjectNorthOffsetAngle(){return this._projectNorthOffsetAngle}destroy(){this._navCubeCanvas&&(this.viewer.localeService.off(this._onUpdated),this.viewer.camera.off(this._onCameraMatrix),this.viewer.camera.off(this._onCameraWorldAxis),this.viewer.camera.perspective.off(this._onCameraFOV),this.viewer.camera.off(this._onCameraProjection),this._navCubeCanvas.removeEventListener("mouseenter",this._onMouseEnter),this._navCubeCanvas.removeEventListener("mouseleave",this._onMouseLeave),this._navCubeCanvas.removeEventListener("mousedown",this._onMouseDown),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._navCubeCanvas=null,this._cubeTextureCanvas.destroy(),this._cubeTextureCanvas=null,this._onMouseEnter=null,this._onMouseLeave=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null),this._navCubeScene.destroy(),this._navCubeScene=null,this._cubeMesh=null,this._shadow=null,super.destroy()}}const xP=d.vec3();class wP{load(e,t,i={}){var s=e.scene.canvas.spinner;s.processes++,PP(e,t,(function(t){!function(e,t,i){for(var s=t.basePath,r=Object.keys(t.materialLibraries),o=r.length,n=0,a=o;n=0?i-1:i+t/3)}function r(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function o(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)}function n(e,t,i,s){var r=e.positions,o=e.object.geometry.positions;o.push(r[t+0]),o.push(r[t+1]),o.push(r[t+2]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[i+2]),o.push(r[s+0]),o.push(r[s+1]),o.push(r[s+2])}function a(e,t){var i=e.positions,s=e.object.geometry.positions;s.push(i[t+0]),s.push(i[t+1]),s.push(i[t+2])}function l(e,t,i,s){var r=e.normals,o=e.object.geometry.normals;o.push(r[t+0]),o.push(r[t+1]),o.push(r[t+2]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[i+2]),o.push(r[s+0]),o.push(r[s+1]),o.push(r[s+2])}function A(e,t,i,s){var r=e.uv,o=e.object.geometry.uv;o.push(r[t+0]),o.push(r[t+1]),o.push(r[i+0]),o.push(r[i+1]),o.push(r[s+0]),o.push(r[s+1])}function h(e,t){var i=e.uv,s=e.object.geometry.uv;s.push(i[t+0]),s.push(i[t+1])}function c(e,t,i,a,h,c,u,d,p,f,g,m,_){var v,b=e.positions.length,y=s(t,b),B=s(i,b),x=s(a,b);if(void 0===h?n(e,y,B,x):(n(e,y,B,v=s(h,b)),n(e,B,x,v)),void 0!==c){var w=e.uv.length;y=o(c,w),B=o(u,w),x=o(d,w),void 0===h?A(e,y,B,x):(A(e,y,B,v=o(p,w)),A(e,B,x,v))}if(void 0!==f){var P=e.normals.length;y=r(f,P),B=f===g?y:r(g,P),x=f===m?y:r(m,P),void 0===h?l(e,y,B,x):(l(e,y,B,v=r(_,P)),l(e,B,x,v))}}function u(e,t,i){e.object.geometry.type="Line";for(var r=e.positions.length,n=e.uv.length,l=0,A=t.length;l=0?n.substring(0,a):n).toLowerCase(),A=(A=a>=0?n.substring(a+1):"").trim(),l.toLowerCase()){case"newmtl":i(e,u),u={id:A},d=!0;break;case"ka":u.ambient=s(A);break;case"kd":u.diffuse=s(A);break;case"ks":u.specular=s(A);break;case"map_kd":u.diffuseMap||(u.diffuseMap=t(e,o,A,"sRGB"));break;case"map_ks":u.specularMap||(u.specularMap=t(e,o,A,"linear"));break;case"map_bump":case"bump":u.normalMap||(u.normalMap=t(e,o,A));break;case"ns":u.shininess=parseFloat(A);break;case"d":(h=parseFloat(A))<1&&(u.alpha=h,u.alphaMode="blend");break;case"tr":(h=parseFloat(A))>0&&(u.alpha=1-h,u.alphaMode="blend")}d&&i(e,u)};function t(e,t,i,s){var r={},o=i.split(/\s+/),n=o.indexOf("-bm");return n>=0&&o.splice(n,2),(n=o.indexOf("-s"))>=0&&(r.scale=[parseFloat(o[n+1]),parseFloat(o[n+2])],o.splice(n,4)),(n=o.indexOf("-o"))>=0&&(r.translate=[parseFloat(o[n+1]),parseFloat(o[n+2])],o.splice(n,4)),r.src=t+o.join(" ").trim(),r.flipY=!0,r.encoding=s||"linear",new Wr(e,r).id}function i(e,t){new Jt(e,t)}function s(t){var i=t.split(e,3);return[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])]}}();function EP(e,t){for(var i=0,s=t.objects.length;i0&&(n.normals=o.normals),o.uv.length>0&&(n.uv=o.uv);for(var a=new Array(n.positions.length/3),l=0;l{this.viewer.metaScene.createMetaModel(i,r),this._sceneGraphLoader.load(t,s,e)}),(e=>{this.error(`load(): Failed to load model modelMetadata for model '${i} from '${r}' - ${e}`)}))}else this._sceneGraphLoader.load(t,s,e);return t.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(i)})),t}destroy(){super.destroy()}}const SP=new Float64Array([0,0,1]),TP=new Float64Array(4);class RP{constructor(e){this.id=null,this._viewer=e.viewer,this._visible=!1,this._pos=d.vec3(),this._origin=d.vec3(),this._rtcPos=d.vec3(),this._baseDir=d.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}_setSectionPlane(e){this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(()=>{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),X(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=d.vec3PairToQuaternion(SP,e,TP)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,i=.01;this._rootNode=new Ir(t,{position:[0,0,0],scale:[5,5,5],isObject:!1});const s=this._rootNode,r={arrowHead:new Gt(s,fr({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Gt(s,fr({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),arrowHeadHandle:new Gt(s,fr({radiusTop:.09,radiusBottom:.09,radialSegments:8,heightSegments:1,height:.37,openEnded:!1})),curve:new Gt(s,ro({radius:.8,tube:i,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),curveHandle:new Gt(s,ro({radius:.8,tube:.06,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),hoop:new Gt(s,ro({radius:.8,tube:i,radialSegments:64,tubeSegments:8,arc:2*Math.PI})),axis:new Gt(s,fr({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1})),axisHandle:new Gt(s,fr({radiusTop:.08,radiusBottom:.08,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},o={pickable:new Jt(s,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),red:new Jt(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Zt(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6}),green:new Jt(s,{diffuse:[0,1,0],emissive:[0,1,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightGreen:new Zt(s,{edges:!1,fill:!0,fillColor:[0,1,0],fillAlpha:.6}),blue:new Jt(s,{diffuse:[0,0,1],emissive:[0,0,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightBlue:new Zt(s,{edges:!1,fill:!0,fillColor:[0,0,1],fillAlpha:.2}),center:new Jt(s,{diffuse:[0,0,0],emissive:[0,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80}),highlightBall:new Zt(s,{edges:!1,fill:!0,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1}),highlightPlane:new Zt(s,{edges:!0,edgeWidth:3,fill:!1,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1})};this._displayMeshes={plane:s.addChild(new dr(s,{geometry:new Gt(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Jt(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new Zt(s,{edges:!1,filled:!0,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:.1,backfaces:!0}),pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1],isObject:!1}),e),planeFrame:s.addChild(new dr(s,{geometry:new Gt(s,ro({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Jt(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new Zt(s,{edges:!1,edgeColor:[0,0,0],filled:!0,fillColor:[.8,.8,.8],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45],isObject:!1}),e),xCurve:s.addChild(new dr(s,{geometry:r.curve,material:o.red,matrix:function(){const e=d.rotationMat4v(90*d.DEGTORAD,[0,1,0],d.identityMat4()),t=d.rotationMat4v(270*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveHandle:s.addChild(new dr(s,{geometry:r.curveHandle,material:o.pickable,matrix:function(){const e=d.rotationMat4v(90*d.DEGTORAD,[0,1,0],d.identityMat4()),t=d.rotationMat4v(270*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveArrow1:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=d.translateMat4c(0,-.07,-.8,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(0*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xCurveArrow2:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=d.translateMat4c(0,-.8,-.07,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurve:s.addChild(new dr(s,{geometry:r.curve,material:o.green,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveHandle:s.addChild(new dr(s,{geometry:r.curveHandle,material:o.pickable,rotation:[-90,0,0],pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveArrow1:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=d.translateMat4c(.07,0,-.8,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurveArrow2:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=d.translateMat4c(.8,0,-.07,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurve:s.addChild(new dr(s,{geometry:r.curve,material:o.blue,matrix:d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4()),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveHandle:s.addChild(new dr(s,{geometry:r.curveHandle,material:o.pickable,matrix:d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4()),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveCurveArrow1:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=d.translateMat4c(.8,-.07,0,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4());return d.mulMat4(e,t,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveArrow2:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=d.translateMat4c(.05,-.8,0,d.identityMat4()),t=d.scaleMat4v([.6,.6,.6],d.identityMat4()),i=d.rotationMat4v(90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(d.mulMat4(e,t,d.identityMat4()),i,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),center:s.addChild(new dr(s,{geometry:new Gt(s,gr({radius:.05})),material:o.center,pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.red,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrowHandle:s.addChild(new dr(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxis:s.addChild(new dr(s,{geometry:r.axis,material:o.red,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisHandle:s.addChild(new dr(s,{geometry:r.axisHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.green,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrowHandle:s.addChild(new dr(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,opacity:.2,isObject:!1}),e),yShaft:s.addChild(new dr(s,{geometry:r.axis,material:o.green,position:[0,-.5,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yShaftHandle:s.addChild(new dr(s,{geometry:r.axisHandle,material:o.pickable,position:[0,-.5,0],pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrowHandle:s.addChild(new dr(s,{geometry:r.arrowHeadHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zShaft:s.addChild(new dr(s,{geometry:r.axis,material:o.blue,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1,isObject:!1}),e),zAxisHandle:s.addChild(new dr(s,{geometry:r.axisHandle,material:o.pickable,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),clippable:!1,pickable:!0,collidable:!0,visible:!1,isObject:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new dr(s,{geometry:new Gt(s,ro({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Jt(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Zt(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45],isObject:!1}),e),xHoop:s.addChild(new dr(s,{geometry:r.hoop,material:o.red,highlighted:!0,highlightMaterial:o.highlightRed,matrix:function(){const e=d.rotationMat4v(90*d.DEGTORAD,[0,1,0],d.identityMat4()),t=d.rotationMat4v(270*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yHoop:s.addChild(new dr(s,{geometry:r.hoop,material:o.green,highlighted:!0,highlightMaterial:o.highlightGreen,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zHoop:s.addChild(new dr(s,{geometry:r.hoop,material:o.blue,highlighted:!0,highlightMaterial:o.highlightBlue,matrix:d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4()),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHeadBig,material:o.red,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[0,0,1],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHeadBig,material:o.green,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(180*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHeadBig,material:o.blue,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e)}}_bindEvents(){const e=this;var t=!1;const i=-1,s=0,r=1,o=2,n=3,a=4,l=5,A=this._rootNode;var h=null,c=null;const u=d.vec2(),p=d.vec3([1,0,0]),f=d.vec3([0,1,0]),g=d.vec3([0,0,1]),m=this._viewer.scene.canvas.canvas,_=this._viewer.camera,v=this._viewer.scene;{const e=d.vec3([0,0,0]);let t=-1;this._onCameraViewMatrix=v.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=v.camera.on("projMatrix",(()=>{})),this._onSceneTick=v.on("tick",(()=>{const i=Math.abs(d.lenVec3(d.subVec3(v.camera.eye,this._pos,e)));if(i!==t&&"perspective"===_.projection){const e=.07*(Math.tan(_.perspective.fov*d.DEGTORAD)*i);A.scale=[e,e,e],t=i}if("ortho"===_.projection){const e=_.ortho.scale/10;A.scale=[e,e,e],t=i}}))}const b=function(){const e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),y=function(){const t=d.mat4();return function(i,s){return d.quaternionToMat4(e._rootNode.quaternion,t),d.transformVec3(t,i,s),d.normalizeVec3(s),s}}();var B=function(){const e=d.vec3();return function(t){const i=Math.abs(t[0]);return i>Math.abs(t[1])&&i>Math.abs(t[2])?d.cross3Vec3(t,[0,1,0],e):d.cross3Vec3(t,[1,0,0],e),d.cross3Vec3(e,t,e),d.normalizeVec3(e),e}}();const x=function(){const t=d.vec3(),i=d.vec3(),s=d.vec4();return function(r,o,n){y(r,s);const a=B(s,o,n);P(o,a,t),P(n,a,i),d.subVec3(i,t);const l=d.dotVec3(i,s);e._pos[0]+=s[0]*l,e._pos[1]+=s[1]*l,e._pos[2]+=s[2]*l,e._rootNode.position=e._pos,e._sectionPlane&&(e._sectionPlane.pos=e._pos)}}();var w=function(){const t=d.vec4(),i=d.vec4(),s=d.vec4(),r=d.vec4();return function(o,n,a){y(o,r);if(!(P(n,r,t)&&P(a,r,i))){const e=B(r,n,a);P(n,e,t,1),P(a,e,i,1);var l=d.dotVec3(t,r);t[0]-=l*r[0],t[1]-=l*r[1],t[2]-=l*r[2],l=d.dotVec3(i,r),i[0]-=l*r[0],i[1]-=l*r[1],i[2]-=l*r[2]}d.normalizeVec3(t),d.normalizeVec3(i),l=d.dotVec3(t,i),l=d.clamp(l,-1,1);var A=Math.acos(l)*d.RADTODEG;d.cross3Vec3(t,i,s),d.dotVec3(s,r)<0&&(A=-A),e._rootNode.rotate(o,A),C()}}(),P=function(){const t=d.vec4([0,0,0,1]),i=d.mat4();return function(s,r,o,n){n=n||0,t[0]=s[0]/m.width*2-1,t[1]=-(s[1]/m.height*2-1),t[2]=0,t[3]=1,d.mulMat4(_.projMatrix,_.viewMatrix,i),d.inverseMat4(i),d.transformVec4(i,t,t),d.mulVec4Scalar(t,1/t[3]);var a=_.eye;d.subVec4(t,a,t);const l=e._sectionPlane.pos;var A=-d.dotVec3(l,r)-n,h=d.dotVec3(r,t);if(Math.abs(h)>.005){var c=-(d.dotVec3(r,a)+A)/h;return d.mulVec3Scalar(t,c,o),d.addVec3(o,a),d.subVec3(o,l,o),!0}return!1}}();const C=function(){const t=d.vec3(),i=d.mat4();return function(){e.sectionPlane&&(d.quaternionToMat4(A.quaternion,i),d.transformVec3(i,[0,0,1],t),e._setSectionPlaneDir(t))}}();var M,F=!1;this._onCameraControlHover=this._viewer.cameraControl.on("hoverEnter",(e=>{if(!this._visible)return;if(F)return;var A;t=!1,M&&(M.visible=!1);switch(e.entity.id){case this._displayMeshes.xAxisArrowHandle.id:case this._displayMeshes.xAxisHandle.id:A=this._affordanceMeshes.xAxisArrow,h=s;break;case this._displayMeshes.yAxisArrowHandle.id:case this._displayMeshes.yShaftHandle.id:A=this._affordanceMeshes.yAxisArrow,h=r;break;case this._displayMeshes.zAxisArrowHandle.id:case this._displayMeshes.zAxisHandle.id:A=this._affordanceMeshes.zAxisArrow,h=o;break;case this._displayMeshes.xCurveHandle.id:A=this._affordanceMeshes.xHoop,h=n;break;case this._displayMeshes.yCurveHandle.id:A=this._affordanceMeshes.yHoop,h=a;break;case this._displayMeshes.zCurveHandle.id:A=this._affordanceMeshes.zHoop,h=l;break;default:return void(h=i)}A&&(A.visible=!0),M=A,t=!0})),this._onCameraControlHoverLeave=this._viewer.cameraControl.on("hoverOutEntity",(e=>{this._visible&&(M&&(M.visible=!1),M=null,h=i)})),m.addEventListener("mousedown",this._canvasMouseDownListener=e=>{if(e.preventDefault(),this._visible&&t&&(this._viewer.cameraControl.pointerEnabled=!1,1===e.which)){F=!0;var i=b(e);c=h,u[0]=i[0],u[1]=i[1]}}),m.addEventListener("mousemove",this._canvasMouseMoveListener=e=>{if(!this._visible)return;if(!F)return;var t=b(e);const i=t[0],A=t[1];switch(c){case s:x(p,u,t);break;case r:x(f,u,t);break;case o:x(g,u,t);break;case n:w(p,u,t);break;case a:w(f,u,t);break;case l:w(g,u,t)}u[0]=i,u[1]=A}),m.addEventListener("mouseup",this._canvasMouseUpListener=e=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,F&&(e.which,F=!1,t=!1))}),m.addEventListener("wheel",this._canvasWheelListener=e=>{if(this._visible)Math.max(-1,Math.min(1,40*-e.deltaY))})}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=e.cameraControl;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix),r.off(this._onCameraControlHover),r.off(this._onCameraControlHoverLeave)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class LP{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new dr(t,{id:i.id,geometry:new Gt(t,zt({xSize:.5,ySize:.5,zSize:.001})),material:new Jt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new $t(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Zt(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Zt(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=d.vec3([0,0,0]),t=d.vec3(),i=d.vec3([0,0,1]),s=d.vec4(4),r=d.vec3(),o=()=>{const o=this._sectionPlane.scene.center,n=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];d.subVec3(o,this._sectionPlane.pos,e);const a=-d.dotVec3(n,e);d.normalizeVec3(n),d.mulVec3Scalar(n,a,t);const l=d.vec3PairToQuaternion(i,this._sectionPlane.dir,s);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=l,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",o),this._onSectionPlaneDir=this._sectionPlane.on("dir",o)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class UP{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new li(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Dt(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Dt(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Dt(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=d.rotationMat4c(-90*d.DEGTORAD,1,0,0),i=d.vec3(),s=d.vec3(),r=d.vec3();this._synchCamera=()=>{const o=this._viewer.camera.eye,n=this._viewer.camera.look,a=this._viewer.camera.up;d.mulVec3Scalar(d.normalizeVec3(d.subVec3(o,n,i)),7),this._zUp?(d.transformVec3(t,i,s),d.transformVec3(t,a,r),e.look=[0,0,0],e.eye=d.transformVec3(t,i,s),e.up=d.transformPoint3(t,a,r)):(e.look=[0,0,0],e.eye=i,e.up=a)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new LP(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const kP=d.AABB3(),OP=d.vec3();class NP extends z{constructor(e,t={}){if(super("SectionPlanes",e),this._freeControls=[],this._sectionPlanes=e.scene.sectionPlanes,this._controls={},this._shownControlId=null,null!==t.overviewCanvasId&&void 0!==t.overviewCanvasId){const e=document.getElementById(t.overviewCanvasId);e?this._overview=new UP(this,{overviewCanvas:e,visible:t.overviewVisible,onHoverEnterPlane:e=>{this._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:e=>{this._overview.setPlaneHighlighted(e,!1)},onClickedPlane:e=>{if(this.getShownControl()===e)return void this.hideControl();this.showControl(e);const t=this.sectionPlanes[e].pos;kP.set(this.viewer.scene.aabb),d.getAABB3Center(kP,OP),kP[0]+=t[0]-OP[0],kP[1]+=t[1]-OP[1],kP[2]+=t[2]-OP[2],kP[3]+=t[0]-OP[0],kP[4]+=t[1]-OP[1],kP[5]+=t[2]-OP[2],this.viewer.cameraFlight.flyTo({aabb:kP,fitFOV:65})},onClickedNothing:()=>{this.hideControl()}}):this.warn("Can't find overview canvas: '"+t.overviewCanvasId+"' - will create plugin without overview")}this._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(e=>{this._sectionPlaneCreated(e)}))}setOverviewVisible(e){this._overview&&this._overview.setVisible(e)}getOverviewVisible(){if(this._overview)return this._overview.getVisible()}get sectionPlanes(){return this._sectionPlanes}createSectionPlane(e={}){void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);return new br(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0})}_sectionPlaneCreated(e){const t=this._freeControls.length>0?this._freeControls.pop():new RP(this);t._setSectionPlane(e),t.setVisible(!1),this._controls[e.id]=t,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(()=>{this._sectionPlaneDestroyed(e)}))}flipSectionPlanes(){const e=this.viewer.scene.sectionPlanes;for(let t in e){e[t].flipDir()}}showControl(e){const t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}getShownControl(){return this._shownControlId}hideControl(){for(var e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}destroySectionPlane(e){var t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}_sectionPlaneDestroyed(e){this._overview&&this._overview.removeSectionPlane(e);const t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}clear(){const e=Object.keys(this._sectionPlanes);for(var t=0,i=e.length;t{this._registerModelStoreys(e),this.fire("storeys",this.storeys)}))}_registerModelStoreys(e){const t=this.viewer,i=t.scene,s=t.metaScene,r=s.metaModels[e],o=i.models[e];if(!r||!r.rootMetaObjects)return;const n=r.rootMetaObjects;for(let t=0,r=n.length;t.5?a.length:0,h=new QP(this,o.aabb,l,e,n,A);h._onModelDestroyed=o.once("destroyed",(()=>{this._deregisterModelStoreys(e),this.fire("storeys",this.storeys)})),this.storeys[n]=h,this.modelStoreys[e]||(this.modelStoreys[e]={}),this.modelStoreys[e][n]=h}}}_deregisterModelStoreys(e){const t=this.modelStoreys[e];if(t){const i=this.viewer.scene;for(let e in t)if(t.hasOwnProperty(e)){const s=t[e],r=i.models[s.modelId];r&&r.off(s._onModelDestroyed),delete this.storeys[e]}delete this.modelStoreys[e]}}get fitStoreyMaps(){return this._fitStoreyMaps}gotoStoreyCamera(e,t={}){const i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),void(t.done&&t.done());const s=this.viewer,r=s.scene.camera,o=i.storeyAABB;if(o[3]{t.done()})):(s.cameraFlight.jumpTo(y.apply(t,{eye:h,look:n,up:c,orthoScale:A})),s.camera.ortho.scale=A)}showStoreyObjects(e,t={}){if(!this.storeys[e])return void this.error("IfcBuildingStorey not found with this ID: "+e);const i=this.viewer,s=i.scene;i.metaScene.metaObjects[e]&&(t.hideOthers&&s.setObjectsVisible(i.scene.visibleObjectIds,!1),this.withStoreyObjects(e,((e,t)=>{e&&(e.visible=!0)})))}withStoreyObjects(e,t){const i=this.viewer,s=i.scene,r=i.metaScene,o=r.metaObjects[e];if(!o)return;const n=o.getObjectIDsInSubtree();for(var a=0,l=n.length;au[1]&&u[0]>u[2],p=!d&&u[1]>u[0]&&u[1]>u[2];!d&&!p&&u[2]>u[0]&&(u[2],u[1]);const f=e.width/A,g=p?e.height/c:e.height/h;return i[0]=Math.floor(e.width-(t[0]-n)*f),i[1]=Math.floor(e.height-(t[2]-l)*g),i[0]>=0&&i[0]=0&&i[1]<=e.height}worldDirToStoreyMap(e,t,i){const s=this.viewer.camera,r=s.eye,o=s.look,n=d.subVec3(o,r,HP),a=s.worldUp,l=a[0]>a[1]&&a[0]>a[2],A=!l&&a[1]>a[0]&&a[1]>a[2];!l&&!A&&a[2]>a[0]&&(a[2],a[1]),l?(i[0]=n[1],i[1]=n[2]):A?(i[0]=n[0],i[1]=n[2]):(i[0]=n[0],i[1]=n[1]),d.normalizeVec2(i)}destroy(){this.viewer.scene.off(this._onModelLoaded),super.destroy()}}const zP=new Float64Array([0,0,1]),WP=new Float64Array(4);class KP{constructor(e){this.id=null,this._viewer=e.viewer,this._plugin=e,this._visible=!1,this._pos=d.vec3(),this._origin=d.vec3(),this._rtcPos=d.vec3(),this._baseDir=d.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}_setSectionPlane(e){this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(()=>{this._setPos(this._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(()=>{this._ignoreNextSectionPlaneDirUpdate?this._ignoreNextSectionPlaneDirUpdate=!1:this._setDir(this._sectionPlane.dir)})))}get sectionPlane(){return this._sectionPlane}_setPos(e){this._pos.set(e),X(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}_setDir(e){this._baseDir.set(e),this._rootNode.quaternion=d.vec3PairToQuaternion(zP,e,WP)}_setSectionPlaneDir(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}setVisible(e=!0){if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}getVisible(){return this._visible}setCulled(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}_createNodes(){const e=!1,t=this._viewer.scene,i=.01;this._rootNode=new Ir(t,{position:[0,0,0],scale:[5,5,5]});const s=this._rootNode,r={arrowHead:new Gt(s,fr({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Gt(s,fr({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new Gt(s,fr({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},o={red:new Jt(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new Jt(s,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new Jt(s,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Zt(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:s.addChild(new dr(s,{geometry:new Gt(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Jt(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1]}),e),planeFrame:s.addChild(new dr(s,{geometry:new Gt(s,ro({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Jt(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45]}),e),center:s.addChild(new dr(s,{geometry:new Gt(s,gr({radius:.05})),material:o.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHead,material:o.blue,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:s.addChild(new dr(s,{geometry:r.axis,material:o.blue,matrix:function(){const e=d.translateMat4c(0,.5,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[1,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new dr(s,{geometry:new Gt(s,ro({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Jt(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Zt(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45]}),e),zAxisArrow:s.addChild(new dr(s,{geometry:r.arrowHeadBig,material:o.blue,matrix:function(){const e=d.translateMat4c(0,1.1,0,d.identityMat4()),t=d.rotationMat4v(-90*d.DEGTORAD,[.8,0,0],d.identityMat4());return d.mulMat4(t,e,d.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}_bindEvents(){const e=this._rootNode,t=d.vec2(),i=this._viewer.camera,s=this._viewer.scene;let r=0,o=!1;{const t=d.vec3([0,0,0]);let n=-1;this._onCameraViewMatrix=s.camera.on("viewMatrix",(()=>{})),this._onCameraProjMatrix=s.camera.on("projMatrix",(()=>{})),this._onSceneTick=s.on("tick",(()=>{o=!1;const l=Math.abs(d.lenVec3(d.subVec3(s.camera.eye,this._pos,t)));if(l!==n&&"perspective"===i.projection){const t=.07*(Math.tan(i.perspective.fov*d.DEGTORAD)*l);e.scale=[t,t,t],n=l}if("ortho"===i.projection){const t=i.ortho.scale/10;e.scale=[t,t,t],n=l}0!==r&&(a(r),r=0)}))}const n=function(){const e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),a=e=>{const t=this._sectionPlane.pos,i=this._sectionPlane.dir;d.addVec3(t,d.mulVec3Scalar(i,.1*e*this._plugin.getDragSensitivity(),d.vec3())),this._sectionPlane.pos=t};{let e=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=i=>{if(i.preventDefault(),this._visible&&(this._viewer.cameraControl.pointerEnabled=!1,1===i.which)){e=!0;var s=n(i);t[0]=s[0],t[1]=s[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=i=>{if(!this._visible)return;if(!e)return;if(o)return;var s=n(i);const r=s[0],l=s[1];a(l-t[1]),t[0]=r,t[1]=l}),this._plugin._controlElement.addEventListener("mouseup",this._canvasMouseUpListener=t=>{this._visible&&(this._viewer.cameraControl.pointerEnabled=!0,e&&(t.which,e=!1))}),this._plugin._controlElement.addEventListener("wheel",this._canvasWheelListener=e=>{this._visible&&(r+=Math.max(-1,Math.min(1,40*-e.deltaY)))})}{let e,t,i=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=t=>{t.stopPropagation(),t.preventDefault(),this._visible&&(e=t.touches[0].clientY,i=e,r=0)}),this._plugin._controlElement.addEventListener("touchmove",this._handleTouchMove=e=>{e.stopPropagation(),e.preventDefault(),this._visible&&(o||(o=!0,t=e.touches[0].clientY,null!==i&&(r+=t-i),i=t))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=i=>{i.stopPropagation(),i.preventDefault(),this._visible&&(e=null,t=null,r=0)})}}_destroy(){this._unbindEvents(),this._destroyNodes()}_unbindEvents(){const e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix)}_destroyNodes(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}class XP{constructor(e,t,i){this.id=i.id,this._sectionPlane=i,this._mesh=new dr(t,{id:i.id,geometry:new Gt(t,zt({xSize:.5,ySize:.5,zSize:.001})),material:new Jt(t,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new $t(t,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Zt(t,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Zt(t,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});{const e=d.vec3([0,0,0]),t=d.vec3(),i=d.vec3([0,0,1]),s=d.vec4(4),r=d.vec3(),o=()=>{const o=this._sectionPlane.scene.center,n=[-this._sectionPlane.dir[0],-this._sectionPlane.dir[1],-this._sectionPlane.dir[2]];d.subVec3(o,this._sectionPlane.pos,e);const a=-d.dotVec3(n,e);d.normalizeVec3(n),d.mulVec3Scalar(n,a,t);const l=d.vec3PairToQuaternion(i,this._sectionPlane.dir,s);r[0]=.1*t[0],r[1]=.1*t[1],r[2]=.1*t[2],this._mesh.quaternion=l,this._mesh.position=r};this._onSectionPlanePos=this._sectionPlane.on("pos",o),this._onSectionPlaneDir=this._sectionPlane.on("dir",o)}this._highlighted=!1,this._selected=!1}setHighlighted(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}getHighlighted(){return this._highlighted}setSelected(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}getSelected(){return this._selected}destroy(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}class JP{constructor(e,t){if(!(t.onHoverEnterPlane&&t.onHoverLeavePlane&&t.onClickedNothing&&t.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=e,this._viewer=e.viewer,this._onHoverEnterPlane=t.onHoverEnterPlane,this._onHoverLeavePlane=t.onHoverLeavePlane,this._onClickedNothing=t.onClickedNothing,this._onClickedPlane=t.onClickedPlane,this._visible=!0,this._planes={},this._canvas=t.overviewCanvas,this._scene=new li(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new Dt(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new Dt(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new Dt(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;{const e=this._scene.camera,t=d.rotationMat4c(-90*d.DEGTORAD,1,0,0),i=d.vec3(),s=d.vec3(),r=d.vec3();this._synchCamera=()=>{const o=this._viewer.camera.eye,n=this._viewer.camera.look,a=this._viewer.camera.up;d.mulVec3Scalar(d.normalizeVec3(d.subVec3(o,n,i)),7),this._zUp?(d.transformVec3(t,i,s),d.transformVec3(t,a,r),e.look=[0,0,0],e.eye=d.transformVec3(t,i,s),e.up=d.transformPoint3(t,a,r)):(e.look=[0,0,0],e.eye=i,e.up=a)}}this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(e=>{this._scene.camera.perspective.fov=e}));var i=null;this._onInputMouseMove=this._scene.input.on("mousemove",(e=>{const t=this._scene.pick({canvasPos:e});if(t){if(!i||t.entity.id!==i.id){if(i){this._planes[i.id]&&this._onHoverLeavePlane(i.id)}i=t.entity;this._planes[i.id]&&this._onHoverEnterPlane(i.id)}}else i&&(this._onHoverLeavePlane(i.id),i=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=()=>{if(i){this._planes[i.id]&&this._onClickedPlane(i.id)}else this._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=()=>{i&&(this._onHoverLeavePlane(i.id),i=null)}),this.setVisible(t.overviewVisible)}addSectionPlane(e){this._planes[e.id]=new XP(this,this._scene,e)}setPlaneHighlighted(e,t){const i=this._planes[e];i&&i.setHighlighted(t)}setPlaneSelected(e,t){const i=this._planes[e];i&&i.setSelected(t)}removeSectionPlane(e){const t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}setVisible(e=!0){this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}getVisible(){return this._visible}destroy(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}const YP=d.AABB3(),ZP=d.vec3();class qP extends z{constructor(e,t={}){if(super("FaceAlignedSectionPlanesPlugin",e),this._freeControls=[],this._sectionPlanes=e.scene.sectionPlanes,this._controls={},this._shownControlId=null,this._dragSensitivity=t.dragSensitivity||1,null!==t.overviewCanvasId&&void 0!==t.overviewCanvasId){const e=document.getElementById(t.overviewCanvasId);e?this._overview=new JP(this,{overviewCanvas:e,visible:t.overviewVisible,onHoverEnterPlane:e=>{this._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:e=>{this._overview.setPlaneHighlighted(e,!1)},onClickedPlane:e=>{if(this.getShownControl()===e)return void this.hideControl();this.showControl(e);const t=this.sectionPlanes[e].pos;YP.set(this.viewer.scene.aabb),d.getAABB3Center(YP,ZP),YP[0]+=t[0]-ZP[0],YP[1]+=t[1]-ZP[1],YP[2]+=t[2]-ZP[2],YP[3]+=t[0]-ZP[0],YP[4]+=t[1]-ZP[1],YP[5]+=t[2]-ZP[2],this.viewer.cameraFlight.flyTo({aabb:YP,fitFOV:65})},onClickedNothing:()=>{this.hideControl()}}):this.warn("Can't find overview canvas: '"+t.overviewCanvasId+"' - will create plugin without overview")}null===t.controlElementId||void 0===t.controlElementId?this.error("Parameter expected: controlElementId"):(this._controlElement=document.getElementById(t.controlElementId),this._controlElement||this.warn("Can't find control element: '"+t.controlElementId+"' - will create plugin without control element")),this._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(e=>{this._sectionPlaneCreated(e)}))}setDragSensitivity(e){this._dragSensitivity=e||1}getDragSensitivity(){return this._dragSensitivity}setOverviewVisible(e){this._overview&&this._overview.setVisible(e)}getOverviewVisible(){if(this._overview)return this._overview.getVisible()}get sectionPlanes(){return this._sectionPlanes}createSectionPlane(e={}){void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);return new br(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0})}_sectionPlaneCreated(e){const t=this._freeControls.length>0?this._freeControls.pop():new KP(this);t._setSectionPlane(e),t.setVisible(!1),this._controls[e.id]=t,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(()=>{this._sectionPlaneDestroyed(e)}))}flipSectionPlanes(){const e=this.viewer.scene.sectionPlanes;for(let t in e){e[t].flipDir()}}showControl(e){const t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}getShownControl(){return this._shownControlId}hideControl(){for(let e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}destroySectionPlane(e){let t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}_sectionPlaneDestroyed(e){this._overview&&this._overview.removeSectionPlane(e);const t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}clear(){const e=Object.keys(this._sectionPlanes);for(let t=0,i=e.length;t>5&31)/31,l=(e>>10&31)/31):(n=h,a=c,l=u),(y&&n!==p||a!==f||l!==g)&&(null!==p&&(m=!0),p=n,f=a,g=l)}for(let e=1;e<=3;e++){let i=t+12*e;v.push(r.getFloat32(i,!0)),v.push(r.getFloat32(i+4,!0)),v.push(r.getFloat32(i+8,!0)),b.push(o,B,x),d&&A.push(n,a,l,1)}y&&m&&(nC(i,v,b,A,_,s),v=[],b=[],A=A?[]:null,m=!1)}v.length>0&&nC(i,v,b,A,_,s)}function oC(e,t,i,s){const r=/facet([\s\S]*?)endfacet/g;let o=0;const n=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,a=new RegExp("vertex"+n+n+n,"g"),l=new RegExp("normal"+n+n+n,"g"),A=[],h=[];let c,u,d,p,f,g,m;for(;null!==(p=r.exec(t));){for(f=0,g=0,m=p[0];null!==(p=l.exec(m));)c=parseFloat(p[1]),u=parseFloat(p[2]),d=parseFloat(p[3]),g++;for(;null!==(p=a.exec(m));)A.push(parseFloat(p[1]),parseFloat(p[2]),parseFloat(p[3])),h.push(c,u,d),f++;1!==g&&e.error("Error in normal of face "+o),3!==f&&e.error("Error in positions of face "+o),o++}nC(i,A,h,null,new Rr(i,{roughness:.5}),s)}function nC(e,t,i,s,r,o){const n=new Int32Array(t.length/3);for(let e=0,t=n.length;e0?i:null,s=s&&s.length>0?s:null,o.smoothNormals&&d.faceToVertexNormals(t,i,o);const a=tC;J(t,t,a);const l=new Gt(e,{primitive:"triangles",positions:t,normals:i,colors:s,indices:n}),A=new dr(e,{origin:0!==a[0]||0!==a[1]||0!==a[2]?a:null,geometry:l,material:r,edges:o.edges});e.addChild(A)}function aC(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,s=e.length;i0){const i=document.createElement("a");i.href="#",i.id=`switch-${e.nodeId}`,i.textContent="+",i.classList.add("plus"),t&&i.addEventListener("click",t),o.appendChild(i)}const n=document.createElement("input");n.id=`checkbox-${e.nodeId}`,n.type="checkbox",n.checked=e.checked,n.style["pointer-events"]="all",i&&n.addEventListener("change",i),o.appendChild(n);const a=document.createElement("span");return a.textContent=e.title,o.appendChild(a),s&&(a.oncontextmenu=s),r&&(a.onclick=r),o}createDisabledNodeElement(e){const t=document.createElement("li"),i=document.createElement("a");i.href="#",i.textContent="!",i.classList.add("warn"),i.classList.add("warning"),t.appendChild(i);const s=document.createElement("span");return s.textContent=e,t.appendChild(s),t}addChildren(e,t){const i=document.createElement("ul");t.forEach((e=>{i.appendChild(e)})),e.parentElement.appendChild(i)}expand(e,t,i){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",i)}collapse(e,t,i){if(!e)return;const s=e.parentElement;if(!s)return;const r=s.querySelector("ul");r&&(s.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",i),e.addEventListener("click",t))}isExpanded(e){return void 0!==e.parentElement.getElementsByTagName("li")[0]}getId(e){return e.parentElement.id}getIdFromCheckbox(e){return e.id.replace("checkbox-","")}getSwitchElement(e){return document.getElementById(`switch-${e}`)}isChecked(e){return e.checked}setCheckbox(e,t){const i=document.getElementById(`checkbox-${e}`);i&&t!==i.checked&&(i.checked=t)}setXRayed(e,t){const i=document.getElementById(e);i&&(t?i.classList.add("xrayed-node"):i.classList.remove("xrayed-node"))}setHighlighted(e,t){const i=document.getElementById(e);i&&(t?(i.scrollIntoView({block:"center"}),i.classList.add("highlighted-node")):i.classList.remove("highlighted-node"))}}const cC=[];class uC extends z{constructor(e,t={}){super("TreeViewPlugin",e),this.errors=[],this.valid=!0;const i=t.containerElement||document.getElementById(t.containerElementId);if(i instanceof HTMLElement){for(let e=0;;e++)if(!cC[e]){cC[e]=this,this._index=e,this._id=`tree-${e}`;break}if(this._containerElement=i,this._metaModels={},this._autoAddModels=!1!==t.autoAddModels,this._autoExpandDepth=t.autoExpandDepth||0,this._sortNodes=!1!==t.sortNodes,this._viewer=e,this._rootElement=null,this._muteSceneEvents=!1,this._muteTreeEvents=!1,this._rootNodes=[],this._objectNodes={},this._nodeNodes={},this._rootNames={},this._sortNodes=t.sortNodes,this._pruneEmptyNodes=t.pruneEmptyNodes,this._showListItemElementId=null,this._renderService=t.renderService||new hC,!this._renderService)throw new Error("TreeViewPlugin: no render service set");if(this._containerElement.oncontextmenu=e=>{e.preventDefault()},this._onObjectVisibility=this._viewer.scene.on("objectVisibility",(e=>{if(this._muteSceneEvents)return;const t=e.id,i=this._objectNodes[t];if(!i)return;const s=e.visible;if(!(s!==i.checked))return;this._muteTreeEvents=!0,i.checked=s,s?i.numVisibleEntities++:i.numVisibleEntities--,this._renderService.setCheckbox(i.nodeId,s);let r=i.parent;for(;r;)r.checked=s,s?r.numVisibleEntities++:r.numVisibleEntities--,this._renderService.setCheckbox(r.nodeId,r.numVisibleEntities>0),r=r.parent;this._muteTreeEvents=!1})),this._onObjectXrayed=this._viewer.scene.on("objectXRayed",(e=>{if(this._muteSceneEvents)return;const t=e.id,i=this._objectNodes[t];if(!i)return;this._muteTreeEvents=!0;const s=e.xrayed;s!==i.xrayed&&(i.xrayed=s,this._renderService.setXRayed(i.nodeId,s),this._muteTreeEvents=!1)})),this._switchExpandHandler=e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this._expandSwitchElement(t)},this._switchCollapseHandler=e=>{e.preventDefault(),e.stopPropagation();const t=e.target;this._collapseSwitchElement(t)},this._checkboxChangeHandler=e=>{if(this._muteTreeEvents)return;this._muteSceneEvents=!0;const t=e.target,i=this._renderService.isChecked(t),s=this._renderService.getIdFromCheckbox(t),r=this._nodeNodes[s],o=this._viewer.scene.objects;let n=0;this._withNodeTree(r,(e=>{const t=e.objectId,s=o[t],r=0===e.children.length;e.numVisibleEntities=i?e.numEntities:0,r&&i!==e.checked&&n++,e.checked=i,this._renderService.setCheckbox(e.nodeId,i),s&&(s.visible=i)}));let a=r.parent;for(;a;)a.checked=i,i?a.numVisibleEntities+=n:a.numVisibleEntities-=n,this._renderService.setCheckbox(a.nodeId,a.numVisibleEntities>0),a=a.parent;this._muteSceneEvents=!1},this._hierarchy=t.hierarchy||"containment",this._autoExpandDepth=t.autoExpandDepth||0,this._autoAddModels){const e=Object.keys(this.viewer.metaScene.metaModels);for(let t=0,i=e.length;t{this.viewer.metaScene.metaModels[e]&&this.addModel(e)}))}this.hierarchy=t.hierarchy}else this.error("Mandatory config expected: valid containerElementId or containerElement")}set hierarchy(e){"containment"!==(e=e||"containment")&&"storeys"!==e&&"types"!==e&&(this.error("Unsupported value for `hierarchy' - defaulting to 'containment'"),e="containment"),this._hierarchy!==e&&(this._hierarchy=e,this._createNodes())}get hierarchy(){return this._hierarchy}addModel(e,t={}){if(!this._containerElement)return;const i=this.viewer.scene.models[e];if(!i)throw"Model not found: "+e;const s=this.viewer.metaScene.metaModels[e];s?this._metaModels[e]?this.warn("Model already added: "+e):(this._metaModels[e]=s,t&&t.rootName&&(this._rootNames[e]=t.rootName),i.on("destroyed",(()=>{this.removeModel(i.id)})),this._createNodes()):this.error("MetaModel not found: "+e)}removeModel(e){if(!this._containerElement)return;this._metaModels[e]&&(this._rootNames[e]&&delete this._rootNames[e],delete this._metaModels[e],this._createNodes())}showNode(e){this.unShowNode();const t=this._objectNodes[e];if(!t)return;const i=t.nodeId,s=this._renderService.getSwitchElement(i);if(s)return this._expandSwitchElement(s),s.scrollIntoView(),!0;const r=[];r.unshift(t);let o=t.parent;for(;o;)r.unshift(o),o=o.parent;for(let e=0,t=r.length;e{if(s===e)return;const r=this._renderService.getSwitchElement(i.nodeId);if(r){this._expandSwitchElement(r);const e=i.children;for(var o=0,n=e.length;o0;return this.valid}_validateMetaModelForStoreysHierarchy(e=0,t,i){return!0}_createEnabledNodes(){switch(this._pruneEmptyNodes&&this._findEmptyNodes(),this._hierarchy){case"storeys":this._createStoreysNodes(),0===this._rootNodes.length&&this.error("Failed to build storeys hierarchy");break;case"types":this._createTypesNodes();break;default:this._createContainmentNodes()}this._sortNodes&&this._doSortNodes(),this._synchNodesToEntities(),this._createTrees(),this.expandToDepth(this._autoExpandDepth)}_createDisabledNodes(){const e=this._renderService.createRootNode();this._rootElement=e,this._containerElement.appendChild(e);const t=this._viewer.metaScene.rootMetaObjects;for(let i in t){const s=t[i],r=s.type,o=s.name,n=o&&""!==o&&"Undefined"!==o&&"Default"!==o?o:r,a=this._renderService.createDisabledNodeElement(n);e.appendChild(a)}}_findEmptyNodes(){const e=this._viewer.metaScene.rootMetaObjects;for(let t in e)this._findEmptyNodes2(e[t])}_findEmptyNodes2(e,t=0){const i=this.viewer.scene,s=e.children,r=e.id,o=i.objects[r];if(e._countEntities=0,o&&e._countEntities++,s)for(let t=0,i=s.length;t{e.aabb&&r.aabb||(e.aabb||(e.aabb=t.getAABB(s.getObjectIDsInSubtree(e.objectId))),r.aabb||(r.aabb=t.getAABB(s.getObjectIDsInSubtree(r.objectId))));let o=0;return o=i.xUp?0:i.yUp?1:2,e.aabb[o]>r.aabb[o]?-1:e.aabb[o]s?1:0}_synchNodesToEntities(){const e=Object.keys(this.viewer.metaScene.metaObjects),t=this._viewer.metaScene.metaObjects,i=this._viewer.scene.objects;for(let s=0,r=e.length;sthis._createNodeElement(e))),t=this._renderService.createRootNode();e.forEach((e=>{t.appendChild(e)})),this._containerElement.appendChild(t),this._rootElement=t}_createNodeElement(e){return this._renderService.createNodeElement(e,this._switchExpandHandler,this._checkboxChangeHandler,(t=>{this.fire("contextmenu",{event:t,viewer:this._viewer,treeViewPlugin:this,treeViewNode:e}),t.preventDefault()}),(t=>{this.fire("nodeTitleClicked",{event:t,viewer:this._viewer,treeViewPlugin:this,treeViewNode:e}),t.preventDefault()}))}_expandSwitchElement(e){if(this._renderService.isExpanded(e))return;const t=this._renderService.getId(e),i=this._nodeNodes[t].children.map((e=>this._createNodeElement(e)));this._renderService.addChildren(e,i),this._renderService.expand(e,this._switchExpandHandler,this._switchCollapseHandler)}_collapseNode(e){const t=this._renderService.getSwitchElement(e);this._collapseSwitchElement(t)}_collapseSwitchElement(e){this._renderService.collapse(e,this._switchExpandHandler,this._switchCollapseHandler)}}class dC{constructor(e){this._scene=e,this._objects=[],this._objectsViewCulled=[],this._objectsDetailCulled=[],this._objectsChanged=[],this._objectsChangedList=[],this._modelInfos={},this._numObjects=0,this._lenObjectsChangedList=0,this._dirty=!0,this._onModelLoaded=e.on("modelLoaded",(t=>{const i=e.models[t];i&&this._addModel(i)})),this._onTick=e.on("tick",(()=>{this._dirty&&this._build(),this._applyChanges()}))}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._dirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._dirty=!0)}_build(){if(!this._dirty)return;this._applyChanges();const e=this._scene.objects;for(let e=0;e0){for(let e=0;e{delete pC[t],i._destroy()}))),i}(e.scene),this._maxTreeDepth=t.maxTreeDepth||8,this._modelInfos={},this._frustum=new N,this._kdRoot=null,this._frustumDirty=!1,this._kdTreeDirty=!1,this._onViewMatrix=e.scene.camera.on("viewMatrix",(()=>{this._frustumDirty=!0})),this._onProjMatrix=e.scene.camera.on("projMatMatrix",(()=>{this._frustumDirty=!0})),this._onModelLoaded=e.scene.on("modelLoaded",(e=>{const t=this.viewer.scene.models[e];t&&this._addModel(t)})),this._onSceneTick=e.scene.on("tick",(()=>{this._doCull()}))}set enabled(e){this._enabled=e}get enabled(){return this._enabled}_addModel(e){const t={model:e,onDestroyed:e.on("destroyed",(()=>{this._removeModel(e)}))};this._modelInfos[e.id]=t,this._kdTreeDirty=!0}_removeModel(e){const t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._kdTreeDirty=!0)}_doCull(){const e=this._frustumDirty||this._kdTreeDirty;if(this._frustumDirty&&this._buildFrustum(),this._kdTreeDirty&&this._buildKDTree(),e){const e=this._kdRoot;e&&this._visitKDNode(e)}}_buildFrustum(){const e=this.viewer.scene.camera;Q(this._frustum,e.viewMatrix,e.projMatrix),this._frustumDirty=!1}_buildKDTree(){const e=this.viewer.scene;this._kdRoot,this._kdRoot={aabb:e.getAABB(),intersection:N.INTERSECT};for(let e=0,t=this._objectCullStates.numObjects;e=this._maxTreeDepth)return e.objects=e.objects||[],e.objects.push(i),void d.expandAABB3(e.aabb,r);if(e.left&&d.containsAABB3(e.left.aabb,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1);if(e.right&&d.containsAABB3(e.right.aabb,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1);const o=e.aabb;fC[0]=o[3]-o[0],fC[1]=o[4]-o[1],fC[2]=o[5]-o[2];let n=0;if(fC[1]>fC[n]&&(n=1),fC[2]>fC[n]&&(n=2),!e.left){const a=o.slice();if(a[n+3]=(o[n]+o[n+3])/2,e.left={aabb:a,intersection:N.INTERSECT},d.containsAABB3(a,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1)}if(!e.right){const a=o.slice();if(a[n]=(o[n]+o[n+3])/2,e.right={aabb:a,intersection:N.INTERSECT},d.containsAABB3(a,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1)}e.objects=e.objects||[],e.objects.push(i),d.expandAABB3(e.aabb,r)}_visitKDNode(e,t=N.INTERSECT){if(t!==N.INTERSECT&&e.intersects===t)return;t===N.INTERSECT&&(t=V(this._frustum,e.aabb),e.intersects=t);const i=t===N.OUTSIDE,s=e.objects;if(s&&s.length>0)for(let e=0,t=s.length;e{t(e)}),(function(e){i(e)}))}getMetaModel(e,t,i){y.loadJSON(e,(e=>{t(e)}),(function(e){i(e)}))}getXKT(e,t,i){var s=()=>{};t=t||s,i=i||s;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var o=r[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),i=new Uint8Array(e);for(var n=0;n=0;)e[t]=0}const i=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),s=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),o=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),n=new Array(576);t(n);const a=new Array(60);t(a);const l=new Array(512);t(l);const A=new Array(256);t(A);const h=new Array(29);t(h);const c=new Array(30);function u(e,t,i,s,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=s,this.max_length=r,this.has_stree=e&&e.length}let d,p,f;function g(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}t(c);const m=e=>e<256?l[e]:l[256+(e>>>7)],_=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},v=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<{v(e,i[2*t],i[2*t+1])},y=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},B=(e,t,i)=>{const s=new Array(16);let r,o,n=0;for(r=1;r<=15;r++)n=n+i[r-1]<<1,s[r]=n;for(o=0;o<=t;o++){let t=e[2*o+1];0!==t&&(e[2*o]=y(s[t]++,t))}},x=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},w=e=>{e.bi_valid>8?_(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},P=(e,t,i,s)=>{const r=2*t,o=2*i;return e[r]{const s=e.heap[i];let r=i<<1;for(;r<=e.heap_len&&(r{let o,n,a,l,u=0;if(0!==e.sym_next)do{o=255&e.pending_buf[e.sym_buf+u++],o+=(255&e.pending_buf[e.sym_buf+u++])<<8,n=e.pending_buf[e.sym_buf+u++],0===o?b(e,n,t):(a=A[n],b(e,a+256+1,t),l=i[a],0!==l&&(n-=h[a],v(e,n,l)),o--,a=m(o),b(e,a,r),l=s[a],0!==l&&(o-=c[a],v(e,o,l)))}while(u{const i=t.dyn_tree,s=t.stat_desc.static_tree,r=t.stat_desc.has_stree,o=t.stat_desc.elems;let n,a,l,A=-1;for(e.heap_len=0,e.heap_max=573,n=0;n>1;n>=1;n--)C(e,i,n);l=o;do{n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],C(e,i,1),a=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=a,i[2*l]=i[2*n]+i[2*a],e.depth[l]=(e.depth[n]>=e.depth[a]?e.depth[n]:e.depth[a])+1,i[2*n+1]=i[2*a+1]=l,e.heap[1]=l++,C(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,s=t.max_code,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,n=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,l=t.stat_desc.max_length;let A,h,c,u,d,p,f=0;for(u=0;u<=15;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,A=e.heap_max+1;A<573;A++)h=e.heap[A],u=i[2*i[2*h+1]+1]+1,u>l&&(u=l,f++),i[2*h+1]=u,h>s||(e.bl_count[u]++,d=0,h>=a&&(d=n[h-a]),p=i[2*h],e.opt_len+=p*(u+d),o&&(e.static_len+=p*(r[2*h+1]+d)));if(0!==f){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,f-=2}while(f>0);for(u=l;0!==u;u--)for(h=e.bl_count[u];0!==h;)c=e.heap[--A],c>s||(i[2*c+1]!==u&&(e.opt_len+=(u-i[2*c+1])*i[2*c],i[2*c+1]=u),h--)}})(e,t),B(i,A,e.bl_count)},E=(e,t,i)=>{let s,r,o=-1,n=t[1],a=0,l=7,A=4;for(0===n&&(l=138,A=3),t[2*(i+1)+1]=65535,s=0;s<=i;s++)r=n,n=t[2*(s+1)+1],++a{let s,r,o=-1,n=t[1],a=0,l=7,A=4;for(0===n&&(l=138,A=3),s=0;s<=i;s++)if(r=n,n=t[2*(s+1)+1],!(++a{v(e,0+(s?1:0),3),w(e),_(e,i),_(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var T={_tr_init:e=>{D||((()=>{let e,t,o,g,m;const _=new Array(16);for(o=0,g=0;g<28;g++)for(h[g]=o,e=0;e<1<>=7;g<30;g++)for(c[g]=m<<7,e=0;e<1<{let r,l,A=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),F(e,e.l_desc),F(e,e.d_desc),A=(e=>{let t;for(E(e,e.dyn_ltree,e.l_desc.max_code),E(e,e.dyn_dtree,e.d_desc.max_code),F(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*o[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),r=e.opt_len+3+7>>>3,l=e.static_len+3+7>>>3,l<=r&&(r=l)):r=l=i+5,i+4<=r&&-1!==t?S(e,t,i,s):4===e.strategy||l===r?(v(e,2+(s?1:0),3),M(e,n,a)):(v(e,4+(s?1:0),3),((e,t,i,s)=>{let r;for(v(e,t-257,5),v(e,i-1,5),v(e,s-4,4),r=0;r(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(A[i]+256+1)]++,e.dyn_dtree[2*m(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{v(e,2,3),b(e,256,n),(e=>{16===e.bi_valid?(_(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}},R=(e,t,i,s)=>{let r=65535&e|0,o=e>>>16&65535|0,n=0;for(;0!==i;){n=i>2e3?2e3:i,i-=n;do{r=r+t[s++]|0,o=o+r|0}while(--n);r%=65521,o%=65521}return r|o<<16|0};const L=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var U=(e,t,i,s)=>{const r=L,o=s+i;e^=-1;for(let i=s;i>>8^r[255&(e^t[i])];return-1^e},k={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},O={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:N,_tr_stored_block:Q,_tr_flush_block:V,_tr_tally:H,_tr_align:j}=T,{Z_NO_FLUSH:G,Z_PARTIAL_FLUSH:z,Z_FULL_FLUSH:W,Z_FINISH:K,Z_BLOCK:X,Z_OK:J,Z_STREAM_END:Y,Z_STREAM_ERROR:Z,Z_DATA_ERROR:q,Z_BUF_ERROR:$,Z_DEFAULT_COMPRESSION:ee,Z_FILTERED:te,Z_HUFFMAN_ONLY:ie,Z_RLE:se,Z_FIXED:re,Z_DEFAULT_STRATEGY:oe,Z_UNKNOWN:ne,Z_DEFLATED:ae}=O,le=258,Ae=262,he=42,ce=113,ue=666,de=(e,t)=>(e.msg=k[t],t),pe=e=>2*e-(e>4?9:0),fe=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ge=e=>{let t,i,s,r=e.w_size;t=e.hash_size,s=t;do{i=e.head[--s],e.head[s]=i>=r?i-r:0}while(--t);t=r,s=t;do{i=e.prev[--s],e.prev[s]=i>=r?i-r:0}while(--t)};let me=(e,t,i)=>(t<{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},ve=(e,t)=>{V(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,_e(e.strm)},be=(e,t)=>{e.pending_buf[e.pending++]=t},ye=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Be=(e,t,i,s)=>{let r=e.avail_in;return r>s&&(r=s),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=R(e.adler,t,r,i):2===e.state.wrap&&(e.adler=U(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},xe=(e,t)=>{let i,s,r=e.max_chain_length,o=e.strstart,n=e.prev_length,a=e.nice_match;const l=e.strstart>e.w_size-Ae?e.strstart-(e.w_size-Ae):0,A=e.window,h=e.w_mask,c=e.prev,u=e.strstart+le;let d=A[o+n-1],p=A[o+n];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(i=t,A[i+n]===p&&A[i+n-1]===d&&A[i]===A[o]&&A[++i]===A[o+1]){o+=2,i++;do{}while(A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&A[++o]===A[++i]&&on){if(e.match_start=t,n=s,s>=a)break;d=A[o+n-1],p=A[o+n]}}}while((t=c[t&h])>l&&0!=--r);return n<=e.lookahead?n:e.lookahead},we=e=>{const t=e.w_size;let i,s,r;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Ae)&&(e.window.set(e.window.subarray(t,t+t-s),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),ge(e),s+=t),0===e.strm.avail_in)break;if(i=Be(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=i,e.lookahead+e.insert>=3)for(r=e.strstart-e.insert,e.ins_h=e.window[r],e.ins_h=me(e,e.ins_h,e.window[r+1]);e.insert&&(e.ins_h=me(e,e.ins_h,e.window[r+3-1]),e.prev[r&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=r,r++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead{let i,s,r,o=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_outs+e.strm.avail_in&&(i=s+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,_e(e.strm),s&&(s>i&&(s=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,i-=s),i&&(Be(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===n);return a-=e.strm.avail_in,a&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Be(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,o=r>e.w_size?e.w_size:r,s=e.strstart-e.block_start,(s>=o||(s||t===K)&&t!==G&&0===e.strm.avail_in&&s<=r)&&(i=s>r?r:s,n=t===K&&0===e.strm.avail_in&&i===s?1:0,Q(e,e.block_start,i,n),e.block_start+=i,_e(e.strm)),n?3:1)},Ce=(e,t)=>{let i,s;for(;;){if(e.lookahead=3&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-Ae&&(e.match_length=xe(e,i)),e.match_length>=3)if(s=H(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=me(e,e.ins_h,e.window[e.strstart+1]);else s=H(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(ve(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===K?(ve(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ve(e,!1),0===e.strm.avail_out)?1:2},Me=(e,t)=>{let i,s,r;for(;;){if(e.lookahead=3&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,s=H(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=me(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,s&&(ve(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(s=H(e,0,e.window[e.strstart-1]),s&&ve(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=H(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===K?(ve(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ve(e,!1),0===e.strm.avail_out)?1:2};function Fe(e,t,i,s,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=s,this.func=r}const Ee=[new Fe(0,0,0,0,Pe),new Fe(4,4,8,4,Ce),new Fe(4,5,16,8,Ce),new Fe(4,6,32,32,Ce),new Fe(4,4,16,16,Me),new Fe(8,16,32,32,Me),new Fe(8,16,128,128,Me),new Fe(8,32,128,256,Me),new Fe(32,128,258,1024,Me),new Fe(32,258,258,4096,Me)];function Ie(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ae,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),fe(this.dyn_ltree),fe(this.dyn_dtree),fe(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),fe(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),fe(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const De=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==he&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==ce&&t.status!==ue?1:0},Se=e=>{if(De(e))return de(e,Z);e.total_in=e.total_out=0,e.data_type=ne;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?he:ce,e.adler=2===t.wrap?0:1,t.last_flush=-2,N(t),J},Te=e=>{const t=Se(e);var i;return t===J&&((i=e.state).window_size=2*i.w_size,fe(i.head),i.max_lazy_match=Ee[i.level].max_lazy,i.good_match=Ee[i.level].good_length,i.nice_match=Ee[i.level].nice_length,i.max_chain_length=Ee[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Re=(e,t,i,s,r,o)=>{if(!e)return Z;let n=1;if(t===ee&&(t=6),s<0?(n=0,s=-s):s>15&&(n=2,s-=16),r<1||r>9||i!==ae||s<8||s>15||t<0||t>9||o<0||o>re||8===s&&1!==n)return de(e,Z);8===s&&(s=9);const a=new Ie;return e.state=a,a.strm=e,a.status=he,a.wrap=n,a.gzhead=null,a.w_bits=s,a.w_size=1<De(e)||2!==e.state.wrap?Z:(e.state.gzhead=t,J),ke=(e,t)=>{if(De(e)||t>X||t<0)return e?de(e,Z):Z;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===ue&&t!==K)return de(e,0===e.avail_out?$:Z);const s=i.last_flush;if(i.last_flush=t,0!==i.pending){if(_e(e),0===e.avail_out)return i.last_flush=-1,J}else if(0===e.avail_in&&pe(t)<=pe(s)&&t!==K)return de(e,$);if(i.status===ue&&0!==e.avail_in)return de(e,$);if(i.status===he&&0===i.wrap&&(i.status=ce),i.status===he){let t=ae+(i.w_bits-8<<4)<<8,s=-1;if(s=i.strategy>=ie||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=s<<6,0!==i.strstart&&(t|=32),t+=31-t%31,ye(i,t),0!==i.strstart&&(ye(i,e.adler>>>16),ye(i,65535&e.adler)),e.adler=1,i.status=ce,_e(e),0!==i.pending)return i.last_flush=-1,J}if(57===i.status)if(e.adler=0,be(i,31),be(i,139),be(i,8),i.gzhead)be(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),be(i,255&i.gzhead.time),be(i,i.gzhead.time>>8&255),be(i,i.gzhead.time>>16&255),be(i,i.gzhead.time>>24&255),be(i,9===i.level?2:i.strategy>=ie||i.level<2?4:0),be(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(be(i,255&i.gzhead.extra.length),be(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=U(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(be(i,0),be(i,0),be(i,0),be(i,0),be(i,0),be(i,9===i.level?2:i.strategy>=ie||i.level<2?4:0),be(i,3),i.status=ce,_e(e),0!==i.pending)return i.last_flush=-1,J;if(69===i.status){if(i.gzhead.extra){let t=i.pending,s=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+s>i.pending_buf_size;){let r=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=U(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=r,_e(e),0!==i.pending)return i.last_flush=-1,J;t=0,s-=r}let r=new Uint8Array(i.gzhead.extra);i.pending_buf.set(r.subarray(i.gzindex,i.gzindex+s),i.pending),i.pending+=s,i.gzhead.hcrc&&i.pending>t&&(e.adler=U(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,s=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>s&&(e.adler=U(e.adler,i.pending_buf,i.pending-s,s)),_e(e),0!==i.pending)return i.last_flush=-1,J;s=0}t=i.gzindexs&&(e.adler=U(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,s=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>s&&(e.adler=U(e.adler,i.pending_buf,i.pending-s,s)),_e(e),0!==i.pending)return i.last_flush=-1,J;s=0}t=i.gzindexs&&(e.adler=U(e.adler,i.pending_buf,i.pending-s,s))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(_e(e),0!==i.pending))return i.last_flush=-1,J;be(i,255&e.adler),be(i,e.adler>>8&255),e.adler=0}if(i.status=ce,_e(e),0!==i.pending)return i.last_flush=-1,J}if(0!==e.avail_in||0!==i.lookahead||t!==G&&i.status!==ue){let s=0===i.level?Pe(i,t):i.strategy===ie?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(we(e),0===e.lookahead)){if(t===G)return 1;break}if(e.match_length=0,i=H(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(ve(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===K?(ve(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ve(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===se?((e,t)=>{let i,s,r,o;const n=e.window;for(;;){if(e.lookahead<=le){if(we(e),e.lookahead<=le&&t===G)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(r=e.strstart-1,s=n[r],s===n[++r]&&s===n[++r]&&s===n[++r])){o=e.strstart+le;do{}while(s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&s===n[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=H(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=H(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(ve(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===K?(ve(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(ve(e,!1),0===e.strm.avail_out)?1:2})(i,t):Ee[i.level].func(i,t);if(3!==s&&4!==s||(i.status=ue),1===s||3===s)return 0===e.avail_out&&(i.last_flush=-1),J;if(2===s&&(t===z?j(i):t!==X&&(Q(i,0,0,!1),t===W&&(fe(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),_e(e),0===e.avail_out))return i.last_flush=-1,J}return t!==K?J:i.wrap<=0?Y:(2===i.wrap?(be(i,255&e.adler),be(i,e.adler>>8&255),be(i,e.adler>>16&255),be(i,e.adler>>24&255),be(i,255&e.total_in),be(i,e.total_in>>8&255),be(i,e.total_in>>16&255),be(i,e.total_in>>24&255)):(ye(i,e.adler>>>16),ye(i,65535&e.adler)),_e(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?J:Y)},Oe=e=>{if(De(e))return Z;const t=e.state.status;return e.state=null,t===ce?de(e,q):J},Ne=(e,t)=>{let i=t.length;if(De(e))return Z;const s=e.state,r=s.wrap;if(2===r||1===r&&s.status!==he||s.lookahead)return Z;if(1===r&&(e.adler=R(e.adler,t,i,0)),s.wrap=0,i>=s.w_size){0===r&&(fe(s.head),s.strstart=0,s.block_start=0,s.insert=0);let e=new Uint8Array(s.w_size);e.set(t.subarray(i-s.w_size,i),0),t=e,i=s.w_size}const o=e.avail_in,n=e.next_in,a=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,we(s);s.lookahead>=3;){let e=s.strstart,t=s.lookahead-2;do{s.ins_h=me(s,s.ins_h,s.window[e+3-1]),s.prev[e&s.w_mask]=s.head[s.ins_h],s.head[s.ins_h]=e,e++}while(--t);s.strstart=e,s.lookahead=2,we(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=2,s.match_available=0,e.next_in=n,e.input=a,e.avail_in=o,s.wrap=r,J};const Qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Ve=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Qe(i,t)&&(e[t]=i[t])}}return e},He=e=>{let t=0;for(let i=0,s=e.length;i=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Ge[254]=Ge[254]=1;var ze=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,s,r,o,n=e.length,a=0;for(r=0;r>>6,t[o++]=128|63&i):i<65536?(t[o++]=224|i>>>12,t[o++]=128|i>>>6&63,t[o++]=128|63&i):(t[o++]=240|i>>>18,t[o++]=128|i>>>12&63,t[o++]=128|i>>>6&63,t[o++]=128|63&i);return t},We=(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let s,r;const o=new Array(2*i);for(r=0,s=0;s4)o[r++]=65533,s+=n-1;else{for(t&=2===n?31:3===n?15:7;n>1&&s1?o[r++]=65533:t<65536?o[r++]=t:(t-=65536,o[r++]=55296|t>>10&1023,o[r++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&je)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let s=0;s{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Ge[e[i]]>t?i:t},Xe=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Je=Object.prototype.toString,{Z_NO_FLUSH:Ye,Z_SYNC_FLUSH:Ze,Z_FULL_FLUSH:qe,Z_FINISH:$e,Z_OK:et,Z_STREAM_END:tt,Z_DEFAULT_COMPRESSION:it,Z_DEFAULT_STRATEGY:st,Z_DEFLATED:rt}=O;function ot(e){this.options=Ve({level:it,method:rt,chunkSize:16384,windowBits:15,memLevel:8,strategy:st},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Xe,this.strm.avail_out=0;let i=Le(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==et)throw new Error(k[i]);if(t.header&&Ue(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?ze(t.dictionary):"[object ArrayBuffer]"===Je.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Ne(this.strm,e),i!==et)throw new Error(k[i]);this._dict_set=!0}}function nt(e,t){const i=new ot(t);if(i.push(e,!0),i.err)throw i.msg||k[i.err];return i.result}ot.prototype.push=function(e,t){const i=this.strm,s=this.options.chunkSize;let r,o;if(this.ended)return!1;for(o=t===~~t?t:!0===t?$e:Ye,"string"==typeof e?i.input=ze(e):"[object ArrayBuffer]"===Je.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),(o===Ze||o===qe)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(r=ke(i,o),r===tt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=Oe(this.strm),this.onEnd(r),this.ended=!0,r===et;if(0!==i.avail_out){if(o>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},ot.prototype.onData=function(e){this.chunks.push(e)},ot.prototype.onEnd=function(e){e===et&&(this.result=He(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var at={Deflate:ot,deflate:nt,deflateRaw:function(e,t){return(t=t||{}).raw=!0,nt(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,nt(e,t)},constants:O};const lt=16209;var At=function(e,t){let i,s,r,o,n,a,l,A,h,c,u,d,p,f,g,m,_,v,b,y,B,x,w,P;const C=e.state;i=e.next_in,w=e.input,s=i+(e.avail_in-5),r=e.next_out,P=e.output,o=r-(t-e.avail_out),n=r+(e.avail_out-257),a=C.dmax,l=C.wsize,A=C.whave,h=C.wnext,c=C.window,u=C.hold,d=C.bits,p=C.lencode,f=C.distcode,g=(1<>>24,u>>>=v,d-=v,v=_>>>16&255,0===v)P[r++]=65535&_;else{if(!(16&v)){if(0==(64&v)){_=p[(65535&_)+(u&(1<>>=v,d-=v),d<15&&(u+=w[i++]<>>24,u>>>=v,d-=v,v=_>>>16&255,!(16&v)){if(0==(64&v)){_=f[(65535&_)+(u&(1<a){e.msg="invalid distance too far back",C.mode=lt;break e}if(u>>>=v,d-=v,v=r-o,y>v){if(v=y-v,v>A&&C.sane){e.msg="invalid distance too far back",C.mode=lt;break e}if(B=0,x=c,0===h){if(B+=l-v,v2;)P[r++]=x[B++],P[r++]=x[B++],P[r++]=x[B++],b-=3;b&&(P[r++]=x[B++],b>1&&(P[r++]=x[B++]))}else{B=r-y;do{P[r++]=P[B++],P[r++]=P[B++],P[r++]=P[B++],b-=3}while(b>2);b&&(P[r++]=P[B++],b>1&&(P[r++]=P[B++]))}break}}break}}while(i>3,i-=b,d-=b<<3,u&=(1<{const l=a.bits;let A,h,c,u,d,p,f=0,g=0,m=0,_=0,v=0,b=0,y=0,B=0,x=0,w=0,P=null;const C=new Uint16Array(16),M=new Uint16Array(16);let F,E,I,D=null;for(f=0;f<=15;f++)C[f]=0;for(g=0;g=1&&0===C[_];_--);if(v>_&&(v=_),0===_)return r[o++]=20971520,r[o++]=20971520,a.bits=1,0;for(m=1;m<_&&0===C[m];m++);for(v0&&(0===e||1!==_))return-1;for(M[1]=0,f=1;f<15;f++)M[f+1]=M[f]+C[f];for(g=0;g852||2===e&&x>592)return 1;for(;;){F=f-y,n[g]+1=p?(E=D[n[g]-p],I=P[n[g]-p]):(E=96,I=0),A=1<>y)+h]=F<<24|E<<16|I|0}while(0!==h);for(A=1<>=1;if(0!==A?(w&=A-1,w+=A):w=0,g++,0==--C[f]){if(f===_)break;f=t[i+n[g]]}if(f>v&&(w&u)!==c){for(0===y&&(y=v),d+=m,b=f-y,B=1<852||2===e&&x>592)return 1;c=w&u,r[c]=v<<24|b<<16|d-o|0}}return 0!==w&&(r[d+w]=f-y<<24|64<<16|0),a.bits=v,0};const{Z_FINISH:ft,Z_BLOCK:gt,Z_TREES:mt,Z_OK:_t,Z_STREAM_END:vt,Z_NEED_DICT:bt,Z_STREAM_ERROR:yt,Z_DATA_ERROR:Bt,Z_MEM_ERROR:xt,Z_BUF_ERROR:wt,Z_DEFLATED:Pt}=O,Ct=16180,Mt=16190,Ft=16191,Et=16192,It=16194,Dt=16199,St=16200,Tt=16206,Rt=16209,Lt=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Ut(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const kt=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Ot=e=>{if(kt(e))return yt;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Ct,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,_t},Nt=e=>{if(kt(e))return yt;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ot(e)},Qt=(e,t)=>{let i;if(kt(e))return yt;const s=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?yt:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,Nt(e))},Vt=(e,t)=>{if(!e)return yt;const i=new Ut;e.state=i,i.strm=e,i.window=null,i.mode=Ct;const s=Qt(e,t);return s!==_t&&(e.state=null),s};let Ht,jt,Gt=!0;const zt=e=>{if(Gt){Ht=new Int32Array(512),jt=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(pt(1,e.lens,0,288,Ht,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;pt(2,e.lens,0,32,jt,0,e.work,{bits:5}),Gt=!1}e.lencode=Ht,e.lenbits=9,e.distcode=jt,e.distbits=5},Wt=(e,t,i,s)=>{let r;const o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(o.window.set(t.subarray(i-o.wsize,i),0),o.wnext=0,o.whave=o.wsize):(r=o.wsize-o.wnext,r>s&&(r=s),o.window.set(t.subarray(i-s,i-s+r),o.wnext),(s-=r)?(o.window.set(t.subarray(i-s,i),0),o.wnext=s,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave{let i,s,r,o,n,a,l,A,h,c,u,d,p,f,g,m,_,v,b,y,B,x,w=0;const P=new Uint8Array(4);let C,M;const F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(kt(e)||!e.output||!e.input&&0!==e.avail_in)return yt;i=e.state,i.mode===Ft&&(i.mode=Et),n=e.next_out,r=e.output,l=e.avail_out,o=e.next_in,s=e.input,a=e.avail_in,A=i.hold,h=i.bits,c=a,u=l,x=_t;e:for(;;)switch(i.mode){case Ct:if(0===i.wrap){i.mode=Et;break}for(;h<16;){if(0===a)break e;a--,A+=s[o++]<>>8&255,i.check=U(i.check,P,2,0),A=0,h=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&A)<<8)+(A>>8))%31){e.msg="incorrect header check",i.mode=Rt;break}if((15&A)!==Pt){e.msg="unknown compression method",i.mode=Rt;break}if(A>>>=4,h-=4,B=8+(15&A),0===i.wbits&&(i.wbits=B),B>15||B>i.wbits){e.msg="invalid window size",i.mode=Rt;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(P[0]=255&A,P[1]=A>>>8&255,i.check=U(i.check,P,2,0)),A=0,h=0,i.mode=16182;case 16182:for(;h<32;){if(0===a)break e;a--,A+=s[o++]<>>8&255,P[2]=A>>>16&255,P[3]=A>>>24&255,i.check=U(i.check,P,4,0)),A=0,h=0,i.mode=16183;case 16183:for(;h<16;){if(0===a)break e;a--,A+=s[o++]<>8),512&i.flags&&4&i.wrap&&(P[0]=255&A,P[1]=A>>>8&255,i.check=U(i.check,P,2,0)),A=0,h=0,i.mode=16184;case 16184:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,A+=s[o++]<>>8&255,i.check=U(i.check,P,2,0)),A=0,h=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(d=i.length,d>a&&(d=a),d&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(s.subarray(o,o+d),B)),512&i.flags&&4&i.wrap&&(i.check=U(i.check,s,d,o)),a-=d,o+=d,i.length-=d),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;d=0;do{B=s[o+d++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B))}while(B&&d>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Ft;break;case 16189:for(;h<32;){if(0===a)break e;a--,A+=s[o++]<>>=7&h,h-=7&h,i.mode=Tt;break}for(;h<3;){if(0===a)break e;a--,A+=s[o++]<>>=1,h-=1,3&A){case 0:i.mode=16193;break;case 1:if(zt(i),i.mode=Dt,t===mt){A>>>=2,h-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=Rt}A>>>=2,h-=2;break;case 16193:for(A>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,A+=s[o++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=Rt;break}if(i.length=65535&A,A=0,h=0,i.mode=It,t===mt)break e;case It:i.mode=16195;case 16195:if(d=i.length,d){if(d>a&&(d=a),d>l&&(d=l),0===d)break e;r.set(s.subarray(o,o+d),n),a-=d,o+=d,l-=d,n+=d,i.length-=d;break}i.mode=Ft;break;case 16196:for(;h<14;){if(0===a)break e;a--,A+=s[o++]<>>=5,h-=5,i.ndist=1+(31&A),A>>>=5,h-=5,i.ncode=4+(15&A),A>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Rt;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[F[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,C={bits:i.lenbits},x=pt(0,i.lens,0,19,i.lencode,0,i.work,C),i.lenbits=C.bits,x){e.msg="invalid code lengths set",i.mode=Rt;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>24,m=w>>>16&255,_=65535&w,!(g<=h);){if(0===a)break e;a--,A+=s[o++]<>>=g,h-=g,i.lens[i.have++]=_;else{if(16===_){for(M=g+2;h>>=g,h-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=Rt;break}B=i.lens[i.have-1],d=3+(3&A),A>>>=2,h-=2}else if(17===_){for(M=g+3;h>>=g,h-=g,B=0,d=3+(7&A),A>>>=3,h-=3}else{for(M=g+7;h>>=g,h-=g,B=0,d=11+(127&A),A>>>=7,h-=7}if(i.have+d>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Rt;break}for(;d--;)i.lens[i.have++]=B}}if(i.mode===Rt)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Rt;break}if(i.lenbits=9,C={bits:i.lenbits},x=pt(1,i.lens,0,i.nlen,i.lencode,0,i.work,C),i.lenbits=C.bits,x){e.msg="invalid literal/lengths set",i.mode=Rt;break}if(i.distbits=6,i.distcode=i.distdyn,C={bits:i.distbits},x=pt(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,C),i.distbits=C.bits,x){e.msg="invalid distances set",i.mode=Rt;break}if(i.mode=Dt,t===mt)break e;case Dt:i.mode=St;case St:if(a>=6&&l>=258){e.next_out=n,e.avail_out=l,e.next_in=o,e.avail_in=a,i.hold=A,i.bits=h,At(e,u),n=e.next_out,r=e.output,l=e.avail_out,o=e.next_in,s=e.input,a=e.avail_in,A=i.hold,h=i.bits,i.mode===Ft&&(i.back=-1);break}for(i.back=0;w=i.lencode[A&(1<>>24,m=w>>>16&255,_=65535&w,!(g<=h);){if(0===a)break e;a--,A+=s[o++]<>v)],g=w>>>24,m=w>>>16&255,_=65535&w,!(v+g<=h);){if(0===a)break e;a--,A+=s[o++]<>>=v,h-=v,i.back+=v}if(A>>>=g,h-=g,i.back+=g,i.length=_,0===m){i.mode=16205;break}if(32&m){i.back=-1,i.mode=Ft;break}if(64&m){e.msg="invalid literal/length code",i.mode=Rt;break}i.extra=15&m,i.mode=16201;case 16201:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;w=i.distcode[A&(1<>>24,m=w>>>16&255,_=65535&w,!(g<=h);){if(0===a)break e;a--,A+=s[o++]<>v)],g=w>>>24,m=w>>>16&255,_=65535&w,!(v+g<=h);){if(0===a)break e;a--,A+=s[o++]<>>=v,h-=v,i.back+=v}if(A>>>=g,h-=g,i.back+=g,64&m){e.msg="invalid distance code",i.mode=Rt;break}i.offset=_,i.extra=15&m,i.mode=16203;case 16203:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Rt;break}i.mode=16204;case 16204:if(0===l)break e;if(d=u-l,i.offset>d){if(d=i.offset-d,d>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Rt;break}d>i.wnext?(d-=i.wnext,p=i.wsize-d):p=i.wnext-d,d>i.length&&(d=i.length),f=i.window}else f=r,p=n-i.offset,d=i.length;d>l&&(d=l),l-=d,i.length-=d;do{r[n++]=f[p++]}while(--d);0===i.length&&(i.mode=St);break;case 16205:if(0===l)break e;r[n++]=i.length,l--,i.mode=St;break;case Tt:if(i.wrap){for(;h<32;){if(0===a)break e;a--,A|=s[o++]<{if(kt(e))return yt;let t=e.state;return t.window&&(t.window=null),e.state=null,_t},Zt=(e,t)=>{if(kt(e))return yt;const i=e.state;return 0==(2&i.wrap)?yt:(i.head=t,t.done=!1,_t)},qt=(e,t)=>{const i=t.length;let s,r,o;return kt(e)?yt:(s=e.state,0!==s.wrap&&s.mode!==Mt?yt:s.mode===Mt&&(r=1,r=R(r,t,i,0),r!==s.check)?Bt:(o=Wt(e,t,i,i),o?(s.mode=16210,xt):(s.havedict=1,_t)))},$t=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ei=Object.prototype.toString,{Z_NO_FLUSH:ti,Z_FINISH:ii,Z_OK:si,Z_STREAM_END:ri,Z_NEED_DICT:oi,Z_STREAM_ERROR:ni,Z_DATA_ERROR:ai,Z_MEM_ERROR:li}=O;function Ai(e){this.options=Ve({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Xe,this.strm.avail_out=0;let i=Xt(this.strm,t.windowBits);if(i!==si)throw new Error(k[i]);if(this.header=new $t,Zt(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=ze(t.dictionary):"[object ArrayBuffer]"===ei.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=qt(this.strm,t.dictionary),i!==si)))throw new Error(k[i])}function hi(e,t){const i=new Ai(t);if(i.push(e),i.err)throw i.msg||k[i.err];return i.result}Ai.prototype.push=function(e,t){const i=this.strm,s=this.options.chunkSize,r=this.options.dictionary;let o,n,a;if(this.ended)return!1;for(n=t===~~t?t:!0===t?ii:ti,"[object ArrayBuffer]"===ei.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(s),i.next_out=0,i.avail_out=s),o=Jt(i,n),o===oi&&r&&(o=qt(i,r),o===si?o=Jt(i,n):o===ai&&(o=oi));i.avail_in>0&&o===ri&&i.state.wrap>0&&0!==e[i.next_in];)Kt(i),o=Jt(i,n);switch(o){case ni:case ai:case oi:case li:return this.onEnd(o),this.ended=!0,!1}if(a=i.avail_out,i.next_out&&(0===i.avail_out||o===ri))if("string"===this.options.to){let e=Ke(i.output,i.next_out),t=i.next_out-e,r=We(i.output,e);i.next_out=t,i.avail_out=s-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(r)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(o!==si||0!==a){if(o===ri)return o=Yt(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ai.prototype.onData=function(e){this.chunks.push(e)},Ai.prototype.onEnd=function(e){e===si&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=He(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ci={Inflate:Ai,inflate:hi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,hi(e,t)},ungzip:hi,constants:O};const{Deflate:ui,deflate:di,deflateRaw:pi,gzip:fi}=at,{Inflate:gi,inflate:mi,inflateRaw:_i,ungzip:vi}=ci;var bi=ui,yi=di,Bi=pi,xi=fi,wi=gi,Pi=mi,Ci=_i,Mi=vi,Fi=O,Ei={Deflate:bi,deflate:yi,deflateRaw:Bi,gzip:xi,Inflate:wi,inflate:Pi,inflateRaw:Ci,ungzip:Mi,constants:Fi};e.Deflate=bi,e.Inflate=wi,e.constants=Fi,e.default=Ei,e.deflate=yi,e.deflateRaw=Bi,e.gzip=xi,e.inflate=Pi,e.inflateRaw=Ci,e.ungzip=Mi,Object.defineProperty(e,"__esModule",{value:!0})}));var _C=Object.freeze({__proto__:null});let vC=window.pako||_C;vC.inflate||(vC=vC.default);const bC=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const yC={version:1,parse:function(e,t,i,s,r,o){const n=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],meshPositions:e[4],meshIndices:e[5],meshEdgesIndices:e[6],meshColors:e[7],entityIDs:e[8],entityMeshes:e[9],entityIsObjects:e[10],positionsDecodeMatrix:e[11]}}(i),a=function(e){return{positions:new Uint16Array(vC.inflate(e.positions).buffer),normals:new Int8Array(vC.inflate(e.normals).buffer),indices:new Uint32Array(vC.inflate(e.indices).buffer),edgeIndices:new Uint32Array(vC.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(vC.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(vC.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(vC.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(vC.inflate(e.meshColors).buffer),entityIDs:vC.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(vC.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(vC.inflate(e.entityIsObjects).buffer),positionsDecodeMatrix:new Float32Array(vC.inflate(e.positionsDecodeMatrix).buffer)}}(n);!function(e,t,i,s,r,o){o.getNextId(),s.positionsCompression="precompressed",s.normalsCompression="precompressed";const n=i.positions,a=i.normals,l=i.indices,A=i.edgeIndices,h=i.meshPositions,c=i.meshIndices,u=i.meshEdgesIndices,p=i.meshColors,f=JSON.parse(i.entityIDs),g=i.entityMeshes,m=i.entityIsObjects,_=h.length,v=g.length;for(let r=0;rg[e]g[t]?1:0));for(let e=0;e1||(F[i]=e)}}for(let e=0;e1,o=EC(m.subarray(4*t,4*t+3)),u=m[4*t+3]/255,_=a.subarray(d[t],i?a.length:d[t+1]),b=l.subarray(d[t],i?l.length:d[t+1]),B=A.subarray(p[t],i?A.length:p[t+1]),w=h.subarray(f[t],i?h.length:f[t+1]),M=c.subarray(g[t],g[t]+16);if(r){const e=`${n}-geometry.${t}`;s.createGeometry({id:e,primitive:"triangles",positionsCompressed:_,normalsCompressed:b,indices:B,edgeIndices:w,positionsDecodeMatrix:M})}else{const e=`${n}-${t}`;v[F[t]];const i={};s.createMesh(y.apply(i,{id:e,primitive:"triangles",positionsCompressed:_,normalsCompressed:b,indices:B,edgeIndices:w,positionsDecodeMatrix:M,color:o,opacity:u}))}}let E=0;for(let e=0;e1){const t={},r=`${n}-instance.${E++}`,o=`${n}-geometry.${i}`,a=16*B[e],A=u.subarray(a,a+16);s.createMesh(y.apply(t,{id:r,geometryId:o,matrix:A})),l.push(r)}else l.push(i)}if(l.length>0){const e={};s.createEntity(y.apply(e,{id:r,isObject:!0,meshIds:l}))}}}(0,0,a,s,0,o)}};let DC=window.pako||_C;DC.inflate||(DC=DC.default);const SC=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const TC={version:5,parse:function(e,t,i,s,r,o){const n=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],eachPrimitivePositionsAndNormalsPortion:e[5],eachPrimitiveIndicesPortion:e[6],eachPrimitiveEdgeIndicesPortion:e[7],eachPrimitiveColor:e[8],primitiveInstances:e[9],eachEntityId:e[10],eachEntityPrimitiveInstancesPortion:e[11],eachEntityMatricesPortion:e[12]}}(i),a=function(e){return{positions:new Float32Array(DC.inflate(e.positions).buffer),normals:new Int8Array(DC.inflate(e.normals).buffer),indices:new Uint32Array(DC.inflate(e.indices).buffer),edgeIndices:new Uint32Array(DC.inflate(e.edgeIndices).buffer),matrices:new Float32Array(DC.inflate(e.matrices).buffer),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(DC.inflate(e.eachPrimitivePositionsAndNormalsPortion).buffer),eachPrimitiveIndicesPortion:new Uint32Array(DC.inflate(e.eachPrimitiveIndicesPortion).buffer),eachPrimitiveEdgeIndicesPortion:new Uint32Array(DC.inflate(e.eachPrimitiveEdgeIndicesPortion).buffer),eachPrimitiveColor:new Uint8Array(DC.inflate(e.eachPrimitiveColor).buffer),primitiveInstances:new Uint32Array(DC.inflate(e.primitiveInstances).buffer),eachEntityId:DC.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(DC.inflate(e.eachEntityPrimitiveInstancesPortion).buffer),eachEntityMatricesPortion:new Uint32Array(DC.inflate(e.eachEntityMatricesPortion).buffer)}}(n);!function(e,t,i,s,r,o){const n=o.getNextId();s.positionsCompression="disabled",s.normalsCompression="precompressed";const a=i.positions,l=i.normals,A=i.indices,h=i.edgeIndices,c=i.matrices,u=i.eachPrimitivePositionsAndNormalsPortion,d=i.eachPrimitiveIndicesPortion,p=i.eachPrimitiveEdgeIndicesPortion,f=i.eachPrimitiveColor,g=i.primitiveInstances,m=JSON.parse(i.eachEntityId),_=i.eachEntityPrimitiveInstancesPortion,v=i.eachEntityMatricesPortion,b=u.length,B=g.length,x=new Uint8Array(b),w=m.length;for(let e=0;e1||(P[i]=e)}}for(let e=0;e1,r=SC(f.subarray(4*e,4*e+3)),o=f[4*e+3]/255,c=a.subarray(u[e],t?a.length:u[e+1]),g=l.subarray(u[e],t?l.length:u[e+1]),_=A.subarray(d[e],t?A.length:d[e+1]),v=h.subarray(p[e],t?h.length:p[e+1]);if(i){const t=`${n}-geometry.${e}`;s.createGeometry({id:t,primitive:"triangles",positionsCompressed:c,normalsCompressed:g,indices:_,edgeIndices:v})}else{const t=e;m[P[e]];const i={};s.createMesh(y.apply(i,{id:t,primitive:"triangles",positionsCompressed:c,normalsCompressed:g,indices:_,edgeIndices:v,color:r,opacity:o}))}}let C=0;for(let e=0;e1){const t={},r="instance."+C++,o="geometry"+i,n=16*v[e],l=c.subarray(n,n+16);s.createMesh(y.apply(t,{id:r,geometryId:o,matrix:l})),a.push(r)}else a.push(i)}if(a.length>0){const e={};s.createEntity(y.apply(e,{id:r,isObject:!0,meshIds:a}))}}}(0,0,a,s,0,o)}};let RC=window.pako||_C;RC.inflate||(RC=RC.default);const LC=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const UC={version:6,parse:function(e,t,i,s,r,o){const n=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],reusedPrimitivesDecodeMatrix:e[5],eachPrimitivePositionsAndNormalsPortion:e[6],eachPrimitiveIndicesPortion:e[7],eachPrimitiveEdgeIndicesPortion:e[8],eachPrimitiveColorAndOpacity:e[9],primitiveInstances:e[10],eachEntityId:e[11],eachEntityPrimitiveInstancesPortion:e[12],eachEntityMatricesPortion:e[13],eachTileAABB:e[14],eachTileEntitiesPortion:e[15]}}(i),a=function(e){function t(e,t){return 0===e.length?[]:RC.inflate(e,t).buffer}return{positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedPrimitivesDecodeMatrix:new Float32Array(t(e.reusedPrimitivesDecodeMatrix)),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(t(e.eachPrimitivePositionsAndNormalsPortion)),eachPrimitiveIndicesPortion:new Uint32Array(t(e.eachPrimitiveIndicesPortion)),eachPrimitiveEdgeIndicesPortion:new Uint32Array(t(e.eachPrimitiveEdgeIndicesPortion)),eachPrimitiveColorAndOpacity:new Uint8Array(t(e.eachPrimitiveColorAndOpacity)),primitiveInstances:new Uint32Array(t(e.primitiveInstances)),eachEntityId:RC.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(t(e.eachEntityPrimitiveInstancesPortion)),eachEntityMatricesPortion:new Uint32Array(t(e.eachEntityMatricesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(n);!function(e,t,i,s,r,o){const n=o.getNextId(),a=i.positions,l=i.normals,A=i.indices,h=i.edgeIndices,c=i.matrices,u=i.reusedPrimitivesDecodeMatrix,p=i.eachPrimitivePositionsAndNormalsPortion,f=i.eachPrimitiveIndicesPortion,g=i.eachPrimitiveEdgeIndicesPortion,m=i.eachPrimitiveColorAndOpacity,_=i.primitiveInstances,v=JSON.parse(i.eachEntityId),b=i.eachEntityPrimitiveInstancesPortion,B=i.eachEntityMatricesPortion,x=i.eachTileAABB,w=i.eachTileEntitiesPortion,P=p.length,C=_.length,M=v.length,F=w.length,E=new Uint32Array(P);for(let e=0;e1,c=t===P-1,d=a.subarray(p[t],c?a.length:p[t+1]),v=l.subarray(p[t],c?l.length:p[t+1]),b=A.subarray(f[t],c?A.length:f[t+1]),B=h.subarray(g[t],c?h.length:g[t+1]),x=LC(m.subarray(4*t,4*t+3)),w=m[4*t+3]/255,C=o.getNextId();if(r){const e=`${n}-geometry.${i}.${t}`;U[e]||(s.createGeometry({id:e,primitive:"triangles",positionsCompressed:d,indices:b,edgeIndices:B,positionsDecodeMatrix:u}),U[e]=!0),s.createMesh(y.apply(N,{id:C,geometryId:e,origin:I,matrix:F,color:x,opacity:w})),R.push(C)}else s.createMesh(y.apply(N,{id:C,origin:I,primitive:"triangles",positionsCompressed:d,normalsCompressed:v,indices:b,edgeIndices:B,positionsDecodeMatrix:L,color:x,opacity:w})),R.push(C)}R.length>0&&s.createEntity(y.apply(O,{id:w,isObject:!0,meshIds:R}))}}}(e,t,a,s,0,o)}};let kC=window.pako||_C;kC.inflate||(kC=kC.default);const OC=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function NC(e){const t=[];for(let i=0,s=e.length;i1,d=t===E-1,P=OC(w.subarray(6*e,6*e+3)),C=w[6*e+3]/255,M=w[6*e+4]/255,F=w[6*e+5]/255,I=o.getNextId();if(r){const r=x[e],o=u.slice(r,r+16),B=`${n}-geometry.${i}.${t}`;if(!Q[B]){let e,i,r,o,n,u;switch(f[t]){case 0:e="solid",i=a.subarray(g[t],d?a.length:g[t+1]),r=l.subarray(m[t],d?l.length:m[t+1]),n=h.subarray(v[t],d?h.length:v[t+1]),u=c.subarray(b[t],d?c.length:b[t+1]);break;case 1:e="surface",i=a.subarray(g[t],d?a.length:g[t+1]),r=l.subarray(m[t],d?l.length:m[t+1]),n=h.subarray(v[t],d?h.length:v[t+1]),u=c.subarray(b[t],d?c.length:b[t+1]);break;case 2:e="points",i=a.subarray(g[t],d?a.length:g[t+1]),o=NC(A.subarray(_[t],d?A.length:_[t+1]));break;case 3:e="lines",i=a.subarray(g[t],d?a.length:g[t+1]),n=h.subarray(v[t],d?h.length:v[t+1]);break;default:continue}s.createGeometry({id:B,primitive:e,positionsCompressed:i,normalsCompressed:r,colors:o,indices:n,edgeIndices:u,positionsDecodeMatrix:p}),Q[B]=!0}s.createMesh(y.apply(V,{id:I,geometryId:B,origin:R,matrix:o,color:P,metallic:M,roughness:F,opacity:C})),U.push(I)}else{let e,i,r,o,n,u;switch(f[t]){case 0:e="solid",i=a.subarray(g[t],d?a.length:g[t+1]),r=l.subarray(m[t],d?l.length:m[t+1]),n=h.subarray(v[t],d?h.length:v[t+1]),u=c.subarray(b[t],d?c.length:b[t+1]);break;case 1:e="surface",i=a.subarray(g[t],d?a.length:g[t+1]),r=l.subarray(m[t],d?l.length:m[t+1]),n=h.subarray(v[t],d?h.length:v[t+1]),u=c.subarray(b[t],d?c.length:b[t+1]);break;case 2:e="points",i=a.subarray(g[t],d?a.length:g[t+1]),o=NC(A.subarray(_[t],d?A.length:_[t+1]));break;case 3:e="lines",i=a.subarray(g[t],d?a.length:g[t+1]),n=h.subarray(v[t],d?h.length:v[t+1]);break;default:continue}s.createMesh(y.apply(V,{id:I,origin:R,primitive:e,positionsCompressed:i,normalsCompressed:r,colors:o,indices:n,edgeIndices:u,positionsDecodeMatrix:N,color:P,metallic:M,roughness:F,opacity:C})),U.push(I)}}U.length>0&&s.createEntity(y.apply(O,{id:F,isObject:!0,meshIds:U}))}}}(e,t,a,s,0,o)}};let VC=window.pako||_C;VC.inflate||(VC=VC.default);const HC=d.vec4(),jC=d.vec4();const GC=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function zC(e){const t=[];for(let i=0,s=e.length;i1,l=r===L-1,A=GC(E.subarray(6*e,6*e+3)),h=E[6*e+3]/255,c=E[6*e+4]/255,I=E[6*e+5]/255,D=o.getNextId();if(a){const o=F[e],a=_.slice(o,o+16),M=`${n}-geometry.${i}.${r}`;let E=H[M];if(!E){E={batchThisMesh:!t.reuseGeometries};let e=!1;switch(b[r]){case 0:E.primitiveName="solid",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryNormals=p.subarray(x[r],l?p.length:x[r+1]),E.geometryIndices=g.subarray(P[r],l?g.length:P[r+1]),E.geometryEdgeIndices=m.subarray(C[r],l?m.length:C[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 1:E.primitiveName="surface",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryNormals=p.subarray(x[r],l?p.length:x[r+1]),E.geometryIndices=g.subarray(P[r],l?g.length:P[r+1]),E.geometryEdgeIndices=m.subarray(C[r],l?m.length:C[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 2:E.primitiveName="points",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryColors=zC(f.subarray(w[r],l?f.length:w[r+1])),e=E.geometryPositions.length>0;break;case 3:E.primitiveName="lines",E.geometryPositions=u.subarray(B[r],l?u.length:B[r+1]),E.geometryIndices=g.subarray(P[r],l?g.length:P[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;default:continue}if(e||(E=null),E&&(E.geometryPositions.length,E.batchThisMesh)){E.decompressedPositions=new Float32Array(E.geometryPositions.length);const e=E.geometryPositions,t=E.decompressedPositions;for(let i=0,s=e.length;i0&&n.length>0;break;case 1:e="surface",t=u.subarray(B[r],l?u.length:B[r+1]),i=p.subarray(x[r],l?p.length:x[r+1]),n=g.subarray(P[r],l?g.length:P[r+1]),a=m.subarray(C[r],l?m.length:C[r+1]),d=t.length>0&&n.length>0;break;case 2:e="points",t=u.subarray(B[r],l?u.length:B[r+1]),o=zC(f.subarray(w[r],l?f.length:w[r+1])),d=t.length>0;break;case 3:e="lines",t=u.subarray(B[r],l?u.length:B[r+1]),n=g.subarray(P[r],l?g.length:P[r+1]),d=t.length>0&&n.length>0;break;default:continue}d&&(s.createMesh(y.apply(G,{id:D,origin:Q,primitive:e,positionsCompressed:t,normalsCompressed:i,colorsCompressed:o,indices:n,edgeIndices:a,positionsDecodeMatrix:R,color:A,metallic:c,roughness:I,opacity:h})),T.push(D))}}T.length>0&&s.createEntity(y.apply(j,{id:A,isObject:!0,meshIds:T}))}}}(e,t,a,s,r,o)}};let KC=window.pako||_C;KC.inflate||(KC=KC.default);const XC=d.vec4(),JC=d.vec4();const YC=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();const ZC={version:9,parse:function(e,t,i,s,r,o){const n=function(e){return{metadata:e[0],positions:e[1],normals:e[2],colors:e[3],indices:e[4],edgeIndices:e[5],matrices:e[6],reusedGeometriesDecodeMatrix:e[7],eachGeometryPrimitiveType:e[8],eachGeometryPositionsPortion:e[9],eachGeometryNormalsPortion:e[10],eachGeometryColorsPortion:e[11],eachGeometryIndicesPortion:e[12],eachGeometryEdgeIndicesPortion:e[13],eachMeshGeometriesPortion:e[14],eachMeshMatricesPortion:e[15],eachMeshMaterial:e[16],eachEntityId:e[17],eachEntityMeshesPortion:e[18],eachTileAABB:e[19],eachTileEntitiesPortion:e[20]}}(i),a=function(e){function t(e,t){return 0===e.length?[]:KC.inflate(e,t).buffer}return{metadata:JSON.parse(KC.inflate(e.metadata,{to:"string"})),positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshMaterial:new Uint8Array(t(e.eachMeshMaterial)),eachEntityId:JSON.parse(KC.inflate(e.eachEntityId,{to:"string"})),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(n);!function(e,t,i,s,r,o){const n=o.getNextId(),a=i.metadata,l=i.positions,A=i.normals,h=i.colors,c=i.indices,u=i.edgeIndices,p=i.matrices,f=i.reusedGeometriesDecodeMatrix,g=i.eachGeometryPrimitiveType,m=i.eachGeometryPositionsPortion,_=i.eachGeometryNormalsPortion,v=i.eachGeometryColorsPortion,b=i.eachGeometryIndicesPortion,B=i.eachGeometryEdgeIndicesPortion,x=i.eachMeshGeometriesPortion,w=i.eachMeshMatricesPortion,P=i.eachMeshMaterial,C=i.eachEntityId,M=i.eachEntityMeshesPortion,F=i.eachTileAABB,E=i.eachTileEntitiesPortion,I=m.length,D=x.length,S=M.length,T=E.length;r&&r.loadData(a,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds});const R=new Uint32Array(I);for(let e=0;e1,C=r===I-1,M=YC(P.subarray(6*e,6*e+3)),F=P[6*e+3]/255,E=P[6*e+4]/255,D=P[6*e+5]/255,S=o.getNextId();if(a){const o=w[e],a=p.slice(o,o+16),x=`${n}-geometry.${i}.${r}`;let P=k[x];if(!P){P={batchThisMesh:!t.reuseGeometries};let e=!1;switch(g[r]){case 0:P.primitiveName="solid",P.geometryPositions=l.subarray(m[r],C?l.length:m[r+1]),P.geometryNormals=A.subarray(_[r],C?A.length:_[r+1]),P.geometryIndices=c.subarray(b[r],C?c.length:b[r+1]),P.geometryEdgeIndices=u.subarray(B[r],C?u.length:B[r+1]),e=P.geometryPositions.length>0&&P.geometryIndices.length>0;break;case 1:P.primitiveName="surface",P.geometryPositions=l.subarray(m[r],C?l.length:m[r+1]),P.geometryNormals=A.subarray(_[r],C?A.length:_[r+1]),P.geometryIndices=c.subarray(b[r],C?c.length:b[r+1]),P.geometryEdgeIndices=u.subarray(B[r],C?u.length:B[r+1]),e=P.geometryPositions.length>0&&P.geometryIndices.length>0;break;case 2:P.primitiveName="points",P.geometryPositions=l.subarray(m[r],C?l.length:m[r+1]),P.geometryColors=h.subarray(v[r],C?h.length:v[r+1]),e=P.geometryPositions.length>0;break;case 3:P.primitiveName="lines",P.geometryPositions=l.subarray(m[r],C?l.length:m[r+1]),P.geometryIndices=c.subarray(b[r],C?c.length:b[r+1]),e=P.geometryPositions.length>0&&P.geometryIndices.length>0;break;default:continue}if(e||(P=null),P&&(P.geometryPositions.length,P.batchThisMesh)){P.decompressedPositions=new Float32Array(P.geometryPositions.length),P.transformedAndRecompressedPositions=new Uint16Array(P.geometryPositions.length);const e=P.geometryPositions,t=P.decompressedPositions;for(let i=0,s=e.length;i0&&n.length>0;break;case 1:e="surface",t=l.subarray(m[r],C?l.length:m[r+1]),i=A.subarray(_[r],C?A.length:_[r+1]),n=c.subarray(b[r],C?c.length:b[r+1]),a=u.subarray(B[r],C?u.length:B[r+1]),d=t.length>0&&n.length>0;break;case 2:e="points",t=l.subarray(m[r],C?l.length:m[r+1]),o=h.subarray(v[r],C?h.length:v[r+1]),d=t.length>0;break;case 3:e="lines",t=l.subarray(m[r],C?l.length:m[r+1]),n=c.subarray(b[r],C?c.length:b[r+1]),d=t.length>0&&n.length>0;break;default:continue}d&&(s.createMesh(y.apply(j,{id:S,origin:L,primitive:e,positionsCompressed:t,normalsCompressed:i,colorsCompressed:o,indices:n,edgeIndices:a,positionsDecodeMatrix:Q,color:M,metallic:E,roughness:D,opacity:F})),O.push(S))}}O.length>0&&s.createEntity(y.apply(H,{id:F,isObject:!0,meshIds:O}))}}}(e,t,a,s,r,o)}};let qC=window.pako||_C;qC.inflate||(qC=qC.default);const $C=d.vec4(),eM=d.vec4();const tM=function(){const e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function iM(e,t){const i=[];if(t.length>1)for(let e=0,s=t.length-1;e1)for(let t=0,s=e.length/3-1;t0,a=9*e,c=1===h[a+0],u=h[a+1];h[a+2],h[a+3];const d=h[a+4],p=h[a+5],f=h[a+6],g=h[a+7],m=h[a+8];if(o){const t=new Uint8Array(l.subarray(i,r)).buffer,o=`${n}-texture-${e}`;if(c)s.createTexture({id:o,buffers:[t],minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m});else{const e=new Blob([t],{type:10001===u?"image/jpeg":10002===u?"image/png":"image/gif"}),i=(window.URL||window.webkitURL).createObjectURL(e),r=document.createElement("img");r.src=i,s.createTexture({id:o,image:r,minFilter:d,magFilter:p,wrapS:f,wrapT:g,wrapR:m})}}}for(let e=0;e=0?`${n}-texture-${r}`:null,normalsTextureId:a>=0?`${n}-texture-${a}`:null,metallicRoughnessTextureId:o>=0?`${n}-texture-${o}`:null,emissiveTextureId:l>=0?`${n}-texture-${l}`:null,occlusionTextureId:A>=0?`${n}-texture-${A}`:null})}const j=new Uint32Array(N);for(let e=0;e1,l=r===N-1,A=D[e],h=A>=0?`${n}-textureSet-${A}`:null,T=tM(S.subarray(6*e,6*e+3)),R=S[6*e+3]/255,L=S[6*e+4]/255,O=S[6*e+5]/255,Q=o.getNextId();if(a){const o=I[e],a=v.slice(o,o+16),A=`${n}-geometry.${i}.${r}`;let E=W[A];if(!E){E={batchThisMesh:!t.reuseGeometries};let e=!1;switch(B[r]){case 0:E.primitiveName="solid",E.geometryPositions=c.subarray(x[r],l?c.length:x[r+1]),E.geometryNormals=u.subarray(w[r],l?u.length:w[r+1]),E.geometryUVs=f.subarray(C[r],l?f.length:C[r+1]),E.geometryIndices=g.subarray(M[r],l?g.length:M[r+1]),E.geometryEdgeIndices=m.subarray(F[r],l?m.length:F[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 1:E.primitiveName="surface",E.geometryPositions=c.subarray(x[r],l?c.length:x[r+1]),E.geometryNormals=u.subarray(w[r],l?u.length:w[r+1]),E.geometryUVs=f.subarray(C[r],l?f.length:C[r+1]),E.geometryIndices=g.subarray(M[r],l?g.length:M[r+1]),E.geometryEdgeIndices=m.subarray(F[r],l?m.length:F[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 2:E.primitiveName="points",E.geometryPositions=c.subarray(x[r],l?c.length:x[r+1]),E.geometryColors=p.subarray(P[r],l?p.length:P[r+1]),e=E.geometryPositions.length>0;break;case 3:E.primitiveName="lines",E.geometryPositions=c.subarray(x[r],l?c.length:x[r+1]),E.geometryIndices=g.subarray(M[r],l?g.length:M[r+1]),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;case 4:E.primitiveName="lines",E.geometryPositions=c.subarray(x[r],l?c.length:x[r+1]),E.geometryIndices=iM(E.geometryPositions,g.subarray(M[r],l?g.length:M[r+1])),e=E.geometryPositions.length>0&&E.geometryIndices.length>0;break;default:continue}if(e||(E=null),E&&(E.geometryPositions.length,E.batchThisMesh)){E.decompressedPositions=new Float32Array(E.geometryPositions.length),E.transformedAndRecompressedPositions=new Uint16Array(E.geometryPositions.length);const e=E.geometryPositions,t=E.decompressedPositions;for(let i=0,s=e.length;i0&&a.length>0;break;case 1:e="surface",t=c.subarray(x[r],l?c.length:x[r+1]),i=u.subarray(w[r],l?u.length:w[r+1]),o=f.subarray(C[r],l?f.length:C[r+1]),a=g.subarray(M[r],l?g.length:M[r+1]),A=m.subarray(F[r],l?m.length:F[r+1]),d=t.length>0&&a.length>0;break;case 2:e="points",t=c.subarray(x[r],l?c.length:x[r+1]),n=p.subarray(P[r],l?p.length:P[r+1]),d=t.length>0;break;case 3:e="lines",t=c.subarray(x[r],l?c.length:x[r+1]),a=g.subarray(M[r],l?g.length:M[r+1]),d=t.length>0&&a.length>0;break;case 4:e="lines",t=c.subarray(x[r],l?c.length:x[r+1]),a=iM(t,g.subarray(M[r],l?g.length:M[r+1])),d=t.length>0&&a.length>0;break;default:continue}d&&(s.createMesh(y.apply(H,{id:Q,textureSetId:h,origin:G,primitive:e,positionsCompressed:t,normalsCompressed:i,uv:o&&o.length>0?o:null,colorsCompressed:n,indices:a,edgeIndices:A,positionsDecodeMatrix:_,color:T,metallic:L,roughness:O,opacity:R})),U.push(Q))}}U.length>0&&s.createEntity(y.apply(Q,{id:l,isObject:!0,meshIds:U}))}}}(e,t,a,s,r,o)}},rM={};rM[yC.version]=yC,rM[wC.version]=wC,rM[MC.version]=MC,rM[IC.version]=IC,rM[TC.version]=TC,rM[UC.version]=UC,rM[QC.version]=QC,rM[WC.version]=WC,rM[ZC.version]=ZC,rM[sM.version]=sM;class oM extends z{constructor(e,t={}){super("XKTLoader",e,t),this._maxGeometryBatchSize=t.maxGeometryBatchSize,this.textureTranscoder=t.textureTranscoder,this.dataSource=t.dataSource,this.objectDefaults=t.objectDefaults,this.includeTypes=t.includeTypes,this.excludeTypes=t.excludeTypes,this.excludeUnclassifiedObjects=t.excludeUnclassifiedObjects,this.reuseGeometries=t.reuseGeometries}get supportedVersions(){return Object.keys(rM)}get textureTranscoder(){return this._textureTranscoder}set textureTranscoder(e){this._textureTranscoder=e}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new mC}get objectDefaults(){return this._objectDefaults}set objectDefaults(e){this._objectDefaults=e||mP}get includeTypes(){return this._includeTypes}set includeTypes(e){this._includeTypes=e}get excludeTypes(){return this._excludeTypes}set excludeTypes(e){this._excludeTypes=e}get excludeUnclassifiedObjects(){return this._excludeUnclassifiedObjects}set excludeUnclassifiedObjects(e){this._excludeUnclassifiedObjects=!!e}get globalizeObjectIds(){return this._globalizeObjectIds}set globalizeObjectIds(e){this._globalizeObjectIds=!!e}get reuseGeometries(){return this._reuseGeometries}set reuseGeometries(e){this._reuseGeometries=!1!==e}load(e={}){if(e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id),!(e.src||e.xkt||e.manifestSrc||e.manifest))return this.error("load() param expected: src, xkt, manifestSrc or manifestData"),o;const t={},i=e.includeTypes||this._includeTypes,s=e.excludeTypes||this._excludeTypes,r=e.objectDefaults||this._objectDefaults;if(t.reuseGeometries=null!==e.reuseGeometries&&void 0!==e.reuseGeometries?e.reuseGeometries:!1!==this._reuseGeometries,i){t.includeTypesMap={};for(let e=0,s=i.length;e{o.finalize(),a.finalize(),this.viewer.scene.canvas.spinner.processes--,o.once("destroyed",(()=>{this.viewer.metaScene.destroyMetaModel(a.id)})),this.scheduleTask((()=>{o.destroyed||(o.scene.fire("modelLoaded",o.id),o.fire("loaded",!0,!1))}))},A=e=>{this.viewer.scene.canvas.spinner.processes--,this.error(e),o.fire("error",e)};let h=0;const c={getNextId:()=>`${n}.${h++}`};if(e.metaModelSrc||e.metaModelData)if(e.metaModelSrc){const r=e.metaModelSrc;this._dataSource.getMetaModel(r,(r=>{o.destroyed||(a.loadData(r,{includeTypes:i,excludeTypes:s,globalizeObjectIds:t.globalizeObjectIds}),e.src?this._loadModel(e.src,e,t,o,null,c,l,A):(this._parseModel(e.xkt,e,t,o,null,c),l()))}),(e=>{A(`load(): Failed to load model metadata for model '${n} from '${r}' - ${e}`)}))}else e.metaModelData&&(a.loadData(e.metaModelData,{includeTypes:i,excludeTypes:s,globalizeObjectIds:t.globalizeObjectIds}),e.src?this._loadModel(e.src,e,t,o,null,c,l,A):(this._parseModel(e.xkt,e,t,o,null,c),l()));else if(e.src)this._loadModel(e.src,e,t,o,a,c,l,A);else if(e.xkt)this._parseModel(e.xkt,e,t,o,a,c),l();else if(e.manifestSrc||e.manifest){const r=e.manifestSrc?function(e){const t=e.split("/");return t.pop(),t.join("/")+"/"}(e.manifestSrc):"",n=(e,o,n)=>{let l=0;const A=()=>{l>=e.length?o():this._dataSource.getMetaModel(`${r}${e[l]}`,(e=>{a.loadData(e,{includeTypes:i,excludeTypes:s,globalizeObjectIds:t.globalizeObjectIds}),l++,this.scheduleTask(A,100)}),n)};A()},h=(i,s,n)=>{let a=0;const l=()=>{a>=i.length?s():this._dataSource.getXKT(`${r}${i[a]}`,(i=>{this._parseModel(i,e,t,o,null,c),a++,this.scheduleTask(l,100)}),n)};l()},u=(i,s,n)=>{let l=0;const A=()=>{l>=i.length?s():this._dataSource.getXKT(`${r}${i[l]}`,(i=>{this._parseModel(i,e,t,o,a,c),l++,this.scheduleTask(A,100)}),n)};A()};if(e.manifest){const t=e.manifest,i=t.xktFiles;if(!i||0===i.length)return void A("load(): Failed to load model manifest - manifest not valid");const s=t.metaModelFiles;s?n(s,(()=>{h(i,l,A)}),A):u(i,l,A)}else this._dataSource.getManifest(e.manifestSrc,(e=>{if(o.destroyed)return;const t=e.xktFiles;if(!t||0===t.length)return void A("load(): Failed to load model manifest - manifest not valid");const i=e.metaModelFiles;i?n(i,(()=>{h(t,l,A)}),A):u(t,l,A)}),A)}return o}_loadModel(e,t,i,s,r,o,n,a){this._dataSource.getXKT(t.src,(e=>{this._parseModel(e,t,i,s,r,o),n()}),a)}_parseModel(e,t,i,s,r,o){if(s.destroyed)return;const n=new DataView(e),a=new Uint8Array(e),l=n.getUint32(0,!0),A=rM[l];if(!A)return void this.error("Unsupported .XKT file version: "+l+" - this XKTLoaderPlugin supports versions "+Object.keys(rM));this.log("Loading .xkt V"+l);const h=n.getUint32(4,!0),c=[];let u=4*(h+2);for(let e=0;ee.size)throw new RangeError("offset:"+t+", length:"+i+", size:"+e.size);return e.slice?e.slice(t,t+i):e.webkitSlice?e.webkitSlice(t,t+i):e.mozSlice?e.mozSlice(t,t+i):e.msSlice?e.msSlice(t,t+i):void 0}(e,t,i))}catch(e){r(e)}}}function p(){}function f(e){var i,s=this;s.init=function(e){i=new Blob([],{type:n}),e()},s.writeUint8Array=function(e,s){i=new Blob([i,t?e:e.buffer],{type:n}),s()},s.getData=function(t,s){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=s,r.readAsText(i,e)}}function g(t){var i=this,s="",r="";i.init=function(e){s+="data:"+(t||"")+";base64,",e()},i.writeUint8Array=function(t,i){var o,n=r.length,a=r;for(r="",o=0;o<3*Math.floor((n+t.length)/3)-n;o++)a+=String.fromCharCode(t[o]);for(;o2?s+=e.btoa(a):r=a,i()},i.getData=function(t){t(s+e.btoa(r))}}function m(e){var i,s=this;s.init=function(t){i=new Blob([],{type:e}),t()},s.writeUint8Array=function(s,r){i=new Blob([i,t?s:s.buffer],{type:e}),r()},s.getData=function(e){e(i)}}function _(e,t,i,s,r,n,a,l,A,h){var c,u,d,p=0,f=t.sn;function g(){e.removeEventListener("message",m,!1),l(u,d)}function m(t){var i=t.data,r=i.data,o=i.error;if(o)return o.toString=function(){return"Error: "+this.message},void A(o);if(i.sn===f)switch("number"==typeof i.codecTime&&(e.codecTime+=i.codecTime),"number"==typeof i.crcTime&&(e.crcTime+=i.crcTime),i.type){case"append":r?(u+=r.length,s.writeUint8Array(r,(function(){_()}),h)):_();break;case"flush":d=i.crc,r?(u+=r.length,s.writeUint8Array(r,(function(){g()}),h)):g();break;case"progress":a&&a(c+i.loaded,n);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",i)}}function _(){(c=p*o)<=n?i.readUint8Array(r+c,Math.min(o,n-c),(function(i){a&&a(c,n);var s=0===c?t:{sn:f};s.type="append",s.data=i;try{e.postMessage(s,[i.buffer])}catch(t){e.postMessage(s)}p++}),A):e.postMessage({sn:f,type:"flush"})}u=0,e.addEventListener("message",m,!1),_()}function v(e,t,i,s,r,n,l,A,h,c){var u,d=0,p=0,f="input"===n,g="output"===n,m=new a;!function n(){var a;if((u=d*o)127?r[i-128]:String.fromCharCode(i);return s}function B(e){return decodeURIComponent(escape(e))}function x(e){var t,i="";for(t=0;t>16,i=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&i)>>11,(2016&i)>>5,2*(31&i),0)}catch(e){}}(e.lastModDateRaw),1!=(1&e.bitFlag)?((s||8!=(8&e.bitFlag))&&(e.crc32=t.view.getUint32(i+10,!0),e.compressedSize=t.view.getUint32(i+14,!0),e.uncompressedSize=t.view.getUint32(i+18,!0)),4294967295!==e.compressedSize&&4294967295!==e.uncompressedSize?(e.filenameLength=t.view.getUint16(i+22,!0),e.extraFieldLength=t.view.getUint16(i+24,!0)):r("File is using Zip64 (4gb+ file size).")):r("File contains encrypted entry.")}function P(t,o,n){var a=0;function l(){}l.prototype.getData=function(s,o,l,h){var c=this;function u(e,t){h&&!function(e){var t=A(4);return t.view.setUint32(0,e),c.crc32==t.view.getUint32(0)}(t)?n("CRC failed."):s.getData((function(e){o(e)}))}function d(e){n(e||r)}function p(e){n(e||"Error while writing file data.")}t.readUint8Array(c.offset,30,(function(r){var o,f=A(r.length,r);1347093252==f.view.getUint32(0)?(w(c,f,4,!1,n),o=c.offset+30+c.filenameLength+c.extraFieldLength,s.init((function(){0===c.compressionMethod?b(c._worker,a++,t,s,o,c.compressedSize,h,u,l,d,p):function(t,i,s,r,o,n,a,l,A,h,c){var u=a?"output":"none";e.zip.useWebWorkers?_(t,{sn:i,codecClass:"Inflater",crcType:u},s,r,o,n,A,l,h,c):v(new e.zip.Inflater,s,r,o,n,u,A,l,h,c)}(c._worker,a++,t,s,o,c.compressedSize,h,u,l,d,p)}),p)):n(i)}),d)};var h={getEntries:function(e){var r=this._worker;!function(e){t.size<22?n(i):r(22,(function(){r(Math.min(65558,t.size),(function(){n(i)}))}));function r(i,r){t.readUint8Array(t.size-i,i,(function(t){for(var i=t.length-22;i>=0;i--)if(80===t[i]&&75===t[i+1]&&5===t[i+2]&&6===t[i+3])return void e(new DataView(t.buffer,i,22));r()}),(function(){n(s)}))}}((function(o){var a,h;a=o.getUint32(16,!0),h=o.getUint16(8,!0),a<0||a>=t.size?n(i):t.readUint8Array(a,t.size-a,(function(t){var s,o,a,c,u=0,d=[],p=A(t.length,t);for(s=0;s>>8^i[255&(t^e[s])];this.crc=t},a.prototype.get=function(){return~this.crc},a.prototype.table=function(){var e,t,i,s=[];for(e=0;e<256;e++){for(i=e,t=0;t<8;t++)1&i?i=i>>>1^3988292384:i>>>=1;s[e]=i}return s}(),l.prototype.append=function(e,t){return e},l.prototype.flush=function(){},c.prototype=new h,c.prototype.constructor=c,u.prototype=new h,u.prototype.constructor=u,d.prototype=new h,d.prototype.constructor=d,p.prototype.getData=function(e){e(this.data)},f.prototype=new p,f.prototype.constructor=f,g.prototype=new p,g.prototype.constructor=g,m.prototype=new p,m.prototype.constructor=m;var E={deflater:["z-worker.js","deflate.js"],inflater:["z-worker.js","inflate.js"]};function I(t,i,s){if(null===e.zip.workerScripts||null===e.zip.workerScriptsPath){var r;if(e.zip.workerScripts){if(r=e.zip.workerScripts[t],!Array.isArray(r))return void s(new Error("zip.workerScripts."+t+" is not an array!"));r=function(e){var t=document.createElement("a");return e.map((function(e){return t.href=e,t.href}))}(r)}else(r=E[t].slice(0))[0]=(e.zip.workerScriptsPath||"")+r[0];var o=new Worker(r[0]);o.codecTime=o.crcTime=0,o.postMessage({type:"importScripts",scripts:r.slice(1)}),o.addEventListener("message",(function e(t){var r=t.data;if(r.error)return o.terminate(),void s(r.error);"importScripts"===r.type&&(o.removeEventListener("message",e),o.removeEventListener("error",n),i(o))})),o.addEventListener("error",n)}else s(new Error("Either zip.workerScripts or zip.workerScriptsPath may be set, not both."));function n(e){o.terminate(),s(e)}}function D(e){console.error(e)}e.zip={Reader:h,Writer:p,BlobReader:d,Data64URIReader:u,TextReader:c,BlobWriter:m,Data64URIWriter:g,TextWriter:f,createReader:function(e,t,i){i=i||D,e.init((function(){P(e,t,i)}),i)},createWriter:function(e,t,i,s){i=i||D,s=!!s,e.init((function(){F(e,t,i,s)}),i)},useWebWorkers:!0,workerScriptsPath:null,workerScripts:null}}(nM);const aM=nM.zip;!function(e){var t,i,s=e.Reader,r=e.Writer;try{i=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function o(e){var t=this;function i(i,s){var r;t.data?i():((r=new XMLHttpRequest).addEventListener("load",(function(){t.size||(t.size=Number(r.getResponseHeader("Content-Length"))||Number(r.response.byteLength)),t.data=new Uint8Array(r.response),i()}),!1),r.addEventListener("error",s,!1),r.open("GET",e),r.responseType="arraybuffer",r.send())}t.size=0,t.init=function(s,r){if(function(e){var t=document.createElement("a");return t.href=e,"http:"===t.protocol||"https:"===t.protocol}(e)){var o=new XMLHttpRequest;o.addEventListener("load",(function(){t.size=Number(o.getResponseHeader("Content-Length")),t.size?s():i(s,r)}),!1),o.addEventListener("error",r,!1),o.open("HEAD",e),o.send()}else i(s,r)},t.readUint8Array=function(e,s,r,o){i((function(){r(new Uint8Array(t.data.subarray(e,e+s)))}),o)}}function n(e){var t=this;t.size=0,t.init=function(i,s){var r=new XMLHttpRequest;r.addEventListener("load",(function(){t.size=Number(r.getResponseHeader("Content-Length")),"bytes"==r.getResponseHeader("Accept-Ranges")?i():s("HTTP Range not supported.")}),!1),r.addEventListener("error",s,!1),r.open("HEAD",e),r.send()},t.readUint8Array=function(t,i,s,r){!function(t,i,s,r){var o=new XMLHttpRequest;o.open("GET",e),o.responseType="arraybuffer",o.setRequestHeader("Range","bytes="+t+"-"+(t+i-1)),o.addEventListener("load",(function(){s(o.response)}),!1),o.addEventListener("error",r,!1),o.send()}(t,i,(function(e){s(new Uint8Array(e))}),r)}}function a(e){var t=this;t.size=0,t.init=function(i,s){t.size=e.byteLength,i()},t.readUint8Array=function(t,i,s,r){s(new Uint8Array(e.slice(t,t+i)))}}function l(){var e,t=this;t.init=function(t,i){e=new Uint8Array,t()},t.writeUint8Array=function(t,i,s){var r=new Uint8Array(e.length+t.length);r.set(e),r.set(t,e.length),e=r,i()},t.getData=function(t){t(e.buffer)}}function A(e,t){var s,r=this;r.init=function(t,i){e.createWriter((function(e){s=e,t()}),i)},r.writeUint8Array=function(e,r,o){var n=new Blob([i?e:e.buffer],{type:t});s.onwrite=function(){s.onwrite=null,r()},s.onerror=o,s.write(n)},r.getData=function(t){e.file(t)}}o.prototype=new s,o.prototype.constructor=o,n.prototype=new s,n.prototype.constructor=n,a.prototype=new s,a.prototype.constructor=a,l.prototype=new r,l.prototype.constructor=l,A.prototype=new r,A.prototype.constructor=A,e.FileWriter=A,e.HttpReader=o,e.HttpRangeReader=n,e.ArrayBufferReader=a,e.ArrayBufferWriter=l,e.fs&&((t=e.fs.ZipDirectoryEntry).prototype.addHttpContent=function(i,s,r){return function(i,s,r,o){if(i.directory)return o?new t(i.fs,s,r,i):new e.fs.ZipFileEntry(i.fs,s,r,i);throw"Parent entry is not a directory."}(this,i,{data:s,Reader:r?n:o})},t.prototype.importHttpContent=function(e,t,i,s){this.importZip(t?new n(e):new o(e),i,s)},e.fs.FS.prototype.importHttpContent=function(e,i,s,r){this.entries=[],this.root=new t(this),this.root.importHttpContent(e,i,s,r)})}(aM);const lM=["4.2"];class AM{constructor(e,t={}){this.supportedSchemas=lM,this._xrayOpacity=.7,this._src=null,this._options=t,this.viewpoint=null,t.workerScriptsPath?(aM.workerScriptsPath=t.workerScriptsPath,this.src=t.src,this.xrayOpacity=.7,this.displayEffect=t.displayEffect,this.createMetaModel=t.createMetaModel):e.error("Config expected: workerScriptsPath")}load(e,t,i,s,r,o){switch(s.materialType){case"MetallicMaterial":t._defaultMaterial=new Rr(t,{baseColor:[1,1,1],metallic:.6,roughness:.6});break;case"SpecularMaterial":t._defaultMaterial=new kr(t,{diffuse:[1,1,1],specular:d.vec3([1,1,1]),glossiness:.5});break;default:t._defaultMaterial=new Jt(t,{reflectivity:.75,shiness:100,diffuse:[1,1,1]})}t._wireframeMaterial=new Dr(t,{color:[0,0,0],lineWidth:2});var n=t.scene.canvas.spinner;n.processes++,hM(e,t,i,s,(function(){n.processes--,r&&r(),t.fire("loaded",!0,!1)}),(function(e){n.processes--,t.error(e),o&&o(e),t.fire("error",e)}),(function(e){console.log("Error, Will Robinson: "+e)}))}}var hM=function(e,t,i,s,r,o){!function(e,t,i){var s=new _M;s.load(e,(function(){t(s)}),(function(e){i("Error loading ZIP archive: "+e)}))}(i,(function(i){cM(e,i,s,t,r,o)}),o)},cM=function(){return function(t,i,s,r,o){var n={plugin:t,zip:i,edgeThreshold:30,materialType:s.materialType,scene:r.scene,modelNode:r,info:{references:{}},materials:{}};s.createMetaModel&&(n.metaModelData={modelId:r.id,metaObjects:[{name:r.id,type:"Default",id:r.id}]}),r.scene.loading++,function(t,i){t.zip.getFile("Manifest.xml",(function(s,r){for(var o=r.children,n=0,a=o.length;n0){for(var n=o.trim().split(" "),a=new Int16Array(n.length),l=0,A=0,h=n.length;A0){i.primitive="triangles";for(var o=[],n=0,a=r.length;n=t.length)i();else{var a=t[o].id,l=a.lastIndexOf(":");l>0&&(a=a.substring(l+1));var A=a.lastIndexOf("#");A>0&&(a=a.substring(0,A)),s[a]?r(o+1):function(e,t,i){e.zip.getFile(t,(function(t,s){!function(e,t,i){for(var s,r=t.children,o=0,n=r.length;o0)for(var s=0,r=t.length;s{};t=t||s,i=i||s;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var o=r[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),i=new Uint8Array(e);for(var n=0;n{this._parseModel(e,t,i,s),r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){if(s.destroyed)return;const r=t.stats||{};if(r.sourceFormat="IFC",r.schemaVersion="",r.title="",r.author="",r.created="",r.numMetaObjects=0,r.numPropertySets=0,r.numObjects=0,r.numGeometries=0,r.numTriangles=0,r.numVertices=0,!this._ifcAPI)throw"WebIFCLoaderPlugin has no WebIFC instance configured - please inject via WebIFCLoaderPlugin constructor";const o=new Uint8Array(e),n=this._ifcAPI.OpenModel(o),a=this._ifcAPI.GetModelSchema(n),l=this._ifcAPI.GetLineIDsWithType(n,this._webIFC.IFCPROJECT).get(0),A=!1!==t.loadMetadata,h={modelID:n,modelSchema:a,sceneModel:s,loadMetadata:A,metadata:A?{id:"",projectId:""+l,author:"",createdAt:"",schema:"",creatingApplication:"",metaObjects:[],propertySets:[]}:null,metaObjects:{},options:i,log:function(e){},nextId:0,stats:r};if(A){if(i.includeTypes){h.includeTypes={};for(let e=0,t=i.includeTypes.length;e{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}_parseMetaObjects(e){const t=this._ifcAPI.GetLineIDsWithType(e.modelID,this._webIFC.IFCPROJECT).get(0),i=this._ifcAPI.GetLine(e.modelID,t);this._parseSpatialChildren(e,i)}_parseSpatialChildren(e,t,i){const s=this._ifcAPI.GetNameFromTypeCode(t.type);if(e.includeTypes&&!e.includeTypes[s])return;if(e.excludeTypes&&e.excludeTypes[s])return;this._createMetaObject(e,t,i);const r=t.GlobalId.value;this._parseRelatedItemsOfType(e,t.expressID,"RelatingObject","RelatedObjects",this._webIFC.IFCRELAGGREGATES,r),this._parseRelatedItemsOfType(e,t.expressID,"RelatingStructure","RelatedElements",this._webIFC.IFCRELCONTAINEDINSPATIALSTRUCTURE,r)}_createMetaObject(e,t,i){const s=t.GlobalId.value,r=this._ifcAPI.GetNameFromTypeCode(t.type),o={id:s,name:t.Name&&""!==t.Name.value?t.Name.value:r,type:r,parent:i};e.metadata.metaObjects.push(o),e.metaObjects[s]=o,e.stats.numMetaObjects++}_parseRelatedItemsOfType(e,t,i,s,r,o){const n=this._ifcAPI.GetLineIDsWithType(e.modelID,r);for(let r=0;re.value)).includes(t)}else h=A.value===t;if(h){const t=l[s];if(Array.isArray(t))t.forEach((t=>{const i=this._ifcAPI.GetLine(e.modelID,t.value);this._parseSpatialChildren(e,i,o)}));else{const i=this._ifcAPI.GetLine(e.modelID,t.value);this._parseSpatialChildren(e,i,o)}}}}_parsePropertySets(e){const t=this._ifcAPI.GetLineIDsWithType(e.modelID,this._webIFC.IFCRELDEFINESBYPROPERTIES);for(let i=0;i0){const o="Default",n=t.Name.value,a=[];for(let e=0,t=s.length;e{const i=t.expressID,s=t.geometries,r=[],o=this._ifcAPI.GetLine(e.modelID,i).GlobalId.value;if(e.loadMetadata){const t=o,i=e.metaObjects[t];if(e.includeTypes&&(!i||!e.includeTypes[i.type]))return;if(e.excludeTypes&&(!i||e.excludeTypes[i.type]))return}const n=d.mat4(),a=d.vec3();for(let t=0,i=s.size();t{};t=t||s,i=i||s;const r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){const e=!!r[2];var o=r[3];o=window.decodeURIComponent(o),e&&(o=window.atob(o));try{const e=new ArrayBuffer(o.length),i=new Uint8Array(e);for(var n=0;n{let t=0,i=0,s=0;const r=new DataView(e),o=new Uint8Array(6e3),n=({item:s,format:o,size:n})=>{let a,l;switch(o){case"char":return l=new Uint8Array(e,t,n),t+=n,a=EM(l),[s,a];case"uShort":return a=r.getUint16(t,!0),t+=n,[s,a];case"uLong":return a=r.getUint32(t,!0),"NumberOfVariableLengthRecords"===s&&(i=a),t+=n,[s,a];case"uChar":return a=r.getUint8(t),t+=n,[s,a];case"double":return a=r.getFloat64(t,!0),t+=n,[s,a];default:t+=n}};return(()=>{const e={};PM.forEach((t=>{const i=n({...t});if(void 0!==i){if("FileSignature"===i[0]&&"LASF"!==i[1])throw new Error("Ivalid FileSignature. Is this a LAS/LAZ file");e[i[0]]=i[1]}}));const r=[];let a=i;for(;a--;){const e={};CM.forEach((i=>{const r=n({...i});e[r[0]]=r[1],"UserId"===r[0]&&"LASF_Projection"===r[1]&&(s=t-18+54)})),r.push(e)}const l=(e=>{if(void 0===e)return;const t=s+e.RecordLengthAfterHeader,i=o.slice(s,t),r=FM(i),n=new DataView(r);let a=6,l=Number(n.getUint16(a,!0));const A=[];for(;l--;){const e={};e.key=n.getUint16(a+=2,!0),e.tiffTagLocation=n.getUint16(a+=2,!0),e.count=n.getUint16(a+=2,!0),e.valueOffset=n.getUint16(a+=2,!0),A.push(e)}const h=A.find((e=>3072===e.key));if(h&&h.hasOwnProperty("valueOffset"))return h.valueOffset})(r.find((e=>"LASF_Projection"===e.UserId)));return l&&(e.epsg=l),e})()},FM=e=>{let t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let t=0;t{let t="";return e.forEach((e=>{let i=String.fromCharCode(e);"\0"!==i&&(t+=i)})),t.trim()};class IM extends z{constructor(e,t={}){super("lasLoader",e,t),this.dataSource=t.dataSource,this.skip=t.skip,this.fp64=t.fp64,this.colorDepth=t.colorDepth}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new xM}get skip(){return this._skip}set skip(e){this._skip=e||1}get fp64(){return this._fp64}set fp64(e){this._fp64=!!e}get colorDepth(){return this._colorDepth}set colorDepth(e){this._colorDepth=e||"auto"}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new _c(this.viewer.scene,y.apply(e,{isModel:!0}));if(!e.src&&!e.las)return this.error("load() param expected: src or las"),t;const i={las:{skip:this._skip,fp64:this._fp64,colorDepth:this._colorDepth}};if(e.src)this._loadModel(e.src,e,i,t);else{const s=this.viewer.scene.canvas.spinner;s.processes++,this._parseModel(e.las,e,i,t).then((()=>{s.processes--}),(e=>{s.processes--,this.error(e),t.fire("error",e)}))}return t}_loadModel(e,t,i,s){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getLAS(t.src,(e=>{this._parseModel(e,t,i,s).then((()=>{r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){function r(e){const i=e.value;if(t.rotateX&&i)for(let e=0,t=i.length;e{if(s.destroyed)return void l();const A=t.stats||{};A.sourceFormat="LAS",A.schemaVersion="",A.title="",A.author="",A.created="",A.numMetaObjects=0,A.numPropertySets=0,A.numObjects=0,A.numGeometries=0,A.numTriangles=0,A.numVertices=0;try{const A=MM(e);wB(e,wM,i).then((e=>{const h=e.attributes,c=e.loaderData,u=void 0!==c.pointsFormatId?c.pointsFormatId:-1;if(!h.POSITION)return s.finalize(),void l("No positions found in file");let p,f;switch(u){case 0:p=r(h.POSITION),f=n(h.intensity);break;case 1:if(!h.intensity)return s.finalize(),void l("No positions found in file");p=r(h.POSITION),f=n(h.intensity);break;case 2:case 3:if(!h.intensity)return s.finalize(),void l("No positions found in file");p=r(h.POSITION),f=o(h.COLOR_0,h.intensity)}const g=DM(p,15e5),m=DM(f,2e6),_=[];for(let e=0,t=g.length;e{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))})),a()}))}catch(e){s.finalize(),l(e)}}))}}function DM(e,t){if(t>=e.length)return e;let i=[];for(let s=0;s{t(e)}),(function(e){i(e)}))}}function TM(e,t,i){i=i||2;var s,r,o,n,a,l,A,h=t&&t.length,c=h?t[0]*i:e.length,u=RM(e,0,c,i,!0),d=[];if(!u||u.next===u.prev)return d;if(h&&(u=function(e,t,i,s){var r,o,n,a=[];for(r=0,o=t.length;r80*i){s=o=e[0],r=n=e[1];for(var p=i;po&&(o=a),l>n&&(n=l);A=0!==(A=Math.max(o-s,n-r))?1/A:0}return UM(u,d,i,s,r,A),d}function RM(e,t,i,s,r){var o,n;if(r===rF(e,t,i,s)>0)for(o=t;o=t;o-=s)n=tF(o,e[o],e[o+1],n);return n&&JM(n,n.next)&&(iF(n),n=n.next),n}function LM(e,t){if(!e)return e;t||(t=e);var i,s=e;do{if(i=!1,s.steiner||!JM(s,s.next)&&0!==XM(s.prev,s,s.next))s=s.next;else{if(iF(s),(s=t=s.prev)===s.next)break;i=!0}}while(i||s!==t);return t}function UM(e,t,i,s,r,o,n){if(e){!n&&o&&function(e,t,i,s){var r=e;do{null===r.z&&(r.z=GM(r.x,r.y,t,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,i,s,r,o,n,a,l,A=1;do{for(i=e,e=null,o=null,n=0;i;){for(n++,s=i,a=0,t=0;t0||l>0&&s;)0!==a&&(0===l||!s||i.z<=s.z)?(r=i,i=i.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=s}o.nextZ=null,A*=2}while(n>1)}(r)}(e,s,r,o);for(var a,l,A=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?OM(e,s,r,o):kM(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),iF(e),e=l.next,A=l.next;else if((e=l)===A){n?1===n?UM(e=NM(LM(e),t,i),t,i,s,r,o,2):2===n&&QM(e,t,i,s,r,o):UM(LM(e),t,i,s,r,o,1);break}}}function kM(e){var t=e.prev,i=e,s=e.next;if(XM(t,i,s)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(WM(t.x,t.y,i.x,i.y,s.x,s.y,r.x,r.y)&&XM(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function OM(e,t,i,s){var r=e.prev,o=e,n=e.next;if(XM(r,o,n)>=0)return!1;for(var a=r.xo.x?r.x>n.x?r.x:n.x:o.x>n.x?o.x:n.x,h=r.y>o.y?r.y>n.y?r.y:n.y:o.y>n.y?o.y:n.y,c=GM(a,l,t,i,s),u=GM(A,h,t,i,s),d=e.prevZ,p=e.nextZ;d&&d.z>=c&&p&&p.z<=u;){if(d!==e.prev&&d!==e.next&&WM(r.x,r.y,o.x,o.y,n.x,n.y,d.x,d.y)&&XM(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&&WM(r.x,r.y,o.x,o.y,n.x,n.y,p.x,p.y)&&XM(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=c;){if(d!==e.prev&&d!==e.next&&WM(r.x,r.y,o.x,o.y,n.x,n.y,d.x,d.y)&&XM(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=u;){if(p!==e.prev&&p!==e.next&&WM(r.x,r.y,o.x,o.y,n.x,n.y,p.x,p.y)&&XM(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function NM(e,t,i){var s=e;do{var r=s.prev,o=s.next.next;!JM(r,o)&&YM(r,s,s.next,o)&&$M(r,o)&&$M(o,r)&&(t.push(r.i/i),t.push(s.i/i),t.push(o.i/i),iF(s),iF(s.next),s=e=o),s=s.next}while(s!==e);return LM(s)}function QM(e,t,i,s,r,o){var n=e;do{for(var a=n.next.next;a!==n.prev;){if(n.i!==a.i&&KM(n,a)){var l=eF(n,a);return n=LM(n,n.next),l=LM(l,l.next),UM(n,t,i,s,r,o),void UM(l,t,i,s,r,o)}a=a.next}n=n.next}while(n!==e)}function VM(e,t){return e.x-t.x}function HM(e,t){if(t=function(e,t){var i,s=t,r=e.x,o=e.y,n=-1/0;do{if(o<=s.y&&o>=s.next.y&&s.next.y!==s.y){var a=s.x+(o-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(a<=r&&a>n){if(n=a,a===r){if(o===s.y)return s;if(o===s.next.y)return s.next}i=s.x=s.x&&s.x>=h&&r!==s.x&&WM(oi.x||s.x===i.x&&jM(i,s)))&&(i=s,u=l)),s=s.next}while(s!==A);return i}(e,t),t){var i=eF(t,e);LM(t,t.next),LM(i,i.next)}}function jM(e,t){return XM(e.prev,e,t.prev)<0&&XM(t.next,e,e.next)<0}function GM(e,t,i,s,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function zM(e){var t=e,i=e;do{(t.x=0&&(e-n)*(s-a)-(i-n)*(t-a)>=0&&(i-n)*(o-a)-(r-n)*(s-a)>=0}function KM(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&YM(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&($M(e,t)&&$M(t,e)&&function(e,t){var i=e,s=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==e);return s}(e,t)&&(XM(e.prev,e,t.prev)||XM(e,t.prev,t))||JM(e,t)&&XM(e.prev,e,e.next)>0&&XM(t.prev,t,t.next)>0)}function XM(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function JM(e,t){return e.x===t.x&&e.y===t.y}function YM(e,t,i,s){var r=qM(XM(e,t,i)),o=qM(XM(e,t,s)),n=qM(XM(i,s,e)),a=qM(XM(i,s,t));return r!==o&&n!==a||(!(0!==r||!ZM(e,i,t))||(!(0!==o||!ZM(e,s,t))||(!(0!==n||!ZM(i,e,s))||!(0!==a||!ZM(i,t,s)))))}function ZM(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function qM(e){return e>0?1:e<0?-1:0}function $M(e,t){return XM(e.prev,e,e.next)<0?XM(e,t,e.next)>=0&&XM(e,e.prev,t)>=0:XM(e,t,e.prev)<0||XM(e,e.next,t)<0}function eF(e,t){var i=new sF(e.i,e.x,e.y),s=new sF(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,s.next=i,i.prev=s,o.next=s,s.prev=o,s}function tF(e,t,i,s){var r=new sF(e,t,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function iF(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function sF(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function rF(e,t,i,s){for(var r=0,o=t,n=i-s;o0&&(s+=e[r-1].length,i.holes.push(s))}return i};const oF=d.vec2(),nF=d.vec3(),aF=d.vec3(),lF=d.vec3();class AF extends z{constructor(e,t={}){super("cityJSONLoader",e,t),this.dataSource=t.dataSource}get dataSource(){return this._dataSource}set dataSource(e){this._dataSource=e||new SM}load(e={}){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);const t=new _c(this.viewer.scene,y.apply(e,{isModel:!0,edges:!0}));if(!e.src&&!e.cityJSON)return this.error("load() param expected: src or cityJSON"),t;const i={};if(e.src)this._loadModel(e.src,e,i,t);else{const s=this.viewer.scene.canvas.spinner;s.processes++,this._parseModel(e.cityJSON,e,i,t),s.processes--}return t}_loadModel(e,t,i,s){const r=this.viewer.scene.canvas.spinner;r.processes++,this._dataSource.getCityJSON(t.src,(e=>{this._parseModel(e,t,i,s),r.processes--}),(e=>{r.processes--,this.error(e),s.fire("error",e)}))}_parseModel(e,t,i,s){if(s.destroyed)return;const r=e.transform?this._transformVertices(e.vertices,e.transform,i.rotateX):e.vertices,o=t.stats||{};o.sourceFormat=e.type||"CityJSON",o.schemaVersion=e.version||"",o.title="",o.author="",o.created="",o.numMetaObjects=0,o.numPropertySets=0,o.numObjects=0,o.numGeometries=0,o.numTriangles=0,o.numVertices=0;const n=!1!==t.loadMetadata,a=n?{id:d.createUUID(),name:"Model",type:"Model"}:null,l=n?{id:"",projectId:"",author:"",createdAt:"",schema:e.version||"",creatingApplication:"",metaObjects:[a],propertySets:[]}:null,A={data:e,vertices:r,sceneModel:s,loadMetadata:n,metadata:l,rootMetaObject:a,nextId:0,stats:o};if(this._parseCityJSON(A),s.finalize(),n){const e=s.id;this.viewer.metaScene.createMetaModel(e,A.metadata,i)}s.scene.once("tick",(()=>{s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}_transformVertices(e,t,i){const s=[],r=t.scale||d.vec3([1,1,1]),o=t.translate||d.vec3([0,0,0]);for(let t=0,n=0;t0))return;const o=[];for(let i=0,s=t.geometry.length;i0){const r=t[s[0]];if(void 0!==r.value)n=e[r.value];else{const t=r.values;if(t){a=[];for(let s=0,r=t.length;s0&&(s.createEntity({id:i,meshIds:o,isObject:!0}),e.stats.numObjects++)}_parseGeometrySurfacesWithOwnMaterials(e,t,i,s){switch(t.type){case"MultiPoint":case"MultiLineString":break;case"MultiSurface":case"CompositeSurface":const r=t.boundaries;this._parseSurfacesWithOwnMaterials(e,i,r,s);break;case"Solid":const o=t.boundaries;for(let t=0;t0&&h.push(A.length);const i=this._extractLocalIndices(e,a[t],c,u);A.push(...i)}if(3===A.length)u.indices.push(A[0]),u.indices.push(A[1]),u.indices.push(A[2]);else if(A.length>3){const e=[];for(let t=0;t0&&n.indices.length>0){const t=""+e.nextId++;r.createMesh({id:t,primitive:"triangles",positions:n.positions,indices:n.indices,color:i&&i.diffuseColor?i.diffuseColor:[.8,.8,.8],opacity:1}),s.push(t),e.stats.numGeometries++,e.stats.numVertices+=n.positions.length/3,e.stats.numTriangles+=n.indices.length/3}}_parseSurfacesWithSharedMaterial(e,t,i,s){const r=e.vertices;for(let o=0;o0&&a.push(n.length);const l=this._extractLocalIndices(e,t[o][r],i,s);n.push(...l)}if(3===n.length)s.indices.push(n[0]),s.indices.push(n[1]),s.indices.push(n[2]);else if(n.length>3){let e=[];for(let t=0;t>t;i.sort(Hc);for(var a=new Int32Array(e.length),l=0,u=i.length;le[r+1]){var o=e[r];e[r]=e[r+1],e[r+1]=o}Gc=new Int32Array(e),t.sort(zc);for(var a=new Int32Array(e.length),l=0,u=t.length;l0)for(var s=i._meshes,r=0,n=s.length;r0)for(var o=this._meshes,a=0,l=o.length;a1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._dtxEnabled=s.scene.dtxEnabled&&!1!==r.dtxEnabled,s._enableVertexWelding=!1,s._enableIndexBucketing=!1,s._vboBatchingLayerScratchMemory=ro(),s._textureTranscoder=r.textureTranscoder||Lc(s.scene.viewer),s._maxGeometryBatchSize=r.maxGeometryBatchSize,s._aabb=$.collapseAABB3(),s._aabbDirty=!0,s._quantizationRanges={},s._vboInstancingLayers={},s._vboBatchingLayers={},s._dtxLayers={},s._meshList=[],s.layerList=[],s._entityList=[],s._geometries={},s._dtxBuckets={},s._textures={},s._textureSets={},s._transforms={},s._meshes={},s._unusedMeshes={},s._entities={},s.renderFlags=new zr,s.numGeometries=0,s.numPortions=0,s.numVisibleLayerPortions=0,s.numTransparentLayerPortions=0,s.numXRayedLayerPortions=0,s.numHighlightedLayerPortions=0,s.numSelectedLayerPortions=0,s.numEdgesLayerPortions=0,s.numPickableLayerPortions=0,s.numClippableLayerPortions=0,s.numCulledLayerPortions=0,s.numEntities=0,s._numTriangles=0,s._numLines=0,s._numPoints=0,s._edgeThreshold=r.edgeThreshold||10,s._origin=$.vec3(r.origin||[0,0,0]),s._position=$.vec3(r.position||[0,0,0]),s._rotation=$.vec3(r.rotation||[0,0,0]),s._quaternion=$.vec4(r.quaternion||[0,0,0,1]),s._conjugateQuaternion=$.vec4(r.quaternion||[0,0,0,1]),r.rotation&&$.eulerToQuaternion(s._rotation,"XYZ",s._quaternion),s._scale=$.vec3(r.scale||[1,1,1]),s._worldRotationMatrix=$.mat4(),s._worldRotationMatrixConjugate=$.mat4(),s._matrix=$.mat4(),s._matrixDirty=!0,s._rebuildMatrices(),s._worldNormalMatrix=$.mat4(),$.inverseMat4(s._matrix,s._worldNormalMatrix),$.transposeMat4(s._worldNormalMatrix),(r.matrix||r.position||r.rotation||r.scale||r.quaternion)&&(s._viewMatrix=$.mat4(),s._viewNormalMatrix=$.mat4(),s._viewMatrixDirty=!0,s._matrixNonIdentity=!0),s._opacity=1,s._colorize=[1,1,1],s._saoEnabled=!1!==r.saoEnabled,s._pbrEnabled=!1!==r.pbrEnabled,s._colorTextureEnabled=!1!==r.colorTextureEnabled,s._isModel=r.isModel,s._isModel&&s.scene._registerModel(b(s)),s._onCameraViewMatrix=s.scene.camera.on("matrix",(function(){s._viewMatrixDirty=!0})),s._meshesWithDirtyMatrices=[],s._numMeshesWithDirtyMatrices=0,s._onTick=s.scene.on("tick",(function(){for(;s._numMeshesWithDirtyMatrices>0;)s._meshesWithDirtyMatrices[--s._numMeshesWithDirtyMatrices]._updateMatrix()})),s._createDefaultTextureSet(),s.visible=r.visible,s.culled=r.culled,s.pickable=r.pickable,s.clippable=r.clippable,s.collidable=r.collidable,s.castsShadow=r.castsShadow,s.receivesShadow=r.receivesShadow,s.xrayed=r.xrayed,s.highlighted=r.highlighted,s.selected=r.selected,s.edges=r.edges,s.colorize=r.colorize,s.opacity=r.opacity,s.backfaces=r.backfaces,s}return C(i,[{key:"_meshMatrixDirty",value:function(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}},{key:"_createDefaultTextureSet",value:function(){var e=new Pc({id:"defaultColorTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),t=new Pc({id:"defaultMetalRoughTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),i=new Pc({id:"defaultNormalsTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),s=new Pc({id:"defaultEmissiveTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),r=new Pc({id:"defaultOcclusionTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures.defaultColorTexture=e,this._textures.defaultMetalRoughTexture=t,this._textures.defaultNormalsTexture=i,this._textures.defaultEmissiveTexture=s,this._textures.defaultOcclusionTexture=r,this._textureSets.defaultTextureSet=new xc({id:"defaultTextureSet",model:this,colorTexture:e,metallicRoughnessTexture:t,normalsTexture:i,emissiveTexture:s,occlusionTexture:r})}},{key:"isPerformanceModel",get:function(){return!0}},{key:"transforms",get:function(){return this._transforms}},{key:"textures",get:function(){return this._textures}},{key:"textureSets",get:function(){return this._textureSets}},{key:"meshes",get:function(){return this._meshes}},{key:"objects",get:function(){return this._entities}},{key:"origin",get:function(){return this._origin}},{key:"position",get:function(){return this._position},set:function(e){this._position.set(e||[0,0,0]),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation.set(e||[0,0,0]),$.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"quaternion",get:function(){return this._quaternion},set:function(e){this._quaternion.set(e||[0,0,0,1]),$.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"scale",get:function(){return this._scale},set:function(e){}},{key:"matrix",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._matrix},set:function(e){this._matrix.set(e||lh),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),$.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),$.translateMat4v(this._position,this._matrix),this._matrixDirty=!1,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"rotationMatrix",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrix}},{key:"_rebuildMatrices",value:function(){this._matrixDirty&&($.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),$.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),$.translateMat4v(this._position,this._matrix),this._matrixDirty=!1)}},{key:"rotationMatrixConjugate",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrixConjugate}},{key:"_setWorldMatrixDirty",value:function(){this._matrixDirty=!0,this._aabbDirty=!0}},{key:"_transformDirty",value:function(){this._matrixDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0}},{key:"_sceneModelDirty",value:function(){this.scene._aabbDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._matrixDirty=!0;for(var e=0,t=this._entityList.length;e0},set:function(e){e=!1!==e,this._visible=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!!e,this._xrayed=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!!e,this._highlighted=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!!e,this._selected=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!!e,this._edges=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!1!==e,this._pickable=e;for(var t=0,i=this._entityList.length;t0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){for(var l=e.colors,u=new Uint8Array(l.length),A=0,c=l.length;A>24&255,r=i>>16&255,n=i>>8&255,o=255&i;switch(e.pickColor=new Uint8Array([o,n,r,s]),e.solid="solid"===e.primitive,t.origin=$.vec3(e.origin),e.type){case 2:t.layer=this._getDTXLayer(e),t.aabb=e.aabb;break;case 1:t.layer=this._getVBOBatchingLayer(e),t.aabb=e.aabb;break;case 0:t.layer=this._getVBOInstancingLayer(e),t.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),t.portionId=t.layer.createPortion(t,e),this._meshes[e.id]=t,this._unusedMeshes[e.id]=t,this._meshList.push(t),t}},{key:"_getNumPrimitives",value:function(e){var t=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(var i=0,s=e.buckets.length;i>>0).toString(16)}},{key:"_getVBOInstancingLayer",value:function(e){var t=this,i=e.origin,s=e.textureSetId||"-",r=e.geometryId,n="".concat(Math.round(i[0]),".").concat(Math.round(i[1]),".").concat(Math.round(i[2]),".").concat(s,".").concat(r),o=this._vboInstancingLayers[n];if(o)return o;for(var a=e.textureSet,l=e.geometry;!o;)switch(l.primitive){case"triangles":case"surface":o=new sl({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!1});break;case"solid":o=new sl({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!0});break;case"lines":o=new Hl({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0});break;case"points":o=new Ru({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0})}return this._vboInstancingLayers[n]=o,this.layerList.push(o),o}},{key:"createEntity",value:function(e){if(void 0===e.id?e.id=$.createUUID():this.scene.components[e.id]&&(this.error("Scene already has a Component with this ID: ".concat(e.id," - will assign random ID")),e.id=$.createUUID()),void 0!==e.meshIds){var t=0;this._visible&&!1!==e.visible&&(t|=Qe),this._pickable&&!1!==e.pickable&&(t|=He),this._culled&&!1!==e.culled&&(t|=Ve),this._clippable&&!1!==e.clippable&&(t|=je),this._collidable&&!1!==e.collidable&&(t|=Ge),this._edges&&!1!==e.edges&&(t|=Xe),this._xrayed&&!1!==e.xrayed&&(t|=ze),this._highlighted&&!1!==e.highlighted&&(t|=We),this._selected&&!1!==e.selected&&(t|=Ke),e.flags=t,this._createEntity(e)}else this.error("Config missing: meshIds")}},{key:"_createEntity",value:function(e){for(var t=[],i=0,s=e.meshIds.length;it.sortId?1:0}));for(var o=0,a=this.layerList.length;o0&&0===this.renderFlags.numVisibleLayers?this.renderFlags.culled=!0:this._updateRenderFlags()}},{key:"_updateRenderFlagsVisibleLayers",value:function(){var e=this.renderFlags;e.numLayers=this.layerList.length,e.numVisibleLayers=0;for(var t=0,i=this.layerList.length;t0){var t="".concat(this.id,"-dummyEntityForUnusedMeshes");this.warn('Creating dummy SceneModelEntity "'.concat(t,'" for unused SceneMeshes: [').concat(e.join(","),"]")),this.createEntity({id:t,meshIds:e,isObject:!0})}this._unusedMeshes={}}},{key:"_getActiveSectionPlanesForLayer",value:function(e){var t=this.renderFlags,i=this.scene._sectionPlanesState.sectionPlanes,s=i.length,r=e.layerIndex*s;if(s>0)for(var n=0;n0&&(e.colorTransparent=!0),this.numXRayedLayerPortions>0){var t=this.scene.xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}if(this.numEdgesLayerPortions>0)this.scene.edgeMaterial._state.edges&&(e.edgesOpaque=this.numTransparentLayerPortions0&&(e.edgesTransparent=!0));if(this.numSelectedLayerPortions>0){var i=this.scene.selectedMaterial._state;i.fill&&(i.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),i.edges&&(i.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){var s=this.scene.highlightMaterial._state;s.fill&&(s.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),s.edges&&(s.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}}},{key:"drawColorOpaque",value:function(e){for(var t=this.renderFlags,i=0,s=t.visibleLayers.length;i2&&void 0!==arguments[2]&&arguments[2],s=e.positionsCompressed||[],r=jc(e.indices||[],t),n=Wc(e.edgeIndices||[]);function o(e,t){if(e>t){var i=e;e=t,t=i}function s(i,s){return i!==e?e-i:s!==t?t-s:0}for(var r=0,o=(n.length>>1)-1;r<=o;){var a=o+r>>1,l=s(n[2*a],n[2*a+1]);if(l>0)r=a+1;else{if(!(l<0))return a;o=a-1}}return-r-1}var a=new Int32Array(n.length/2);a.fill(0);var l=s.length/3;if(l>8*(1<h.maxNumPositions&&(h=c()),h.bucketNumber>8)return[e];-1===u[v]&&(u[v]=h.numPositions++,h.positionsCompressed.push(s[3*v]),h.positionsCompressed.push(s[3*v+1]),h.positionsCompressed.push(s[3*v+2])),-1===u[g]&&(u[g]=h.numPositions++,h.positionsCompressed.push(s[3*g]),h.positionsCompressed.push(s[3*g+1]),h.positionsCompressed.push(s[3*g+2])),-1===u[m]&&(u[m]=h.numPositions++,h.positionsCompressed.push(s[3*m]),h.positionsCompressed.push(s[3*m+1]),h.positionsCompressed.push(s[3*m+2])),h.indices.push(u[v]),h.indices.push(u[g]),h.indices.push(u[m]);var _=void 0;(_=o(v,g))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]])),(_=o(v,m))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]])),(_=o(g,m))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]]))}var y=t/8*2,b=t/8,B=2*s.length+(r.length+n.length)*y,w=0;return s.length,A.forEach((function(e){w+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*b,e.positionsCompressed.length})),w>B?[e]:(i&&Kc(A,e),A)}({positionsCompressed:s,indices:r,edgeIndices:n},s.length/3>65536?16:8):o=[{positionsCompressed:s,indices:r,edgeIndices:n}];return o}var hh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,e,r))._positions=r.positions||[],r.indices)s._indices=r.indices;else{s._indices=[];for(var n=0,o=s._positions.length/3-1;n1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"BCFViewpoints",e,r)).originatingSystem=r.originatingSystem||"xeokit.io",s.authoringTool=r.authoringTool||"xeokit.io",s}return C(i,[{key:"getViewpoint",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=this.viewer.scene,s=i.camera,r=i.realWorldOffset,n=!0===t.reverseClippingPlanes,o={},a=$.normalizeVec3($.subVec3(s.look,s.eye,$.vec3())),l=s.eye,u=s.up;s.yUp&&(a=yh(a),l=yh(l),u=yh(u));var A=mh($.addVec3(l,r));"ortho"===s.projection?o.orthogonal_camera={camera_view_point:A,camera_direction:mh(a),camera_up_vector:mh(u),view_to_world_scale:s.ortho.scale}:o.perspective_camera={camera_view_point:A,camera_direction:mh(a),camera_up_vector:mh(u),field_of_view:s.perspective.fov};var c=i.sectionPlanes;for(var d in c)if(c.hasOwnProperty(d)){var p=c[d];if(!p.active)continue;var f=p.pos,v=void 0;v=n?$.negateVec3(p.dir,$.vec3()):p.dir,s.yUp&&(f=yh(f),v=yh(v)),$.addVec3(f,r),f=mh(f),v=mh(v),o.clipping_planes||(o.clipping_planes=[]),o.clipping_planes.push({location:f,direction:v})}var g=i.lineSets;for(var m in g)if(g.hasOwnProperty(m)){var _=g[m];o.lines||(o.lines=[]);for(var y=_.positions,b=_.indices,B=0,w=b.length/2;B1&&void 0!==arguments[1]?arguments[1]:{};if(e){var s=this.viewer,r=s.scene,n=r.camera,o=!1!==i.rayCast,a=!1!==i.immediate,l=!1!==i.reset,u=r.realWorldOffset,A=!0===i.reverseClippingPlanes;if(r.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){var t=_h(e.location,dh),i=_h(e.direction,dh);A&&$.negateVec3(i),$.subVec3(t,u),n.yUp&&(t=bh(t),i=bh(i)),new An(r,{pos:t,dir:i})})),r.clearLines(),e.lines&&e.lines.length>0){var c=[],h=[],d=0;e.lines.forEach((function(e){e.start_point&&e.end_point&&(c.push(e.start_point.x),c.push(e.start_point.y),c.push(e.start_point.z),c.push(e.end_point.x),c.push(e.end_point.y),c.push(e.end_point.z),h.push(d++),h.push(d++))})),new hh(r,{positions:c,indices:h,clippable:!1,collidable:!0})}if(r.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){var t=e.bitmap_type||"jpg",i=e.bitmap_data,s=_h(e.location,ph),o=_h(e.normal,fh),a=_h(e.up,vh),l=e.height||1;t&&i&&s&&o&&a&&(n.yUp&&(s=bh(s),o=bh(o),a=bh(a)),new Zn(r,{src:i,type:t,pos:s,normal:o,up:a,clippable:!1,collidable:!0,height:l}))})),l&&(r.setObjectsXRayed(r.xrayedObjectIds,!1),r.setObjectsHighlighted(r.highlightedObjectIds,!1),r.setObjectsSelected(r.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(r.setObjectsVisible(r.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.visible=!1}))}))):(r.setObjectsVisible(r.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.visible=!0}))})));var p=e.components.visibility.view_setup_hints;p&&(!1===p.spaces_visible&&r.setObjectsVisible(s.metaScene.getObjectIDsByType("IfcSpace"),!0),void 0!==p.spaces_translucent&&r.setObjectsXRayed(s.metaScene.getObjectIDsByType("IfcSpace"),!0),p.space_boundaries_visible,!1===p.openings_visible&&r.setObjectsVisible(s.metaScene.getObjectIDsByType("IfcOpening"),!0),p.space_boundaries_translucent,void 0!==p.openings_translucent&&r.setObjectsXRayed(s.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(r.setObjectsSelected(r.selectedObjectIds,!1),e.components.selection.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.selected=!0}))}))),e.components.translucency&&(r.setObjectsXRayed(r.xrayedObjectIds,!1),e.components.translucency.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.xrayed=!0}))}))),e.components.coloring&&e.components.coloring.forEach((function(e){var s=e.color,r=0,n=!1;8===s.length&&((r=parseInt(s.substring(0,2),16)/256)<=1&&r>=.95&&(r=1),s=s.substring(2),n=!0);var o=[parseInt(s.substring(0,2),16)/256,parseInt(s.substring(2,4),16)/256,parseInt(s.substring(4,6),16)/256];e.components.map((function(e){return t._withBCFComponent(i,e,(function(e){e.colorize=o,n&&(e.opacity=r)}))}))}))}if(e.perspective_camera||e.orthogonal_camera){var f,v,g,m;if(e.perspective_camera?(f=_h(e.perspective_camera.camera_view_point,dh),v=_h(e.perspective_camera.camera_direction,dh),g=_h(e.perspective_camera.camera_up_vector,dh),n.perspective.fov=e.perspective_camera.field_of_view,m="perspective"):(f=_h(e.orthogonal_camera.camera_view_point,dh),v=_h(e.orthogonal_camera.camera_direction,dh),g=_h(e.orthogonal_camera.camera_up_vector,dh),n.ortho.scale=e.orthogonal_camera.view_to_world_scale,m="ortho"),$.subVec3(f,u),n.yUp&&(f=bh(f),v=bh(v),g=bh(g)),o){var _=r.pick({pickSurface:!0,origin:f,direction:v});v=_?_.worldPos:$.addVec3(f,v,dh)}else v=$.addVec3(f,v,dh);a?(n.eye=f,n.look=v,n.up=g,n.projection=m):s.cameraFlight.flyTo({eye:f,look:v,up:g,duration:i.duration,projection:m})}}}},{key:"_withBCFComponent",value:function(e,t,i){var s=this.viewer,r=s.scene;if(t.authoring_tool_id&&t.originating_system===this.originatingSystem){var n=t.authoring_tool_id,o=r.objects[n];if(o)return void i(o);if(e.updateCompositeObjects)if(s.metaScene.metaObjects[n])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}if(t.ifc_guid){var a=t.ifc_guid,l=r.objects[a];if(l)return void i(l);if(e.updateCompositeObjects)if(s.metaScene.metaObjects[a])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(a),i);Object.keys(r.models).forEach((function(t){var n=$.globalizeObjectId(t,a),o=r.objects[n];o?i(o):e.updateCompositeObjects&&s.metaScene.metaObjects[n]&&r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}))}}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this)}}]),i}();function mh(e){return{x:e[0],y:e[1],z:e[2]}}function _h(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function yh(e){return new Float64Array([e[0],-e[2],e[1]])}function bh(e){return new Float64Array([e[0],e[2],-e[1]])}function Bh(e){var t="";return t+=Math.round(255*e[0]).toString(16).padStart(2,"0"),t+=Math.round(255*e[1]).toString(16).padStart(2,"0"),t+=Math.round(255*e[2]).toString(16).padStart(2,"0")}var wh=$.vec3(),xh=function(e,t,i,s){var r=e-i,n=t-s;return Math.sqrt(r*r+n*n)},Ph=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,e.viewer.scene,r)).plugin=e,s._container=r.container,!s._container)throw"config missing: container";s._eventSubs={};var n=s.plugin.viewer.scene;s._originMarker=new et(n,r.origin),s._targetMarker=new et(n,r.target),s._originWorld=$.vec3(),s._targetWorld=$.vec3(),s._wp=new Float64Array(24),s._vp=new Float64Array(24),s._pp=new Float64Array(24),s._cp=new Float64Array(8),s._xAxisLabelCulled=!1,s._yAxisLabelCulled=!1,s._zAxisLabelCulled=!1,s._color=r.color||s.plugin.defaultColor;var o=r.onMouseOver?function(e){r.onMouseOver(e,b(s)),s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,a=r.onMouseLeave?function(e){r.onMouseLeave(e,b(s)),s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,l=function(e){s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},u=function(e){s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},A=function(e){s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},c=r.onContextMenu?function(e){r.onContextMenu(e,b(s))}:null,h=function(e){s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};return s._originDot=new it(s._container,{fillColor:s._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._targetDot=new it(s._container,{fillColor:s._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._lengthWire=new tt(s._container,{color:s._color,thickness:2,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._xAxisWire=new tt(s._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._yAxisWire=new tt(s._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._zAxisWire=new tt(s._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._lengthLabel=new st(s._container,{fillColor:s._color,prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._xAxisLabel=new st(s._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._yAxisLabel=new st(s._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._zAxisLabel=new st(s._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._wpDirty=!1,s._vpDirty=!1,s._cpDirty=!1,s._sectionPlanesDirty=!0,s._visible=!1,s._originVisible=!1,s._targetVisible=!1,s._wireVisible=!1,s._axisVisible=!1,s._xAxisVisible=!1,s._yAxisVisible=!1,s._zAxisVisible=!1,s._axisEnabled=!0,s._labelsVisible=!1,s._labelsOnWires=!1,s._clickable=!1,s._originMarker.on("worldPos",(function(e){s._originWorld.set(e||[0,0,0]),s._wpDirty=!0,s._needUpdate(0)})),s._targetMarker.on("worldPos",(function(e){s._targetWorld.set(e||[0,0,0]),s._wpDirty=!0,s._needUpdate(0)})),s._onViewMatrix=n.camera.on("viewMatrix",(function(){s._vpDirty=!0,s._needUpdate(0)})),s._onProjMatrix=n.camera.on("projMatrix",(function(){s._cpDirty=!0,s._needUpdate()})),s._onCanvasBoundary=n.canvas.on("boundary",(function(){s._cpDirty=!0,s._needUpdate(0)})),s._onMetricsUnits=n.metrics.on("units",(function(){s._cpDirty=!0,s._needUpdate()})),s._onMetricsScale=n.metrics.on("scale",(function(){s._cpDirty=!0,s._needUpdate()})),s._onMetricsOrigin=n.metrics.on("origin",(function(){s._cpDirty=!0,s._needUpdate()})),s._onSectionPlaneUpdated=n.on("sectionPlaneUpdated",(function(){s._sectionPlanesDirty=!0,s._needUpdate()})),s.approximate=r.approximate,s.visible=r.visible,s.originVisible=r.originVisible,s.targetVisible=r.targetVisible,s.wireVisible=r.wireVisible,s.axisVisible=r.axisVisible,s.xAxisVisible=r.xAxisVisible,s.yAxisVisible=r.yAxisVisible,s.zAxisVisible=r.zAxisVisible,s.labelsVisible=r.labelsVisible,s.labelsOnWires=r.labelsOnWires,s}return C(i,[{key:"_update",value:function(){if(this._visible){var e=this.plugin.viewer.scene;if(this._wpDirty&&(this._wp[0]=this._originWorld[0],this._wp[1]=this._originWorld[1],this._wp[2]=this._originWorld[2],this._wp[3]=1,this._wp[4]=this._targetWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._targetWorld[0],this._wp[9]=this._targetWorld[1],this._wp[10]=this._originWorld[2],this._wp[11]=1,this._wp[12]=this._targetWorld[0],this._wp[13]=this._targetWorld[1],this._wp[14]=this._targetWorld[2],this._wp[15]=1,this._wpDirty=!1,this._vpDirty=!0),this._vpDirty&&($.transformPositions4(e.camera.viewMatrix,this._wp,this._vp),this._vp[3]=1,this._vp[7]=1,this._vp[11]=1,this._vp[15]=1,this._vpDirty=!1,this._cpDirty=!0),this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld))return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setCulled(!0),this._yAxisWire.setCulled(!0),this._zAxisWire.setCulled(!0),this._lengthWire.setCulled(!0),this._originDot.setCulled(!0),void this._targetDot.setCulled(!0);this._xAxisLabel.setCulled(!1),this._yAxisLabel.setCulled(!1),this._zAxisLabel.setCulled(!1),this._lengthLabel.setCulled(!1),this._xAxisWire.setCulled(!1),this._yAxisWire.setCulled(!1),this._zAxisWire.setCulled(!1),this._lengthWire.setCulled(!1),this._originDot.setCulled(!1),this._targetDot.setCulled(!1),this._sectionPlanesDirty=!0}var t=this._originMarker.viewPos[2],i=this._targetMarker.viewPos[2];if(t>-.3||i>-.3)return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setVisible(!1),this._yAxisWire.setVisible(!1),this._zAxisWire.setVisible(!1),this._lengthWire.setVisible(!1),this._originDot.setVisible(!1),void this._targetDot.setVisible(!1);if(this._cpDirty){$.transformPositions4(e.camera.project.matrix,this._vp,this._pp);for(var s=this._pp,r=this._cp,n=e.canvas.canvas.getBoundingClientRect(),o=this._container.getBoundingClientRect(),a=n.top-o.top,l=n.left-o.left,u=e.canvas.boundary,A=u[2],c=u[3],h=0,d=this.plugin.viewer.scene.metrics,p=d.scale,f=d.units,v=d.unitsInfo[f].abbrev,g=0,m=s.length;g1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e.viewer.scene))._canvasToPagePos=r.canvasToPagePos,s.pointerLens=r.pointerLens,s._active=!1,s._currentDistanceMeasurement=null,s._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},s._initMarkerDiv(),s._onCameraControlHoverSnapOrSurface=null,s._onCameraControlHoverSnapOrSurfaceOff=null,s._onMouseDown=null,s._onMouseUp=null,s._onCanvasTouchStart=null,s._onCanvasTouchEnd=null,s._snapping=!1!==r.snapping,s._mouseState=0,s._attachPlugin(e,r),s}return C(i,[{key:"_initMarkerDiv",value:function(){var e=document.createElement("div");e.setAttribute("id","myMarkerDiv");var t=this.scene.canvas.canvas;t.parentNode.insertBefore(e,t),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.top="-200px",e.style.left="-200px",e.style.margin="0 0",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this._markerDiv=e}},{key:"_destroyMarkerDiv",value:function(){if(this._markerDiv){var e=document.getElementById("myMarkerDiv");e.parentNode.removeChild(e),this._markerDiv=null}}},{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=e}},{key:"active",get:function(){return this._active}},{key:"snapping",get:function(){return this._snapping},set:function(e){e!==this._snapping?(this._snapping=e,this.deactivate(),this.activate()):this._snapping=e}},{key:"activate",value:function(){var e=this;if(!this._active){this._markerDiv||this._initMarkerDiv(),this.fire("activated",!0);var t=this.distanceMeasurementsPlugin,i=this.scene,s=t.viewer.cameraControl,r=i.canvas.canvas;i.input;var n,o,a=!1,l=$.vec3(),u=$.vec2(),A=null;this._mouseState=0;var c=function e(t){return t.offsetTop+(t.offsetParent&&e(t.offsetParent))},h=function e(t){return t.offsetLeft+(t.offsetParent&&e(t.offsetParent))},d=$.vec2();this._onCameraControlHoverSnapOrSurface=s.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(function(t){var i=t.snappedCanvasPos||t.canvasPos;a=!0,l.set(t.worldPos),u.set(t.canvasPos),0===e._mouseState?(e._canvasToPagePos?(e._canvasToPagePos(r,i,d),e._markerDiv.style.left="".concat(d[0]-5,"px"),e._markerDiv.style.top="".concat(d[1]-5,"px")):(e._markerDiv.style.left="".concat(h(r)+i[0]-5,"px"),e._markerDiv.style.top="".concat(c(r)+i[1]-5,"px")),e._markerDiv.style.background="pink",t.snappedToVertex||t.snappedToEdge?(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=t.canvasPos,e.pointerLens.snappedCanvasPos=t.snappedCanvasPos||t.canvasPos,e.pointerLens.snapped=!0),e._markerDiv.style.background="greenyellow",e._markerDiv.style.border="2px solid green"):(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=t.canvasPos,e.pointerLens.snappedCanvasPos=t.canvasPos,e.pointerLens.snapped=!1),e._markerDiv.style.background="pink",e._markerDiv.style.border="2px solid red"),A=t.entity):(e._markerDiv.style.left="-10000px",e._markerDiv.style.top="-10000px"),r.style.cursor="pointer",e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.wireVisible=e._currentDistanceMeasurementInitState.wireVisible,e._currentDistanceMeasurement.axisVisible=e._currentDistanceMeasurementInitState.axisVisible&&e.distanceMeasurementsPlugin.defaultAxisVisible,e._currentDistanceMeasurement.xAxisVisible=e._currentDistanceMeasurementInitState.xAxisVisible&&e.distanceMeasurementsPlugin.defaultXAxisVisible,e._currentDistanceMeasurement.yAxisVisible=e._currentDistanceMeasurementInitState.yAxisVisible&&e.distanceMeasurementsPlugin.defaultYAxisVisible,e._currentDistanceMeasurement.zAxisVisible=e._currentDistanceMeasurementInitState.zAxisVisible&&e.distanceMeasurementsPlugin.defaultZAxisVisible,e._currentDistanceMeasurement.targetVisible=e._currentDistanceMeasurementInitState.targetVisible,e._currentDistanceMeasurement.target.worldPos=l.slice(),e._markerDiv.style.left="-10000px",e._markerDiv.style.top="-10000px")})),r.addEventListener("mousedown",this._onMouseDown=function(e){1===e.which&&(n=e.clientX,o=e.clientY)}),r.addEventListener("mouseup",this._onMouseUp=function(i){1===i.which&&(i.clientX>n+20||i.clientXo+20||i.clientY1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"DistanceMeasurements",e))._pointerLens=r.pointerLens,s._container=r.container||document.body,s._defaultControl=null,s._measurements={},s.labelMinAxisLength=r.labelMinAxisLength,s.defaultVisible=!1!==r.defaultVisible,s.defaultOriginVisible=!1!==r.defaultOriginVisible,s.defaultTargetVisible=!1!==r.defaultTargetVisible,s.defaultWireVisible=!1!==r.defaultWireVisible,s.defaultLabelsVisible=!1!==r.defaultLabelsVisible,s.defaultAxisVisible=!1!==r.defaultAxisVisible,s.defaultXAxisVisible=!1!==r.defaultXAxisVisible,s.defaultYAxisVisible=!1!==r.defaultYAxisVisible,s.defaultZAxisVisible=!1!==r.defaultZAxisVisible,s.defaultColor=void 0!==r.defaultColor?r.defaultColor:"#00BBFF",s.zIndex=r.zIndex||1e4,s.defaultLabelsOnWires=!1!==r.defaultLabelsOnWires,s._onMouseOver=function(e,t){s.fire("mouseOver",{plugin:b(s),distanceMeasurement:t,measurement:t,event:e})},s._onMouseLeave=function(e,t){s.fire("mouseLeave",{plugin:b(s),distanceMeasurement:t,measurement:t,event:e})},s._onContextMenu=function(e,t){s.fire("contextMenu",{plugin:b(s),distanceMeasurement:t,measurement:t,event:e})},s}return C(i,[{key:"getContainerElement",value:function(){return this._container}},{key:"send",value:function(e,t){}},{key:"pointerLens",get:function(){return this._pointerLens}},{key:"control",get:function(){return this._defaultControl||(this._defaultControl=new Mh(this,{})),this._defaultControl}},{key:"measurements",get:function(){return this._measurements}},{key:"labelMinAxisLength",get:function(){return this._labelMinAxisLength},set:function(e){e<1&&(this.error("labelMinAxisLength must be >= 1; defaulting to 25"),e=25),this._labelMinAxisLength=e||25}},{key:"createMeasurement",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.viewer.scene.components[t.id]&&(this.error("Viewer scene component with this ID already exists: "+t.id),delete t.id);var i=t.origin,s=t.target,r=new Ph(this,{id:t.id,plugin:this,container:this._container,origin:{entity:i.entity,worldPos:i.worldPos},target:{entity:s.entity,worldPos:s.worldPos},visible:t.visible,wireVisible:t.wireVisible,axisVisible:!1!==t.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==t.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==t.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==t.zAxisVisible&&!1!==this.defaultZAxisVisible,labelsVisible:!1!==t.labelsVisible&&!1!==this.defaultLabelsVisible,originVisible:t.originVisible,targetVisible:t.targetVisible,color:t.color,labelsOnWires:!1!==t.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[r.id]=r,r.on("destroyed",(function(){delete e._measurements[r.id]})),this.fire("measurementCreated",r),r}},{key:"destroyMeasurement",value:function(e){var t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("DistanceMeasurement not found: "+e)}},{key:"setLabelsShown",value:function(e){for(var t=0,i=Object.entries(this.measurements);t1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(s=t.call(this,e.viewer.scene)).pointerLens=r.pointerLens,s.pointerCircle=new De(e.viewer),s._active=!1;var n=document.createElement("div"),o=s.scene.canvas.canvas;return o.parentNode.insertBefore(n,o),n.style.background="black",n.style.border="2px solid blue",n.style.borderRadius="10px",n.style.width="5px",n.style.height="5px",n.style.margin="-200px -200px",n.style.zIndex="100",n.style.position="absolute",n.style.pointerEvents="none",s.markerDiv=n,s._currentDistanceMeasurement=null,s._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},s._onCanvasTouchStart=null,s._onCanvasTouchEnd=null,s._longTouchTimeoutMs=300,s._snapToEdge=!1!==r.snapToEdge,s._snapToVertex=!1!==r.snapToVertex,s._touchState=0,s._attachPlugin(e,r),s}return C(i,[{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=e}},{key:"active",get:function(){return this._active}},{key:"snapToVertex",get:function(){return this._snapToVertex},set:function(e){this._snapToVertex=e}},{key:"snapToEdge",get:function(){return this._snapToEdge},set:function(e){this._snapToEdge=e}},{key:"activate",value:function(){var e=this;if(!this._active){var t=this.plugin,i=this.scene,s=i.canvas.canvas;t.pointerLens;var r=$.vec3(),n=20,o=null;this._touchState=0;var a=$.vec2(),l=$.vec2(),u=$.vec2(),A=null,c=function(){e.plugin.viewer.cameraControl.active=!1},h=function(){e.plugin.viewer.cameraControl.active=!0};s.addEventListener("touchstart",this._onCanvasTouchStart=function(s){var u=s.touches.length;if(1===u){var d=s.touches[0],p=d.clientX,f=d.clientY;switch(a.set([p,f]),l.set([p,f]),e._touchState){case 0:if(1!==u&&null!==o)return o&&(clearTimeout(o),o=null),e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),h(),void(e._touchState=0);var v=i.pick({canvasPos:l,snapToVertex:e._snapToVertex,snapToEdge:e._snapToEdge});if(v&&v.snapped)r.set(v.worldPos),e.pointerCircle.start(v.snappedCanvasPos);else{var g=i.pick({canvasPos:l,pickSurface:!0});if(!g||!g.worldPos)return;r.set(g.worldPos),e.pointerCircle.start(g.canvasPos)}o=setTimeout((function(){1!==u||l[0]>a[0]+n||l[0]a[1]+n||l[1]a[0]+n||l[0]a[1]+n||l[1]a[0]+n||da[1]+n||pa[0]+n||da[1]+n||p1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(s=t.call(this,"FastNav",e))._hideColorTexture=!1!==r.hideColorTexture,s._hidePBR=!1!==r.hidePBR,s._hideSAO=!1!==r.hideSAO,s._hideEdges=!1!==r.hideEdges,s._hideTransparentObjects=!!r.hideTransparentObjects,s._scaleCanvasResolution=!!r.scaleCanvasResolution,s._defaultScaleCanvasResolutionFactor=r.defaultScaleCanvasResolutionFactor||1,s._scaleCanvasResolutionFactor=r.scaleCanvasResolutionFactor||.6,s._delayBeforeRestore=!1!==r.delayBeforeRestore,s._delayBeforeRestoreSeconds=r.delayBeforeRestoreSeconds||.5;var n=1e3*s._delayBeforeRestoreSeconds,o=!1,a=function(){n=1e3*s._delayBeforeRestoreSeconds,o||(e.scene._renderer.setColorTextureEnabled(!s._hideColorTexture),e.scene._renderer.setPBREnabled(!s._hidePBR),e.scene._renderer.setSAOEnabled(!s._hideSAO),e.scene._renderer.setTransparentEnabled(!s._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!s._hideEdges),s._scaleCanvasResolution?e.scene.canvas.resolutionScale=s._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=s._defaultScaleCanvasResolutionFactor,o=!0)},l=function(){e.scene.canvas.resolutionScale=s._defaultScaleCanvasResolutionFactor,e.scene._renderer.setEdgesEnabled(!0),e.scene._renderer.setColorTextureEnabled(!0),e.scene._renderer.setPBREnabled(!0),e.scene._renderer.setSAOEnabled(!0),e.scene._renderer.setTransparentEnabled(!0),o=!1};s._onCanvasBoundary=e.scene.canvas.on("boundary",a),s._onCameraMatrix=e.scene.camera.on("matrix",a),s._onSceneTick=e.scene.on("tick",(function(e){o&&(n-=e.deltaTime,(!s._delayBeforeRestore||n<=0)&&l())}));var u=!1;return s._onSceneMouseDown=e.scene.input.on("mousedown",(function(){u=!0})),s._onSceneMouseUp=e.scene.input.on("mouseup",(function(){u=!1})),s._onSceneMouseMove=e.scene.input.on("mousemove",(function(){u&&a()})),s}return C(i,[{key:"hideColorTexture",get:function(){return this._hideColorTexture},set:function(e){this._hideColorTexture=e}},{key:"hidePBR",get:function(){return this._hidePBR},set:function(e){this._hidePBR=e}},{key:"hideSAO",get:function(){return this._hideSAO},set:function(e){this._hideSAO=e}},{key:"hideEdges",get:function(){return this._hideEdges},set:function(e){this._hideEdges=e}},{key:"hideTransparentObjects",get:function(){return this._hideTransparentObjects},set:function(e){this._hideTransparentObjects=!1!==e}},{key:"scaleCanvasResolution",get:function(){return this._scaleCanvasResolution},set:function(e){this._scaleCanvasResolution=e}},{key:"defaultScaleCanvasResolutionFactor",get:function(){return this._defaultScaleCanvasResolutionFactor},set:function(e){this._defaultScaleCanvasResolutionFactor=e||1}},{key:"scaleCanvasResolutionFactor",get:function(){return this._scaleCanvasResolutionFactor},set:function(e){this._scaleCanvasResolutionFactor=e||.6}},{key:"delayBeforeRestore",get:function(){return this._delayBeforeRestore},set:function(e){this._delayBeforeRestore=e}},{key:"delayBeforeRestoreSeconds",get:function(){return this._delayBeforeRestoreSeconds},set:function(e){this._delayBeforeRestoreSeconds=null!=e?e:.5}},{key:"send",value:function(e,t){}},{key:"destroy",value:function(){this.viewer.scene.camera.off(this._onCameraMatrix),this.viewer.scene.canvas.off(this._onCanvasBoundary),this.viewer.scene.input.off(this._onSceneMouseDown),this.viewer.scene.input.off(this._onSceneMouseUp),this.viewer.scene.input.off(this._onSceneMouseMove),this.viewer.scene.off(this._onSceneTick),f(B(i.prototype),"destroy",this).call(this)}}]),i}(),Ih=function(){function e(){x(this,e)}return C(e,[{key:"getMetaModel",value:function(e,t,i){le.loadJSON(e,(function(e){t(e)}),(function(e){i(e)}))}},{key:"getGLTF",value:function(e,t,i){le.loadArraybuffer(e,(function(e){t(e)}),(function(e){i(e)}))}},{key:"getGLB",value:function(e,t,i){le.loadArraybuffer(e,(function(e){t(e)}),(function(e){i(e)}))}},{key:"getArrayBuffer",value:function(e,t,i,s){!function(e,t,i,s){var r=function(){};i=i||r,s=s||r;var n=/^data:(.*?)(;base64)?,(.*)$/,o=t.match(n);if(o){var a=!!o[2],l=o[3];l=window.decodeURIComponent(l),a&&(l=window.atob(l));try{for(var u=new ArrayBuffer(l.length),A=new Uint8Array(u),c=0;c0&&void 0!==arguments[0]?arguments[0]:{};x(this,e),this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=t.messages,this.locale=t.locale}return C(e,[{key:"messages",set:function(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}},{key:"loadMessages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)this._messages[t]=e[t];this.messages=this._messages}},{key:"clearMessages",value:function(){this.messages={}}},{key:"locales",get:function(){return this._locales}},{key:"locale",get:function(){return this._locale},set:function(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}},{key:"translate",value:function(e,t){var i=this._messages[this._locale];if(!i)return null;var s=Sh(e,i);return s?t?Th(s,t):s:null}},{key:"translatePlurals",value:function(e,t,i){var s=this._messages[this._locale];if(!s)return null;var r=Sh(e,s);return(r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one)?(r=Th(r,[t]),i&&(r=Th(r,i)),r):null}},{key:"fire",value:function(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);var s=this._eventSubs[e];if(s)for(var r in s){if(s.hasOwnProperty(r))s[r].callback(t)}}},{key:"on",value:function(e,t){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new Q),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});var i=this._eventSubs[e];i||(i={},this._eventSubs[e]=i);var s=this._eventSubIDMap.addItem();i[s]={callback:t},this._eventSubEvents[s]=e;var r=this._events[e];return void 0!==r&&t(r),s}},{key:"off",value:function(e){if(null!=e&&this._eventSubEvents){var t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];var i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}}]),e}();function Sh(e,t){if(t[e])return t[e];for(var i=e.split("."),s=t,r=0,n=i.length;s&&r1&&void 0!==arguments[1]?arguments[1]:[];return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,i){return"{{"===e?"{":"}}"===e?"}":t[i]}))}var Rh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).t=r.t,s}return C(i,[{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"tangent",get:function(){return this.getTangent(this._t)}},{key:"length",get:function(){var e=this._getLengths();return e[e.length-1]}},{key:"getTangent",value:function(e){var t=1e-4;void 0===e&&(e=this._t);var i=e-t,s=e+t;i<0&&(i=0),s>1&&(s=1);var r=this.getPoint(i),n=this.getPoint(s),o=$.subVec3(n,r,[]);return $.normalizeVec3(o,[])}},{key:"getPointAt",value:function(e){var t=this.getUToTMapping(e);return this.getPoint(t)}},{key:"getPoints",value:function(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}},{key:"_getLengths",value:function(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,s=[],r=this.getPoint(0),n=0;for(s.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),n+=$.lenVec3($.subVec3(t,r,[])),s.push(n),r=t;return this.cacheArcLengths=s,s}},{key:"_updateArcLengths",value:function(){this.needsUpdate=!0,this._getLengths()}},{key:"getUToTMapping",value:function(e,t){var i,s=this._getLengths(),r=0,n=s.length;i=t||e*s[n-1];for(var o,a=0,l=n-1;a<=l;)if((o=s[r=Math.floor(a+(l-a)/2)]-i)<0)a=r+1;else{if(!(o>0)){l=r;break}l=r-1}if(s[r=l]===i)return r/(n-1);var u=s[r];return(r+(i-u)/(s[r+1]-u))/(n-1)}}]),i}(),Lh=function(e){g(i,Rh);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).points=r.points,s.t=r.t,s}return C(i,[{key:"points",get:function(){return this._points},set:function(e){this._points=e||[]}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var t=this.points;if(!(t.length<3)){var i=(t.length-1)*e,s=Math.floor(i),r=i-s,n=t[0===s?s:s-1],o=t[s],a=t[s>t.length-2?t.length-1:s+1],l=t[s>t.length-3?t.length-1:s+2],u=$.vec3();return u[0]=$.catmullRomInterpolate(n[0],o[0],a[0],l[0],r),u[1]=$.catmullRomInterpolate(n[1],o[1],a[1],l[1],r),u[2]=$.catmullRomInterpolate(n[2],o[2],a[2],l[2],r),u}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}},{key:"getJSON",value:function(){return{points:points,t:this._t}}}]),i}(),Uh=$.vec3(),Oh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._frames=[],s._eyeCurve=new Lh(b(s)),s._lookCurve=new Lh(b(s)),s._upCurve=new Lh(b(s)),r.frames&&(s.addFrames(r.frames),s.smoothFrameTimes(1)),s}return C(i,[{key:"type",get:function(){return"CameraPath"}},{key:"frames",get:function(){return this._frames}},{key:"eyeCurve",get:function(){return this._eyeCurve}},{key:"lookCurve",get:function(){return this._lookCurve}},{key:"upCurve",get:function(){return this._upCurve}},{key:"saveFrame",value:function(e){var t=this.scene.camera;this.addFrame(e,t.eye,t.look,t.up)}},{key:"addFrame",value:function(e,t,i,s){var r={t:e,eye:t.slice(0),look:i.slice(0),up:s.slice(0)};this._frames.push(r),this._eyeCurve.points.push(r.eye),this._lookCurve.points.push(r.look),this._upCurve.points.push(r.up)}},{key:"addFrames",value:function(e){for(var t,i=0,s=e.length;i1?1:e,t.eye=this._eyeCurve.getPoint(e,Uh),t.look=this._lookCurve.getPoint(e,Uh),t.up=this._upCurve.getPoint(e,Uh)}},{key:"sampleFrame",value:function(e,t,i,s){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,s)}},{key:"smoothFrameTimes",value:function(e){if(0!==this._frames.length){var t=$.vec3(),i=0;this._frames[0].t=0;for(var s=[],r=1,n=this._frames.length;r1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._look1=$.vec3(),s._eye1=$.vec3(),s._up1=$.vec3(),s._look2=$.vec3(),s._eye2=$.vec3(),s._up2=$.vec3(),s._orthoScale1=1,s._orthoScale2=1,s._flying=!1,s._flyEyeLookUp=!1,s._flyingEye=!1,s._flyingLook=!1,s._callback=null,s._callbackScope=null,s._time1=null,s._time2=null,s.easing=!1!==r.easing,s.duration=r.duration,s.fit=r.fit,s.fitFOV=r.fitFOV,s.trail=r.trail,s}return C(i,[{key:"type",get:function(){return"CameraFlightAnimation"}},{key:"flyTo",value:function(e,t,i){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=t,this._callbackScope=i;var s,r,n,o,a,l=this.scene.camera,u=!!e.projection&&e.projection!==l.projection;if(this._eye1[0]=l.eye[0],this._eye1[1]=l.eye[1],this._eye1[2]=l.eye[2],this._look1[0]=l.look[0],this._look1[1]=l.look[1],this._look1[2]=l.look[2],this._up1[0]=l.up[0],this._up1[1]=l.up[1],this._up1[2]=l.up[2],this._orthoScale1=l.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)s=e.aabb;else if(6===e.length)s=e;else if(e.eye&&e.look||e.up)r=e.eye,n=e.look,o=e.up;else if(e.eye)r=e.eye;else if(e.look)n=e.look;else{var A=e;if((le.isNumeric(A)||le.isString(A))&&(a=A,!(A=this.scene.components[a])))return this.error("Component not found: "+le.inQuotes(a)),void(t&&(i?t.call(i):t()));u||(s=A.aabb||this.scene.aabb)}var c=e.poi;if(s){if(s[3]=1;e>1&&(e=1);var s=this.easing?i._ease(e,0,1,1):e,r=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?($.subVec3(r.eye,r.look,jh),r.eye=$.lerpVec3(s,0,1,this._eye1,this._eye2,Vh),r.look=$.subVec3(Vh,jh,Qh)):this._flyingLook&&(r.look=$.lerpVec3(s,0,1,this._look1,this._look2,Qh),r.up=$.lerpVec3(s,0,1,this._up1,this._up2,Hh)):this._flyingEyeLookUp&&(r.eye=$.lerpVec3(s,0,1,this._eye1,this._eye2,Vh),r.look=$.lerpVec3(s,0,1,this._look1,this._look2,Qh),r.up=$.lerpVec3(s,0,1,this._up1,this._up2,Hh)),this._projection2){var n="ortho"===this._projection2?i._easeOutExpo(e,0,1,1):i._easeInCubic(e,0,1,1);r.customProjection.matrix=$.lerpMat4(n,0,1,this._projMatrix1,this._projMatrix2)}else r.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return r.ortho.scale=this._orthoScale2,void this.stop();_e.scheduleTask(this._update,this)}}},{key:"stop",value:function(){if(this._flying){this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);var e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}}},{key:"cancel",value:function(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}},{key:"duration",get:function(){return this._duration/1e3},set:function(e){this._duration=e?1e3*e:500,this.stop()}},{key:"fit",get:function(){return this._fit},set:function(e){this._fit=!1!==e}},{key:"fitFOV",get:function(){return this._fitFOV},set:function(e){this._fitFOV=e||45}},{key:"trail",get:function(){return this._trail},set:function(e){this._trail=!!e}},{key:"destroy",value:function(){this.stop(),f(B(i.prototype),"destroy",this).call(this)}}],[{key:"_ease",value:function(e,t,i,s){return-i*(e/=s)*(e-2)+t}},{key:"_easeInCubic",value:function(e,t,i,s){return i*(e/=s)*e*e+t}},{key:"_easeOutExpo",value:function(e,t,i,s){return i*(1-Math.pow(2,-10*e/s))+t}}]),i}(),zh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._cameraFlightAnimation=new Gh(b(s)),s._t=0,s.state=i.SCRUBBING,s._playingFromT=0,s._playingToT=0,s._playingRate=r.playingRate||1,s._playingDir=1,s._lastTime=null,s.cameraPath=r.cameraPath,s._tick=s.scene.on("tick",s._updateT,b(s)),s}return C(i,[{key:"type",get:function(){return"CameraPathAnimation"}},{key:"_updateT",value:function(){var e=this._cameraPath;if(e){var t,s,r=performance.now(),n=this._lastTime?.001*(r-this._lastTime):0;if(this._lastTime=r,0!==n)switch(this.state){case i.SCRUBBING:return;case i.PLAYING:if(this._t+=this._playingRate*n,0===(t=this._cameraPath.frames.length)||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=i.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case i.PLAYING_TO:s=this._t+this._playingRate*n*this._playingDir,(this._playingDir<0&&s<=this._playingToT||this._playingDir>0&&s>=this._playingToT)&&(s=this._playingToT,this.state=i.SCRUBBING,this.fire("stopped")),this._t=s,e.loadFrame(this._t)}}}},{key:"_ease",value:function(e,t,i,s){return-i*(e/=s)*(e-2)+t}},{key:"cameraPath",get:function(){return this._cameraPath},set:function(e){this._cameraPath=e}},{key:"rate",get:function(){return this._playingRate},set:function(e){this._playingRate=e}},{key:"play",value:function(){this._cameraPath&&(this._lastTime=null,this.state=i.PLAYING)}},{key:"playToT",value:function(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=i.PLAYING_TO)}},{key:"playToFrame",value:function(e){var t=this._cameraPath;if(t){var i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}}},{key:"flyToFrame",value:function(e,t){var s=this._cameraPath;if(s){var r=s.frames[e];r?(this.state=i.SCRUBBING,this._cameraFlightAnimation.flyTo(r,t)):this.error("flyToFrame - frame index out of range: "+e)}}},{key:"scrubToT",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=i.SCRUBBING))}},{key:"scrubToFrame",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(t.frames[e]?(t.loadFrame(this._t),this.state=i.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)))}},{key:"stop",value:function(){this.state=i.SCRUBBING,this.fire("stopped")}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this),this.scene.off(this._tick)}}]),i}();zh.STOPPED=0,zh.SCRUBBING=1,zh.PLAYING=2,zh.PLAYING_TO=3;var Wh=$.vec3(),Kh=$.vec3();$.vec3();var Xh=$.vec3([0,-1,0]),Jh=$.vec4([0,0,0,1]),Yh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._src=null,s._image=null,s._pos=$.vec3(),s._origin=$.vec3(),s._rtcPos=$.vec3(),s._dir=$.vec3(),s._size=1,s._imageSize=$.vec2(),s._texture=new Ln(b(s)),s._plane=new sn(b(s),{geometry:new Si(b(s),Kn({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new Oi(b(s),{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:s._texture,emissiveMap:s._texture,backfaces:!0}),clippable:r.clippable}),s._grid=new sn(b(s),{geometry:new Si(b(s),Wn({size:1,divisions:10})),material:new Oi(b(s),{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:r.clippable}),s._node=new yn(b(s),{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[s._plane,s._grid]}),s._gridVisible=!1,s.visible=!0,s.gridVisible=r.gridVisible,s.position=r.position,s.rotation=r.rotation,s.dir=r.dir,s.size=r.size,s.collidable=r.collidable,s.clippable=r.clippable,s.pickable=r.pickable,s.opacity=r.opacity,r.image?s.image=r.image:s.src=r.src,s}return C(i,[{key:"visible",get:function(){return this._plane.visible},set:function(e){this._plane.visible=e,this._grid.visible=this._gridVisible&&e}},{key:"gridVisible",get:function(){return this._gridVisible},set:function(e){e=!1!==e,this._gridVisible=e,this._grid.visible=this._gridVisible&&this.visible}},{key:"image",get:function(){return this._image},set:function(e){this._image=e,this._image&&(this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}},{key:"src",get:function(){return this._src},set:function(e){var t=this;if(this._src=e,this._src){this._image=null;var i=new Image;i.onload=function(){t._texture.image=i,t._imageSize[0]=i.width,t._imageSize[1]=i.height,t._updatePlaneSizeFromImage()},i.src=this._src}}},{key:"position",get:function(){return this._pos},set:function(e){this._pos.set(e||[0,0,0]),Le(this._pos,this._origin,this._rtcPos),this._node.origin=this._origin,this._node.position=this._rtcPos}},{key:"rotation",get:function(){return this._node.rotation},set:function(e){this._node.rotation=e}},{key:"size",get:function(){return this._size},set:function(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}},{key:"dir",get:function(){return this._dir},set:function(e){if(this._dir.set(e||[0,0,-1]),e){var t=this.scene.center,i=[-this._dir[0],-this._dir[1],-this._dir[2]];$.subVec3(t,this.position,Wh);var s=-$.dotVec3(i,Wh);$.normalizeVec3(i),$.mulVec3Scalar(i,s,Kh),$.vec3PairToQuaternion(Xh,e,Jh),this._node.quaternion=Jh}}},{key:"collidable",get:function(){return this._node.collidable},set:function(e){this._node.collidable=!1!==e}},{key:"clippable",get:function(){return this._node.clippable},set:function(e){this._node.clippable=!1!==e}},{key:"pickable",get:function(){return this._node.pickable},set:function(e){this._node.pickable=!1!==e}},{key:"opacity",get:function(){return this._node.opacity},set:function(e){this._node.opacity=e}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this)}},{key:"_updatePlaneSizeFromImage",value:function(){var e=this._size,t=this._imageSize[0],i=this._imageSize[1];if(t>i){var s=i/t;this._node.scale=[e,1,e*s]}else{var r=t/i;this._node.scale=[e*r,1,e]}}}]),i}(),Zh=function(e){g(i,_i);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i);var n=b(s=t.call(this,e,r));s._shadowRenderBuf=null,s._shadowViewMatrix=null,s._shadowProjMatrix=null,s._shadowViewMatrixDirty=!0,s._shadowProjMatrixDirty=!0;var o=s.scene.camera,a=s.scene.canvas;return s._onCameraViewMatrix=o.on("viewMatrix",(function(){s._shadowViewMatrixDirty=!0})),s._onCameraProjMatrix=o.on("projMatrix",(function(){s._shadowProjMatrixDirty=!0})),s._onCanvasBoundary=a.on("boundary",(function(){s._shadowProjMatrixDirty=!0})),s._state=new Zt({type:"point",pos:$.vec3([1,1,1]),color:$.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:r.space||"view",castsShadow:!1,getShadowViewMatrix:function(){if(n._shadowViewMatrixDirty){n._shadowViewMatrix||(n._shadowViewMatrix=$.identityMat4());var e=n._state.pos,t=o.look,i=o.up;$.lookAtMat4v(e,t,i,n._shadowViewMatrix),n._shadowViewMatrixDirty=!1}return n._shadowViewMatrix},getShadowProjMatrix:function(){if(n._shadowProjMatrixDirty){n._shadowProjMatrix||(n._shadowProjMatrix=$.identityMat4());var e=n.scene.canvas.canvas;$.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,n._shadowProjMatrix),n._shadowProjMatrixDirty=!1}return n._shadowProjMatrix},getShadowRenderBuf:function(){return n._shadowRenderBuf||(n._shadowRenderBuf=new zt(n.scene.canvas.canvas,n.scene.canvas.gl,{size:[1024,1024]})),n._shadowRenderBuf}}),s.pos=r.pos,s.color=r.color,s.intensity=r.intensity,s.constantAttenuation=r.constantAttenuation,s.linearAttenuation=r.linearAttenuation,s.quadraticAttenuation=r.quadraticAttenuation,s.castsShadow=r.castsShadow,s.scene._lightCreated(b(s)),s}return C(i,[{key:"type",get:function(){return"PointLight"}},{key:"pos",get:function(){return this._state.pos},set:function(e){this._state.pos.set(e||[1,1,1]),this._shadowViewMatrixDirty=!0,this.glRedraw()}},{key:"color",get:function(){return this._state.color},set:function(e){this._state.color.set(e||[.7,.7,.8]),this.glRedraw()}},{key:"intensity",get:function(){return this._state.intensity},set:function(e){e=void 0!==e?e:1,this._state.intensity=e,this.glRedraw()}},{key:"constantAttenuation",get:function(){return this._state.attenuation[0]},set:function(e){this._state.attenuation[0]=e||0,this.glRedraw()}},{key:"linearAttenuation",get:function(){return this._state.attenuation[1]},set:function(e){this._state.attenuation[1]=e||0,this.glRedraw()}},{key:"quadraticAttenuation",get:function(){return this._state.attenuation[2]},set:function(e){this._state.attenuation[2]=e||0,this.glRedraw()}},{key:"castsShadow",get:function(){return this._state.castsShadow},set:function(e){e=!!e,this._state.castsShadow!==e&&(this._state.castsShadow=e,this._shadowViewMatrixDirty=!0,this.glRedraw())}},{key:"destroy",value:function(){var e=this.scene.camera,t=this.scene.canvas;e.off(this._onCameraViewMatrix),e.off(this._onCameraProjMatrix),t.off(this._onCanvasBoundary),f(B(i.prototype),"destroy",this).call(this),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}}]),i}();function qh(e){return 0==(e&e-1)}function $h(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1}var ed=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i);var n=(s=t.call(this,e,r)).scene.canvas.gl;return s._state=new Zt({texture:new kn({gl:n,target:n.TEXTURE_CUBE_MAP}),flipY:s._checkFlipY(r.minFilter),encoding:s._checkEncoding(r.encoding),minFilter:1008,magFilter:1006,wrapS:1001,wrapT:1001,mipmaps:!0}),s._src=r.src,s._images=[],s._loadSrc(r.src),se.memory.textures++,s}return C(i,[{key:"type",get:function(){return"CubeTexture"}},{key:"_checkFlipY",value:function(e){return!!e}},{key:"_checkEncoding",value:function(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),e}},{key:"_webglContextRestored",value:function(){this.scene.canvas.gl,this._state.texture=null,this._src&&this._loadSrc(this._src)}},{key:"_loadSrc",value:function(e){var t=this,i=this.scene.canvas.gl;this._images=[];for(var s=!1,r=0,n=function(n){var o,a,l=new Image;l.onload=(o=l,a=n,function(){if(!s&&(o=function(e){if(!qh(e.width)||!qh(e.height)){var t=document.createElement("canvas");t.width=$h(e.width),t.height=$h(e.height),t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}(o),t._images[a]=o,6==++r)){var e=t._state.texture;e||(e=new kn({gl:i,target:i.TEXTURE_CUBE_MAP}),t._state.texture=e),e.setImage(t._images,t._state),t.fire("loaded",t._src,!1),t.glRedraw()}}),l.onerror=function(){s=!0},l.src=e[n]},o=0;o1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).scene._lightsState.addReflectionMap(s._state),s.scene._reflectionMapCreated(b(s)),s}return C(i,[{key:"type",get:function(){return"ReflectionMap"}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this),this.scene._reflectionMapDestroyed(this)}}]),i}(),id=function(e){g(i,ed);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).scene._lightMapCreated(b(s)),s}return C(i,[{key:"type",get:function(){return"LightMap"}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this),this.scene._lightMapDestroyed(this)}}]),i}(),sd=function(e){g(i,et);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,{entity:r.entity,occludable:r.occludable,worldPos:r.worldPos}))._occluded=!1,s._visible=!0,s._src=null,s._image=null,s._pos=$.vec3(),s._origin=$.vec3(),s._rtcPos=$.vec3(),s._dir=$.vec3(),s._size=1,s._imageSize=$.vec2(),s._texture=new Ln(b(s),{src:r.src}),s._geometry=new Si(b(s),{primitive:"triangles",positions:[3,3,0,-3,3,0,-3,-3,0,3,-3,0],normals:[-1,0,0,-1,0,0,-1,0,0,-1,0,0],uv:[1,-1,0,-1,0,0,1,0],indices:[0,1,2,0,2,3]}),s._mesh=new sn(b(s),{geometry:s._geometry,material:new Oi(b(s),{ambient:[.9,.3,.9],shininess:30,diffuseMap:s._texture,backfaces:!0}),scale:[1,1,1],position:r.worldPos,rotation:[90,0,0],billboard:"spherical",occluder:!1}),s.visible=!0,s.collidable=r.collidable,s.clippable=r.clippable,s.pickable=r.pickable,s.opacity=r.opacity,s.size=r.size,r.image?s.image=r.image:s.src=r.src,s}return C(i,[{key:"_setVisible",value:function(e){this._occluded=!e,this._mesh.visible=this._visible&&!this._occluded,f(B(i.prototype),"_setVisible",this).call(this,e)}},{key:"visible",get:function(){return this._visible},set:function(e){this._visible=null==e||e,this._mesh.visible=this._visible&&!this._occluded}},{key:"image",get:function(){return this._image},set:function(e){this._image=e,this._image&&(this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}},{key:"src",get:function(){return this._src},set:function(e){var t=this;if(this._src=e,this._src){this._image=null;var i=new Image;i.onload=function(){t._texture.image=i,t._imageSize[0]=i.width,t._imageSize[1]=i.height,t._updatePlaneSizeFromImage()},i.src=this._src}}},{key:"size",get:function(){return this._size},set:function(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}},{key:"collidable",get:function(){return this._mesh.collidable},set:function(e){this._mesh.collidable=!1!==e}},{key:"clippable",get:function(){return this._mesh.clippable},set:function(e){this._mesh.clippable=!1!==e}},{key:"pickable",get:function(){return this._mesh.pickable},set:function(e){this._mesh.pickable=!1!==e}},{key:"opacity",get:function(){return this._mesh.opacity},set:function(e){this._mesh.opacity=e}},{key:"_updatePlaneSizeFromImage",value:function(){var e=.5*this._size,t=this._imageSize[0],i=this._imageSize[1],s=i/t;this._geometry.positions=t>i?[e,e*s,0,-e,e*s,0,-e,-e*s,0,e,-e*s,0]:[e/s,e,0,-e/s,e,0,-e/s,-e,0,e/s,-e,0]}}]),i}(),rd=function(){function e(t){x(this,e),this._eye=$.vec3(),this._look=$.vec3(),this._up=$.vec3(),this._projection={},t&&this.saveCamera(t)}return C(e,[{key:"saveCamera",value:function(e){var t=e.camera,i=t.project;switch(this._eye.set(t.eye),this._look.set(t.look),this._up.set(t.up),t.projection){case"perspective":this._projection={projection:"perspective",fov:i.fov,fovAxis:i.fovAxis,near:i.near,far:i.far};break;case"ortho":this._projection={projection:"ortho",scale:i.scale,near:i.near,far:i.far};break;case"frustum":this._projection={projection:"frustum",left:i.left,right:i.right,top:i.top,bottom:i.bottom,near:i.near,far:i.far};break;case"custom":this._projection={projection:"custom",matrix:i.matrix.slice()}}}},{key:"restoreCamera",value:function(e,t){var i=e.camera,s=this._projection;function r(){switch(s.type){case"perspective":i.perspective.fov=s.fov,i.perspective.fovAxis=s.fovAxis,i.perspective.near=s.near,i.perspective.far=s.far;break;case"ortho":i.ortho.scale=s.scale,i.ortho.near=s.near,i.ortho.far=s.far;break;case"frustum":i.frustum.left=s.left,i.frustum.right=s.right,i.frustum.top=s.top,i.frustum.bottom=s.bottom,i.frustum.near=s.near,i.frustum.far=s.far;break;case"custom":i.customProjection.matrix=s.matrix}}t?e.viewer.cameraFlight.flyTo({eye:this._eye,look:this._look,up:this._up,orthoScale:s.scale,projection:s.projection},(function(){r(),t()})):(i.eye=this._eye,i.look=this._look,i.up=this._up,r(),i.projection=s.projection)}}]),e}(),nd=$.vec3(),od=function(){function e(t){if(x(this,e),this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,t){var i=t.metaScene.scene;this.saveObjects(i,t)}}return C(e,[{key:"saveObjects",value:function(e,t,i){this.numObjects=0,this._mask=i?le.apply(i,{}):null;for(var s=!i||i.visible,r=!i||i.edges,n=!i||i.xrayed,o=!i||i.highlighted,a=!i||i.selected,l=!i||i.clippable,u=!i||i.pickable,A=!i||i.colorize,c=!i||i.opacity,h=t.metaObjects,d=e.objects,p=0,f=h.length;p1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).v0=r.v0,s.v1=r.v1,s.v2=r.v2,s.v3=r.v3,s.t=r.t,s}return C(i,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||$.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||$.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||$.vec3([0,0,0])}},{key:"v3",get:function(){return this._v3},set:function(e){this.fire("v3",this._v3=e||$.vec3([0,0,0]))}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var t=$.vec3();return t[0]=$.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),t[1]=$.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),t[2]=$.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),t}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}}]),i}(),Ad=function(e){g(i,Rh);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._cachedLengths=[],s._dirty=!0,s._curves=[],s._t=0,s._dirtySubs=[],s._destroyedSubs=[],s.curves=r.curves||[],s.t=r.t,s}return C(i,[{key:"addCurve",value:function(e){this._curves.push(e),this._dirty=!0}},{key:"curves",get:function(){return this._curves},set:function(e){var t,i,s;for(e=e||[],i=0,s=this._curves.length;i1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"length",get:function(){var e=this._getCurveLengths();return e[e.length-1]}},{key:"getPoint",value:function(e){for(var t,i=e*this.length,s=this._getCurveLengths(),r=0;r=i){var n=1-(s[r]-i)/(t=this._curves[r]).length;return t.getPointAt(n)}r++}return null}},{key:"_getCurveLengths",value:function(){if(!this._dirty)return this._cachedLengths;var e,t=[],i=0,s=this._curves.length;for(e=0;e1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).v0=r.v0,s.v1=r.v1,s.v2=r.v2,s.t=r.t,s}return C(i,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||$.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||$.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||$.vec3([0,0,0])}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var t=$.vec3();return t[0]=$.b2(e,this._v0[0],this._v1[0],this._v2[0]),t[1]=$.b2(e,this._v0[1],this._v1[1],this._v2[1]),t[2]=$.b2(e,this._v0[2],this._v1[2],this._v2[2]),t}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}}]),i}(),hd=function(e){g(i,Ah);var t=_(i);function i(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),t.call(this,e,s)}return C(i)}(),dd=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._skyboxMesh=new sn(b(s),{geometry:new Si(b(s),{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[2e3,2e3,2e3],rotation:[0,-90,0],material:new Oi(b(s),{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Ln(b(s),{src:r.src,flipY:!0,wrapS:"clampToEdge",wrapT:"clampToEdge",encoding:r.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),s.size=r.size,s.active=r.active,s}return C(i,[{key:"size",get:function(){return this._size},set:function(e){this._size=e||1e3,this._skyboxMesh.scale=[this._size,this._size,this._size]}},{key:"active",get:function(){return this._skyboxMesh.visible},set:function(e){this._skyboxMesh.visible=e}}]),i}(),pd=function(){function e(){x(this,e)}return C(e,[{key:"transcode",value:function(e,t){}},{key:"destroy",value:function(){}}]),e}(),fd=$.vec4(),vd=$.vec4(),gd=$.vec3(),md=$.vec3(),_d=$.vec3(),yd=$.vec4(),bd=$.vec4(),Bd=$.vec4(),wd=function(){function e(t){x(this,e),this._scene=t}return C(e,[{key:"dollyToCanvasPos",value:function(e,t,i){var s=!1,r=this._scene.camera;if(e){var n=$.subVec3(e,r.eye,gd);s=$.lenVec3(n)0&&void 0!==arguments[0]?arguments[0]:{};this.destroyPivotSphere(),this._pivotSphereEnabled=!0,e.size&&(this._pivotSphereSize=e.size);var t=e.color||[1,0,0];this._pivotSphereMaterial=new Oi(this._scene,{emissive:t,ambient:t,specular:[0,0,0],diffuse:[0,0,0]})}},{key:"disablePivotSphere",value:function(){this.destroyPivotSphere(),this._pivotSphereEnabled=!1}},{key:"startPivot",value:function(){if(this._cameraLookingDownwards())return this._pivoting=!1,!1;var e=this._scene.camera,t=$.lookAtMat4v(e.eye,e.look,e.worldUp);$.transformPoint3(t,this.getPivotPos(),this._cameraOffset);var i=this.getPivotPos();this._cameraOffset[2]+=$.distVec3(e.eye,i),t=$.inverseMat4(t);var s=$.transformVec3(t,this._cameraOffset),r=$.vec3();if($.subVec3(e.eye,i,r),$.addVec3(r,s),e.zUp){var n=r[1];r[1]=r[2],r[2]=n}this._radius=$.lenVec3(r),this._polar=Math.acos(r[1]/this._radius),this._azimuth=Math.atan2(r[0],r[2]),this._pivoting=!0}},{key:"_cameraLookingDownwards",value:function(){var e=this._scene.camera,t=$.normalizeVec3($.subVec3(e.look,e.eye,xd)),i=$.cross3Vec3(t,e.worldUp,Pd);return $.sqLenVec3(i)<=1e-4}},{key:"getPivoting",value:function(){return this._pivoting}},{key:"setPivotPos",value:function(e){this._pivotWorldPos.set(e),this._pivotPosSet=!0}},{key:"setCanvasPivotPos",value:function(e){var t=this._scene.camera,i=Math.abs($.distVec3(this._scene.center,t.eye)),s=t.project.transposedMatrix,r=s.subarray(8,12),n=s.subarray(12),o=[0,0,-1,1],a=$.dotVec4(o,r)/$.dotVec4(o,n),l=Md;t.project.unproject(e,a,Fd,Ed,l);var u=$.normalizeVec3($.subVec3(l,t.eye,xd)),A=$.addVec3(t.eye,$.mulVec3Scalar(u,i,Pd),Cd);this.setPivotPos(A)}},{key:"getPivotPos",value:function(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}},{key:"continuePivot",value:function(e,t){if(this._pivoting&&(0!==e||0!==t)){var i=this._scene.camera,s=-e,r=-t;1===i.worldUp[2]&&(s=-s),this._azimuth+=.01*-s,this._polar+=.01*r,this._polar=$.clamp(this._polar,.001,Math.PI-.001);var n=[this._radius*Math.sin(this._polar)*Math.sin(this._azimuth),this._radius*Math.cos(this._polar),this._radius*Math.sin(this._polar)*Math.cos(this._azimuth)];if(1===i.worldUp[2]){var o=n[1];n[1]=n[2],n[2]=o}var a=$.lenVec3($.subVec3(i.look,i.eye,$.vec3())),l=this.getPivotPos();$.addVec3(n,l);var u=$.lookAtMat4v(n,l,i.worldUp);u=$.inverseMat4(u);var A=$.transformVec3(u,this._cameraOffset);u[12]-=A[0],u[13]-=A[1],u[14]-=A[2];var c=[u[8],u[9],u[10]];i.eye=[u[12],u[13],u[14]],$.subVec3(i.eye,$.mulVec3Scalar(c,a),i.look),i.up=[u[4],u[5],u[6]],this.showPivot()}}},{key:"showPivot",value:function(){this._shown||(this._pivotElement&&(this.updatePivotElement(),this._pivotElement.style.visibility="visible"),this._pivotSphereEnabled&&(this.destroyPivotSphere(),this.createPivotSphere()),this._shown=!0)}},{key:"hidePivot",value:function(){this._shown&&(this._pivotElement&&(this._pivotElement.style.visibility="hidden"),this._pivotSphereEnabled&&this.destroyPivotSphere(),this._shown=!1)}},{key:"endPivot",value:function(){this._pivoting=!1}},{key:"destroy",value:function(){this.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}]),e}(),Id=function(){function e(t,i){x(this,e),this._scene=t.scene,this._cameraControl=t,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=i,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=$.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}return C(e,[{key:"update",value:function(){if(this._configs.pointerEnabled&&(this.schedulePickEntity||this.schedulePickSurface)){var e="".concat(~~this.pickCursorPos[0],"-").concat(~~this.pickCursorPos[1],"-").concat(this.scheduleSnapOrPick,"-").concat(this.schedulePickSurface,"-").concat(this.schedulePickEntity);if(this._lastHash!==e){this.picked=!1,this.pickedSurface=!1,this.snappedOrPicked=!1,this.hoveredSnappedOrSurfaceOff=!1;var t=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){var i=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});i&&(i.snappedToEdge||i.snappedToVertex)?(this.snapPickResult=i,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){var s=this.pickResult.canvasPos;if(s[0]===this.pickCursorPos[0]&&s[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=t?1:0,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.hoveredSnappedOrSurfaceOff=!0,void(this.scheduleSnapOrPick=!1)}if(this.schedulePickEntity&&this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){var r=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(r[0]===this.pickCursorPos[0]&&r[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!1,this.schedulePickEntity=!1,void(this.schedulePickSurface=!1)}this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult?(this.pickResult=this._scene.pick({pickSurface:!0,pickSurfaceNormal:!1,canvasPos:this.pickCursorPos}),this.pickResult?(this.picked=!0,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.pickedSurface=!0,this._needFireEvents++):this.scheduleSnapOrPick&&(this.hoveredSnappedOrSurfaceOff=!0,this._needFireEvents++)):(this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos}),this.pickResult&&(this.picked=!0,this.pickedSurface=!1,this._needFireEvents++)),this.scheduleSnapOrPick=!1,this.schedulePickEntity=!1,this.schedulePickSurface=!1}}}},{key:"fireEvents",value:function(){if(0!==this._needFireEvents){if(this.hoveredSnappedOrSurfaceOff&&this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},!0),this.snappedOrPicked)if(this.snapPickResult){var e=new wt;e.entity=this.snapPickResult.entity,e.snappedToVertex=this.snapPickResult.snappedToVertex,e.snappedToEdge=this.snapPickResult.snappedToEdge,e.worldPos=this.snapPickResult.worldPos,e.canvasPos=this.pickCursorPos,e.snappedCanvasPos=this.snapPickResult.snappedCanvasPos,this._cameraControl.fire("hoverSnapOrSurface",e,!0),this.snapPickResult=null}else this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,!0);if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){var t=this.pickResult.entity.id;this._lastPickedEntityId!==t&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=t)}this._cameraControl.fire("hover",this.pickResult,!0),this.pickResult.worldPos&&(this.pickedSurface=!0,this._cameraControl.fire("hoverSurface",this.pickResult,!0))}else void 0!==this._lastPickedEntityId&&(this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},!0);this.pickResult=null,this._needFireEvents=0}}}]),e}(),Dd=$.vec2(),Sd=function(){function e(t,i,s,r,n){x(this,e),this._scene=t;var o,a,l,u=i.pickController,A=0,c=0,h=0,d=0,p=!1,f=$.vec3(),v=!0,g=this._scene.canvas.canvas,m=[];function _(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];g.style.cursor="move",y(),e&&b()}function y(){A=r.pointerCanvasPos[0],c=r.pointerCanvasPos[1],h=r.pointerCanvasPos[0],d=r.pointerCanvasPos[1]}function b(){u.pickCursorPos=r.pointerCanvasPos,u.schedulePickSurface=!0,u.update(),u.picked&&u.pickedSurface&&u.pickResult&&u.pickResult.worldPos?(p=!0,f.set(u.pickResult.worldPos)):p=!1}document.addEventListener("keydown",this._documentKeyDownHandler=function(e){if(s.active&&s.pointerEnabled&&t.input.keyboardEnabled){var i=e.keyCode;m[i]=!0}}),document.addEventListener("keyup",this._documentKeyUpHandler=function(e){if(s.active&&s.pointerEnabled&&t.input.keyboardEnabled){var i=e.keyCode;m[i]=!1}}),g.addEventListener("mousedown",this._mouseDownHandler=function(e){if(s.active&&s.pointerEnabled)switch(e.which){case 1:m[t.input.KEY_SHIFT]||s.planView?(o=!0,_()):(o=!0,_(!1));break;case 2:a=!0,_();break;case 3:l=!0,s.panRightClick&&_()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=function(e){if(s.active&&s.pointerEnabled&&(o||a||l)){var i=t.canvas.boundary,u=i[2],h=i[3],d=r.pointerCanvasPos[0],v=r.pointerCanvasPos[1],g=m[t.input.KEY_SHIFT]||s.planView||!s.panRightClick&&a||s.panRightClick&&l,_=document.pointerLockElement?e.movementX:d-A,y=document.pointerLockElement?e.movementY:v-c;if(g){var b=t.camera;if("perspective"===b.projection){var B=Math.abs(p?$.lenVec3($.subVec3(f,t.camera.eye,[])):t.camera.eyeLookDist)*Math.tan(b.perspective.fov/2*Math.PI/180);n.panDeltaX+=1.5*_*B/h,n.panDeltaY+=1.5*y*B/h}else n.panDeltaX+=.5*b.ortho.scale*(_/h),n.panDeltaY+=.5*b.ortho.scale*(y/h)}else!o||a||l||s.planView||(s.firstPerson?(n.rotateDeltaY-=_/u*s.dragRotationRate/2,n.rotateDeltaX+=y/h*(s.dragRotationRate/4)):(n.rotateDeltaY-=_/u*(1.5*s.dragRotationRate),n.rotateDeltaX+=y/h*(1.5*s.dragRotationRate)));A=d,c=v}}),g.addEventListener("mousemove",this._canvasMouseMoveHandler=function(e){s.active&&s.pointerEnabled&&r.mouseover&&(v=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){if(s.active&&s.pointerEnabled)switch(e.which){case 1:case 2:case 3:o=!1,a=!1,l=!1}}),g.addEventListener("mouseup",this._mouseUpHandler=function(e){if(s.active&&s.pointerEnabled){if(3===e.which){!function(e,t){if(e){for(var i=e.target,s=0,r=0,n=0,o=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,n+=i.scrollLeft,o+=i.scrollTop,i=i.offsetParent;t[0]=e.pageX+n-s,t[1]=e.pageY+o-r}else e=window.event,t[0]=e.x,t[1]=e.y}(e,Dd);var t=Dd[0],r=Dd[1];Math.abs(t-h)<3&&Math.abs(r-d)<3&&i.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Dd,event:e},!0)}g.style.removeProperty("cursor")}}),g.addEventListener("mouseenter",this._mouseEnterHandler=function(){s.active&&s.pointerEnabled});var B=1/60,w=null;g.addEventListener("wheel",this._mouseWheelHandler=function(e){if(s.active&&s.pointerEnabled){var t=performance.now()/1e3,i=null!==w?t-w:0;w=t,i>.05&&(i=.05),i0?i.cameraFlight.flyTo(Nd,(function(){i.pivotController.getPivoting()&&s.followPointer&&i.pivotController.showPivot()})):(i.cameraFlight.jumpTo(Nd),i.pivotController.getPivoting()&&s.followPointer&&i.pivotController.showPivot())}}}))}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.input.off(this._onSceneKeyDown)}}]),e}(),Vd=function(){function e(t,i,s,r,n){var o=this;x(this,e),this._scene=t;var a=i.pickController,l=i.pivotController,u=i.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;var A=!1,c=!1,h=this._scene.canvas.canvas,d=function(e){var s;e&&e.worldPos&&(s=e.worldPos);var r=e&&e.entity?e.entity.aabb:t.aabb;if(s){var n=t.camera;$.subVec3(n.eye,n.look,[]),i.cameraFlight.flyTo({aabb:r})}else i.cameraFlight.flyTo({aabb:r})},p=t.tickify(this._canvasMouseMoveHandler=function(e){if(s.active&&s.pointerEnabled&&!A&&!c){var i=u.hasSubs("hover"),n=u.hasSubs("hoverEnter"),l=u.hasSubs("hoverOut"),h=u.hasSubs("hoverOff"),d=u.hasSubs("hoverSurface"),p=u.hasSubs("hoverSnapOrSurface");if(i||n||l||h||d||p)if(a.pickCursorPos=r.pointerCanvasPos,a.schedulePickEntity=!0,a.schedulePickSurface=d,a.scheduleSnapOrPick=p,a.update(),a.pickResult){if(a.pickResult.entity){var f=a.pickResult.entity.id;o._lastPickedEntityId!==f&&(void 0!==o._lastPickedEntityId&&u.fire("hoverOut",{entity:t.objects[o._lastPickedEntityId]},!0),u.fire("hoverEnter",a.pickResult,!0),o._lastPickedEntityId=f)}u.fire("hover",a.pickResult,!0),(a.pickResult.worldPos||a.pickResult.snappedWorldPos)&&u.fire("hoverSurface",a.pickResult,!0)}else void 0!==o._lastPickedEntityId&&(u.fire("hoverOut",{entity:t.objects[o._lastPickedEntityId]},!0),o._lastPickedEntityId=void 0),u.fire("hoverOff",{canvasPos:a.pickCursorPos},!0)}});h.addEventListener("mousemove",p),h.addEventListener("mousedown",this._canvasMouseDownHandler=function(e){if(1===e.which&&(A=!0),3===e.which&&(c=!0),1===e.which&&s.active&&s.pointerEnabled&&(r.mouseDownClientX=e.clientX,r.mouseDownClientY=e.clientY,r.mouseDownCursorX=r.pointerCanvasPos[0],r.mouseDownCursorY=r.pointerCanvasPos[1],!s.firstPerson&&s.followPointer&&(a.pickCursorPos=r.pointerCanvasPos,a.schedulePickSurface=!0,a.update(),1===e.which))){var i=a.pickResult;i&&i.worldPos?(l.setPivotPos(i.worldPos),l.startPivot()):(s.smartPivot?l.setCanvasPivotPos(r.pointerCanvasPos):l.setPivotPos(t.camera.look),l.startPivot())}}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){1===e.which&&(A=!1),3===e.which&&(c=!1),l.getPivoting()&&l.endPivot()}),h.addEventListener("mouseup",this._canvasMouseUpHandler=function(e){if(s.active&&s.pointerEnabled&&(1===e.which&&(l.hidePivot(),!(Math.abs(e.clientX-r.mouseDownClientX)>3||Math.abs(e.clientY-r.mouseDownClientY)>3)))){var n=u.hasSubs("picked"),A=u.hasSubs("pickedNothing"),c=u.hasSubs("pickedSurface"),h=u.hasSubs("doublePicked"),p=u.hasSubs("doublePickedSurface"),f=u.hasSubs("doublePickedNothing");if(!(s.doublePickFlyTo||h||p||f))return(n||A||c)&&(a.pickCursorPos=r.pointerCanvasPos,a.schedulePickEntity=!0,a.schedulePickSurface=c,a.update(),a.pickResult?(u.fire("picked",a.pickResult,!0),a.pickedSurface&&u.fire("pickedSurface",a.pickResult,!0)):u.fire("pickedNothing",{canvasPos:r.pointerCanvasPos},!0)),void(o._clicks=0);if(o._clicks++,1===o._clicks){a.pickCursorPos=r.pointerCanvasPos,a.schedulePickEntity=s.doublePickFlyTo,a.schedulePickSurface=c,a.update();var v=a.pickResult,g=a.pickedSurface;o._timeout=setTimeout((function(){v?(u.fire("picked",v,!0),g&&(u.fire("pickedSurface",v,!0),!s.firstPerson&&s.followPointer&&(i.pivotController.setPivotPos(v.worldPos),i.pivotController.startPivot()&&i.pivotController.showPivot()))):u.fire("pickedNothing",{canvasPos:r.pointerCanvasPos},!0),o._clicks=0}),s.doubleClickTimeFrame)}else{if(null!==o._timeout&&(window.clearTimeout(o._timeout),o._timeout=null),a.pickCursorPos=r.pointerCanvasPos,a.schedulePickEntity=s.doublePickFlyTo||h||p,a.schedulePickSurface=a.schedulePickEntity&&p,a.update(),a.pickResult){if(u.fire("doublePicked",a.pickResult,!0),a.pickedSurface&&u.fire("doublePickedSurface",a.pickResult,!0),s.doublePickFlyTo&&(d(a.pickResult),!s.firstPerson&&s.followPointer)){var m=a.pickResult.entity.aabb,_=$.getAABB3Center(m);i.pivotController.setPivotPos(_),i.pivotController.startPivot()&&i.pivotController.showPivot()}}else if(u.fire("doublePickedNothing",{canvasPos:r.pointerCanvasPos},!0),s.doublePickFlyTo&&(d(),!s.firstPerson&&s.followPointer)){var y=t.aabb,b=$.getAABB3Center(y);i.pivotController.setPivotPos(b),i.pivotController.startPivot()&&i.pivotController.showPivot()}o._clicks=0}}},!1)}return C(e,[{key:"reset",value:function(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;e.removeEventListener("mousemove",this._canvasMouseMoveHandler),e.removeEventListener("mousedown",this._canvasMouseDownHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._canvasMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}]),e}(),Hd=function(){function e(t,i,s,r,n){x(this,e),this._scene=t;var o=t.input,a=[],l=t.canvas.canvas,u=!0;this._onSceneMouseMove=o.on("mousemove",(function(){u=!0})),this._onSceneKeyDown=o.on("keydown",(function(e){s.active&&s.pointerEnabled&&t.input.keyboardEnabled&&r.mouseover&&(a[e]=!0,e===o.KEY_SHIFT&&(l.style.cursor="move"))})),this._onSceneKeyUp=o.on("keyup",(function(e){s.active&&s.pointerEnabled&&t.input.keyboardEnabled&&(a[e]=!1,e===o.KEY_SHIFT&&(l.style.cursor=null),i.pivotController.getPivoting()&&i.pivotController.endPivot())})),this._onTick=t.on("tick",(function(e){if(s.active&&s.pointerEnabled&&t.input.keyboardEnabled&&r.mouseover){var l=i.cameraControl,A=e.deltaTime/1e3;if(!s.planView){var c=l._isKeyDownForAction(l.ROTATE_Y_POS,a),h=l._isKeyDownForAction(l.ROTATE_Y_NEG,a),d=l._isKeyDownForAction(l.ROTATE_X_POS,a),p=l._isKeyDownForAction(l.ROTATE_X_NEG,a),f=A*s.keyboardRotationRate;(c||h||d||p)&&(!s.firstPerson&&s.followPointer&&i.pivotController.startPivot(),c?n.rotateDeltaY+=f:h&&(n.rotateDeltaY-=f),d?n.rotateDeltaX+=f:p&&(n.rotateDeltaX-=f),!s.firstPerson&&s.followPointer&&i.pivotController.startPivot())}if(!a[o.KEY_CTRL]&&!a[o.KEY_ALT]){var v=l._isKeyDownForAction(l.DOLLY_BACKWARDS,a),g=l._isKeyDownForAction(l.DOLLY_FORWARDS,a);if(v||g){var m=A*s.keyboardDollyRate;!s.firstPerson&&s.followPointer&&i.pivotController.startPivot(),g?n.dollyDelta-=m:v&&(n.dollyDelta+=m),u&&(r.followPointerDirty=!0,u=!1)}}var _=l._isKeyDownForAction(l.PAN_FORWARDS,a),y=l._isKeyDownForAction(l.PAN_BACKWARDS,a),b=l._isKeyDownForAction(l.PAN_LEFT,a),B=l._isKeyDownForAction(l.PAN_RIGHT,a),w=l._isKeyDownForAction(l.PAN_UP,a),x=l._isKeyDownForAction(l.PAN_DOWN,a),P=(a[o.KEY_ALT]?.3:1)*A*s.keyboardPanRate;(_||y||b||B||w||x)&&(!s.firstPerson&&s.followPointer&&i.pivotController.startPivot(),x?n.panDeltaY+=P:w&&(n.panDeltaY+=-P),B?n.panDeltaX+=-P:b&&(n.panDeltaX+=P),y?n.panDeltaZ+=P:_&&(n.panDeltaZ+=-P))}}))}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.off(this._onTick),this._scene.input.off(this._onSceneMouseMove),this._scene.input.off(this._onSceneKeyDown),this._scene.input.off(this._onSceneKeyUp)}}]),e}(),jd=$.vec3(),Gd=function(){function e(t,i,s,r,n){x(this,e),this._scene=t;var o=t.camera,a=i.pickController,l=i.pivotController,u=i.panController,A=1,c=1,h=null;this._onTick=t.on("tick",(function(){if(s.active&&s.pointerEnabled){var e="default";if(Math.abs(n.dollyDelta)<.001&&(n.dollyDelta=0),Math.abs(n.rotateDeltaX)<.001&&(n.rotateDeltaX=0),Math.abs(n.rotateDeltaY)<.001&&(n.rotateDeltaY=0),0===n.rotateDeltaX&&0===n.rotateDeltaY||(n.dollyDelta=0),s.followPointer){if(--A<=0&&(A=1,0!==n.dollyDelta)){if(0===n.rotateDeltaY&&0===n.rotateDeltaX&&s.followPointer&&r.followPointerDirty&&(a.pickCursorPos=r.pointerCanvasPos,a.schedulePickSurface=!0,a.update(),a.pickResult&&a.pickResult.worldPos?h=a.pickResult.worldPos:(c=1,h=null),r.followPointerDirty=!1),h){var i=Math.abs($.lenVec3($.subVec3(h,t.camera.eye,jd)));c=i/s.dollyProximityThreshold}cs.longTapRadius||Math.abs(g)>s.longTapRadius)&&(clearTimeout(r.longTouchTimeout),r.longTouchTimeout=null),s.planView){var m=t.camera;if("perspective"===m.projection){var _=Math.abs(t.camera.eyeLookDist)*Math.tan(m.perspective.fov/2*Math.PI/180);n.panDeltaX+=v*_/l*s.touchPanRate,n.panDeltaY+=g*_/l*s.touchPanRate}else n.panDeltaX+=.5*m.ortho.scale*(v/l)*s.touchPanRate,n.panDeltaY+=.5*m.ortho.scale*(g/l)*s.touchPanRate}else n.rotateDeltaY-=v/a*(1*s.dragRotationRate),n.rotateDeltaX+=g/l*(1.5*s.dragRotationRate)}else if(2===p){var y=d[0],b=d[1];Kd(y,u),Kd(b,A);var B=$.geometricMeanVec2(h[0],h[1]),w=$.geometricMeanVec2(u,A),x=$.vec2();$.subVec2(B,w,x);var P=x[0],C=x[1],M=t.camera,F=$.distVec2([y.pageX,y.pageY],[b.pageX,b.pageY]),E=($.distVec2(h[0],h[1])-F)*s.touchDollyRate;if(n.dollyDelta=E,Math.abs(E)<1)if("perspective"===M.projection){var k=o.pickResult?o.pickResult.worldPos:t.center,I=Math.abs($.lenVec3($.subVec3(k,t.camera.eye,[])))*Math.tan(M.perspective.fov/2*Math.PI/180);n.panDeltaX-=P*I/l*s.touchPanRate,n.panDeltaY-=C*I/l*s.touchPanRate}else n.panDeltaX-=.5*M.ortho.scale*(P/l)*s.touchPanRate,n.panDeltaY-=.5*M.ortho.scale*(C/l)*s.touchPanRate;r.pointerCanvasPos=w}for(var D=0;D-1&&t-c<150&&(h>-1&&c-h<325?(Jd(n[0],a.pickCursorPos),a.schedulePickEntity=!0,a.schedulePickSurface=o,a.update(),a.pickResult?(a.pickResult.touchInput=!0,l.fire("doublePicked",a.pickResult),a.pickedSurface&&l.fire("doublePickedSurface",a.pickResult),s.doublePickFlyTo&&p(a.pickResult)):(l.fire("doublePickedNothing"),s.doublePickFlyTo&&p()),h=-1):$.distVec2(u[0],A)<4&&(Jd(n[0],a.pickCursorPos),a.schedulePickEntity=!0,a.schedulePickSurface=o,a.update(),a.pickResult?(a.pickResult.touchInput=!0,l.fire("picked",a.pickResult),a.pickedSurface&&l.fire("pickedSurface",a.pickResult)):l.fire("pickedNothing"),h=t),c=-1),u.length=i.length;for(var d=0,f=i.length;d1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(s=t.call(this,e,r)).PAN_LEFT=0,s.PAN_RIGHT=1,s.PAN_UP=2,s.PAN_DOWN=3,s.PAN_FORWARDS=4,s.PAN_BACKWARDS=5,s.ROTATE_X_POS=6,s.ROTATE_X_NEG=7,s.ROTATE_Y_POS=8,s.ROTATE_Y_NEG=9,s.DOLLY_FORWARDS=10,s.DOLLY_BACKWARDS=11,s.AXIS_VIEW_RIGHT=12,s.AXIS_VIEW_BACK=13,s.AXIS_VIEW_LEFT=14,s.AXIS_VIEW_FRONT=15,s.AXIS_VIEW_TOP=16,s.AXIS_VIEW_BOTTOM=17,s._keyMap={},s.scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},s._configs={longTapTimeout:600,longTapRadius:5,active:!0,keyboardLayout:"qwerty",navMode:"orbit",planView:!1,firstPerson:!1,followPointer:!0,doublePickFlyTo:!0,panRightClick:!0,showPivot:!1,pointerEnabled:!0,constrainVertical:!1,smartPivot:!1,doubleClickTimeFrame:250,snapToVertex:true,snapToEdge:true,snapRadius:30,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},s._states={pointerCanvasPos:$.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:$.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},s._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};var n=s.scene;return s._controllers={cameraControl:b(s),pickController:new Id(b(s),s._configs),pivotController:new kd(n,s._configs),panController:new wd(n),cameraFlight:new Gh(b(s),{duration:.5})},s._handlers=[new zd(s.scene,s._controllers,s._configs,s._states,s._updates),new Xd(s.scene,s._controllers,s._configs,s._states,s._updates),new Sd(s.scene,s._controllers,s._configs,s._states,s._updates),new Qd(s.scene,s._controllers,s._configs,s._states,s._updates),new Vd(s.scene,s._controllers,s._configs,s._states,s._updates),new Yd(s.scene,s._controllers,s._configs,s._states,s._updates),new Hd(s.scene,s._controllers,s._configs,s._states,s._updates)],s._cameraUpdater=new Gd(s.scene,s._controllers,s._configs,s._states,s._updates),s.navMode=r.navMode,r.planView&&(s.planView=r.planView),s.constrainVertical=r.constrainVertical,r.keyboardLayout?s.keyboardLayout=r.keyboardLayout:s.keyMap=r.keyMap,s.doublePickFlyTo=r.doublePickFlyTo,s.panRightClick=r.panRightClick,s.active=r.active,s.followPointer=r.followPointer,s.rotationInertia=r.rotationInertia,s.keyboardPanRate=r.keyboardPanRate,s.touchPanRate=r.touchPanRate,s.keyboardRotationRate=r.keyboardRotationRate,s.dragRotationRate=r.dragRotationRate,s.touchDollyRate=r.touchDollyRate,s.dollyInertia=r.dollyInertia,s.dollyProximityThreshold=r.dollyProximityThreshold,s.dollyMinSpeed=r.dollyMinSpeed,s.panInertia=r.panInertia,s.pointerEnabled=!0,s.keyboardDollyRate=r.keyboardDollyRate,s.mouseWheelDollyRate=r.mouseWheelDollyRate,s}return C(i,[{key:"keyMap",get:function(){return this._keyMap},set:function(e){if(e=e||"qwerty",le.isString(e)){var t=this.scene.input,i={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":i[this.PAN_LEFT]=[t.KEY_A],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_Z],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_W,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_Q,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6];break;case"azerty":i[this.PAN_LEFT]=[t.KEY_Q],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_W],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_Z,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_A,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6]}this._keyMap=i}else{var s=e;this._keyMap=s}}},{key:"_isKeyDownForAction",value:function(e,t){var i=this._keyMap[e];if(!i)return!1;t||(t=this.scene.input.keyDown);for(var s=0,r=i.length;s0&&void 0!==arguments[0]?arguments[0]:{};this._controllers.pivotController.enablePivotSphere(e)}},{key:"disablePivotSphere",value:function(){this._controllers.pivotController.disablePivotSphere()}},{key:"smartPivot",get:function(){return this._configs.smartPivot},set:function(e){this._configs.smartPivot=!1!==e}},{key:"doubleClickTimeFrame",get:function(){return this._configs.doubleClickTimeFrame},set:function(e){this._configs.doubleClickTimeFrame=null!=e?e:250}},{key:"destroy",value:function(){this._destroyHandlers(),this._destroyControllers(),this._cameraUpdater.destroy(),f(B(i.prototype),"destroy",this).call(this)}},{key:"_destroyHandlers",value:function(){for(var e=0,t=this._handlers.length;e1&&void 0!==arguments[1]?arguments[1]:{};if(this.finalized)throw"MetaScene already finalized - can't add more data";this._globalizeIDs(e,t);var i=this.metaScene,s=e.properties;if(e.propertySets)for(var r=0,n=e.propertySets.length;r0?sp(t):null,o=i&&i.length>0?sp(i):null;return function e(t){if(t){var i=!0;(o&&o[t.type]||n&&!n[t.type])&&(i=!1),i&&s.push(t.id);var r=t.children;if(r)for(var a=0,l=r.length;a>t;i.sort(Hc);for(var a=new Int32Array(e.length),l=0,u=i.length;le[r+1]){var o=e[r];e[r]=e[r+1],e[r+1]=o}Gc=new Int32Array(e),t.sort(zc);for(var a=new Int32Array(e.length),l=0,u=t.length;l0)for(var s=i._meshes,r=0,n=s.length;r0)for(var o=this._meshes,a=0,l=o.length;a1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._dtxEnabled=s.scene.dtxEnabled&&!1!==r.dtxEnabled,s._enableVertexWelding=!1,s._enableIndexBucketing=!1,s._vboBatchingLayerScratchMemory=ro(),s._textureTranscoder=r.textureTranscoder||Lc(s.scene.viewer),s._maxGeometryBatchSize=r.maxGeometryBatchSize,s._aabb=$.collapseAABB3(),s._aabbDirty=!0,s._quantizationRanges={},s._vboInstancingLayers={},s._vboBatchingLayers={},s._dtxLayers={},s._meshList=[],s.layerList=[],s._entityList=[],s._geometries={},s._dtxBuckets={},s._textures={},s._textureSets={},s._transforms={},s._meshes={},s._unusedMeshes={},s._entities={},s.renderFlags=new zr,s.numGeometries=0,s.numPortions=0,s.numVisibleLayerPortions=0,s.numTransparentLayerPortions=0,s.numXRayedLayerPortions=0,s.numHighlightedLayerPortions=0,s.numSelectedLayerPortions=0,s.numEdgesLayerPortions=0,s.numPickableLayerPortions=0,s.numClippableLayerPortions=0,s.numCulledLayerPortions=0,s.numEntities=0,s._numTriangles=0,s._numLines=0,s._numPoints=0,s._edgeThreshold=r.edgeThreshold||10,s._origin=$.vec3(r.origin||[0,0,0]),s._position=$.vec3(r.position||[0,0,0]),s._rotation=$.vec3(r.rotation||[0,0,0]),s._quaternion=$.vec4(r.quaternion||[0,0,0,1]),s._conjugateQuaternion=$.vec4(r.quaternion||[0,0,0,1]),r.rotation&&$.eulerToQuaternion(s._rotation,"XYZ",s._quaternion),s._scale=$.vec3(r.scale||[1,1,1]),s._worldRotationMatrix=$.mat4(),s._worldRotationMatrixConjugate=$.mat4(),s._matrix=$.mat4(),s._matrixDirty=!0,s._rebuildMatrices(),s._worldNormalMatrix=$.mat4(),$.inverseMat4(s._matrix,s._worldNormalMatrix),$.transposeMat4(s._worldNormalMatrix),(r.matrix||r.position||r.rotation||r.scale||r.quaternion)&&(s._viewMatrix=$.mat4(),s._viewNormalMatrix=$.mat4(),s._viewMatrixDirty=!0,s._matrixNonIdentity=!0),s._opacity=1,s._colorize=[1,1,1],s._saoEnabled=!1!==r.saoEnabled,s._pbrEnabled=!1!==r.pbrEnabled,s._colorTextureEnabled=!1!==r.colorTextureEnabled,s._isModel=r.isModel,s._isModel&&s.scene._registerModel(b(s)),s._onCameraViewMatrix=s.scene.camera.on("matrix",(function(){s._viewMatrixDirty=!0})),s._meshesWithDirtyMatrices=[],s._numMeshesWithDirtyMatrices=0,s._onTick=s.scene.on("tick",(function(){for(;s._numMeshesWithDirtyMatrices>0;)s._meshesWithDirtyMatrices[--s._numMeshesWithDirtyMatrices]._updateMatrix()})),s._createDefaultTextureSet(),s.visible=r.visible,s.culled=r.culled,s.pickable=r.pickable,s.clippable=r.clippable,s.collidable=r.collidable,s.castsShadow=r.castsShadow,s.receivesShadow=r.receivesShadow,s.xrayed=r.xrayed,s.highlighted=r.highlighted,s.selected=r.selected,s.edges=r.edges,s.colorize=r.colorize,s.opacity=r.opacity,s.backfaces=r.backfaces,s}return C(i,[{key:"_meshMatrixDirty",value:function(e){this._meshesWithDirtyMatrices[this._numMeshesWithDirtyMatrices++]=e}},{key:"_createDefaultTextureSet",value:function(){var e=new Pc({id:"defaultColorTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})}),t=new Pc({id:"defaultMetalRoughTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[0,1,1,1]})}),i=new Pc({id:"defaultNormalsTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[0,0,0,0]})}),s=new Pc({id:"defaultEmissiveTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[0,0,0,1]})}),r=new Pc({id:"defaultOcclusionTexture",texture:new kn({gl:this.scene.canvas.gl,preloadColor:[1,1,1,1]})});this._textures.defaultColorTexture=e,this._textures.defaultMetalRoughTexture=t,this._textures.defaultNormalsTexture=i,this._textures.defaultEmissiveTexture=s,this._textures.defaultOcclusionTexture=r,this._textureSets.defaultTextureSet=new xc({id:"defaultTextureSet",model:this,colorTexture:e,metallicRoughnessTexture:t,normalsTexture:i,emissiveTexture:s,occlusionTexture:r})}},{key:"isPerformanceModel",get:function(){return!0}},{key:"transforms",get:function(){return this._transforms}},{key:"textures",get:function(){return this._textures}},{key:"textureSets",get:function(){return this._textureSets}},{key:"meshes",get:function(){return this._meshes}},{key:"objects",get:function(){return this._entities}},{key:"origin",get:function(){return this._origin}},{key:"position",get:function(){return this._position},set:function(e){this._position.set(e||[0,0,0]),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation.set(e||[0,0,0]),$.eulerToQuaternion(this._rotation,"XYZ",this._quaternion),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"quaternion",get:function(){return this._quaternion},set:function(e){this._quaternion.set(e||[0,0,0,1]),$.quaternionToEuler(this._quaternion,"XYZ",this._rotation),this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"scale",get:function(){return this._scale},set:function(e){}},{key:"matrix",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._matrix},set:function(e){this._matrix.set(e||lh),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),$.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),$.translateMat4v(this._position,this._matrix),this._matrixDirty=!1,this._setWorldMatrixDirty(),this._sceneModelDirty(),this.glRedraw()}},{key:"rotationMatrix",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrix}},{key:"_rebuildMatrices",value:function(){this._matrixDirty&&($.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrix),$.conjugateQuaternion(this._quaternion,this._conjugateQuaternion),$.quaternionToRotationMat4(this._quaternion,this._worldRotationMatrixConjugate),this._matrix.set(this._worldRotationMatrix),$.translateMat4v(this._position,this._matrix),this._matrixDirty=!1)}},{key:"rotationMatrixConjugate",get:function(){return this._matrixDirty&&this._rebuildMatrices(),this._worldRotationMatrixConjugate}},{key:"_setWorldMatrixDirty",value:function(){this._matrixDirty=!0,this._aabbDirty=!0}},{key:"_transformDirty",value:function(){this._matrixDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0}},{key:"_sceneModelDirty",value:function(){this.scene._aabbDirty=!0,this._aabbDirty=!0,this.scene._aabbDirty=!0,this._matrixDirty=!0;for(var e=0,t=this._entityList.length;e0},set:function(e){e=!1!==e,this._visible=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!!e,this._xrayed=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!!e,this._highlighted=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!!e,this._selected=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!!e,this._edges=e;for(var t=0,i=this._entityList.length;t0},set:function(e){e=!1!==e,this._pickable=e;for(var t=0,i=this._entityList.length;t0)e.colorsCompressed=new Uint8Array(e.colorsCompressed);else if(e.colors&&e.colors.length>0){for(var l=e.colors,u=new Uint8Array(l.length),A=0,c=l.length;A>24&255,r=i>>16&255,n=i>>8&255,o=255&i;switch(e.pickColor=new Uint8Array([o,n,r,s]),e.solid="solid"===e.primitive,t.origin=$.vec3(e.origin),e.type){case 2:t.layer=this._getDTXLayer(e),t.aabb=e.aabb;break;case 1:t.layer=this._getVBOBatchingLayer(e),t.aabb=e.aabb;break;case 0:t.layer=this._getVBOInstancingLayer(e),t.aabb=e.aabb}return e.transform&&(e.meshMatrix=e.transform.worldMatrix),t.portionId=t.layer.createPortion(t,e),this._meshes[e.id]=t,this._unusedMeshes[e.id]=t,this._meshList.push(t),t}},{key:"_getNumPrimitives",value:function(e){var t=0;switch(e.geometry?e.geometry.primitive:e.primitive){case"triangles":case"solid":case"surface":switch(e.type){case 2:for(var i=0,s=e.buckets.length;i>>0).toString(16)}},{key:"_getVBOInstancingLayer",value:function(e){var t=this,i=e.origin,s=e.textureSetId||"-",r=e.geometryId,n="".concat(Math.round(i[0]),".").concat(Math.round(i[1]),".").concat(Math.round(i[2]),".").concat(s,".").concat(r),o=this._vboInstancingLayers[n];if(o)return o;for(var a=e.textureSet,l=e.geometry;!o;)switch(l.primitive){case"triangles":case"surface":o=new sl({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!1});break;case"solid":o=new sl({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0,solid:!0});break;case"lines":o=new Hl({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0});break;case"points":o=new Ru({model:t,textureSet:a,geometry:l,origin:i,layerIndex:0})}return this._vboInstancingLayers[n]=o,this.layerList.push(o),o}},{key:"createEntity",value:function(e){if(void 0===e.id?e.id=$.createUUID():this.scene.components[e.id]&&(this.error("Scene already has a Component with this ID: ".concat(e.id," - will assign random ID")),e.id=$.createUUID()),void 0!==e.meshIds){var t=0;this._visible&&!1!==e.visible&&(t|=Qe),this._pickable&&!1!==e.pickable&&(t|=He),this._culled&&!1!==e.culled&&(t|=Ve),this._clippable&&!1!==e.clippable&&(t|=je),this._collidable&&!1!==e.collidable&&(t|=Ge),this._edges&&!1!==e.edges&&(t|=Xe),this._xrayed&&!1!==e.xrayed&&(t|=ze),this._highlighted&&!1!==e.highlighted&&(t|=We),this._selected&&!1!==e.selected&&(t|=Ke),e.flags=t,this._createEntity(e)}else this.error("Config missing: meshIds")}},{key:"_createEntity",value:function(e){for(var t=[],i=0,s=e.meshIds.length;it.sortId?1:0}));for(var o=0,a=this.layerList.length;o0&&0===this.renderFlags.numVisibleLayers?this.renderFlags.culled=!0:this._updateRenderFlags()}},{key:"_updateRenderFlagsVisibleLayers",value:function(){var e=this.renderFlags;e.numLayers=this.layerList.length,e.numVisibleLayers=0;for(var t=0,i=this.layerList.length;t0){var t="".concat(this.id,"-dummyEntityForUnusedMeshes");this.warn('Creating dummy SceneModelEntity "'.concat(t,'" for unused SceneMeshes: [').concat(e.join(","),"]")),this.createEntity({id:t,meshIds:e,isObject:!0})}this._unusedMeshes={}}},{key:"_getActiveSectionPlanesForLayer",value:function(e){var t=this.renderFlags,i=this.scene._sectionPlanesState.sectionPlanes,s=i.length,r=e.layerIndex*s;if(s>0)for(var n=0;n0&&(e.colorTransparent=!0),this.numXRayedLayerPortions>0){var t=this.scene.xrayMaterial._state;t.fill&&(t.fillAlpha<1?e.xrayedSilhouetteTransparent=!0:e.xrayedSilhouetteOpaque=!0),t.edges&&(t.edgeAlpha<1?e.xrayedEdgesTransparent=!0:e.xrayedEdgesOpaque=!0)}if(this.numEdgesLayerPortions>0)this.scene.edgeMaterial._state.edges&&(e.edgesOpaque=this.numTransparentLayerPortions0&&(e.edgesTransparent=!0));if(this.numSelectedLayerPortions>0){var i=this.scene.selectedMaterial._state;i.fill&&(i.fillAlpha<1?e.selectedSilhouetteTransparent=!0:e.selectedSilhouetteOpaque=!0),i.edges&&(i.edgeAlpha<1?e.selectedEdgesTransparent=!0:e.selectedEdgesOpaque=!0)}if(this.numHighlightedLayerPortions>0){var s=this.scene.highlightMaterial._state;s.fill&&(s.fillAlpha<1?e.highlightedSilhouetteTransparent=!0:e.highlightedSilhouetteOpaque=!0),s.edges&&(s.edgeAlpha<1?e.highlightedEdgesTransparent=!0:e.highlightedEdgesOpaque=!0)}}}},{key:"drawColorOpaque",value:function(e){for(var t=this.renderFlags,i=0,s=t.visibleLayers.length;i2&&void 0!==arguments[2]&&arguments[2],s=e.positionsCompressed||[],r=jc(e.indices||[],t),n=Wc(e.edgeIndices||[]);function o(e,t){if(e>t){var i=e;e=t,t=i}function s(i,s){return i!==e?e-i:s!==t?t-s:0}for(var r=0,o=(n.length>>1)-1;r<=o;){var a=o+r>>1,l=s(n[2*a],n[2*a+1]);if(l>0)r=a+1;else{if(!(l<0))return a;o=a-1}}return-r-1}var a=new Int32Array(n.length/2);a.fill(0);var l=s.length/3;if(l>8*(1<h.maxNumPositions&&(h=c()),h.bucketNumber>8)return[e];-1===u[v]&&(u[v]=h.numPositions++,h.positionsCompressed.push(s[3*v]),h.positionsCompressed.push(s[3*v+1]),h.positionsCompressed.push(s[3*v+2])),-1===u[g]&&(u[g]=h.numPositions++,h.positionsCompressed.push(s[3*g]),h.positionsCompressed.push(s[3*g+1]),h.positionsCompressed.push(s[3*g+2])),-1===u[m]&&(u[m]=h.numPositions++,h.positionsCompressed.push(s[3*m]),h.positionsCompressed.push(s[3*m+1]),h.positionsCompressed.push(s[3*m+2])),h.indices.push(u[v]),h.indices.push(u[g]),h.indices.push(u[m]);var _=void 0;(_=o(v,g))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]])),(_=o(v,m))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]])),(_=o(g,m))>=0&&0===a[_]&&(a[_]=1,h.edgeIndices.push(u[n[2*_]]),h.edgeIndices.push(u[n[2*_+1]]))}var y=t/8*2,b=t/8,B=2*s.length+(r.length+n.length)*y,w=0;return s.length,A.forEach((function(e){w+=2*e.positionsCompressed.length+(e.indices.length+e.edgeIndices.length)*b,e.positionsCompressed.length})),w>B?[e]:(i&&Kc(A,e),A)}({positionsCompressed:s,indices:r,edgeIndices:n},s.length/3>65536?16:8):o=[{positionsCompressed:s,indices:r,edgeIndices:n}];return o}var hh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,e,r))._positions=r.positions||[],r.indices)s._indices=r.indices;else{s._indices=[];for(var n=0,o=s._positions.length/3-1;n1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"BCFViewpoints",e,r)).originatingSystem=r.originatingSystem||"xeokit.io",s.authoringTool=r.authoringTool||"xeokit.io",s}return C(i,[{key:"getViewpoint",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=this.viewer.scene,s=i.camera,r=i.realWorldOffset,n=!0===t.reverseClippingPlanes,o={},a=$.normalizeVec3($.subVec3(s.look,s.eye,$.vec3())),l=s.eye,u=s.up;s.yUp&&(a=yh(a),l=yh(l),u=yh(u));var A=mh($.addVec3(l,r));"ortho"===s.projection?o.orthogonal_camera={camera_view_point:A,camera_direction:mh(a),camera_up_vector:mh(u),view_to_world_scale:s.ortho.scale}:o.perspective_camera={camera_view_point:A,camera_direction:mh(a),camera_up_vector:mh(u),field_of_view:s.perspective.fov};var c=i.sectionPlanes;for(var d in c)if(c.hasOwnProperty(d)){var p=c[d];if(!p.active)continue;var f=p.pos,v=void 0;v=n?$.negateVec3(p.dir,$.vec3()):p.dir,s.yUp&&(f=yh(f),v=yh(v)),$.addVec3(f,r),f=mh(f),v=mh(v),o.clipping_planes||(o.clipping_planes=[]),o.clipping_planes.push({location:f,direction:v})}var g=i.lineSets;for(var m in g)if(g.hasOwnProperty(m)){var _=g[m];o.lines||(o.lines=[]);for(var y=_.positions,b=_.indices,B=0,w=b.length/2;B1&&void 0!==arguments[1]?arguments[1]:{};if(e){var s=this.viewer,r=s.scene,n=r.camera,o=!1!==i.rayCast,a=!1!==i.immediate,l=!1!==i.reset,u=r.realWorldOffset,A=!0===i.reverseClippingPlanes;if(r.clearSectionPlanes(),e.clipping_planes&&e.clipping_planes.length>0&&e.clipping_planes.forEach((function(e){var t=_h(e.location,dh),i=_h(e.direction,dh);A&&$.negateVec3(i),$.subVec3(t,u),n.yUp&&(t=bh(t),i=bh(i)),new An(r,{pos:t,dir:i})})),r.clearLines(),e.lines&&e.lines.length>0){var c=[],h=[],d=0;e.lines.forEach((function(e){e.start_point&&e.end_point&&(c.push(e.start_point.x),c.push(e.start_point.y),c.push(e.start_point.z),c.push(e.end_point.x),c.push(e.end_point.y),c.push(e.end_point.z),h.push(d++),h.push(d++))})),new hh(r,{positions:c,indices:h,clippable:!1,collidable:!0})}if(r.clearBitmaps(),e.bitmaps&&e.bitmaps.length>0&&e.bitmaps.forEach((function(e){var t=e.bitmap_type||"jpg",i=e.bitmap_data,s=_h(e.location,ph),o=_h(e.normal,fh),a=_h(e.up,vh),l=e.height||1;t&&i&&s&&o&&a&&(n.yUp&&(s=bh(s),o=bh(o),a=bh(a)),new Zn(r,{src:i,type:t,pos:s,normal:o,up:a,clippable:!1,collidable:!0,height:l}))})),l&&(r.setObjectsXRayed(r.xrayedObjectIds,!1),r.setObjectsHighlighted(r.highlightedObjectIds,!1),r.setObjectsSelected(r.selectedObjectIds,!1)),e.components){if(e.components.visibility){e.components.visibility.default_visibility?(r.setObjectsVisible(r.objectIds,!0),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.visible=!1}))}))):(r.setObjectsVisible(r.objectIds,!1),e.components.visibility.exceptions&&e.components.visibility.exceptions.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.visible=!0}))})));var p=e.components.visibility.view_setup_hints;p&&(!1===p.spaces_visible&&r.setObjectsVisible(s.metaScene.getObjectIDsByType("IfcSpace"),!0),void 0!==p.spaces_translucent&&r.setObjectsXRayed(s.metaScene.getObjectIDsByType("IfcSpace"),!0),p.space_boundaries_visible,!1===p.openings_visible&&r.setObjectsVisible(s.metaScene.getObjectIDsByType("IfcOpening"),!0),p.space_boundaries_translucent,void 0!==p.openings_translucent&&r.setObjectsXRayed(s.metaScene.getObjectIDsByType("IfcOpening"),!0))}e.components.selection&&(r.setObjectsSelected(r.selectedObjectIds,!1),e.components.selection.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.selected=!0}))}))),e.components.translucency&&(r.setObjectsXRayed(r.xrayedObjectIds,!1),e.components.translucency.forEach((function(e){return t._withBCFComponent(i,e,(function(e){return e.xrayed=!0}))}))),e.components.coloring&&e.components.coloring.forEach((function(e){var s=e.color,r=0,n=!1;8===s.length&&((r=parseInt(s.substring(0,2),16)/256)<=1&&r>=.95&&(r=1),s=s.substring(2),n=!0);var o=[parseInt(s.substring(0,2),16)/256,parseInt(s.substring(2,4),16)/256,parseInt(s.substring(4,6),16)/256];e.components.map((function(e){return t._withBCFComponent(i,e,(function(e){e.colorize=o,n&&(e.opacity=r)}))}))}))}if(e.perspective_camera||e.orthogonal_camera){var f,v,g,m;if(e.perspective_camera?(f=_h(e.perspective_camera.camera_view_point,dh),v=_h(e.perspective_camera.camera_direction,dh),g=_h(e.perspective_camera.camera_up_vector,dh),n.perspective.fov=e.perspective_camera.field_of_view,m="perspective"):(f=_h(e.orthogonal_camera.camera_view_point,dh),v=_h(e.orthogonal_camera.camera_direction,dh),g=_h(e.orthogonal_camera.camera_up_vector,dh),n.ortho.scale=e.orthogonal_camera.view_to_world_scale,m="ortho"),$.subVec3(f,u),n.yUp&&(f=bh(f),v=bh(v),g=bh(g)),o){var _=r.pick({pickSurface:!0,origin:f,direction:v});v=_?_.worldPos:$.addVec3(f,v,dh)}else v=$.addVec3(f,v,dh);a?(n.eye=f,n.look=v,n.up=g,n.projection=m):s.cameraFlight.flyTo({eye:f,look:v,up:g,duration:i.duration,projection:m})}}}},{key:"_withBCFComponent",value:function(e,t,i){var s=this.viewer,r=s.scene;if(t.authoring_tool_id&&t.originating_system===this.originatingSystem){var n=t.authoring_tool_id,o=r.objects[n];if(o)return void i(o);if(e.updateCompositeObjects)if(s.metaScene.metaObjects[n])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}if(t.ifc_guid){var a=t.ifc_guid,l=r.objects[a];if(l)return void i(l);if(e.updateCompositeObjects)if(s.metaScene.metaObjects[a])return void r.withObjects(s.metaScene.getObjectIDsInSubtree(a),i);Object.keys(r.models).forEach((function(t){var n=$.globalizeObjectId(t,a),o=r.objects[n];o?i(o):e.updateCompositeObjects&&s.metaScene.metaObjects[n]&&r.withObjects(s.metaScene.getObjectIDsInSubtree(n),i)}))}}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this)}}]),i}();function mh(e){return{x:e[0],y:e[1],z:e[2]}}function _h(e,t){return(t=new Float64Array(3))[0]=e.x,t[1]=e.y,t[2]=e.z,t}function yh(e){return new Float64Array([e[0],-e[2],e[1]])}function bh(e){return new Float64Array([e[0],e[2],-e[1]])}function Bh(e){var t="";return t+=Math.round(255*e[0]).toString(16).padStart(2,"0"),t+=Math.round(255*e[1]).toString(16).padStart(2,"0"),t+=Math.round(255*e[2]).toString(16).padStart(2,"0")}var wh=$.vec3(),xh=function(e,t,i,s){var r=e-i,n=t-s;return Math.sqrt(r*r+n*n)},Ph=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,e.viewer.scene,r)).plugin=e,s._container=r.container,!s._container)throw"config missing: container";s._eventSubs={};var n=s.plugin.viewer.scene;s._originMarker=new et(n,r.origin),s._targetMarker=new et(n,r.target),s._originWorld=$.vec3(),s._targetWorld=$.vec3(),s._wp=new Float64Array(24),s._vp=new Float64Array(24),s._pp=new Float64Array(24),s._cp=new Float64Array(8),s._xAxisLabelCulled=!1,s._yAxisLabelCulled=!1,s._zAxisLabelCulled=!1,s._color=r.color||s.plugin.defaultColor;var o=r.onMouseOver?function(e){r.onMouseOver(e,b(s)),s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseover",e))}:null,a=r.onMouseLeave?function(e){r.onMouseLeave(e,b(s)),s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseleave",e))}:null,l=function(e){s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousedown",e))},u=function(e){s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mouseup",e))},A=function(e){s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent("mousemove",e))},c=r.onContextMenu?function(e){r.onContextMenu(e,b(s))}:null,h=function(e){s.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent("wheel",e))};return s._originDot=new it(s._container,{fillColor:s._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._targetDot=new it(s._container,{fillColor:s._color,zIndex:void 0!==e.zIndex?e.zIndex+2:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._lengthWire=new tt(s._container,{color:s._color,thickness:2,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._xAxisWire=new tt(s._container,{color:"#FF0000",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._yAxisWire=new tt(s._container,{color:"green",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._zAxisWire=new tt(s._container,{color:"blue",thickness:1,thicknessClickable:6,zIndex:void 0!==e.zIndex?e.zIndex+1:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._lengthLabel=new st(s._container,{fillColor:s._color,prefix:"",text:"",zIndex:void 0!==e.zIndex?e.zIndex+4:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._xAxisLabel=new st(s._container,{fillColor:"red",prefix:"X",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._yAxisLabel=new st(s._container,{fillColor:"green",prefix:"Y",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._zAxisLabel=new st(s._container,{fillColor:"blue",prefix:"Z",text:"",zIndex:void 0!==e.zIndex?e.zIndex+3:void 0,onMouseOver:o,onMouseLeave:a,onMouseWheel:h,onMouseDown:l,onMouseUp:u,onMouseMove:A,onContextMenu:c}),s._wpDirty=!1,s._vpDirty=!1,s._cpDirty=!1,s._sectionPlanesDirty=!0,s._visible=!1,s._originVisible=!1,s._targetVisible=!1,s._wireVisible=!1,s._axisVisible=!1,s._xAxisVisible=!1,s._yAxisVisible=!1,s._zAxisVisible=!1,s._axisEnabled=!0,s._labelsVisible=!1,s._labelsOnWires=!1,s._clickable=!1,s._originMarker.on("worldPos",(function(e){s._originWorld.set(e||[0,0,0]),s._wpDirty=!0,s._needUpdate(0)})),s._targetMarker.on("worldPos",(function(e){s._targetWorld.set(e||[0,0,0]),s._wpDirty=!0,s._needUpdate(0)})),s._onViewMatrix=n.camera.on("viewMatrix",(function(){s._vpDirty=!0,s._needUpdate(0)})),s._onProjMatrix=n.camera.on("projMatrix",(function(){s._cpDirty=!0,s._needUpdate()})),s._onCanvasBoundary=n.canvas.on("boundary",(function(){s._cpDirty=!0,s._needUpdate(0)})),s._onMetricsUnits=n.metrics.on("units",(function(){s._cpDirty=!0,s._needUpdate()})),s._onMetricsScale=n.metrics.on("scale",(function(){s._cpDirty=!0,s._needUpdate()})),s._onMetricsOrigin=n.metrics.on("origin",(function(){s._cpDirty=!0,s._needUpdate()})),s._onSectionPlaneUpdated=n.on("sectionPlaneUpdated",(function(){s._sectionPlanesDirty=!0,s._needUpdate()})),s.approximate=r.approximate,s.visible=r.visible,s.originVisible=r.originVisible,s.targetVisible=r.targetVisible,s.wireVisible=r.wireVisible,s.axisVisible=r.axisVisible,s.xAxisVisible=r.xAxisVisible,s.yAxisVisible=r.yAxisVisible,s.zAxisVisible=r.zAxisVisible,s.labelsVisible=r.labelsVisible,s.labelsOnWires=r.labelsOnWires,s}return C(i,[{key:"_update",value:function(){if(this._visible){var e=this.plugin.viewer.scene;if(this._wpDirty&&(this._wp[0]=this._originWorld[0],this._wp[1]=this._originWorld[1],this._wp[2]=this._originWorld[2],this._wp[3]=1,this._wp[4]=this._targetWorld[0],this._wp[5]=this._originWorld[1],this._wp[6]=this._originWorld[2],this._wp[7]=1,this._wp[8]=this._targetWorld[0],this._wp[9]=this._targetWorld[1],this._wp[10]=this._originWorld[2],this._wp[11]=1,this._wp[12]=this._targetWorld[0],this._wp[13]=this._targetWorld[1],this._wp[14]=this._targetWorld[2],this._wp[15]=1,this._wpDirty=!1,this._vpDirty=!0),this._vpDirty&&($.transformPositions4(e.camera.viewMatrix,this._wp,this._vp),this._vp[3]=1,this._vp[7]=1,this._vp[11]=1,this._vp[15]=1,this._vpDirty=!1,this._cpDirty=!0),this._sectionPlanesDirty){if(this._isSliced(this._originWorld)||this._isSliced(this._targetWorld))return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setCulled(!0),this._yAxisWire.setCulled(!0),this._zAxisWire.setCulled(!0),this._lengthWire.setCulled(!0),this._originDot.setCulled(!0),void this._targetDot.setCulled(!0);this._xAxisLabel.setCulled(!1),this._yAxisLabel.setCulled(!1),this._zAxisLabel.setCulled(!1),this._lengthLabel.setCulled(!1),this._xAxisWire.setCulled(!1),this._yAxisWire.setCulled(!1),this._zAxisWire.setCulled(!1),this._lengthWire.setCulled(!1),this._originDot.setCulled(!1),this._targetDot.setCulled(!1),this._sectionPlanesDirty=!0}var t=this._originMarker.viewPos[2],i=this._targetMarker.viewPos[2];if(t>-.3||i>-.3)return this._xAxisLabel.setCulled(!0),this._yAxisLabel.setCulled(!0),this._zAxisLabel.setCulled(!0),this._lengthLabel.setCulled(!0),this._xAxisWire.setVisible(!1),this._yAxisWire.setVisible(!1),this._zAxisWire.setVisible(!1),this._lengthWire.setVisible(!1),this._originDot.setVisible(!1),void this._targetDot.setVisible(!1);if(this._cpDirty){$.transformPositions4(e.camera.project.matrix,this._vp,this._pp);for(var s=this._pp,r=this._cp,n=e.canvas.canvas.getBoundingClientRect(),o=this._container.getBoundingClientRect(),a=n.top-o.top,l=n.left-o.left,u=e.canvas.boundary,A=u[2],c=u[3],h=0,d=this.plugin.viewer.scene.metrics,p=d.scale,f=d.units,v=d.unitsInfo[f].abbrev,g=0,m=s.length;g1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e.viewer.scene))._canvasToPagePos=r.canvasToPagePos,s.pointerLens=r.pointerLens,s._active=!1,s._currentDistanceMeasurement=null,s._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},s._initMarkerDiv(),s._onCameraControlHoverSnapOrSurface=null,s._onCameraControlHoverSnapOrSurfaceOff=null,s._onMouseDown=null,s._onMouseUp=null,s._onCanvasTouchStart=null,s._onCanvasTouchEnd=null,s._snapping=!1!==r.snapping,s._mouseState=0,s._attachPlugin(e,r),s}return C(i,[{key:"_initMarkerDiv",value:function(){var e=document.createElement("div");e.setAttribute("id","myMarkerDiv");var t=this.scene.canvas.canvas;t.parentNode.insertBefore(e,t),e.style.background="black",e.style.border="2px solid blue",e.style.borderRadius="10px",e.style.width="5px",e.style.height="5px",e.style.top="-200px",e.style.left="-200px",e.style.margin="0 0",e.style.zIndex="100",e.style.position="absolute",e.style.pointerEvents="none",this._markerDiv=e}},{key:"_destroyMarkerDiv",value:function(){if(this._markerDiv){var e=document.getElementById("myMarkerDiv");e.parentNode.removeChild(e),this._markerDiv=null}}},{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=e}},{key:"active",get:function(){return this._active}},{key:"snapping",get:function(){return this._snapping},set:function(e){e!==this._snapping?(this._snapping=e,this.deactivate(),this.activate()):this._snapping=e}},{key:"activate",value:function(){var e=this;if(!this._active){this._markerDiv||this._initMarkerDiv(),this.fire("activated",!0);var t=this.distanceMeasurementsPlugin,i=this.scene,s=t.viewer.cameraControl,r=i.canvas.canvas;i.input;var n,o,a=!1,l=$.vec3(),u=$.vec2(),A=null;this._mouseState=0;var c=function e(t){return t.offsetTop+(t.offsetParent&&e(t.offsetParent))},h=function e(t){return t.offsetLeft+(t.offsetParent&&e(t.offsetParent))},d=$.vec2();this._onCameraControlHoverSnapOrSurface=s.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",(function(t){var i=t.snappedCanvasPos||t.canvasPos;a=!0,l.set(t.worldPos),u.set(t.canvasPos),0===e._mouseState?(e._canvasToPagePos?(e._canvasToPagePos(r,i,d),e._markerDiv.style.left="".concat(d[0]-5,"px"),e._markerDiv.style.top="".concat(d[1]-5,"px")):(e._markerDiv.style.left="".concat(h(r)+i[0]-5,"px"),e._markerDiv.style.top="".concat(c(r)+i[1]-5,"px")),e._markerDiv.style.background="pink",t.snappedToVertex||t.snappedToEdge?(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=t.canvasPos,e.pointerLens.snappedCanvasPos=t.snappedCanvasPos||t.canvasPos,e.pointerLens.snapped=!0),e._markerDiv.style.background="greenyellow",e._markerDiv.style.border="2px solid green"):(e.pointerLens&&(e.pointerLens.visible=!0,e.pointerLens.canvasPos=t.canvasPos,e.pointerLens.snappedCanvasPos=t.canvasPos,e.pointerLens.snapped=!1),e._markerDiv.style.background="pink",e._markerDiv.style.border="2px solid red"),A=t.entity):(e._markerDiv.style.left="-10000px",e._markerDiv.style.top="-10000px"),r.style.cursor="pointer",e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.wireVisible=e._currentDistanceMeasurementInitState.wireVisible,e._currentDistanceMeasurement.axisVisible=e._currentDistanceMeasurementInitState.axisVisible&&e.distanceMeasurementsPlugin.defaultAxisVisible,e._currentDistanceMeasurement.xAxisVisible=e._currentDistanceMeasurementInitState.xAxisVisible&&e.distanceMeasurementsPlugin.defaultXAxisVisible,e._currentDistanceMeasurement.yAxisVisible=e._currentDistanceMeasurementInitState.yAxisVisible&&e.distanceMeasurementsPlugin.defaultYAxisVisible,e._currentDistanceMeasurement.zAxisVisible=e._currentDistanceMeasurementInitState.zAxisVisible&&e.distanceMeasurementsPlugin.defaultZAxisVisible,e._currentDistanceMeasurement.targetVisible=e._currentDistanceMeasurementInitState.targetVisible,e._currentDistanceMeasurement.target.worldPos=l.slice(),e._markerDiv.style.left="-10000px",e._markerDiv.style.top="-10000px")})),r.addEventListener("mousedown",this._onMouseDown=function(e){1===e.which&&(n=e.clientX,o=e.clientY)}),r.addEventListener("mouseup",this._onMouseUp=function(i){1===i.which&&(i.clientX>n+20||i.clientXo+20||i.clientY1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"DistanceMeasurements",e))._pointerLens=r.pointerLens,s._container=r.container||document.body,s._defaultControl=null,s._measurements={},s.labelMinAxisLength=r.labelMinAxisLength,s.defaultVisible=!1!==r.defaultVisible,s.defaultOriginVisible=!1!==r.defaultOriginVisible,s.defaultTargetVisible=!1!==r.defaultTargetVisible,s.defaultWireVisible=!1!==r.defaultWireVisible,s.defaultLabelsVisible=!1!==r.defaultLabelsVisible,s.defaultAxisVisible=!1!==r.defaultAxisVisible,s.defaultXAxisVisible=!1!==r.defaultXAxisVisible,s.defaultYAxisVisible=!1!==r.defaultYAxisVisible,s.defaultZAxisVisible=!1!==r.defaultZAxisVisible,s.defaultColor=void 0!==r.defaultColor?r.defaultColor:"#00BBFF",s.zIndex=r.zIndex||1e4,s.defaultLabelsOnWires=!1!==r.defaultLabelsOnWires,s._onMouseOver=function(e,t){s.fire("mouseOver",{plugin:b(s),distanceMeasurement:t,measurement:t,event:e})},s._onMouseLeave=function(e,t){s.fire("mouseLeave",{plugin:b(s),distanceMeasurement:t,measurement:t,event:e})},s._onContextMenu=function(e,t){s.fire("contextMenu",{plugin:b(s),distanceMeasurement:t,measurement:t,event:e})},s}return C(i,[{key:"getContainerElement",value:function(){return this._container}},{key:"send",value:function(e,t){}},{key:"pointerLens",get:function(){return this._pointerLens}},{key:"control",get:function(){return this._defaultControl||(this._defaultControl=new Mh(this,{})),this._defaultControl}},{key:"measurements",get:function(){return this._measurements}},{key:"labelMinAxisLength",get:function(){return this._labelMinAxisLength},set:function(e){e<1&&(this.error("labelMinAxisLength must be >= 1; defaulting to 25"),e=25),this._labelMinAxisLength=e||25}},{key:"createMeasurement",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.viewer.scene.components[t.id]&&(this.error("Viewer scene component with this ID already exists: "+t.id),delete t.id);var i=t.origin,s=t.target,r=new Ph(this,{id:t.id,plugin:this,container:this._container,origin:{entity:i.entity,worldPos:i.worldPos},target:{entity:s.entity,worldPos:s.worldPos},visible:t.visible,wireVisible:t.wireVisible,axisVisible:!1!==t.axisVisible&&!1!==this.defaultAxisVisible,xAxisVisible:!1!==t.xAxisVisible&&!1!==this.defaultXAxisVisible,yAxisVisible:!1!==t.yAxisVisible&&!1!==this.defaultYAxisVisible,zAxisVisible:!1!==t.zAxisVisible&&!1!==this.defaultZAxisVisible,labelsVisible:!1!==t.labelsVisible&&!1!==this.defaultLabelsVisible,originVisible:t.originVisible,targetVisible:t.targetVisible,color:t.color,labelsOnWires:!1!==t.labelsOnWires&&!1!==this.defaultLabelsOnWires,onMouseOver:this._onMouseOver,onMouseLeave:this._onMouseLeave,onContextMenu:this._onContextMenu});return this._measurements[r.id]=r,r.on("destroyed",(function(){delete e._measurements[r.id]})),this.fire("measurementCreated",r),r}},{key:"destroyMeasurement",value:function(e){var t=this._measurements[e];t?(t.destroy(),this.fire("measurementDestroyed",t)):this.log("DistanceMeasurement not found: "+e)}},{key:"setLabelsShown",value:function(e){for(var t=0,i=Object.entries(this.measurements);t1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(s=t.call(this,e.viewer.scene)).pointerLens=r.pointerLens,s.pointerCircle=new De(e.viewer),s._active=!1;var n=document.createElement("div"),o=s.scene.canvas.canvas;return o.parentNode.insertBefore(n,o),n.style.background="black",n.style.border="2px solid blue",n.style.borderRadius="10px",n.style.width="5px",n.style.height="5px",n.style.margin="-200px -200px",n.style.zIndex="100",n.style.position="absolute",n.style.pointerEvents="none",s.markerDiv=n,s._currentDistanceMeasurement=null,s._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null},s._onCanvasTouchStart=null,s._onCanvasTouchEnd=null,s._longTouchTimeoutMs=300,s._snapToEdge=!1!==r.snapToEdge,s._snapToVertex=!1!==r.snapToVertex,s._touchState=0,s._attachPlugin(e,r),s}return C(i,[{key:"_attachPlugin",value:function(e){this.distanceMeasurementsPlugin=e,this.plugin=e}},{key:"active",get:function(){return this._active}},{key:"snapToVertex",get:function(){return this._snapToVertex},set:function(e){this._snapToVertex=e}},{key:"snapToEdge",get:function(){return this._snapToEdge},set:function(e){this._snapToEdge=e}},{key:"activate",value:function(){var e=this;if(!this._active){var t=this.plugin,i=this.scene,s=i.canvas.canvas;t.pointerLens;var r=$.vec3(),n=20,o=null;this._touchState=0;var a=$.vec2(),l=$.vec2(),u=$.vec2(),A=null,c=function(){e.plugin.viewer.cameraControl.active=!1},h=function(){e.plugin.viewer.cameraControl.active=!0};s.addEventListener("touchstart",this._onCanvasTouchStart=function(s){var u=s.touches.length;if(1===u){var d=s.touches[0],p=d.clientX,f=d.clientY;switch(a.set([p,f]),l.set([p,f]),e._touchState){case 0:if(1!==u&&null!==o)return o&&(clearTimeout(o),o=null),e._currentDistanceMeasurement&&(e._currentDistanceMeasurement.destroy(),e._currentDistanceMeasurement=null),h(),void(e._touchState=0);var v=i.pick({canvasPos:l,snapToVertex:e._snapToVertex,snapToEdge:e._snapToEdge});if(v&&v.snapped)r.set(v.worldPos),e.pointerCircle.start(v.snappedCanvasPos);else{var g=i.pick({canvasPos:l,pickSurface:!0});if(!g||!g.worldPos)return;r.set(g.worldPos),e.pointerCircle.start(g.canvasPos)}o=setTimeout((function(){1!==u||l[0]>a[0]+n||l[0]a[1]+n||l[1]a[0]+n||l[0]a[1]+n||l[1]a[0]+n||da[1]+n||pa[0]+n||da[1]+n||p1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(s=t.call(this,"FastNav",e))._hideColorTexture=!1!==r.hideColorTexture,s._hidePBR=!1!==r.hidePBR,s._hideSAO=!1!==r.hideSAO,s._hideEdges=!1!==r.hideEdges,s._hideTransparentObjects=!!r.hideTransparentObjects,s._scaleCanvasResolution=!!r.scaleCanvasResolution,s._defaultScaleCanvasResolutionFactor=r.defaultScaleCanvasResolutionFactor||1,s._scaleCanvasResolutionFactor=r.scaleCanvasResolutionFactor||.6,s._delayBeforeRestore=!1!==r.delayBeforeRestore,s._delayBeforeRestoreSeconds=r.delayBeforeRestoreSeconds||.5;var n=1e3*s._delayBeforeRestoreSeconds,o=!1,a=function(){n=1e3*s._delayBeforeRestoreSeconds,o||(e.scene._renderer.setColorTextureEnabled(!s._hideColorTexture),e.scene._renderer.setPBREnabled(!s._hidePBR),e.scene._renderer.setSAOEnabled(!s._hideSAO),e.scene._renderer.setTransparentEnabled(!s._hideTransparentObjects),e.scene._renderer.setEdgesEnabled(!s._hideEdges),s._scaleCanvasResolution?e.scene.canvas.resolutionScale=s._scaleCanvasResolutionFactor:e.scene.canvas.resolutionScale=s._defaultScaleCanvasResolutionFactor,o=!0)},l=function(){e.scene.canvas.resolutionScale=s._defaultScaleCanvasResolutionFactor,e.scene._renderer.setEdgesEnabled(!0),e.scene._renderer.setColorTextureEnabled(!0),e.scene._renderer.setPBREnabled(!0),e.scene._renderer.setSAOEnabled(!0),e.scene._renderer.setTransparentEnabled(!0),o=!1};s._onCanvasBoundary=e.scene.canvas.on("boundary",a),s._onCameraMatrix=e.scene.camera.on("matrix",a),s._onSceneTick=e.scene.on("tick",(function(e){o&&(n-=e.deltaTime,(!s._delayBeforeRestore||n<=0)&&l())}));var u=!1;return s._onSceneMouseDown=e.scene.input.on("mousedown",(function(){u=!0})),s._onSceneMouseUp=e.scene.input.on("mouseup",(function(){u=!1})),s._onSceneMouseMove=e.scene.input.on("mousemove",(function(){u&&a()})),s}return C(i,[{key:"hideColorTexture",get:function(){return this._hideColorTexture},set:function(e){this._hideColorTexture=e}},{key:"hidePBR",get:function(){return this._hidePBR},set:function(e){this._hidePBR=e}},{key:"hideSAO",get:function(){return this._hideSAO},set:function(e){this._hideSAO=e}},{key:"hideEdges",get:function(){return this._hideEdges},set:function(e){this._hideEdges=e}},{key:"hideTransparentObjects",get:function(){return this._hideTransparentObjects},set:function(e){this._hideTransparentObjects=!1!==e}},{key:"scaleCanvasResolution",get:function(){return this._scaleCanvasResolution},set:function(e){this._scaleCanvasResolution=e}},{key:"defaultScaleCanvasResolutionFactor",get:function(){return this._defaultScaleCanvasResolutionFactor},set:function(e){this._defaultScaleCanvasResolutionFactor=e||1}},{key:"scaleCanvasResolutionFactor",get:function(){return this._scaleCanvasResolutionFactor},set:function(e){this._scaleCanvasResolutionFactor=e||.6}},{key:"delayBeforeRestore",get:function(){return this._delayBeforeRestore},set:function(e){this._delayBeforeRestore=e}},{key:"delayBeforeRestoreSeconds",get:function(){return this._delayBeforeRestoreSeconds},set:function(e){this._delayBeforeRestoreSeconds=null!=e?e:.5}},{key:"send",value:function(e,t){}},{key:"destroy",value:function(){this.viewer.scene.camera.off(this._onCameraMatrix),this.viewer.scene.canvas.off(this._onCanvasBoundary),this.viewer.scene.input.off(this._onSceneMouseDown),this.viewer.scene.input.off(this._onSceneMouseUp),this.viewer.scene.input.off(this._onSceneMouseMove),this.viewer.scene.off(this._onSceneTick),f(B(i.prototype),"destroy",this).call(this)}}]),i}(),Ih=function(){function e(){x(this,e)}return C(e,[{key:"getMetaModel",value:function(e,t,i){le.loadJSON(e,(function(e){t(e)}),(function(e){i(e)}))}},{key:"getGLTF",value:function(e,t,i){le.loadArraybuffer(e,(function(e){t(e)}),(function(e){i(e)}))}},{key:"getGLB",value:function(e,t,i){le.loadArraybuffer(e,(function(e){t(e)}),(function(e){i(e)}))}},{key:"getArrayBuffer",value:function(e,t,i,s){!function(e,t,i,s){var r=function(){};i=i||r,s=s||r;var n=/^data:(.*?)(;base64)?,(.*)$/,o=t.match(n);if(o){var a=!!o[2],l=o[3];l=window.decodeURIComponent(l),a&&(l=window.atob(l));try{for(var u=new ArrayBuffer(l.length),A=new Uint8Array(u),c=0;c0&&void 0!==arguments[0]?arguments[0]:{};x(this,e),this._eventSubIDMap=null,this._eventSubEvents=null,this._eventSubs=null,this._events=null,this._locale="en",this._messages={},this._locales=[],this._locale="en",this.messages=t.messages,this.locale=t.locale}return C(e,[{key:"messages",set:function(e){this._messages=e||{},this._locales=Object.keys(this._messages),this.fire("updated",this)}},{key:"loadMessages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var t in e)this._messages[t]=e[t];this.messages=this._messages}},{key:"clearMessages",value:function(){this.messages={}}},{key:"locales",get:function(){return this._locales}},{key:"locale",get:function(){return this._locale},set:function(e){e=e||"de",this._locale!==e&&(this._locale=e,this.fire("updated",e))}},{key:"translate",value:function(e,t){var i=this._messages[this._locale];if(!i)return null;var s=Sh(e,i);return s?t?Th(s,t):s:null}},{key:"translatePlurals",value:function(e,t,i){var s=this._messages[this._locale];if(!s)return null;var r=Sh(e,s);return(r=0===(t=parseInt(""+t,10))?r.zero:t>1?r.other:r.one)?(r=Th(r,[t]),i&&(r=Th(r,i)),r):null}},{key:"fire",value:function(e,t,i){this._events||(this._events={}),this._eventSubs||(this._eventSubs={}),!0!==i&&(this._events[e]=t||!0);var s=this._eventSubs[e];if(s)for(var r in s){if(s.hasOwnProperty(r))s[r].callback(t)}}},{key:"on",value:function(e,t){this._events||(this._events={}),this._eventSubIDMap||(this._eventSubIDMap=new Q),this._eventSubEvents||(this._eventSubEvents={}),this._eventSubs||(this._eventSubs={});var i=this._eventSubs[e];i||(i={},this._eventSubs[e]=i);var s=this._eventSubIDMap.addItem();i[s]={callback:t},this._eventSubEvents[s]=e;var r=this._events[e];return void 0!==r&&t(r),s}},{key:"off",value:function(e){if(null!=e&&this._eventSubEvents){var t=this._eventSubEvents[e];if(t){delete this._eventSubEvents[e];var i=this._eventSubs[t];i&&delete i[e],this._eventSubIDMap.removeItem(e)}}}}]),e}();function Sh(e,t){if(t[e])return t[e];for(var i=e.split("."),s=t,r=0,n=i.length;s&&r1&&void 0!==arguments[1]?arguments[1]:[];return e.replace(/\{\{|\}\}|\{(\d+)\}/g,(function(e,i){return"{{"===e?"{":"}}"===e?"}":t[i]}))}var Rh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).t=r.t,s}return C(i,[{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"tangent",get:function(){return this.getTangent(this._t)}},{key:"length",get:function(){var e=this._getLengths();return e[e.length-1]}},{key:"getTangent",value:function(e){var t=1e-4;void 0===e&&(e=this._t);var i=e-t,s=e+t;i<0&&(i=0),s>1&&(s=1);var r=this.getPoint(i),n=this.getPoint(s),o=$.subVec3(n,r,[]);return $.normalizeVec3(o,[])}},{key:"getPointAt",value:function(e){var t=this.getUToTMapping(e);return this.getPoint(t)}},{key:"getPoints",value:function(e){e||(e=5);var t,i=[];for(t=0;t<=e;t++)i.push(this.getPoint(t/e));return i}},{key:"_getLengths",value:function(e){if(e||(e=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,i,s=[],r=this.getPoint(0),n=0;for(s.push(0),i=1;i<=e;i++)t=this.getPoint(i/e),n+=$.lenVec3($.subVec3(t,r,[])),s.push(n),r=t;return this.cacheArcLengths=s,s}},{key:"_updateArcLengths",value:function(){this.needsUpdate=!0,this._getLengths()}},{key:"getUToTMapping",value:function(e,t){var i,s=this._getLengths(),r=0,n=s.length;i=t||e*s[n-1];for(var o,a=0,l=n-1;a<=l;)if((o=s[r=Math.floor(a+(l-a)/2)]-i)<0)a=r+1;else{if(!(o>0)){l=r;break}l=r-1}if(s[r=l]===i)return r/(n-1);var u=s[r];return(r+(i-u)/(s[r+1]-u))/(n-1)}}]),i}(),Lh=function(e){g(i,Rh);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).points=r.points,s.t=r.t,s}return C(i,[{key:"points",get:function(){return this._points},set:function(e){this._points=e||[]}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var t=this.points;if(!(t.length<3)){var i=(t.length-1)*e,s=Math.floor(i),r=i-s,n=t[0===s?s:s-1],o=t[s],a=t[s>t.length-2?t.length-1:s+1],l=t[s>t.length-3?t.length-1:s+2],u=$.vec3();return u[0]=$.catmullRomInterpolate(n[0],o[0],a[0],l[0],r),u[1]=$.catmullRomInterpolate(n[1],o[1],a[1],l[1],r),u[2]=$.catmullRomInterpolate(n[2],o[2],a[2],l[2],r),u}this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].")}},{key:"getJSON",value:function(){return{points:points,t:this._t}}}]),i}(),Uh=$.vec3(),Oh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._frames=[],s._eyeCurve=new Lh(b(s)),s._lookCurve=new Lh(b(s)),s._upCurve=new Lh(b(s)),r.frames&&(s.addFrames(r.frames),s.smoothFrameTimes(1)),s}return C(i,[{key:"type",get:function(){return"CameraPath"}},{key:"frames",get:function(){return this._frames}},{key:"eyeCurve",get:function(){return this._eyeCurve}},{key:"lookCurve",get:function(){return this._lookCurve}},{key:"upCurve",get:function(){return this._upCurve}},{key:"saveFrame",value:function(e){var t=this.scene.camera;this.addFrame(e,t.eye,t.look,t.up)}},{key:"addFrame",value:function(e,t,i,s){var r={t:e,eye:t.slice(0),look:i.slice(0),up:s.slice(0)};this._frames.push(r),this._eyeCurve.points.push(r.eye),this._lookCurve.points.push(r.look),this._upCurve.points.push(r.up)}},{key:"addFrames",value:function(e){for(var t,i=0,s=e.length;i1?1:e,t.eye=this._eyeCurve.getPoint(e,Uh),t.look=this._lookCurve.getPoint(e,Uh),t.up=this._upCurve.getPoint(e,Uh)}},{key:"sampleFrame",value:function(e,t,i,s){e=e<0?0:e>1?1:e,this._eyeCurve.getPoint(e,t),this._lookCurve.getPoint(e,i),this._upCurve.getPoint(e,s)}},{key:"smoothFrameTimes",value:function(e){if(0!==this._frames.length){var t=$.vec3(),i=0;this._frames[0].t=0;for(var s=[],r=1,n=this._frames.length;r1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._look1=$.vec3(),s._eye1=$.vec3(),s._up1=$.vec3(),s._look2=$.vec3(),s._eye2=$.vec3(),s._up2=$.vec3(),s._orthoScale1=1,s._orthoScale2=1,s._flying=!1,s._flyEyeLookUp=!1,s._flyingEye=!1,s._flyingLook=!1,s._callback=null,s._callbackScope=null,s._time1=null,s._time2=null,s.easing=!1!==r.easing,s.duration=r.duration,s.fit=r.fit,s.fitFOV=r.fitFOV,s.trail=r.trail,s}return C(i,[{key:"type",get:function(){return"CameraFlightAnimation"}},{key:"flyTo",value:function(e,t,i){e=e||this.scene,this._flying&&this.stop(),this._flying=!1,this._flyingEye=!1,this._flyingLook=!1,this._flyingEyeLookUp=!1,this._callback=t,this._callbackScope=i;var s,r,n,o,a,l=this.scene.camera,u=!!e.projection&&e.projection!==l.projection;if(this._eye1[0]=l.eye[0],this._eye1[1]=l.eye[1],this._eye1[2]=l.eye[2],this._look1[0]=l.look[0],this._look1[1]=l.look[1],this._look1[2]=l.look[2],this._up1[0]=l.up[0],this._up1[1]=l.up[1],this._up1[2]=l.up[2],this._orthoScale1=l.ortho.scale,this._orthoScale2=e.orthoScale||this._orthoScale1,e.aabb)s=e.aabb;else if(6===e.length)s=e;else if(e.eye&&e.look||e.up)r=e.eye,n=e.look,o=e.up;else if(e.eye)r=e.eye;else if(e.look)n=e.look;else{var A=e;if((le.isNumeric(A)||le.isString(A))&&(a=A,!(A=this.scene.components[a])))return this.error("Component not found: "+le.inQuotes(a)),void(t&&(i?t.call(i):t()));u||(s=A.aabb||this.scene.aabb)}var c=e.poi;if(s){if(s[3]=1;e>1&&(e=1);var s=this.easing?i._ease(e,0,1,1):e,r=this.scene.camera;if(this._flyingEye||this._flyingLook?this._flyingEye?($.subVec3(r.eye,r.look,jh),r.eye=$.lerpVec3(s,0,1,this._eye1,this._eye2,Vh),r.look=$.subVec3(Vh,jh,Qh)):this._flyingLook&&(r.look=$.lerpVec3(s,0,1,this._look1,this._look2,Qh),r.up=$.lerpVec3(s,0,1,this._up1,this._up2,Hh)):this._flyingEyeLookUp&&(r.eye=$.lerpVec3(s,0,1,this._eye1,this._eye2,Vh),r.look=$.lerpVec3(s,0,1,this._look1,this._look2,Qh),r.up=$.lerpVec3(s,0,1,this._up1,this._up2,Hh)),this._projection2){var n="ortho"===this._projection2?i._easeOutExpo(e,0,1,1):i._easeInCubic(e,0,1,1);r.customProjection.matrix=$.lerpMat4(n,0,1,this._projMatrix1,this._projMatrix2)}else r.ortho.scale=this._orthoScale1+e*(this._orthoScale2-this._orthoScale1);if(t)return r.ortho.scale=this._orthoScale2,void this.stop();_e.scheduleTask(this._update,this)}}},{key:"stop",value:function(){if(this._flying){this._flying=!1,this._time1=null,this._time2=null,this._projection2&&(this.scene.camera.projection=this._projection2);var e=this._callback;e&&(this._callback=null,this._callbackScope?e.call(this._callbackScope):e()),this.fire("stopped",!0,!0)}}},{key:"cancel",value:function(){this._flying&&(this._flying=!1,this._time1=null,this._time2=null,this._callback&&(this._callback=null),this.fire("canceled",!0,!0))}},{key:"duration",get:function(){return this._duration/1e3},set:function(e){this._duration=e?1e3*e:500,this.stop()}},{key:"fit",get:function(){return this._fit},set:function(e){this._fit=!1!==e}},{key:"fitFOV",get:function(){return this._fitFOV},set:function(e){this._fitFOV=e||45}},{key:"trail",get:function(){return this._trail},set:function(e){this._trail=!!e}},{key:"destroy",value:function(){this.stop(),f(B(i.prototype),"destroy",this).call(this)}}],[{key:"_ease",value:function(e,t,i,s){return-i*(e/=s)*(e-2)+t}},{key:"_easeInCubic",value:function(e,t,i,s){return i*(e/=s)*e*e+t}},{key:"_easeOutExpo",value:function(e,t,i,s){return i*(1-Math.pow(2,-10*e/s))+t}}]),i}(),zh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._cameraFlightAnimation=new Gh(b(s)),s._t=0,s.state=i.SCRUBBING,s._playingFromT=0,s._playingToT=0,s._playingRate=r.playingRate||1,s._playingDir=1,s._lastTime=null,s.cameraPath=r.cameraPath,s._tick=s.scene.on("tick",s._updateT,b(s)),s}return C(i,[{key:"type",get:function(){return"CameraPathAnimation"}},{key:"_updateT",value:function(){var e=this._cameraPath;if(e){var t,s,r=performance.now(),n=this._lastTime?.001*(r-this._lastTime):0;if(this._lastTime=r,0!==n)switch(this.state){case i.SCRUBBING:return;case i.PLAYING:if(this._t+=this._playingRate*n,0===(t=this._cameraPath.frames.length)||this._playingDir<0&&this._t<=0||this._playingDir>0&&this._t>=this._cameraPath.frames[t-1].t)return this.state=i.SCRUBBING,this._t=this._cameraPath.frames[t-1].t,void this.fire("stopped");e.loadFrame(this._t);break;case i.PLAYING_TO:s=this._t+this._playingRate*n*this._playingDir,(this._playingDir<0&&s<=this._playingToT||this._playingDir>0&&s>=this._playingToT)&&(s=this._playingToT,this.state=i.SCRUBBING,this.fire("stopped")),this._t=s,e.loadFrame(this._t)}}}},{key:"_ease",value:function(e,t,i,s){return-i*(e/=s)*(e-2)+t}},{key:"cameraPath",get:function(){return this._cameraPath},set:function(e){this._cameraPath=e}},{key:"rate",get:function(){return this._playingRate},set:function(e){this._playingRate=e}},{key:"play",value:function(){this._cameraPath&&(this._lastTime=null,this.state=i.PLAYING)}},{key:"playToT",value:function(e){this._cameraPath&&(this._playingFromT=this._t,this._playingToT=e,this._playingDir=this._playingToT-this._playingFromT<0?-1:1,this._lastTime=null,this.state=i.PLAYING_TO)}},{key:"playToFrame",value:function(e){var t=this._cameraPath;if(t){var i=t.frames[e];i?this.playToT(i.t):this.error("playToFrame - frame index out of range: "+e)}}},{key:"flyToFrame",value:function(e,t){var s=this._cameraPath;if(s){var r=s.frames[e];r?(this.state=i.SCRUBBING,this._cameraFlightAnimation.flyTo(r,t)):this.error("flyToFrame - frame index out of range: "+e)}}},{key:"scrubToT",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(this._t=e,t.loadFrame(this._t),this.state=i.SCRUBBING))}},{key:"scrubToFrame",value:function(e){var t=this._cameraPath;t&&(this.scene.camera&&(t.frames[e]?(t.loadFrame(this._t),this.state=i.SCRUBBING):this.error("playToFrame - frame index out of range: "+e)))}},{key:"stop",value:function(){this.state=i.SCRUBBING,this.fire("stopped")}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this),this.scene.off(this._tick)}}]),i}();zh.STOPPED=0,zh.SCRUBBING=1,zh.PLAYING=2,zh.PLAYING_TO=3;var Wh=$.vec3(),Kh=$.vec3();$.vec3();var Xh=$.vec3([0,-1,0]),Jh=$.vec4([0,0,0,1]),Yh=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._src=null,s._image=null,s._pos=$.vec3(),s._origin=$.vec3(),s._rtcPos=$.vec3(),s._dir=$.vec3(),s._size=1,s._imageSize=$.vec2(),s._texture=new Ln(b(s)),s._plane=new sn(b(s),{geometry:new Si(b(s),Kn({center:[0,0,0],xSize:1,zSize:1,xSegments:10,zSegments:10})),material:new Oi(b(s),{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:s._texture,emissiveMap:s._texture,backfaces:!0}),clippable:r.clippable}),s._grid=new sn(b(s),{geometry:new Si(b(s),Wn({size:1,divisions:10})),material:new Oi(b(s),{diffuse:[0,0,0],ambient:[0,0,0],emissive:[.2,.8,.2]}),position:[0,.001,0],clippable:r.clippable}),s._node=new yn(b(s),{rotation:[0,0,0],position:[0,0,0],scale:[1,1,1],clippable:!1,children:[s._plane,s._grid]}),s._gridVisible=!1,s.visible=!0,s.gridVisible=r.gridVisible,s.position=r.position,s.rotation=r.rotation,s.dir=r.dir,s.size=r.size,s.collidable=r.collidable,s.clippable=r.clippable,s.pickable=r.pickable,s.opacity=r.opacity,r.image?s.image=r.image:s.src=r.src,s}return C(i,[{key:"visible",get:function(){return this._plane.visible},set:function(e){this._plane.visible=e,this._grid.visible=this._gridVisible&&e}},{key:"gridVisible",get:function(){return this._gridVisible},set:function(e){e=!1!==e,this._gridVisible=e,this._grid.visible=this._gridVisible&&this.visible}},{key:"image",get:function(){return this._image},set:function(e){this._image=e,this._image&&(this._imageSize[0]=e.width,this._imageSize[1]=e.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}},{key:"src",get:function(){return this._src},set:function(e){var t=this;if(this._src=e,this._src){this._image=null;var i=new Image;i.onload=function(){t._texture.image=i,t._imageSize[0]=i.width,t._imageSize[1]=i.height,t._updatePlaneSizeFromImage()},i.src=this._src}}},{key:"position",get:function(){return this._pos},set:function(e){this._pos.set(e||[0,0,0]),Le(this._pos,this._origin,this._rtcPos),this._node.origin=this._origin,this._node.position=this._rtcPos}},{key:"rotation",get:function(){return this._node.rotation},set:function(e){this._node.rotation=e}},{key:"size",get:function(){return this._size},set:function(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}},{key:"dir",get:function(){return this._dir},set:function(e){if(this._dir.set(e||[0,0,-1]),e){var t=this.scene.center,i=[-this._dir[0],-this._dir[1],-this._dir[2]];$.subVec3(t,this.position,Wh);var s=-$.dotVec3(i,Wh);$.normalizeVec3(i),$.mulVec3Scalar(i,s,Kh),$.vec3PairToQuaternion(Xh,e,Jh),this._node.quaternion=Jh}}},{key:"collidable",get:function(){return this._node.collidable},set:function(e){this._node.collidable=!1!==e}},{key:"clippable",get:function(){return this._node.clippable},set:function(e){this._node.clippable=!1!==e}},{key:"pickable",get:function(){return this._node.pickable},set:function(e){this._node.pickable=!1!==e}},{key:"opacity",get:function(){return this._node.opacity},set:function(e){this._node.opacity=e}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this)}},{key:"_updatePlaneSizeFromImage",value:function(){var e=this._size,t=this._imageSize[0],i=this._imageSize[1];if(t>i){var s=i/t;this._node.scale=[e,1,e*s]}else{var r=t/i;this._node.scale=[e*r,1,e]}}}]),i}(),Zh=function(e){g(i,_i);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i);var n=b(s=t.call(this,e,r));s._shadowRenderBuf=null,s._shadowViewMatrix=null,s._shadowProjMatrix=null,s._shadowViewMatrixDirty=!0,s._shadowProjMatrixDirty=!0;var o=s.scene.camera,a=s.scene.canvas;return s._onCameraViewMatrix=o.on("viewMatrix",(function(){s._shadowViewMatrixDirty=!0})),s._onCameraProjMatrix=o.on("projMatrix",(function(){s._shadowProjMatrixDirty=!0})),s._onCanvasBoundary=a.on("boundary",(function(){s._shadowProjMatrixDirty=!0})),s._state=new Zt({type:"point",pos:$.vec3([1,1,1]),color:$.vec3([.7,.7,.8]),intensity:1,attenuation:[0,0,0],space:r.space||"view",castsShadow:!1,getShadowViewMatrix:function(){if(n._shadowViewMatrixDirty){n._shadowViewMatrix||(n._shadowViewMatrix=$.identityMat4());var e=n._state.pos,t=o.look,i=o.up;$.lookAtMat4v(e,t,i,n._shadowViewMatrix),n._shadowViewMatrixDirty=!1}return n._shadowViewMatrix},getShadowProjMatrix:function(){if(n._shadowProjMatrixDirty){n._shadowProjMatrix||(n._shadowProjMatrix=$.identityMat4());var e=n.scene.canvas.canvas;$.perspectiveMat4(Math.PI/180*70,e.clientWidth/e.clientHeight,.1,500,n._shadowProjMatrix),n._shadowProjMatrixDirty=!1}return n._shadowProjMatrix},getShadowRenderBuf:function(){return n._shadowRenderBuf||(n._shadowRenderBuf=new zt(n.scene.canvas.canvas,n.scene.canvas.gl,{size:[1024,1024]})),n._shadowRenderBuf}}),s.pos=r.pos,s.color=r.color,s.intensity=r.intensity,s.constantAttenuation=r.constantAttenuation,s.linearAttenuation=r.linearAttenuation,s.quadraticAttenuation=r.quadraticAttenuation,s.castsShadow=r.castsShadow,s.scene._lightCreated(b(s)),s}return C(i,[{key:"type",get:function(){return"PointLight"}},{key:"pos",get:function(){return this._state.pos},set:function(e){this._state.pos.set(e||[1,1,1]),this._shadowViewMatrixDirty=!0,this.glRedraw()}},{key:"color",get:function(){return this._state.color},set:function(e){this._state.color.set(e||[.7,.7,.8]),this.glRedraw()}},{key:"intensity",get:function(){return this._state.intensity},set:function(e){e=void 0!==e?e:1,this._state.intensity=e,this.glRedraw()}},{key:"constantAttenuation",get:function(){return this._state.attenuation[0]},set:function(e){this._state.attenuation[0]=e||0,this.glRedraw()}},{key:"linearAttenuation",get:function(){return this._state.attenuation[1]},set:function(e){this._state.attenuation[1]=e||0,this.glRedraw()}},{key:"quadraticAttenuation",get:function(){return this._state.attenuation[2]},set:function(e){this._state.attenuation[2]=e||0,this.glRedraw()}},{key:"castsShadow",get:function(){return this._state.castsShadow},set:function(e){e=!!e,this._state.castsShadow!==e&&(this._state.castsShadow=e,this._shadowViewMatrixDirty=!0,this.glRedraw())}},{key:"destroy",value:function(){var e=this.scene.camera,t=this.scene.canvas;e.off(this._onCameraViewMatrix),e.off(this._onCameraProjMatrix),t.off(this._onCanvasBoundary),f(B(i.prototype),"destroy",this).call(this),this._state.destroy(),this._shadowRenderBuf&&this._shadowRenderBuf.destroy(),this.scene._lightDestroyed(this),this.glRedraw()}}]),i}();function qh(e){return 0==(e&e-1)}function $h(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1}var ed=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i);var n=(s=t.call(this,e,r)).scene.canvas.gl;return s._state=new Zt({texture:new kn({gl:n,target:n.TEXTURE_CUBE_MAP}),flipY:s._checkFlipY(r.minFilter),encoding:s._checkEncoding(r.encoding),minFilter:1008,magFilter:1006,wrapS:1001,wrapT:1001,mipmaps:!0}),s._src=r.src,s._images=[],s._loadSrc(r.src),se.memory.textures++,s}return C(i,[{key:"type",get:function(){return"CubeTexture"}},{key:"_checkFlipY",value:function(e){return!!e}},{key:"_checkEncoding",value:function(e){return 3e3!==(e=e||3e3)&&3001!==e&&(this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding."),e=3e3),e}},{key:"_webglContextRestored",value:function(){this.scene.canvas.gl,this._state.texture=null,this._src&&this._loadSrc(this._src)}},{key:"_loadSrc",value:function(e){var t=this,i=this.scene.canvas.gl;this._images=[];for(var s=!1,r=0,n=function(n){var o,a,l=new Image;l.onload=(o=l,a=n,function(){if(!s&&(o=function(e){if(!qh(e.width)||!qh(e.height)){var t=document.createElement("canvas");t.width=$h(e.width),t.height=$h(e.height),t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height),e=t}return e}(o),t._images[a]=o,6==++r)){var e=t._state.texture;e||(e=new kn({gl:i,target:i.TEXTURE_CUBE_MAP}),t._state.texture=e),e.setImage(t._images,t._state),t.fire("loaded",t._src,!1),t.glRedraw()}}),l.onerror=function(){s=!0},l.src=e[n]},o=0;o1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).scene._lightsState.addReflectionMap(s._state),s.scene._reflectionMapCreated(b(s)),s}return C(i,[{key:"type",get:function(){return"ReflectionMap"}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this),this.scene._reflectionMapDestroyed(this)}}]),i}(),id=function(e){g(i,ed);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).scene._lightMapCreated(b(s)),s}return C(i,[{key:"type",get:function(){return"LightMap"}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this),this.scene._lightMapDestroyed(this)}}]),i}(),sd=function(e){g(i,et);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,{entity:r.entity,occludable:r.occludable,worldPos:r.worldPos}))._occluded=!1,s._visible=!0,s._src=null,s._image=null,s._pos=$.vec3(),s._origin=$.vec3(),s._rtcPos=$.vec3(),s._dir=$.vec3(),s._size=1,s._imageSize=$.vec2(),s._texture=new Ln(b(s),{src:r.src}),s._geometry=new Si(b(s),{primitive:"triangles",positions:[3,3,0,-3,3,0,-3,-3,0,3,-3,0],normals:[-1,0,0,-1,0,0,-1,0,0,-1,0,0],uv:[1,-1,0,-1,0,0,1,0],indices:[0,1,2,0,2,3]}),s._mesh=new sn(b(s),{geometry:s._geometry,material:new Oi(b(s),{ambient:[.9,.3,.9],shininess:30,diffuseMap:s._texture,backfaces:!0}),scale:[1,1,1],position:r.worldPos,rotation:[90,0,0],billboard:"spherical",occluder:!1}),s.visible=!0,s.collidable=r.collidable,s.clippable=r.clippable,s.pickable=r.pickable,s.opacity=r.opacity,s.size=r.size,r.image?s.image=r.image:s.src=r.src,s}return C(i,[{key:"_setVisible",value:function(e){this._occluded=!e,this._mesh.visible=this._visible&&!this._occluded,f(B(i.prototype),"_setVisible",this).call(this,e)}},{key:"visible",get:function(){return this._visible},set:function(e){this._visible=null==e||e,this._mesh.visible=this._visible&&!this._occluded}},{key:"image",get:function(){return this._image},set:function(e){this._image=e,this._image&&(this._imageSize[0]=this._image.width,this._imageSize[1]=this._image.height,this._updatePlaneSizeFromImage(),this._src=null,this._texture.image=this._image)}},{key:"src",get:function(){return this._src},set:function(e){var t=this;if(this._src=e,this._src){this._image=null;var i=new Image;i.onload=function(){t._texture.image=i,t._imageSize[0]=i.width,t._imageSize[1]=i.height,t._updatePlaneSizeFromImage()},i.src=this._src}}},{key:"size",get:function(){return this._size},set:function(e){this._size=null==e?1:e,this._image&&this._updatePlaneSizeFromImage()}},{key:"collidable",get:function(){return this._mesh.collidable},set:function(e){this._mesh.collidable=!1!==e}},{key:"clippable",get:function(){return this._mesh.clippable},set:function(e){this._mesh.clippable=!1!==e}},{key:"pickable",get:function(){return this._mesh.pickable},set:function(e){this._mesh.pickable=!1!==e}},{key:"opacity",get:function(){return this._mesh.opacity},set:function(e){this._mesh.opacity=e}},{key:"_updatePlaneSizeFromImage",value:function(){var e=.5*this._size,t=this._imageSize[0],i=this._imageSize[1],s=i/t;this._geometry.positions=t>i?[e,e*s,0,-e,e*s,0,-e,-e*s,0,e,-e*s,0]:[e/s,e,0,-e/s,e,0,-e/s,-e,0,e/s,-e,0]}}]),i}(),rd=function(){function e(t){x(this,e),this._eye=$.vec3(),this._look=$.vec3(),this._up=$.vec3(),this._projection={},t&&this.saveCamera(t)}return C(e,[{key:"saveCamera",value:function(e){var t=e.camera,i=t.project;switch(this._eye.set(t.eye),this._look.set(t.look),this._up.set(t.up),t.projection){case"perspective":this._projection={projection:"perspective",fov:i.fov,fovAxis:i.fovAxis,near:i.near,far:i.far};break;case"ortho":this._projection={projection:"ortho",scale:i.scale,near:i.near,far:i.far};break;case"frustum":this._projection={projection:"frustum",left:i.left,right:i.right,top:i.top,bottom:i.bottom,near:i.near,far:i.far};break;case"custom":this._projection={projection:"custom",matrix:i.matrix.slice()}}}},{key:"restoreCamera",value:function(e,t){var i=e.camera,s=this._projection;function r(){switch(s.type){case"perspective":i.perspective.fov=s.fov,i.perspective.fovAxis=s.fovAxis,i.perspective.near=s.near,i.perspective.far=s.far;break;case"ortho":i.ortho.scale=s.scale,i.ortho.near=s.near,i.ortho.far=s.far;break;case"frustum":i.frustum.left=s.left,i.frustum.right=s.right,i.frustum.top=s.top,i.frustum.bottom=s.bottom,i.frustum.near=s.near,i.frustum.far=s.far;break;case"custom":i.customProjection.matrix=s.matrix}}t?e.viewer.cameraFlight.flyTo({eye:this._eye,look:this._look,up:this._up,orthoScale:s.scale,projection:s.projection},(function(){r(),t()})):(i.eye=this._eye,i.look=this._look,i.up=this._up,r(),i.projection=s.projection)}}]),e}(),nd=$.vec3(),od=function(){function e(t){if(x(this,e),this.objectsVisible=[],this.objectsEdges=[],this.objectsXrayed=[],this.objectsHighlighted=[],this.objectsSelected=[],this.objectsClippable=[],this.objectsPickable=[],this.objectsColorize=[],this.objectsOpacity=[],this.numObjects=0,t){var i=t.metaScene.scene;this.saveObjects(i,t)}}return C(e,[{key:"saveObjects",value:function(e,t,i){this.numObjects=0,this._mask=i?le.apply(i,{}):null;for(var s=!i||i.visible,r=!i||i.edges,n=!i||i.xrayed,o=!i||i.highlighted,a=!i||i.selected,l=!i||i.clippable,u=!i||i.pickable,A=!i||i.colorize,c=!i||i.opacity,h=t.metaObjects,d=e.objects,p=0,f=h.length;p1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).v0=r.v0,s.v1=r.v1,s.v2=r.v2,s.v3=r.v3,s.t=r.t,s}return C(i,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||$.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||$.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||$.vec3([0,0,0])}},{key:"v3",get:function(){return this._v3},set:function(e){this.fire("v3",this._v3=e||$.vec3([0,0,0]))}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var t=$.vec3();return t[0]=$.b3(e,this._v0[0],this._v1[0],this._v2[0],this._v3[0]),t[1]=$.b3(e,this._v0[1],this._v1[1],this._v2[1],this._v3[1]),t[2]=$.b3(e,this._v0[2],this._v1[2],this._v2[2],this._v3[2]),t}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,v3:this._v3,t:this._t}}}]),i}(),Ad=function(e){g(i,Rh);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._cachedLengths=[],s._dirty=!0,s._curves=[],s._t=0,s._dirtySubs=[],s._destroyedSubs=[],s.curves=r.curves||[],s.t=r.t,s}return C(i,[{key:"addCurve",value:function(e){this._curves.push(e),this._dirty=!0}},{key:"curves",get:function(){return this._curves},set:function(e){var t,i,s;for(e=e||[],i=0,s=this._curves.length;i1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"length",get:function(){var e=this._getCurveLengths();return e[e.length-1]}},{key:"getPoint",value:function(e){for(var t,i=e*this.length,s=this._getCurveLengths(),r=0;r=i){var n=1-(s[r]-i)/(t=this._curves[r]).length;return t.getPointAt(n)}r++}return null}},{key:"_getCurveLengths",value:function(){if(!this._dirty)return this._cachedLengths;var e,t=[],i=0,s=this._curves.length;for(e=0;e1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r)).v0=r.v0,s.v1=r.v1,s.v2=r.v2,s.t=r.t,s}return C(i,[{key:"v0",get:function(){return this._v0},set:function(e){this._v0=e||$.vec3([0,0,0])}},{key:"v1",get:function(){return this._v1},set:function(e){this._v1=e||$.vec3([0,0,0])}},{key:"v2",get:function(){return this._v2},set:function(e){this._v2=e||$.vec3([0,0,0])}},{key:"t",get:function(){return this._t},set:function(e){e=e||0,this._t=e<0?0:e>1?1:e}},{key:"point",get:function(){return this.getPoint(this._t)}},{key:"getPoint",value:function(e){var t=$.vec3();return t[0]=$.b2(e,this._v0[0],this._v1[0],this._v2[0]),t[1]=$.b2(e,this._v0[1],this._v1[1],this._v2[1]),t[2]=$.b2(e,this._v0[2],this._v1[2],this._v2[2]),t}},{key:"getJSON",value:function(){return{v0:this._v0,v1:this._v1,v2:this._v2,t:this._t}}}]),i}(),hd=function(e){g(i,Ah);var t=_(i);function i(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),t.call(this,e,s)}return C(i)}(),dd=function(e){g(i,Be);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,e,r))._skyboxMesh=new sn(b(s),{geometry:new Si(b(s),{primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:!0,scale:[2e3,2e3,2e3],rotation:[0,-90,0],material:new Oi(b(s),{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Ln(b(s),{src:r.src,flipY:!0,wrapS:"clampToEdge",wrapT:"clampToEdge",encoding:r.encoding||"sRGB"}),backfaces:!0}),visible:!1,pickable:!1,clippable:!1,collidable:!1}),s.size=r.size,s.active=r.active,s}return C(i,[{key:"size",get:function(){return this._size},set:function(e){this._size=e||1e3,this._skyboxMesh.scale=[this._size,this._size,this._size]}},{key:"active",get:function(){return this._skyboxMesh.visible},set:function(e){this._skyboxMesh.visible=e}}]),i}(),pd=function(){function e(){x(this,e)}return C(e,[{key:"transcode",value:function(e,t){}},{key:"destroy",value:function(){}}]),e}(),fd=$.vec4(),vd=$.vec4(),gd=$.vec3(),md=$.vec3(),_d=$.vec3(),yd=$.vec4(),bd=$.vec4(),Bd=$.vec4(),wd=function(){function e(t){x(this,e),this._scene=t}return C(e,[{key:"dollyToCanvasPos",value:function(e,t,i){var s=!1,r=this._scene.camera;if(e){var n=$.subVec3(e,r.eye,gd);s=$.lenVec3(n)0&&void 0!==arguments[0]?arguments[0]:{};this.destroyPivotSphere(),this._pivotSphereEnabled=!0,e.size&&(this._pivotSphereSize=e.size);var t=e.color||[1,0,0];this._pivotSphereMaterial=new Oi(this._scene,{emissive:t,ambient:t,specular:[0,0,0],diffuse:[0,0,0]})}},{key:"disablePivotSphere",value:function(){this.destroyPivotSphere(),this._pivotSphereEnabled=!1}},{key:"startPivot",value:function(){if(this._cameraLookingDownwards())return this._pivoting=!1,!1;var e=this._scene.camera,t=$.lookAtMat4v(e.eye,e.look,e.worldUp);$.transformPoint3(t,this.getPivotPos(),this._cameraOffset);var i=this.getPivotPos();this._cameraOffset[2]+=$.distVec3(e.eye,i),t=$.inverseMat4(t);var s=$.transformVec3(t,this._cameraOffset),r=$.vec3();if($.subVec3(e.eye,i,r),$.addVec3(r,s),e.zUp){var n=r[1];r[1]=r[2],r[2]=n}this._radius=$.lenVec3(r),this._polar=Math.acos(r[1]/this._radius),this._azimuth=Math.atan2(r[0],r[2]),this._pivoting=!0}},{key:"_cameraLookingDownwards",value:function(){var e=this._scene.camera,t=$.normalizeVec3($.subVec3(e.look,e.eye,xd)),i=$.cross3Vec3(t,e.worldUp,Pd);return $.sqLenVec3(i)<=1e-4}},{key:"getPivoting",value:function(){return this._pivoting}},{key:"setPivotPos",value:function(e){this._pivotWorldPos.set(e),this._pivotPosSet=!0}},{key:"setCanvasPivotPos",value:function(e){var t=this._scene.camera,i=Math.abs($.distVec3(this._scene.center,t.eye)),s=t.project.transposedMatrix,r=s.subarray(8,12),n=s.subarray(12),o=[0,0,-1,1],a=$.dotVec4(o,r)/$.dotVec4(o,n),l=Md;t.project.unproject(e,a,Fd,Ed,l);var u=$.normalizeVec3($.subVec3(l,t.eye,xd)),A=$.addVec3(t.eye,$.mulVec3Scalar(u,i,Pd),Cd);this.setPivotPos(A)}},{key:"getPivotPos",value:function(){return this._pivotPosSet?this._pivotWorldPos:this._scene.camera.look}},{key:"continuePivot",value:function(e,t){if(this._pivoting&&(0!==e||0!==t)){var i=this._scene.camera,s=-e,r=-t;1===i.worldUp[2]&&(s=-s),this._azimuth+=.01*-s,this._polar+=.01*r,this._polar=$.clamp(this._polar,.001,Math.PI-.001);var n=[this._radius*Math.sin(this._polar)*Math.sin(this._azimuth),this._radius*Math.cos(this._polar),this._radius*Math.sin(this._polar)*Math.cos(this._azimuth)];if(1===i.worldUp[2]){var o=n[1];n[1]=n[2],n[2]=o}var a=$.lenVec3($.subVec3(i.look,i.eye,$.vec3())),l=this.getPivotPos();$.addVec3(n,l);var u=$.lookAtMat4v(n,l,i.worldUp);u=$.inverseMat4(u);var A=$.transformVec3(u,this._cameraOffset);u[12]-=A[0],u[13]-=A[1],u[14]-=A[2];var c=[u[8],u[9],u[10]];i.eye=[u[12],u[13],u[14]],$.subVec3(i.eye,$.mulVec3Scalar(c,a),i.look),i.up=[u[4],u[5],u[6]],this.showPivot()}}},{key:"showPivot",value:function(){this._shown||(this._pivotElement&&(this.updatePivotElement(),this._pivotElement.style.visibility="visible"),this._pivotSphereEnabled&&(this.destroyPivotSphere(),this.createPivotSphere()),this._shown=!0)}},{key:"hidePivot",value:function(){this._shown&&(this._pivotElement&&(this._pivotElement.style.visibility="hidden"),this._pivotSphereEnabled&&this.destroyPivotSphere(),this._shown=!1)}},{key:"endPivot",value:function(){this._pivoting=!1}},{key:"destroy",value:function(){this.destroyPivotSphere(),this._scene.camera.off(this._onViewMatrix),this._scene.camera.off(this._onProjMatrix),this._scene.off(this._onTick)}}]),e}(),Id=function(){function e(t,i){x(this,e),this._scene=t.scene,this._cameraControl=t,this._scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},this._configs=i,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick=!1,this.pickCursorPos=$.vec2(),this.picked=!1,this.pickedSurface=!1,this.pickResult=null,this._lastPickedEntityId=null,this._lastHash=null,this._needFireEvents=0}return C(e,[{key:"update",value:function(){if(this._configs.pointerEnabled&&(this.schedulePickEntity||this.schedulePickSurface)){var e="".concat(~~this.pickCursorPos[0],"-").concat(~~this.pickCursorPos[1],"-").concat(this.scheduleSnapOrPick,"-").concat(this.schedulePickSurface,"-").concat(this.schedulePickEntity);if(this._lastHash!==e){this.picked=!1,this.pickedSurface=!1,this.snappedOrPicked=!1,this.hoveredSnappedOrSurfaceOff=!1;var t=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){var i=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});i&&(i.snappedToEdge||i.snappedToVertex)?(this.snapPickResult=i,this.snappedOrPicked=!0,this._needFireEvents++):(this.schedulePickSurface=!0,this.snapPickResult=null)}if(this.schedulePickSurface&&this.pickResult&&this.pickResult.worldPos){var s=this.pickResult.canvasPos;if(s[0]===this.pickCursorPos[0]&&s[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!0,this._needFireEvents+=t?1:0,this.schedulePickEntity=!1,this.schedulePickSurface=!1,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.hoveredSnappedOrSurfaceOff=!0,void(this.scheduleSnapOrPick=!1)}if(this.schedulePickEntity&&this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){var r=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(r[0]===this.pickCursorPos[0]&&r[1]===this.pickCursorPos[1])return this.picked=!0,this.pickedSurface=!1,this.schedulePickEntity=!1,void(this.schedulePickSurface=!1)}this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult?(this.pickResult=this._scene.pick({pickSurface:!0,pickSurfaceNormal:!1,canvasPos:this.pickCursorPos}),this.pickResult?(this.picked=!0,this.scheduleSnapOrPick?this.snappedOrPicked=!0:this.pickedSurface=!0,this._needFireEvents++):this.scheduleSnapOrPick&&(this.hoveredSnappedOrSurfaceOff=!0,this._needFireEvents++)):(this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos}),this.pickResult&&(this.picked=!0,this.pickedSurface=!1,this._needFireEvents++)),this.scheduleSnapOrPick=!1,this.schedulePickEntity=!1,this.schedulePickSurface=!1}}}},{key:"fireEvents",value:function(){if(0!==this._needFireEvents){if(this.hoveredSnappedOrSurfaceOff&&this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},!0),this.snappedOrPicked)if(this.snapPickResult){var e=new wt;e.entity=this.snapPickResult.entity,e.snappedToVertex=this.snapPickResult.snappedToVertex,e.snappedToEdge=this.snapPickResult.snappedToEdge,e.worldPos=this.snapPickResult.worldPos,e.canvasPos=this.pickCursorPos,e.snappedCanvasPos=this.snapPickResult.snappedCanvasPos,this._cameraControl.fire("hoverSnapOrSurface",e,!0),this.snapPickResult=null}else this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,!0);if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){var t=this.pickResult.entity.id;this._lastPickedEntityId!==t&&(void 0!==this._lastPickedEntityId&&this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._cameraControl.fire("hoverEnter",this.pickResult,!0),this._lastPickedEntityId=t)}this._cameraControl.fire("hover",this.pickResult,!0),this.pickResult.worldPos&&(this.pickedSurface=!0,this._cameraControl.fire("hoverSurface",this.pickResult,!0))}else void 0!==this._lastPickedEntityId&&(this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},!0),this._lastPickedEntityId=void 0),this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},!0);this.pickResult=null,this._needFireEvents=0}}}]),e}(),Dd=$.vec2(),Sd=function(){function e(t,i,s,r,n){x(this,e),this._scene=t;var o,a,l,u=i.pickController,A=0,c=0,h=0,d=0,p=!1,f=$.vec3(),v=!0,g=this._scene.canvas.canvas,m=[];function _(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];g.style.cursor="move",y(),e&&b()}function y(){A=r.pointerCanvasPos[0],c=r.pointerCanvasPos[1],h=r.pointerCanvasPos[0],d=r.pointerCanvasPos[1]}function b(){u.pickCursorPos=r.pointerCanvasPos,u.schedulePickSurface=!0,u.update(),u.picked&&u.pickedSurface&&u.pickResult&&u.pickResult.worldPos?(p=!0,f.set(u.pickResult.worldPos)):p=!1}document.addEventListener("keydown",this._documentKeyDownHandler=function(e){if(s.active&&s.pointerEnabled&&t.input.keyboardEnabled){var i=e.keyCode;m[i]=!0}}),document.addEventListener("keyup",this._documentKeyUpHandler=function(e){if(s.active&&s.pointerEnabled&&t.input.keyboardEnabled){var i=e.keyCode;m[i]=!1}}),g.addEventListener("mousedown",this._mouseDownHandler=function(e){if(s.active&&s.pointerEnabled)switch(e.which){case 1:m[t.input.KEY_SHIFT]||s.planView?(o=!0,_()):(o=!0,_(!1));break;case 2:a=!0,_();break;case 3:l=!0,s.panRightClick&&_()}}),document.addEventListener("mousemove",this._documentMouseMoveHandler=function(e){if(s.active&&s.pointerEnabled&&(o||a||l)){var i=t.canvas.boundary,u=i[2],h=i[3],d=r.pointerCanvasPos[0],v=r.pointerCanvasPos[1],g=m[t.input.KEY_SHIFT]||s.planView||!s.panRightClick&&a||s.panRightClick&&l,_=document.pointerLockElement?e.movementX:d-A,y=document.pointerLockElement?e.movementY:v-c;if(g){var b=t.camera;if("perspective"===b.projection){var B=Math.abs(p?$.lenVec3($.subVec3(f,t.camera.eye,[])):t.camera.eyeLookDist)*Math.tan(b.perspective.fov/2*Math.PI/180);n.panDeltaX+=1.5*_*B/h,n.panDeltaY+=1.5*y*B/h}else n.panDeltaX+=.5*b.ortho.scale*(_/h),n.panDeltaY+=.5*b.ortho.scale*(y/h)}else!o||a||l||s.planView||(s.firstPerson?(n.rotateDeltaY-=_/u*s.dragRotationRate/2,n.rotateDeltaX+=y/h*(s.dragRotationRate/4)):(n.rotateDeltaY-=_/u*(1.5*s.dragRotationRate),n.rotateDeltaX+=y/h*(1.5*s.dragRotationRate)));A=d,c=v}}),g.addEventListener("mousemove",this._canvasMouseMoveHandler=function(e){s.active&&s.pointerEnabled&&r.mouseover&&(v=!0)}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){if(s.active&&s.pointerEnabled)switch(e.which){case 1:case 2:case 3:o=!1,a=!1,l=!1}}),g.addEventListener("mouseup",this._mouseUpHandler=function(e){if(s.active&&s.pointerEnabled){if(3===e.which){!function(e,t){if(e){for(var i=e.target,s=0,r=0,n=0,o=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,n+=i.scrollLeft,o+=i.scrollTop,i=i.offsetParent;t[0]=e.pageX+n-s,t[1]=e.pageY+o-r}else e=window.event,t[0]=e.x,t[1]=e.y}(e,Dd);var t=Dd[0],r=Dd[1];Math.abs(t-h)<3&&Math.abs(r-d)<3&&i.cameraControl.fire("rightClick",{pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:Dd,event:e},!0)}g.style.removeProperty("cursor")}}),g.addEventListener("mouseenter",this._mouseEnterHandler=function(){s.active&&s.pointerEnabled});var B=1/60,w=null;g.addEventListener("wheel",this._mouseWheelHandler=function(e){if(s.active&&s.pointerEnabled){var t=performance.now()/1e3,i=null!==w?t-w:0;w=t,i>.05&&(i=.05),i0?i.cameraFlight.flyTo(Nd,(function(){i.pivotController.getPivoting()&&s.followPointer&&i.pivotController.showPivot()})):(i.cameraFlight.jumpTo(Nd),i.pivotController.getPivoting()&&s.followPointer&&i.pivotController.showPivot())}}}))}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.input.off(this._onSceneKeyDown)}}]),e}(),Vd=function(){function e(t,i,s,r,n){var o=this;x(this,e),this._scene=t;var a=i.pickController,l=i.pivotController,u=i.cameraControl;this._clicks=0,this._timeout=null,this._lastPickedEntityId=null;var A=!1,c=!1,h=this._scene.canvas.canvas,d=function(e){var s;e&&e.worldPos&&(s=e.worldPos);var r=e&&e.entity?e.entity.aabb:t.aabb;if(s){var n=t.camera;$.subVec3(n.eye,n.look,[]),i.cameraFlight.flyTo({aabb:r})}else i.cameraFlight.flyTo({aabb:r})},p=t.tickify(this._canvasMouseMoveHandler=function(e){if(s.active&&s.pointerEnabled&&!A&&!c){var i=u.hasSubs("hover"),n=u.hasSubs("hoverEnter"),l=u.hasSubs("hoverOut"),h=u.hasSubs("hoverOff"),d=u.hasSubs("hoverSurface"),p=u.hasSubs("hoverSnapOrSurface");if(i||n||l||h||d||p)if(a.pickCursorPos=r.pointerCanvasPos,a.schedulePickEntity=!0,a.schedulePickSurface=d,a.scheduleSnapOrPick=p,a.update(),a.pickResult){if(a.pickResult.entity){var f=a.pickResult.entity.id;o._lastPickedEntityId!==f&&(void 0!==o._lastPickedEntityId&&u.fire("hoverOut",{entity:t.objects[o._lastPickedEntityId]},!0),u.fire("hoverEnter",a.pickResult,!0),o._lastPickedEntityId=f)}u.fire("hover",a.pickResult,!0),(a.pickResult.worldPos||a.pickResult.snappedWorldPos)&&u.fire("hoverSurface",a.pickResult,!0)}else void 0!==o._lastPickedEntityId&&(u.fire("hoverOut",{entity:t.objects[o._lastPickedEntityId]},!0),o._lastPickedEntityId=void 0),u.fire("hoverOff",{canvasPos:a.pickCursorPos},!0)}});h.addEventListener("mousemove",p),h.addEventListener("mousedown",this._canvasMouseDownHandler=function(e){if(1===e.which&&(A=!0),3===e.which&&(c=!0),1===e.which&&s.active&&s.pointerEnabled&&(r.mouseDownClientX=e.clientX,r.mouseDownClientY=e.clientY,r.mouseDownCursorX=r.pointerCanvasPos[0],r.mouseDownCursorY=r.pointerCanvasPos[1],!s.firstPerson&&s.followPointer&&(a.pickCursorPos=r.pointerCanvasPos,a.schedulePickSurface=!0,a.update(),1===e.which))){var i=a.pickResult;i&&i.worldPos?(l.setPivotPos(i.worldPos),l.startPivot()):(s.smartPivot?l.setCanvasPivotPos(r.pointerCanvasPos):l.setPivotPos(t.camera.look),l.startPivot())}}),document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){1===e.which&&(A=!1),3===e.which&&(c=!1),l.getPivoting()&&l.endPivot()}),h.addEventListener("mouseup",this._canvasMouseUpHandler=function(e){if(s.active&&s.pointerEnabled&&(1===e.which&&(l.hidePivot(),!(Math.abs(e.clientX-r.mouseDownClientX)>3||Math.abs(e.clientY-r.mouseDownClientY)>3)))){var n=u.hasSubs("picked"),A=u.hasSubs("pickedNothing"),c=u.hasSubs("pickedSurface"),h=u.hasSubs("doublePicked"),p=u.hasSubs("doublePickedSurface"),f=u.hasSubs("doublePickedNothing");if(!(s.doublePickFlyTo||h||p||f))return(n||A||c)&&(a.pickCursorPos=r.pointerCanvasPos,a.schedulePickEntity=!0,a.schedulePickSurface=c,a.update(),a.pickResult?(u.fire("picked",a.pickResult,!0),a.pickedSurface&&u.fire("pickedSurface",a.pickResult,!0)):u.fire("pickedNothing",{canvasPos:r.pointerCanvasPos},!0)),void(o._clicks=0);if(o._clicks++,1===o._clicks){a.pickCursorPos=r.pointerCanvasPos,a.schedulePickEntity=s.doublePickFlyTo,a.schedulePickSurface=c,a.update();var v=a.pickResult,g=a.pickedSurface;o._timeout=setTimeout((function(){v?(u.fire("picked",v,!0),g&&(u.fire("pickedSurface",v,!0),!s.firstPerson&&s.followPointer&&(i.pivotController.setPivotPos(v.worldPos),i.pivotController.startPivot()&&i.pivotController.showPivot()))):u.fire("pickedNothing",{canvasPos:r.pointerCanvasPos},!0),o._clicks=0}),s.doubleClickTimeFrame)}else{if(null!==o._timeout&&(window.clearTimeout(o._timeout),o._timeout=null),a.pickCursorPos=r.pointerCanvasPos,a.schedulePickEntity=s.doublePickFlyTo||h||p,a.schedulePickSurface=a.schedulePickEntity&&p,a.update(),a.pickResult){if(u.fire("doublePicked",a.pickResult,!0),a.pickedSurface&&u.fire("doublePickedSurface",a.pickResult,!0),s.doublePickFlyTo&&(d(a.pickResult),!s.firstPerson&&s.followPointer)){var m=a.pickResult.entity.aabb,_=$.getAABB3Center(m);i.pivotController.setPivotPos(_),i.pivotController.startPivot()&&i.pivotController.showPivot()}}else if(u.fire("doublePickedNothing",{canvasPos:r.pointerCanvasPos},!0),s.doublePickFlyTo&&(d(),!s.firstPerson&&s.followPointer)){var y=t.aabb,b=$.getAABB3Center(y);i.pivotController.setPivotPos(b),i.pivotController.startPivot()&&i.pivotController.showPivot()}o._clicks=0}}},!1)}return C(e,[{key:"reset",value:function(){this._clicks=0,this._lastPickedEntityId=null,this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}},{key:"destroy",value:function(){var e=this._scene.canvas.canvas;e.removeEventListener("mousemove",this._canvasMouseMoveHandler),e.removeEventListener("mousedown",this._canvasMouseDownHandler),document.removeEventListener("mouseup",this._documentMouseUpHandler),e.removeEventListener("mouseup",this._canvasMouseUpHandler),this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null)}}]),e}(),Hd=function(){function e(t,i,s,r,n){x(this,e),this._scene=t;var o=t.input,a=[],l=t.canvas.canvas,u=!0;this._onSceneMouseMove=o.on("mousemove",(function(){u=!0})),this._onSceneKeyDown=o.on("keydown",(function(e){s.active&&s.pointerEnabled&&t.input.keyboardEnabled&&r.mouseover&&(a[e]=!0,e===o.KEY_SHIFT&&(l.style.cursor="move"))})),this._onSceneKeyUp=o.on("keyup",(function(e){s.active&&s.pointerEnabled&&t.input.keyboardEnabled&&(a[e]=!1,e===o.KEY_SHIFT&&(l.style.cursor=null),i.pivotController.getPivoting()&&i.pivotController.endPivot())})),this._onTick=t.on("tick",(function(e){if(s.active&&s.pointerEnabled&&t.input.keyboardEnabled&&r.mouseover){var l=i.cameraControl,A=e.deltaTime/1e3;if(!s.planView){var c=l._isKeyDownForAction(l.ROTATE_Y_POS,a),h=l._isKeyDownForAction(l.ROTATE_Y_NEG,a),d=l._isKeyDownForAction(l.ROTATE_X_POS,a),p=l._isKeyDownForAction(l.ROTATE_X_NEG,a),f=A*s.keyboardRotationRate;(c||h||d||p)&&(!s.firstPerson&&s.followPointer&&i.pivotController.startPivot(),c?n.rotateDeltaY+=f:h&&(n.rotateDeltaY-=f),d?n.rotateDeltaX+=f:p&&(n.rotateDeltaX-=f),!s.firstPerson&&s.followPointer&&i.pivotController.startPivot())}if(!a[o.KEY_CTRL]&&!a[o.KEY_ALT]){var v=l._isKeyDownForAction(l.DOLLY_BACKWARDS,a),g=l._isKeyDownForAction(l.DOLLY_FORWARDS,a);if(v||g){var m=A*s.keyboardDollyRate;!s.firstPerson&&s.followPointer&&i.pivotController.startPivot(),g?n.dollyDelta-=m:v&&(n.dollyDelta+=m),u&&(r.followPointerDirty=!0,u=!1)}}var _=l._isKeyDownForAction(l.PAN_FORWARDS,a),y=l._isKeyDownForAction(l.PAN_BACKWARDS,a),b=l._isKeyDownForAction(l.PAN_LEFT,a),B=l._isKeyDownForAction(l.PAN_RIGHT,a),w=l._isKeyDownForAction(l.PAN_UP,a),x=l._isKeyDownForAction(l.PAN_DOWN,a),P=(a[o.KEY_ALT]?.3:1)*A*s.keyboardPanRate;(_||y||b||B||w||x)&&(!s.firstPerson&&s.followPointer&&i.pivotController.startPivot(),x?n.panDeltaY+=P:w&&(n.panDeltaY+=-P),B?n.panDeltaX+=-P:b&&(n.panDeltaX+=P),y?n.panDeltaZ+=P:_&&(n.panDeltaZ+=-P))}}))}return C(e,[{key:"reset",value:function(){}},{key:"destroy",value:function(){this._scene.off(this._onTick),this._scene.input.off(this._onSceneMouseMove),this._scene.input.off(this._onSceneKeyDown),this._scene.input.off(this._onSceneKeyUp)}}]),e}(),jd=$.vec3(),Gd=function(){function e(t,i,s,r,n){x(this,e),this._scene=t;var o=t.camera,a=i.pickController,l=i.pivotController,u=i.panController,A=1,c=1,h=null;this._onTick=t.on("tick",(function(){if(s.active&&s.pointerEnabled){var e="default";if(Math.abs(n.dollyDelta)<.001&&(n.dollyDelta=0),Math.abs(n.rotateDeltaX)<.001&&(n.rotateDeltaX=0),Math.abs(n.rotateDeltaY)<.001&&(n.rotateDeltaY=0),0===n.rotateDeltaX&&0===n.rotateDeltaY||(n.dollyDelta=0),s.followPointer){if(--A<=0&&(A=1,0!==n.dollyDelta)){if(0===n.rotateDeltaY&&0===n.rotateDeltaX&&s.followPointer&&r.followPointerDirty&&(a.pickCursorPos=r.pointerCanvasPos,a.schedulePickSurface=!0,a.update(),a.pickResult&&a.pickResult.worldPos?h=a.pickResult.worldPos:(c=1,h=null),r.followPointerDirty=!1),h){var i=Math.abs($.lenVec3($.subVec3(h,t.camera.eye,jd)));c=i/s.dollyProximityThreshold}cs.longTapRadius||Math.abs(g)>s.longTapRadius)&&(clearTimeout(r.longTouchTimeout),r.longTouchTimeout=null),s.planView){var m=t.camera;if("perspective"===m.projection){var _=Math.abs(t.camera.eyeLookDist)*Math.tan(m.perspective.fov/2*Math.PI/180);n.panDeltaX+=v*_/l*s.touchPanRate,n.panDeltaY+=g*_/l*s.touchPanRate}else n.panDeltaX+=.5*m.ortho.scale*(v/l)*s.touchPanRate,n.panDeltaY+=.5*m.ortho.scale*(g/l)*s.touchPanRate}else n.rotateDeltaY-=v/a*(1*s.dragRotationRate),n.rotateDeltaX+=g/l*(1.5*s.dragRotationRate)}else if(2===p){var y=d[0],b=d[1];Kd(y,u),Kd(b,A);var B=$.geometricMeanVec2(h[0],h[1]),w=$.geometricMeanVec2(u,A),x=$.vec2();$.subVec2(B,w,x);var P=x[0],C=x[1],M=t.camera,F=$.distVec2([y.pageX,y.pageY],[b.pageX,b.pageY]),E=($.distVec2(h[0],h[1])-F)*s.touchDollyRate;if(n.dollyDelta=E,Math.abs(E)<1)if("perspective"===M.projection){var k=o.pickResult?o.pickResult.worldPos:t.center,I=Math.abs($.lenVec3($.subVec3(k,t.camera.eye,[])))*Math.tan(M.perspective.fov/2*Math.PI/180);n.panDeltaX-=P*I/l*s.touchPanRate,n.panDeltaY-=C*I/l*s.touchPanRate}else n.panDeltaX-=.5*M.ortho.scale*(P/l)*s.touchPanRate,n.panDeltaY-=.5*M.ortho.scale*(C/l)*s.touchPanRate;r.pointerCanvasPos=w}for(var D=0;D-1&&t-c<150&&(h>-1&&c-h<325?(Jd(n[0],a.pickCursorPos),a.schedulePickEntity=!0,a.schedulePickSurface=o,a.update(),a.pickResult?(a.pickResult.touchInput=!0,l.fire("doublePicked",a.pickResult),a.pickedSurface&&l.fire("doublePickedSurface",a.pickResult),s.doublePickFlyTo&&p(a.pickResult)):(l.fire("doublePickedNothing"),s.doublePickFlyTo&&p()),h=-1):$.distVec2(u[0],A)<4&&(Jd(n[0],a.pickCursorPos),a.schedulePickEntity=!0,a.schedulePickSurface=o,a.update(),a.pickResult?(a.pickResult.touchInput=!0,l.fire("picked",a.pickResult),a.pickedSurface&&l.fire("pickedSurface",a.pickResult)):l.fire("pickedNothing"),h=t),c=-1),u.length=i.length;for(var d=0,f=i.length;d1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(s=t.call(this,e,r)).PAN_LEFT=0,s.PAN_RIGHT=1,s.PAN_UP=2,s.PAN_DOWN=3,s.PAN_FORWARDS=4,s.PAN_BACKWARDS=5,s.ROTATE_X_POS=6,s.ROTATE_X_NEG=7,s.ROTATE_Y_POS=8,s.ROTATE_Y_NEG=9,s.DOLLY_FORWARDS=10,s.DOLLY_BACKWARDS=11,s.AXIS_VIEW_RIGHT=12,s.AXIS_VIEW_BACK=13,s.AXIS_VIEW_LEFT=14,s.AXIS_VIEW_FRONT=15,s.AXIS_VIEW_TOP=16,s.AXIS_VIEW_BOTTOM=17,s._keyMap={},s.scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault()},s._configs={longTapTimeout:600,longTapRadius:5,active:!0,keyboardLayout:"qwerty",navMode:"orbit",planView:!1,firstPerson:!1,followPointer:!0,doublePickFlyTo:!0,panRightClick:!0,showPivot:!1,pointerEnabled:!0,constrainVertical:!1,smartPivot:!1,doubleClickTimeFrame:250,snapToVertex:true,snapToEdge:true,snapRadius:30,dragRotationRate:360,keyboardRotationRate:90,rotationInertia:0,keyboardPanRate:1,touchPanRate:1,panInertia:.5,keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:.2,dollyInertia:0,dollyProximityThreshold:30,dollyMinSpeed:.04},s._states={pointerCanvasPos:$.vec2(),mouseover:!1,followPointerDirty:!0,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,activeTouches:[],tapStartPos:$.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null},s._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};var n=s.scene;return s._controllers={cameraControl:b(s),pickController:new Id(b(s),s._configs),pivotController:new kd(n,s._configs),panController:new wd(n),cameraFlight:new Gh(b(s),{duration:.5})},s._handlers=[new zd(s.scene,s._controllers,s._configs,s._states,s._updates),new Xd(s.scene,s._controllers,s._configs,s._states,s._updates),new Sd(s.scene,s._controllers,s._configs,s._states,s._updates),new Qd(s.scene,s._controllers,s._configs,s._states,s._updates),new Vd(s.scene,s._controllers,s._configs,s._states,s._updates),new Yd(s.scene,s._controllers,s._configs,s._states,s._updates),new Hd(s.scene,s._controllers,s._configs,s._states,s._updates)],s._cameraUpdater=new Gd(s.scene,s._controllers,s._configs,s._states,s._updates),s.navMode=r.navMode,r.planView&&(s.planView=r.planView),s.constrainVertical=r.constrainVertical,r.keyboardLayout?s.keyboardLayout=r.keyboardLayout:s.keyMap=r.keyMap,s.doublePickFlyTo=r.doublePickFlyTo,s.panRightClick=r.panRightClick,s.active=r.active,s.followPointer=r.followPointer,s.rotationInertia=r.rotationInertia,s.keyboardPanRate=r.keyboardPanRate,s.touchPanRate=r.touchPanRate,s.keyboardRotationRate=r.keyboardRotationRate,s.dragRotationRate=r.dragRotationRate,s.touchDollyRate=r.touchDollyRate,s.dollyInertia=r.dollyInertia,s.dollyProximityThreshold=r.dollyProximityThreshold,s.dollyMinSpeed=r.dollyMinSpeed,s.panInertia=r.panInertia,s.pointerEnabled=!0,s.keyboardDollyRate=r.keyboardDollyRate,s.mouseWheelDollyRate=r.mouseWheelDollyRate,s}return C(i,[{key:"keyMap",get:function(){return this._keyMap},set:function(e){if(e=e||"qwerty",le.isString(e)){var t=this.scene.input,i={};switch(e){default:this.error("Unsupported value for 'keyMap': "+e+" defaulting to 'qwerty'");case"qwerty":i[this.PAN_LEFT]=[t.KEY_A],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_Z],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_W,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_Q,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6];break;case"azerty":i[this.PAN_LEFT]=[t.KEY_Q],i[this.PAN_RIGHT]=[t.KEY_D],i[this.PAN_UP]=[t.KEY_W],i[this.PAN_DOWN]=[t.KEY_X],i[this.PAN_BACKWARDS]=[],i[this.PAN_FORWARDS]=[],i[this.DOLLY_FORWARDS]=[t.KEY_Z,t.KEY_ADD],i[this.DOLLY_BACKWARDS]=[t.KEY_S,t.KEY_SUBTRACT],i[this.ROTATE_X_POS]=[t.KEY_DOWN_ARROW],i[this.ROTATE_X_NEG]=[t.KEY_UP_ARROW],i[this.ROTATE_Y_POS]=[t.KEY_A,t.KEY_LEFT_ARROW],i[this.ROTATE_Y_NEG]=[t.KEY_E,t.KEY_RIGHT_ARROW],i[this.AXIS_VIEW_RIGHT]=[t.KEY_NUM_1],i[this.AXIS_VIEW_BACK]=[t.KEY_NUM_2],i[this.AXIS_VIEW_LEFT]=[t.KEY_NUM_3],i[this.AXIS_VIEW_FRONT]=[t.KEY_NUM_4],i[this.AXIS_VIEW_TOP]=[t.KEY_NUM_5],i[this.AXIS_VIEW_BOTTOM]=[t.KEY_NUM_6]}this._keyMap=i}else{var s=e;this._keyMap=s}}},{key:"_isKeyDownForAction",value:function(e,t){var i=this._keyMap[e];if(!i)return!1;t||(t=this.scene.input.keyDown);for(var s=0,r=i.length;s0&&void 0!==arguments[0]?arguments[0]:{};this._controllers.pivotController.enablePivotSphere(e)}},{key:"disablePivotSphere",value:function(){this._controllers.pivotController.disablePivotSphere()}},{key:"smartPivot",get:function(){return this._configs.smartPivot},set:function(e){this._configs.smartPivot=!1!==e}},{key:"doubleClickTimeFrame",get:function(){return this._configs.doubleClickTimeFrame},set:function(e){this._configs.doubleClickTimeFrame=null!=e?e:250}},{key:"destroy",value:function(){this._destroyHandlers(),this._destroyControllers(),this._cameraUpdater.destroy(),f(B(i.prototype),"destroy",this).call(this)}},{key:"_destroyHandlers",value:function(){for(var e=0,t=this._handlers.length;e1&&void 0!==arguments[1]?arguments[1]:{};if(this.finalized)throw"MetaScene already finalized - can't add more data";this._globalizeIDs(e,t);var i=this.metaScene,s=e.properties;if(e.propertySets)for(var r=0,n=e.propertySets.length;r0?sp(t):null,o=i&&i.length>0?sp(i):null;return function e(t){if(t){var i=!0;(o&&o[t.type]||n&&!n[t.type])&&(i=!1),i&&s.push(t.id);var r=t.children;if(r)for(var a=0,l=r.length;a * Copyright (c) 2022 Niklas von Hertzen @@ -33,4 +33,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var rp=function(e,t){return rp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},rp(e,t)};function np(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}rp(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var op=function(){return op=Object.assign||function(e){for(var t,i=1,s=arguments.length;i0&&r[r.length-1])||6!==n[0]&&2!==n[0])){o=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]=55296&&r<=56319&&i>10),o%1024+56320)),(r+1===i||s.length>16384)&&(n+=String.fromCharCode.apply(String,s),s.length=0)}return n},pp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fp="undefined"==typeof Uint8Array?[]:new Uint8Array(256),vp=0;vp=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Bp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wp="undefined"==typeof Uint8Array?[]:new Uint8Array(256),xp=0;xp>4,A[l++]=(15&s)<<4|r>>2,A[l++]=(3&r)<<6|63&n;return u}(e),o=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s0;){var o=s[--n];if(Array.isArray(e)?-1!==e.indexOf(o):e===o)for(var a=i;a<=s.length;){var l;if((l=s[++a])===t)return!0;if(l!==Pp)break}if(o!==Pp)break}return!1},of=function(e,t){for(var i=e;i>=0;){var s=t[i];if(s!==Pp)return s;i--}return 0},af=function(e,t,i,s,r){if(0===i[s])return"×";var n=s-1;if(Array.isArray(r)&&!0===r[n])return"×";var o=n-1,a=n+1,l=t[n],u=o>=0?t[o]:0,A=t[a];if(2===l&&3===A)return"×";if(-1!==qp.indexOf(l))return"!";if(-1!==qp.indexOf(A))return"×";if(-1!==$p.indexOf(A))return"×";if(8===of(n,t))return"÷";if(11===Yp.get(e[n]))return"×";if((l===Qp||l===Vp)&&11===Yp.get(e[a]))return"×";if(7===l||7===A)return"×";if(9===l)return"×";if(-1===[Pp,Cp,Mp].indexOf(l)&&9===A)return"×";if(-1!==[Fp,Ep,kp,Tp,Op].indexOf(A))return"×";if(of(n,t)===Sp)return"×";if(nf(23,Sp,n,t))return"×";if(nf([Fp,Ep],Dp,n,t))return"×";if(nf(12,12,n,t))return"×";if(l===Pp)return"÷";if(23===l||23===A)return"×";if(16===A||16===l)return"÷";if(-1!==[Cp,Mp,Dp].indexOf(A)||14===l)return"×";if(36===u&&-1!==rf.indexOf(l))return"×";if(l===Op&&36===A)return"×";if(A===Ip)return"×";if(-1!==Zp.indexOf(A)&&l===Rp||-1!==Zp.indexOf(l)&&A===Rp)return"×";if(l===Up&&-1!==[Gp,Qp,Vp].indexOf(A)||-1!==[Gp,Qp,Vp].indexOf(l)&&A===Lp)return"×";if(-1!==Zp.indexOf(l)&&-1!==ef.indexOf(A)||-1!==ef.indexOf(l)&&-1!==Zp.indexOf(A))return"×";if(-1!==[Up,Lp].indexOf(l)&&(A===Rp||-1!==[Sp,Mp].indexOf(A)&&t[a+1]===Rp)||-1!==[Sp,Mp].indexOf(l)&&A===Rp||l===Rp&&-1!==[Rp,Op,Tp].indexOf(A))return"×";if(-1!==[Rp,Op,Tp,Fp,Ep].indexOf(A))for(var c=n;c>=0;){if((h=t[c])===Rp)return"×";if(-1===[Op,Tp].indexOf(h))break;c--}if(-1!==[Up,Lp].indexOf(A))for(c=-1!==[Fp,Ep].indexOf(l)?o:n;c>=0;){var h;if((h=t[c])===Rp)return"×";if(-1===[Op,Tp].indexOf(h))break;c--}if(zp===l&&-1!==[zp,Wp,Hp,jp].indexOf(A)||-1!==[Wp,Hp].indexOf(l)&&-1!==[Wp,Kp].indexOf(A)||-1!==[Kp,jp].indexOf(l)&&A===Kp)return"×";if(-1!==sf.indexOf(l)&&-1!==[Ip,Lp].indexOf(A)||-1!==sf.indexOf(A)&&l===Up)return"×";if(-1!==Zp.indexOf(l)&&-1!==Zp.indexOf(A))return"×";if(l===Tp&&-1!==Zp.indexOf(A))return"×";if(-1!==Zp.concat(Rp).indexOf(l)&&A===Sp&&-1===Jp.indexOf(e[a])||-1!==Zp.concat(Rp).indexOf(A)&&l===Ep)return"×";if(41===l&&41===A){for(var d=i[n],p=1;d>0&&41===t[--d];)p++;if(p%2!=0)return"×"}return l===Qp&&A===Vp?"×":"÷"},lf=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=function(e,t){void 0===t&&(t="strict");var i=[],s=[],r=[];return e.forEach((function(e,n){var o=Yp.get(e);if(o>50?(r.push(!0),o-=50):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return s.push(n),i.push(16);if(4===o||11===o){if(0===n)return s.push(n),i.push(Np);var a=i[n-1];return-1===tf.indexOf(a)?(s.push(s[n-1]),i.push(a)):(s.push(n),i.push(Np))}return s.push(n),31===o?i.push("strict"===t?Dp:Gp):o===Xp||29===o?i.push(Np):43===o?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(Gp):i.push(Np):void i.push(o)})),[s,i,r]}(e,t.lineBreak),s=i[0],r=i[1],n=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[Rp,Np,Xp].indexOf(e)?Gp:e})));var o="keep-all"===t.wordBreak?n.map((function(t,i){return t&&e[i]>=19968&&e[i]<=40959})):void 0;return[s,r,o]},uf=function(){function e(e,t,i,s){this.codePoints=e,this.required="!"===t,this.start=i,this.end=s}return e.prototype.slice=function(){return dp.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),Af=function(e){return e>=48&&e<=57},cf=function(e){return Af(e)||e>=65&&e<=70||e>=97&&e<=102},hf=function(e){return 10===e||9===e||32===e},df=function(e){return function(e){return function(e){return e>=97&&e<=122}(e)||function(e){return e>=65&&e<=90}(e)}(e)||function(e){return e>=128}(e)||95===e},pf=function(e){return df(e)||Af(e)||45===e},ff=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},vf=function(e,t){return 92===e&&10!==t},gf=function(e,t,i){return 45===e?df(t)||vf(t,i):!!df(e)||!(92!==e||!vf(e,t))},mf=function(e,t,i){return 43===e||45===e?!!Af(t)||46===t&&Af(i):Af(46===e?t:e)},_f=function(e){var t=0,i=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(i=-1),t++);for(var s=[];Af(e[t]);)s.push(e[t++]);var r=s.length?parseInt(dp.apply(void 0,s),10):0;46===e[t]&&t++;for(var n=[];Af(e[t]);)n.push(e[t++]);var o=n.length,a=o?parseInt(dp.apply(void 0,n),10):0;69!==e[t]&&101!==e[t]||t++;var l=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(l=-1),t++);for(var u=[];Af(e[t]);)u.push(e[t++]);var A=u.length?parseInt(dp.apply(void 0,u),10):0;return i*(r+a*Math.pow(10,-o))*Math.pow(10,l*A)},yf={type:2},bf={type:3},Bf={type:4},wf={type:13},xf={type:8},Pf={type:21},Cf={type:9},Mf={type:10},Ff={type:11},Ef={type:12},kf={type:14},If={type:23},Df={type:1},Sf={type:25},Tf={type:24},Rf={type:26},Lf={type:27},Uf={type:28},Of={type:29},Nf={type:31},Qf={type:32},Vf=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(hp(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==Qf;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(pf(t)||vf(i,s)){var r=gf(t,i,s)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),wf;break;case 39:return this.consumeStringToken(39);case 40:return yf;case 41:return bf;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),kf;break;case 43:if(mf(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return Bf;case 45:var n=e,o=this.peekCodePoint(0),a=this.peekCodePoint(1);if(mf(n,o,a))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(gf(n,o,a))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===o&&62===a)return this.consumeCodePoint(),this.consumeCodePoint(),Tf;break;case 46:if(mf(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(42===l&&47===(l=this.consumeCodePoint()))return this.consumeToken();if(-1===l)return this.consumeToken()}break;case 58:return Rf;case 59:return Lf;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),Sf;break;case 64:var u=this.peekCodePoint(0),A=this.peekCodePoint(1),c=this.peekCodePoint(2);if(gf(u,A,c))return{type:7,value:this.consumeName()};break;case 91:return Uf;case 92:if(vf(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return Of;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),xf;break;case 123:return Ff;case 125:return Ef;case 117:case 85:var h=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==h||!cf(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Cf;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),Pf;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Mf;break;case-1:return Qf}return hf(e)?(this.consumeWhiteSpace(),Nf):Af(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):df(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:dp(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();cf(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(dp.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(dp.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var s=parseInt(dp.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&cf(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];cf(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:s,end:parseInt(dp.apply(void 0,r),16)}}return{type:30,start:s,end:s}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var t=this.peekCodePoint(0);if(39===t||34===t){var i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),If)}for(;;){var s=this.consumeCodePoint();if(-1===s||41===s)return{type:22,value:dp.apply(void 0,e)};if(hf(s))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:dp.apply(void 0,e)}):(this.consumeBadUrlRemnants(),If);if(34===s||39===s||40===s||ff(s))return this.consumeBadUrlRemnants(),If;if(92===s){if(!vf(s,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),If;e.push(this.consumeEscapedCodePoint())}else e.push(s)}},e.prototype.consumeWhiteSpace=function(){for(;hf(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;vf(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var i=Math.min(5e4,e);t+=dp.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var s=this._value[i];if(-1===s||void 0===s||s===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(10===s)return this._value.splice(0,i),Df;if(92===s){var r=this._value[i+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):vf(s,r)&&(t+=this.consumeStringSlice(i),t+=dp(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=4,i=this.peekCodePoint(0);for(43!==i&&45!==i||e.push(this.consumeCodePoint());Af(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var s=this.peekCodePoint(1);if(46===i&&Af(s))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Af(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),s=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===i||101===i)&&((43===s||45===s)&&Af(r)||Af(s)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Af(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[_f(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],s=this.peekCodePoint(0),r=this.peekCodePoint(1),n=this.peekCodePoint(2);return gf(s,r,n)?{type:15,number:t,flags:i,unit:this.consumeName()}:37===s?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(cf(e)){for(var t=dp(e);cf(this.peekCodePoint(0))&&t.length<6;)t+=dp(this.consumeCodePoint());hf(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||function(e){return e>=55296&&e<=57343}(i)||i>1114111?65533:i}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(pf(t))e+=dp(t);else{if(!vf(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=dp(this.consumeEscapedCodePoint())}}},e}(),Hf=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new Vf;return i.write(t),new e(i.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(32===i.type||Zf(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?Qf:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),jf=function(e){return 15===e.type},Gf=function(e){return 17===e.type},zf=function(e){return 20===e.type},Wf=function(e){return 0===e.type},Kf=function(e,t){return zf(e)&&e.value===t},Xf=function(e){return 31!==e.type},Jf=function(e){return 31!==e.type&&4!==e.type},Yf=function(e){var t=[],i=[];return e.forEach((function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)})),i.length&&t.push(i),t},Zf=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},qf=function(e){return 17===e.type||15===e.type},$f=function(e){return 16===e.type||qf(e)},ev=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},tv={type:17,number:0,flags:4},iv={type:16,number:50,flags:4},sv={type:16,number:100,flags:4},rv=function(e,t,i){var s=e[0],r=e[1];return[nv(s,t),nv(void 0!==r?r:s,i)]},nv=function(e,t){if(16===e.type)return e.number/100*t;if(jf(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},ov=function(e,t){if(15===t.type)switch(t.unit){case"deg":return Math.PI*t.number/180;case"grad":return Math.PI/200*t.number;case"rad":return t.number;case"turn":return 2*Math.PI*t.number}throw new Error("Unsupported angle type")},av=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},lv=function(e){switch(e.filter(zf).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[tv,tv];case"to top":case"bottom":return uv(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[tv,sv];case"to right":case"left":return uv(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[sv,sv];case"to bottom":case"top":return uv(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[sv,tv];case"to left":case"right":return uv(270)}return 0},uv=function(e){return Math.PI*e/180},Av=function(e,t){if(18===t.type){var i=mv[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var s=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);return dv(parseInt(s+s,16),parseInt(r+r,16),parseInt(n+n,16),1)}if(4===t.value.length){s=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);var o=t.value.substring(3,4);return dv(parseInt(s+s,16),parseInt(r+r,16),parseInt(n+n,16),parseInt(o+o,16)/255)}if(6===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6);return dv(parseInt(s,16),parseInt(r,16),parseInt(n,16),1)}if(8===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6),o=t.value.substring(6,8);return dv(parseInt(s,16),parseInt(r,16),parseInt(n,16),parseInt(o,16)/255)}}if(20===t.type){var a=yv[t.value.toUpperCase()];if(void 0!==a)return a}return yv.TRANSPARENT},cv=function(e){return 0==(255&e)},hv=function(e){var t=255&e,i=255&e>>8,s=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+s+","+i+","+t/255+")":"rgb("+r+","+s+","+i+")"},dv=function(e,t,i,s){return(e<<24|t<<16|i<<8|Math.round(255*s)<<0)>>>0},pv=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},fv=function(e,t){var i=t.filter(Jf);if(3===i.length){var s=i.map(pv),r=s[0],n=s[1],o=s[2];return dv(r,n,o,1)}if(4===i.length){var a=i.map(pv),l=(r=a[0],n=a[1],o=a[2],a[3]);return dv(r,n,o,l)}return 0};function vv(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var gv=function(e,t){var i=t.filter(Jf),s=i[0],r=i[1],n=i[2],o=i[3],a=(17===s.type?uv(s.number):ov(e,s))/(2*Math.PI),l=$f(r)?r.number/100:0,u=$f(n)?n.number/100:0,A=void 0!==o&&$f(o)?nv(o,1):1;if(0===l)return dv(255*u,255*u,255*u,1);var c=u<=.5?u*(l+1):u+l-u*l,h=2*u-c,d=vv(h,c,a+1/3),p=vv(h,c,a),f=vv(h,c,a-1/3);return dv(255*d,255*p,255*f,A)},mv={hsl:gv,hsla:gv,rgb:fv,rgba:fv},_v=function(e,t){return Av(e,Hf.create(t).parseComponentValue())},yv={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},bv={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(zf(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Bv={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},wv=function(e,t){var i=Av(e,t[0]),s=t[1];return s&&$f(s)?{color:i,stop:s}:{color:i,stop:null}},xv=function(e,t){var i=e[0],s=e[e.length-1];null===i.stop&&(i.stop=tv),null===s.stop&&(s.stop=sv);for(var r=[],n=0,o=0;on?r.push(l):r.push(n),n=l}else r.push(null)}var u=null;for(o=0;oe.optimumDistance)?{optimumCorner:t,optimumDistance:a}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},Fv=function(e,t){var i=uv(180),s=[];return Yf(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&-1!==["top","left","right","bottom"].indexOf(n.value))return void(i=lv(t));if(av(n))return void(i=(ov(e,n)+uv(270))%uv(360))}var o=wv(e,t);s.push(o)})),{angle:i,stops:s,type:1}},Ev=function(e,t){var i=0,s=3,r=[],n=[];return Yf(t).forEach((function(t,o){var a=!0;if(0===o?a=t.reduce((function(e,t){if(zf(t))switch(t.value){case"center":return n.push(iv),!1;case"top":case"left":return n.push(tv),!1;case"right":case"bottom":return n.push(sv),!1}else if($f(t)||qf(t))return n.push(t),!1;return e}),a):1===o&&(a=t.reduce((function(e,t){if(zf(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"contain":case"closest-side":return s=0,!1;case"farthest-side":return s=1,!1;case"closest-corner":return s=2,!1;case"cover":case"farthest-corner":return s=3,!1}else if(qf(t)||$f(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)),a){var l=wv(e,t);r.push(l)}})),{size:s,shape:i,stops:r,position:n,type:2}},kv=function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var s=Dv[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(e,t.values)}throw new Error("Unsupported image type "+t.type)};var Iv,Dv={"linear-gradient":function(e,t){var i=uv(180),s=[];return Yf(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&"to"===n.value)return void(i=lv(t));if(av(n))return void(i=ov(e,n))}var o=wv(e,t);s.push(o)})),{angle:i,stops:s,type:1}},"-moz-linear-gradient":Fv,"-ms-linear-gradient":Fv,"-o-linear-gradient":Fv,"-webkit-linear-gradient":Fv,"radial-gradient":function(e,t){var i=0,s=3,r=[],n=[];return Yf(t).forEach((function(t,o){var a=!0;if(0===o){var l=!1;a=t.reduce((function(e,t){if(l)if(zf(t))switch(t.value){case"center":return n.push(iv),e;case"top":case"left":return n.push(tv),e;case"right":case"bottom":return n.push(sv),e}else($f(t)||qf(t))&&n.push(t);else if(zf(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"at":return l=!0,!1;case"closest-side":return s=0,!1;case"cover":case"farthest-side":return s=1,!1;case"contain":case"closest-corner":return s=2,!1;case"farthest-corner":return s=3,!1}else if(qf(t)||$f(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)}if(a){var u=wv(e,t);r.push(u)}})),{size:s,shape:i,stops:r,position:n,type:2}},"-moz-radial-gradient":Ev,"-ms-radial-gradient":Ev,"-o-radial-gradient":Ev,"-webkit-radial-gradient":Ev,"-webkit-gradient":function(e,t){var i=uv(180),s=[],r=1;return Yf(t).forEach((function(t,i){var n=t[0];if(0===i){if(zf(n)&&"linear"===n.value)return void(r=1);if(zf(n)&&"radial"===n.value)return void(r=2)}if(18===n.type)if("from"===n.name){var o=Av(e,n.values[0]);s.push({stop:tv,color:o})}else if("to"===n.name){o=Av(e,n.values[0]);s.push({stop:sv,color:o})}else if("color-stop"===n.name){var a=n.values.filter(Jf);if(2===a.length){o=Av(e,a[1]);var l=a[0];Gf(l)&&s.push({stop:{type:16,number:100*l.number,flags:l.flags},color:o})}}})),1===r?{angle:(i+uv(180))%uv(360),stops:s,type:r}:{size:3,shape:0,stops:s,position:[],type:r}}},Sv={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter((function(e){return Jf(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Dv[e.name])}(e)})).map((function(t){return kv(e,t)}))}},Tv={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(zf(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Rv={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return Yf(t).map((function(e){return e.filter($f)})).map(ev)}},Lv={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return Yf(t).map((function(e){return e.filter(zf).map((function(e){return e.value})).join(" ")})).map(Uv)}},Uv=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Iv||(Iv={}));var Ov,Nv={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return Yf(t).map((function(e){return e.filter(Qv)}))}},Qv=function(e){return zf(e)||$f(e)},Vv=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},Hv=Vv("top"),jv=Vv("right"),Gv=Vv("bottom"),zv=Vv("left"),Wv=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return ev(t.filter($f))}}},Kv=Wv("top-left"),Xv=Wv("top-right"),Jv=Wv("bottom-right"),Yv=Wv("bottom-left"),Zv=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},qv=Zv("top"),$v=Zv("right"),eg=Zv("bottom"),tg=Zv("left"),ig=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return jf(t)?t.number:0}}},sg=ig("top"),rg=ig("right"),ng=ig("bottom"),og=ig("left"),ag={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},lg={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},ug={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(zf).reduce((function(e,t){return e|Ag(t.value)}),0)}},Ag=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},cg={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},hg={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(Ov||(Ov={}));var dg,pg={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?Ov.STRICT:Ov.NORMAL}},fg={name:"line-height",initialValue:"normal",prefix:!1,type:4},vg=function(e,t){return zf(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:$f(e)?nv(e,t):t},gg={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:kv(e,t)}},mg={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},_g={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},yg=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},bg=yg("top"),Bg=yg("right"),wg=yg("bottom"),xg=yg("left"),Pg={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(zf).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},Cg={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Mg=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Fg=Mg("top"),Eg=Mg("right"),kg=Mg("bottom"),Ig=Mg("left"),Dg={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Sg={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Tg={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Kf(t[0],"none")?[]:Yf(t).map((function(t){for(var i={color:yv.TRANSPARENT,offsetX:tv,offsetY:tv,blur:tv},s=0,r=0;r1?1:0],this.overflowWrap=dm(e,Cg,t.overflowWrap),this.paddingTop=dm(e,Fg,t.paddingTop),this.paddingRight=dm(e,Eg,t.paddingRight),this.paddingBottom=dm(e,kg,t.paddingBottom),this.paddingLeft=dm(e,Ig,t.paddingLeft),this.paintOrder=dm(e,am,t.paintOrder),this.position=dm(e,Sg,t.position),this.textAlign=dm(e,Dg,t.textAlign),this.textDecorationColor=dm(e,Wg,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=dm(e,Kg,null!==(s=t.textDecorationLine)&&void 0!==s?s:t.textDecoration),this.textShadow=dm(e,Tg,t.textShadow),this.textTransform=dm(e,Rg,t.textTransform),this.transform=dm(e,Lg,t.transform),this.transformOrigin=dm(e,Qg,t.transformOrigin),this.visibility=dm(e,Vg,t.visibility),this.webkitTextStrokeColor=dm(e,lm,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=dm(e,um,t.webkitTextStrokeWidth),this.wordBreak=dm(e,Hg,t.wordBreak),this.zIndex=dm(e,jg,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return cv(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return $g(this.display,4)||$g(this.display,33554432)||$g(this.display,268435456)||$g(this.display,536870912)||$g(this.display,67108864)||$g(this.display,134217728)},e}(),cm=function(e,t){this.content=dm(e,em,t.content),this.quotes=dm(e,rm,t.quotes)},hm=function(e,t){this.counterIncrement=dm(e,tm,t.counterIncrement),this.counterReset=dm(e,im,t.counterReset)},dm=function(e,t,i){var s=new Vf,r=null!=i?i.toString():t.initialValue;s.write(r);var n=new Hf(s.read());switch(t.type){case 2:var o=n.parseComponentValue();return t.parse(e,zf(o)?o.value:t.initialValue);case 0:return t.parse(e,n.parseComponentValue());case 1:return t.parse(e,n.parseComponentValues());case 4:return n.parseComponentValue();case 3:switch(t.format){case"angle":return ov(e,n.parseComponentValue());case"color":return Av(e,n.parseComponentValue());case"image":return kv(e,n.parseComponentValue());case"length":var a=n.parseComponentValue();return qf(a)?a:tv;case"length-percentage":var l=n.parseComponentValue();return $f(l)?l:tv;case"time":return Gg(e,n.parseComponentValue())}}},pm=function(e,t){var i=function(e){switch(e.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(e);return 1===i||t===i},fm=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,pm(t,3),this.styles=new Am(e,window.getComputedStyle(t,null)),f_(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=cp(this.context,t),pm(t,4)&&(this.flags|=16)},vm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gm="undefined"==typeof Uint8Array?[]:new Uint8Array(256),mm=0;mm=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),bm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bm="undefined"==typeof Uint8Array?[]:new Uint8Array(256),wm=0;wm>10),o%1024+56320)),(r+1===i||s.length>16384)&&(n+=String.fromCharCode.apply(String,s),s.length=0)}return n},km=function(e,t){var i,s,r,n=function(e){var t,i,s,r,n,o=.75*e.length,a=e.length,l=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);var u="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(o):new Array(o),A=Array.isArray(u)?u:new Uint8Array(u);for(t=0;t>4,A[l++]=(15&s)<<4|r>>2,A[l++]=(3&r)<<6|63&n;return u}(e),o=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s=55296&&r<=56319&&i=i)return{done:!0,value:null};for(var e="×";so.x||r.y>o.y;return o=r,0===t||a}));return e.body.removeChild(t),a}(document);return Object.defineProperty(Um,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,i=e.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,";try{s.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(Um,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?function(e){var t=e.createElement("canvas"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var r=new Image,n=t.toDataURL();r.src=n;var o=Rm(i,i,0,0,r);return s.fillStyle="red",s.fillRect(0,0,i,i),Lm(o).then((function(t){s.drawImage(t,0,0);var r=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var o=e.createElement("div");return o.style.backgroundImage="url("+n+")",o.style.height="100px",Tm(r)?Lm(Rm(i,i,0,0,o)):Promise.reject(!1)})).then((function(e){return s.drawImage(e,0,0),Tm(s.getImageData(0,0,i,i).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(Um,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(Um,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(Um,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Um,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(Um,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Om=function(e,t){this.text=e,this.bounds=t},Nm=function(e,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(s,t);var n=cp(e,s);return s.firstChild&&r.replaceChild(s.firstChild,s),n}}return Ap.EMPTY},Qm=function(e,t,i){var s=e.ownerDocument;if(!s)throw new Error("Node has no owner document");var r=s.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},Vm=function(e){if(Um.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return function(e){for(var t,i=Sm(e),s=[];!(t=i.next()).done;)t.value&&s.push(t.value.slice());return s}(e)},Hm=function(e,t){return 0!==t.letterSpacing?Vm(e):function(e,t){if(Um.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map((function(e){return e.segment}))}return Gm(e,t)}(e,t)},jm=[32,160,4961,65792,65793,4153,4241],Gm=function(e,t){for(var i,s=function(e,t){var i=hp(e),s=lf(i,t),r=s[0],n=s[1],o=s[2],a=i.length,l=0,u=0;return{next:function(){if(u>=a)return{done:!0,value:null};for(var e="×";u0)if(Um.SUPPORT_RANGE_BOUNDS){var r=Qm(s,o,t.length).getClientRects();if(r.length>1){var a=Vm(t),l=0;a.forEach((function(t){n.push(new Om(t,Ap.fromDOMRectList(e,Qm(s,l+o,t.length).getClientRects()))),l+=t.length}))}else n.push(new Om(t,Ap.fromDOMRectList(e,r)))}else{var u=s.splitText(t.length);n.push(new Om(t,Nm(e,s))),s=u}else Um.SUPPORT_RANGE_BOUNDS||(s=s.splitText(t.length));o+=t.length})),n}(e,this.text,i,t)},Wm=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Km,Xm);case 2:return e.toUpperCase();default:return e}},Km=/(^|\s|:|-|\(|\))([a-z])/g,Xm=function(e,t,i){return e.length>0?t+i.toUpperCase():e},Jm=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.src=i.currentSrc||i.src,s.intrinsicWidth=i.naturalWidth,s.intrinsicHeight=i.naturalHeight,s.context.cache.addImage(s.src),s}return np(t,e),t}(fm),Ym=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i,s.intrinsicWidth=i.width,s.intrinsicHeight=i.height,s}return np(t,e),t}(fm),Zm=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=new XMLSerializer,n=cp(t,i);return i.setAttribute("width",n.width+"px"),i.setAttribute("height",n.height+"px"),s.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),s.intrinsicWidth=i.width.baseVal.value,s.intrinsicHeight=i.height.baseVal.value,s.context.cache.addImage(s.svg),s}return np(t,e),t}(fm),qm=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return np(t,e),t}(fm),$m=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.start=i.start,s.reversed="boolean"==typeof i.reversed&&!0===i.reversed,s}return np(t,e),t}(fm),e_=[{type:15,flags:0,unit:"px",number:3}],t_=[{type:16,flags:0,number:50}],i_="password",s_=function(e){function t(t,i){var s,r=e.call(this,t,i)||this;switch(r.type=i.type.toLowerCase(),r.checked=i.checked,r.value=function(e){var t=e.type===i_?new Array(e.value.length+1).join("•"):e.value;return 0===t.length?e.placeholder||"":t}(i),"checkbox"!==r.type&&"radio"!==r.type||(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=(s=r.bounds).width>s.height?new Ap(s.left+(s.width-s.height)/2,s.top,s.height,s.height):s.width0)s.textNodes.push(new zm(t,n,s.styles));else if(p_(n))if(E_(n)&&n.assignedNodes)n.assignedNodes().forEach((function(i){return e(t,i,s,r)}));else{var a=u_(t,n);a.styles.isVisible()&&(c_(n,a,r)?a.flags|=4:h_(a.styles)&&(a.flags|=2),-1!==a_.indexOf(n.tagName)&&(a.flags|=8),s.elements.push(a),n.slot,n.shadowRoot?e(t,n.shadowRoot,a,r):M_(n)||y_(n)||F_(n)||e(t,n,a,r))}},u_=function(e,t){return x_(t)?new Jm(e,t):B_(t)?new Ym(e,t):y_(t)?new Zm(e,t):g_(t)?new qm(e,t):m_(t)?new $m(e,t):__(t)?new s_(e,t):F_(t)?new r_(e,t):M_(t)?new n_(e,t):P_(t)?new o_(e,t):new fm(e,t)},A_=function(e,t){var i=u_(e,t);return i.flags|=4,l_(e,t,i,i),i},c_=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||b_(e)&&i.styles.isTransparent()},h_=function(e){return e.isPositioned()||e.isFloating()},d_=function(e){return e.nodeType===Node.TEXT_NODE},p_=function(e){return e.nodeType===Node.ELEMENT_NODE},f_=function(e){return p_(e)&&void 0!==e.style&&!v_(e)},v_=function(e){return"object"===w(e.className)},g_=function(e){return"LI"===e.tagName},m_=function(e){return"OL"===e.tagName},__=function(e){return"INPUT"===e.tagName},y_=function(e){return"svg"===e.tagName},b_=function(e){return"BODY"===e.tagName},B_=function(e){return"CANVAS"===e.tagName},w_=function(e){return"VIDEO"===e.tagName},x_=function(e){return"IMG"===e.tagName},P_=function(e){return"IFRAME"===e.tagName},C_=function(e){return"STYLE"===e.tagName},M_=function(e){return"TEXTAREA"===e.tagName},F_=function(e){return"SELECT"===e.tagName},E_=function(e){return"SLOT"===e.tagName},k_=function(e){return e.tagName.indexOf("-")>0},I_=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,i=e.counterIncrement,s=e.counterReset,r=!0;null!==i&&i.forEach((function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)}));var n=[];return r&&s.forEach((function(e){var i=t.counters[e.counter];n.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)})),n},e}(),D_={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},S_={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},T_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},R_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},L_=function(e,t,i,s,r,n){return ei?V_(e,r,n.length>0):s.integers.reduce((function(t,i,r){for(;e>=i;)e-=i,t+=s.values[r];return t}),"")+n},U_=function(e,t,i,s){var r="";do{i||e--,r=s(e)+r,e/=t}while(e*t>=t);return r},O_=function(e,t,i,s,r){var n=i-t+1;return(e<0?"-":"")+(U_(Math.abs(e),n,s,(function(e){return dp(Math.floor(e%n)+t)}))+r)},N_=function(e,t,i){void 0===i&&(i=". ");var s=t.length;return U_(Math.abs(e),s,!1,(function(e){return t[Math.floor(e%s)]}))+i},Q_=function(e,t,i,s,r,n){if(e<-9999||e>9999)return V_(e,4,r.length>0);var o=Math.abs(e),a=r;if(0===o)return t[0]+a;for(var l=0;o>0&&l<=4;l++){var u=o%10;0===u&&$g(n,1)&&""!==a?a=t[u]+a:u>1||1===u&&0===l||1===u&&1===l&&$g(n,2)||1===u&&1===l&&$g(n,4)&&e>100||1===u&&l>1&&$g(n,8)?a=t[u]+(l>0?i[l-1]:"")+a:1===u&&l>0&&(a=i[l-1]+a),o=Math.floor(o/10)}return(e<0?s:"")+a},V_=function(e,t,i){var s=i?". ":"",r=i?"、":"",n=i?", ":"",o=i?" ":"";switch(t){case 0:return"•"+o;case 1:return"◦"+o;case 2:return"◾"+o;case 5:var a=O_(e,48,57,!0,s);return a.length<4?"0"+a:a;case 4:return N_(e,"〇一二三四五六七八九",r);case 6:return L_(e,1,3999,D_,3,s).toLowerCase();case 7:return L_(e,1,3999,D_,3,s);case 8:return O_(e,945,969,!1,s);case 9:return O_(e,97,122,!1,s);case 10:return O_(e,65,90,!1,s);case 11:return O_(e,1632,1641,!0,s);case 12:case 49:return L_(e,1,9999,S_,3,s);case 35:return L_(e,1,9999,S_,3,s).toLowerCase();case 13:return O_(e,2534,2543,!0,s);case 14:case 30:return O_(e,6112,6121,!0,s);case 15:return N_(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return N_(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return Q_(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return Q_(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return Q_(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return Q_(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return Q_(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return Q_(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return Q_(e,"영일이삼사오육칠팔구","십백천만","마이너스",n,7);case 33:return Q_(e,"零一二三四五六七八九","十百千萬","마이너스",n,0);case 32:return Q_(e,"零壹貳參四五六七八九","拾百千","마이너스",n,7);case 18:return O_(e,2406,2415,!0,s);case 20:return L_(e,1,19999,R_,3,s);case 21:return O_(e,2790,2799,!0,s);case 22:return O_(e,2662,2671,!0,s);case 22:return L_(e,1,10999,T_,3,s);case 23:return N_(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return N_(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return O_(e,3302,3311,!0,s);case 28:return N_(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return N_(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return O_(e,3792,3801,!0,s);case 37:return O_(e,6160,6169,!0,s);case 38:return O_(e,4160,4169,!0,s);case 39:return O_(e,2918,2927,!0,s);case 40:return O_(e,1776,1785,!0,s);case 43:return O_(e,3046,3055,!0,s);case 44:return O_(e,3174,3183,!0,s);case 45:return O_(e,3664,3673,!0,s);case 46:return O_(e,3872,3881,!0,s);default:return O_(e,48,57,!0,s)}},H_=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new I_,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var i=this,s=G_(e,t);if(!s.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,n=e.defaultView.pageYOffset,o=s.contentWindow,a=o.document,l=K_(s).then((function(){return ap(i,void 0,void 0,(function(){var e,i;return lp(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(q_),o&&(o.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||o.scrollY===t.top&&o.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(o.scrollX-t.left,o.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(i=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:a.fonts&&a.fonts.ready?[4,a.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,W_(a)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(a,i)})).then((function(){return s}))]:[2,s]}}))}))}));return a.open(),a.write(Y_(document.doctype)+""),Z_(this.referenceElement.ownerDocument,r,n),a.replaceChild(a.adoptNode(this.documentElement),a.documentElement),a.close(),l},e.prototype.createElementClone=function(e){if(pm(e,2),B_(e))return this.createCanvasClone(e);if(w_(e))return this.createVideoClone(e);if(C_(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return x_(t)&&(x_(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),k_(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return J_(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),s=e.cloneNode(!1);return s.textContent=i,s}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var s=e.cloneNode(!1);try{s.width=e.width,s.height=e.height;var r=e.getContext("2d"),n=s.getContext("2d");if(n)if(!this.options.allowTaint&&r)n.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var o=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(o){var a=o.getContextAttributes();!1===(null==a?void 0:a.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}n.drawImage(e,0,0)}return s}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return s},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var s=e.ownerDocument.createElement("canvas");return s.width=e.offsetWidth,s.height=e.offsetHeight,s},e.prototype.appendChildNode=function(e,t,i){p_(t)&&(function(e){return"SCRIPT"===e.tagName}(t)||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&p_(t)&&C_(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var s=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(p_(r)&&E_(r)&&"function"==typeof r.assignedNodes){var n=r.assignedNodes();n.length&&n.forEach((function(e){return s.appendChildNode(t,e,i)}))}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(d_(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&p_(e)&&(f_(e)||v_(e))){var s=this.createElementClone(e);s.style.transitionProperty="none";var r=i.getComputedStyle(e),n=i.getComputedStyle(e,":before"),o=i.getComputedStyle(e,":after");this.referenceElement===e&&f_(s)&&(this.clonedReferenceElement=s),b_(s)&&ty(s);var a=this.counters.parse(new hm(this.context,r)),l=this.resolvePseudoContent(e,s,n,xm.BEFORE);k_(e)&&(t=!0),w_(e)||this.cloneChildNodes(e,s,t),l&&s.insertBefore(l,s.firstChild);var u=this.resolvePseudoContent(e,s,o,xm.AFTER);return u&&s.appendChild(u),this.counters.pop(a),(r&&(this.options.copyStyles||v_(e))&&!P_(e)||t)&&J_(r,s),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([s,e.scrollLeft,e.scrollTop]),(M_(e)||F_(e))&&(M_(s)||F_(s))&&(s.value=e.value),s}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,s){var r=this;if(i){var n=i.content,o=t.ownerDocument;if(o&&n&&"none"!==n&&"-moz-alt-content"!==n&&"none"!==i.display){this.counters.parse(new hm(this.context,i));var a=new cm(this.context,i),l=o.createElement("html2canvaspseudoelement");J_(i,l),a.content.forEach((function(t){if(0===t.type)l.appendChild(o.createTextNode(t.value));else if(22===t.type){var i=o.createElement("img");i.src=t.value,i.style.opacity="1",l.appendChild(i)}else if(18===t.type){if("attr"===t.name){var s=t.values.filter(zf);s.length&&l.appendChild(o.createTextNode(e.getAttribute(s[0].value)||""))}else if("counter"===t.name){var n=t.values.filter(Jf),u=n[0],A=n[1];if(u&&zf(u)){var c=r.counters.getCounterValue(u.value),h=A&&zf(A)?_g.parse(r.context,A.value):3;l.appendChild(o.createTextNode(V_(c,h,!1)))}}else if("counters"===t.name){var d=t.values.filter(Jf),p=(u=d[0],d[1]);A=d[2];if(u&&zf(u)){var f=r.counters.getCounterValues(u.value),v=A&&zf(A)?_g.parse(r.context,A.value):3,g=p&&0===p.type?p.value:"",m=f.map((function(e){return V_(e,v,!1)})).join(g);l.appendChild(o.createTextNode(m))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(o.createTextNode(nm(a.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(o.createTextNode(nm(a.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(o.createTextNode(t.value))}})),l.className=$_+" "+ey;var u=s===xm.BEFORE?" "+$_:" "+ey;return v_(t)?t.className.baseValue+=u:t.className+=u,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(xm||(xm={}));var j_,G_=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(i),i},z_=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},W_=function(e){return Promise.all([].slice.call(e.images,0).map(z_))},K_=function(e){return new Promise((function(t,i){var s=e.contentWindow;if(!s)return i("No window assigned for iframe");var r=s.document;s.onload=e.onload=function(){s.onload=e.onload=null;var i=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))}),50)}}))},X_=["all","d","content"],J_=function(e,t){for(var i=e.length-1;i>=0;i--){var s=e.item(i);-1===X_.indexOf(s)&&t.style.setProperty(s,e.getPropertyValue(s))}return t},Y_=function(e){var t="";return e&&(t+=""),t},Z_=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},q_=function(e){var t=e[0],i=e[1],s=e[2];t.scrollLeft=i,t.scrollTop=s},$_="___html2canvas___pseudoelement_before",ey="___html2canvas___pseudoelement_after",ty=function(e){iy(e,"."+$_+':before{\n content: "" !important;\n display: none !important;\n}\n .'+ey+':after{\n content: "" !important;\n display: none !important;\n}')},iy=function(e,t){var i=e.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,e.appendChild(s)}},sy=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),ry=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:cy(e)||ly(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return ap(this,void 0,void 0,(function(){var t,i,s,r,n=this;return lp(this,(function(o){switch(o.label){case 0:return t=sy.isSameOrigin(e),i=!uy(e)&&!0===this._options.useCORS&&Um.SUPPORT_CORS_IMAGES&&!t,s=!uy(e)&&!t&&!cy(e)&&"string"==typeof this._options.proxy&&Um.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||uy(e)||cy(e)||s||i?(r=e,s?[4,this.proxy(r)]:[3,2]):[2];case 1:r=o.sent(),o.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var s=new Image;s.onload=function(){return e(s)},s.onerror=t,(Ay(r)||i)&&(s.crossOrigin="anonymous"),s.src=r,!0===s.complete&&setTimeout((function(){return e(s)}),500),n._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+n._options.imageTimeout+"ms) loading image")}),n._options.imageTimeout)}))];case 3:return[2,o.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var s=e.substring(0,256);return new Promise((function(r,n){var o=Um.SUPPORT_RESPONSE_TYPE?"blob":"text",a=new XMLHttpRequest;a.onload=function(){if(200===a.status)if("text"===o)r(a.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return n(e)}),!1),e.readAsDataURL(a.response)}else n("Failed to proxy resource "+s+" with status code "+a.status)},a.onerror=n;var l=i.indexOf("?")>-1?"&":"?";if(a.open("GET",""+i+l+"url="+encodeURIComponent(e)+"&responseType="+o),"text"!==o&&a instanceof XMLHttpRequest&&(a.responseType=o),t._options.imageTimeout){var u=t._options.imageTimeout;a.timeout=u,a.ontimeout=function(){return n("Timed out ("+u+"ms) proxying "+s)}}a.send()}))},e}(),ny=/^data:image\/svg\+xml/i,oy=/^data:image\/.*;base64,/i,ay=/^data:image\/.*/i,ly=function(e){return Um.SUPPORT_SVG_DRAWING||!hy(e)},uy=function(e){return ay.test(e)},Ay=function(e){return oy.test(e)},cy=function(e){return"blob"===e.substr(0,4)},hy=function(e){return"svg"===e.substr(-3).toLowerCase()||ny.test(e)},dy=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),py=function(e,t,i){return new dy(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},fy=function(){function e(e,t,i,s){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=s}return e.prototype.subdivide=function(t,i){var s=py(this.start,this.startControl,t),r=py(this.startControl,this.endControl,t),n=py(this.endControl,this.end,t),o=py(s,r,t),a=py(r,n,t),l=py(o,a,t);return i?new e(this.start,s,o,l):new e(l,a,n,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),vy=function(e){return 1===e.type},gy=function(e){var t=e.styles,i=e.bounds,s=rv(t.borderTopLeftRadius,i.width,i.height),r=s[0],n=s[1],o=rv(t.borderTopRightRadius,i.width,i.height),a=o[0],l=o[1],u=rv(t.borderBottomRightRadius,i.width,i.height),A=u[0],c=u[1],h=rv(t.borderBottomLeftRadius,i.width,i.height),d=h[0],p=h[1],f=[];f.push((r+a)/i.width),f.push((d+A)/i.width),f.push((n+p)/i.height),f.push((l+c)/i.height);var v=Math.max.apply(Math,f);v>1&&(r/=v,n/=v,a/=v,l/=v,A/=v,c/=v,d/=v,p/=v);var g=i.width-a,m=i.height-c,_=i.width-A,y=i.height-p,b=t.borderTopWidth,B=t.borderRightWidth,w=t.borderBottomWidth,x=t.borderLeftWidth,P=nv(t.paddingTop,e.bounds.width),C=nv(t.paddingRight,e.bounds.width),M=nv(t.paddingBottom,e.bounds.width),F=nv(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||n>0?my(i.left+x/3,i.top+b/3,r-x/3,n-b/3,j_.TOP_LEFT):new dy(i.left+x/3,i.top+b/3),this.topRightBorderDoubleOuterBox=r>0||n>0?my(i.left+g,i.top+b/3,a-B/3,l-b/3,j_.TOP_RIGHT):new dy(i.left+i.width-B/3,i.top+b/3),this.bottomRightBorderDoubleOuterBox=A>0||c>0?my(i.left+_,i.top+m,A-B/3,c-w/3,j_.BOTTOM_RIGHT):new dy(i.left+i.width-B/3,i.top+i.height-w/3),this.bottomLeftBorderDoubleOuterBox=d>0||p>0?my(i.left+x/3,i.top+y,d-x/3,p-w/3,j_.BOTTOM_LEFT):new dy(i.left+x/3,i.top+i.height-w/3),this.topLeftBorderDoubleInnerBox=r>0||n>0?my(i.left+2*x/3,i.top+2*b/3,r-2*x/3,n-2*b/3,j_.TOP_LEFT):new dy(i.left+2*x/3,i.top+2*b/3),this.topRightBorderDoubleInnerBox=r>0||n>0?my(i.left+g,i.top+2*b/3,a-2*B/3,l-2*b/3,j_.TOP_RIGHT):new dy(i.left+i.width-2*B/3,i.top+2*b/3),this.bottomRightBorderDoubleInnerBox=A>0||c>0?my(i.left+_,i.top+m,A-2*B/3,c-2*w/3,j_.BOTTOM_RIGHT):new dy(i.left+i.width-2*B/3,i.top+i.height-2*w/3),this.bottomLeftBorderDoubleInnerBox=d>0||p>0?my(i.left+2*x/3,i.top+y,d-2*x/3,p-2*w/3,j_.BOTTOM_LEFT):new dy(i.left+2*x/3,i.top+i.height-2*w/3),this.topLeftBorderStroke=r>0||n>0?my(i.left+x/2,i.top+b/2,r-x/2,n-b/2,j_.TOP_LEFT):new dy(i.left+x/2,i.top+b/2),this.topRightBorderStroke=r>0||n>0?my(i.left+g,i.top+b/2,a-B/2,l-b/2,j_.TOP_RIGHT):new dy(i.left+i.width-B/2,i.top+b/2),this.bottomRightBorderStroke=A>0||c>0?my(i.left+_,i.top+m,A-B/2,c-w/2,j_.BOTTOM_RIGHT):new dy(i.left+i.width-B/2,i.top+i.height-w/2),this.bottomLeftBorderStroke=d>0||p>0?my(i.left+x/2,i.top+y,d-x/2,p-w/2,j_.BOTTOM_LEFT):new dy(i.left+x/2,i.top+i.height-w/2),this.topLeftBorderBox=r>0||n>0?my(i.left,i.top,r,n,j_.TOP_LEFT):new dy(i.left,i.top),this.topRightBorderBox=a>0||l>0?my(i.left+g,i.top,a,l,j_.TOP_RIGHT):new dy(i.left+i.width,i.top),this.bottomRightBorderBox=A>0||c>0?my(i.left+_,i.top+m,A,c,j_.BOTTOM_RIGHT):new dy(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=d>0||p>0?my(i.left,i.top+y,d,p,j_.BOTTOM_LEFT):new dy(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||n>0?my(i.left+x,i.top+b,Math.max(0,r-x),Math.max(0,n-b),j_.TOP_LEFT):new dy(i.left+x,i.top+b),this.topRightPaddingBox=a>0||l>0?my(i.left+Math.min(g,i.width-B),i.top+b,g>i.width+B?0:Math.max(0,a-B),Math.max(0,l-b),j_.TOP_RIGHT):new dy(i.left+i.width-B,i.top+b),this.bottomRightPaddingBox=A>0||c>0?my(i.left+Math.min(_,i.width-x),i.top+Math.min(m,i.height-w),Math.max(0,A-B),Math.max(0,c-w),j_.BOTTOM_RIGHT):new dy(i.left+i.width-B,i.top+i.height-w),this.bottomLeftPaddingBox=d>0||p>0?my(i.left+x,i.top+Math.min(y,i.height-w),Math.max(0,d-x),Math.max(0,p-w),j_.BOTTOM_LEFT):new dy(i.left+x,i.top+i.height-w),this.topLeftContentBox=r>0||n>0?my(i.left+x+F,i.top+b+P,Math.max(0,r-(x+F)),Math.max(0,n-(b+P)),j_.TOP_LEFT):new dy(i.left+x+F,i.top+b+P),this.topRightContentBox=a>0||l>0?my(i.left+Math.min(g,i.width+x+F),i.top+b+P,g>i.width+x+F?0:a-x+F,l-(b+P),j_.TOP_RIGHT):new dy(i.left+i.width-(B+C),i.top+b+P),this.bottomRightContentBox=A>0||c>0?my(i.left+Math.min(_,i.width-(x+F)),i.top+Math.min(m,i.height+b+P),Math.max(0,A-(B+C)),c-(w+M),j_.BOTTOM_RIGHT):new dy(i.left+i.width-(B+C),i.top+i.height-(w+M)),this.bottomLeftContentBox=d>0||p>0?my(i.left+x+F,i.top+y,Math.max(0,d-(x+F)),p-(w+M),j_.BOTTOM_LEFT):new dy(i.left+x+F,i.top+i.height-(w+M))};!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(j_||(j_={}));var my=function(e,t,i,s,r){var n=(Math.sqrt(2)-1)/3*4,o=i*n,a=s*n,l=e+i,u=t+s;switch(r){case j_.TOP_LEFT:return new fy(new dy(e,u),new dy(e,u-a),new dy(l-o,t),new dy(l,t));case j_.TOP_RIGHT:return new fy(new dy(e,t),new dy(e+o,t),new dy(l,u-a),new dy(l,u));case j_.BOTTOM_RIGHT:return new fy(new dy(l,t),new dy(l,t+a),new dy(e+o,u),new dy(e,u));case j_.BOTTOM_LEFT:default:return new fy(new dy(l,u),new dy(l-o,u),new dy(e,t+a),new dy(e,t))}},_y=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},yy=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},by=function(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6},By=function(e,t){this.path=e,this.target=t,this.type=1},wy=function(e){this.opacity=e,this.type=2,this.target=6},xy=function(e){return 1===e.type},Py=function(e,t){return e.length===t.length&&e.some((function(e,i){return e===t[i]}))},Cy=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},My=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new gy(this.container),this.container.styles.opacity<1&&this.effects.push(new wy(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,s=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new by(i,s,r))}if(0!==this.container.styles.overflowX){var n=_y(this.curves),o=yy(this.curves);Py(n,o)?this.effects.push(new By(n,6)):(this.effects.push(new By(n,2)),this.effects.push(new By(o,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,s=this.effects.slice(0);i;){var r=i.effects.filter((function(e){return!xy(e)}));if(t||0!==i.container.styles.position||!i.parent){if(s.unshift.apply(s,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var n=_y(i.curves),o=yy(i.curves);Py(n,o)||s.unshift(new By(o,6))}}else s.unshift.apply(s,r);i=i.parent}return s.filter((function(t){return $g(t.target,e)}))},e}(),Fy=function e(t,i,s,r){t.container.elements.forEach((function(n){var o=$g(n.flags,4),a=$g(n.flags,2),l=new My(n,t);$g(n.styles.display,2048)&&r.push(l);var u=$g(n.flags,8)?[]:r;if(o||a){var A=o||n.styles.isPositioned()?s:i,c=new Cy(l);if(n.styles.isPositioned()||n.styles.opacity<1||n.styles.isTransformed()){var h=n.styles.zIndex.order;if(h<0){var d=0;A.negativeZIndex.some((function(e,t){return h>e.element.container.styles.zIndex.order?(d=t,!1):d>0})),A.negativeZIndex.splice(d,0,c)}else if(h>0){var p=0;A.positiveZIndex.some((function(e,t){return h>=e.element.container.styles.zIndex.order?(p=t+1,!1):p>0})),A.positiveZIndex.splice(p,0,c)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else n.styles.isFloating()?A.nonPositionedFloats.push(c):A.nonPositionedInlineLevel.push(c);e(l,c,o?c:s,u)}else n.styles.isInlineLevel()?i.inlineLevel.push(l):i.nonInlineLevel.push(l),e(l,i,s,u);$g(n.flags,8)&&Ey(n,u)}))},Ey=function(e,t){for(var i=e instanceof $m?e.start:1,s=e instanceof $m&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var s=Ry(e),r=yy(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return ap(this,void 0,void 0,(function(){var i,s,r,n,o,a,l,u,A,c,h,d,p,f,v,g,m,_;return lp(this,(function(y){switch(y.label){case 0:this.applyEffects(e.getEffects(4)),i=e.container,s=e.curves,r=i.styles,n=0,o=i.textNodes,y.label=1;case 1:return n0&&w>0&&(g=s.ctx.createPattern(p,"repeat"),s.renderRepeat(_,g,P,C))):function(e){return 2===e.type}(i)&&(m=Ly(e,t,[null,null,null]),_=m[0],y=m[1],b=m[2],B=m[3],w=m[4],x=0===i.position.length?[iv]:i.position,P=nv(x[0],B),C=nv(x[x.length-1],w),M=function(e,t,i,s,r){var n=0,o=0;switch(e.size){case 0:0===e.shape?n=o=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(n=Math.min(Math.abs(t),Math.abs(t-s)),o=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)n=o=Math.min(Cv(t,i),Cv(t,i-r),Cv(t-s,i),Cv(t-s,i-r));else if(1===e.shape){var a=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-s)),l=Mv(s,r,t,i,!0),u=l[0],A=l[1];o=a*(n=Cv(u-t,(A-i)/a))}break;case 1:0===e.shape?n=o=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(n=Math.max(Math.abs(t),Math.abs(t-s)),o=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)n=o=Math.max(Cv(t,i),Cv(t,i-r),Cv(t-s,i),Cv(t-s,i-r));else if(1===e.shape){a=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-s));var c=Mv(s,r,t,i,!1);u=c[0],A=c[1],o=a*(n=Cv(u-t,(A-i)/a))}}return Array.isArray(e.size)&&(n=nv(e.size[0],s),o=2===e.size.length?nv(e.size[1],r):n),[n,o]}(i,P,C,B,w),F=M[0],E=M[1],F>0&&E>0&&(k=s.ctx.createRadialGradient(y+P,b+C,0,y+P,b+C,F),xv(i.stops,2*F).forEach((function(e){return k.addColorStop(e.stop,hv(e.color))})),s.path(_),s.ctx.fillStyle=k,F!==E?(I=e.bounds.left+.5*e.bounds.width,D=e.bounds.top+.5*e.bounds.height,T=1/(S=E/F),s.ctx.save(),s.ctx.translate(I,D),s.ctx.transform(1,0,0,S,0,0),s.ctx.translate(-I,-D),s.ctx.fillRect(y,T*(b-D)+D,B,w*T),s.ctx.restore()):s.ctx.fill())),R.label=6;case 6:return t--,[2]}}))},s=this,r=0,n=e.styles.backgroundImage.slice(0).reverse(),a.label=1;case 1:return r0?2!==l.style?[3,5]:[4,this.renderDashedDottedBorder(l.color,l.width,n,e.curves,2)]:[3,11]:[3,13];case 4:return A.sent(),[3,11];case 5:return 3!==l.style?[3,7]:[4,this.renderDashedDottedBorder(l.color,l.width,n,e.curves,3)];case 6:return A.sent(),[3,11];case 7:return 4!==l.style?[3,9]:[4,this.renderDoubleBorder(l.color,l.width,n,e.curves)];case 8:return A.sent(),[3,11];case 9:return[4,this.renderSolidBorder(l.color,n,e.curves)];case 10:A.sent(),A.label=11;case 11:n++,A.label=12;case 12:return o++,[3,3];case 13:return[2]}}))}))},t.prototype.renderDashedDottedBorder=function(e,t,i,s,r){return ap(this,void 0,void 0,(function(){var n,o,a,l,u,A,c,h,d,p,f,v,g,m,_,y;return lp(this,(function(b){return this.ctx.save(),n=function(e,t){switch(t){case 0:return Dy(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Dy(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Dy(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return Dy(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(s,i),o=Iy(s,i),2===r&&(this.path(o),this.ctx.clip()),vy(o[0])?(a=o[0].start.x,l=o[0].start.y):(a=o[0].x,l=o[0].y),vy(o[1])?(u=o[1].end.x,A=o[1].end.y):(u=o[1].x,A=o[1].y),c=0===i||2===i?Math.abs(a-u):Math.abs(l-A),this.ctx.beginPath(),3===r?this.formatPath(n):this.formatPath(o.slice(0,2)),h=t<3?3*t:2*t,d=t<3?2*t:t,3===r&&(h=t,d=t),p=!0,c<=2*h?p=!1:c<=2*h+d?(h*=f=c/(2*h+d),d*=f):(v=Math.floor((c+d)/(h+d)),g=(c-v*h)/(v-1),d=(m=(c-(v+1)*h)/v)<=0||Math.abs(d-g)0&&void 0!==arguments[0]?arguments[0]:{},t=!this._snapshotBegun,i=void 0!==e.width&&void 0!==e.height,s=this.scene.canvas.canvas,r=s.clientWidth,n=s.clientHeight,o=e.width?Math.floor(e.width):s.width,a=e.height?Math.floor(e.height):s.height;i&&(s.width=o,s.height=a),this._snapshotBegun||this.beginSnapshot({width:o,height:a}),e.includeGizmos||this.sendToPlugins("snapshotStarting");for(var l={},u=0,A=this._plugins.length;u0&&void 0!==b[0]?b[0]:{},i=!this._snapshotBegun,s=void 0!==t.width&&void 0!==t.height,r=this.scene.canvas.canvas,n=r.clientWidth,o=r.clientHeight,l=t.width?Math.floor(t.width):r.width,u=t.height?Math.floor(t.height):r.height,s&&(r.width=l,r.height=u),this._snapshotBegun||this.beginSnapshot(),t.includeGizmos||this.sendToPlugins("snapshotStarting"),this.scene._renderer.renderSnapshot(),A=this.scene._renderer.readSnapshotAsCanvas(),s&&(r.width=n,r.height=o,this.scene.glRedraw()),c={},h=[],d=0,p=this._plugins.length;d1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2?arguments[2]:void 0,s=i||new Set;if(e){if(bb(e))s.add(e);else if(bb(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"===w(e))for(var r in e)yb(e[r],t,s)}else;return void 0===i?Array.from(s):[]}function bb(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var Bb=function(){},wb=function(){function e(t){x(this,e),pb(this,"name",void 0),pb(this,"source",void 0),pb(this,"url",void 0),pb(this,"terminated",!1),pb(this,"worker",void 0),pb(this,"onMessage",void 0),pb(this,"onError",void 0),pb(this,"_loadableURL","");var i=t.name,s=t.source,r=t.url;ab(s||r),this.name=i,this.source=s,this.url=r,this.onMessage=Bb,this.onError=function(e){return console.log(e)},this.worker=Ab?this._createBrowserWorker():this._createNodeWorker()}return C(e,[{key:"destroy",value:function(){this.onMessage=Bb,this.onError=Bb,this.worker.terminate(),this.terminated=!0}},{key:"isRunning",get:function(){return Boolean(this.onMessage)}},{key:"postMessage",value:function(e,t){t=t||yb(e),this.worker.postMessage(e,t)}},{key:"_getErrorFromErrorEvent",value:function(e){var t="Failed to load ";return t+="worker ".concat(this.name," from ").concat(this.url,". "),e.message&&(t+="".concat(e.message," in ")),e.lineno&&(t+=":".concat(e.lineno,":").concat(e.colno)),new Error(t)}},{key:"_createBrowserWorker",value:function(){var e=this;this._loadableURL=mb({source:this.source,url:this.url});var t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=function(t){t.data?e.onMessage(t.data):e.onError(new Error("No data received"))},t.onerror=function(t){e.onError(e._getErrorFromErrorEvent(t)),e.terminated=!0},t.onmessageerror=function(e){return console.error(e)},t}},{key:"_createNodeWorker",value:function(){var e,t=this;if(this.url){var i=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);e=new vb(i,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new vb(this.source,{eval:!0})}return e.on("message",(function(e){t.onMessage(e)})),e.on("error",(function(e){t.onError(e)})),e.on("exit",(function(e){})),e}}],[{key:"isSupported",value:function(){return"undefined"!=typeof Worker&&Ab||void 0!==w(vb)}}]),e}(),xb=function(){function e(t){x(this,e),pb(this,"name","unnamed"),pb(this,"source",void 0),pb(this,"url",void 0),pb(this,"maxConcurrency",1),pb(this,"maxMobileConcurrency",1),pb(this,"onDebug",(function(){})),pb(this,"reuseWorkers",!0),pb(this,"props",{}),pb(this,"jobQueue",[]),pb(this,"idleQueue",[]),pb(this,"count",0),pb(this,"isDestroyed",!1),this.source=t.source,this.url=t.url,this.setProps(t)}var t,i;return C(e,[{key:"destroy",value:function(){this.idleQueue.forEach((function(e){return e.destroy()})),this.isDestroyed=!0}},{key:"setProps",value:function(e){this.props=n(n({},this.props),e),void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}},{key:"startJob",value:(i=u(a().mark((function e(t){var i,s,r,n=this,o=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=o.length>1&&void 0!==o[1]?o[1]:function(e,t,i){return e.done(i)},s=o.length>2&&void 0!==o[2]?o[2]:function(e,t){return e.error(t)},r=new Promise((function(e){return n.jobQueue.push({name:t,onMessage:i,onError:s,onStart:e}),n})),this._startQueuedJob(),e.next=6,r;case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_startQueuedJob",value:(t=u(a().mark((function e(){var t,i,s;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.jobQueue.length){e.next=2;break}return e.abrupt("return");case 2:if(t=this._getAvailableWorker()){e.next=5;break}return e.abrupt("return");case 5:if(!(i=this.jobQueue.shift())){e.next=18;break}return this.onDebug({message:"Starting job",name:i.name,workerThread:t,backlog:this.jobQueue.length}),s=new fb(i.name,t),t.onMessage=function(e){return i.onMessage(s,e.type,e.payload)},t.onError=function(e){return i.onError(s,e)},i.onStart(s),e.prev=12,e.next=15,s.result;case 15:return e.prev=15,this.returnWorkerToQueue(t),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[12,,15,18]])}))),function(){return t.apply(this,arguments)})},{key:"returnWorkerToQueue",value:function(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}},{key:"_getAvailableWorker",value:function(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count0&&void 0!==arguments[0]?arguments[0]:{};return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}}]),e}();pb(Cb,"_workerFarm",void 0);function Mb(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t[e.id]||{},s="".concat(e.id,"-worker.js"),r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r="modules/".concat(e.module,"/dist/").concat(s)),!r){var n=e.version;"latest"===n&&(n="latest");var o=n?"@".concat(n):"";r="https://unpkg.com/@loaders.gl/".concat(e.module).concat(o,"/dist/").concat(s)}return ab(r),r}function Fb(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"3.2.6";ab(e,"no worker provided");var i=e.version;return!(!t||!i)}var Eb=Object.freeze({__proto__:null,default:{}}),kb={};function Ib(e){return Db.apply(this,arguments)}function Db(){return Db=u(a().mark((function e(t){var i,s,r=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.length>1&&void 0!==r[1]?r[1]:null,s=r.length>2&&void 0!==r[2]?r[2]:{},i&&(t=Sb(t,i,s)),kb[t]=kb[t]||Tb(t),e.next=6,kb[t];case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)}))),Db.apply(this,arguments)}function Sb(e,t,i){if(e.startsWith("http"))return e;var s=i.modules||{};return s[e]?s[e]:Ab?i.CDN?(ab(i.CDN.startsWith("http")),"".concat(i.CDN,"/").concat(t,"@").concat("3.2.6","/dist/libs/").concat(e)):cb?"../src/libs/".concat(e):"modules/".concat(t,"/src/libs/").concat(e):"modules/".concat(t,"/dist/libs/").concat(e)}function Tb(e){return Rb.apply(this,arguments)}function Rb(){return(Rb=u(a().mark((function e(t){var i,s,r;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.endsWith("wasm")){e.next=7;break}return e.next=3,fetch(t);case 3:return i=e.sent,e.next=6,i.arrayBuffer();case 6:return e.abrupt("return",e.sent);case 7:if(Ab){e.next=20;break}if(e.prev=8,e.t0=Eb&&void 0,!e.t0){e.next=14;break}return e.next=13,(void 0)(t);case 13:e.t0=e.sent;case 14:return e.abrupt("return",e.t0);case 17:return e.prev=17,e.t1=e.catch(8),e.abrupt("return",null);case 20:if(!cb){e.next=22;break}return e.abrupt("return",importScripts(t));case 22:return e.next=24,fetch(t);case 24:return s=e.sent,e.next=27,s.text();case 27:return r=e.sent,e.abrupt("return",Lb(r,t));case 29:case"end":return e.stop()}}),e,null,[[8,17]])})))).apply(this,arguments)}function Lb(e,t){if(Ab){if(cb)return eval.call(ub,e),null;var i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}}function Ub(e,t){return!!Cb.isSupported()&&(!!(Ab||null!=t&&t._nodeWorkers)&&(e.worker&&(null==t?void 0:t.worker)))}function Ob(e,t,i,s,r){return Nb.apply(this,arguments)}function Nb(){return Nb=u(a().mark((function e(t,i,s,r,n){var o,l,u,A,c,h;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.id,l=Mb(t,s),u=Cb.getWorkerFarm(s),A=u.getWorkerPool({name:o,url:l}),s=JSON.parse(JSON.stringify(s)),r=JSON.parse(JSON.stringify(r||{})),e.next=8,A.startJob("process-on-worker",Qb.bind(null,n));case 8:return(c=e.sent).postMessage("process",{input:i,options:s,context:r}),e.next=12,c.result;case 12:return h=e.sent,e.next=15,h.result;case 15:return e.abrupt("return",e.sent);case 16:case"end":return e.stop()}}),e)}))),Nb.apply(this,arguments)}function Qb(e,t,i,s){return Vb.apply(this,arguments)}function Vb(){return(Vb=u(a().mark((function e(t,i,s,r){var n,o,l,u,A;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=s,e.next="done"===e.t0?3:"error"===e.t0?5:"process"===e.t0?7:20;break;case 3:return i.done(r),e.abrupt("break",21);case 5:return i.error(new Error(r.error)),e.abrupt("break",21);case 7:return n=r.id,o=r.input,l=r.options,e.prev=8,e.next=11,t(o,l);case 11:u=e.sent,i.postMessage("done",{id:n,result:u}),e.next=19;break;case 15:e.prev=15,e.t1=e.catch(8),A=e.t1 instanceof Error?e.t1.message:"unknown error",i.postMessage("error",{id:n,error:A});case 19:return e.abrupt("break",21);case 20:console.warn("parse-with-worker unknown message ".concat(s));case 21:case"end":return e.stop()}}),e,null,[[8,15]])})))).apply(this,arguments)}function Hb(e,t,i){if(e.byteLength<=t+i)return"";for(var s=new DataView(e),r="",n=0;n1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return Hb(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return Hb(e,0,t)}return""}(e),'"'))}}function Gb(e){return e&&"object"===w(e)&&e.isBuffer}function zb(e){if(Gb(e))return Gb(t=e)?new Uint8Array(t.buffer,t.byteOffset,t.length).slice().buffer:t;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){var i=e;return(new TextEncoder).encode(i).buffer}if(e&&"object"===w(e)&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Wb(){for(var e=arguments.length,t=new Array(e),i=0;i=0),rb(t>0),e+(t-1)&~(t-1)}function Jb(e,t,i){var s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{var r=e.byteOffset,n=e.byteLength;s=new Uint8Array(e.buffer||e.arrayBuffer,r,n)}return t.set(s,i),i+Xb(s.byteLength,4)}function Yb(e){return Zb.apply(this,arguments)}function Zb(){return(Zb=u(a().mark((function e(t){var i,s,r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=[],s=!1,r=!1,e.prev=3,o=I(t);case 5:return e.next=7,o.next();case 7:if(!(s=!(l=e.sent).done)){e.next=13;break}u=l.value,i.push(u);case 10:s=!1,e.next=5;break;case 13:e.next=19;break;case 15:e.prev=15,e.t0=e.catch(3),r=!0,n=e.t0;case 19:if(e.prev=19,e.prev=20,!s||null==o.return){e.next=24;break}return e.next=24,o.return();case 24:if(e.prev=24,!r){e.next=27;break}throw n;case 27:return e.finish(24);case 28:return e.finish(19);case 29:return e.abrupt("return",Wb.apply(void 0,i));case 30:case"end":return e.stop()}}),e,null,[[3,15,19,29],[20,,24,28]])})))).apply(this,arguments)}var qb={};function $b(e){for(var t in qb)if(e.startsWith(t)){var i=qb[t];e=e.replace(t,i)}return e.startsWith("http://")||e.startsWith("https://")||(e="".concat("").concat(e)),e}var eB=function(e){return"function"==typeof e},tB=function(e){return null!==e&&"object"===w(e)},iB=function(e){return tB(e)&&e.constructor==={}.constructor},sB=function(e){return e&&"function"==typeof e[Symbol.iterator]},rB=function(e){return e&&"function"==typeof e[Symbol.asyncIterator]},nB=function(e){return"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json},oB=function(e){return"undefined"!=typeof Blob&&e instanceof Blob},aB=function(e){return function(e){return"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||tB(e)&&eB(e.tee)&&eB(e.cancel)&&eB(e.getReader)}(e)||function(e){return tB(e)&&eB(e.read)&&eB(e.pipe)&&function(e){return"boolean"==typeof e}(e.readable)}(e)},lB=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,uB=/^([-\w.]+\/[-\w.+]+)/;function AB(e){var t=uB.exec(e);return t?t[1]:e}function cB(e){var t=lB.exec(e);return t?t[1]:""}var hB=/\?.*/;function dB(e){if(nB(e)){var t=fB(e.url||"");return{url:t,type:AB(e.headers.get("content-type")||"")||cB(t)}}return oB(e)?{url:fB(e.name||""),type:e.type||""}:"string"==typeof e?{url:fB(e),type:cB(e)}:{url:"",type:""}}function pB(e){return nB(e)?e.headers["content-length"]||-1:oB(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}function fB(e){return e.replace(hB,"")}function vB(e){return gB.apply(this,arguments)}function gB(){return(gB=u(a().mark((function e(t){var i,s,r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!nB(t)){e.next=2;break}return e.abrupt("return",t);case 2:return i={},(s=pB(t))>=0&&(i["content-length"]=String(s)),r=dB(t),n=r.url,(o=r.type)&&(i["content-type"]=o),e.next=9,BB(t);case 9:return(l=e.sent)&&(i["x-first-bytes"]=l),"string"==typeof t&&(t=(new TextEncoder).encode(t)),u=new Response(t,{headers:i}),Object.defineProperty(u,"url",{value:n}),e.abrupt("return",u);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mB(e){return _B.apply(this,arguments)}function _B(){return(_B=u(a().mark((function e(t){var i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.ok){e.next=5;break}return e.next=3,yB(t);case 3:throw i=e.sent,new Error(i);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yB(e){return bB.apply(this,arguments)}function bB(){return(bB=u(a().mark((function e(t){var i,s,r;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i="Failed to fetch resource ".concat(t.url," (").concat(t.status,"): "),e.prev=1,s=t.headers.get("Content-Type"),r=t.statusText,!s.includes("application/json")){e.next=11;break}return e.t0=r,e.t1=" ",e.next=9,t.text();case 9:e.t2=e.sent,r=e.t0+=e.t1.concat.call(e.t1,e.t2);case 11:i=(i+=r).length>60?"".concat(i.slice(0,60),"..."):i,e.next=17;break;case 15:e.prev=15,e.t3=e.catch(1);case 17:return e.abrupt("return",i);case 18:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function BB(e){return wB.apply(this,arguments)}function wB(){return(wB=u(a().mark((function e(t){var i,s,r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=5,"string"!=typeof t){e.next=3;break}return e.abrupt("return","data:,".concat(t.slice(0,i)));case 3:if(!(t instanceof Blob)){e.next=8;break}return s=t.slice(0,5),e.next=7,new Promise((function(e){var t=new FileReader;t.onload=function(t){var i;return e(null==t||null===(i=t.target)||void 0===i?void 0:i.result)},t.readAsDataURL(s)}));case 7:return e.abrupt("return",e.sent);case 8:if(!(t instanceof ArrayBuffer)){e.next=12;break}return r=t.slice(0,i),n=xB(r),e.abrupt("return","data:base64,".concat(n));case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xB(e){for(var t="",i=new Uint8Array(e),s=0;s=0)}();function DB(e){try{var t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}var SB=function(){function e(t,i){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";x(this,e),this.storage=DB(s),this.id=t,this.config={},Object.assign(this.config,i),this._loadConfiguration()}return C(e,[{key:"getConfiguration",value:function(){return this.config}},{key:"setConfiguration",value:function(e){return this.config={},this.updateConfiguration(e)}},{key:"updateConfiguration",value:function(e){if(Object.assign(this.config,e),this.storage){var t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}},{key:"_loadConfiguration",value:function(){var e={};if(this.storage){var t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}]),e}();function TB(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600,r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));var n=e.width*i,o=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(n/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(r,");"),"background-size:".concat(n,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}var RB={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function LB(e){return"string"==typeof e?RB[e.toUpperCase()]||RB.WHITE:e}function UB(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"],s=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(s),n=c(r);try{var o=function(){var s=t.value;"function"==typeof e[s]&&(i.find((function(e){return s===e}))||(e[s]=e[s].bind(e)))};for(n.s();!(t=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function OB(e,t){if(!e)throw new Error(t||"Assertion failed")}function NB(){var e;if(IB&&FB.performance)e=FB.performance.now();else if(EB.hrtime){var t=EB.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}var QB={debug:IB&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},VB={enabled:!0,level:0};function HB(){}var jB={},GB={once:!0};function zB(e){for(var t in e)for(var i in e[t])return i||"untitled";return"empty"}var WB=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""},i=t.id;x(this,e),this.id=i,this.VERSION=kB,this._startTs=NB(),this._deltaTs=NB(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new SB("__probe-".concat(this.id,"__"),VB),this.userData={},this.timeStamp("".concat(this.id," started")),UB(this),Object.seal(this)}return C(e,[{key:"level",get:function(){return this.getLevel()},set:function(e){this.setLevel(e)}},{key:"isEnabled",value:function(){return this._storage.config.enabled}},{key:"getLevel",value:function(){return this._storage.config.level}},{key:"getTotal",value:function(){return Number((NB()-this._startTs).toPrecision(10))}},{key:"getDelta",value:function(){return Number((NB()-this._deltaTs).toPrecision(10))}},{key:"priority",get:function(){return this.level},set:function(e){this.level=e}},{key:"getPriority",value:function(){return this.level}},{key:"enable",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}},{key:"setLevel",value:function(e){return this._storage.updateConfiguration({level:e}),this}},{key:"assert",value:function(e,t){OB(e,t)}},{key:"warn",value:function(e){return this._getLogFunction(0,e,QB.warn,arguments,GB)}},{key:"error",value:function(e){return this._getLogFunction(0,e,QB.error,arguments)}},{key:"deprecated",value:function(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}},{key:"removed",value:function(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}},{key:"probe",value:function(e,t){return this._getLogFunction(e,t,QB.log,arguments,{time:!0,once:!0})}},{key:"log",value:function(e,t){return this._getLogFunction(e,t,QB.debug,arguments)}},{key:"info",value:function(e,t){return this._getLogFunction(e,t,console.info,arguments)}},{key:"once",value:function(e,t){return this._getLogFunction(e,t,QB.debug||QB.info,arguments,GB)}},{key:"table",value:function(e,t,i){return t?this._getLogFunction(e,t,console.table||HB,i&&[i],{tag:zB(t)}):HB}},{key:"image",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){var t=e.logLevel,i=e.priority,s=e.image,r=e.message,n=void 0===r?"":r,o=e.scale,a=void 0===o?1:o;return this._shouldLog(t||i)?IB?function(e){var t=e.image,i=e.message,s=void 0===i?"":i,r=e.scale,n=void 0===r?1:r;if("string"==typeof t){var o=new Image;return o.onload=function(){var e,t=TB(o,s,n);(e=console).log.apply(e,A(t))},o.src=t,HB}var a=t.nodeName||"";if("img"===a.toLowerCase()){var l;return(l=console).log.apply(l,A(TB(t,s,n))),HB}if("canvas"===a.toLowerCase()){var u=new Image;return u.onload=function(){var e;return(e=console).log.apply(e,A(TB(u,s,n)))},u.src=t.toDataURL(),HB}return HB}({image:s,message:n,scale:a}):function(e){var t=e.image,i=(e.message,e.scale),s=void 0===i?1:i,r=null;try{r=module.require("asciify-image")}catch(e){}if(r)return function(){return r(t,{fit:"box",width:"".concat(Math.round(80*s),"%")}).then((function(e){return console.log(e)}))};return HB}({image:s,message:n,scale:a}):HB}))},{key:"settings",value:function(){console.table?console.table(this._storage.config):console.log(this._storage.config)}},{key:"get",value:function(e){return this._storage.config[e]}},{key:"set",value:function(e,t){this._storage.updateConfiguration(o({},e,t))}},{key:"time",value:function(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}},{key:"timeEnd",value:function(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}},{key:"timeStamp",value:function(e,t){return this._getLogFunction(e,t,console.timeStamp||HB)}},{key:"group",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1},s=i=XB({logLevel:e,message:t,opts:i}),r=s.collapsed;return i.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}},{key:"groupCollapsed",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},i,{collapsed:!0}))}},{key:"groupEnd",value:function(e){return this._getLogFunction(e,"",console.groupEnd||HB)}},{key:"withGroup",value:function(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}},{key:"trace",value:function(){console.trace&&console.trace()}},{key:"_shouldLog",value:function(e){return this.isEnabled()&&this.getLevel()>=KB(e)}},{key:"_getLogFunction",value:function(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],r=arguments.length>4?arguments[4]:void 0;if(this._shouldLog(e)){var n;r=XB({logLevel:e,message:t,args:s,opts:r}),OB(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=NB();var o=r.tag||r.message;if(r.once){if(jB[o])return HB;jB[o]=NB()}return t=JB(this.id,r.message,r),(n=i).bind.apply(n,[console,t].concat(A(r.args)))}return HB}}]),e}();function KB(e){if(!e)return 0;var t;switch(w(e)){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return OB(Number.isFinite(t)&&t>=0),t}function XB(e){var t=e.logLevel,i=e.message;e.logLevel=KB(t);for(var s=e.args?Array.from(e.args):[];s.length&&s.shift()!==i;);switch(e.args=s,w(t)){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());var r=w(e.message);return OB("string"===r||"object"===r),Object.assign(e,e.opts)}function JB(e,t,i){if("string"==typeof t){var s=i.time?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8,i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}((r=i.total)<10?"".concat(r.toFixed(2),"ms"):r<100?"".concat(r.toFixed(1),"ms"):r<1e3?"".concat(r.toFixed(0),"ms"):"".concat((r/1e3).toFixed(2),"s")):"";t=function(e,t,i){return IB||"string"!=typeof e||(t&&(t=LB(t),e="[".concat(t,"m").concat(e,"")),i&&(t=LB(i),e="[".concat(i+10,"m").concat(e,""))),e}(t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),i.color,i.background)}var r;return t}WB.VERSION=kB;var YB=new WB({id:"loaders.gl"}),ZB=function(){function e(){x(this,e)}return C(e,[{key:"log",value:function(){return function(){}}},{key:"info",value:function(){return function(){}}},{key:"warn",value:function(){return function(){}}},{key:"error",value:function(){return function(){}}}]),e}(),qB={fetch:null,mimeType:void 0,nothrow:!1,log:new(function(){function e(){x(this,e),pb(this,"console",void 0),this.console=console}return C(e,[{key:"log",value:function(){for(var e,t=arguments.length,i=new Array(t),s=0;s=0)}()}var cw={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"===("undefined"==typeof process?"undefined":w(process))&&process},hw=cw.window||cw.self||cw.global,dw=cw.process||{},pw="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";function fw(e){try{var t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}Aw();var vw,gw=function(){function e(t){x(this,e);var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";pb(this,"storage",void 0),pb(this,"id",void 0),pb(this,"config",{}),this.storage=fw(s),this.id=t,this.config={},Object.assign(this.config,i),this._loadConfiguration()}return C(e,[{key:"getConfiguration",value:function(){return this.config}},{key:"setConfiguration",value:function(e){return this.config={},this.updateConfiguration(e)}},{key:"updateConfiguration",value:function(e){if(Object.assign(this.config,e),this.storage){var t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}},{key:"_loadConfiguration",value:function(){var e={};if(this.storage){var t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}]),e}();function mw(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600,r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));var n=e.width*i,o=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(n/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(r,");"),"background-size:".concat(n,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}function _w(e){return"string"==typeof e?vw[e.toUpperCase()]||vw.WHITE:e}function yw(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"],s=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(s),n=c(r);try{var o=function(){var s=t.value;"function"==typeof e[s]&&(i.find((function(e){return s===e}))||(e[s]=e[s].bind(e)))};for(n.s();!(t=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function bw(e,t){if(!e)throw new Error(t||"Assertion failed")}function Bw(){var e,t,i;if(Aw&&"performance"in hw)e=null==hw||null===(t=hw.performance)||void 0===t||null===(i=t.now)||void 0===i?void 0:i.call(t);else if("hrtime"in dw){var s,r=null==dw||null===(s=dw.hrtime)||void 0===s?void 0:s.call(dw);e=1e3*r[0]+r[1]/1e6}else e=Date.now();return e}!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(vw||(vw={}));var ww={debug:Aw&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},xw={enabled:!0,level:0};function Pw(){}var Cw={},Mw={once:!0},Fw=function(){function e(){x(this,e);var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""},i=t.id;pb(this,"id",void 0),pb(this,"VERSION",pw),pb(this,"_startTs",Bw()),pb(this,"_deltaTs",Bw()),pb(this,"_storage",void 0),pb(this,"userData",{}),pb(this,"LOG_THROTTLE_TIMEOUT",0),this.id=i,this._storage=new gw("__probe-".concat(this.id,"__"),xw),this.userData={},this.timeStamp("".concat(this.id," started")),yw(this),Object.seal(this)}return C(e,[{key:"level",get:function(){return this.getLevel()},set:function(e){this.setLevel(e)}},{key:"isEnabled",value:function(){return this._storage.config.enabled}},{key:"getLevel",value:function(){return this._storage.config.level}},{key:"getTotal",value:function(){return Number((Bw()-this._startTs).toPrecision(10))}},{key:"getDelta",value:function(){return Number((Bw()-this._deltaTs).toPrecision(10))}},{key:"priority",get:function(){return this.level},set:function(e){this.level=e}},{key:"getPriority",value:function(){return this.level}},{key:"enable",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}},{key:"setLevel",value:function(e){return this._storage.updateConfiguration({level:e}),this}},{key:"get",value:function(e){return this._storage.config[e]}},{key:"set",value:function(e,t){this._storage.updateConfiguration(o({},e,t))}},{key:"settings",value:function(){console.table?console.table(this._storage.config):console.log(this._storage.config)}},{key:"assert",value:function(e,t){bw(e,t)}},{key:"warn",value:function(e){return this._getLogFunction(0,e,ww.warn,arguments,Mw)}},{key:"error",value:function(e){return this._getLogFunction(0,e,ww.error,arguments)}},{key:"deprecated",value:function(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}},{key:"removed",value:function(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}},{key:"probe",value:function(e,t){return this._getLogFunction(e,t,ww.log,arguments,{time:!0,once:!0})}},{key:"log",value:function(e,t){return this._getLogFunction(e,t,ww.debug,arguments)}},{key:"info",value:function(e,t){return this._getLogFunction(e,t,console.info,arguments)}},{key:"once",value:function(e,t){for(var i=arguments.length,s=new Array(i>2?i-2:0),r=2;r2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1},s=kw({logLevel:e,message:t,opts:i}),r=i.collapsed;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}},{key:"groupCollapsed",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},i,{collapsed:!0}))}},{key:"groupEnd",value:function(e){return this._getLogFunction(e,"",console.groupEnd||Pw)}},{key:"withGroup",value:function(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}},{key:"trace",value:function(){console.trace&&console.trace()}},{key:"_shouldLog",value:function(e){return this.isEnabled()&&this.getLevel()>=Ew(e)}},{key:"_getLogFunction",value:function(e,t,i,s,r){if(this._shouldLog(e)){var n;r=kw({logLevel:e,message:t,args:s,opts:r}),bw(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Bw();var o=r.tag||r.message;if(r.once){if(Cw[o])return Pw;Cw[o]=Bw()}return t=function(e,t,i){if("string"==typeof t){var s=i.time?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8,i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}((r=i.total)<10?"".concat(r.toFixed(2),"ms"):r<100?"".concat(r.toFixed(1),"ms"):r<1e3?"".concat(r.toFixed(0),"ms"):"".concat((r/1e3).toFixed(2),"s")):"";t=function(e,t,i){return Aw||"string"!=typeof e||(t&&(t=_w(t),e="[".concat(t,"m").concat(e,"")),i&&(t=_w(i),e="[".concat(i+10,"m").concat(e,""))),e}(t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),i.color,i.background)}var r;return t}(this.id,r.message,r),(n=i).bind.apply(n,[console,t].concat(A(r.args)))}return Pw}}]),e}();function Ew(e){if(!e)return 0;var t;switch(w(e)){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return bw(Number.isFinite(t)&&t>=0),t}function kw(e){var t=e.logLevel,i=e.message;e.logLevel=Ew(t);for(var s=e.args?Array.from(e.args):[];s.length&&s.shift()!==i;);switch(w(t)){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());var r=w(e.message);return bw("string"===r||"object"===r),Object.assign(e,{args:s},e.opts)}function Iw(e){for(var t in e)for(var i in e[t])return i||"untitled";return"empty"}pb(Fw,"VERSION",pw);var Dw=new Fw({id:"loaders.gl"}),Sw=/\.([^.]+)$/;function Tw(e){return Rw.apply(this,arguments)}function Rw(){return Rw=u(a().mark((function e(t){var i,s,r,o,l=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=l.length>1&&void 0!==l[1]?l[1]:[],s=l.length>2?l[2]:void 0,r=l.length>3?l[3]:void 0,Ow(t)){e.next=5;break}return e.abrupt("return",null);case 5:if(!(o=Lw(t,i,n(n({},s),{},{nothrow:!0}),r))){e.next=8;break}return e.abrupt("return",o);case 8:if(!oB(t)){e.next=13;break}return e.next=11,t.slice(0,10).arrayBuffer();case 11:t=e.sent,o=Lw(t,i,s,r);case 13:if(o||null!=s&&s.nothrow){e.next=15;break}throw new Error(Nw(t));case 15:return e.abrupt("return",o);case 16:case"end":return e.stop()}}),e)}))),Rw.apply(this,arguments)}function Lw(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;if(!Ow(e))return null;if(t&&!Array.isArray(t))return lw(t);var r,n=[];(t&&(n=n.concat(t)),null!=i&&i.ignoreRegisteredLoaders)||(r=n).push.apply(r,A(uw()));Qw(n);var o=Uw(e,n,i,s);if(!(o||null!=i&&i.nothrow))throw new Error(Nw(e));return o}function Uw(e,t,i,s){var r,n=dB(e),o=n.url,a=n.type,l=o||(null==s?void 0:s.url),u=null,A="";(null!=i&&i.mimeType&&(u=Vw(t,null==i?void 0:i.mimeType),A="match forced by supplied MIME type ".concat(null==i?void 0:i.mimeType)),u=u||function(e,t){var i=t&&Sw.exec(t),s=i&&i[1];return s?function(e,t){t=t.toLowerCase();var i,s=c(e);try{for(s.s();!(i=s.n()).done;){var r,n=i.value,o=c(n.extensions);try{for(o.s();!(r=o.n()).done;){if(r.value.toLowerCase()===t)return n}}catch(e){o.e(e)}finally{o.f()}}}catch(e){s.e(e)}finally{s.f()}return null}(e,s):null}(t,l),A=A||(u?"matched url ".concat(l):""),u=u||Vw(t,a),A=A||(u?"matched MIME type ".concat(a):""),u=u||function(e,t){if(!t)return null;var i,s=c(e);try{for(s.s();!(i=s.n()).done;){var r=i.value;if("string"==typeof t){if(Hw(t,r))return r}else if(ArrayBuffer.isView(t)){if(jw(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer){if(jw(t,0,r))return r}}}catch(e){s.e(e)}finally{s.f()}return null}(t,e),A=A||(u?"matched initial data ".concat(Gw(e)):""),u=u||Vw(t,null==i?void 0:i.fallbackMimeType),A=A||(u?"matched fallback MIME type ".concat(a):""))&&Dw.log(1,"selectLoader selected ".concat(null===(r=u)||void 0===r?void 0:r.name,": ").concat(A,"."));return u}function Ow(e){return!(e instanceof Response&&204===e.status)}function Nw(e){var t=dB(e),i=t.url,s=t.type,r="No valid loader found (";r+=i?"".concat(function(e){var t=e&&e.lastIndexOf("/");return t>=0?e.substr(t+1):""}(i),", "):"no url provided, ",r+="MIME type: ".concat(s?'"'.concat(s,'"'):"not provided",", ");var n=e?Gw(e):"";return r+=n?' first bytes: "'.concat(n,'"'):"first bytes: not available",r+=")"}function Qw(e){var t,i=c(e);try{for(i.s();!(t=i.n()).done;){lw(t.value)}}catch(e){i.e(e)}finally{i.f()}}function Vw(e,t){var i,s=c(e);try{for(s.s();!(i=s.n()).done;){var r=i.value;if(r.mimeTypes&&r.mimeTypes.includes(t))return r;if(t==="application/x.".concat(r.id))return r}}catch(e){s.e(e)}finally{s.f()}return null}function Hw(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some((function(t){return e.startsWith(t)}))}function jw(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some((function(s){return function(e,t,i,s){if(s instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLength1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return zw(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){var i=0;return zw(e,i,t)}return""}function zw(e,t,i){if(e.byteLength1&&void 0!==A[1]?A[1]:{},s=t.chunkSize,r=void 0===s?262144:s,n=0;case 3:if(!(n2&&void 0!==arguments[2]?arguments[2]:null;if(i)return i;var s=n({fetch:sw(t,e)},e);return Array.isArray(s.loaders)||(s.loaders=null),s}function rx(e,t){if(!t&&e&&!Array.isArray(e))return e;var i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){var s=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[].concat(A(i),A(s)):s}return i&&i.length?i:null}function nx(e,t,i,s){return ox.apply(this,arguments)}function ox(){return(ox=u(a().mark((function e(t,i,s,r){var n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ab(!r||"object"===w(r)),!i||Array.isArray(i)||aw(i)||(r=void 0,s=i,i=void 0),e.next=4,t;case 4:return t=e.sent,s=s||{},n=dB(t),o=n.url,l=rx(i,r),e.next=11,Tw(t,l,s);case 11:if(u=e.sent){e.next=14;break}return e.abrupt("return",null);case 14:return s=iw(s,u,l,o),r=sx({url:o,parse:nx,loaders:l},s,r),e.next=18,ax(u,t,s,r);case 18:return e.abrupt("return",e.sent);case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ax(e,t,i,s){return lx.apply(this,arguments)}function lx(){return(lx=u(a().mark((function e(t,i,s,r){var n,o,l,u,A,c,h,d;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Fb(t),nB(i)&&(o=(n=i).ok,l=n.redirected,u=n.status,A=n.statusText,c=n.type,h=n.url,d=Object.fromEntries(n.headers.entries()),r.response={headers:d,ok:o,redirected:l,status:u,statusText:A,type:c,url:h}),e.next=4,tx(i,t,s);case 4:if(i=e.sent,!t.parseTextSync||"string"!=typeof i){e.next=8;break}return s.dataType="text",e.abrupt("return",t.parseTextSync(i,s,r,t));case 8:if(!Ub(t,s)){e.next=12;break}return e.next=11,Ob(t,i,s,r,nx);case 11:case 15:case 19:return e.abrupt("return",e.sent);case 12:if(!t.parseText||"string"!=typeof i){e.next=16;break}return e.next=15,t.parseText(i,s,r,t);case 16:if(!t.parse){e.next=20;break}return e.next=19,t.parse(i,s,r,t);case 20:throw ab(!t.parseSync),new Error("".concat(t.id," loader - no parser found and worker is disabled"));case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ux,Ax,cx="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.wasm"),hx="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.js");function dx(e){return px.apply(this,arguments)}function px(){return(px=u(a().mark((function e(t){var i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(i=t.modules||{}).basis){e.next=3;break}return e.abrupt("return",i.basis);case 3:return ux=ux||fx(t),e.next=6,ux;case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fx(e){return vx.apply(this,arguments)}function vx(){return(vx=u(a().mark((function e(t){var i,s,r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null,s=null,e.t0=Promise,e.next=5,Ib("basis_transcoder.js","textures",t);case 5:return e.t1=e.sent,e.next=8,Ib("basis_transcoder.wasm","textures",t);case 8:return e.t2=e.sent,e.t3=[e.t1,e.t2],e.next=12,e.t0.all.call(e.t0,e.t3);case 12:return r=e.sent,n=h(r,2),i=n[0],s=n[1],i=i||globalThis.BASIS,e.next=19,gx(i,s);case 19:return e.abrupt("return",e.sent);case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function gx(e,t){var i={};return t&&(i.wasmBinary=t),new Promise((function(t){e(i).then((function(e){var i=e.BasisFile;(0,e.initializeBasis)(),t({BasisFile:i})}))}))}function mx(e){return _x.apply(this,arguments)}function _x(){return(_x=u(a().mark((function e(t){var i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(i=t.modules||{}).basisEncoder){e.next=3;break}return e.abrupt("return",i.basisEncoder);case 3:return Ax=Ax||yx(t),e.next=6,Ax;case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yx(e){return bx.apply(this,arguments)}function bx(){return(bx=u(a().mark((function e(t){var i,s,r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null,s=null,e.t0=Promise,e.next=5,Ib(hx,"textures",t);case 5:return e.t1=e.sent,e.next=8,Ib(cx,"textures",t);case 8:return e.t2=e.sent,e.t3=[e.t1,e.t2],e.next=12,e.t0.all.call(e.t0,e.t3);case 12:return r=e.sent,n=h(r,2),i=n[0],s=n[1],i=i||globalThis.BASIS,e.next=19,Bx(i,s);case 19:return e.abrupt("return",e.sent);case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Bx(e,t){var i={};return t&&(i.wasmBinary=t),new Promise((function(t){e(i).then((function(e){var i=e.BasisFile,s=e.KTX2File,r=e.initializeBasis,n=e.BasisEncoder;r(),t({BasisFile:i,KTX2File:s,BasisEncoder:n})}))}))}var wx,xx,Px,Cx,Mx,Fx,Ex,kx,Ix,Dx=33776,Sx=33779,Tx=35840,Rx=35842,Lx=36196,Ux=37808,Ox=["","WEBKIT_","MOZ_"],Nx={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"},Qx=null;function Vx(e){if(!Qx){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Qx=new Set;var t,i=c(Ox);try{for(i.s();!(t=i.n()).done;){var s=t.value;for(var r in Nx)if(e&&e.getExtension("".concat(s).concat(r))){var n=Nx[r];Qx.add(n)}}}catch(e){i.e(e)}finally{i.f()}}return Qx}(Ix=wx||(wx={}))[Ix.NONE=0]="NONE",Ix[Ix.BASISLZ=1]="BASISLZ",Ix[Ix.ZSTD=2]="ZSTD",Ix[Ix.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(xx||(xx={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(Px||(Px={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(Cx||(Cx={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(Mx||(Mx={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(Fx||(Fx={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(Ex||(Ex={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(kx||(kx={}));var Hx=[171,75,84,88,32,50,48,187,13,10,26,10];function jx(e){var t=new Uint8Array(e);return!(t.byteLength1&&void 0!==s[1]?s[1]:null)&&vP||(i=null),!i){e.next=13;break}return e.prev=3,e.next=6,createImageBitmap(t,i);case 6:return e.abrupt("return",e.sent);case 9:e.prev=9,e.t0=e.catch(3),console.warn(e.t0),vP=!1;case 13:return e.next=15,createImageBitmap(t);case 15:return e.abrupt("return",e.sent);case 16:case"end":return e.stop()}}),e,null,[[3,9]])}))),yP.apply(this,arguments)}function bP(e){for(var t in e||fP)return!1;return!0}function BP(e){var t=wP(e);return function(e){var t=wP(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,false)))return null;return{mimeType:"image/png",width:t.getUint32(16,false),height:t.getUint32(20,false)}}(t)||function(e){var t=wP(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,false)&&255===t.getUint8(2)))return null;var i=function(){for(var e=new Set([65499,65476,65484,65501,65534]),t=65504;t<65520;++t)e.add(t);var i=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:i}}(),s=i.tableMarkers,r=i.sofMarkers,n=2;for(;n+9=10&&1195984440===t.getUint32(0,false)))return null;return{mimeType:"image/gif",width:t.getUint16(6,true),height:t.getUint16(8,true)}}(t)||function(e){var t=wP(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,false)&&t.getUint32(2,true)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,true),height:t.getUint32(22,true)}}(t)}function wP(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}function xP(e,t){return PP.apply(this,arguments)}function PP(){return PP=u(a().mark((function e(t,i){var s,r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=BP(t)||{},r=s.mimeType,rb(n=globalThis._parseImageNode),e.next=5,n(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)}))),PP.apply(this,arguments)}function CP(){return(CP=u(a().mark((function e(t,i,s){var r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=(i=i||{}).image||{},n=r.type||"auto",o=(s||{}).url,l=MP(n),e.t0=l,e.next="imagebitmap"===e.t0?8:"image"===e.t0?12:"data"===e.t0?16:20;break;case 8:return e.next=10,gP(t,i,o);case 10:return u=e.sent,e.abrupt("break",21);case 12:return e.next=14,cP(t,i,o);case 14:return u=e.sent,e.abrupt("break",21);case 16:return e.next=18,xP(t);case 18:return u=e.sent,e.abrupt("break",21);case 20:rb(!1);case 21:return"data"===n&&(u=nP(u)),e.abrupt("return",u);case 23:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function MP(e){switch(e){case"auto":case"data":return function(){if(tP)return"imagebitmap";if(eP)return"image";if(sP)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return tP||eP||sP;case"imagebitmap":return tP;case"image":return eP;case"data":return sP;default:throw new Error("@loaders.gl/images: image ".concat(e," not supported in this environment"))}}(e),e}}var FP={id:"image",module:"images",name:"Images",version:"3.2.6",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:function(e,t,i){return CP.apply(this,arguments)},tests:[function(e){return Boolean(BP(new DataView(e)))}],options:{image:{type:"auto",decode:!0}}},EP=["image/png","image/jpeg","image/gif"],kP={};function IP(e){return void 0===kP[e]&&(kP[e]=function(e){switch(e){case"image/webp":return function(){if(!nb)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch(e){return!1}}();case"image/svg":return nb;default:if(!nb){var t=globalThis._parseImageNode;return Boolean(t)&&EP.includes(e)}return!0}}(e)),kP[e]}function DP(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function SP(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;var i=t.baseUri||t.uri;if(!i)throw new Error("'baseUri' must be provided to resolve relative url ".concat(e));return i.substr(0,i.lastIndexOf("/")+1)+e}function TP(e,t,i){var s=e.bufferViews[i];DP(s);var r=t[s.buffer];DP(r);var n=(s.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,n,s.byteLength)}var RP=["SCALAR","VEC2","VEC3","VEC4"],LP=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],UP=new Map(LP),OP={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},NP={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},QP={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function VP(e){return RP[e-1]||RP[0]}function HP(e){var t=UP.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function jP(e,t){var i=QP[e.componentType],s=OP[e.type],r=NP[e.componentType],n=e.count*s,o=e.count*s*r;return DP(o>=0&&o<=t.byteLength),{ArrayType:i,length:n,byteLength:o}}var GP,zP={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]},WP=function(){function e(t){x(this,e),pb(this,"gltf",void 0),pb(this,"sourceBuffers",void 0),pb(this,"byteLength",void 0),this.gltf=t||{json:n({},zP),buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}return C(e,[{key:"json",get:function(){return this.gltf.json}},{key:"getApplicationData",value:function(e){return this.json[e]}},{key:"getExtraData",value:function(e){return(this.json.extras||{})[e]}},{key:"getExtension",value:function(e){var t=this.getUsedExtensions().find((function(t){return t===e})),i=this.json.extensions||{};return t?i[e]||!0:null}},{key:"getRequiredExtension",value:function(e){var t=this.getRequiredExtensions().find((function(t){return t===e}));return t?this.getExtension(e):null}},{key:"getRequiredExtensions",value:function(){return this.json.extensionsRequired||[]}},{key:"getUsedExtensions",value:function(){return this.json.extensionsUsed||[]}},{key:"getObjectExtension",value:function(e,t){return(e.extensions||{})[t]}},{key:"getScene",value:function(e){return this.getObject("scenes",e)}},{key:"getNode",value:function(e){return this.getObject("nodes",e)}},{key:"getSkin",value:function(e){return this.getObject("skins",e)}},{key:"getMesh",value:function(e){return this.getObject("meshes",e)}},{key:"getMaterial",value:function(e){return this.getObject("materials",e)}},{key:"getAccessor",value:function(e){return this.getObject("accessors",e)}},{key:"getTexture",value:function(e){return this.getObject("textures",e)}},{key:"getSampler",value:function(e){return this.getObject("samplers",e)}},{key:"getImage",value:function(e){return this.getObject("images",e)}},{key:"getBufferView",value:function(e){return this.getObject("bufferViews",e)}},{key:"getBuffer",value:function(e){return this.getObject("buffers",e)}},{key:"getObject",value:function(e,t){if("object"===w(t))return t;var i=this.json[e]&&this.json[e][t];if(!i)throw new Error("glTF file error: Could not find ".concat(e,"[").concat(t,"]"));return i}},{key:"getTypedArrayForBufferView",value:function(e){var t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];DP(i);var s=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,e.byteLength)}},{key:"getTypedArrayForAccessor",value:function(e){e=this.getAccessor(e);var t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,s=jP(e,t),r=s.ArrayType,n=s.length;return new r(i,t.byteOffset+e.byteOffset,n)}},{key:"getTypedArrayForImageData",value:function(e){e=this.getAccessor(e);var t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(i,s,t.byteLength)}},{key:"addApplicationData",value:function(e,t){return this.json[e]=t,this}},{key:"addExtraData",value:function(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}},{key:"addObjectExtension",value:function(e,t,i){return e.extensions=e.extensions||{},e.extensions[t]=i,this.registerUsedExtension(t),this}},{key:"setObjectExtension",value:function(e,t,i){(e.extensions||{})[t]=i}},{key:"removeObjectExtension",value:function(e,t){var i=e.extensions||{},s=i[t];return delete i[t],s}},{key:"addExtension",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return DP(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}},{key:"addRequiredExtension",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return DP(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}},{key:"registerUsedExtension",value:function(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((function(t){return t===e}))||this.json.extensionsUsed.push(e)}},{key:"registerRequiredExtension",value:function(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((function(t){return t===e}))||this.json.extensionsRequired.push(e)}},{key:"removeExtension",value:function(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}},{key:"setDefaultScene",value:function(e){this.json.scene=e}},{key:"addScene",value:function(e){var t=e.nodeIndices;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}},{key:"addNode",value:function(e){var t=e.meshIndex,i=e.matrix;this.json.nodes=this.json.nodes||[];var s={mesh:t};return i&&(s.matrix=i),this.json.nodes.push(s),this.json.nodes.length-1}},{key:"addMesh",value:function(e){var t=e.attributes,i=e.indices,s=e.material,r=e.mode,n=void 0===r?4:r,o={primitives:[{attributes:this._addAttributes(t),mode:n}]};if(i){var a=this._addIndices(i);o.primitives[0].indices=a}return Number.isFinite(s)&&(o.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}},{key:"addPointCloud",value:function(e){var t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}},{key:"addImage",value:function(e,t){var i=BP(e),s=t||(null==i?void 0:i.mimeType),r={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}},{key:"addBufferView",value:function(e){var t=e.byteLength;DP(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);var i={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=Xb(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}},{key:"addAccessor",value:function(e,t){var i={bufferView:e,type:VP(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}},{key:"addBinaryBuffer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{size:3},i=this.addBufferView(e),s={min:t.min,max:t.max};s.min&&s.max||(s=this._getAccessorMinMax(e,t.size));var r={size:t.size,componentType:HP(e),count:Math.round(e.length/t.size),min:s.min,max:s.max};return this.addAccessor(i,Object.assign(r,t))}},{key:"addTexture",value:function(e){var t={source:e.imageIndex};return this.json.textures=this.json.textures||[],this.json.textures.push(t),this.json.textures.length-1}},{key:"addMaterial",value:function(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}},{key:"createBinaryChunk",value:function(){var e,t;this.gltf.buffers=[];var i,s=this.byteLength,r=new ArrayBuffer(s),n=new Uint8Array(r),o=0,a=c(this.sourceBuffers||[]);try{for(a.s();!(i=a.n()).done;){o=Jb(i.value,n,o)}}catch(e){a.e(e)}finally{a.f()}null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=s:this.json.buffers=[{byteLength:s}],this.gltf.binary=r,this.sourceBuffers=[r]}},{key:"_removeStringFromArray",value:function(e,t){for(var i=!0;i;){var s=e.indexOf(t);s>-1?e.splice(s,1):i=!1}}},{key:"_addAttributes",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};for(var i in e){var s=e[i],r=this._getGltfAttributeName(i),n=this.addBinaryBuffer(s.value,s);t[r]=n}return t}},{key:"_addIndices",value:function(e){return this.addBinaryBuffer(e,{size:1})}},{key:"_getGltfAttributeName",value:function(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}},{key:"_getAccessorMinMax",value:function(e,t){var i={min:null,max:null};if(e.length5&&void 0!==u[5]?u[5]:"NONE",e.next=3,tC();case 3:oC(l=e.sent,l.exports[qP[n]],t,i,s,r,l.exports[ZP[o||"NONE"]]);case 5:case"end":return e.stop()}}),e)}))),eC.apply(this,arguments)}function tC(){return iC.apply(this,arguments)}function iC(){return(iC=u(a().mark((function e(){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GP||(GP=sC()),e.abrupt("return",GP);case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function sC(){return rC.apply(this,arguments)}function rC(){return(rC=u(a().mark((function e(){var t,i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=KP,WebAssembly.validate(JP)&&(t=XP,console.log("Warning: meshopt_decoder is using experimental SIMD support")),e.next=4,WebAssembly.instantiate(nC(t),{});case 4:return i=e.sent,e.next=7,i.instance.exports.__wasm_call_ctors();case 7:return e.abrupt("return",i.instance);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function nC(e){for(var t=new Uint8Array(e.length),i=0;i96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}for(var r=0,n=0;nr?A:r,n=c>n?c:n,o=h>o?h:o}return[[t,i,s],[r,n,o]]}var fC=function(){function e(t,i){x(this,e),pb(this,"fields",void 0),pb(this,"metadata",void 0),function(e,t){if(!e)throw new Error(t||"loader assertion failed.")}(Array.isArray(t)),function(e){var t,i={},s=c(e);try{for(s.s();!(t=s.n()).done;){var r=t.value;i[r.name]&&console.warn("Schema: duplicated field name",r.name,r),i[r.name]=!0}}catch(e){s.e(e)}finally{s.f()}}(t),this.fields=t,this.metadata=i||new Map}return C(e,[{key:"compareTo",value:function(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(var t=0;t2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Map;x(this,e),pb(this,"name",void 0),pb(this,"type",void 0),pb(this,"nullable",void 0),pb(this,"metadata",void 0),this.name=t,this.type=i,this.nullable=s,this.metadata=r}return C(e,[{key:"typeId",get:function(){return this.type&&this.type.typeId}},{key:"clone",value:function(){return new e(this.name,this.type,this.nullable,this.metadata)}},{key:"compareTo",value:function(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}},{key:"toString",value:function(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(gC||(gC={}));var _C=function(){function e(){x(this,e)}return C(e,[{key:"typeId",get:function(){return gC.NONE}},{key:"compareTo",value:function(e){return this===e}}],[{key:"isNull",value:function(e){return e&&e.typeId===gC.Null}},{key:"isInt",value:function(e){return e&&e.typeId===gC.Int}},{key:"isFloat",value:function(e){return e&&e.typeId===gC.Float}},{key:"isBinary",value:function(e){return e&&e.typeId===gC.Binary}},{key:"isUtf8",value:function(e){return e&&e.typeId===gC.Utf8}},{key:"isBool",value:function(e){return e&&e.typeId===gC.Bool}},{key:"isDecimal",value:function(e){return e&&e.typeId===gC.Decimal}},{key:"isDate",value:function(e){return e&&e.typeId===gC.Date}},{key:"isTime",value:function(e){return e&&e.typeId===gC.Time}},{key:"isTimestamp",value:function(e){return e&&e.typeId===gC.Timestamp}},{key:"isInterval",value:function(e){return e&&e.typeId===gC.Interval}},{key:"isList",value:function(e){return e&&e.typeId===gC.List}},{key:"isStruct",value:function(e){return e&&e.typeId===gC.Struct}},{key:"isUnion",value:function(e){return e&&e.typeId===gC.Union}},{key:"isFixedSizeBinary",value:function(e){return e&&e.typeId===gC.FixedSizeBinary}},{key:"isFixedSizeList",value:function(e){return e&&e.typeId===gC.FixedSizeList}},{key:"isMap",value:function(e){return e&&e.typeId===gC.Map}},{key:"isDictionary",value:function(e){return e&&e.typeId===gC.Dictionary}}]),e}(),yC=function(e,t){g(s,_C);var i=_(s);function s(e,t){var r;return x(this,s),pb(b(r=i.call(this)),"isSigned",void 0),pb(b(r),"bitWidth",void 0),r.isSigned=e,r.bitWidth=t,r}return C(s,[{key:"typeId",get:function(){return gC.Int}},{key:t,get:function(){return"Int"}},{key:"toString",value:function(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}]),s}(0,Symbol.toStringTag),bC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!0,8)}return C(i)}(),BC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!0,16)}return C(i)}(),wC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!0,32)}return C(i)}(),xC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!1,8)}return C(i)}(),PC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!1,16)}return C(i)}(),CC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!1,32)}return C(i)}(),MC=32,FC=64,EC=function(e,t){g(s,_C);var i=_(s);function s(e){var t;return x(this,s),pb(b(t=i.call(this)),"precision",void 0),t.precision=e,t}return C(s,[{key:"typeId",get:function(){return gC.Float}},{key:t,get:function(){return"Float"}},{key:"toString",value:function(){return"Float".concat(this.precision)}}]),s}(0,Symbol.toStringTag),kC=function(e){g(i,EC);var t=_(i);function i(){return x(this,i),t.call(this,MC)}return C(i)}(),IC=function(e){g(i,EC);var t=_(i);function i(){return x(this,i),t.call(this,FC)}return C(i)}(),DC=function(e,t){g(s,_C);var i=_(s);function s(e,t){var r;return x(this,s),pb(b(r=i.call(this)),"listSize",void 0),pb(b(r),"children",void 0),r.listSize=e,r.children=[t],r}return C(s,[{key:"typeId",get:function(){return gC.FixedSizeList}},{key:"valueType",get:function(){return this.children[0].type}},{key:"valueField",get:function(){return this.children[0]}},{key:t,get:function(){return"FixedSizeList"}},{key:"toString",value:function(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}]),s}(0,Symbol.toStringTag);function SC(e,t,i){var s=function(e){switch(e.constructor){case Int8Array:return new bC;case Uint8Array:return new xC;case Int16Array:return new BC;case Uint16Array:return new PC;case Int32Array:return new wC;case Uint32Array:return new CC;case Float32Array:return new kC;case Float64Array:return new IC;default:throw new Error("array type not supported")}}(t.value),r=i||function(e){var t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new mC(e,new DC(t.size,new mC("value",s)),!1,r)}function TC(e,t,i){var s=LC(t.metadata),r=[],n=function(e){var t={};for(var i in e){var s=e[i];t[s.name||"undefined"]=s}return t}(t.attributes);for(var o in e){var a=RC(o,e[o],n[o]);r.push(a)}if(i){var l=RC("indices",i);r.push(l)}return new fC(r,s)}function RC(e,t,i){return SC(e,t,i?LC(i.metadata):void 0)}function LC(e){var t=new Map;for(var i in e)t.set("".concat(i,".string"),JSON.stringify(e[i]));return t}var UC={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},OC={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},NC=function(){function e(t){x(this,e),pb(this,"draco",void 0),pb(this,"decoder",void 0),pb(this,"metadataQuerier",void 0),this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}return C(e,[{key:"destroy",value:function(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}},{key:"parseSync",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);var s=this.decoder.GetEncodedGeometryType(i),r=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{var o;switch(s){case this.draco.TRIANGULAR_MESH:o=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:o=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!o.ok()||!r.ptr){var a="DRACO decompression failed: ".concat(o.error_msg());throw new Error(a)}var l=this._getDracoLoaderData(r,s,t),u=this._getMeshData(r,l,t),A=pC(u.attributes),c=TC(u.attributes,l,u.indices),h=n(n({loader:"draco",loaderData:l,header:{vertexCount:r.num_points(),boundingBox:A}},u),{},{schema:c});return h}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}},{key:"_getDracoLoaderData",value:function(e,t,i){var s=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:r}}},{key:"_getDracoAttributes",value:function(e,t){for(var i={},s=0;s2&&void 0!==arguments[2]&&arguments[2];if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),s=t.length/i);return{buffer:t,size:i,count:s}}(e),i=t.buffer,s=t.size;return{value:i,size:s,byteOffset:0,count:t.count,type:VP(s),componentType:HP(i)}}function $C(){return($C=u(a().mark((function e(t,i,s){var r,n,o,l,u,A;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=i&&null!==(r=i.gltf)&&void 0!==r&&r.decompressMeshes){e.next=2;break}return e.abrupt("return");case 2:n=new WP(t),o=[],l=c(rM(n));try{for(l.s();!(u=l.n()).done;)A=u.value,n.getObjectExtension(A,"KHR_draco_mesh_compression")&&o.push(eM(n,A,i,s))}catch(e){l.e(e)}finally{l.f()}return e.next=8,Promise.all(o);case 8:n.removeExtension("KHR_draco_mesh_compression");case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function eM(e,t,i,s){return tM.apply(this,arguments)}function tM(){return tM=u(a().mark((function e(t,i,s,r){var o,l,u,A,c,d,p,f,v,g,m,_,y,b;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t.getObjectExtension(i,"KHR_draco_mesh_compression")){e.next=3;break}return e.abrupt("return");case 3:return l=t.getTypedArrayForBufferView(o.bufferView),u=Kb(l.buffer,l.byteOffset),A=r.parse,delete(c=n({},s))["3d-tiles"],e.next=10,A(u,JC,c,r);case 10:for(d=e.sent,p=ZC(d.attributes),f=0,v=Object.entries(p);f2&&void 0!==arguments[2]?arguments[2]:4,r=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");var a=r.DracoWriter.encodeSync({attributes:e}),l=null==n||null===(i=n.parseSync)||void 0===i?void 0:i.call(n,{attributes:e}),u=r._addFauxAttributes(l.attributes),A=r.addBufferView(a),c={primitives:[{attributes:u,mode:s,extensions:o({},"KHR_draco_mesh_compression",{bufferView:A,attributes:u})}]};return c}function sM(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function rM(e){var t,i,r,n,o,l;return a().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:t=c(e.json.meshes||[]),s.prev=1,t.s();case 3:if((i=t.n()).done){s.next=24;break}r=i.value,n=c(r.primitives),s.prev=6,n.s();case 8:if((o=n.n()).done){s.next=14;break}return l=o.value,s.next=12,l;case 12:s.next=8;break;case 14:s.next=19;break;case 16:s.prev=16,s.t0=s.catch(6),n.e(s.t0);case 19:return s.prev=19,n.f(),s.finish(19);case 22:s.next=3;break;case 24:s.next=29;break;case 26:s.prev=26,s.t1=s.catch(1),t.e(s.t1);case 29:return s.prev=29,t.f(),s.finish(29);case 32:case"end":return s.stop()}}),s,null,[[1,26,29,32],[6,16,19,22]])}function nM(){return(nM=u(a().mark((function e(t){var i,s,r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new WP(t),s=i.json,(r=i.getExtension("KHR_lights_punctual"))&&(i.json.lights=r.lights,i.removeExtension("KHR_lights_punctual")),n=c(s.nodes||[]);try{for(n.s();!(o=n.n()).done;)l=o.value,(u=i.getObjectExtension(l,"KHR_lights_punctual"))&&(l.light=u.light),i.removeObjectExtension(l,"KHR_lights_punctual")}catch(e){n.e(e)}finally{n.f()}case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oM(){return(oM=u(a().mark((function e(t){var i,s,r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=new WP(t),(s=i.json).lights&&(DP(!(r=i.addExtension("KHR_lights_punctual")).lights),r.lights=s.lights,delete s.lights),i.json.lights){n=c(i.json.lights);try{for(n.s();!(o=n.n()).done;)l=o.value,u=l.node,i.addObjectExtension(u,"KHR_lights_punctual",l)}catch(e){n.e(e)}finally{n.f()}delete i.json.lights}case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function aM(){return(aM=u(a().mark((function e(t){var i,s,r,n,o;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new WP(t),s=i.json,i.removeExtension("KHR_materials_unlit"),r=c(s.materials||[]);try{for(r.s();!(n=r.n()).done;)o=n.value,o.extensions&&o.extensions.KHR_materials_unlit&&(o.unlit=!0),i.removeObjectExtension(o,"KHR_materials_unlit")}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function lM(){return(lM=u(a().mark((function e(t){var i,s,r,n,o,l,u,A;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=new WP(t),s=i.json,r=i.getExtension("KHR_techniques_webgl")){n=AM(r,i),o=c(s.materials||[]);try{for(o.s();!(l=o.n()).done;)u=l.value,(A=i.getObjectExtension(u,"KHR_techniques_webgl"))&&(u.technique=Object.assign({},A,n[A.technique]),u.technique.values=cM(u.technique,i)),i.removeObjectExtension(u,"KHR_techniques_webgl")}catch(e){o.e(e)}finally{o.f()}i.removeExtension("KHR_techniques_webgl")}case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function uM(){return(uM=u(a().mark((function e(t,i){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function AM(e,t){var i=e.programs,s=void 0===i?[]:i,r=e.shaders,n=void 0===r?[]:r,o=e.techniques,a=void 0===o?[]:o,l=new TextDecoder;return n.forEach((function(e){if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=l.decode(t.getTypedArrayForBufferView(e.bufferView))})),s.forEach((function(e){e.fragmentShader=n[e.fragmentShader],e.vertexShader=n[e.vertexShader]})),a.forEach((function(e){e.program=s[e.program]})),a}function cM(e,t){var i=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach((function(t){e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)})),Object.keys(i).forEach((function(e){"object"===w(i[e])&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))})),i}var hM=[AC,cC,hC,Object.freeze({__proto__:null,name:"KHR_draco_mesh_compression",preprocess:function(e,t,i){var s,r=new WP(e),n=c(rM(r));try{for(n.s();!(s=n.n()).done;){var o=s.value;r.getObjectExtension(o,"KHR_draco_mesh_compression")}}catch(e){n.e(e)}finally{n.f()}},decode:function(e,t,i){return $C.apply(this,arguments)},encode:function(e){var t,i=new WP(e),s=c(i.json.meshes||[]);try{for(s.s();!(t=s.n()).done;){var r=t.value;iM(r),i.addRequiredExtension("KHR_draco_mesh_compression")}}catch(e){s.e(e)}finally{s.f()}}}),Object.freeze({__proto__:null,name:"KHR_lights_punctual",decode:function(e){return nM.apply(this,arguments)},encode:function(e){return oM.apply(this,arguments)}}),Object.freeze({__proto__:null,name:"KHR_materials_unlit",decode:function(e){return aM.apply(this,arguments)},encode:function(e){var t=new WP(e),i=t.json;if(t.materials){var s,r=c(i.materials||[]);try{for(r.s();!(s=r.n()).done;){var n=s.value;n.unlit&&(delete n.unlit,t.addObjectExtension(n,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}}catch(e){r.e(e)}finally{r.f()}}}}),Object.freeze({__proto__:null,name:"KHR_techniques_webgl",decode:function(e){return lM.apply(this,arguments)},encode:function(e,t){return uM.apply(this,arguments)}})];function dM(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0,r=hM.filter((function(e){return vM(e.name,i)})),n=c(r);try{for(n.s();!(t=n.n()).done;){var o,a=t.value;null===(o=a.preprocess)||void 0===o||o.call(a,e,i,s)}}catch(e){n.e(e)}finally{n.f()}}function pM(e){return fM.apply(this,arguments)}function fM(){return fM=u(a().mark((function e(t){var i,s,r,n,o,l,u,A=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=A.length>1&&void 0!==A[1]?A[1]:{},s=A.length>2?A[2]:void 0,r=hM.filter((function(e){return vM(e.name,i)})),n=c(r),e.prev=4,n.s();case 6:if((o=n.n()).done){e.next=12;break}return l=o.value,e.next=10,null===(u=l.decode)||void 0===u?void 0:u.call(l,t,i,s);case 10:e.next=6;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(4),n.e(e.t0);case 17:return e.prev=17,n.f(),e.finish(17);case 20:case"end":return e.stop()}}),e,null,[[4,14,17,20]])}))),fM.apply(this,arguments)}function vM(e,t){var i,s=(null==t||null===(i=t.gltf)||void 0===i?void 0:i.excludeExtensions)||{};return!(e in s&&!s[e])}var gM={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},mM={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},_M=function(){function e(){x(this,e),pb(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),pb(this,"json",void 0)}return C(e,[{key:"normalize",value:function(e,t){this.json=e.json;var i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version ".concat(i.asset.version))}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){var t,i=new WP(e),s=i.json,r=c(s.images||[]);try{for(r.s();!(t=r.n()).done;){var n=t.value,o=i.getObjectExtension(n,"KHR_binary_glTF");o&&Object.assign(n,o),i.removeObjectExtension(n,"KHR_binary_glTF")}}catch(e){r.e(e)}finally{r.f()}s.buffers&&s.buffers[0]&&delete s.buffers[0].uri,i.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}},{key:"_addAsset",value:function(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}},{key:"_convertTopLevelObjectsToArrays",value:function(e){for(var t in gM)this._convertTopLevelObjectToArray(e,t)}},{key:"_convertTopLevelObjectToArray",value:function(e,t){var i=e[t];if(i&&!Array.isArray(i))for(var s in e[t]=[],i){var r=i[s];r.id=r.id||s;var n=e[t].length;e[t].push(r),this.idToIndexMap[t][s]=n}}},{key:"_convertObjectIdsToArrayIndices",value:function(e){for(var t in gM)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));var i,s=c(e.textures);try{for(s.s();!(i=s.n()).done;){var r=i.value;this._convertTextureIds(r)}}catch(e){s.e(e)}finally{s.f()}var n,o=c(e.meshes);try{for(o.s();!(n=o.n()).done;){var a=n.value;this._convertMeshIds(a)}}catch(e){o.e(e)}finally{o.f()}var l,u=c(e.nodes);try{for(u.s();!(l=u.n()).done;){var A=l.value;this._convertNodeIds(A)}}catch(e){u.e(e)}finally{u.f()}var h,d=c(e.scenes);try{for(d.s();!(h=d.n()).done;){var p=h.value;this._convertSceneIds(p)}}catch(e){d.e(e)}finally{d.f()}}},{key:"_convertTextureIds",value:function(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}},{key:"_convertMeshIds",value:function(e){var t,i=c(e.primitives);try{for(i.s();!(t=i.n()).done;){var s=t.value,r=s.attributes,n=s.indices,o=s.material;for(var a in r)r[a]=this._convertIdToIndex(r[a],"accessor");n&&(s.indices=this._convertIdToIndex(n,"accessor")),o&&(s.material=this._convertIdToIndex(o,"material"))}}catch(e){i.e(e)}finally{i.f()}}},{key:"_convertNodeIds",value:function(e){var t=this;e.children&&(e.children=e.children.map((function(e){return t._convertIdToIndex(e,"node")}))),e.meshes&&(e.meshes=e.meshes.map((function(e){return t._convertIdToIndex(e,"mesh")})))}},{key:"_convertSceneIds",value:function(e){var t=this;e.nodes&&(e.nodes=e.nodes.map((function(e){return t._convertIdToIndex(e,"node")})))}},{key:"_convertIdsToIndices",value:function(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute ".concat(t)),e[t]=[]);var i,s=c(e[t]);try{for(s.s();!(i=s.n()).done;){var r=i.value;for(var n in r){var o=r[n],a=this._convertIdToIndex(o,n);r[n]=a}}}catch(e){s.e(e)}finally{s.f()}}},{key:"_convertIdToIndex",value:function(e,t){var i=mM[t];if(i in this.idToIndexMap){var s=this.idToIndexMap[i][e];if(!Number.isFinite(s))throw new Error("gltf v1: failed to resolve ".concat(t," with id ").concat(e));return s}return e}},{key:"_updateObjects",value:function(e){var t,i=c(this.json.buffers);try{for(i.s();!(t=i.n()).done;){delete t.value.type}}catch(e){i.e(e)}finally{i.f()}}},{key:"_updateMaterial",value:function(e){var t,i=c(e.materials);try{var s=function(){var i=t.value;i.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};var s=(null===(r=i.values)||void 0===r?void 0:r.tex)||(null===(n=i.values)||void 0===n?void 0:n.texture2d_0),o=e.textures.findIndex((function(e){return e.id===s}));-1!==o&&(i.pbrMetallicRoughness.baseColorTexture={index:o})};for(i.s();!(t=i.n()).done;){var r,n;s()}}catch(e){i.e(e)}finally{i.f()}}}]),e}();function yM(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(new _M).normalize(e,t)}var bM={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},BM={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},wM=10240,xM=10241,PM=10242,CM=10243,MM=10497,FM=9986,EM={magFilter:wM,minFilter:xM,wrapS:PM,wrapT:CM},kM=(o(e={},wM,9729),o(e,xM,FM),o(e,PM,MM),o(e,CM,MM),e);var IM=function(){function e(){x(this,e),pb(this,"baseUri",""),pb(this,"json",{}),pb(this,"buffers",[]),pb(this,"images",[])}return C(e,[{key:"postProcess",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.json,s=e.buffers,r=void 0===s?[]:s,n=e.images,o=void 0===n?[]:n,a=e.baseUri,l=void 0===a?"":a;return DP(i),this.baseUri=l,this.json=i,this.buffers=r,this.images=o,this._resolveTree(this.json,t),this.json}},{key:"_resolveTree",value:function(e){var t=this;e.bufferViews&&(e.bufferViews=e.bufferViews.map((function(e,i){return t._resolveBufferView(e,i)}))),e.images&&(e.images=e.images.map((function(e,i){return t._resolveImage(e,i)}))),e.samplers&&(e.samplers=e.samplers.map((function(e,i){return t._resolveSampler(e,i)}))),e.textures&&(e.textures=e.textures.map((function(e,i){return t._resolveTexture(e,i)}))),e.accessors&&(e.accessors=e.accessors.map((function(e,i){return t._resolveAccessor(e,i)}))),e.materials&&(e.materials=e.materials.map((function(e,i){return t._resolveMaterial(e,i)}))),e.meshes&&(e.meshes=e.meshes.map((function(e,i){return t._resolveMesh(e,i)}))),e.nodes&&(e.nodes=e.nodes.map((function(e,i){return t._resolveNode(e,i)}))),e.skins&&(e.skins=e.skins.map((function(e,i){return t._resolveSkin(e,i)}))),e.scenes&&(e.scenes=e.scenes.map((function(e,i){return t._resolveScene(e,i)}))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}},{key:"getScene",value:function(e){return this._get("scenes",e)}},{key:"getNode",value:function(e){return this._get("nodes",e)}},{key:"getSkin",value:function(e){return this._get("skins",e)}},{key:"getMesh",value:function(e){return this._get("meshes",e)}},{key:"getMaterial",value:function(e){return this._get("materials",e)}},{key:"getAccessor",value:function(e){return this._get("accessors",e)}},{key:"getCamera",value:function(e){return null}},{key:"getTexture",value:function(e){return this._get("textures",e)}},{key:"getSampler",value:function(e){return this._get("samplers",e)}},{key:"getImage",value:function(e){return this._get("images",e)}},{key:"getBufferView",value:function(e){return this._get("bufferViews",e)}},{key:"getBuffer",value:function(e){return this._get("buffers",e)}},{key:"_get",value:function(e,t){if("object"===w(t))return t;var i=this.json[e]&&this.json[e][t];return i||console.warn("glTF file error: Could not find ".concat(e,"[").concat(t,"]")),i}},{key:"_resolveScene",value:function(e,t){var i=this;return e.id=e.id||"scene-".concat(t),e.nodes=(e.nodes||[]).map((function(e){return i.getNode(e)})),e}},{key:"_resolveNode",value:function(e,t){var i=this;return e.id=e.id||"node-".concat(t),e.children&&(e.children=e.children.map((function(e){return i.getNode(e)}))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce((function(e,t){var s=i.getMesh(t);return e.id=s.id,e.primitives=e.primitives.concat(s.primitives),e}),{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}},{key:"_resolveSkin",value:function(e,t){return e.id=e.id||"skin-".concat(t),e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}},{key:"_resolveMesh",value:function(e,t){var i=this;return e.id=e.id||"mesh-".concat(t),e.primitives&&(e.primitives=e.primitives.map((function(e){var t=(e=n({},e)).attributes;for(var s in e.attributes={},t)e.attributes[s]=i.getAccessor(t[s]);return void 0!==e.indices&&(e.indices=i.getAccessor(e.indices)),void 0!==e.material&&(e.material=i.getMaterial(e.material)),e}))),e}},{key:"_resolveMaterial",value:function(e,t){if(e.id=e.id||"material-".concat(t),e.normalTexture&&(e.normalTexture=n({},e.normalTexture),e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture=n({},e.occlustionTexture),e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture=n({},e.emmisiveTexture),e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness=n({},e.pbrMetallicRoughness);var i=e.pbrMetallicRoughness;i.baseColorTexture&&(i.baseColorTexture=n({},i.baseColorTexture),i.baseColorTexture.texture=this.getTexture(i.baseColorTexture.index)),i.metallicRoughnessTexture&&(i.metallicRoughnessTexture=n({},i.metallicRoughnessTexture),i.metallicRoughnessTexture.texture=this.getTexture(i.metallicRoughnessTexture.index))}return e}},{key:"_resolveAccessor",value:function(e,t){var i,s;if(e.id=e.id||"accessor-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(i=e.componentType,BM[i]),e.components=(s=e.type,bM[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){var r=e.bufferView.buffer,n=jP(e,e.bufferView),o=n.ArrayType,a=n.byteLength,l=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+r.byteOffset,u=r.arrayBuffer.slice(l,l+a);e.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(r,l,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new o(u)}return e}},{key:"_getValueFromInterleavedBuffer",value:function(e,t,i,s,r){for(var n=new Uint8Array(r*s),o=0;o1&&void 0!==arguments[1]?arguments[1]:0;return"".concat(String.fromCharCode(e.getUint8(t+0))).concat(String.fromCharCode(e.getUint8(t+1))).concat(String.fromCharCode(e.getUint8(t+2))).concat(String.fromCharCode(e.getUint8(t+3)))}function RM(e,t,i){rb(e.header.byteLength>20);var s=t.getUint32(i+0,SM),r=t.getUint32(i+4,SM);return i+=8,rb(0===r),UM(e,t,i,s),i+=s,i+=OM(e,t,i,e.header.byteLength)}function LM(e,t,i,s){return rb(e.header.byteLength>20),function(e,t,i,s){for(;i+8<=e.header.byteLength;){var r=t.getUint32(i+0,SM),n=t.getUint32(i+4,SM);switch(i+=8,n){case 1313821514:UM(e,t,i,r);break;case 5130562:OM(e,t,i,r);break;case 0:s.strict||UM(e,t,i,r);break;case 1:s.strict||OM(e,t,i,r)}i+=Xb(r,4)}}(e,t,i,s),i+e.header.byteLength}function UM(e,t,i,s){var r=new Uint8Array(t.buffer,i,s),n=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(n),Xb(s,4)}function OM(e,t,i,s){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:s,arrayBuffer:t.buffer}),Xb(s,4)}function NM(e,t){return QM.apply(this,arguments)}function QM(){return QM=u(a().mark((function e(t,i){var s,r,n,o,l,u,A,c,h,d,p=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=p.length>2&&void 0!==p[2]?p[2]:0,r=p.length>3?p[3]:void 0,n=p.length>4?p[4]:void 0,VM(t,i,s,r),yM(t,{normalize:null==r||null===(o=r.gltf)||void 0===o?void 0:o.normalize}),dM(t,r,n),c=[],null==r||null===(l=r.gltf)||void 0===l||!l.loadBuffers||!t.json.buffers){e.next=10;break}return e.next=10,HM(t,r,n);case 10:return null!=r&&null!==(u=r.gltf)&&void 0!==u&&u.loadImages&&(h=GM(t,r,n),c.push(h)),d=pM(t,r,n),c.push(d),e.next=15,Promise.all(c);case 15:return e.abrupt("return",null!=r&&null!==(A=r.gltf)&&void 0!==A&&A.postProcess?DM(t,r):t);case 16:case"end":return e.stop()}}),e)}))),QM.apply(this,arguments)}function VM(e,t,i,s){(s.uri&&(e.baseUri=s.uri),t instanceof ArrayBuffer&&!function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=new DataView(e),r=i.magic,n=void 0===r?1735152710:r,o=s.getUint32(t,!1);return o===n||1735152710===o}(t,i,s))&&(t=(new TextDecoder).decode(t));if("string"==typeof t)e.json=jb(t);else if(t instanceof ArrayBuffer){var r={};i=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=new DataView(t),r=TM(s,i+0),n=s.getUint32(i+4,SM),o=s.getUint32(i+8,SM);switch(Object.assign(e,{header:{byteOffset:i,byteLength:o,hasBinChunk:!1},type:r,version:n,json:{},binChunks:[]}),i+=12,e.version){case 1:return RM(e,s,i);case 2:return LM(e,s,i,{});default:throw new Error("Invalid GLB version ".concat(e.version,". Only supports v1 and v2."))}}(r,t,i,s.glb),DP("glTF"===r.type,"Invalid GLB magic string ".concat(r.type)),e._glb=r,e.json=r.json}else DP(!1,"GLTF: must be ArrayBuffer or string");var n=e.json.buffers||[];if(e.buffers=new Array(n.length).fill(null),e._glb&&e._glb.header.hasBinChunk){var o=e._glb.binChunks;e.buffers[0]={arrayBuffer:o[0].arrayBuffer,byteOffset:o[0].byteOffset,byteLength:o[0].byteLength}}var a=e.json.images||[];e.images=new Array(a.length).fill({})}function HM(e,t,i){return jM.apply(this,arguments)}function jM(){return(jM=u(a().mark((function e(t,i,s){var r,n,o,l,u,A,c,h;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.json.buffers||[],n=0;case 2:if(!(n1&&void 0!==u[1]?u[1]:{},s=u.length>2?u[2]:void 0,(i=n(n({},JM.options),i)).gltf=n(n({},JM.options.gltf),i.gltf),r=i.byteOffset,o=void 0===r?0:r,l={},e.next=8,NM(l,t,o,i,s);case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e)}))),YM.apply(this,arguments)}var ZM=function(){function e(t){x(this,e)}return C(e,[{key:"load",value:function(e,t,i,s,r,n,o){!function(e,t,i,s,r,n,o){var a=e.viewer.scene.canvas.spinner;a.processes++,"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(function(o){s.basePath=$M(t),eF(e,t,o,i,s,r,n),a.processes--}),(function(e){a.processes--,o(e)})):e.dataSource.getGLTF(t,(function(o){s.basePath=$M(t),eF(e,t,o,i,s,r,n),a.processes--}),(function(e){a.processes--,o(e)}))}(e,t,i,s=s||{},r,(function(){_e.scheduleTask((function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1)})),n&&n()}),(function(t){e.error(t),o&&o(t),r.fire("error",t)}))}},{key:"parse",value:function(e,t,i,s,r,n,o){eF(e,"",t,i,s=s||{},r,(function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1),n&&n()}))}}]),e}();function qM(e){for(var t={},i={},s=e.metaObjects||[],r={},n=0,o=s.length;n0)for(var A=0;A0){null==y&&e.log("Warning: 'name' properties not found on glTF scene nodes - will randomly-generate object IDs in XKT");var b=y;if(e.metaModelCorrections){var B=e.metaModelCorrections.eachChildRoot[b];if(B){var w=e.metaModelCorrections.eachRootStats[B.id];w.countChildren++,w.countChildren>=w.numChildren&&(n.createEntity({id:B.id,meshIds:nF}),nF.length=0)}else{e.metaModelCorrections.metaObjectsMap[b]&&(n.createEntity({id:b,meshIds:nF}),nF.length=0)}}else n.createEntity({id:b,meshIds:nF}),nF.length=0}}function aF(e,t){e.plugin.error(t)}var lF={DEFAULT:{}},uF=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"GLTFLoader",e,r))._sceneModelLoader=new ZM(b(s),r),s.dataSource=r.dataSource,s.objectDefaults=r.objectDefaults,s}return C(i,[{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new Ih}},{key:"objectDefaults",get:function(){return this._objectDefaults},set:function(e){this._objectDefaults=e||lF}},{key:"load",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.id&&this.viewer.scene.components[t.id]&&(this.error("Component with this ID already exists in viewer: "+t.id+" - will autogenerate this ID"),delete t.id);var i=new Ah(this.viewer.scene,le.apply(t,{isModel:!0,dtxEnabled:t.dtxEnabled})),s=i.id;if(!t.src&&!t.gltf)return this.error("load() param expected: src or gltf"),i;if(t.metaModelSrc||t.metaModelJSON){var r=t.objectDefaults||this._objectDefaults||lF,n=function(n){var o;if(e.viewer.metaScene.createMetaModel(s,n,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes}),e.viewer.scene.canvas.spinner.processes--,t.includeTypes){o={};for(var a=0,l=t.includeTypes.length;a2&&void 0!==arguments[2]?arguments[2]:{},s="lightgrey",r=i.hoverColor||"rgba(0,0,0,0.4)",n=i.textColor||"black",o=500,a=o+o/3,l=a/24,u=[{boundary:[6,6,6,6],color:i.frontColor||i.color||"#55FF55"},{boundary:[18,6,6,6],color:i.backColor||i.color||"#55FF55"},{boundary:[12,6,6,6],color:i.rightColor||i.color||"#FF5555"},{boundary:[0,6,6,6],color:i.leftColor||i.color||"#FF5555"},{boundary:[6,0,6,6],color:i.topColor||i.color||"#7777FF"},{boundary:[6,12,6,6],color:i.bottomColor||i.color||"#7777FF"}],A=[{label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,1,0],up:[0,0,1]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,-1,0],up:[0,0,1]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,0,1]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,0,1]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,0,1],up:[0,-1,0]},{boundaries:[[7,5,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,0,-1],up:[1,0,1]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-1,-1],up:[0,-1,1]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,0,-1],up:[-1,0,1]},{boundaries:[[7,11,4,2]],dir:[0,1,1],up:[0,-1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,0,1],up:[-1,0,1]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,-1,1],up:[0,1,1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,0,1],up:[1,0,1]},{boundaries:[[5,7,2,4]],dir:[1,1,0],up:[0,0,1]},{boundaries:[[11,7,2,4]],dir:[-1,1,0],up:[0,0,1]},{boundaries:[[17,7,2,4]],dir:[-1,-1,0],up:[0,0,1]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,-1,0],up:[0,0,1]},{boundaries:[[5,11,2,2]],dir:[1,1,1],up:[-1,-1,1]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[1,-1,1],up:[-1,1,1]},{boundaries:[[5,5,2,2]],dir:[1,1,-1],up:[1,1,1]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-1,-1,1],up:[1,1,1]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-1,-1,-1],up:[-1,-1,1]},{boundaries:[[11,11,2,2]],dir:[-1,1,1],up:[1,-1,1]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[1,-1,-1],up:[1,-1,1]},{boundaries:[[11,5,2,2]],dir:[-1,1,-1],up:[-1,1,1]}];i.frontColor||i.color,i.backColor||i.color,i.rightColor||i.color,i.leftColor||i.color,i.topColor||i.color,i.bottomColor||i.color;for(var c=[{yUp:"",label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,0,1],up:[0,1,0]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,1,0]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,1,0]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,-1,0],up:[0,0,-1]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,1,0],up:[0,0,1]},{boundaries:[[7,5,4,2]],dir:[0,-.7071,-.7071],up:[0,.7071,-.7071]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,-1,0],up:[1,1,0]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-.7071,.7071],up:[0,.7071,.7071]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,-1,0],up:[-1,1,0]},{boundaries:[[7,11,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,1,0],up:[-1,1,0]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,1,1],up:[0,1,-1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,1,0],up:[1,1,0]},{boundaries:[[5,7,2,4]],dir:[1,0,-1],up:[0,1,0]},{boundaries:[[11,7,2,4]],dir:[-1,0,-1],up:[0,1,0]},{boundaries:[[17,7,2,4]],dir:[-1,0,1],up:[0,1,0]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,0,1],up:[0,1,0]},{boundaries:[[5,11,2,2]],dir:[.5,.7071,-.5],up:[-.5,.7071,.5]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[.5,.7071,.5],up:[-.5,.7071,-.5]},{boundaries:[[5,5,2,2]],dir:[.5,-.7071,-.5],up:[.5,.7071,-.5]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-.5,.7071,.5],up:[.5,.7071,-.5]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-.5,-.7071,.5],up:[-.5,.7071,.5]},{boundaries:[[11,11,2,2]],dir:[-.5,.7071,-.5],up:[.5,.7071,.5]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[.5,-.7071,.5],up:[.5,.7071,.5]},{boundaries:[[11,5,2,2]],dir:[-.5,-.7071,-.5],up:[-.5,.7071,-.5]}],h=0,d=A.length;h=c[0]*l&&t<=(c[0]+c[2])*l&&i>=c[1]*l&&i<=(c[1]+c[3])*l)return s}return-1},this.setAreaHighlighted=function(e,t){var i=v[e];if(!i)throw"Area not found: "+e;i.highlighted=!!t,y()},this.getAreaDir=function(e){var t=v[e];if(!t)throw"Unknown area: "+e;return t.dir},this.getAreaUp=function(e){var t=v[e];if(!t)throw"Unknown area: "+e;return t.up},this.getImage=function(){return this._textureCanvas},this.destroy=function(){this._textureCanvas&&(this._textureCanvas.parentNode.removeChild(this._textureCanvas),this._textureCanvas=null)}}var cF=$.vec3(),hF=$.vec3();$.mat4();var dF=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),s=t.call(this,"NavCube",e,r),e.navCube=b(s);var n=!0;try{s._navCubeScene=new Zi(e,{canvasId:r.canvasId,canvasElement:r.canvasElement,transparent:!0}),s._navCubeCanvas=s._navCubeScene.canvas.canvas,s._navCubeScene.input.keyboardEnabled=!1}catch(e){return s.error(e),y(s)}var o=s._navCubeScene;o.clearLights(),new yi(o,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new yi(o,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new yi(o,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),s._navCubeCamera=o.camera,s._navCubeCamera.ortho.scale=7,s._navCubeCamera.ortho.near=.1,s._navCubeCamera.ortho.far=2e3,o.edgeMaterial.edgeColor=[.2,.2,.2],o.edgeMaterial.edgeAlpha=.6,s._zUp=Boolean(e.camera.zUp);var a=b(s);s.setIsProjectNorth(r.isProjectNorth),s.setProjectNorthOffsetAngle(r.projectNorthOffsetAngle);var l,u=(l=$.mat4(),function(e,t,i){return $.identityMat4(l),$.rotationMat4v(e*a._projectNorthOffsetAngle*$.DEGTORAD,[0,1,0],l),$.transformVec3(l,t,i)});s._synchCamera=function(){var t=$.rotationMat4c(-90*$.DEGTORAD,1,0,0),i=$.vec3(),s=$.vec3(),r=$.vec3();return function(){var n=e.camera.eye,o=e.camera.look,l=e.camera.up;i=$.mulVec3Scalar($.normalizeVec3($.subVec3(n,o,i)),5),a._isProjectNorth&&a._projectNorthOffsetAngle&&(i=u(-1,i,cF),l=u(-1,l,hF)),a._zUp?($.transformVec3(t,i,s),$.transformVec3(t,l,r),a._navCubeCamera.look=[0,0,0],a._navCubeCamera.eye=$.transformVec3(t,i,s),a._navCubeCamera.up=$.transformPoint3(t,l,r)):(a._navCubeCamera.look=[0,0,0],a._navCubeCamera.eye=i,a._navCubeCamera.up=l)}}(),s._cubeTextureCanvas=new AF(e,o,r),s._cubeSampler=new Ln(o,{image:s._cubeTextureCanvas.getImage(),flipY:!0,wrapS:1001,wrapT:1001}),s._cubeMesh=new sn(o,{geometry:new Si(o,{primitive:"triangles",normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),material:new Oi(o,{diffuse:[.4,.4,.4],specular:[.4,.4,.4],emissive:[.6,.6,.6],diffuseMap:s._cubeSampler,emissiveMap:s._cubeSampler}),visible:!!n,edges:!0}),s._shadow=!1===r.shadowVisible?null:new sn(o,{geometry:new Si(o,nn({center:[0,0,0],radiusTop:.001,radiusBottom:1.4,height:.01,radialSegments:20,heightSegments:1,openEnded:!0})),material:new Oi(o,{diffuse:[0,0,0],specular:[0,0,0],emissive:[0,0,0],alpha:.5}),position:[0,-1.5,0],visible:!!n,pickable:!1,backfaces:!1}),s._onCameraMatrix=e.camera.on("matrix",s._synchCamera),s._onCameraWorldAxis=e.camera.on("worldAxis",(function(){e.camera.zUp?(s._zUp=!0,s._cubeTextureCanvas.setZUp(),s._repaint(),s._synchCamera()):e.camera.yUp&&(s._zUp=!1,s._cubeTextureCanvas.setYUp(),s._repaint(),s._synchCamera())})),s._onCameraFOV=e.camera.perspective.on("fov",(function(e){s._synchProjection&&(s._navCubeCamera.perspective.fov=e)})),s._onCameraProjection=e.camera.on("projection",(function(e){s._synchProjection&&(s._navCubeCamera.projection="ortho"===e||"perspective"===e?e:"perspective")}));var A=-1;function c(t,i){var s=(t-d)*-_,r=(i-p)*-_;e.camera.orbitYaw(s),e.camera.orbitPitch(-r),d=t,p=i}function h(e){var t=[0,0];if(e){for(var i=e.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t}var d,p,f=null,v=null,g=!1,m=!1,_=.5;a._navCubeCanvas.addEventListener("mouseenter",a._onMouseEnter=function(e){m=!0}),a._navCubeCanvas.addEventListener("mouseleave",a._onMouseLeave=function(e){m=!1}),a._navCubeCanvas.addEventListener("mousedown",a._onMouseDown=function(e){if(1===e.which){f=e.x,v=e.y,d=e.clientX,p=e.clientY;var t=h(e),i=o.pick({canvasPos:t});g=!!i}}),document.addEventListener("mouseup",a._onMouseUp=function(e){if(1===e.which&&(g=!1,null!==f)){var t=h(e),i=o.pick({canvasPos:t,pickSurface:!0});if(i&&i.uv){var s=a._cubeTextureCanvas.getArea(i.uv);if(s>=0&&(document.body.style.cursor="pointer",A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1),s>=0)){if(a._cubeTextureCanvas.setAreaHighlighted(s,!0),A=s,a._repaint(),e.xf+3||e.yv+3)return;var r=a._cubeTextureCanvas.getAreaDir(s);if(r){var n=a._cubeTextureCanvas.getAreaUp(s);a._isProjectNorth&&a._projectNorthOffsetAngle&&(r=u(1,r,cF),n=u(1,n,hF)),B(r,n,(function(){A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1),document.body.style.cursor="pointer",A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1),s>=0&&(a._cubeTextureCanvas.setAreaHighlighted(s,!1),A=-1,a._repaint())}))}}}}}),document.addEventListener("mousemove",a._onMouseMove=function(e){if(A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1),1!==e.buttons||g){if(g){var t=e.clientX,i=e.clientY;return document.body.style.cursor="move",void c(t,i)}if(m){var s=h(e),r=o.pick({canvasPos:s,pickSurface:!0});if(r){if(r.uv){document.body.style.cursor="pointer";var n=a._cubeTextureCanvas.getArea(r.uv);if(n===A)return;A>=0&&a._cubeTextureCanvas.setAreaHighlighted(A,!1),n>=0&&(a._cubeTextureCanvas.setAreaHighlighted(n,!0),a._repaint(),A=n)}}else document.body.style.cursor="default",A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1)}}});var B=function(){var t=$.vec3();return function(i,s,r){var n=a._fitVisible?e.scene.getAABB(e.scene.visibleObjectIds):e.scene.aabb,o=$.getAABB3Diag(n);$.getAABB3Center(n,t);var l=Math.abs(o/Math.tan(a._cameraFitFOV*$.DEGTORAD));e.cameraControl.pivotPos=t,a._cameraFly?e.cameraFlight.flyTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:s||[0,1,0],orthoScale:1.1*o,fitFOV:a._cameraFitFOV,duration:a._cameraFlyDuration},r):e.cameraFlight.jumpTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:s||[0,1,0],orthoScale:1.1*o,fitFOV:a._cameraFitFOV},r)}}();return s._onUpdated=e.localeService.on("updated",(function(){s._cubeTextureCanvas.clear(),s._repaint()})),s.setVisible(r.visible),s.setCameraFitFOV(r.cameraFitFOV),s.setCameraFly(r.cameraFly),s.setCameraFlyDuration(r.cameraFlyDuration),s.setFitVisible(r.fitVisible),s.setSynchProjection(r.synchProjection),s}return C(i,[{key:"send",value:function(e,t){if("language"===e)this._cubeTextureCanvas.clear(),this._repaint()}},{key:"_repaint",value:function(){var e=this._cubeTextureCanvas.getImage();this._cubeMesh.material.diffuseMap.image=e,this._cubeMesh.material.emissiveMap.image=e}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._navCubeCanvas&&(this._cubeMesh.visible=e,this._shadow&&(this._shadow.visible=e),this._navCubeCanvas.style.visibility=e?"visible":"hidden")}},{key:"getVisible",value:function(){return!!this._navCubeCanvas&&this._cubeMesh.visible}},{key:"setFitVisible",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._fitVisible=e}},{key:"getFitVisible",value:function(){return this._fitVisible}},{key:"setCameraFly",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._cameraFly=e}},{key:"getCameraFly",value:function(){return this._cameraFly}},{key:"setCameraFitFOV",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:45;this._cameraFitFOV=e}},{key:"getCameraFitFOV",value:function(){return this._cameraFitFOV}},{key:"setCameraFlyDuration",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5;this._cameraFlyDuration=e}},{key:"getCameraFlyDuration",value:function(){return this._cameraFlyDuration}},{key:"setSynchProjection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._synchProjection=e}},{key:"getSynchProjection",value:function(){return this._synchProjection}},{key:"setIsProjectNorth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._isProjectNorth=e}},{key:"getIsProjectNorth",value:function(){return this._isProjectNorth}},{key:"setProjectNorthOffsetAngle",value:function(e){this._projectNorthOffsetAngle=e}},{key:"getProjectNorthOffsetAngle",value:function(){return this._projectNorthOffsetAngle}},{key:"destroy",value:function(){this._navCubeCanvas&&(this.viewer.localeService.off(this._onUpdated),this.viewer.camera.off(this._onCameraMatrix),this.viewer.camera.off(this._onCameraWorldAxis),this.viewer.camera.perspective.off(this._onCameraFOV),this.viewer.camera.off(this._onCameraProjection),this._navCubeCanvas.removeEventListener("mouseenter",this._onMouseEnter),this._navCubeCanvas.removeEventListener("mouseleave",this._onMouseLeave),this._navCubeCanvas.removeEventListener("mousedown",this._onMouseDown),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._navCubeCanvas=null,this._cubeTextureCanvas.destroy(),this._cubeTextureCanvas=null,this._onMouseEnter=null,this._onMouseLeave=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null),this._navCubeScene.destroy(),this._navCubeScene=null,this._cubeMesh=null,this._shadow=null,f(B(i.prototype),"destroy",this).call(this)}}]),i}(),pF=$.vec3(),fF=function(){function e(){x(this,e)}return C(e,[{key:"load",value:function(e,t){var i=e.scene.canvas.spinner;i.processes++,vF(e,t,(function(t){mF(e,t,(function(){bF(e,t),i.processes--,_e.scheduleTask((function(){e.fire("loaded",!0,!1)}))}))}))}},{key:"parse",value:function(e,t,i,s){if(t){var r=gF(e,t,null);i&&yF(e,i,s),bF(e,r),e.src=null,e.fire("loaded",!0,!1)}else this.warn("load() param expected: objText")}}]),e}(),vF=function(e,t,i){BF(t,(function(s){var r=gF(e,s,t);i(r)}),(function(t){e.error(t)}))},gF=function(){var e={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /};return function(s,r,n){var o={src:n=n||"",basePath:t(n),objects:[],object:{},positions:[],normals:[],uv:[],materialLibraries:{}};i(o,"",!1),-1!==r.indexOf("\r\n")&&(r=r.replace("\r\n","\n"));for(var a=r.split("\n"),l="",u="",A="",d=[],p="function"==typeof"".trimLeft,f=0,v=a.length;f=0?i-1:i+t/3)}function r(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function n(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)}function o(e,t,i,s){var r=e.positions,n=e.object.geometry.positions;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2])}function a(e,t){var i=e.positions,s=e.object.geometry.positions;s.push(i[t+0]),s.push(i[t+1]),s.push(i[t+2])}function l(e,t,i,s){var r=e.normals,n=e.object.geometry.normals;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2])}function u(e,t,i,s){var r=e.uv,n=e.object.geometry.uv;n.push(r[t+0]),n.push(r[t+1]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[s+0]),n.push(r[s+1])}function A(e,t){var i=e.uv,s=e.object.geometry.uv;s.push(i[t+0]),s.push(i[t+1])}function c(e,t,i,a,A,c,h,d,p,f,v,g,m){var _,y=e.positions.length,b=s(t,y),B=s(i,y),w=s(a,y);if(void 0===A?o(e,b,B,w):(o(e,b,B,_=s(A,y)),o(e,B,w,_)),void 0!==c){var x=e.uv.length;b=n(c,x),B=n(h,x),w=n(d,x),void 0===A?u(e,b,B,w):(u(e,b,B,_=n(p,x)),u(e,B,w,_))}if(void 0!==f){var P=e.normals.length;b=r(f,P),B=f===v?b:r(v,P),w=f===g?b:r(g,P),void 0===A?l(e,b,B,w):(l(e,b,B,_=r(m,P)),l(e,B,w,_))}}function h(e,t,i){e.object.geometry.type="Line";for(var r=e.positions.length,o=e.uv.length,l=0,u=t.length;l=0?o.substring(0,a):o).toLowerCase(),u=(u=a>=0?o.substring(a+1):"").trim(),l.toLowerCase()){case"newmtl":i(e,h),h={id:u},d=!0;break;case"ka":h.ambient=s(u);break;case"kd":h.diffuse=s(u);break;case"ks":h.specular=s(u);break;case"map_kd":h.diffuseMap||(h.diffuseMap=t(e,n,u,"sRGB"));break;case"map_ks":h.specularMap||(h.specularMap=t(e,n,u,"linear"));break;case"map_bump":case"bump":h.normalMap||(h.normalMap=t(e,n,u));break;case"ns":h.shininess=parseFloat(u);break;case"d":(A=parseFloat(u))<1&&(h.alpha=A,h.alphaMode="blend");break;case"tr":(A=parseFloat(u))>0&&(h.alpha=1-A,h.alphaMode="blend")}d&&i(e,h)};function t(e,t,i,s){var r={},n=i.split(/\s+/),o=n.indexOf("-bm");return o>=0&&n.splice(o,2),(o=n.indexOf("-s"))>=0&&(r.scale=[parseFloat(n[o+1]),parseFloat(n[o+2])],n.splice(o,4)),(o=n.indexOf("-o"))>=0&&(r.translate=[parseFloat(n[o+1]),parseFloat(n[o+2])],n.splice(o,4)),r.src=t+n.join(" ").trim(),r.flipY=!0,r.encoding=s||"linear",new Ln(e,r).id}function i(e,t){new Oi(e,t)}function s(t){var i=t.split(e,3);return[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])]}}();function bF(e,t){for(var i=0,s=t.objects.length;i0&&(o.normals=n.normals),n.uv.length>0&&(o.uv=n.uv);for(var a=new Array(o.positions.length/3),l=0;l0&&void 0!==arguments[0]?arguments[0]:{};t.id&&this.viewer.scene.components[t.id]&&(this.error("Component with this ID already exists in viewer: "+t.id+" - will autogenerate this ID"),delete t.id);var i=new yn(this.viewer.scene,le.apply(t,{isModel:!0})),s=i.id,r=t.src;if(!r)return this.error("load() param expected: src"),i;if(t.metaModelSrc){var n=t.metaModelSrc;le.loadJSON(n,(function(n){e.viewer.metaScene.createMetaModel(s,n),e._sceneGraphLoader.load(i,r,t)}),(function(t){e.error("load(): Failed to load model modelMetadata for model '".concat(s," from '").concat(n,"' - ").concat(t))}))}else this._sceneGraphLoader.load(i,r,t);return i.once("destroyed",(function(){e.viewer.metaScene.destroyMetaModel(s)})),i}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this)}}]),i}(),xF=new Float64Array([0,0,1]),PF=new Float64Array(4),CF=function(){function e(t){x(this,e),this.id=null,this._viewer=t.viewer,this._visible=!1,this._pos=$.vec3(),this._origin=$.vec3(),this._rtcPos=$.vec3(),this._baseDir=$.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}return C(e,[{key:"_setSectionPlane",value:function(e){var t=this;this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(function(){t._setPos(t._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(function(){t._ignoreNextSectionPlaneDirUpdate?t._ignoreNextSectionPlaneDirUpdate=!1:t._setDir(t._sectionPlane.dir)})))}},{key:"sectionPlane",get:function(){return this._sectionPlane}},{key:"_setPos",value:function(e){this._pos.set(e),Le(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}},{key:"_setDir",value:function(e){this._baseDir.set(e),this._rootNode.quaternion=$.vec3PairToQuaternion(xF,e,PF)}},{key:"_setSectionPlaneDir",value:function(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}},{key:"getVisible",value:function(){return this._visible}},{key:"setCulled",value:function(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}},{key:"_createNodes",value:function(){var e=!1,t=this._viewer.scene,i=.01;this._rootNode=new yn(t,{position:[0,0,0],scale:[5,5,5],isObject:!1});var s,r,n=this._rootNode,o={arrowHead:new Si(n,nn({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Si(n,nn({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),arrowHeadHandle:new Si(n,nn({radiusTop:.09,radiusBottom:.09,radialSegments:8,heightSegments:1,height:.37,openEnded:!1})),curve:new Si(n,Xn({radius:.8,tube:i,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),curveHandle:new Si(n,Xn({radius:.8,tube:.06,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),hoop:new Si(n,Xn({radius:.8,tube:i,radialSegments:64,tubeSegments:8,arc:2*Math.PI})),axis:new Si(n,nn({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1})),axisHandle:new Si(n,nn({radiusTop:.08,radiusBottom:.08,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},a={pickable:new Oi(n,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),red:new Oi(n,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Qi(n,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6}),green:new Oi(n,{diffuse:[0,1,0],emissive:[0,1,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightGreen:new Qi(n,{edges:!1,fill:!0,fillColor:[0,1,0],fillAlpha:.6}),blue:new Oi(n,{diffuse:[0,0,1],emissive:[0,0,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightBlue:new Qi(n,{edges:!1,fill:!0,fillColor:[0,0,1],fillAlpha:.2}),center:new Oi(n,{diffuse:[0,0,0],emissive:[0,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80}),highlightBall:new Qi(n,{edges:!1,fill:!0,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1}),highlightPlane:new Qi(n,{edges:!0,edgeWidth:3,fill:!1,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1})};this._displayMeshes={plane:n.addChild(new sn(n,{geometry:new Si(n,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Oi(n,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new Qi(n,{edges:!1,filled:!0,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:.1,backfaces:!0}),pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1],isObject:!1}),e),planeFrame:n.addChild(new sn(n,{geometry:new Si(n,Xn({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Oi(n,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new Qi(n,{edges:!1,edgeColor:[0,0,0],filled:!0,fillColor:[.8,.8,.8],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45],isObject:!1}),e),xCurve:n.addChild(new sn(n,{geometry:o.curve,material:a.red,matrix:(s=$.rotationMat4v(90*$.DEGTORAD,[0,1,0],$.identityMat4()),r=$.rotationMat4v(270*$.DEGTORAD,[1,0,0],$.identityMat4()),$.mulMat4(r,s,$.identityMat4())),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveHandle:n.addChild(new sn(n,{geometry:o.curveHandle,material:a.pickable,matrix:function(){var e=$.rotationMat4v(90*$.DEGTORAD,[0,1,0],$.identityMat4()),t=$.rotationMat4v(270*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveArrow1:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.red,matrix:function(){var e=$.translateMat4c(0,-.07,-.8,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(0*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xCurveArrow2:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.red,matrix:function(){var e=$.translateMat4c(0,-.8,-.07,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurve:n.addChild(new sn(n,{geometry:o.curve,material:a.green,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveHandle:n.addChild(new sn(n,{geometry:o.curveHandle,material:a.pickable,rotation:[-90,0,0],pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveArrow1:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.green,matrix:function(){var e=$.translateMat4c(.07,0,-.8,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurveArrow2:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.green,matrix:function(){var e=$.translateMat4c(.8,0,-.07,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurve:n.addChild(new sn(n,{geometry:o.curve,material:a.blue,matrix:$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4()),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveHandle:n.addChild(new sn(n,{geometry:o.curveHandle,material:a.pickable,matrix:$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4()),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveCurveArrow1:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.blue,matrix:function(){var e=$.translateMat4c(.8,-.07,0,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4());return $.mulMat4(e,t,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveArrow2:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.blue,matrix:function(){var e=$.translateMat4c(.05,-.8,0,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),center:n.addChild(new sn(n,{geometry:new Si(n,on({radius:.05})),material:a.center,pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.red,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrowHandle:n.addChild(new sn(n,{geometry:o.arrowHeadHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxis:n.addChild(new sn(n,{geometry:o.axis,material:a.red,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisHandle:n.addChild(new sn(n,{geometry:o.axisHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.green,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrowHandle:n.addChild(new sn(n,{geometry:o.arrowHeadHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,opacity:.2,isObject:!1}),e),yShaft:n.addChild(new sn(n,{geometry:o.axis,material:a.green,position:[0,-.5,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yShaftHandle:n.addChild(new sn(n,{geometry:o.axisHandle,material:a.pickable,position:[0,-.5,0],pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.blue,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrowHandle:n.addChild(new sn(n,{geometry:o.arrowHeadHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zShaft:n.addChild(new sn(n,{geometry:o.axis,material:a.blue,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1,isObject:!1}),e),zAxisHandle:n.addChild(new sn(n,{geometry:o.axisHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),clippable:!1,pickable:!0,collidable:!0,visible:!1,isObject:!1}),e)},this._affordanceMeshes={planeFrame:n.addChild(new sn(n,{geometry:new Si(n,Xn({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Oi(n,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Qi(n,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45],isObject:!1}),e),xHoop:n.addChild(new sn(n,{geometry:o.hoop,material:a.red,highlighted:!0,highlightMaterial:a.highlightRed,matrix:function(){var e=$.rotationMat4v(90*$.DEGTORAD,[0,1,0],$.identityMat4()),t=$.rotationMat4v(270*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yHoop:n.addChild(new sn(n,{geometry:o.hoop,material:a.green,highlighted:!0,highlightMaterial:a.highlightGreen,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zHoop:n.addChild(new sn(n,{geometry:o.hoop,material:a.blue,highlighted:!0,highlightMaterial:a.highlightBlue,matrix:$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4()),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHeadBig,material:a.red,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHeadBig,material:a.green,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHeadBig,material:a.blue,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e)}}},{key:"_bindEvents",value:function(){var e=this,t=this,i=!1,s=-1,r=0,n=1,o=2,a=3,l=4,u=5,A=this._rootNode,c=null,h=null,d=$.vec2(),p=$.vec3([1,0,0]),f=$.vec3([0,1,0]),v=$.vec3([0,0,1]),g=this._viewer.scene.canvas.canvas,m=this._viewer.camera,_=this._viewer.scene,y=$.vec3([0,0,0]),b=-1;this._onCameraViewMatrix=_.camera.on("viewMatrix",(function(){})),this._onCameraProjMatrix=_.camera.on("projMatrix",(function(){})),this._onSceneTick=_.on("tick",(function(){var t=Math.abs($.lenVec3($.subVec3(_.camera.eye,e._pos,y)));if(t!==b&&"perspective"===m.projection){var i=.07*(Math.tan(m.perspective.fov*$.DEGTORAD)*t);A.scale=[i,i,i],b=t}if("ortho"===m.projection){var s=m.ortho.scale/10;A.scale=[s,s,s],b=t}}));var B,w,x,P,C,M=function(){var e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),F=function(){var e=$.mat4();return function(i,s){return $.quaternionToMat4(t._rootNode.quaternion,e),$.transformVec3(e,i,s),$.normalizeVec3(s),s}}(),E=(B=$.vec3(),function(e){var t=Math.abs(e[0]);return t>Math.abs(e[1])&&t>Math.abs(e[2])?$.cross3Vec3(e,[0,1,0],B):$.cross3Vec3(e,[1,0,0],B),$.cross3Vec3(B,e,B),$.normalizeVec3(B),B}),k=(w=$.vec3(),x=$.vec3(),P=$.vec4(),function(e,i,s){F(e,P);var r=E(P,i,s);D(i,r,w),D(s,r,x),$.subVec3(x,w);var n=$.dotVec3(x,P);t._pos[0]+=P[0]*n,t._pos[1]+=P[1]*n,t._pos[2]+=P[2]*n,t._rootNode.position=t._pos,t._sectionPlane&&(t._sectionPlane.pos=t._pos)}),I=function(){var e=$.vec4(),i=$.vec4(),s=$.vec4(),r=$.vec4();return function(n,o,a){if(F(n,r),!(D(o,r,e)&&D(a,r,i))){var l=E(r,o,a);D(o,l,e,1),D(a,l,i,1);var u=$.dotVec3(e,r);e[0]-=u*r[0],e[1]-=u*r[1],e[2]-=u*r[2],u=$.dotVec3(i,r),i[0]-=u*r[0],i[1]-=u*r[1],i[2]-=u*r[2]}$.normalizeVec3(e),$.normalizeVec3(i),u=$.dotVec3(e,i),u=$.clamp(u,-1,1);var A=Math.acos(u)*$.RADTODEG;$.cross3Vec3(e,i,s),$.dotVec3(s,r)<0&&(A=-A),t._rootNode.rotate(n,A),S()}}(),D=function(){var e=$.vec4([0,0,0,1]),i=$.mat4();return function(s,r,n,o){o=o||0,e[0]=s[0]/g.width*2-1,e[1]=-(s[1]/g.height*2-1),e[2]=0,e[3]=1,$.mulMat4(m.projMatrix,m.viewMatrix,i),$.inverseMat4(i),$.transformVec4(i,e,e),$.mulVec4Scalar(e,1/e[3]);var a=m.eye;$.subVec4(e,a,e);var l=t._sectionPlane.pos,u=-$.dotVec3(l,r)-o,A=$.dotVec3(r,e);if(Math.abs(A)>.005){var c=-($.dotVec3(r,a)+u)/A;return $.mulVec3Scalar(e,c,n),$.addVec3(n,a),$.subVec3(n,l,n),!0}return!1}}(),S=function(){var e=$.vec3(),i=$.mat4();return function(){t.sectionPlane&&($.quaternionToMat4(A.quaternion,i),$.transformVec3(i,[0,0,1],e),t._setSectionPlaneDir(e))}}(),T=!1;this._onCameraControlHover=this._viewer.cameraControl.on("hoverEnter",(function(t){if(e._visible&&!T){var A;switch(i=!1,C&&(C.visible=!1),t.entity.id){case e._displayMeshes.xAxisArrowHandle.id:case e._displayMeshes.xAxisHandle.id:A=e._affordanceMeshes.xAxisArrow,c=r;break;case e._displayMeshes.yAxisArrowHandle.id:case e._displayMeshes.yShaftHandle.id:A=e._affordanceMeshes.yAxisArrow,c=n;break;case e._displayMeshes.zAxisArrowHandle.id:case e._displayMeshes.zAxisHandle.id:A=e._affordanceMeshes.zAxisArrow,c=o;break;case e._displayMeshes.xCurveHandle.id:A=e._affordanceMeshes.xHoop,c=a;break;case e._displayMeshes.yCurveHandle.id:A=e._affordanceMeshes.yHoop,c=l;break;case e._displayMeshes.zCurveHandle.id:A=e._affordanceMeshes.zHoop,c=u;break;default:return void(c=s)}A&&(A.visible=!0),C=A,i=!0}})),this._onCameraControlHoverLeave=this._viewer.cameraControl.on("hoverOutEntity",(function(t){e._visible&&(C&&(C.visible=!1),C=null,c=s)})),g.addEventListener("mousedown",this._canvasMouseDownListener=function(t){if(t.preventDefault(),e._visible&&i&&(e._viewer.cameraControl.pointerEnabled=!1,1===t.which)){T=!0;var s=M(t);h=c,d[0]=s[0],d[1]=s[1]}}),g.addEventListener("mousemove",this._canvasMouseMoveListener=function(t){if(e._visible&&T){var i=M(t),s=i[0],A=i[1];switch(h){case r:k(p,d,i);break;case n:k(f,d,i);break;case o:k(v,d,i);break;case a:I(p,d,i);break;case l:I(f,d,i);break;case u:I(v,d,i)}d[0]=s,d[1]=A}}),g.addEventListener("mouseup",this._canvasMouseUpListener=function(t){e._visible&&(e._viewer.cameraControl.pointerEnabled=!0,T&&(t.which,T=!1,i=!1))}),g.addEventListener("wheel",this._canvasWheelListener=function(t){if(e._visible)Math.max(-1,Math.min(1,40*-t.deltaY))})}},{key:"_destroy",value:function(){this._unbindEvents(),this._destroyNodes()}},{key:"_unbindEvents",value:function(){var e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=e.cameraControl;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix),r.off(this._onCameraControlHover),r.off(this._onCameraControlHoverLeave)}},{key:"_destroyNodes",value:function(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}]),e}(),MF=function(){function e(t,i,s){var r=this;x(this,e),this.id=s.id,this._sectionPlane=s,this._mesh=new sn(i,{id:s.id,geometry:new Si(i,Ti({xSize:.5,ySize:.5,zSize:.001})),material:new Oi(i,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new Hi(i,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Qi(i,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Qi(i,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});var n=$.vec3([0,0,0]),o=$.vec3(),a=$.vec3([0,0,1]),l=$.vec4(4),u=$.vec3(),A=function(){var e=r._sectionPlane.scene.center,t=[-r._sectionPlane.dir[0],-r._sectionPlane.dir[1],-r._sectionPlane.dir[2]];$.subVec3(e,r._sectionPlane.pos,n);var i=-$.dotVec3(t,n);$.normalizeVec3(t),$.mulVec3Scalar(t,i,o);var s=$.vec3PairToQuaternion(a,r._sectionPlane.dir,l);u[0]=.1*o[0],u[1]=.1*o[1],u[2]=.1*o[2],r._mesh.quaternion=s,r._mesh.position=u};this._onSectionPlanePos=this._sectionPlane.on("pos",A),this._onSectionPlaneDir=this._sectionPlane.on("dir",A),this._highlighted=!1,this._selected=!1}return C(e,[{key:"setHighlighted",value:function(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}},{key:"getHighlighted",value:function(){return this._highlighted}},{key:"setSelected",value:function(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}},{key:"getSelected",value:function(){return this._selected}},{key:"destroy",value:function(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}]),e}(),FF=function(){function e(t,i){var s=this;if(x(this,e),!(i.onHoverEnterPlane&&i.onHoverLeavePlane&&i.onClickedNothing&&i.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=t,this._viewer=t.viewer,this._onHoverEnterPlane=i.onHoverEnterPlane,this._onHoverLeavePlane=i.onHoverLeavePlane,this._onClickedNothing=i.onClickedNothing,this._onClickedPlane=i.onClickedPlane,this._visible=!0,this._planes={},this._canvas=i.overviewCanvas,this._scene=new Zi(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new yi(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new yi(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new yi(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;var r=this._scene.camera,n=$.rotationMat4c(-90*$.DEGTORAD,1,0,0),o=$.vec3(),a=$.vec3(),l=$.vec3();this._synchCamera=function(){var e=s._viewer.camera.eye,t=s._viewer.camera.look,i=s._viewer.camera.up;$.mulVec3Scalar($.normalizeVec3($.subVec3(e,t,o)),7),s._zUp?($.transformVec3(n,o,a),$.transformVec3(n,i,l),r.look=[0,0,0],r.eye=$.transformVec3(n,o,a),r.up=$.transformPoint3(n,i,l)):(r.look=[0,0,0],r.eye=o,r.up=i)},this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(function(e){s._scene.camera.perspective.fov=e}));var u=null;this._onInputMouseMove=this._scene.input.on("mousemove",(function(e){var t=s._scene.pick({canvasPos:e});if(t){if(!u||t.entity.id!==u.id){if(u)s._planes[u.id]&&s._onHoverLeavePlane(u.id);u=t.entity,s._planes[u.id]&&s._onHoverEnterPlane(u.id)}}else u&&(s._onHoverLeavePlane(u.id),u=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=function(){u?s._planes[u.id]&&s._onClickedPlane(u.id):s._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=function(){u&&(s._onHoverLeavePlane(u.id),u=null)}),this.setVisible(i.overviewVisible)}return C(e,[{key:"addSectionPlane",value:function(e){this._planes[e.id]=new MF(this,this._scene,e)}},{key:"setPlaneHighlighted",value:function(e,t){var i=this._planes[e];i&&i.setHighlighted(t)}},{key:"setPlaneSelected",value:function(e,t){var i=this._planes[e];i&&i.setSelected(t)}},{key:"removeSectionPlane",value:function(e){var t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}},{key:"getVisible",value:function(){return this._visible}},{key:"destroy",value:function(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}]),e}(),EF=$.AABB3(),kF=$.vec3(),IF=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,"SectionPlanes",e))._freeControls=[],s._sectionPlanes=e.scene.sectionPlanes,s._controls={},s._shownControlId=null,null!==r.overviewCanvasId&&void 0!==r.overviewCanvasId){var n=document.getElementById(r.overviewCanvasId);n?s._overview=new FF(b(s),{overviewCanvas:n,visible:r.overviewVisible,onHoverEnterPlane:function(e){s._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:function(e){s._overview.setPlaneHighlighted(e,!1)},onClickedPlane:function(e){if(s.getShownControl()!==e){s.showControl(e);var t=s.sectionPlanes[e].pos;EF.set(s.viewer.scene.aabb),$.getAABB3Center(EF,kF),EF[0]+=t[0]-kF[0],EF[1]+=t[1]-kF[1],EF[2]+=t[2]-kF[2],EF[3]+=t[0]-kF[0],EF[4]+=t[1]-kF[1],EF[5]+=t[2]-kF[2],s.viewer.cameraFlight.flyTo({aabb:EF,fitFOV:65})}else s.hideControl()},onClickedNothing:function(){s.hideControl()}}):s.warn("Can't find overview canvas: '"+r.overviewCanvasId+"' - will create plugin without overview")}return s._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(function(e){s._sectionPlaneCreated(e)})),s}return C(i,[{key:"setOverviewVisible",value:function(e){this._overview&&this._overview.setVisible(e)}},{key:"getOverviewVisible",value:function(){if(this._overview)return this._overview.getVisible()}},{key:"sectionPlanes",get:function(){return this._sectionPlanes}},{key:"createSectionPlane",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);var t=new An(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0});return t}},{key:"_sectionPlaneCreated",value:function(e){var t=this,i=this._freeControls.length>0?this._freeControls.pop():new CF(this);i._setSectionPlane(e),i.setVisible(!1),this._controls[e.id]=i,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(function(){t._sectionPlaneDestroyed(e)}))}},{key:"flipSectionPlanes",value:function(){var e=this.viewer.scene.sectionPlanes;for(var t in e){e[t].flipDir()}}},{key:"showControl",value:function(e){var t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}},{key:"getShownControl",value:function(){return this._shownControlId}},{key:"hideControl",value:function(){for(var e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}},{key:"destroySectionPlane",value:function(e){var t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}},{key:"_sectionPlaneDestroyed",value:function(e){this._overview&&this._overview.removeSectionPlane(e);var t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}},{key:"clear",value:function(){for(var e=Object.keys(this._sectionPlanes),t=0,i=e.length;t1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"StoreyViews",e))._objectsMemento=new ld,s._cameraMemento=new rd,s.storeys={},s.modelStoreys={},s._fitStoreyMaps=!!r.fitStoreyMaps,s._onModelLoaded=s.viewer.scene.on("modelLoaded",(function(e){s._registerModelStoreys(e),s.fire("storeys",s.storeys)})),s}return C(i,[{key:"_registerModelStoreys",value:function(e){var t=this,i=this.viewer,s=i.scene,r=i.metaScene,n=r.metaModels[e],o=s.models[e];if(n&&n.rootMetaObjects)for(var a=n.rootMetaObjects,l=0,u=a.length;l.5?p.length:0,g=new DF(this,o.aabb,f,e,d,v);g._onModelDestroyed=o.once("destroyed",(function(){t._deregisterModelStoreys(e),t.fire("storeys",t.storeys)})),this.storeys[d]=g,this.modelStoreys[e]||(this.modelStoreys[e]={}),this.modelStoreys[e][d]=g}}},{key:"_deregisterModelStoreys",value:function(e){var t=this.modelStoreys[e];if(t){var i=this.viewer.scene;for(var s in t)if(t.hasOwnProperty(s)){var r=t[s],n=i.models[r.modelId];n&&n.off(r._onModelDestroyed),delete this.storeys[s]}delete this.modelStoreys[e]}}},{key:"fitStoreyMaps",get:function(){return this._fitStoreyMaps}},{key:"gotoStoreyCamera",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),void(t.done&&t.done());var s=this.viewer,r=s.scene,n=r.camera,o=i.storeyAABB;if(o[3]1&&void 0!==arguments[1]?arguments[1]:{},i=this.storeys[e];if(i){var s=this.viewer,r=s.scene,n=s.metaScene,o=n.metaObjects[e];o&&(t.hideOthers&&r.setObjectsVisible(s.scene.visibleObjectIds,!1),this.withStoreyObjects(e,(function(e,t){e&&(e.visible=!0)})))}else this.error("IfcBuildingStorey not found with this ID: "+e)}},{key:"withStoreyObjects",value:function(e,t){var i=this.viewer,s=i.scene,r=i.metaScene,n=r.metaObjects[e];if(n)for(var o=n.getObjectIDsInSubtree(),a=0,l=o.length;a1&&void 0!==arguments[1]?arguments[1]:{},i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),LF;var s,r,n=this.viewer,o=n.scene,a=t.format||"png",l=this._fitStoreyMaps?i.storeyAABB:i.modelAABB,u=Math.abs((l[5]-l[2])/(l[3]-l[0])),A=t.padding||0;t.width&&t.height?(s=t.width,r=t.height):t.height?(r=t.height,s=Math.round(r/u)):t.width?(s=t.width,r=Math.round(s*u)):(s=300,r=Math.round(s*u)),this._objectsMemento.saveObjects(o),this._cameraMemento.saveCamera(o),this.showStoreyObjects(e,le.apply(t,{hideOthers:!0})),this._arrangeStoreyMapCamera(i);var c=n.getSnapshot({width:s,height:r,format:a});return this._objectsMemento.restoreObjects(o),this._cameraMemento.restoreCamera(o),new SF(e,c,a,s,r,A)}},{key:"_arrangeStoreyMapCamera",value:function(e){var t=this.viewer,i=t.scene.camera,s=this._fitStoreyMaps?e.storeyAABB:e.modelAABB,r=$.getAABB3Center(s),n=TF;n[0]=r[0]+.5*i.worldUp[0],n[1]=r[1]+.5*i.worldUp[1],n[2]=r[2]+.5*i.worldUp[2];var o=i.worldForward;t.cameraFlight.jumpTo({eye:n,look:r,up:o});var a=(s[3]-s[0])/2,l=(s[4]-s[1])/2,u=(s[5]-s[2])/2,A=-a,c=+a,h=-l,d=+l,p=-u,f=+u;t.camera.customProjection.matrix=$.orthoMat4c(A,c,p,f,h,d,RF),t.camera.projection="customProjection"}},{key:"pickStoreyMap",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),null;var n=1-t[0]/e.width,o=1-t[1]/e.height,a=this._fitStoreyMaps?r.storeyAABB:r.modelAABB,l=a[0],u=a[1],A=a[2],c=a[3],h=a[4],d=a[5],p=c-l,f=h-u,v=d-A,g=$.vec3([l+p*n,u+.5*f,A+v*o]),m=$.vec3([0,-1,0]),_=$.addVec3(g,m,TF),y=this.viewer.camera.worldForward,b=$.lookAtMat4v(g,_,y,RF),B=this.viewer.scene.pick({pickSurface:i.pickSurface,pickInvisible:!0,matrix:b});return B}},{key:"storeyMapToWorldPos",value:function(e,t){var i=e.storeyId,s=this.storeys[i];if(!s)return this.error("IfcBuildingStorey not found with this ID: "+i),null;var r=1-t[0]/e.width,n=1-t[1]/e.height,o=this._fitStoreyMaps?s.storeyAABB:s.modelAABB,a=o[0],l=o[1],u=o[2],A=o[3],c=o[4],h=o[5],d=A-a,p=c-l,f=h-u,v=$.vec3([a+d*r,l+.5*p,u+f*n]);return v}},{key:"getStoreyContainingWorldPos",value:function(e){for(var t in this.storeys){var i=this.storeys[t];if($.point3AABB3Intersect(i.storeyAABB,e))return t}return null}},{key:"worldPosToStoreyMap",value:function(e,t,i){var s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),!1;var n=this._fitStoreyMaps?r.storeyAABB:r.modelAABB,o=n[0],a=n[1],l=n[2],u=n[3]-o,A=n[4]-a,c=n[5]-l,h=this.viewer.camera.worldUp,d=h[0]>h[1]&&h[0]>h[2],p=!d&&h[1]>h[0]&&h[1]>h[2];!d&&!p&&h[2]>h[0]&&(h[2],h[1]);var f=e.width/u,v=p?e.height/c:e.height/A;return i[0]=Math.floor(e.width-(t[0]-o)*f),i[1]=Math.floor(e.height-(t[2]-l)*v),i[0]>=0&&i[0]=0&&i[1]<=e.height}},{key:"worldDirToStoreyMap",value:function(e,t,i){var s=this.viewer.camera,r=s.eye,n=s.look,o=$.subVec3(n,r,TF),a=s.worldUp,l=a[0]>a[1]&&a[0]>a[2],u=!l&&a[1]>a[0]&&a[1]>a[2];!l&&!u&&a[2]>a[0]&&(a[2],a[1]),l?(i[0]=o[1],i[1]=o[2]):u?(i[0]=o[0],i[1]=o[2]):(i[0]=o[0],i[1]=o[1]),$.normalizeVec2(i)}},{key:"destroy",value:function(){this.viewer.scene.off(this._onModelLoaded),f(B(i.prototype),"destroy",this).call(this)}}]),i}(),OF=new Float64Array([0,0,1]),NF=new Float64Array(4),QF=function(){function e(t){x(this,e),this.id=null,this._viewer=t.viewer,this._plugin=t,this._visible=!1,this._pos=$.vec3(),this._origin=$.vec3(),this._rtcPos=$.vec3(),this._baseDir=$.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}return C(e,[{key:"_setSectionPlane",value:function(e){var t=this;this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(function(){t._setPos(t._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(function(){t._ignoreNextSectionPlaneDirUpdate?t._ignoreNextSectionPlaneDirUpdate=!1:t._setDir(t._sectionPlane.dir)})))}},{key:"sectionPlane",get:function(){return this._sectionPlane}},{key:"_setPos",value:function(e){this._pos.set(e),Le(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}},{key:"_setDir",value:function(e){this._baseDir.set(e),this._rootNode.quaternion=$.vec3PairToQuaternion(OF,e,NF)}},{key:"_setSectionPlaneDir",value:function(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}},{key:"getVisible",value:function(){return this._visible}},{key:"setCulled",value:function(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}},{key:"_createNodes",value:function(){var e=!1,t=this._viewer.scene,i=.01;this._rootNode=new yn(t,{position:[0,0,0],scale:[5,5,5]});var s=this._rootNode,r={arrowHead:new Si(s,nn({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Si(s,nn({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new Si(s,nn({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},n={red:new Oi(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new Oi(s,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new Oi(s,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Qi(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:s.addChild(new sn(s,{geometry:new Si(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Oi(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1]}),e),planeFrame:s.addChild(new sn(s,{geometry:new Si(s,Xn({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Oi(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45]}),e),center:s.addChild(new sn(s,{geometry:new Si(s,on({radius:.05})),material:n.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:s.addChild(new sn(s,{geometry:r.arrowHead,material:n.blue,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:s.addChild(new sn(s,{geometry:r.axis,material:n.blue,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new sn(s,{geometry:new Si(s,Xn({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Oi(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Qi(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45]}),e),zAxisArrow:s.addChild(new sn(s,{geometry:r.arrowHeadBig,material:n.blue,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}},{key:"_bindEvents",value:function(){var e=this,t=this._rootNode,i=$.vec2(),s=this._viewer.camera,r=this._viewer.scene,n=0,o=!1,a=$.vec3([0,0,0]),l=-1;this._onCameraViewMatrix=r.camera.on("viewMatrix",(function(){})),this._onCameraProjMatrix=r.camera.on("projMatrix",(function(){})),this._onSceneTick=r.on("tick",(function(){o=!1;var i=Math.abs($.lenVec3($.subVec3(r.camera.eye,e._pos,a)));if(i!==l&&"perspective"===s.projection){var u=.07*(Math.tan(s.perspective.fov*$.DEGTORAD)*i);t.scale=[u,u,u],l=i}if("ortho"===s.projection){var c=s.ortho.scale/10;t.scale=[c,c,c],l=i}0!==n&&(A(n),n=0)}));var u=function(){var e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),A=function(t){var i=e._sectionPlane.pos,s=e._sectionPlane.dir;$.addVec3(i,$.mulVec3Scalar(s,.1*t*e._plugin.getDragSensitivity(),$.vec3())),e._sectionPlane.pos=i},c=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=function(t){if(t.preventDefault(),e._visible&&(e._viewer.cameraControl.pointerEnabled=!1,1===t.which)){c=!0;var s=u(t);i[0]=s[0],i[1]=s[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=function(t){if(e._visible&&c&&!o){var s=u(t),r=s[0],n=s[1];A(n-i[1]),i[0]=r,i[1]=n}}),this._plugin._controlElement.addEventListener("mouseup",this._canvasMouseUpListener=function(t){e._visible&&(e._viewer.cameraControl.pointerEnabled=!0,c&&(t.which,c=!1))}),this._plugin._controlElement.addEventListener("wheel",this._canvasWheelListener=function(t){e._visible&&(n+=Math.max(-1,Math.min(1,40*-t.deltaY)))});var h,d,p=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=function(t){t.stopPropagation(),t.preventDefault(),e._visible&&(h=t.touches[0].clientY,p=h,n=0)}),this._plugin._controlElement.addEventListener("touchmove",this._handleTouchMove=function(t){t.stopPropagation(),t.preventDefault(),e._visible&&(o||(o=!0,d=t.touches[0].clientY,null!==p&&(n+=d-p),p=d))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=function(t){t.stopPropagation(),t.preventDefault(),e._visible&&(h=null,d=null,n=0)})}},{key:"_destroy",value:function(){this._unbindEvents(),this._destroyNodes()}},{key:"_unbindEvents",value:function(){var e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix)}},{key:"_destroyNodes",value:function(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}]),e}(),VF=function(){function e(t,i,s){var r=this;x(this,e),this.id=s.id,this._sectionPlane=s,this._mesh=new sn(i,{id:s.id,geometry:new Si(i,Ti({xSize:.5,ySize:.5,zSize:.001})),material:new Oi(i,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new Hi(i,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Qi(i,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Qi(i,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});var n=$.vec3([0,0,0]),o=$.vec3(),a=$.vec3([0,0,1]),l=$.vec4(4),u=$.vec3(),A=function(){var e=r._sectionPlane.scene.center,t=[-r._sectionPlane.dir[0],-r._sectionPlane.dir[1],-r._sectionPlane.dir[2]];$.subVec3(e,r._sectionPlane.pos,n);var i=-$.dotVec3(t,n);$.normalizeVec3(t),$.mulVec3Scalar(t,i,o);var s=$.vec3PairToQuaternion(a,r._sectionPlane.dir,l);u[0]=.1*o[0],u[1]=.1*o[1],u[2]=.1*o[2],r._mesh.quaternion=s,r._mesh.position=u};this._onSectionPlanePos=this._sectionPlane.on("pos",A),this._onSectionPlaneDir=this._sectionPlane.on("dir",A),this._highlighted=!1,this._selected=!1}return C(e,[{key:"setHighlighted",value:function(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}},{key:"getHighlighted",value:function(){return this._highlighted}},{key:"setSelected",value:function(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}},{key:"getSelected",value:function(){return this._selected}},{key:"destroy",value:function(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}]),e}(),HF=function(){function e(t,i){var s=this;if(x(this,e),!(i.onHoverEnterPlane&&i.onHoverLeavePlane&&i.onClickedNothing&&i.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=t,this._viewer=t.viewer,this._onHoverEnterPlane=i.onHoverEnterPlane,this._onHoverLeavePlane=i.onHoverLeavePlane,this._onClickedNothing=i.onClickedNothing,this._onClickedPlane=i.onClickedPlane,this._visible=!0,this._planes={},this._canvas=i.overviewCanvas,this._scene=new Zi(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new yi(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new yi(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new yi(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;var r=this._scene.camera,n=$.rotationMat4c(-90*$.DEGTORAD,1,0,0),o=$.vec3(),a=$.vec3(),l=$.vec3();this._synchCamera=function(){var e=s._viewer.camera.eye,t=s._viewer.camera.look,i=s._viewer.camera.up;$.mulVec3Scalar($.normalizeVec3($.subVec3(e,t,o)),7),s._zUp?($.transformVec3(n,o,a),$.transformVec3(n,i,l),r.look=[0,0,0],r.eye=$.transformVec3(n,o,a),r.up=$.transformPoint3(n,i,l)):(r.look=[0,0,0],r.eye=o,r.up=i)},this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(function(e){s._scene.camera.perspective.fov=e}));var u=null;this._onInputMouseMove=this._scene.input.on("mousemove",(function(e){var t=s._scene.pick({canvasPos:e});if(t){if(!u||t.entity.id!==u.id){if(u)s._planes[u.id]&&s._onHoverLeavePlane(u.id);u=t.entity,s._planes[u.id]&&s._onHoverEnterPlane(u.id)}}else u&&(s._onHoverLeavePlane(u.id),u=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=function(){u?s._planes[u.id]&&s._onClickedPlane(u.id):s._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=function(){u&&(s._onHoverLeavePlane(u.id),u=null)}),this.setVisible(i.overviewVisible)}return C(e,[{key:"addSectionPlane",value:function(e){this._planes[e.id]=new VF(this,this._scene,e)}},{key:"setPlaneHighlighted",value:function(e,t){var i=this._planes[e];i&&i.setHighlighted(t)}},{key:"setPlaneSelected",value:function(e,t){var i=this._planes[e];i&&i.setSelected(t)}},{key:"removeSectionPlane",value:function(e){var t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}},{key:"getVisible",value:function(){return this._visible}},{key:"destroy",value:function(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}]),e}(),jF=$.AABB3(),GF=$.vec3(),zF=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,"FaceAlignedSectionPlanesPlugin",e))._freeControls=[],s._sectionPlanes=e.scene.sectionPlanes,s._controls={},s._shownControlId=null,s._dragSensitivity=r.dragSensitivity||1,null!==r.overviewCanvasId&&void 0!==r.overviewCanvasId){var n=document.getElementById(r.overviewCanvasId);n?s._overview=new HF(b(s),{overviewCanvas:n,visible:r.overviewVisible,onHoverEnterPlane:function(e){s._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:function(e){s._overview.setPlaneHighlighted(e,!1)},onClickedPlane:function(e){if(s.getShownControl()!==e){s.showControl(e);var t=s.sectionPlanes[e].pos;jF.set(s.viewer.scene.aabb),$.getAABB3Center(jF,GF),jF[0]+=t[0]-GF[0],jF[1]+=t[1]-GF[1],jF[2]+=t[2]-GF[2],jF[3]+=t[0]-GF[0],jF[4]+=t[1]-GF[1],jF[5]+=t[2]-GF[2],s.viewer.cameraFlight.flyTo({aabb:jF,fitFOV:65})}else s.hideControl()},onClickedNothing:function(){s.hideControl()}}):s.warn("Can't find overview canvas: '"+r.overviewCanvasId+"' - will create plugin without overview")}return null===r.controlElementId||void 0===r.controlElementId?s.error("Parameter expected: controlElementId"):(s._controlElement=document.getElementById(r.controlElementId),s._controlElement||s.warn("Can't find control element: '"+r.controlElementId+"' - will create plugin without control element")),s._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(function(e){s._sectionPlaneCreated(e)})),s}return C(i,[{key:"setDragSensitivity",value:function(e){this._dragSensitivity=e||1}},{key:"getDragSensitivity",value:function(){return this._dragSensitivity}},{key:"setOverviewVisible",value:function(e){this._overview&&this._overview.setVisible(e)}},{key:"getOverviewVisible",value:function(){if(this._overview)return this._overview.getVisible()}},{key:"sectionPlanes",get:function(){return this._sectionPlanes}},{key:"createSectionPlane",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);var t=new An(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0});return t}},{key:"_sectionPlaneCreated",value:function(e){var t=this,i=this._freeControls.length>0?this._freeControls.pop():new QF(this);i._setSectionPlane(e),i.setVisible(!1),this._controls[e.id]=i,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(function(){t._sectionPlaneDestroyed(e)}))}},{key:"flipSectionPlanes",value:function(){var e=this.viewer.scene.sectionPlanes;for(var t in e){e[t].flipDir()}}},{key:"showControl",value:function(e){var t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}},{key:"getShownControl",value:function(){return this._shownControlId}},{key:"hideControl",value:function(){for(var e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}},{key:"destroySectionPlane",value:function(e){var t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}},{key:"_sectionPlaneDestroyed",value:function(e){this._overview&&this._overview.removeSectionPlane(e);var t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}},{key:"clear",value:function(){for(var e=Object.keys(this._sectionPlanes),t=0,i=e.length;t>5&31)/31,o=(F>>10&31)/31):(r=l,n=u,o=A),(B&&r!==p||n!==f||o!==v)&&(null!==p&&(g=!0),p=r,f=n,v=o)}for(var E=1;E<=3;E++){var k=x+12*E;y.push(c.getFloat32(k,!0)),y.push(c.getFloat32(k+4,!0)),y.push(c.getFloat32(k+8,!0)),b.push(P,C,M),d&&a.push(r,n,o,1)}B&&g&&($F(i,y,b,a,_,s),y=[],b=[],a=a?[]:null,g=!1)}y.length>0&&$F(i,y,b,a,_,s)}function qF(e,t,i,s){for(var r,n,o,a,l,u,A,c=/facet([\s\S]*?)endfacet/g,h=0,d=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,p=new RegExp("vertex"+d+d+d,"g"),f=new RegExp("normal"+d+d+d,"g"),v=[],g=[];null!==(a=c.exec(t));){for(l=0,u=0,A=a[0];null!==(a=f.exec(A));)r=parseFloat(a[1]),n=parseFloat(a[2]),o=parseFloat(a[3]),u++;for(;null!==(a=p.exec(A));)v.push(parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3])),g.push(r,n,o),l++;1!==u&&e.error("Error in normal of face "+h),3!==l&&e.error("Error in positions of face "+h),h++}$F(i,v,g,null,new xn(i,{roughness:.5}),s)}function $F(e,t,i,s,r,n){for(var o=new Int32Array(t.length/3),a=0,l=o.length;a0?i:null,s=s&&s.length>0?s:null,n.smoothNormals&&$.faceToVertexNormals(t,i,n);var u=XF;Ue(t,t,u);var A=new Si(e,{primitive:"triangles",positions:t,normals:i,colors:s,indices:o}),c=new sn(e,{origin:0!==u[0]||0!==u[1]||0!==u[2]?u:null,geometry:A,material:r,edges:n.edges});e.addChild(c)}function eE(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",i=0,s=e.length;i1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"STLLoader",e,r))._sceneGraphLoader=new JF,s.dataSource=r.dataSource,s}return C(i,[{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new KF}},{key:"load",value:function(e){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new yn(this.viewer.scene,le.apply(e,{isModel:!0})),i=e.src,s=e.stl;return i||s?(i?this._sceneGraphLoader.load(this,t,i,e):this._sceneGraphLoader.parse(this,t,s,e),t):(this.error("load() param expected: either 'src' or 'stl'"),t)}}]),i}(),sE=function(){function e(){x(this,e)}return C(e,[{key:"createRootNode",value:function(){return document.createElement("ul")}},{key:"createNodeElement",value:function(e,t,i,s,r){var n=document.createElement("li");if(n.id=e.nodeId,e.xrayed&&n.classList.add("xrayed-node"),e.children.length>0){var o=document.createElement("a");o.href="#",o.id="switch-".concat(e.nodeId),o.textContent="+",o.classList.add("plus"),t&&o.addEventListener("click",t),n.appendChild(o)}var a=document.createElement("input");a.id="checkbox-".concat(e.nodeId),a.type="checkbox",a.checked=e.checked,a.style["pointer-events"]="all",i&&a.addEventListener("change",i),n.appendChild(a);var l=document.createElement("span");return l.textContent=e.title,n.appendChild(l),s&&(l.oncontextmenu=s),r&&(l.onclick=r),n}},{key:"createDisabledNodeElement",value:function(e){var t=document.createElement("li"),i=document.createElement("a");i.href="#",i.textContent="!",i.classList.add("warn"),i.classList.add("warning"),t.appendChild(i);var s=document.createElement("span");return s.textContent=e,t.appendChild(s),t}},{key:"addChildren",value:function(e,t){var i=document.createElement("ul");t.forEach((function(e){i.appendChild(e)})),e.parentElement.appendChild(i)}},{key:"expand",value:function(e,t,i){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",i)}},{key:"collapse",value:function(e,t,i){if(e){var s=e.parentElement;if(s){var r=s.querySelector("ul");r&&(s.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",i),e.addEventListener("click",t))}}}},{key:"isExpanded",value:function(e){return void 0!==e.parentElement.getElementsByTagName("li")[0]}},{key:"getId",value:function(e){return e.parentElement.id}},{key:"getIdFromCheckbox",value:function(e){return e.id.replace("checkbox-","")}},{key:"getSwitchElement",value:function(e){return document.getElementById("switch-".concat(e))}},{key:"isChecked",value:function(e){return e.checked}},{key:"setCheckbox",value:function(e,t){var i=document.getElementById("checkbox-".concat(e));i&&t!==i.checked&&(i.checked=t)}},{key:"setXRayed",value:function(e,t){var i=document.getElementById(e);i&&(t?i.classList.add("xrayed-node"):i.classList.remove("xrayed-node"))}},{key:"setHighlighted",value:function(e,t){var i=document.getElementById(e);i&&(t?(i.scrollIntoView({block:"center"}),i.classList.add("highlighted-node")):i.classList.remove("highlighted-node"))}}]),e}(),rE=[],nE=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(s=t.call(this,"TreeViewPlugin",e)).errors=[],s.valid=!0;var n=r.containerElement||document.getElementById(r.containerElementId);if(!(n instanceof HTMLElement))return s.error("Mandatory config expected: valid containerElementId or containerElement"),y(s);for(var o=0;;o++)if(!rE[o]){rE[o]=b(s),s._index=o,s._id="tree-".concat(o);break}if(s._containerElement=n,s._metaModels={},s._autoAddModels=!1!==r.autoAddModels,s._autoExpandDepth=r.autoExpandDepth||0,s._sortNodes=!1!==r.sortNodes,s._viewer=e,s._rootElement=null,s._muteSceneEvents=!1,s._muteTreeEvents=!1,s._rootNodes=[],s._objectNodes={},s._nodeNodes={},s._rootNames={},s._sortNodes=r.sortNodes,s._pruneEmptyNodes=r.pruneEmptyNodes,s._showListItemElementId=null,s._renderService=r.renderService||new sE,!s._renderService)throw new Error("TreeViewPlugin: no render service set");if(s._containerElement.oncontextmenu=function(e){e.preventDefault()},s._onObjectVisibility=s._viewer.scene.on("objectVisibility",(function(e){if(!s._muteSceneEvents){var t=e.id,i=s._objectNodes[t];if(i){var r=e.visible;if(r!==i.checked){s._muteTreeEvents=!0,i.checked=r,r?i.numVisibleEntities++:i.numVisibleEntities--,s._renderService.setCheckbox(i.nodeId,r);for(var n=i.parent;n;)n.checked=r,r?n.numVisibleEntities++:n.numVisibleEntities--,s._renderService.setCheckbox(n.nodeId,n.numVisibleEntities>0),n=n.parent;s._muteTreeEvents=!1}}}})),s._onObjectXrayed=s._viewer.scene.on("objectXRayed",(function(e){if(!s._muteSceneEvents){var t=e.id,i=s._objectNodes[t];if(i){s._muteTreeEvents=!0;var r=e.xrayed;r!==i.xrayed&&(i.xrayed=r,s._renderService.setXRayed(i.nodeId,r),s._muteTreeEvents=!1)}}})),s._switchExpandHandler=function(e){e.preventDefault(),e.stopPropagation();var t=e.target;s._expandSwitchElement(t)},s._switchCollapseHandler=function(e){e.preventDefault(),e.stopPropagation();var t=e.target;s._collapseSwitchElement(t)},s._checkboxChangeHandler=function(e){if(!s._muteTreeEvents){s._muteSceneEvents=!0;var t=e.target,i=s._renderService.isChecked(t),r=s._renderService.getIdFromCheckbox(t),n=s._nodeNodes[r],o=s._viewer.scene.objects,a=0;s._withNodeTree(n,(function(e){var t=e.objectId,r=o[t],n=0===e.children.length;e.numVisibleEntities=i?e.numEntities:0,n&&i!==e.checked&&a++,e.checked=i,s._renderService.setCheckbox(e.nodeId,i),r&&(r.visible=i)}));for(var l=n.parent;l;)l.checked=i,i?l.numVisibleEntities+=a:l.numVisibleEntities-=a,s._renderService.setCheckbox(l.nodeId,l.numVisibleEntities>0),l=l.parent;s._muteSceneEvents=!1}},s._hierarchy=r.hierarchy||"containment",s._autoExpandDepth=r.autoExpandDepth||0,s._autoAddModels){for(var a=Object.keys(s.viewer.metaScene.metaModels),l=0,u=a.length;l1&&void 0!==arguments[1]?arguments[1]:{};if(this._containerElement){var s=this.viewer.scene.models[e];if(!s)throw"Model not found: "+e;var r=this.viewer.metaScene.metaModels[e];r?this._metaModels[e]?this.warn("Model already added: "+e):(this._metaModels[e]=r,i&&i.rootName&&(this._rootNames[e]=i.rootName),s.on("destroyed",(function(){t.removeModel(s.id)})),this._createNodes()):this.error("MetaModel not found: "+e)}}},{key:"removeModel",value:function(e){this._containerElement&&(this._metaModels[e]&&(this._rootNames[e]&&delete this._rootNames[e],delete this._metaModels[e],this._createNodes()))}},{key:"showNode",value:function(e){this.unShowNode();var t=this._objectNodes[e];if(t){var i=t.nodeId,s=this._renderService.getSwitchElement(i);if(s)return this._expandSwitchElement(s),s.scrollIntoView(),!0;var r=[];r.unshift(t);for(var n=t.parent;n;)r.unshift(n),n=n.parent;for(var o=0,a=r.length;o0;return this.valid}},{key:"_validateMetaModelForStoreysHierarchy",value:function(){return!0}},{key:"_createEnabledNodes",value:function(){switch(this._pruneEmptyNodes&&this._findEmptyNodes(),this._hierarchy){case"storeys":this._createStoreysNodes(),0===this._rootNodes.length&&this.error("Failed to build storeys hierarchy");break;case"types":this._createTypesNodes();break;default:this._createContainmentNodes()}this._sortNodes&&this._doSortNodes(),this._synchNodesToEntities(),this._createTrees(),this.expandToDepth(this._autoExpandDepth)}},{key:"_createDisabledNodes",value:function(){var e=this._renderService.createRootNode();this._rootElement=e,this._containerElement.appendChild(e);var t=this._viewer.metaScene.rootMetaObjects;for(var i in t){var s=t[i],r=s.type,n=s.name,o=n&&""!==n&&"Undefined"!==n&&"Default"!==n?n:r,a=this._renderService.createDisabledNodeElement(o);e.appendChild(a)}}},{key:"_findEmptyNodes",value:function(){var e=this._viewer.metaScene.rootMetaObjects;for(var t in e)this._findEmptyNodes2(e[t])}},{key:"_findEmptyNodes2",value:function(e){var t=this.viewer,i=t.scene,s=e.children,r=e.id,n=i.objects[r];if(e._countEntities=0,n&&e._countEntities++,s)for(var o=0,a=s.length;or.aabb[n]?-1:e.aabb[n]s?1:0}},{key:"_synchNodesToEntities",value:function(){for(var e=Object.keys(this.viewer.metaScene.metaObjects),t=this._viewer.metaScene.metaObjects,i=this._viewer.scene.objects,s=0,r=e.length;s0){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"ViewCull",e))._objectCullStates=lE(e.scene),s._maxTreeDepth=r.maxTreeDepth||8,s._modelInfos={},s._frustum=new Me,s._kdRoot=null,s._frustumDirty=!1,s._kdTreeDirty=!1,s._onViewMatrix=e.scene.camera.on("viewMatrix",(function(){s._frustumDirty=!0})),s._onProjMatrix=e.scene.camera.on("projMatMatrix",(function(){s._frustumDirty=!0})),s._onModelLoaded=e.scene.on("modelLoaded",(function(e){var t=s.viewer.scene.models[e];t&&s._addModel(t)})),s._onSceneTick=e.scene.on("tick",(function(){s._doCull()})),s}return C(i,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}},{key:"_addModel",value:function(e){var t=this,i={model:e,onDestroyed:e.on("destroyed",(function(){t._removeModel(e)}))};this._modelInfos[e.id]=i,this._kdTreeDirty=!0}},{key:"_removeModel",value:function(e){var t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._kdTreeDirty=!0)}},{key:"_doCull",value:function(){var e=this._frustumDirty||this._kdTreeDirty;if(this._frustumDirty&&this._buildFrustum(),this._kdTreeDirty&&this._buildKDTree(),e){var t=this._kdRoot;t&&this._visitKDNode(t)}}},{key:"_buildFrustum",value:function(){var e=this.viewer.scene.camera;Fe(this._frustum,e.viewMatrix,e.projMatrix),this._frustumDirty=!1}},{key:"_buildKDTree",value:function(){var e=this.viewer.scene;this._kdRoot,this._kdRoot={aabb:e.getAABB(),intersection:Me.INTERSECT};for(var t=0,i=this._objectCullStates.numObjects;t=this._maxTreeDepth)return e.objects=e.objects||[],e.objects.push(i),void $.expandAABB3(e.aabb,r);if(e.left&&$.containsAABB3(e.left.aabb,r))this._insertEntityIntoKDTree(e.left,t,i,s+1);else if(e.right&&$.containsAABB3(e.right.aabb,r))this._insertEntityIntoKDTree(e.right,t,i,s+1);else{var n=e.aabb;uE[0]=n[3]-n[0],uE[1]=n[4]-n[1],uE[2]=n[5]-n[2];var o=0;if(uE[1]>uE[o]&&(o=1),uE[2]>uE[o]&&(o=2),!e.left){var a=n.slice();if(a[o+3]=(n[o]+n[o+3])/2,e.left={aabb:a,intersection:Me.INTERSECT},$.containsAABB3(a,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1)}if(!e.right){var l=n.slice();if(l[o]=(n[o]+n[o+3])/2,e.right={aabb:l,intersection:Me.INTERSECT},$.containsAABB3(l,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1)}e.objects=e.objects||[],e.objects.push(i),$.expandAABB3(e.aabb,r)}}},{key:"_visitKDNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Me.INTERSECT;if(t===Me.INTERSECT||e.intersects!==t){t===Me.INTERSECT&&(t=Ee(this._frustum,e.aabb),e.intersects=t);var i=t===Me.OUTSIDE,s=e.objects;if(s&&s.length>0)for(var r=0,n=s.length;r=0;)e[t]=0}var i=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),s=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o=new Array(576);t(o);var a=new Array(60);t(a);var l=new Array(512);t(l);var u=new Array(256);t(u);var A=new Array(29);t(A);var c,h,d,p=new Array(30);function f(e,t,i,s,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=s,this.max_length=r,this.has_stree=e&&e.length}function v(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}t(p);var g=function(e){return e<256?l[e]:l[256+(e>>>7)]},m=function(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},_=function(e,t,i){e.bi_valid>16-i?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<>>=1,i<<=1}while(--t>0);return i>>>1},B=function(e,t,i){var s,r,n=new Array(16),o=0;for(s=1;s<=15;s++)o=o+i[s-1]<<1,n[s]=o;for(r=0;r<=t;r++){var a=e[2*r+1];0!==a&&(e[2*r]=b(n[a]++,a))}},x=function(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},P=function(e){e.bi_valid>8?m(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},C=function(e,t,i,s){var r=2*t,n=2*i;return e[r]>1;i>=1;i--)M(e,n,i);r=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],M(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=s,n[2*r]=n[2*i]+n[2*s],e.depth[r]=(e.depth[i]>=e.depth[s]?e.depth[i]:e.depth[s])+1,n[2*i+1]=n[2*s+1]=r,e.heap[1]=r++,M(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,s,r,n,o,a,l=t.dyn_tree,u=t.max_code,A=t.stat_desc.static_tree,c=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,f=0;for(n=0;n<=15;n++)e.bl_count[n]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<573;i++)(n=l[2*l[2*(s=e.heap[i])+1]+1]+1)>p&&(n=p,f++),l[2*s+1]=n,s>u||(e.bl_count[n]++,o=0,s>=d&&(o=h[s-d]),a=l[2*s],e.opt_len+=a*(n+o),c&&(e.static_len+=a*(A[2*s+1]+o)));if(0!==f){do{for(n=p-1;0===e.bl_count[n];)n--;e.bl_count[n]--,e.bl_count[n+1]+=2,e.bl_count[p]--,f-=2}while(f>0);for(n=p;0!==n;n--)for(s=e.bl_count[n];0!==s;)(r=e.heap[--i])>u||(l[2*r+1]!==n&&(e.opt_len+=(n-l[2*r+1])*l[2*r],l[2*r+1]=n),s--)}}(e,t),B(n,u,e.bl_count)},k=function(e,t,i){var s,r,n=-1,o=t[1],a=0,l=7,u=4;for(0===o&&(l=138,u=3),t[2*(i+1)+1]=65535,s=0;s<=i;s++)r=o,o=t[2*(s+1)+1],++a>=7;v<30;v++)for(p[v]=g<<7,e=0;e<1<0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),E(e,e.l_desc),E(e,e.d_desc),u=function(e){var t;for(k(e,e.dyn_ltree,e.l_desc.max_code),k(e,e.dyn_dtree,e.d_desc.max_code),E(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*n[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(l=e.static_len+3+7>>>3)<=r&&(r=l)):r=l=i+5,i+4<=r&&-1!==t?S(e,t,i,s):4===e.strategy||l===r?(_(e,2+(s?1:0),3),F(e,o,a)):(_(e,4+(s?1:0),3),function(e,t,i,s){var r;for(_(e,t-257,5),_(e,i-1,5),_(e,s-4,4),r=0;r>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(u[i]+256+1)]++,e.dyn_dtree[2*g(t)]++),e.sym_next===e.sym_end},O=function(e){_(e,2,3),y(e,256,o),function(e){16===e.bi_valid?(m(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)},N=function(e,t,i,s){for(var r=65535&e|0,n=e>>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(r=r+t[s++]|0)|0}while(--o);r%=65521,n%=65521}return r|n<<16|0},Q=new Uint32Array(function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}()),V=function(e,t,i,s){var r=Q,n=s+i;e^=-1;for(var o=s;o>>8^r[255&(e^t[o])];return-1^e},H={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},j={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},G=T,z=R,W=L,K=U,X=O,J=j.Z_NO_FLUSH,Y=j.Z_PARTIAL_FLUSH,Z=j.Z_FULL_FLUSH,q=j.Z_FINISH,$=j.Z_BLOCK,ee=j.Z_OK,te=j.Z_STREAM_END,ie=j.Z_STREAM_ERROR,se=j.Z_DATA_ERROR,re=j.Z_BUF_ERROR,ne=j.Z_DEFAULT_COMPRESSION,oe=j.Z_FILTERED,ae=j.Z_HUFFMAN_ONLY,le=j.Z_RLE,ue=j.Z_FIXED,Ae=j.Z_UNKNOWN,ce=j.Z_DEFLATED,he=258,de=262,pe=42,fe=113,ve=666,ge=function(e,t){return e.msg=H[t],t},me=function(e){return 2*e-(e>4?9:0)},_e=function(e){for(var t=e.length;--t>=0;)e[t]=0},ye=function(e){var t,i,s,r=e.w_size;s=t=e.hash_size;do{i=e.head[--s],e.head[s]=i>=r?i-r:0}while(--t);s=t=r;do{i=e.prev[--s],e.prev[s]=i>=r?i-r:0}while(--t)},be=function(e,t,i){return(t<e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},we=function(e,t){W(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Be(e.strm)},xe=function(e,t){e.pending_buf[e.pending++]=t},Pe=function(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ce=function(e,t,i,s){var r=e.avail_in;return r>s&&(r=s),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=N(e.adler,t,r,i):2===e.state.wrap&&(e.adler=V(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},Me=function(e,t){var i,s,r=e.max_chain_length,n=e.strstart,o=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-de?e.strstart-(e.w_size-de):0,u=e.window,A=e.w_mask,c=e.prev,h=e.strstart+he,d=u[n+o-1],p=u[n+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(i=t)+o]===p&&u[i+o-1]===d&&u[i]===u[n]&&u[++i]===u[n+1]){n+=2,i++;do{}while(u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&no){if(e.match_start=t,o=s,s>=a)break;d=u[n+o-1],p=u[n+o]}}}while((t=c[t&A])>l&&0!=--r);return o<=e.lookahead?o:e.lookahead},Fe=function(e){var t,i,s,r=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=r+(r-de)&&(e.window.set(e.window.subarray(r,r+r-i),0),e.match_start-=r,e.strstart-=r,e.block_start-=r,e.insert>e.strstart&&(e.insert=e.strstart),ye(e),i+=r),0===e.strm.avail_in)break;if(t=Ce(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=t,e.lookahead+e.insert>=3)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=be(e,e.ins_h,e.window[s+1]);e.insert&&(e.ins_h=be(e,e.ins_h,e.window[s+3-1]),e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookaheade.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_out(s=e.strstart-e.block_start)+e.strm.avail_in&&(i=s+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,Be(e.strm),s&&(s>i&&(s=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,i-=s),i&&(Ce(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return(a-=e.strm.avail_in)&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Ce(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,n=(r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r)>e.w_size?e.w_size:r,((s=e.strstart-e.block_start)>=n||(s||t===q)&&t!==J&&0===e.strm.avail_in&&s<=r)&&(i=s>r?r:s,o=t===q&&0===e.strm.avail_in&&i===s?1:0,z(e,e.block_start,i,o),e.block_start+=i,Be(e.strm)),o?3:1)},ke=function(e,t){for(var i,s;;){if(e.lookahead=3&&(e.ins_h=be(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-de&&(e.match_length=Me(e,i)),e.match_length>=3)if(s=K(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=be(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=be(e,e.ins_h,e.window[e.strstart+1]);else s=K(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(we(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===q?(we(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(we(e,!1),0===e.strm.avail_out)?1:2},Ie=function(e,t){for(var i,s,r;;){if(e.lookahead=3&&(e.ins_h=be(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,s=K(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=be(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,s&&(we(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((s=K(e,0,e.window[e.strstart-1]))&&we(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=K(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===q?(we(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(we(e,!1),0===e.strm.avail_out)?1:2};function De(e,t,i,s,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=s,this.func=r}var Se=[new De(0,0,0,0,Ee),new De(4,4,8,4,ke),new De(4,5,16,8,ke),new De(4,6,32,32,ke),new De(4,4,16,16,Ie),new De(8,16,32,32,Ie),new De(8,16,128,128,Ie),new De(8,32,128,256,Ie),new De(32,128,258,1024,Ie),new De(32,258,258,4096,Ie)];function Te(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ce,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),_e(this.dyn_ltree),_e(this.dyn_dtree),_e(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),_e(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),_e(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Re=function(e){if(!e)return 1;var t=e.state;return!t||t.strm!==e||t.status!==pe&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==fe&&t.status!==ve?1:0},Le=function(e){if(Re(e))return ge(e,ie);e.total_in=e.total_out=0,e.data_type=Ae;var t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?pe:fe,e.adler=2===t.wrap?0:1,t.last_flush=-2,G(t),ee},Ue=function(e){var t,i=Le(e);return i===ee&&((t=e.state).window_size=2*t.w_size,_e(t.head),t.max_lazy_match=Se[t.level].max_lazy,t.good_match=Se[t.level].good_length,t.nice_match=Se[t.level].nice_length,t.max_chain_length=Se[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),i},Oe=function(e,t,i,s,r,n){if(!e)return ie;var o=1;if(t===ne&&(t=6),s<0?(o=0,s=-s):s>15&&(o=2,s-=16),r<1||r>9||i!==ce||s<8||s>15||t<0||t>9||n<0||n>ue||8===s&&1!==o)return ge(e,ie);8===s&&(s=9);var a=new Te;return e.state=a,a.strm=e,a.status=pe,a.wrap=o,a.gzhead=null,a.w_bits=s,a.w_size=1<$||t<0)return e?ge(e,ie):ie;var i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===ve&&t!==q)return ge(e,0===e.avail_out?re:ie);var s=i.last_flush;if(i.last_flush=t,0!==i.pending){if(Be(e),0===e.avail_out)return i.last_flush=-1,ee}else if(0===e.avail_in&&me(t)<=me(s)&&t!==q)return ge(e,re);if(i.status===ve&&0!==e.avail_in)return ge(e,re);if(i.status===pe&&0===i.wrap&&(i.status=fe),i.status===pe){var r=ce+(i.w_bits-8<<4)<<8;if(r|=(i.strategy>=ae||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(r|=32),Pe(i,r+=31-r%31),0!==i.strstart&&(Pe(i,e.adler>>>16),Pe(i,65535&e.adler)),e.adler=1,i.status=fe,Be(e),0!==i.pending)return i.last_flush=-1,ee}if(57===i.status)if(e.adler=0,xe(i,31),xe(i,139),xe(i,8),i.gzhead)xe(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),xe(i,255&i.gzhead.time),xe(i,i.gzhead.time>>8&255),xe(i,i.gzhead.time>>16&255),xe(i,i.gzhead.time>>24&255),xe(i,9===i.level?2:i.strategy>=ae||i.level<2?4:0),xe(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(xe(i,255&i.gzhead.extra.length),xe(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=V(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(xe(i,0),xe(i,0),xe(i,0),xe(i,0),xe(i,0),xe(i,9===i.level?2:i.strategy>=ae||i.level<2?4:0),xe(i,3),i.status=fe,Be(e),0!==i.pending)return i.last_flush=-1,ee;if(69===i.status){if(i.gzhead.extra){for(var n=i.pending,o=(65535&i.gzhead.extra.length)-i.gzindex;i.pending+o>i.pending_buf_size;){var a=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+a),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>n&&(e.adler=V(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex+=a,Be(e),0!==i.pending)return i.last_flush=-1,ee;n=0,o-=a}var l=new Uint8Array(i.gzhead.extra);i.pending_buf.set(l.subarray(i.gzindex,i.gzindex+o),i.pending),i.pending+=o,i.gzhead.hcrc&&i.pending>n&&(e.adler=V(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){var u,A=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>A&&(e.adler=V(e.adler,i.pending_buf,i.pending-A,A)),Be(e),0!==i.pending)return i.last_flush=-1,ee;A=0}u=i.gzindexA&&(e.adler=V(e.adler,i.pending_buf,i.pending-A,A)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){var c,h=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>h&&(e.adler=V(e.adler,i.pending_buf,i.pending-h,h)),Be(e),0!==i.pending)return i.last_flush=-1,ee;h=0}c=i.gzindexh&&(e.adler=V(e.adler,i.pending_buf,i.pending-h,h))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(Be(e),0!==i.pending))return i.last_flush=-1,ee;xe(i,255&e.adler),xe(i,e.adler>>8&255),e.adler=0}if(i.status=fe,Be(e),0!==i.pending)return i.last_flush=-1,ee}if(0!==e.avail_in||0!==i.lookahead||t!==J&&i.status!==ve){var d=0===i.level?Ee(i,t):i.strategy===ae?function(e,t){for(var i;;){if(0===e.lookahead&&(Fe(e),0===e.lookahead)){if(t===J)return 1;break}if(e.match_length=0,i=K(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(we(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===q?(we(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(we(e,!1),0===e.strm.avail_out)?1:2}(i,t):i.strategy===le?function(e,t){for(var i,s,r,n,o=e.window;;){if(e.lookahead<=he){if(Fe(e),e.lookahead<=he&&t===J)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&((s=o[r=e.strstart-1])===o[++r]&&s===o[++r]&&s===o[++r])){n=e.strstart+he;do{}while(s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=K(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=K(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(we(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===q?(we(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(we(e,!1),0===e.strm.avail_out)?1:2}(i,t):Se[i.level].func(i,t);if(3!==d&&4!==d||(i.status=ve),1===d||3===d)return 0===e.avail_out&&(i.last_flush=-1),ee;if(2===d&&(t===Y?X(i):t!==$&&(z(i,0,0,!1),t===Z&&(_e(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),Be(e),0===e.avail_out))return i.last_flush=-1,ee}return t!==q?ee:i.wrap<=0?te:(2===i.wrap?(xe(i,255&e.adler),xe(i,e.adler>>8&255),xe(i,e.adler>>16&255),xe(i,e.adler>>24&255),xe(i,255&e.total_in),xe(i,e.total_in>>8&255),xe(i,e.total_in>>16&255),xe(i,e.total_in>>24&255)):(Pe(i,e.adler>>>16),Pe(i,65535&e.adler)),Be(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?ee:te)},He=function(e){if(Re(e))return ie;var t=e.state.status;return e.state=null,t===fe?ge(e,se):ee},je=function(e,t){var i=t.length;if(Re(e))return ie;var s=e.state,r=s.wrap;if(2===r||1===r&&s.status!==pe||s.lookahead)return ie;if(1===r&&(e.adler=N(e.adler,t,i,0)),s.wrap=0,i>=s.w_size){0===r&&(_e(s.head),s.strstart=0,s.block_start=0,s.insert=0);var n=new Uint8Array(s.w_size);n.set(t.subarray(i-s.w_size,i),0),t=n,i=s.w_size}var o=e.avail_in,a=e.next_in,l=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,Fe(s);s.lookahead>=3;){var u=s.strstart,A=s.lookahead-2;do{s.ins_h=be(s,s.ins_h,s.window[u+3-1]),s.prev[u&s.w_mask]=s.head[s.ins_h],s.head[s.ins_h]=u,u++}while(--A);s.strstart=u,s.lookahead=2,Fe(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=2,s.match_available=0,e.next_in=a,e.input=l,e.avail_in=o,s.wrap=r,ee},Ge=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},ze=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=w(i))throw new TypeError(i+"must be non-object");for(var s in i)Ge(i,s)&&(e[s]=i[s])}}return e},We=function(e){for(var t=0,i=0,s=e.length;i=252?6:Je>=248?5:Je>=240?4:Je>=224?3:Je>=192?2:1;Xe[254]=Xe[254]=1;var Ye=function(e){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,i,s,r,n,o=e.length,a=0;for(r=0;r>>6,t[n++]=128|63&i):i<65536?(t[n++]=224|i>>>12,t[n++]=128|i>>>6&63,t[n++]=128|63&i):(t[n++]=240|i>>>18,t[n++]=128|i>>>12&63,t[n++]=128|i>>>6&63,t[n++]=128|63&i);return t},Ze=function(e,t){var i,s,r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var n=new Array(2*r);for(s=0,i=0;i4)n[s++]=65533,i+=a-1;else{for(o&=2===a?31:3===a?15:7;a>1&&i1?n[s++]=65533:o<65536?n[s++]=o:(o-=65536,n[s++]=55296|o>>10&1023,n[s++]=56320|1023&o)}}}return function(e,t){if(t<65534&&e.subarray&&Ke)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var i="",s=0;se.length&&(t=e.length);for(var i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Xe[e[i]]>t?i:t},$e=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},et=Object.prototype.toString,tt=j.Z_NO_FLUSH,it=j.Z_SYNC_FLUSH,st=j.Z_FULL_FLUSH,rt=j.Z_FINISH,nt=j.Z_OK,ot=j.Z_STREAM_END,at=j.Z_DEFAULT_COMPRESSION,lt=j.Z_DEFAULT_STRATEGY,ut=j.Z_DEFLATED;function At(e){this.options=ze({level:at,method:ut,chunkSize:16384,windowBits:15,memLevel:8,strategy:lt},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $e,this.strm.avail_out=0;var i=Ne(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==nt)throw new Error(H[i]);if(t.header&&Qe(this.strm,t.header),t.dictionary){var s;if(s="string"==typeof t.dictionary?Ye(t.dictionary):"[object ArrayBuffer]"===et.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(i=je(this.strm,s))!==nt)throw new Error(H[i]);this._dict_set=!0}}function ct(e,t){var i=new At(t);if(i.push(e,!0),i.err)throw i.msg||H[i.err];return i.result}At.prototype.push=function(e,t){var i,s,r=this.strm,n=this.options.chunkSize;if(this.ended)return!1;for(s=t===~~t?t:!0===t?rt:tt,"string"==typeof e?r.input=Ye(e):"[object ArrayBuffer]"===et.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(s===it||s===st)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=Ve(r,s))===ot)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=He(this.strm),this.onEnd(i),this.ended=!0,i===nt;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},At.prototype.onData=function(e){this.chunks.push(e)},At.prototype.onEnd=function(e){e===nt&&(this.result=We(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ht=At,dt=ct,pt=function(e,t){return(t=t||{}).raw=!0,ct(e,t)},ft=function(e,t){return(t=t||{}).gzip=!0,ct(e,t)},vt=16209,gt=function(e,t){var i,s,r,n,o,a,l,u,A,c,h,d,p,f,v,g,m,_,y,b,B,w,x,P,C=e.state;i=e.next_in,x=e.input,s=i+(e.avail_in-5),r=e.next_out,P=e.output,n=r-(t-e.avail_out),o=r+(e.avail_out-257),a=C.dmax,l=C.wsize,u=C.whave,A=C.wnext,c=C.window,h=C.hold,d=C.bits,p=C.lencode,f=C.distcode,v=(1<>>=_=m>>>24,d-=_,0===(_=m>>>16&255))P[r++]=65535&m;else{if(!(16&_)){if(0==(64&_)){m=p[(65535&m)+(h&(1<<_)-1)];continue t}if(32&_){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=vt;break e}y=65535&m,(_&=15)&&(d<_&&(h+=x[i++]<>>=_,d-=_),d<15&&(h+=x[i++]<>>=_=m>>>24,d-=_,!(16&(_=m>>>16&255))){if(0==(64&_)){m=f[(65535&m)+(h&(1<<_)-1)];continue i}e.msg="invalid distance code",C.mode=vt;break e}if(b=65535&m,d<(_&=15)&&(h+=x[i++]<a){e.msg="invalid distance too far back",C.mode=vt;break e}if(h>>>=_,d-=_,b>(_=r-n)){if((_=b-_)>u&&C.sane){e.msg="invalid distance too far back",C.mode=vt;break e}if(B=0,w=c,0===A){if(B+=l-_,_2;)P[r++]=w[B++],P[r++]=w[B++],P[r++]=w[B++],y-=3;y&&(P[r++]=w[B++],y>1&&(P[r++]=w[B++]))}else{B=r-b;do{P[r++]=P[B++],P[r++]=P[B++],P[r++]=P[B++],y-=3}while(y>2);y&&(P[r++]=P[B++],y>1&&(P[r++]=P[B++]))}break}}break}}while(i>3,h&=(1<<(d-=y<<3))-1,e.next_in=i,e.next_out=r,e.avail_in=i=1&&0===E[b];b--);if(B>b&&(B=b),0===b)return r[n++]=20971520,r[n++]=20971520,a.bits=1,0;for(y=1;y0&&(0===e||1!==b))return-1;for(k[1]=0,m=1;m<15;m++)k[m+1]=k[m]+E[m];for(_=0;_852||2===e&&C>592)return 1;for(;;){p=m-x,o[_]+1=d?(f=I[o[_]-d],v=F[o[_]-d]):(f=96,v=0),l=1<>x)+(u-=l)]=p<<24|f<<16|v|0}while(0!==u);for(l=1<>=1;if(0!==l?(M&=l-1,M+=l):M=0,_++,0==--E[m]){if(m===b)break;m=t[i+o[_]]}if(m>B&&(M&c)!==A){for(0===x&&(x=B),h+=y,P=1<<(w=m-x);w+x852||2===e&&C>592)return 1;r[A=M&c]=B<<24|w<<16|h-n|0}}return 0!==M&&(r[h+M]=m-x<<24|64<<16|0),a.bits=B,0},wt=j.Z_FINISH,xt=j.Z_BLOCK,Pt=j.Z_TREES,Ct=j.Z_OK,Mt=j.Z_STREAM_END,Ft=j.Z_NEED_DICT,Et=j.Z_STREAM_ERROR,kt=j.Z_DATA_ERROR,It=j.Z_MEM_ERROR,Dt=j.Z_BUF_ERROR,St=j.Z_DEFLATED,Tt=16180,Rt=16190,Lt=16191,Ut=16192,Ot=16194,Nt=16199,Qt=16200,Vt=16206,Ht=16209,jt=function(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)};function Gt(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var zt,Wt,Kt=function(e){if(!e)return 1;var t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Xt=function(e){if(Kt(e))return Et;var t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Tt,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Ct},Jt=function(e){if(Kt(e))return Et;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Xt(e)},Yt=function(e,t){var i;if(Kt(e))return Et;var s=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Et:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,Jt(e))},Zt=function(e,t){if(!e)return Et;var i=new Gt;e.state=i,i.strm=e,i.window=null,i.mode=Tt;var s=Yt(e,t);return s!==Ct&&(e.state=null),s},qt=!0,$t=function(e){if(qt){zt=new Int32Array(512),Wt=new Int32Array(32);for(var t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Bt(1,e.lens,0,288,zt,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bt(2,e.lens,0,32,Wt,0,e.work,{bits:5}),qt=!1}e.lencode=zt,e.lenbits=9,e.distcode=Wt,e.distbits=5},ei=function(e,t,i,s){var r,n=e.state;return null===n.window&&(n.wsize=1<=n.wsize?(n.window.set(t.subarray(i-n.wsize,i),0),n.wnext=0,n.whave=n.wsize):((r=n.wsize-n.wnext)>s&&(r=s),n.window.set(t.subarray(i-s,i-s+r),n.wnext),(s-=r)?(n.window.set(t.subarray(i-s,i),0),n.wnext=s,n.whave=n.wsize):(n.wnext+=r,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=V(i.check,M,2,0),u=0,A=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",i.mode=Ht;break}if((15&u)!==St){e.msg="unknown compression method",i.mode=Ht;break}if(A-=4,B=8+(15&(u>>>=4)),0===i.wbits&&(i.wbits=B),B>15||B>i.wbits){e.msg="invalid window size",i.mode=Ht;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(M[0]=255&u,M[1]=u>>>8&255,i.check=V(i.check,M,2,0)),u=0,A=0,i.mode=16182;case 16182:for(;A<32;){if(0===a)break e;a--,u+=s[n++]<>>8&255,M[2]=u>>>16&255,M[3]=u>>>24&255,i.check=V(i.check,M,4,0)),u=0,A=0,i.mode=16183;case 16183:for(;A<16;){if(0===a)break e;a--,u+=s[n++]<>8),512&i.flags&&4&i.wrap&&(M[0]=255&u,M[1]=u>>>8&255,i.check=V(i.check,M,2,0)),u=0,A=0,i.mode=16184;case 16184:if(1024&i.flags){for(;A<16;){if(0===a)break e;a--,u+=s[n++]<>>8&255,i.check=V(i.check,M,2,0)),u=0,A=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&((d=i.length)>a&&(d=a),d&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(s.subarray(n,n+d),B)),512&i.flags&&4&i.wrap&&(i.check=V(i.check,s,d,n)),a-=d,n+=d,i.length-=d),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;d=0;do{B=s[n+d++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B))}while(B&&d>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Lt;break;case 16189:for(;A<32;){if(0===a)break e;a--,u+=s[n++]<>>=7&A,A-=7&A,i.mode=Vt;break}for(;A<3;){if(0===a)break e;a--,u+=s[n++]<>>=1)){case 0:i.mode=16193;break;case 1:if($t(i),i.mode=Nt,t===Pt){u>>>=2,A-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=Ht}u>>>=2,A-=2;break;case 16193:for(u>>>=7&A,A-=7&A;A<32;){if(0===a)break e;a--,u+=s[n++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=Ht;break}if(i.length=65535&u,u=0,A=0,i.mode=Ot,t===Pt)break e;case Ot:i.mode=16195;case 16195:if(d=i.length){if(d>a&&(d=a),d>l&&(d=l),0===d)break e;r.set(s.subarray(n,n+d),o),a-=d,n+=d,l-=d,o+=d,i.length-=d;break}i.mode=Lt;break;case 16196:for(;A<14;){if(0===a)break e;a--,u+=s[n++]<>>=5,A-=5,i.ndist=1+(31&u),u>>>=5,A-=5,i.ncode=4+(15&u),u>>>=4,A-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Ht;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,A-=3}for(;i.have<19;)i.lens[F[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,x={bits:i.lenbits},w=Bt(0,i.lens,0,19,i.lencode,0,i.work,x),i.lenbits=x.bits,w){e.msg="invalid code lengths set",i.mode=Ht;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>16&255,m=65535&C,!((v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>>=v,A-=v,i.lens[i.have++]=m;else{if(16===m){for(P=v+2;A>>=v,A-=v,0===i.have){e.msg="invalid bit length repeat",i.mode=Ht;break}B=i.lens[i.have-1],d=3+(3&u),u>>>=2,A-=2}else if(17===m){for(P=v+3;A>>=v)),u>>>=3,A-=3}else{for(P=v+7;A>>=v)),u>>>=7,A-=7}if(i.have+d>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Ht;break}for(;d--;)i.lens[i.have++]=B}}if(i.mode===Ht)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Ht;break}if(i.lenbits=9,x={bits:i.lenbits},w=Bt(1,i.lens,0,i.nlen,i.lencode,0,i.work,x),i.lenbits=x.bits,w){e.msg="invalid literal/lengths set",i.mode=Ht;break}if(i.distbits=6,i.distcode=i.distdyn,x={bits:i.distbits},w=Bt(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,x),i.distbits=x.bits,w){e.msg="invalid distances set",i.mode=Ht;break}if(i.mode=Nt,t===Pt)break e;case Nt:i.mode=Qt;case Qt:if(a>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=n,e.avail_in=a,i.hold=u,i.bits=A,gt(e,h),o=e.next_out,r=e.output,l=e.avail_out,n=e.next_in,s=e.input,a=e.avail_in,u=i.hold,A=i.bits,i.mode===Lt&&(i.back=-1);break}for(i.back=0;g=(C=i.lencode[u&(1<>>16&255,m=65535&C,!((v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>_)])>>>16&255,m=65535&C,!(_+(v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>>=_,A-=_,i.back+=_}if(u>>>=v,A-=v,i.back+=v,i.length=m,0===g){i.mode=16205;break}if(32&g){i.back=-1,i.mode=Lt;break}if(64&g){e.msg="invalid literal/length code",i.mode=Ht;break}i.extra=15&g,i.mode=16201;case 16201:if(i.extra){for(P=i.extra;A>>=i.extra,A-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;g=(C=i.distcode[u&(1<>>16&255,m=65535&C,!((v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>_)])>>>16&255,m=65535&C,!(_+(v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>>=_,A-=_,i.back+=_}if(u>>>=v,A-=v,i.back+=v,64&g){e.msg="invalid distance code",i.mode=Ht;break}i.offset=m,i.extra=15&g,i.mode=16203;case 16203:if(i.extra){for(P=i.extra;A>>=i.extra,A-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Ht;break}i.mode=16204;case 16204:if(0===l)break e;if(d=h-l,i.offset>d){if((d=i.offset-d)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Ht;break}d>i.wnext?(d-=i.wnext,p=i.wsize-d):p=i.wnext-d,d>i.length&&(d=i.length),f=i.window}else f=r,p=o-i.offset,d=i.length;d>l&&(d=l),l-=d,i.length-=d;do{r[o++]=f[p++]}while(--d);0===i.length&&(i.mode=Qt);break;case 16205:if(0===l)break e;r[o++]=i.length,l--,i.mode=Qt;break;case Vt:if(i.wrap){for(;A<32;){if(0===a)break e;a--,u|=s[n++]<=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $e,this.strm.avail_out=0;var i=ii(this.strm,t.windowBits);if(i!==ci)throw new Error(H[i]);if(this.header=new ai,ni(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Ye(t.dictionary):"[object ArrayBuffer]"===li.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=oi(this.strm,t.dictionary))!==ci))throw new Error(H[i])}function mi(e,t){var i=new gi(t);if(i.push(e),i.err)throw i.msg||H[i.err];return i.result}gi.prototype.push=function(e,t){var i,s,r,n=this.strm,o=this.options.chunkSize,a=this.options.dictionary;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Ai:ui,"[object ArrayBuffer]"===li.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(o),n.next_out=0,n.avail_out=o),(i=si(n,s))===di&&a&&((i=oi(n,a))===ci?i=si(n,s):i===fi&&(i=di));n.avail_in>0&&i===hi&&n.state.wrap>0&&0!==e[n.next_in];)ti(n),i=si(n,s);switch(i){case pi:case fi:case di:case vi:return this.onEnd(i),this.ended=!0,!1}if(r=n.avail_out,n.next_out&&(0===n.avail_out||i===hi))if("string"===this.options.to){var l=qe(n.output,n.next_out),u=n.next_out-l,A=Ze(n.output,l);n.next_out=u,n.avail_out=o-u,u&&n.output.set(n.output.subarray(l,l+u),0),this.onData(A)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(i!==ci||0!==r){if(i===hi)return i=ri(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},gi.prototype.onData=function(e){this.chunks.push(e)},gi.prototype.onEnd=function(e){e===ci&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=We(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var _i=function(e,t){return(t=t||{}).raw=!0,mi(e,t)},yi=ht,bi=dt,Bi=pt,wi=ft,xi=gi,Pi=mi,Ci=_i,Mi=mi,Fi=j,Ei={Deflate:yi,deflate:bi,deflateRaw:Bi,gzip:wi,Inflate:xi,inflate:Pi,inflateRaw:Ci,ungzip:Mi,constants:Fi};e.Deflate=yi,e.Inflate=xi,e.constants=Fi,e.default=Ei,e.deflate=bi,e.deflateRaw=Bi,e.gzip=wi,e.inflate=Pi,e.inflateRaw=Ci,e.ungzip=Mi,Object.defineProperty(e,"__esModule",{value:!0})}));var hE=Object.freeze({__proto__:null}),dE=window.pako||hE;dE.inflate||(dE=dE.default);var pE,fE=(pE=new Float32Array(3),function(e){return pE[0]=e[0]/255,pE[1]=e[1]/255,pE[2]=e[2]/255,pE});var vE={version:1,parse:function(e,t,i,s,r,n){var o=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],meshPositions:e[4],meshIndices:e[5],meshEdgesIndices:e[6],meshColors:e[7],entityIDs:e[8],entityMeshes:e[9],entityIsObjects:e[10],positionsDecodeMatrix:e[11]}}(i),a=function(e){return{positions:new Uint16Array(dE.inflate(e.positions).buffer),normals:new Int8Array(dE.inflate(e.normals).buffer),indices:new Uint32Array(dE.inflate(e.indices).buffer),edgeIndices:new Uint32Array(dE.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(dE.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(dE.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(dE.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(dE.inflate(e.meshColors).buffer),entityIDs:dE.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(dE.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(dE.inflate(e.entityIsObjects).buffer),positionsDecodeMatrix:new Float32Array(dE.inflate(e.positionsDecodeMatrix).buffer)}}(o);!function(e,t,i,s,r,n){n.getNextId(),s.positionsCompression="precompressed",s.normalsCompression="precompressed";for(var o=i.positions,a=i.normals,l=i.indices,u=i.edgeIndices,A=i.meshPositions,c=i.meshIndices,h=i.meshEdgesIndices,d=i.meshColors,p=JSON.parse(i.entityIDs),f=i.entityMeshes,v=i.entityIsObjects,g=A.length,m=f.length,_=0;_v[t]?1:0}));for(var F=0;F1||(E[L]=k)}for(var U=0;U1,V=xE(g.subarray(4*O,4*O+3)),H=g[4*O+3]/255,j=a.subarray(d[O],N?a.length:d[O+1]),G=l.subarray(d[O],N?l.length:d[O+1]),z=u.subarray(p[O],N?u.length:p[O+1]),W=A.subarray(f[O],N?A.length:f[O+1]),K=c.subarray(v[O],v[O]+16);if(Q){var X="".concat(o,"-geometry.").concat(O);s.createGeometry({id:X,primitive:"triangles",positionsCompressed:j,normalsCompressed:G,indices:z,edgeIndices:W,positionsDecodeMatrix:K})}else{var J="".concat(o,"-").concat(O);_[E[O]],s.createMesh(le.apply({},{id:J,primitive:"triangles",positionsCompressed:j,normalsCompressed:G,indices:z,edgeIndices:W,positionsDecodeMatrix:K,color:V,opacity:H}))}}for(var Y=0,Z=0;Z1){var oe="".concat(o,"-instance.").concat(Y++),ae="".concat(o,"-geometry.").concat(ne),ue=16*b[Z],Ae=h.subarray(ue,ue+16);s.createMesh(le.apply({},{id:oe,geometryId:ae,matrix:Ae})),se.push(oe)}else se.push(ne)}se.length>0&&s.createEntity(le.apply({},{id:ee,isObject:!0,meshIds:se}))}}(0,0,a,s,0,n)}},CE=window.pako||hE;CE.inflate||(CE=CE.default);var ME=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();var FE={version:5,parse:function(e,t,i,s,r,n){var o=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],eachPrimitivePositionsAndNormalsPortion:e[5],eachPrimitiveIndicesPortion:e[6],eachPrimitiveEdgeIndicesPortion:e[7],eachPrimitiveColor:e[8],primitiveInstances:e[9],eachEntityId:e[10],eachEntityPrimitiveInstancesPortion:e[11],eachEntityMatricesPortion:e[12]}}(i),a=function(e){return{positions:new Float32Array(CE.inflate(e.positions).buffer),normals:new Int8Array(CE.inflate(e.normals).buffer),indices:new Uint32Array(CE.inflate(e.indices).buffer),edgeIndices:new Uint32Array(CE.inflate(e.edgeIndices).buffer),matrices:new Float32Array(CE.inflate(e.matrices).buffer),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(CE.inflate(e.eachPrimitivePositionsAndNormalsPortion).buffer),eachPrimitiveIndicesPortion:new Uint32Array(CE.inflate(e.eachPrimitiveIndicesPortion).buffer),eachPrimitiveEdgeIndicesPortion:new Uint32Array(CE.inflate(e.eachPrimitiveEdgeIndicesPortion).buffer),eachPrimitiveColor:new Uint8Array(CE.inflate(e.eachPrimitiveColor).buffer),primitiveInstances:new Uint32Array(CE.inflate(e.primitiveInstances).buffer),eachEntityId:CE.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(CE.inflate(e.eachEntityPrimitiveInstancesPortion).buffer),eachEntityMatricesPortion:new Uint32Array(CE.inflate(e.eachEntityMatricesPortion).buffer)}}(o);!function(e,t,i,s,r,n){var o=n.getNextId();s.positionsCompression="disabled",s.normalsCompression="precompressed";for(var a=i.positions,l=i.normals,u=i.indices,A=i.edgeIndices,c=i.matrices,h=i.eachPrimitivePositionsAndNormalsPortion,d=i.eachPrimitiveIndicesPortion,p=i.eachPrimitiveEdgeIndicesPortion,f=i.eachPrimitiveColor,v=i.primitiveInstances,g=JSON.parse(i.eachEntityId),m=i.eachEntityPrimitiveInstancesPortion,_=i.eachEntityMatricesPortion,y=h.length,b=v.length,B=new Uint8Array(y),w=g.length,x=0;x1||(P[D]=C)}for(var S=0;S1,L=ME(f.subarray(4*S,4*S+3)),U=f[4*S+3]/255,O=a.subarray(h[S],T?a.length:h[S+1]),N=l.subarray(h[S],T?l.length:h[S+1]),Q=u.subarray(d[S],T?u.length:d[S+1]),V=A.subarray(p[S],T?A.length:p[S+1]);if(R){var H="".concat(o,"-geometry.").concat(S);s.createGeometry({id:H,primitive:"triangles",positionsCompressed:O,normalsCompressed:N,indices:Q,edgeIndices:V})}else{var j=S;g[P[S]],s.createMesh(le.apply({},{id:j,primitive:"triangles",positionsCompressed:O,normalsCompressed:N,indices:Q,edgeIndices:V,color:L,opacity:U}))}}for(var G=0,z=0;z1){var ee="instance."+G++,te="geometry"+$,ie=16*_[z],se=c.subarray(ie,ie+16);s.createMesh(le.apply({},{id:ee,geometryId:te,matrix:se})),Z.push(ee)}else Z.push($)}Z.length>0&&s.createEntity(le.apply({},{id:X,isObject:!0,meshIds:Z}))}}(0,0,a,s,0,n)}},EE=window.pako||hE;EE.inflate||(EE=EE.default);var kE,IE=(kE=new Float32Array(3),function(e){return kE[0]=e[0]/255,kE[1]=e[1]/255,kE[2]=e[2]/255,kE});var DE={version:6,parse:function(e,t,i,s,r,n){var o=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],reusedPrimitivesDecodeMatrix:e[5],eachPrimitivePositionsAndNormalsPortion:e[6],eachPrimitiveIndicesPortion:e[7],eachPrimitiveEdgeIndicesPortion:e[8],eachPrimitiveColorAndOpacity:e[9],primitiveInstances:e[10],eachEntityId:e[11],eachEntityPrimitiveInstancesPortion:e[12],eachEntityMatricesPortion:e[13],eachTileAABB:e[14],eachTileEntitiesPortion:e[15]}}(i),a=function(e){function t(e,t){return 0===e.length?[]:EE.inflate(e,t).buffer}return{positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedPrimitivesDecodeMatrix:new Float32Array(t(e.reusedPrimitivesDecodeMatrix)),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(t(e.eachPrimitivePositionsAndNormalsPortion)),eachPrimitiveIndicesPortion:new Uint32Array(t(e.eachPrimitiveIndicesPortion)),eachPrimitiveEdgeIndicesPortion:new Uint32Array(t(e.eachPrimitiveEdgeIndicesPortion)),eachPrimitiveColorAndOpacity:new Uint8Array(t(e.eachPrimitiveColorAndOpacity)),primitiveInstances:new Uint32Array(t(e.primitiveInstances)),eachEntityId:EE.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(t(e.eachEntityPrimitiveInstancesPortion)),eachEntityMatricesPortion:new Uint32Array(t(e.eachEntityMatricesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(o);!function(e,t,i,s,r,n){for(var o=n.getNextId(),a=i.positions,l=i.normals,u=i.indices,A=i.edgeIndices,c=i.matrices,h=i.reusedPrimitivesDecodeMatrix,d=i.eachPrimitivePositionsAndNormalsPortion,p=i.eachPrimitiveIndicesPortion,f=i.eachPrimitiveEdgeIndicesPortion,v=i.eachPrimitiveColorAndOpacity,g=i.primitiveInstances,m=JSON.parse(i.eachEntityId),_=i.eachEntityPrimitiveInstancesPortion,y=i.eachEntityMatricesPortion,b=i.eachTileAABB,B=i.eachTileEntitiesPortion,w=d.length,x=g.length,P=m.length,C=B.length,M=new Uint32Array(w),F=0;F1,se=te===w-1,re=a.subarray(d[te],se?a.length:d[te+1]),ne=l.subarray(d[te],se?l.length:d[te+1]),oe=u.subarray(p[te],se?u.length:p[te+1]),ae=A.subarray(f[te],se?A.length:f[te+1]),ue=IE(v.subarray(4*te,4*te+3)),Ae=v[4*te+3]/255,ce=n.getNextId();if(ie){var he="".concat(o,"-geometry.").concat(D,".").concat(te);N[he]||(s.createGeometry({id:he,primitive:"triangles",positionsCompressed:re,indices:oe,edgeIndices:ae,positionsDecodeMatrix:h}),N[he]=!0),s.createMesh(le.apply(Z,{id:ce,geometryId:he,origin:k,matrix:G,color:ue,opacity:Ae})),X.push(ce)}else s.createMesh(le.apply(Z,{id:ce,origin:k,primitive:"triangles",positionsCompressed:re,normalsCompressed:ne,indices:oe,edgeIndices:ae,positionsDecodeMatrix:O,color:ue,opacity:Ae})),X.push(ce)}X.length>0&&s.createEntity(le.apply(Y,{id:H,isObject:!0,meshIds:X}))}}}(e,t,a,s,0,n)}},SE=window.pako||hE;SE.inflate||(SE=SE.default);var TE=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function RE(e){for(var t=[],i=0,s=e.length;i1,ne=se===M-1,oe=TE(B.subarray(6*ie,6*ie+3)),ae=B[6*ie+3]/255,ue=B[6*ie+4]/255,Ae=B[6*ie+5]/255,ce=n.getNextId();if(re){var he=b[ie],de=h.slice(he,he+16),pe="".concat(o,"-geometry.").concat(L,".").concat(se);if(!j[pe]){var fe=void 0,ve=void 0,ge=void 0,me=void 0,_e=void 0,ye=void 0;switch(p[se]){case 0:fe="solid",ve=a.subarray(f[se],ne?a.length:f[se+1]),ge=l.subarray(v[se],ne?l.length:v[se+1]),_e=A.subarray(m[se],ne?A.length:m[se+1]),ye=c.subarray(_[se],ne?c.length:_[se+1]);break;case 1:fe="surface",ve=a.subarray(f[se],ne?a.length:f[se+1]),ge=l.subarray(v[se],ne?l.length:v[se+1]),_e=A.subarray(m[se],ne?A.length:m[se+1]),ye=c.subarray(_[se],ne?c.length:_[se+1]);break;case 2:fe="points",ve=a.subarray(f[se],ne?a.length:f[se+1]),me=RE(u.subarray(g[se],ne?u.length:g[se+1]));break;case 3:fe="lines",ve=a.subarray(f[se],ne?a.length:f[se+1]),_e=A.subarray(m[se],ne?A.length:m[se+1]);break;default:continue}s.createGeometry({id:pe,primitive:fe,positionsCompressed:ve,normalsCompressed:ge,colors:me,indices:_e,edgeIndices:ye,positionsDecodeMatrix:d}),j[pe]=!0}s.createMesh(le.apply(ee,{id:ce,geometryId:pe,origin:T,matrix:de,color:oe,metallic:ue,roughness:Ae,opacity:ae})),Y.push(ce)}else{var be=void 0,Be=void 0,we=void 0,xe=void 0,Pe=void 0,Ce=void 0;switch(p[se]){case 0:be="solid",Be=a.subarray(f[se],ne?a.length:f[se+1]),we=l.subarray(v[se],ne?l.length:v[se+1]),Pe=A.subarray(m[se],ne?A.length:m[se+1]),Ce=c.subarray(_[se],ne?c.length:_[se+1]);break;case 1:be="surface",Be=a.subarray(f[se],ne?a.length:f[se+1]),we=l.subarray(v[se],ne?l.length:v[se+1]),Pe=A.subarray(m[se],ne?A.length:m[se+1]),Ce=c.subarray(_[se],ne?c.length:_[se+1]);break;case 2:be="points",Be=a.subarray(f[se],ne?a.length:f[se+1]),xe=RE(u.subarray(g[se],ne?u.length:g[se+1]));break;case 3:be="lines",Be=a.subarray(f[se],ne?a.length:f[se+1]),Pe=A.subarray(m[se],ne?A.length:m[se+1]);break;default:continue}s.createMesh(le.apply(ee,{id:ce,origin:T,primitive:be,positionsCompressed:Be,normalsCompressed:we,colors:xe,indices:Pe,edgeIndices:Ce,positionsDecodeMatrix:H,color:oe,metallic:ue,roughness:Ae,opacity:ae})),Y.push(ce)}}Y.length>0&&s.createEntity(le.apply(q,{id:W,isObject:!0,meshIds:Y}))}}}(e,t,a,s,0,n)}},UE=window.pako||hE;UE.inflate||(UE=UE.default);var OE=$.vec4(),NE=$.vec4();var QE=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function VE(e){for(var t=[],i=0,s=e.length;i1,ye=me===S-1,be=QE(M.subarray(6*ge,6*ge+3)),Be=M[6*ge+3]/255,we=M[6*ge+4]/255,xe=M[6*ge+5]/255,Pe=n.getNextId();if(_e){var Ce=C[ge],Me=g.slice(Ce,Ce+16),Fe="".concat(o,"-geometry.").concat(Y,".").concat(me),Ee=J[Fe];if(!Ee){Ee={batchThisMesh:!t.reuseGeometries};var ke=!1;switch(_[me]){case 0:Ee.primitiveName="solid",Ee.geometryPositions=h.subarray(y[me],ye?h.length:y[me+1]),Ee.geometryNormals=d.subarray(b[me],ye?d.length:b[me+1]),Ee.geometryIndices=f.subarray(w[me],ye?f.length:w[me+1]),Ee.geometryEdgeIndices=v.subarray(x[me],ye?v.length:x[me+1]),ke=Ee.geometryPositions.length>0&&Ee.geometryIndices.length>0;break;case 1:Ee.primitiveName="surface",Ee.geometryPositions=h.subarray(y[me],ye?h.length:y[me+1]),Ee.geometryNormals=d.subarray(b[me],ye?d.length:b[me+1]),Ee.geometryIndices=f.subarray(w[me],ye?f.length:w[me+1]),Ee.geometryEdgeIndices=v.subarray(x[me],ye?v.length:x[me+1]),ke=Ee.geometryPositions.length>0&&Ee.geometryIndices.length>0;break;case 2:Ee.primitiveName="points",Ee.geometryPositions=h.subarray(y[me],ye?h.length:y[me+1]),Ee.geometryColors=VE(p.subarray(B[me],ye?p.length:B[me+1])),ke=Ee.geometryPositions.length>0;break;case 3:Ee.primitiveName="lines",Ee.geometryPositions=h.subarray(y[me],ye?h.length:y[me+1]),Ee.geometryIndices=f.subarray(w[me],ye?f.length:w[me+1]),ke=Ee.geometryPositions.length>0&&Ee.geometryIndices.length>0;break;default:continue}if(ke||(Ee=null),Ee&&(Ee.geometryPositions.length,Ee.batchThisMesh)){Ee.decompressedPositions=new Float32Array(Ee.geometryPositions.length);for(var Ie=Ee.geometryPositions,De=Ee.decompressedPositions,Se=0,Te=Ie.length;Se0&&je.length>0;break;case 1:Ne="surface",Qe=h.subarray(y[me],ye?h.length:y[me+1]),Ve=d.subarray(b[me],ye?d.length:b[me+1]),je=f.subarray(w[me],ye?f.length:w[me+1]),Ge=v.subarray(x[me],ye?v.length:x[me+1]),ze=Qe.length>0&&je.length>0;break;case 2:Ne="points",Qe=h.subarray(y[me],ye?h.length:y[me+1]),He=VE(p.subarray(B[me],ye?p.length:B[me+1])),ze=Qe.length>0;break;case 3:Ne="lines",Qe=h.subarray(y[me],ye?h.length:y[me+1]),je=f.subarray(w[me],ye?f.length:w[me+1]),ze=Qe.length>0&&je.length>0;break;default:continue}ze&&(s.createMesh(le.apply(fe,{id:Pe,origin:K,primitive:Ne,positionsCompressed:Qe,normalsCompressed:Ve,colorsCompressed:He,indices:je,edgeIndices:Ge,positionsDecodeMatrix:se,color:be,metallic:we,roughness:xe,opacity:Be})),he.push(Pe))}}he.length>0&&s.createEntity(le.apply(pe,{id:ae,isObject:!0,meshIds:he}))}}}(e,t,a,s,r,n)}},jE=window.pako||hE;jE.inflate||(jE=jE.default);var GE=$.vec4(),zE=$.vec4();var WE=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();var KE={version:9,parse:function(e,t,i,s,r,n){var o=function(e){return{metadata:e[0],positions:e[1],normals:e[2],colors:e[3],indices:e[4],edgeIndices:e[5],matrices:e[6],reusedGeometriesDecodeMatrix:e[7],eachGeometryPrimitiveType:e[8],eachGeometryPositionsPortion:e[9],eachGeometryNormalsPortion:e[10],eachGeometryColorsPortion:e[11],eachGeometryIndicesPortion:e[12],eachGeometryEdgeIndicesPortion:e[13],eachMeshGeometriesPortion:e[14],eachMeshMatricesPortion:e[15],eachMeshMaterial:e[16],eachEntityId:e[17],eachEntityMeshesPortion:e[18],eachTileAABB:e[19],eachTileEntitiesPortion:e[20]}}(i),a=function(e){function t(e,t){return 0===e.length?[]:jE.inflate(e,t).buffer}return{metadata:JSON.parse(jE.inflate(e.metadata,{to:"string"})),positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshMaterial:new Uint8Array(t(e.eachMeshMaterial)),eachEntityId:JSON.parse(jE.inflate(e.eachEntityId,{to:"string"})),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(o);!function(e,t,i,s,r,n){var o=n.getNextId(),a=i.metadata,l=i.positions,u=i.normals,A=i.colors,c=i.indices,h=i.edgeIndices,d=i.matrices,p=i.reusedGeometriesDecodeMatrix,f=i.eachGeometryPrimitiveType,v=i.eachGeometryPositionsPortion,g=i.eachGeometryNormalsPortion,m=i.eachGeometryColorsPortion,_=i.eachGeometryIndicesPortion,y=i.eachGeometryEdgeIndicesPortion,b=i.eachMeshGeometriesPortion,B=i.eachMeshMatricesPortion,w=i.eachMeshMaterial,x=i.eachEntityId,P=i.eachEntityMeshesPortion,C=i.eachTileAABB,M=i.eachTileEntitiesPortion,F=v.length,E=b.length,k=P.length,I=M.length;r&&r.loadData(a,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds});for(var D=new Uint32Array(F),S=0;S1,ae=ne===F-1,ue=WE(w.subarray(6*re,6*re+3)),Ae=w[6*re+3]/255,ce=w[6*re+4]/255,he=w[6*re+5]/255,de=n.getNextId();if(oe){var pe=B[re],fe=d.slice(pe,pe+16),ve="".concat(o,"-geometry.").concat(O,".").concat(ne),ge=U[ve];if(!ge){ge={batchThisMesh:!t.reuseGeometries};var me=!1;switch(f[ne]){case 0:ge.primitiveName="solid",ge.geometryPositions=l.subarray(v[ne],ae?l.length:v[ne+1]),ge.geometryNormals=u.subarray(g[ne],ae?u.length:g[ne+1]),ge.geometryIndices=c.subarray(_[ne],ae?c.length:_[ne+1]),ge.geometryEdgeIndices=h.subarray(y[ne],ae?h.length:y[ne+1]),me=ge.geometryPositions.length>0&&ge.geometryIndices.length>0;break;case 1:ge.primitiveName="surface",ge.geometryPositions=l.subarray(v[ne],ae?l.length:v[ne+1]),ge.geometryNormals=u.subarray(g[ne],ae?u.length:g[ne+1]),ge.geometryIndices=c.subarray(_[ne],ae?c.length:_[ne+1]),ge.geometryEdgeIndices=h.subarray(y[ne],ae?h.length:y[ne+1]),me=ge.geometryPositions.length>0&&ge.geometryIndices.length>0;break;case 2:ge.primitiveName="points",ge.geometryPositions=l.subarray(v[ne],ae?l.length:v[ne+1]),ge.geometryColors=A.subarray(m[ne],ae?A.length:m[ne+1]),me=ge.geometryPositions.length>0;break;case 3:ge.primitiveName="lines",ge.geometryPositions=l.subarray(v[ne],ae?l.length:v[ne+1]),ge.geometryIndices=c.subarray(_[ne],ae?c.length:_[ne+1]),me=ge.geometryPositions.length>0&&ge.geometryIndices.length>0;break;default:continue}if(me||(ge=null),ge&&(ge.geometryPositions.length,ge.batchThisMesh)){ge.decompressedPositions=new Float32Array(ge.geometryPositions.length),ge.transformedAndRecompressedPositions=new Uint16Array(ge.geometryPositions.length);for(var _e=ge.geometryPositions,ye=ge.decompressedPositions,be=0,Be=_e.length;be0&&Ie.length>0;break;case 1:Me="surface",Fe=l.subarray(v[ne],ae?l.length:v[ne+1]),Ee=u.subarray(g[ne],ae?u.length:g[ne+1]),Ie=c.subarray(_[ne],ae?c.length:_[ne+1]),De=h.subarray(y[ne],ae?h.length:y[ne+1]),Se=Fe.length>0&&Ie.length>0;break;case 2:Me="points",Fe=l.subarray(v[ne],ae?l.length:v[ne+1]),ke=A.subarray(m[ne],ae?A.length:m[ne+1]),Se=Fe.length>0;break;case 3:Me="lines",Fe=l.subarray(v[ne],ae?l.length:v[ne+1]),Ie=c.subarray(_[ne],ae?c.length:_[ne+1]),Se=Fe.length>0&&Ie.length>0;break;default:continue}Se&&(s.createMesh(le.apply(ie,{id:de,origin:R,primitive:Me,positionsCompressed:Fe,normalsCompressed:Ee,colorsCompressed:ke,indices:Ie,edgeIndices:De,positionsDecodeMatrix:G,color:ue,metallic:ce,roughness:he,opacity:Ae})),q.push(de))}}q.length>0&&s.createEntity(le.apply(te,{id:X,isObject:!0,meshIds:q}))}}}(e,t,a,s,r,n)}},XE=window.pako||hE;XE.inflate||(XE=XE.default);var JE=$.vec4(),YE=$.vec4();var ZE=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function qE(e,t){var i=[];if(t.length>1)for(var s=0,r=t.length-1;s1)for(var n=0,o=e.length/3-1;n0,W=9*V,K=1===A[W+0],X=A[W+1];A[W+2],A[W+3];var J=A[W+4],Y=A[W+5],Z=A[W+6],q=A[W+7],ee=A[W+8];if(z){var te=new Uint8Array(l.subarray(j,G)).buffer,ie="".concat(o,"-texture-").concat(V);if(K)s.createTexture({id:ie,buffers:[te],minFilter:J,magFilter:Y,wrapS:Z,wrapT:q,wrapR:ee});else{var se=new Blob([te],{type:10001===X?"image/jpeg":10002===X?"image/png":"image/gif"}),re=(window.URL||window.webkitURL).createObjectURL(se),ne=document.createElement("img");ne.src=re,s.createTexture({id:ie,image:ne,minFilter:J,magFilter:Y,wrapS:Z,wrapT:q,wrapR:ee})}}}for(var oe=0;oe=0?"".concat(o,"-texture-").concat(Ae):null,normalsTextureId:he>=0?"".concat(o,"-texture-").concat(he):null,metallicRoughnessTextureId:ce>=0?"".concat(o,"-texture-").concat(ce):null,emissiveTextureId:de>=0?"".concat(o,"-texture-").concat(de):null,occlusionTextureId:pe>=0?"".concat(o,"-texture-").concat(pe):null})}for(var fe=new Uint32Array(U),ve=0;ve1,je=Ve===U-1,Ge=E[Qe],ze=Ge>=0?"".concat(o,"-textureSet-").concat(Ge):null,We=ZE(k.subarray(6*Qe,6*Qe+3)),Ke=k[6*Qe+3]/255,Xe=k[6*Qe+4]/255,Je=k[6*Qe+5]/255,Ye=n.getNextId();if(He){var Ze=F[Qe],qe=m.slice(Ze,Ze+16),$e="".concat(o,"-geometry.").concat(be,".").concat(Ve),et=ye[$e];if(!et){et={batchThisMesh:!t.reuseGeometries};var tt=!1;switch(y[Ve]){case 0:et.primitiveName="solid",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryNormals=h.subarray(B[Ve],je?h.length:B[Ve+1]),et.geometryUVs=p.subarray(x[Ve],je?p.length:x[Ve+1]),et.geometryIndices=f.subarray(P[Ve],je?f.length:P[Ve+1]),et.geometryEdgeIndices=v.subarray(C[Ve],je?v.length:C[Ve+1]),tt=et.geometryPositions.length>0&&et.geometryIndices.length>0;break;case 1:et.primitiveName="surface",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryNormals=h.subarray(B[Ve],je?h.length:B[Ve+1]),et.geometryUVs=p.subarray(x[Ve],je?p.length:x[Ve+1]),et.geometryIndices=f.subarray(P[Ve],je?f.length:P[Ve+1]),et.geometryEdgeIndices=v.subarray(C[Ve],je?v.length:C[Ve+1]),tt=et.geometryPositions.length>0&&et.geometryIndices.length>0;break;case 2:et.primitiveName="points",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryColors=d.subarray(w[Ve],je?d.length:w[Ve+1]),tt=et.geometryPositions.length>0;break;case 3:et.primitiveName="lines",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryIndices=f.subarray(P[Ve],je?f.length:P[Ve+1]),tt=et.geometryPositions.length>0&&et.geometryIndices.length>0;break;case 4:et.primitiveName="lines",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryIndices=qE(et.geometryPositions,f.subarray(P[Ve],je?f.length:P[Ve+1])),tt=et.geometryPositions.length>0&&et.geometryIndices.length>0;break;default:continue}if(tt||(et=null),et&&(et.geometryPositions.length,et.batchThisMesh)){et.decompressedPositions=new Float32Array(et.geometryPositions.length),et.transformedAndRecompressedPositions=new Uint16Array(et.geometryPositions.length);for(var it=et.geometryPositions,st=et.decompressedPositions,rt=0,nt=it.length;rt0&&ft.length>0;break;case 1:At="surface",ct=c.subarray(b[Ve],je?c.length:b[Ve+1]),ht=h.subarray(B[Ve],je?h.length:B[Ve+1]),dt=p.subarray(x[Ve],je?p.length:x[Ve+1]),ft=f.subarray(P[Ve],je?f.length:P[Ve+1]),vt=v.subarray(C[Ve],je?v.length:C[Ve+1]),gt=ct.length>0&&ft.length>0;break;case 2:At="points",ct=c.subarray(b[Ve],je?c.length:b[Ve+1]),pt=d.subarray(w[Ve],je?d.length:w[Ve+1]),gt=ct.length>0;break;case 3:At="lines",ct=c.subarray(b[Ve],je?c.length:b[Ve+1]),ft=f.subarray(P[Ve],je?f.length:P[Ve+1]),gt=ct.length>0&&ft.length>0;break;case 4:At="lines",ft=qE(ct=c.subarray(b[Ve],je?c.length:b[Ve+1]),f.subarray(P[Ve],je?f.length:P[Ve+1])),gt=ct.length>0&&ft.length>0;break;default:continue}gt&&(s.createMesh(le.apply(Oe,{id:Ye,textureSetId:ze,origin:me,primitive:At,positionsCompressed:ct,normalsCompressed:ht,uv:dt&&dt.length>0?dt:null,colorsCompressed:pt,indices:ft,edgeIndices:vt,positionsDecodeMatrix:Me,color:We,metallic:Xe,roughness:Je,opacity:Ke})),Re.push(Ye))}}Re.length>0&&s.createEntity(le.apply(Ue,{id:Ie,isObject:!0,meshIds:Re}))}}}(e,t,a,s,r,n)}},ek={};ek[vE.version]=vE,ek[_E.version]=_E,ek[BE.version]=BE,ek[PE.version]=PE,ek[FE.version]=FE,ek[DE.version]=DE,ek[LE.version]=LE,ek[HE.version]=HE,ek[KE.version]=KE,ek[$E.version]=$E;var tk=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"XKTLoader",e,r))._maxGeometryBatchSize=r.maxGeometryBatchSize,s.textureTranscoder=r.textureTranscoder,s.dataSource=r.dataSource,s.objectDefaults=r.objectDefaults,s.includeTypes=r.includeTypes,s.excludeTypes=r.excludeTypes,s.excludeUnclassifiedObjects=r.excludeUnclassifiedObjects,s.reuseGeometries=r.reuseGeometries,s}return C(i,[{key:"supportedVersions",get:function(){return Object.keys(ek)}},{key:"textureTranscoder",get:function(){return this._textureTranscoder},set:function(e){this._textureTranscoder=e}},{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new cE}},{key:"objectDefaults",get:function(){return this._objectDefaults},set:function(e){this._objectDefaults=e||lF}},{key:"includeTypes",get:function(){return this._includeTypes},set:function(e){this._includeTypes=e}},{key:"excludeTypes",get:function(){return this._excludeTypes},set:function(e){this._excludeTypes=e}},{key:"excludeUnclassifiedObjects",get:function(){return this._excludeUnclassifiedObjects},set:function(e){this._excludeUnclassifiedObjects=!!e}},{key:"globalizeObjectIds",get:function(){return this._globalizeObjectIds},set:function(e){this._globalizeObjectIds=!!e}},{key:"reuseGeometries",get:function(){return this._reuseGeometries},set:function(e){this._reuseGeometries=!1!==e}},{key:"load",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t.id&&this.viewer.scene.components[t.id]&&(this.error("Component with this ID already exists in viewer: "+t.id+" - will autogenerate this ID"),delete t.id),!(t.src||t.xkt||t.manifestSrc||t.manifest))return this.error("load() param expected: src, xkt, manifestSrc or manifestData"),A;var i={},s=t.includeTypes||this._includeTypes,r=t.excludeTypes||this._excludeTypes,n=t.objectDefaults||this._objectDefaults;if(i.reuseGeometries=null!==t.reuseGeometries&&void 0!==t.reuseGeometries?t.reuseGeometries:!1!==this._reuseGeometries,s){i.includeTypesMap={};for(var o=0,a=s.length;o=t.length?n():e._dataSource.getMetaModel("".concat(m).concat(t[a]),(function(t){h.loadData(t,{includeTypes:s,excludeTypes:r,globalizeObjectIds:i.globalizeObjectIds}),a++,e.scheduleTask(l,100)}),o)}()},y=function(s,r,n){var o=0;!function a(){o>=s.length?r():e._dataSource.getXKT("".concat(m).concat(s[o]),(function(s){e._parseModel(s,t,i,A,null,v),o++,e.scheduleTask(a,100)}),n)}()},b=function(s,r,n){var o=0;!function a(){o>=s.length?r():e._dataSource.getXKT("".concat(m).concat(s[o]),(function(s){e._parseModel(s,t,i,A,h,v),o++,e.scheduleTask(a,100)}),n)}()};if(t.manifest){var B=t.manifest,w=B.xktFiles;if(!w||0===w.length)return void p("load(): Failed to load model manifest - manifest not valid");var x=B.metaModelFiles;x?_(x,(function(){y(w,d,p)}),p):b(w,d,p)}else this._dataSource.getManifest(t.manifestSrc,(function(e){if(!A.destroyed){var t=e.xktFiles;if(t&&0!==t.length){var i=e.metaModelFiles;i?_(i,(function(){y(t,d,p)}),p):b(t,d,p)}else p("load(): Failed to load model manifest - manifest not valid")}}),p)}return A}},{key:"_loadModel",value:function(e,t,i,s,r,n,o,a){var l=this;this._dataSource.getXKT(t.src,(function(e){l._parseModel(e,t,i,s,r,n),o()}),a)}},{key:"_parseModel",value:function(e,t,i,s,r,n){if(!s.destroyed){var o=new DataView(e),a=new Uint8Array(e),l=o.getUint32(0,!0),u=ek[l];if(u){this.log("Loading .xkt V"+l);for(var A=o.getUint32(4,!0),c=[],h=4*(A+2),d=0;de.size)throw new RangeError("offset:"+t+", length:"+i+", size:"+e.size);return e.slice?e.slice(t,t+i):e.webkitSlice?e.webkitSlice(t,t+i):e.mozSlice?e.mozSlice(t,t+i):e.msSlice?e.msSlice(t,t+i):void 0}(e,t,i))}catch(e){r(e)}}}function p(){}function f(e){var i,s=this;s.init=function(e){i=new Blob([],{type:o}),e()},s.writeUint8Array=function(e,s){i=new Blob([i,t?e:e.buffer],{type:o}),s()},s.getData=function(t,s){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=s,r.readAsText(i,e)}}function v(t){var i=this,s="",r="";i.init=function(e){s+="data:"+(t||"")+";base64,",e()},i.writeUint8Array=function(t,i){var n,o=r.length,a=r;for(r="",n=0;n<3*Math.floor((o+t.length)/3)-o;n++)a+=String.fromCharCode(t[n]);for(;n2?s+=e.btoa(a):r=a,i()},i.getData=function(t){t(s+e.btoa(r))}}function g(e){var i,s=this;s.init=function(t){i=new Blob([],{type:e}),t()},s.writeUint8Array=function(s,r){i=new Blob([i,t?s:s.buffer],{type:e}),r()},s.getData=function(e){e(i)}}function m(e,t,i,s,r,o,a,l,u,A){var c,h,d,p=0,f=t.sn;function v(){e.removeEventListener("message",g,!1),l(h,d)}function g(t){var i=t.data,r=i.data,n=i.error;if(n)return n.toString=function(){return"Error: "+this.message},void u(n);if(i.sn===f)switch("number"==typeof i.codecTime&&(e.codecTime+=i.codecTime),"number"==typeof i.crcTime&&(e.crcTime+=i.crcTime),i.type){case"append":r?(h+=r.length,s.writeUint8Array(r,(function(){m()}),A)):m();break;case"flush":d=i.crc,r?(h+=r.length,s.writeUint8Array(r,(function(){v()}),A)):v();break;case"progress":a&&a(c+i.loaded,o);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",i)}}function m(){(c=p*n)<=o?i.readUint8Array(r+c,Math.min(n,o-c),(function(i){a&&a(c,o);var s=0===c?t:{sn:f};s.type="append",s.data=i;try{e.postMessage(s,[i.buffer])}catch(t){e.postMessage(s)}p++}),u):e.postMessage({sn:f,type:"flush"})}h=0,e.addEventListener("message",g,!1),m()}function _(e,t,i,s,r,o,l,u,A,c){var h,d=0,p=0,f="input"===o,v="output"===o,g=new a;!function o(){var a;if((h=d*n)127?r[i-128]:String.fromCharCode(i);return s}function B(e){return decodeURIComponent(escape(e))}function w(e){var t,i="";for(t=0;t>16,i=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&i)>>11,(2016&i)>>5,2*(31&i),0)}catch(e){}}(e.lastModDateRaw),1!=(1&e.bitFlag)?((s||8!=(8&e.bitFlag))&&(e.crc32=t.view.getUint32(i+10,!0),e.compressedSize=t.view.getUint32(i+14,!0),e.uncompressedSize=t.view.getUint32(i+18,!0)),4294967295!==e.compressedSize&&4294967295!==e.uncompressedSize?(e.filenameLength=t.view.getUint16(i+22,!0),e.extraFieldLength=t.view.getUint16(i+24,!0)):r("File is using Zip64 (4gb+ file size).")):r("File contains encrypted entry.")}function P(t,n,o){var a=0;function l(){}l.prototype.getData=function(s,n,l,A){var c=this;function h(e,t){A&&!function(e){var t=u(4);return t.view.setUint32(0,e),c.crc32==t.view.getUint32(0)}(t)?o("CRC failed."):s.getData((function(e){n(e)}))}function d(e){o(e||r)}function p(e){o(e||"Error while writing file data.")}t.readUint8Array(c.offset,30,(function(r){var n,f=u(r.length,r);1347093252==f.view.getUint32(0)?(x(c,f,4,!1,o),n=c.offset+30+c.filenameLength+c.extraFieldLength,s.init((function(){0===c.compressionMethod?y(c._worker,a++,t,s,n,c.compressedSize,A,h,l,d,p):function(t,i,s,r,n,o,a,l,u,A,c){var h=a?"output":"none";e.zip.useWebWorkers?m(t,{sn:i,codecClass:"Inflater",crcType:h},s,r,n,o,u,l,A,c):_(new e.zip.Inflater,s,r,n,o,h,u,l,A,c)}(c._worker,a++,t,s,n,c.compressedSize,A,h,l,d,p)}),p)):o(i)}),d)};var A={getEntries:function(e){var r=this._worker;!function(e){t.size<22?o(i):r(22,(function(){r(Math.min(65558,t.size),(function(){o(i)}))}));function r(i,r){t.readUint8Array(t.size-i,i,(function(t){for(var i=t.length-22;i>=0;i--)if(80===t[i]&&75===t[i+1]&&5===t[i+2]&&6===t[i+3])return void e(new DataView(t.buffer,i,22));r()}),(function(){o(s)}))}}((function(n){var a,A;a=n.getUint32(16,!0),A=n.getUint16(8,!0),a<0||a>=t.size?o(i):t.readUint8Array(a,t.size-a,(function(t){var s,n,a,c,h=0,d=[],p=u(t.length,t);for(s=0;s>>8^i[255&(t^e[s])];this.crc=t},a.prototype.get=function(){return~this.crc},a.prototype.table=function(){var e,t,i,s=[];for(e=0;e<256;e++){for(i=e,t=0;t<8;t++)1&i?i=i>>>1^3988292384:i>>>=1;s[e]=i}return s}(),l.prototype.append=function(e,t){return e},l.prototype.flush=function(){},c.prototype=new A,c.prototype.constructor=c,h.prototype=new A,h.prototype.constructor=h,d.prototype=new A,d.prototype.constructor=d,p.prototype.getData=function(e){e(this.data)},f.prototype=new p,f.prototype.constructor=f,v.prototype=new p,v.prototype.constructor=v,g.prototype=new p,g.prototype.constructor=g;var E={deflater:["z-worker.js","deflate.js"],inflater:["z-worker.js","inflate.js"]};function k(t,i,s){if(null===e.zip.workerScripts||null===e.zip.workerScriptsPath){var r;if(e.zip.workerScripts){if(r=e.zip.workerScripts[t],!Array.isArray(r))return void s(new Error("zip.workerScripts."+t+" is not an array!"));r=function(e){var t=document.createElement("a");return e.map((function(e){return t.href=e,t.href}))}(r)}else(r=E[t].slice(0))[0]=(e.zip.workerScriptsPath||"")+r[0];var n=new Worker(r[0]);n.codecTime=n.crcTime=0,n.postMessage({type:"importScripts",scripts:r.slice(1)}),n.addEventListener("message",(function e(t){var r=t.data;if(r.error)return n.terminate(),void s(r.error);"importScripts"===r.type&&(n.removeEventListener("message",e),n.removeEventListener("error",o),i(n))})),n.addEventListener("error",o)}else s(new Error("Either zip.workerScripts or zip.workerScriptsPath may be set, not both."));function o(e){n.terminate(),s(e)}}function I(e){console.error(e)}e.zip={Reader:A,Writer:p,BlobReader:d,Data64URIReader:h,TextReader:c,BlobWriter:g,Data64URIWriter:v,TextWriter:f,createReader:function(e,t,i){i=i||I,e.init((function(){P(e,t,i)}),i)},createWriter:function(e,t,i,s){i=i||I,s=!!s,e.init((function(){F(e,t,i,s)}),i)},useWebWorkers:!0,workerScriptsPath:null,workerScripts:null}}(sk);var rk=sk.zip;!function(e){var t,i,s=e.Reader,r=e.Writer;try{i=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function n(e){var t=this;function i(i,s){var r;t.data?i():((r=new XMLHttpRequest).addEventListener("load",(function(){t.size||(t.size=Number(r.getResponseHeader("Content-Length"))||Number(r.response.byteLength)),t.data=new Uint8Array(r.response),i()}),!1),r.addEventListener("error",s,!1),r.open("GET",e),r.responseType="arraybuffer",r.send())}t.size=0,t.init=function(s,r){if(function(e){var t=document.createElement("a");return t.href=e,"http:"===t.protocol||"https:"===t.protocol}(e)){var n=new XMLHttpRequest;n.addEventListener("load",(function(){t.size=Number(n.getResponseHeader("Content-Length")),t.size?s():i(s,r)}),!1),n.addEventListener("error",r,!1),n.open("HEAD",e),n.send()}else i(s,r)},t.readUint8Array=function(e,s,r,n){i((function(){r(new Uint8Array(t.data.subarray(e,e+s)))}),n)}}function o(e){var t=this;t.size=0,t.init=function(i,s){var r=new XMLHttpRequest;r.addEventListener("load",(function(){t.size=Number(r.getResponseHeader("Content-Length")),"bytes"==r.getResponseHeader("Accept-Ranges")?i():s("HTTP Range not supported.")}),!1),r.addEventListener("error",s,!1),r.open("HEAD",e),r.send()},t.readUint8Array=function(t,i,s,r){!function(t,i,s,r){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="arraybuffer",n.setRequestHeader("Range","bytes="+t+"-"+(t+i-1)),n.addEventListener("load",(function(){s(n.response)}),!1),n.addEventListener("error",r,!1),n.send()}(t,i,(function(e){s(new Uint8Array(e))}),r)}}function a(e){var t=this;t.size=0,t.init=function(i,s){t.size=e.byteLength,i()},t.readUint8Array=function(t,i,s,r){s(new Uint8Array(e.slice(t,t+i)))}}function l(){var e,t=this;t.init=function(t,i){e=new Uint8Array,t()},t.writeUint8Array=function(t,i,s){var r=new Uint8Array(e.length+t.length);r.set(e),r.set(t,e.length),e=r,i()},t.getData=function(t){t(e.buffer)}}function u(e,t){var s,r=this;r.init=function(t,i){e.createWriter((function(e){s=e,t()}),i)},r.writeUint8Array=function(e,r,n){var o=new Blob([i?e:e.buffer],{type:t});s.onwrite=function(){s.onwrite=null,r()},s.onerror=n,s.write(o)},r.getData=function(t){e.file(t)}}n.prototype=new s,n.prototype.constructor=n,o.prototype=new s,o.prototype.constructor=o,a.prototype=new s,a.prototype.constructor=a,l.prototype=new r,l.prototype.constructor=l,u.prototype=new r,u.prototype.constructor=u,e.FileWriter=u,e.HttpReader=n,e.HttpRangeReader=o,e.ArrayBufferReader=a,e.ArrayBufferWriter=l,e.fs&&((t=e.fs.ZipDirectoryEntry).prototype.addHttpContent=function(i,s,r){return function(i,s,r,n){if(i.directory)return n?new t(i.fs,s,r,i):new e.fs.ZipFileEntry(i.fs,s,r,i);throw"Parent entry is not a directory."}(this,i,{data:s,Reader:r?o:n})},t.prototype.importHttpContent=function(e,t,i,s){this.importZip(t?new o(e):new n(e),i,s)},e.fs.FS.prototype.importHttpContent=function(e,i,s,r){this.entries=[],this.root=new t(this),this.root.importHttpContent(e,i,s,r)})}(rk);var nk=["4.2"],ok=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,e),this.supportedSchemas=nk,this._xrayOpacity=.7,this._src=null,this._options=i,this.viewpoint=null,i.workerScriptsPath?(rk.workerScriptsPath=i.workerScriptsPath,this.src=i.src,this.xrayOpacity=.7,this.displayEffect=i.displayEffect,this.createMetaModel=i.createMetaModel):t.error("Config expected: workerScriptsPath")}return C(e,[{key:"load",value:function(e,t,i,s,r,n){switch(s.materialType){case"MetallicMaterial":t._defaultMaterial=new xn(t,{baseColor:[1,1,1],metallic:.6,roughness:.6});break;case"SpecularMaterial":t._defaultMaterial=new Mn(t,{diffuse:[1,1,1],specular:$.vec3([1,1,1]),glossiness:.5});break;default:t._defaultMaterial=new Oi(t,{reflectivity:.75,shiness:100,diffuse:[1,1,1]})}t._wireframeMaterial=new bn(t,{color:[0,0,0],lineWidth:2});var o=t.scene.canvas.spinner;o.processes++,ak(e,t,i,s,(function(){o.processes--,r&&r(),t.fire("loaded",!0,!1)}),(function(e){o.processes--,t.error(e),n&&n(e),t.fire("error",e)}),(function(e){console.log("Error, Will Robinson: "+e)}))}}]),e}(),ak=function(e,t,i,s,r,n){!function(e,t,i){var s=new fk;s.load(e,(function(){t(s)}),(function(e){i("Error loading ZIP archive: "+e)}))}(i,(function(i){lk(e,i,s,t,r,n)}),n)},lk=function(){return function(t,i,s,r,n){var o={plugin:t,zip:i,edgeThreshold:30,materialType:s.materialType,scene:r.scene,modelNode:r,info:{references:{}},materials:{}};s.createMetaModel&&(o.metaModelData={modelId:r.id,metaObjects:[{name:r.id,type:"Default",id:r.id}]}),r.scene.loading++,function(t,i){t.zip.getFile("Manifest.xml",(function(s,r){for(var n=r.children,o=0,a=n.length;o0){for(var o=n.trim().split(" "),a=new Int16Array(o.length),l=0,u=0,A=o.length;u0){i.primitive="triangles";for(var n=[],o=0,a=r.length;o=t.length)i();else{var a=t[n].id,l=a.lastIndexOf(":");l>0&&(a=a.substring(l+1));var u=a.lastIndexOf("#");u>0&&(a=a.substring(0,u)),s[a]?r(n+1):function(e,t,i){e.zip.getFile(t,(function(t,s){!function(e,t,i){for(var s,r=t.children,n=0,o=r.length;n0)for(var s=0,r=t.length;s1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),s=t.call(this,"XML3DLoader",e,r),r.workerScriptsPath?(s._workerScriptsPath=r.workerScriptsPath,s._loader=new ok(b(s),r),s.supportedSchemas=s._loader.supportedSchemas,s):(s.error("Config expected: workerScriptsPath"),y(s))}return C(i,[{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.workerScriptsPath=this._workerScriptsPath,e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new yn(this.viewer.scene,le.apply(e,{isModel:!0})),i=e.src;return i?(this._loader.load(this,t,i,e),t):(this.error("load() param expected: src"),t)}}]),i}(),mk=function(){function e(){x(this,e)}return C(e,[{key:"getIFC",value:function(e,t,i){var s=function(){};t=t||s,i=i||s;var r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){var n=!!r[2],o=r[3];o=window.decodeURIComponent(o),n&&(o=window.atob(o));try{for(var a=new ArrayBuffer(o.length),l=new Uint8Array(a),u=0;u1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,"ifcLoader",e,r)).dataSource=r.dataSource,s.objectDefaults=r.objectDefaults,s.includeTypes=r.includeTypes,s.excludeTypes=r.excludeTypes,s.excludeUnclassifiedObjects=r.excludeUnclassifiedObjects,!r.WebIFC)throw"Parameter expected: WebIFC";if(!r.IfcAPI)throw"Parameter expected: IfcAPI";return s._webIFC=r.WebIFC,s._ifcAPI=r.IfcAPI,s}return C(i,[{key:"supportedVersions",get:function(){return["2x3","4"]}},{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new mk}},{key:"objectDefaults",get:function(){return this._objectDefaults},set:function(e){this._objectDefaults=e||lF}},{key:"includeTypes",get:function(){return this._includeTypes},set:function(e){this._includeTypes=e}},{key:"excludeTypes",get:function(){return this._excludeTypes},set:function(e){this._excludeTypes=e}},{key:"excludeUnclassifiedObjects",get:function(){return this._excludeUnclassifiedObjects},set:function(e){this._excludeUnclassifiedObjects=!!e}},{key:"globalizeObjectIds",get:function(){return this._globalizeObjectIds},set:function(e){this._globalizeObjectIds=!!e}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new Ah(this.viewer.scene,le.apply(e,{isModel:!0}));if(!e.src&&!e.ifc)return this.error("load() param expected: src or IFC"),t;var i={autoNormals:!0};if(!1!==e.loadMetadata){var s=e.includeTypes||this._includeTypes,r=e.excludeTypes||this._excludeTypes,n=e.objectDefaults||this._objectDefaults;if(s){i.includeTypesMap={};for(var o=0,a=s.length;o0){for(var l=n.Name.value,u=[],A=0,c=a.length;A1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"lasLoader",e,r)).dataSource=r.dataSource,s.skip=r.skip,s.fp64=r.fp64,s.colorDepth=r.colorDepth,s}return C(i,[{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new yk}},{key:"skip",get:function(){return this._skip},set:function(e){this._skip=e||1}},{key:"fp64",get:function(){return this._fp64},set:function(e){this._fp64=!!e}},{key:"colorDepth",get:function(){return this._colorDepth},set:function(e){this._colorDepth=e||"auto"}},{key:"load",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.id&&this.viewer.scene.components[t.id]&&(this.error("Component with this ID already exists in viewer: "+t.id+" - will autogenerate this ID"),delete t.id);var i=new Ah(this.viewer.scene,le.apply(t,{isModel:!0}));if(!t.src&&!t.las)return this.error("load() param expected: src or las"),i;var s={las:{skip:this._skip,fp64:this._fp64,colorDepth:this._colorDepth}};if(t.src)this._loadModel(t.src,t,s,i);else{var r=this.viewer.scene.canvas.spinner;r.processes++,this._parseModel(t.las,t,s,i).then((function(){r.processes--}),(function(t){r.processes--,e.error(t),i.fire("error",t)}))}return i}},{key:"_loadModel",value:function(e,t,i,s){var r=this,n=this.viewer.scene.canvas.spinner;n.processes++,this._dataSource.getLAS(t.src,(function(e){r._parseModel(e,t,i,s).then((function(){n.processes--}),(function(e){n.processes--,r.error(e),s.fire("error",e)}))}),(function(e){n.processes--,r.error(e),s.fire("error",e)}))}},{key:"_parseModel",value:function(e,t,i,s){var r=this;function n(e){var i=e.value;if(t.rotateX&&i)for(var s=0,r=i.length;s=e.length)return e;for(var i=[],s=0;s80*i){s=n=e[0],r=o=e[1];for(var p=i;pn&&(n=a),l>o&&(o=l);u=0!==(u=Math.max(n-s,o-r))?1/u:0}return Sk(h,d,i,s,r,u),d}function Ik(e,t,i,s,r){var n,o;if(r===tI(e,t,i,s)>0)for(n=t;n=t;n-=s)o=qk(n,e[n],e[n+1],o);return o&&Wk(o,o.next)&&($k(o),o=o.next),o}function Dk(e,t){if(!e)return e;t||(t=e);var i,s=e;do{if(i=!1,s.steiner||!Wk(s,s.next)&&0!==zk(s.prev,s,s.next))s=s.next;else{if($k(s),(s=t=s.prev)===s.next)break;i=!0}}while(i||s!==t);return t}function Sk(e,t,i,s,r,n,o){if(e){!o&&n&&function(e,t,i,s){var r=e;do{null===r.z&&(r.z=Vk(r.x,r.y,t,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,i,s,r,n,o,a,l,u=1;do{for(i=e,e=null,n=null,o=0;i;){for(o++,s=i,a=0,t=0;t0||l>0&&s;)0!==a&&(0===l||!s||i.z<=s.z)?(r=i,i=i.nextZ,a--):(r=s,s=s.nextZ,l--),n?n.nextZ=r:e=r,r.prevZ=n,n=r;i=s}n.nextZ=null,u*=2}while(o>1)}(r)}(e,s,r,n);for(var a,l,u=e;e.prev!==e.next;)if(a=e.prev,l=e.next,n?Rk(e,s,r,n):Tk(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),$k(e),e=l.next,u=l.next;else if((e=l)===u){o?1===o?Sk(e=Lk(Dk(e),t,i),t,i,s,r,n,2):2===o&&Uk(e,t,i,s,r,n):Sk(Dk(e),t,i,s,r,n,1);break}}}function Tk(e){var t=e.prev,i=e,s=e.next;if(zk(t,i,s)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(jk(t.x,t.y,i.x,i.y,s.x,s.y,r.x,r.y)&&zk(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Rk(e,t,i,s){var r=e.prev,n=e,o=e.next;if(zk(r,n,o)>=0)return!1;for(var a=r.xn.x?r.x>o.x?r.x:o.x:n.x>o.x?n.x:o.x,A=r.y>n.y?r.y>o.y?r.y:o.y:n.y>o.y?n.y:o.y,c=Vk(a,l,t,i,s),h=Vk(u,A,t,i,s),d=e.prevZ,p=e.nextZ;d&&d.z>=c&&p&&p.z<=h;){if(d!==e.prev&&d!==e.next&&jk(r.x,r.y,n.x,n.y,o.x,o.y,d.x,d.y)&&zk(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&&jk(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&zk(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=c;){if(d!==e.prev&&d!==e.next&&jk(r.x,r.y,n.x,n.y,o.x,o.y,d.x,d.y)&&zk(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=h;){if(p!==e.prev&&p!==e.next&&jk(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&zk(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Lk(e,t,i){var s=e;do{var r=s.prev,n=s.next.next;!Wk(r,n)&&Kk(r,s,s.next,n)&&Yk(r,n)&&Yk(n,r)&&(t.push(r.i/i),t.push(s.i/i),t.push(n.i/i),$k(s),$k(s.next),s=e=n),s=s.next}while(s!==e);return Dk(s)}function Uk(e,t,i,s,r,n){var o=e;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Gk(o,a)){var l=Zk(o,a);return o=Dk(o,o.next),l=Dk(l,l.next),Sk(o,t,i,s,r,n),void Sk(l,t,i,s,r,n)}a=a.next}o=o.next}while(o!==e)}function Ok(e,t){return e.x-t.x}function Nk(e,t){if(t=function(e,t){var i,s=t,r=e.x,n=e.y,o=-1/0;do{if(n<=s.y&&n>=s.next.y&&s.next.y!==s.y){var a=s.x+(n-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(a<=r&&a>o){if(o=a,a===r){if(n===s.y)return s;if(n===s.next.y)return s.next}i=s.x=s.x&&s.x>=A&&r!==s.x&&jk(ni.x||s.x===i.x&&Qk(i,s)))&&(i=s,h=l)),s=s.next}while(s!==u);return i}(e,t),t){var i=Zk(t,e);Dk(t,t.next),Dk(i,i.next)}}function Qk(e,t){return zk(e.prev,e,t.prev)<0&&zk(t.next,e,e.next)<0}function Vk(e,t,i,s,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Hk(e){var t=e,i=e;do{(t.x=0&&(e-o)*(s-a)-(i-o)*(t-a)>=0&&(i-o)*(n-a)-(r-o)*(s-a)>=0}function Gk(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Kk(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Yk(e,t)&&Yk(t,e)&&function(e,t){var i=e,s=!1,r=(e.x+t.x)/2,n=(e.y+t.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==e);return s}(e,t)&&(zk(e.prev,e,t.prev)||zk(e,t.prev,t))||Wk(e,t)&&zk(e.prev,e,e.next)>0&&zk(t.prev,t,t.next)>0)}function zk(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Wk(e,t){return e.x===t.x&&e.y===t.y}function Kk(e,t,i,s){var r=Jk(zk(e,t,i)),n=Jk(zk(e,t,s)),o=Jk(zk(i,s,e)),a=Jk(zk(i,s,t));return r!==n&&o!==a||(!(0!==r||!Xk(e,i,t))||(!(0!==n||!Xk(e,s,t))||(!(0!==o||!Xk(i,e,s))||!(0!==a||!Xk(i,t,s)))))}function Xk(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Jk(e){return e>0?1:e<0?-1:0}function Yk(e,t){return zk(e.prev,e,e.next)<0?zk(e,t,e.next)>=0&&zk(e,e.prev,t)>=0:zk(e,t,e.prev)<0||zk(e,e.next,t)<0}function Zk(e,t){var i=new eI(e.i,e.x,e.y),s=new eI(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,s.next=i,i.prev=s,n.next=s,s.prev=n,s}function qk(e,t,i,s){var r=new eI(e,t,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function $k(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function eI(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function tI(e,t,i,s){for(var r=0,n=t,o=i-s;n0&&(s+=e[r-1].length,i.holes.push(s))}return i};var iI=$.vec2(),sI=$.vec3(),rI=$.vec3(),nI=$.vec3(),oI=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"cityJSONLoader",e,r)).dataSource=r.dataSource,s}return C(i,[{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new Ek}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new Ah(this.viewer.scene,le.apply(e,{isModel:!0,edges:!0}));if(!e.src&&!e.cityJSON)return this.error("load() param expected: src or cityJSON"),t;var i={};if(e.src)this._loadModel(e.src,e,i,t);else{var s=this.viewer.scene.canvas.spinner;s.processes++,this._parseModel(e.cityJSON,e,i,t),s.processes--}return t}},{key:"_loadModel",value:function(e,t,i,s){var r=this,n=this.viewer.scene.canvas.spinner;n.processes++,this._dataSource.getCityJSON(t.src,(function(e){r._parseModel(e,t,i,s),n.processes--}),(function(e){n.processes--,r.error(e),s.fire("error",e)}))}},{key:"_parseModel",value:function(e,t,i,s){if(!s.destroyed){var r=e.transform?this._transformVertices(e.vertices,e.transform,i.rotateX):e.vertices,n=t.stats||{};n.sourceFormat=e.type||"CityJSON",n.schemaVersion=e.version||"",n.title="",n.author="",n.created="",n.numMetaObjects=0,n.numPropertySets=0,n.numObjects=0,n.numGeometries=0,n.numTriangles=0,n.numVertices=0;var o=!1!==t.loadMetadata,a=o?{id:$.createUUID(),name:"Model",type:"Model"}:null,l=o?{id:"",projectId:"",author:"",createdAt:"",schema:e.version||"",creatingApplication:"",metaObjects:[a],propertySets:[]}:null,u={data:e,vertices:r,sceneModel:s,loadMetadata:o,metadata:l,rootMetaObject:a,nextId:0,stats:n};if(this._parseCityJSON(u),s.finalize(),o){var A=s.id;this.viewer.metaScene.createMetaModel(A,u.metadata,i)}s.scene.once("tick",(function(){s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}}},{key:"_transformVertices",value:function(e,t,i){for(var s=[],r=t.scale||$.vec3([1,1,1]),n=t.translate||$.vec3([0,0,0]),o=0,a=0;o0){for(var u=[],A=0,c=t.geometry.length;A0){var _=g[m[0]];if(void 0!==_.value)d=v[_.value];else{var y=_.values;if(y){p=[];for(var b=0,B=y.length;b0&&(s.createEntity({id:i,meshIds:u,isObject:!0}),e.stats.numObjects++)}}},{key:"_parseGeometrySurfacesWithOwnMaterials",value:function(e,t,i,s){switch(t.type){case"MultiPoint":case"MultiLineString":break;case"MultiSurface":case"CompositeSurface":var r=t.boundaries;this._parseSurfacesWithOwnMaterials(e,i,r,s);break;case"Solid":for(var n=t.boundaries,o=0;o0&&c.push(u.length);var f=this._extractLocalIndices(e,a[p],h,d);u.push.apply(u,A(f))}if(3===u.length)d.indices.push(u[0]),d.indices.push(u[1]),d.indices.push(u[2]);else if(u.length>3){for(var v=[],g=0;g0&&o.indices.length>0){var f=""+e.nextId++;r.createMesh({id:f,primitive:"triangles",positions:o.positions,indices:o.indices,color:i&&i.diffuseColor?i.diffuseColor:[.8,.8,.8],opacity:1}),s.push(f),e.stats.numGeometries++,e.stats.numVertices+=o.positions.length/3,e.stats.numTriangles+=o.indices.length/3}}},{key:"_parseSurfacesWithSharedMaterial",value:function(e,t,i,s){for(var r=e.vertices,n=0;n0&&a.push(o.length);var u=this._extractLocalIndices(e,t[n][l],i,s);o.push.apply(o,A(u))}if(3===o.length)s.indices.push(o[0]),s.indices.push(o[1]),s.indices.push(o[2]);else if(o.length>3){for(var c=[],h=0;h0&&r[r.length-1])||6!==n[0]&&2!==n[0])){o=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]=55296&&r<=56319&&i>10),o%1024+56320)),(r+1===i||s.length>16384)&&(n+=String.fromCharCode.apply(String,s),s.length=0)}return n},pp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fp="undefined"==typeof Uint8Array?[]:new Uint8Array(256),vp=0;vp=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),Bp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wp="undefined"==typeof Uint8Array?[]:new Uint8Array(256),xp=0;xp>4,A[l++]=(15&s)<<4|r>>2,A[l++]=(3&r)<<6|63&n;return u}(e),o=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s0;){var o=s[--n];if(Array.isArray(e)?-1!==e.indexOf(o):e===o)for(var a=i;a<=s.length;){var l;if((l=s[++a])===t)return!0;if(l!==Pp)break}if(o!==Pp)break}return!1},of=function(e,t){for(var i=e;i>=0;){var s=t[i];if(s!==Pp)return s;i--}return 0},af=function(e,t,i,s,r){if(0===i[s])return"×";var n=s-1;if(Array.isArray(r)&&!0===r[n])return"×";var o=n-1,a=n+1,l=t[n],u=o>=0?t[o]:0,A=t[a];if(2===l&&3===A)return"×";if(-1!==qp.indexOf(l))return"!";if(-1!==qp.indexOf(A))return"×";if(-1!==$p.indexOf(A))return"×";if(8===of(n,t))return"÷";if(11===Yp.get(e[n]))return"×";if((l===Qp||l===Vp)&&11===Yp.get(e[a]))return"×";if(7===l||7===A)return"×";if(9===l)return"×";if(-1===[Pp,Cp,Mp].indexOf(l)&&9===A)return"×";if(-1!==[Fp,Ep,kp,Tp,Op].indexOf(A))return"×";if(of(n,t)===Sp)return"×";if(nf(23,Sp,n,t))return"×";if(nf([Fp,Ep],Dp,n,t))return"×";if(nf(12,12,n,t))return"×";if(l===Pp)return"÷";if(23===l||23===A)return"×";if(16===A||16===l)return"÷";if(-1!==[Cp,Mp,Dp].indexOf(A)||14===l)return"×";if(36===u&&-1!==rf.indexOf(l))return"×";if(l===Op&&36===A)return"×";if(A===Ip)return"×";if(-1!==Zp.indexOf(A)&&l===Rp||-1!==Zp.indexOf(l)&&A===Rp)return"×";if(l===Up&&-1!==[Gp,Qp,Vp].indexOf(A)||-1!==[Gp,Qp,Vp].indexOf(l)&&A===Lp)return"×";if(-1!==Zp.indexOf(l)&&-1!==ef.indexOf(A)||-1!==ef.indexOf(l)&&-1!==Zp.indexOf(A))return"×";if(-1!==[Up,Lp].indexOf(l)&&(A===Rp||-1!==[Sp,Mp].indexOf(A)&&t[a+1]===Rp)||-1!==[Sp,Mp].indexOf(l)&&A===Rp||l===Rp&&-1!==[Rp,Op,Tp].indexOf(A))return"×";if(-1!==[Rp,Op,Tp,Fp,Ep].indexOf(A))for(var c=n;c>=0;){if((h=t[c])===Rp)return"×";if(-1===[Op,Tp].indexOf(h))break;c--}if(-1!==[Up,Lp].indexOf(A))for(c=-1!==[Fp,Ep].indexOf(l)?o:n;c>=0;){var h;if((h=t[c])===Rp)return"×";if(-1===[Op,Tp].indexOf(h))break;c--}if(zp===l&&-1!==[zp,Wp,Hp,jp].indexOf(A)||-1!==[Wp,Hp].indexOf(l)&&-1!==[Wp,Kp].indexOf(A)||-1!==[Kp,jp].indexOf(l)&&A===Kp)return"×";if(-1!==sf.indexOf(l)&&-1!==[Ip,Lp].indexOf(A)||-1!==sf.indexOf(A)&&l===Up)return"×";if(-1!==Zp.indexOf(l)&&-1!==Zp.indexOf(A))return"×";if(l===Tp&&-1!==Zp.indexOf(A))return"×";if(-1!==Zp.concat(Rp).indexOf(l)&&A===Sp&&-1===Jp.indexOf(e[a])||-1!==Zp.concat(Rp).indexOf(A)&&l===Ep)return"×";if(41===l&&41===A){for(var d=i[n],p=1;d>0&&41===t[--d];)p++;if(p%2!=0)return"×"}return l===Qp&&A===Vp?"×":"÷"},lf=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=function(e,t){void 0===t&&(t="strict");var i=[],s=[],r=[];return e.forEach((function(e,n){var o=Yp.get(e);if(o>50?(r.push(!0),o-=50):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return s.push(n),i.push(16);if(4===o||11===o){if(0===n)return s.push(n),i.push(Np);var a=i[n-1];return-1===tf.indexOf(a)?(s.push(s[n-1]),i.push(a)):(s.push(n),i.push(Np))}return s.push(n),31===o?i.push("strict"===t?Dp:Gp):o===Xp||29===o?i.push(Np):43===o?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(Gp):i.push(Np):void i.push(o)})),[s,i,r]}(e,t.lineBreak),s=i[0],r=i[1],n=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map((function(e){return-1!==[Rp,Np,Xp].indexOf(e)?Gp:e})));var o="keep-all"===t.wordBreak?n.map((function(t,i){return t&&e[i]>=19968&&e[i]<=40959})):void 0;return[s,r,o]},uf=function(){function e(e,t,i,s){this.codePoints=e,this.required="!"===t,this.start=i,this.end=s}return e.prototype.slice=function(){return dp.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),Af=function(e){return e>=48&&e<=57},cf=function(e){return Af(e)||e>=65&&e<=70||e>=97&&e<=102},hf=function(e){return 10===e||9===e||32===e},df=function(e){return function(e){return function(e){return e>=97&&e<=122}(e)||function(e){return e>=65&&e<=90}(e)}(e)||function(e){return e>=128}(e)||95===e},pf=function(e){return df(e)||Af(e)||45===e},ff=function(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e},vf=function(e,t){return 92===e&&10!==t},gf=function(e,t,i){return 45===e?df(t)||vf(t,i):!!df(e)||!(92!==e||!vf(e,t))},mf=function(e,t,i){return 43===e||45===e?!!Af(t)||46===t&&Af(i):Af(46===e?t:e)},_f=function(e){var t=0,i=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(i=-1),t++);for(var s=[];Af(e[t]);)s.push(e[t++]);var r=s.length?parseInt(dp.apply(void 0,s),10):0;46===e[t]&&t++;for(var n=[];Af(e[t]);)n.push(e[t++]);var o=n.length,a=o?parseInt(dp.apply(void 0,n),10):0;69!==e[t]&&101!==e[t]||t++;var l=1;43!==e[t]&&45!==e[t]||(45===e[t]&&(l=-1),t++);for(var u=[];Af(e[t]);)u.push(e[t++]);var A=u.length?parseInt(dp.apply(void 0,u),10):0;return i*(r+a*Math.pow(10,-o))*Math.pow(10,l*A)},yf={type:2},bf={type:3},Bf={type:4},wf={type:13},xf={type:8},Pf={type:21},Cf={type:9},Mf={type:10},Ff={type:11},Ef={type:12},kf={type:14},If={type:23},Df={type:1},Sf={type:25},Tf={type:24},Rf={type:26},Lf={type:27},Uf={type:28},Of={type:29},Nf={type:31},Qf={type:32},Vf=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(hp(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==Qf;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case 34:return this.consumeStringToken(34);case 35:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),s=this.peekCodePoint(2);if(pf(t)||vf(i,s)){var r=gf(t,i,s)?2:1;return{type:5,value:this.consumeName(),flags:r}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),wf;break;case 39:return this.consumeStringToken(39);case 40:return yf;case 41:return bf;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),kf;break;case 43:if(mf(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 44:return Bf;case 45:var n=e,o=this.peekCodePoint(0),a=this.peekCodePoint(1);if(mf(n,o,a))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(gf(n,o,a))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(45===o&&62===a)return this.consumeCodePoint(),this.consumeCodePoint(),Tf;break;case 46:if(mf(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(42===l&&47===(l=this.consumeCodePoint()))return this.consumeToken();if(-1===l)return this.consumeToken()}break;case 58:return Rf;case 59:return Lf;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),Sf;break;case 64:var u=this.peekCodePoint(0),A=this.peekCodePoint(1),c=this.peekCodePoint(2);if(gf(u,A,c))return{type:7,value:this.consumeName()};break;case 91:return Uf;case 92:if(vf(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case 93:return Of;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),xf;break;case 123:return Ff;case 125:return Ef;case 117:case 85:var h=this.peekCodePoint(0),d=this.peekCodePoint(1);return 43!==h||!cf(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Cf;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),Pf;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),Mf;break;case-1:return Qf}return hf(e)?(this.consumeWhiteSpace(),Nf):Af(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):df(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:dp(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();cf(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;63===t&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(dp.apply(void 0,e.map((function(e){return 63===e?48:e}))),16),end:parseInt(dp.apply(void 0,e.map((function(e){return 63===e?70:e}))),16)};var s=parseInt(dp.apply(void 0,e),16);if(45===this.peekCodePoint(0)&&cf(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];cf(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:s,end:parseInt(dp.apply(void 0,r),16)}}return{type:30,start:s,end:s}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var t=this.peekCodePoint(0);if(39===t||34===t){var i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),If)}for(;;){var s=this.consumeCodePoint();if(-1===s||41===s)return{type:22,value:dp.apply(void 0,e)};if(hf(s))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:dp.apply(void 0,e)}):(this.consumeBadUrlRemnants(),If);if(34===s||39===s||40===s||ff(s))return this.consumeBadUrlRemnants(),If;if(92===s){if(!vf(s,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),If;e.push(this.consumeEscapedCodePoint())}else e.push(s)}},e.prototype.consumeWhiteSpace=function(){for(;hf(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(41===e||-1===e)return;vf(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t="";e>0;){var i=Math.min(5e4,e);t+=dp.apply(void 0,this._value.splice(0,i)),e-=i}return this._value.shift(),t},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var s=this._value[i];if(-1===s||void 0===s||s===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(10===s)return this._value.splice(0,i),Df;if(92===s){var r=this._value[i+1];-1!==r&&void 0!==r&&(10===r?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):vf(s,r)&&(t+=this.consumeStringSlice(i),t+=dp(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=4,i=this.peekCodePoint(0);for(43!==i&&45!==i||e.push(this.consumeCodePoint());Af(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var s=this.peekCodePoint(1);if(46===i&&Af(s))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Af(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),s=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((69===i||101===i)&&((43===s||45===s)&&Af(r)||Af(s)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=8;Af(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[_f(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],s=this.peekCodePoint(0),r=this.peekCodePoint(1),n=this.peekCodePoint(2);return gf(s,r,n)?{type:15,number:t,flags:i,unit:this.consumeName()}:37===s?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(cf(e)){for(var t=dp(e);cf(this.peekCodePoint(0))&&t.length<6;)t+=dp(this.consumeCodePoint());hf(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||function(e){return e>=55296&&e<=57343}(i)||i>1114111?65533:i}return-1===e?65533:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(pf(t))e+=dp(t);else{if(!vf(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=dp(this.consumeEscapedCodePoint())}}},e}(),Hf=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new Vf;return i.write(t),new e(i.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(32===i.type||Zf(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?Qf:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),jf=function(e){return 15===e.type},Gf=function(e){return 17===e.type},zf=function(e){return 20===e.type},Wf=function(e){return 0===e.type},Kf=function(e,t){return zf(e)&&e.value===t},Xf=function(e){return 31!==e.type},Jf=function(e){return 31!==e.type&&4!==e.type},Yf=function(e){var t=[],i=[];return e.forEach((function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)})),i.length&&t.push(i),t},Zf=function(e,t){return 11===t&&12===e.type||(28===t&&29===e.type||2===t&&3===e.type)},qf=function(e){return 17===e.type||15===e.type},$f=function(e){return 16===e.type||qf(e)},ev=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},tv={type:17,number:0,flags:4},iv={type:16,number:50,flags:4},sv={type:16,number:100,flags:4},rv=function(e,t,i){var s=e[0],r=e[1];return[nv(s,t),nv(void 0!==r?r:s,i)]},nv=function(e,t){if(16===e.type)return e.number/100*t;if(jf(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},ov=function(e,t){if(15===t.type)switch(t.unit){case"deg":return Math.PI*t.number/180;case"grad":return Math.PI/200*t.number;case"rad":return t.number;case"turn":return 2*Math.PI*t.number}throw new Error("Unsupported angle type")},av=function(e){return 15===e.type&&("deg"===e.unit||"grad"===e.unit||"rad"===e.unit||"turn"===e.unit)},lv=function(e){switch(e.filter(zf).map((function(e){return e.value})).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[tv,tv];case"to top":case"bottom":return uv(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[tv,sv];case"to right":case"left":return uv(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[sv,sv];case"to bottom":case"top":return uv(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[sv,tv];case"to left":case"right":return uv(270)}return 0},uv=function(e){return Math.PI*e/180},Av=function(e,t){if(18===t.type){var i=mv[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var s=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);return dv(parseInt(s+s,16),parseInt(r+r,16),parseInt(n+n,16),1)}if(4===t.value.length){s=t.value.substring(0,1),r=t.value.substring(1,2),n=t.value.substring(2,3);var o=t.value.substring(3,4);return dv(parseInt(s+s,16),parseInt(r+r,16),parseInt(n+n,16),parseInt(o+o,16)/255)}if(6===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6);return dv(parseInt(s,16),parseInt(r,16),parseInt(n,16),1)}if(8===t.value.length){s=t.value.substring(0,2),r=t.value.substring(2,4),n=t.value.substring(4,6),o=t.value.substring(6,8);return dv(parseInt(s,16),parseInt(r,16),parseInt(n,16),parseInt(o,16)/255)}}if(20===t.type){var a=yv[t.value.toUpperCase()];if(void 0!==a)return a}return yv.TRANSPARENT},cv=function(e){return 0==(255&e)},hv=function(e){var t=255&e,i=255&e>>8,s=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+s+","+i+","+t/255+")":"rgb("+r+","+s+","+i+")"},dv=function(e,t,i,s){return(e<<24|t<<16|i<<8|Math.round(255*s)<<0)>>>0},pv=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},fv=function(e,t){var i=t.filter(Jf);if(3===i.length){var s=i.map(pv),r=s[0],n=s[1],o=s[2];return dv(r,n,o,1)}if(4===i.length){var a=i.map(pv),l=(r=a[0],n=a[1],o=a[2],a[3]);return dv(r,n,o,l)}return 0};function vv(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var gv=function(e,t){var i=t.filter(Jf),s=i[0],r=i[1],n=i[2],o=i[3],a=(17===s.type?uv(s.number):ov(e,s))/(2*Math.PI),l=$f(r)?r.number/100:0,u=$f(n)?n.number/100:0,A=void 0!==o&&$f(o)?nv(o,1):1;if(0===l)return dv(255*u,255*u,255*u,1);var c=u<=.5?u*(l+1):u+l-u*l,h=2*u-c,d=vv(h,c,a+1/3),p=vv(h,c,a),f=vv(h,c,a-1/3);return dv(255*d,255*p,255*f,A)},mv={hsl:gv,hsla:gv,rgb:fv,rgba:fv},_v=function(e,t){return Av(e,Hf.create(t).parseComponentValue())},yv={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},bv={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(zf(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Bv={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},wv=function(e,t){var i=Av(e,t[0]),s=t[1];return s&&$f(s)?{color:i,stop:s}:{color:i,stop:null}},xv=function(e,t){var i=e[0],s=e[e.length-1];null===i.stop&&(i.stop=tv),null===s.stop&&(s.stop=sv);for(var r=[],n=0,o=0;on?r.push(l):r.push(n),n=l}else r.push(null)}var u=null;for(o=0;oe.optimumDistance)?{optimumCorner:t,optimumDistance:a}:e}),{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},Fv=function(e,t){var i=uv(180),s=[];return Yf(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&-1!==["top","left","right","bottom"].indexOf(n.value))return void(i=lv(t));if(av(n))return void(i=(ov(e,n)+uv(270))%uv(360))}var o=wv(e,t);s.push(o)})),{angle:i,stops:s,type:1}},Ev=function(e,t){var i=0,s=3,r=[],n=[];return Yf(t).forEach((function(t,o){var a=!0;if(0===o?a=t.reduce((function(e,t){if(zf(t))switch(t.value){case"center":return n.push(iv),!1;case"top":case"left":return n.push(tv),!1;case"right":case"bottom":return n.push(sv),!1}else if($f(t)||qf(t))return n.push(t),!1;return e}),a):1===o&&(a=t.reduce((function(e,t){if(zf(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"contain":case"closest-side":return s=0,!1;case"farthest-side":return s=1,!1;case"closest-corner":return s=2,!1;case"cover":case"farthest-corner":return s=3,!1}else if(qf(t)||$f(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)),a){var l=wv(e,t);r.push(l)}})),{size:s,shape:i,stops:r,position:n,type:2}},kv=function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var s=Dv[t.name];if(void 0===s)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return s(e,t.values)}throw new Error("Unsupported image type "+t.type)};var Iv,Dv={"linear-gradient":function(e,t){var i=uv(180),s=[];return Yf(t).forEach((function(t,r){if(0===r){var n=t[0];if(20===n.type&&"to"===n.value)return void(i=lv(t));if(av(n))return void(i=ov(e,n))}var o=wv(e,t);s.push(o)})),{angle:i,stops:s,type:1}},"-moz-linear-gradient":Fv,"-ms-linear-gradient":Fv,"-o-linear-gradient":Fv,"-webkit-linear-gradient":Fv,"radial-gradient":function(e,t){var i=0,s=3,r=[],n=[];return Yf(t).forEach((function(t,o){var a=!0;if(0===o){var l=!1;a=t.reduce((function(e,t){if(l)if(zf(t))switch(t.value){case"center":return n.push(iv),e;case"top":case"left":return n.push(tv),e;case"right":case"bottom":return n.push(sv),e}else($f(t)||qf(t))&&n.push(t);else if(zf(t))switch(t.value){case"circle":return i=0,!1;case"ellipse":return i=1,!1;case"at":return l=!0,!1;case"closest-side":return s=0,!1;case"cover":case"farthest-side":return s=1,!1;case"contain":case"closest-corner":return s=2,!1;case"farthest-corner":return s=3,!1}else if(qf(t)||$f(t))return Array.isArray(s)||(s=[]),s.push(t),!1;return e}),a)}if(a){var u=wv(e,t);r.push(u)}})),{size:s,shape:i,stops:r,position:n,type:2}},"-moz-radial-gradient":Ev,"-ms-radial-gradient":Ev,"-o-radial-gradient":Ev,"-webkit-radial-gradient":Ev,"-webkit-gradient":function(e,t){var i=uv(180),s=[],r=1;return Yf(t).forEach((function(t,i){var n=t[0];if(0===i){if(zf(n)&&"linear"===n.value)return void(r=1);if(zf(n)&&"radial"===n.value)return void(r=2)}if(18===n.type)if("from"===n.name){var o=Av(e,n.values[0]);s.push({stop:tv,color:o})}else if("to"===n.name){o=Av(e,n.values[0]);s.push({stop:sv,color:o})}else if("color-stop"===n.name){var a=n.values.filter(Jf);if(2===a.length){o=Av(e,a[1]);var l=a[0];Gf(l)&&s.push({stop:{type:16,number:100*l.number,flags:l.flags},color:o})}}})),1===r?{angle:(i+uv(180))%uv(360),stops:s,type:r}:{size:3,shape:0,stops:s,position:[],type:r}}},Sv={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter((function(e){return Jf(e)&&function(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Dv[e.name])}(e)})).map((function(t){return kv(e,t)}))}},Tv={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map((function(e){if(zf(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0}))}},Rv={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return Yf(t).map((function(e){return e.filter($f)})).map(ev)}},Lv={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return Yf(t).map((function(e){return e.filter(zf).map((function(e){return e.value})).join(" ")})).map(Uv)}},Uv=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Iv||(Iv={}));var Ov,Nv={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return Yf(t).map((function(e){return e.filter(Qv)}))}},Qv=function(e){return zf(e)||$f(e)},Vv=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},Hv=Vv("top"),jv=Vv("right"),Gv=Vv("bottom"),zv=Vv("left"),Wv=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return ev(t.filter($f))}}},Kv=Wv("top-left"),Xv=Wv("top-right"),Jv=Wv("bottom-right"),Yv=Wv("bottom-left"),Zv=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},qv=Zv("top"),$v=Zv("right"),eg=Zv("bottom"),tg=Zv("left"),ig=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return jf(t)?t.number:0}}},sg=ig("top"),rg=ig("right"),ng=ig("bottom"),og=ig("left"),ag={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},lg={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},ug={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(zf).reduce((function(e,t){return e|Ag(t.value)}),0)}},Ag=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},cg={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},hg={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}(Ov||(Ov={}));var dg,pg={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?Ov.STRICT:Ov.NORMAL}},fg={name:"line-height",initialValue:"normal",prefix:!1,type:4},vg=function(e,t){return zf(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:$f(e)?nv(e,t):t},gg={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:kv(e,t)}},mg={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},_g={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},yg=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},bg=yg("top"),Bg=yg("right"),wg=yg("bottom"),xg=yg("left"),Pg={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(zf).map((function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}}))}},Cg={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},Mg=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Fg=Mg("top"),Eg=Mg("right"),kg=Mg("bottom"),Ig=Mg("left"),Dg={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Sg={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Tg={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Kf(t[0],"none")?[]:Yf(t).map((function(t){for(var i={color:yv.TRANSPARENT,offsetX:tv,offsetY:tv,blur:tv},s=0,r=0;r1?1:0],this.overflowWrap=dm(e,Cg,t.overflowWrap),this.paddingTop=dm(e,Fg,t.paddingTop),this.paddingRight=dm(e,Eg,t.paddingRight),this.paddingBottom=dm(e,kg,t.paddingBottom),this.paddingLeft=dm(e,Ig,t.paddingLeft),this.paintOrder=dm(e,am,t.paintOrder),this.position=dm(e,Sg,t.position),this.textAlign=dm(e,Dg,t.textAlign),this.textDecorationColor=dm(e,Wg,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=dm(e,Kg,null!==(s=t.textDecorationLine)&&void 0!==s?s:t.textDecoration),this.textShadow=dm(e,Tg,t.textShadow),this.textTransform=dm(e,Rg,t.textTransform),this.transform=dm(e,Lg,t.transform),this.transformOrigin=dm(e,Qg,t.transformOrigin),this.visibility=dm(e,Vg,t.visibility),this.webkitTextStrokeColor=dm(e,lm,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=dm(e,um,t.webkitTextStrokeWidth),this.wordBreak=dm(e,Hg,t.wordBreak),this.zIndex=dm(e,jg,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return cv(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return $g(this.display,4)||$g(this.display,33554432)||$g(this.display,268435456)||$g(this.display,536870912)||$g(this.display,67108864)||$g(this.display,134217728)},e}(),cm=function(e,t){this.content=dm(e,em,t.content),this.quotes=dm(e,rm,t.quotes)},hm=function(e,t){this.counterIncrement=dm(e,tm,t.counterIncrement),this.counterReset=dm(e,im,t.counterReset)},dm=function(e,t,i){var s=new Vf,r=null!=i?i.toString():t.initialValue;s.write(r);var n=new Hf(s.read());switch(t.type){case 2:var o=n.parseComponentValue();return t.parse(e,zf(o)?o.value:t.initialValue);case 0:return t.parse(e,n.parseComponentValue());case 1:return t.parse(e,n.parseComponentValues());case 4:return n.parseComponentValue();case 3:switch(t.format){case"angle":return ov(e,n.parseComponentValue());case"color":return Av(e,n.parseComponentValue());case"image":return kv(e,n.parseComponentValue());case"length":var a=n.parseComponentValue();return qf(a)?a:tv;case"length-percentage":var l=n.parseComponentValue();return $f(l)?l:tv;case"time":return Gg(e,n.parseComponentValue())}}},pm=function(e,t){var i=function(e){switch(e.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(e);return 1===i||t===i},fm=function(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,pm(t,3),this.styles=new Am(e,window.getComputedStyle(t,null)),f_(t)&&(this.styles.animationDuration.some((function(e){return e>0}))&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=cp(this.context,t),pm(t,4)&&(this.flags|=16)},vm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gm="undefined"==typeof Uint8Array?[]:new Uint8Array(256),mm=0;mm=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t=this.index[2048+(e-55296>>5)])<<2)+(31&e),this.data[t];if(e>11),t=this.index[t],t+=e>>5&63,t=((t=this.index[t])<<2)+(31&e),this.data[t];if(e<=1114111)return this.data[this.highValueIndex]}return this.errorValue},e}(),bm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Bm="undefined"==typeof Uint8Array?[]:new Uint8Array(256),wm=0;wm>10),o%1024+56320)),(r+1===i||s.length>16384)&&(n+=String.fromCharCode.apply(String,s),s.length=0)}return n},km=function(e,t){var i,s,r,n=function(e){var t,i,s,r,n,o=.75*e.length,a=e.length,l=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);var u="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(o):new Array(o),A=Array.isArray(u)?u:new Uint8Array(u);for(t=0;t>4,A[l++]=(15&s)<<4|r>>2,A[l++]=(3&r)<<6|63&n;return u}(e),o=Array.isArray(n)?function(e){for(var t=e.length,i=[],s=0;s=55296&&r<=56319&&i=i)return{done:!0,value:null};for(var e="×";so.x||r.y>o.y;return o=r,0===t||a}));return e.body.removeChild(t),a}(document);return Object.defineProperty(Um,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=function(e){var t=new Image,i=e.createElement("canvas"),s=i.getContext("2d");if(!s)return!1;t.src="data:image/svg+xml,";try{s.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0}(document);return Object.defineProperty(Um,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?function(e){var t=e.createElement("canvas"),i=100;t.width=i,t.height=i;var s=t.getContext("2d");if(!s)return Promise.reject(!1);s.fillStyle="rgb(0, 255, 0)",s.fillRect(0,0,i,i);var r=new Image,n=t.toDataURL();r.src=n;var o=Rm(i,i,0,0,r);return s.fillStyle="red",s.fillRect(0,0,i,i),Lm(o).then((function(t){s.drawImage(t,0,0);var r=s.getImageData(0,0,i,i).data;s.fillStyle="red",s.fillRect(0,0,i,i);var o=e.createElement("div");return o.style.backgroundImage="url("+n+")",o.style.height="100px",Tm(r)?Lm(Rm(i,i,0,0,o)):Promise.reject(!1)})).then((function(e){return s.drawImage(e,0,0),Tm(s.getImageData(0,0,i,i).data)})).catch((function(){return!1}))}(document):Promise.resolve(!1);return Object.defineProperty(Um,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=void 0!==(new Image).crossOrigin;return Object.defineProperty(Um,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(Um,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Um,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(Um,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Om=function(e,t){this.text=e,this.bounds=t},Nm=function(e,t){var i=t.ownerDocument;if(i){var s=i.createElement("html2canvaswrapper");s.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(s,t);var n=cp(e,s);return s.firstChild&&r.replaceChild(s.firstChild,s),n}}return Ap.EMPTY},Qm=function(e,t,i){var s=e.ownerDocument;if(!s)throw new Error("Node has no owner document");var r=s.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},Vm=function(e){if(Um.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map((function(e){return e.segment}))}return function(e){for(var t,i=Sm(e),s=[];!(t=i.next()).done;)t.value&&s.push(t.value.slice());return s}(e)},Hm=function(e,t){return 0!==t.letterSpacing?Vm(e):function(e,t){if(Um.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map((function(e){return e.segment}))}return Gm(e,t)}(e,t)},jm=[32,160,4961,65792,65793,4153,4241],Gm=function(e,t){for(var i,s=function(e,t){var i=hp(e),s=lf(i,t),r=s[0],n=s[1],o=s[2],a=i.length,l=0,u=0;return{next:function(){if(u>=a)return{done:!0,value:null};for(var e="×";u0)if(Um.SUPPORT_RANGE_BOUNDS){var r=Qm(s,o,t.length).getClientRects();if(r.length>1){var a=Vm(t),l=0;a.forEach((function(t){n.push(new Om(t,Ap.fromDOMRectList(e,Qm(s,l+o,t.length).getClientRects()))),l+=t.length}))}else n.push(new Om(t,Ap.fromDOMRectList(e,r)))}else{var u=s.splitText(t.length);n.push(new Om(t,Nm(e,s))),s=u}else Um.SUPPORT_RANGE_BOUNDS||(s=s.splitText(t.length));o+=t.length})),n}(e,this.text,i,t)},Wm=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Km,Xm);case 2:return e.toUpperCase();default:return e}},Km=/(^|\s|:|-|\(|\))([a-z])/g,Xm=function(e,t,i){return e.length>0?t+i.toUpperCase():e},Jm=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.src=i.currentSrc||i.src,s.intrinsicWidth=i.naturalWidth,s.intrinsicHeight=i.naturalHeight,s.context.cache.addImage(s.src),s}return np(t,e),t}(fm),Ym=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.canvas=i,s.intrinsicWidth=i.width,s.intrinsicHeight=i.height,s}return np(t,e),t}(fm),Zm=function(e){function t(t,i){var s=e.call(this,t,i)||this,r=new XMLSerializer,n=cp(t,i);return i.setAttribute("width",n.width+"px"),i.setAttribute("height",n.height+"px"),s.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),s.intrinsicWidth=i.width.baseVal.value,s.intrinsicHeight=i.height.baseVal.value,s.context.cache.addImage(s.svg),s}return np(t,e),t}(fm),qm=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.value=i.value,s}return np(t,e),t}(fm),$m=function(e){function t(t,i){var s=e.call(this,t,i)||this;return s.start=i.start,s.reversed="boolean"==typeof i.reversed&&!0===i.reversed,s}return np(t,e),t}(fm),e_=[{type:15,flags:0,unit:"px",number:3}],t_=[{type:16,flags:0,number:50}],i_="password",s_=function(e){function t(t,i){var s,r=e.call(this,t,i)||this;switch(r.type=i.type.toLowerCase(),r.checked=i.checked,r.value=function(e){var t=e.type===i_?new Array(e.value.length+1).join("•"):e.value;return 0===t.length?e.placeholder||"":t}(i),"checkbox"!==r.type&&"radio"!==r.type||(r.styles.backgroundColor=3739148031,r.styles.borderTopColor=r.styles.borderRightColor=r.styles.borderBottomColor=r.styles.borderLeftColor=2779096575,r.styles.borderTopWidth=r.styles.borderRightWidth=r.styles.borderBottomWidth=r.styles.borderLeftWidth=1,r.styles.borderTopStyle=r.styles.borderRightStyle=r.styles.borderBottomStyle=r.styles.borderLeftStyle=1,r.styles.backgroundClip=[0],r.styles.backgroundOrigin=[0],r.bounds=(s=r.bounds).width>s.height?new Ap(s.left+(s.width-s.height)/2,s.top,s.height,s.height):s.width0)s.textNodes.push(new zm(t,n,s.styles));else if(p_(n))if(E_(n)&&n.assignedNodes)n.assignedNodes().forEach((function(i){return e(t,i,s,r)}));else{var a=u_(t,n);a.styles.isVisible()&&(c_(n,a,r)?a.flags|=4:h_(a.styles)&&(a.flags|=2),-1!==a_.indexOf(n.tagName)&&(a.flags|=8),s.elements.push(a),n.slot,n.shadowRoot?e(t,n.shadowRoot,a,r):M_(n)||y_(n)||F_(n)||e(t,n,a,r))}},u_=function(e,t){return x_(t)?new Jm(e,t):B_(t)?new Ym(e,t):y_(t)?new Zm(e,t):g_(t)?new qm(e,t):m_(t)?new $m(e,t):__(t)?new s_(e,t):F_(t)?new r_(e,t):M_(t)?new n_(e,t):P_(t)?new o_(e,t):new fm(e,t)},A_=function(e,t){var i=u_(e,t);return i.flags|=4,l_(e,t,i,i),i},c_=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||b_(e)&&i.styles.isTransparent()},h_=function(e){return e.isPositioned()||e.isFloating()},d_=function(e){return e.nodeType===Node.TEXT_NODE},p_=function(e){return e.nodeType===Node.ELEMENT_NODE},f_=function(e){return p_(e)&&void 0!==e.style&&!v_(e)},v_=function(e){return"object"===w(e.className)},g_=function(e){return"LI"===e.tagName},m_=function(e){return"OL"===e.tagName},__=function(e){return"INPUT"===e.tagName},y_=function(e){return"svg"===e.tagName},b_=function(e){return"BODY"===e.tagName},B_=function(e){return"CANVAS"===e.tagName},w_=function(e){return"VIDEO"===e.tagName},x_=function(e){return"IMG"===e.tagName},P_=function(e){return"IFRAME"===e.tagName},C_=function(e){return"STYLE"===e.tagName},M_=function(e){return"TEXTAREA"===e.tagName},F_=function(e){return"SELECT"===e.tagName},E_=function(e){return"SLOT"===e.tagName},k_=function(e){return e.tagName.indexOf("-")>0},I_=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach((function(e){return t.counters[e].pop()}))},e.prototype.parse=function(e){var t=this,i=e.counterIncrement,s=e.counterReset,r=!0;null!==i&&i.forEach((function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)}));var n=[];return r&&s.forEach((function(e){var i=t.counters[e.counter];n.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)})),n},e}(),D_={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},S_={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},T_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},R_={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},L_=function(e,t,i,s,r,n){return ei?V_(e,r,n.length>0):s.integers.reduce((function(t,i,r){for(;e>=i;)e-=i,t+=s.values[r];return t}),"")+n},U_=function(e,t,i,s){var r="";do{i||e--,r=s(e)+r,e/=t}while(e*t>=t);return r},O_=function(e,t,i,s,r){var n=i-t+1;return(e<0?"-":"")+(U_(Math.abs(e),n,s,(function(e){return dp(Math.floor(e%n)+t)}))+r)},N_=function(e,t,i){void 0===i&&(i=". ");var s=t.length;return U_(Math.abs(e),s,!1,(function(e){return t[Math.floor(e%s)]}))+i},Q_=function(e,t,i,s,r,n){if(e<-9999||e>9999)return V_(e,4,r.length>0);var o=Math.abs(e),a=r;if(0===o)return t[0]+a;for(var l=0;o>0&&l<=4;l++){var u=o%10;0===u&&$g(n,1)&&""!==a?a=t[u]+a:u>1||1===u&&0===l||1===u&&1===l&&$g(n,2)||1===u&&1===l&&$g(n,4)&&e>100||1===u&&l>1&&$g(n,8)?a=t[u]+(l>0?i[l-1]:"")+a:1===u&&l>0&&(a=i[l-1]+a),o=Math.floor(o/10)}return(e<0?s:"")+a},V_=function(e,t,i){var s=i?". ":"",r=i?"、":"",n=i?", ":"",o=i?" ":"";switch(t){case 0:return"•"+o;case 1:return"◦"+o;case 2:return"◾"+o;case 5:var a=O_(e,48,57,!0,s);return a.length<4?"0"+a:a;case 4:return N_(e,"〇一二三四五六七八九",r);case 6:return L_(e,1,3999,D_,3,s).toLowerCase();case 7:return L_(e,1,3999,D_,3,s);case 8:return O_(e,945,969,!1,s);case 9:return O_(e,97,122,!1,s);case 10:return O_(e,65,90,!1,s);case 11:return O_(e,1632,1641,!0,s);case 12:case 49:return L_(e,1,9999,S_,3,s);case 35:return L_(e,1,9999,S_,3,s).toLowerCase();case 13:return O_(e,2534,2543,!0,s);case 14:case 30:return O_(e,6112,6121,!0,s);case 15:return N_(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return N_(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return Q_(e,"零一二三四五六七八九","十百千萬","負",r,14);case 47:return Q_(e,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",r,15);case 42:return Q_(e,"零一二三四五六七八九","十百千萬","负",r,14);case 41:return Q_(e,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",r,15);case 26:return Q_(e,"〇一二三四五六七八九","十百千万","マイナス",r,0);case 25:return Q_(e,"零壱弐参四伍六七八九","拾百千万","マイナス",r,7);case 31:return Q_(e,"영일이삼사오육칠팔구","십백천만","마이너스",n,7);case 33:return Q_(e,"零一二三四五六七八九","十百千萬","마이너스",n,0);case 32:return Q_(e,"零壹貳參四五六七八九","拾百千","마이너스",n,7);case 18:return O_(e,2406,2415,!0,s);case 20:return L_(e,1,19999,R_,3,s);case 21:return O_(e,2790,2799,!0,s);case 22:return O_(e,2662,2671,!0,s);case 22:return L_(e,1,10999,T_,3,s);case 23:return N_(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return N_(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return O_(e,3302,3311,!0,s);case 28:return N_(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return N_(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return O_(e,3792,3801,!0,s);case 37:return O_(e,6160,6169,!0,s);case 38:return O_(e,4160,4169,!0,s);case 39:return O_(e,2918,2927,!0,s);case 40:return O_(e,1776,1785,!0,s);case 43:return O_(e,3046,3055,!0,s);case 44:return O_(e,3174,3183,!0,s);case 45:return O_(e,3664,3673,!0,s);case 46:return O_(e,3872,3881,!0,s);default:return O_(e,48,57,!0,s)}},H_=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new I_,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var i=this,s=G_(e,t);if(!s.contentWindow)return Promise.reject("Unable to find iframe window");var r=e.defaultView.pageXOffset,n=e.defaultView.pageYOffset,o=s.contentWindow,a=o.document,l=K_(s).then((function(){return ap(i,void 0,void 0,(function(){var e,i;return lp(this,(function(r){switch(r.label){case 0:return this.scrolledElements.forEach(q_),o&&(o.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||o.scrollY===t.top&&o.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(o.scrollX-t.left,o.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(i=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:a.fonts&&a.fonts.ready?[4,a.fonts.ready]:[3,2];case 1:r.sent(),r.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,W_(a)]:[3,4];case 3:r.sent(),r.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then((function(){return e(a,i)})).then((function(){return s}))]:[2,s]}}))}))}));return a.open(),a.write(Y_(document.doctype)+""),Z_(this.referenceElement.ownerDocument,r,n),a.replaceChild(a.adoptNode(this.documentElement),a.documentElement),a.close(),l},e.prototype.createElementClone=function(e){if(pm(e,2),B_(e))return this.createCanvasClone(e);if(w_(e))return this.createVideoClone(e);if(C_(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return x_(t)&&(x_(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),k_(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return J_(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce((function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e}),""),s=e.cloneNode(!1);return s.textContent=i,s}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var s=e.cloneNode(!1);try{s.width=e.width,s.height=e.height;var r=e.getContext("2d"),n=s.getContext("2d");if(n)if(!this.options.allowTaint&&r)n.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var o=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(o){var a=o.getContextAttributes();!1===(null==a?void 0:a.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}n.drawImage(e,0,0)}return s}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return s},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var s=e.ownerDocument.createElement("canvas");return s.width=e.offsetWidth,s.height=e.offsetHeight,s},e.prototype.appendChildNode=function(e,t,i){p_(t)&&(function(e){return"SCRIPT"===e.tagName}(t)||t.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&p_(t)&&C_(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var s=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(p_(r)&&E_(r)&&"function"==typeof r.assignedNodes){var n=r.assignedNodes();n.length&&n.forEach((function(e){return s.appendChildNode(t,e,i)}))}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(d_(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&p_(e)&&(f_(e)||v_(e))){var s=this.createElementClone(e);s.style.transitionProperty="none";var r=i.getComputedStyle(e),n=i.getComputedStyle(e,":before"),o=i.getComputedStyle(e,":after");this.referenceElement===e&&f_(s)&&(this.clonedReferenceElement=s),b_(s)&&ty(s);var a=this.counters.parse(new hm(this.context,r)),l=this.resolvePseudoContent(e,s,n,xm.BEFORE);k_(e)&&(t=!0),w_(e)||this.cloneChildNodes(e,s,t),l&&s.insertBefore(l,s.firstChild);var u=this.resolvePseudoContent(e,s,o,xm.AFTER);return u&&s.appendChild(u),this.counters.pop(a),(r&&(this.options.copyStyles||v_(e))&&!P_(e)||t)&&J_(r,s),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([s,e.scrollLeft,e.scrollTop]),(M_(e)||F_(e))&&(M_(s)||F_(s))&&(s.value=e.value),s}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,s){var r=this;if(i){var n=i.content,o=t.ownerDocument;if(o&&n&&"none"!==n&&"-moz-alt-content"!==n&&"none"!==i.display){this.counters.parse(new hm(this.context,i));var a=new cm(this.context,i),l=o.createElement("html2canvaspseudoelement");J_(i,l),a.content.forEach((function(t){if(0===t.type)l.appendChild(o.createTextNode(t.value));else if(22===t.type){var i=o.createElement("img");i.src=t.value,i.style.opacity="1",l.appendChild(i)}else if(18===t.type){if("attr"===t.name){var s=t.values.filter(zf);s.length&&l.appendChild(o.createTextNode(e.getAttribute(s[0].value)||""))}else if("counter"===t.name){var n=t.values.filter(Jf),u=n[0],A=n[1];if(u&&zf(u)){var c=r.counters.getCounterValue(u.value),h=A&&zf(A)?_g.parse(r.context,A.value):3;l.appendChild(o.createTextNode(V_(c,h,!1)))}}else if("counters"===t.name){var d=t.values.filter(Jf),p=(u=d[0],d[1]);A=d[2];if(u&&zf(u)){var f=r.counters.getCounterValues(u.value),v=A&&zf(A)?_g.parse(r.context,A.value):3,g=p&&0===p.type?p.value:"",m=f.map((function(e){return V_(e,v,!1)})).join(g);l.appendChild(o.createTextNode(m))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(o.createTextNode(nm(a.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(o.createTextNode(nm(a.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(o.createTextNode(t.value))}})),l.className=$_+" "+ey;var u=s===xm.BEFORE?" "+$_:" "+ey;return v_(t)?t.className.baseValue+=u:t.className+=u,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(xm||(xm={}));var j_,G_=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute("data-html2canvas-ignore","true"),e.body.appendChild(i),i},z_=function(e){return new Promise((function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()}))},W_=function(e){return Promise.all([].slice.call(e.images,0).map(z_))},K_=function(e){return new Promise((function(t,i){var s=e.contentWindow;if(!s)return i("No window assigned for iframe");var r=s.document;s.onload=e.onload=function(){s.onload=e.onload=null;var i=setInterval((function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))}),50)}}))},X_=["all","d","content"],J_=function(e,t){for(var i=e.length-1;i>=0;i--){var s=e.item(i);-1===X_.indexOf(s)&&t.style.setProperty(s,e.getPropertyValue(s))}return t},Y_=function(e){var t="";return e&&(t+=""),t},Z_=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},q_=function(e){var t=e[0],i=e[1],s=e[2];t.scrollLeft=i,t.scrollTop=s},$_="___html2canvas___pseudoelement_before",ey="___html2canvas___pseudoelement_after",ty=function(e){iy(e,"."+$_+':before{\n content: "" !important;\n display: none !important;\n}\n .'+ey+':after{\n content: "" !important;\n display: none !important;\n}')},iy=function(e,t){var i=e.ownerDocument;if(i){var s=i.createElement("style");s.textContent=t,e.appendChild(s)}},sy=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),ry=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:cy(e)||ly(e)?((this._cache[e]=this.loadImage(e)).catch((function(){})),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return ap(this,void 0,void 0,(function(){var t,i,s,r,n=this;return lp(this,(function(o){switch(o.label){case 0:return t=sy.isSameOrigin(e),i=!uy(e)&&!0===this._options.useCORS&&Um.SUPPORT_CORS_IMAGES&&!t,s=!uy(e)&&!t&&!cy(e)&&"string"==typeof this._options.proxy&&Um.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||uy(e)||cy(e)||s||i?(r=e,s?[4,this.proxy(r)]:[3,2]):[2];case 1:r=o.sent(),o.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise((function(e,t){var s=new Image;s.onload=function(){return e(s)},s.onerror=t,(Ay(r)||i)&&(s.crossOrigin="anonymous"),s.src=r,!0===s.complete&&setTimeout((function(){return e(s)}),500),n._options.imageTimeout>0&&setTimeout((function(){return t("Timed out ("+n._options.imageTimeout+"ms) loading image")}),n._options.imageTimeout)}))];case 3:return[2,o.sent()]}}))}))},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var s=e.substring(0,256);return new Promise((function(r,n){var o=Um.SUPPORT_RESPONSE_TYPE?"blob":"text",a=new XMLHttpRequest;a.onload=function(){if(200===a.status)if("text"===o)r(a.response);else{var e=new FileReader;e.addEventListener("load",(function(){return r(e.result)}),!1),e.addEventListener("error",(function(e){return n(e)}),!1),e.readAsDataURL(a.response)}else n("Failed to proxy resource "+s+" with status code "+a.status)},a.onerror=n;var l=i.indexOf("?")>-1?"&":"?";if(a.open("GET",""+i+l+"url="+encodeURIComponent(e)+"&responseType="+o),"text"!==o&&a instanceof XMLHttpRequest&&(a.responseType=o),t._options.imageTimeout){var u=t._options.imageTimeout;a.timeout=u,a.ontimeout=function(){return n("Timed out ("+u+"ms) proxying "+s)}}a.send()}))},e}(),ny=/^data:image\/svg\+xml/i,oy=/^data:image\/.*;base64,/i,ay=/^data:image\/.*/i,ly=function(e){return Um.SUPPORT_SVG_DRAWING||!hy(e)},uy=function(e){return ay.test(e)},Ay=function(e){return oy.test(e)},cy=function(e){return"blob"===e.substr(0,4)},hy=function(e){return"svg"===e.substr(-3).toLowerCase()||ny.test(e)},dy=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),py=function(e,t,i){return new dy(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},fy=function(){function e(e,t,i,s){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=s}return e.prototype.subdivide=function(t,i){var s=py(this.start,this.startControl,t),r=py(this.startControl,this.endControl,t),n=py(this.endControl,this.end,t),o=py(s,r,t),a=py(r,n,t),l=py(o,a,t);return i?new e(this.start,s,o,l):new e(l,a,n,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),vy=function(e){return 1===e.type},gy=function(e){var t=e.styles,i=e.bounds,s=rv(t.borderTopLeftRadius,i.width,i.height),r=s[0],n=s[1],o=rv(t.borderTopRightRadius,i.width,i.height),a=o[0],l=o[1],u=rv(t.borderBottomRightRadius,i.width,i.height),A=u[0],c=u[1],h=rv(t.borderBottomLeftRadius,i.width,i.height),d=h[0],p=h[1],f=[];f.push((r+a)/i.width),f.push((d+A)/i.width),f.push((n+p)/i.height),f.push((l+c)/i.height);var v=Math.max.apply(Math,f);v>1&&(r/=v,n/=v,a/=v,l/=v,A/=v,c/=v,d/=v,p/=v);var g=i.width-a,m=i.height-c,_=i.width-A,y=i.height-p,b=t.borderTopWidth,B=t.borderRightWidth,w=t.borderBottomWidth,x=t.borderLeftWidth,P=nv(t.paddingTop,e.bounds.width),C=nv(t.paddingRight,e.bounds.width),M=nv(t.paddingBottom,e.bounds.width),F=nv(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||n>0?my(i.left+x/3,i.top+b/3,r-x/3,n-b/3,j_.TOP_LEFT):new dy(i.left+x/3,i.top+b/3),this.topRightBorderDoubleOuterBox=r>0||n>0?my(i.left+g,i.top+b/3,a-B/3,l-b/3,j_.TOP_RIGHT):new dy(i.left+i.width-B/3,i.top+b/3),this.bottomRightBorderDoubleOuterBox=A>0||c>0?my(i.left+_,i.top+m,A-B/3,c-w/3,j_.BOTTOM_RIGHT):new dy(i.left+i.width-B/3,i.top+i.height-w/3),this.bottomLeftBorderDoubleOuterBox=d>0||p>0?my(i.left+x/3,i.top+y,d-x/3,p-w/3,j_.BOTTOM_LEFT):new dy(i.left+x/3,i.top+i.height-w/3),this.topLeftBorderDoubleInnerBox=r>0||n>0?my(i.left+2*x/3,i.top+2*b/3,r-2*x/3,n-2*b/3,j_.TOP_LEFT):new dy(i.left+2*x/3,i.top+2*b/3),this.topRightBorderDoubleInnerBox=r>0||n>0?my(i.left+g,i.top+2*b/3,a-2*B/3,l-2*b/3,j_.TOP_RIGHT):new dy(i.left+i.width-2*B/3,i.top+2*b/3),this.bottomRightBorderDoubleInnerBox=A>0||c>0?my(i.left+_,i.top+m,A-2*B/3,c-2*w/3,j_.BOTTOM_RIGHT):new dy(i.left+i.width-2*B/3,i.top+i.height-2*w/3),this.bottomLeftBorderDoubleInnerBox=d>0||p>0?my(i.left+2*x/3,i.top+y,d-2*x/3,p-2*w/3,j_.BOTTOM_LEFT):new dy(i.left+2*x/3,i.top+i.height-2*w/3),this.topLeftBorderStroke=r>0||n>0?my(i.left+x/2,i.top+b/2,r-x/2,n-b/2,j_.TOP_LEFT):new dy(i.left+x/2,i.top+b/2),this.topRightBorderStroke=r>0||n>0?my(i.left+g,i.top+b/2,a-B/2,l-b/2,j_.TOP_RIGHT):new dy(i.left+i.width-B/2,i.top+b/2),this.bottomRightBorderStroke=A>0||c>0?my(i.left+_,i.top+m,A-B/2,c-w/2,j_.BOTTOM_RIGHT):new dy(i.left+i.width-B/2,i.top+i.height-w/2),this.bottomLeftBorderStroke=d>0||p>0?my(i.left+x/2,i.top+y,d-x/2,p-w/2,j_.BOTTOM_LEFT):new dy(i.left+x/2,i.top+i.height-w/2),this.topLeftBorderBox=r>0||n>0?my(i.left,i.top,r,n,j_.TOP_LEFT):new dy(i.left,i.top),this.topRightBorderBox=a>0||l>0?my(i.left+g,i.top,a,l,j_.TOP_RIGHT):new dy(i.left+i.width,i.top),this.bottomRightBorderBox=A>0||c>0?my(i.left+_,i.top+m,A,c,j_.BOTTOM_RIGHT):new dy(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=d>0||p>0?my(i.left,i.top+y,d,p,j_.BOTTOM_LEFT):new dy(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||n>0?my(i.left+x,i.top+b,Math.max(0,r-x),Math.max(0,n-b),j_.TOP_LEFT):new dy(i.left+x,i.top+b),this.topRightPaddingBox=a>0||l>0?my(i.left+Math.min(g,i.width-B),i.top+b,g>i.width+B?0:Math.max(0,a-B),Math.max(0,l-b),j_.TOP_RIGHT):new dy(i.left+i.width-B,i.top+b),this.bottomRightPaddingBox=A>0||c>0?my(i.left+Math.min(_,i.width-x),i.top+Math.min(m,i.height-w),Math.max(0,A-B),Math.max(0,c-w),j_.BOTTOM_RIGHT):new dy(i.left+i.width-B,i.top+i.height-w),this.bottomLeftPaddingBox=d>0||p>0?my(i.left+x,i.top+Math.min(y,i.height-w),Math.max(0,d-x),Math.max(0,p-w),j_.BOTTOM_LEFT):new dy(i.left+x,i.top+i.height-w),this.topLeftContentBox=r>0||n>0?my(i.left+x+F,i.top+b+P,Math.max(0,r-(x+F)),Math.max(0,n-(b+P)),j_.TOP_LEFT):new dy(i.left+x+F,i.top+b+P),this.topRightContentBox=a>0||l>0?my(i.left+Math.min(g,i.width+x+F),i.top+b+P,g>i.width+x+F?0:a-x+F,l-(b+P),j_.TOP_RIGHT):new dy(i.left+i.width-(B+C),i.top+b+P),this.bottomRightContentBox=A>0||c>0?my(i.left+Math.min(_,i.width-(x+F)),i.top+Math.min(m,i.height+b+P),Math.max(0,A-(B+C)),c-(w+M),j_.BOTTOM_RIGHT):new dy(i.left+i.width-(B+C),i.top+i.height-(w+M)),this.bottomLeftContentBox=d>0||p>0?my(i.left+x+F,i.top+y,Math.max(0,d-(x+F)),p-(w+M),j_.BOTTOM_LEFT):new dy(i.left+x+F,i.top+i.height-(w+M))};!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(j_||(j_={}));var my=function(e,t,i,s,r){var n=(Math.sqrt(2)-1)/3*4,o=i*n,a=s*n,l=e+i,u=t+s;switch(r){case j_.TOP_LEFT:return new fy(new dy(e,u),new dy(e,u-a),new dy(l-o,t),new dy(l,t));case j_.TOP_RIGHT:return new fy(new dy(e,t),new dy(e+o,t),new dy(l,u-a),new dy(l,u));case j_.BOTTOM_RIGHT:return new fy(new dy(l,t),new dy(l,t+a),new dy(e+o,u),new dy(e,u));case j_.BOTTOM_LEFT:default:return new fy(new dy(l,u),new dy(l-o,u),new dy(e,t+a),new dy(e,t))}},_y=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},yy=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},by=function(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6},By=function(e,t){this.path=e,this.target=t,this.type=1},wy=function(e){this.opacity=e,this.type=2,this.target=6},xy=function(e){return 1===e.type},Py=function(e,t){return e.length===t.length&&e.some((function(e,i){return e===t[i]}))},Cy=function(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},My=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new gy(this.container),this.container.styles.opacity<1&&this.effects.push(new wy(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,s=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new by(i,s,r))}if(0!==this.container.styles.overflowX){var n=_y(this.curves),o=yy(this.curves);Py(n,o)?this.effects.push(new By(n,6)):(this.effects.push(new By(n,2)),this.effects.push(new By(o,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,s=this.effects.slice(0);i;){var r=i.effects.filter((function(e){return!xy(e)}));if(t||0!==i.container.styles.position||!i.parent){if(s.unshift.apply(s,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var n=_y(i.curves),o=yy(i.curves);Py(n,o)||s.unshift(new By(o,6))}}else s.unshift.apply(s,r);i=i.parent}return s.filter((function(t){return $g(t.target,e)}))},e}(),Fy=function e(t,i,s,r){t.container.elements.forEach((function(n){var o=$g(n.flags,4),a=$g(n.flags,2),l=new My(n,t);$g(n.styles.display,2048)&&r.push(l);var u=$g(n.flags,8)?[]:r;if(o||a){var A=o||n.styles.isPositioned()?s:i,c=new Cy(l);if(n.styles.isPositioned()||n.styles.opacity<1||n.styles.isTransformed()){var h=n.styles.zIndex.order;if(h<0){var d=0;A.negativeZIndex.some((function(e,t){return h>e.element.container.styles.zIndex.order?(d=t,!1):d>0})),A.negativeZIndex.splice(d,0,c)}else if(h>0){var p=0;A.positiveZIndex.some((function(e,t){return h>=e.element.container.styles.zIndex.order?(p=t+1,!1):p>0})),A.positiveZIndex.splice(p,0,c)}else A.zeroOrAutoZIndexOrTransformedOrOpacity.push(c)}else n.styles.isFloating()?A.nonPositionedFloats.push(c):A.nonPositionedInlineLevel.push(c);e(l,c,o?c:s,u)}else n.styles.isInlineLevel()?i.inlineLevel.push(l):i.nonInlineLevel.push(l),e(l,i,s,u);$g(n.flags,8)&&Ey(n,u)}))},Ey=function(e,t){for(var i=e instanceof $m?e.start:1,s=e instanceof $m&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var s=Ry(e),r=yy(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,s.left,s.top,s.width,s.height),this.ctx.restore()}},t.prototype.renderNodeContent=function(e){return ap(this,void 0,void 0,(function(){var i,s,r,n,o,a,l,u,A,c,h,d,p,f,v,g,m,_;return lp(this,(function(y){switch(y.label){case 0:this.applyEffects(e.getEffects(4)),i=e.container,s=e.curves,r=i.styles,n=0,o=i.textNodes,y.label=1;case 1:return n0&&w>0&&(g=s.ctx.createPattern(p,"repeat"),s.renderRepeat(_,g,P,C))):function(e){return 2===e.type}(i)&&(m=Ly(e,t,[null,null,null]),_=m[0],y=m[1],b=m[2],B=m[3],w=m[4],x=0===i.position.length?[iv]:i.position,P=nv(x[0],B),C=nv(x[x.length-1],w),M=function(e,t,i,s,r){var n=0,o=0;switch(e.size){case 0:0===e.shape?n=o=Math.min(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(n=Math.min(Math.abs(t),Math.abs(t-s)),o=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)n=o=Math.min(Cv(t,i),Cv(t,i-r),Cv(t-s,i),Cv(t-s,i-r));else if(1===e.shape){var a=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-s)),l=Mv(s,r,t,i,!0),u=l[0],A=l[1];o=a*(n=Cv(u-t,(A-i)/a))}break;case 1:0===e.shape?n=o=Math.max(Math.abs(t),Math.abs(t-s),Math.abs(i),Math.abs(i-r)):1===e.shape&&(n=Math.max(Math.abs(t),Math.abs(t-s)),o=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)n=o=Math.max(Cv(t,i),Cv(t,i-r),Cv(t-s,i),Cv(t-s,i-r));else if(1===e.shape){a=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-s));var c=Mv(s,r,t,i,!1);u=c[0],A=c[1],o=a*(n=Cv(u-t,(A-i)/a))}}return Array.isArray(e.size)&&(n=nv(e.size[0],s),o=2===e.size.length?nv(e.size[1],r):n),[n,o]}(i,P,C,B,w),F=M[0],E=M[1],F>0&&E>0&&(k=s.ctx.createRadialGradient(y+P,b+C,0,y+P,b+C,F),xv(i.stops,2*F).forEach((function(e){return k.addColorStop(e.stop,hv(e.color))})),s.path(_),s.ctx.fillStyle=k,F!==E?(I=e.bounds.left+.5*e.bounds.width,D=e.bounds.top+.5*e.bounds.height,T=1/(S=E/F),s.ctx.save(),s.ctx.translate(I,D),s.ctx.transform(1,0,0,S,0,0),s.ctx.translate(-I,-D),s.ctx.fillRect(y,T*(b-D)+D,B,w*T),s.ctx.restore()):s.ctx.fill())),R.label=6;case 6:return t--,[2]}}))},s=this,r=0,n=e.styles.backgroundImage.slice(0).reverse(),a.label=1;case 1:return r0?2!==l.style?[3,5]:[4,this.renderDashedDottedBorder(l.color,l.width,n,e.curves,2)]:[3,11]:[3,13];case 4:return A.sent(),[3,11];case 5:return 3!==l.style?[3,7]:[4,this.renderDashedDottedBorder(l.color,l.width,n,e.curves,3)];case 6:return A.sent(),[3,11];case 7:return 4!==l.style?[3,9]:[4,this.renderDoubleBorder(l.color,l.width,n,e.curves)];case 8:return A.sent(),[3,11];case 9:return[4,this.renderSolidBorder(l.color,n,e.curves)];case 10:A.sent(),A.label=11;case 11:n++,A.label=12;case 12:return o++,[3,3];case 13:return[2]}}))}))},t.prototype.renderDashedDottedBorder=function(e,t,i,s,r){return ap(this,void 0,void 0,(function(){var n,o,a,l,u,A,c,h,d,p,f,v,g,m,_,y;return lp(this,(function(b){return this.ctx.save(),n=function(e,t){switch(t){case 0:return Dy(e.topLeftBorderStroke,e.topRightBorderStroke);case 1:return Dy(e.topRightBorderStroke,e.bottomRightBorderStroke);case 2:return Dy(e.bottomRightBorderStroke,e.bottomLeftBorderStroke);default:return Dy(e.bottomLeftBorderStroke,e.topLeftBorderStroke)}}(s,i),o=Iy(s,i),2===r&&(this.path(o),this.ctx.clip()),vy(o[0])?(a=o[0].start.x,l=o[0].start.y):(a=o[0].x,l=o[0].y),vy(o[1])?(u=o[1].end.x,A=o[1].end.y):(u=o[1].x,A=o[1].y),c=0===i||2===i?Math.abs(a-u):Math.abs(l-A),this.ctx.beginPath(),3===r?this.formatPath(n):this.formatPath(o.slice(0,2)),h=t<3?3*t:2*t,d=t<3?2*t:t,3===r&&(h=t,d=t),p=!0,c<=2*h?p=!1:c<=2*h+d?(h*=f=c/(2*h+d),d*=f):(v=Math.floor((c+d)/(h+d)),g=(c-v*h)/(v-1),d=(m=(c-(v+1)*h)/v)<=0||Math.abs(d-g)0&&void 0!==arguments[0]?arguments[0]:{},t=!this._snapshotBegun,i=void 0!==e.width&&void 0!==e.height,s=this.scene.canvas.canvas,r=s.clientWidth,n=s.clientHeight,o=e.width?Math.floor(e.width):s.width,a=e.height?Math.floor(e.height):s.height;i&&(s.width=o,s.height=a),this._snapshotBegun||this.beginSnapshot({width:o,height:a}),e.includeGizmos||this.sendToPlugins("snapshotStarting");for(var l={},u=0,A=this._plugins.length;u0&&void 0!==b[0]?b[0]:{},i=!this._snapshotBegun,s=void 0!==t.width&&void 0!==t.height,r=this.scene.canvas.canvas,n=r.clientWidth,o=r.clientHeight,l=t.width?Math.floor(t.width):r.width,u=t.height?Math.floor(t.height):r.height,s&&(r.width=l,r.height=u),this._snapshotBegun||this.beginSnapshot(),t.includeGizmos||this.sendToPlugins("snapshotStarting"),this.scene._renderer.renderSnapshot(),A=this.scene._renderer.readSnapshotAsCanvas(),s&&(r.width=n,r.height=o,this.scene.glRedraw()),c={},h=[],d=0,p=this._plugins.length;d1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2?arguments[2]:void 0,s=i||new Set;if(e){if(bb(e))s.add(e);else if(bb(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"===w(e))for(var r in e)yb(e[r],t,s)}else;return void 0===i?Array.from(s):[]}function bb(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var Bb=function(){},wb=function(){function e(t){x(this,e),pb(this,"name",void 0),pb(this,"source",void 0),pb(this,"url",void 0),pb(this,"terminated",!1),pb(this,"worker",void 0),pb(this,"onMessage",void 0),pb(this,"onError",void 0),pb(this,"_loadableURL","");var i=t.name,s=t.source,r=t.url;ab(s||r),this.name=i,this.source=s,this.url=r,this.onMessage=Bb,this.onError=function(e){return console.log(e)},this.worker=Ab?this._createBrowserWorker():this._createNodeWorker()}return C(e,[{key:"destroy",value:function(){this.onMessage=Bb,this.onError=Bb,this.worker.terminate(),this.terminated=!0}},{key:"isRunning",get:function(){return Boolean(this.onMessage)}},{key:"postMessage",value:function(e,t){t=t||yb(e),this.worker.postMessage(e,t)}},{key:"_getErrorFromErrorEvent",value:function(e){var t="Failed to load ";return t+="worker ".concat(this.name," from ").concat(this.url,". "),e.message&&(t+="".concat(e.message," in ")),e.lineno&&(t+=":".concat(e.lineno,":").concat(e.colno)),new Error(t)}},{key:"_createBrowserWorker",value:function(){var e=this;this._loadableURL=mb({source:this.source,url:this.url});var t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=function(t){t.data?e.onMessage(t.data):e.onError(new Error("No data received"))},t.onerror=function(t){e.onError(e._getErrorFromErrorEvent(t)),e.terminated=!0},t.onmessageerror=function(e){return console.error(e)},t}},{key:"_createNodeWorker",value:function(){var e,t=this;if(this.url){var i=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./".concat(this.url);e=new vb(i,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new vb(this.source,{eval:!0})}return e.on("message",(function(e){t.onMessage(e)})),e.on("error",(function(e){t.onError(e)})),e.on("exit",(function(e){})),e}}],[{key:"isSupported",value:function(){return"undefined"!=typeof Worker&&Ab||void 0!==w(vb)}}]),e}(),xb=function(){function e(t){x(this,e),pb(this,"name","unnamed"),pb(this,"source",void 0),pb(this,"url",void 0),pb(this,"maxConcurrency",1),pb(this,"maxMobileConcurrency",1),pb(this,"onDebug",(function(){})),pb(this,"reuseWorkers",!0),pb(this,"props",{}),pb(this,"jobQueue",[]),pb(this,"idleQueue",[]),pb(this,"count",0),pb(this,"isDestroyed",!1),this.source=t.source,this.url=t.url,this.setProps(t)}var t,i;return C(e,[{key:"destroy",value:function(){this.idleQueue.forEach((function(e){return e.destroy()})),this.isDestroyed=!0}},{key:"setProps",value:function(e){this.props=n(n({},this.props),e),void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}},{key:"startJob",value:(i=u(a().mark((function e(t){var i,s,r,n=this,o=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=o.length>1&&void 0!==o[1]?o[1]:function(e,t,i){return e.done(i)},s=o.length>2&&void 0!==o[2]?o[2]:function(e,t){return e.error(t)},r=new Promise((function(e){return n.jobQueue.push({name:t,onMessage:i,onError:s,onStart:e}),n})),this._startQueuedJob(),e.next=6,r;case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"_startQueuedJob",value:(t=u(a().mark((function e(){var t,i,s;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.jobQueue.length){e.next=2;break}return e.abrupt("return");case 2:if(t=this._getAvailableWorker()){e.next=5;break}return e.abrupt("return");case 5:if(!(i=this.jobQueue.shift())){e.next=18;break}return this.onDebug({message:"Starting job",name:i.name,workerThread:t,backlog:this.jobQueue.length}),s=new fb(i.name,t),t.onMessage=function(e){return i.onMessage(s,e.type,e.payload)},t.onError=function(e){return i.onError(s,e)},i.onStart(s),e.prev=12,e.next=15,s.result;case 15:return e.prev=15,this.returnWorkerToQueue(t),e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[12,,15,18]])}))),function(){return t.apply(this,arguments)})},{key:"returnWorkerToQueue",value:function(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}},{key:"_getAvailableWorker",value:function(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count0&&void 0!==arguments[0]?arguments[0]:{};return e._workerFarm=e._workerFarm||new e({}),e._workerFarm.setProps(t),e._workerFarm}}]),e}();pb(Cb,"_workerFarm",void 0);function Mb(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t[e.id]||{},s="".concat(e.id,"-worker.js"),r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r="modules/".concat(e.module,"/dist/").concat(s)),!r){var n=e.version;"latest"===n&&(n="latest");var o=n?"@".concat(n):"";r="https://unpkg.com/@loaders.gl/".concat(e.module).concat(o,"/dist/").concat(s)}return ab(r),r}function Fb(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"3.2.6";ab(e,"no worker provided");var i=e.version;return!(!t||!i)}var Eb=Object.freeze({__proto__:null,default:{}}),kb={};function Ib(e){return Db.apply(this,arguments)}function Db(){return Db=u(a().mark((function e(t){var i,s,r=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.length>1&&void 0!==r[1]?r[1]:null,s=r.length>2&&void 0!==r[2]?r[2]:{},i&&(t=Sb(t,i,s)),kb[t]=kb[t]||Tb(t),e.next=6,kb[t];case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)}))),Db.apply(this,arguments)}function Sb(e,t,i){if(e.startsWith("http"))return e;var s=i.modules||{};return s[e]?s[e]:Ab?i.CDN?(ab(i.CDN.startsWith("http")),"".concat(i.CDN,"/").concat(t,"@").concat("3.2.6","/dist/libs/").concat(e)):cb?"../src/libs/".concat(e):"modules/".concat(t,"/src/libs/").concat(e):"modules/".concat(t,"/dist/libs/").concat(e)}function Tb(e){return Rb.apply(this,arguments)}function Rb(){return(Rb=u(a().mark((function e(t){var i,s,r;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.endsWith("wasm")){e.next=7;break}return e.next=3,fetch(t);case 3:return i=e.sent,e.next=6,i.arrayBuffer();case 6:return e.abrupt("return",e.sent);case 7:if(Ab){e.next=20;break}if(e.prev=8,e.t0=Eb&&void 0,!e.t0){e.next=14;break}return e.next=13,(void 0)(t);case 13:e.t0=e.sent;case 14:return e.abrupt("return",e.t0);case 17:return e.prev=17,e.t1=e.catch(8),e.abrupt("return",null);case 20:if(!cb){e.next=22;break}return e.abrupt("return",importScripts(t));case 22:return e.next=24,fetch(t);case 24:return s=e.sent,e.next=27,s.text();case 27:return r=e.sent,e.abrupt("return",Lb(r,t));case 29:case"end":return e.stop()}}),e,null,[[8,17]])})))).apply(this,arguments)}function Lb(e,t){if(Ab){if(cb)return eval.call(ub,e),null;var i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}}function Ub(e,t){return!!Cb.isSupported()&&(!!(Ab||null!=t&&t._nodeWorkers)&&(e.worker&&(null==t?void 0:t.worker)))}function Ob(e,t,i,s,r){return Nb.apply(this,arguments)}function Nb(){return Nb=u(a().mark((function e(t,i,s,r,n){var o,l,u,A,c,h;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.id,l=Mb(t,s),u=Cb.getWorkerFarm(s),A=u.getWorkerPool({name:o,url:l}),s=JSON.parse(JSON.stringify(s)),r=JSON.parse(JSON.stringify(r||{})),e.next=8,A.startJob("process-on-worker",Qb.bind(null,n));case 8:return(c=e.sent).postMessage("process",{input:i,options:s,context:r}),e.next=12,c.result;case 12:return h=e.sent,e.next=15,h.result;case 15:return e.abrupt("return",e.sent);case 16:case"end":return e.stop()}}),e)}))),Nb.apply(this,arguments)}function Qb(e,t,i,s){return Vb.apply(this,arguments)}function Vb(){return(Vb=u(a().mark((function e(t,i,s,r){var n,o,l,u,A;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=s,e.next="done"===e.t0?3:"error"===e.t0?5:"process"===e.t0?7:20;break;case 3:return i.done(r),e.abrupt("break",21);case 5:return i.error(new Error(r.error)),e.abrupt("break",21);case 7:return n=r.id,o=r.input,l=r.options,e.prev=8,e.next=11,t(o,l);case 11:u=e.sent,i.postMessage("done",{id:n,result:u}),e.next=19;break;case 15:e.prev=15,e.t1=e.catch(8),A=e.t1 instanceof Error?e.t1.message:"unknown error",i.postMessage("error",{id:n,error:A});case 19:return e.abrupt("break",21);case 20:console.warn("parse-with-worker unknown message ".concat(s));case 21:case"end":return e.stop()}}),e,null,[[8,15]])})))).apply(this,arguments)}function Hb(e,t,i){if(e.byteLength<=t+i)return"";for(var s=new DataView(e),r="",n=0;n1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return Hb(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return Hb(e,0,t)}return""}(e),'"'))}}function Gb(e){return e&&"object"===w(e)&&e.isBuffer}function zb(e){if(Gb(e))return Gb(t=e)?new Uint8Array(t.buffer,t.byteOffset,t.length).slice().buffer:t;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){var i=e;return(new TextEncoder).encode(i).buffer}if(e&&"object"===w(e)&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Wb(){for(var e=arguments.length,t=new Array(e),i=0;i=0),rb(t>0),e+(t-1)&~(t-1)}function Jb(e,t,i){var s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{var r=e.byteOffset,n=e.byteLength;s=new Uint8Array(e.buffer||e.arrayBuffer,r,n)}return t.set(s,i),i+Xb(s.byteLength,4)}function Yb(e){return Zb.apply(this,arguments)}function Zb(){return(Zb=u(a().mark((function e(t){var i,s,r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=[],s=!1,r=!1,e.prev=3,o=I(t);case 5:return e.next=7,o.next();case 7:if(!(s=!(l=e.sent).done)){e.next=13;break}u=l.value,i.push(u);case 10:s=!1,e.next=5;break;case 13:e.next=19;break;case 15:e.prev=15,e.t0=e.catch(3),r=!0,n=e.t0;case 19:if(e.prev=19,e.prev=20,!s||null==o.return){e.next=24;break}return e.next=24,o.return();case 24:if(e.prev=24,!r){e.next=27;break}throw n;case 27:return e.finish(24);case 28:return e.finish(19);case 29:return e.abrupt("return",Wb.apply(void 0,i));case 30:case"end":return e.stop()}}),e,null,[[3,15,19,29],[20,,24,28]])})))).apply(this,arguments)}var qb={};function $b(e){for(var t in qb)if(e.startsWith(t)){var i=qb[t];e=e.replace(t,i)}return e.startsWith("http://")||e.startsWith("https://")||(e="".concat("").concat(e)),e}var eB=function(e){return"function"==typeof e},tB=function(e){return null!==e&&"object"===w(e)},iB=function(e){return tB(e)&&e.constructor==={}.constructor},sB=function(e){return e&&"function"==typeof e[Symbol.iterator]},rB=function(e){return e&&"function"==typeof e[Symbol.asyncIterator]},nB=function(e){return"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json},oB=function(e){return"undefined"!=typeof Blob&&e instanceof Blob},aB=function(e){return function(e){return"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||tB(e)&&eB(e.tee)&&eB(e.cancel)&&eB(e.getReader)}(e)||function(e){return tB(e)&&eB(e.read)&&eB(e.pipe)&&function(e){return"boolean"==typeof e}(e.readable)}(e)},lB=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,uB=/^([-\w.]+\/[-\w.+]+)/;function AB(e){var t=uB.exec(e);return t?t[1]:e}function cB(e){var t=lB.exec(e);return t?t[1]:""}var hB=/\?.*/;function dB(e){if(nB(e)){var t=fB(e.url||"");return{url:t,type:AB(e.headers.get("content-type")||"")||cB(t)}}return oB(e)?{url:fB(e.name||""),type:e.type||""}:"string"==typeof e?{url:fB(e),type:cB(e)}:{url:"",type:""}}function pB(e){return nB(e)?e.headers["content-length"]||-1:oB(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}function fB(e){return e.replace(hB,"")}function vB(e){return gB.apply(this,arguments)}function gB(){return(gB=u(a().mark((function e(t){var i,s,r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!nB(t)){e.next=2;break}return e.abrupt("return",t);case 2:return i={},(s=pB(t))>=0&&(i["content-length"]=String(s)),r=dB(t),n=r.url,(o=r.type)&&(i["content-type"]=o),e.next=9,BB(t);case 9:return(l=e.sent)&&(i["x-first-bytes"]=l),"string"==typeof t&&(t=(new TextEncoder).encode(t)),u=new Response(t,{headers:i}),Object.defineProperty(u,"url",{value:n}),e.abrupt("return",u);case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mB(e){return _B.apply(this,arguments)}function _B(){return(_B=u(a().mark((function e(t){var i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.ok){e.next=5;break}return e.next=3,yB(t);case 3:throw i=e.sent,new Error(i);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yB(e){return bB.apply(this,arguments)}function bB(){return(bB=u(a().mark((function e(t){var i,s,r;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i="Failed to fetch resource ".concat(t.url," (").concat(t.status,"): "),e.prev=1,s=t.headers.get("Content-Type"),r=t.statusText,!s.includes("application/json")){e.next=11;break}return e.t0=r,e.t1=" ",e.next=9,t.text();case 9:e.t2=e.sent,r=e.t0+=e.t1.concat.call(e.t1,e.t2);case 11:i=(i+=r).length>60?"".concat(i.slice(0,60),"..."):i,e.next=17;break;case 15:e.prev=15,e.t3=e.catch(1);case 17:return e.abrupt("return",i);case 18:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function BB(e){return wB.apply(this,arguments)}function wB(){return(wB=u(a().mark((function e(t){var i,s,r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=5,"string"!=typeof t){e.next=3;break}return e.abrupt("return","data:,".concat(t.slice(0,i)));case 3:if(!(t instanceof Blob)){e.next=8;break}return s=t.slice(0,5),e.next=7,new Promise((function(e){var t=new FileReader;t.onload=function(t){var i;return e(null==t||null===(i=t.target)||void 0===i?void 0:i.result)},t.readAsDataURL(s)}));case 7:return e.abrupt("return",e.sent);case 8:if(!(t instanceof ArrayBuffer)){e.next=12;break}return r=t.slice(0,i),n=xB(r),e.abrupt("return","data:base64,".concat(n));case 12:return e.abrupt("return",null);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xB(e){for(var t="",i=new Uint8Array(e),s=0;s=0)}();function DB(e){try{var t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}var SB=function(){function e(t,i){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";x(this,e),this.storage=DB(s),this.id=t,this.config={},Object.assign(this.config,i),this._loadConfiguration()}return C(e,[{key:"getConfiguration",value:function(){return this.config}},{key:"setConfiguration",value:function(e){return this.config={},this.updateConfiguration(e)}},{key:"updateConfiguration",value:function(e){if(Object.assign(this.config,e),this.storage){var t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}},{key:"_loadConfiguration",value:function(){var e={};if(this.storage){var t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}]),e}();function TB(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600,r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));var n=e.width*i,o=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(n/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(r,");"),"background-size:".concat(n,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}var RB={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function LB(e){return"string"==typeof e?RB[e.toUpperCase()]||RB.WHITE:e}function UB(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"],s=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(s),n=c(r);try{var o=function(){var s=t.value;"function"==typeof e[s]&&(i.find((function(e){return s===e}))||(e[s]=e[s].bind(e)))};for(n.s();!(t=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function OB(e,t){if(!e)throw new Error(t||"Assertion failed")}function NB(){var e;if(IB&&FB.performance)e=FB.performance.now();else if(EB.hrtime){var t=EB.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}var QB={debug:IB&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},VB={enabled:!0,level:0};function HB(){}var jB={},GB={once:!0};function zB(e){for(var t in e)for(var i in e[t])return i||"untitled";return"empty"}var WB=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""},i=t.id;x(this,e),this.id=i,this.VERSION=kB,this._startTs=NB(),this._deltaTs=NB(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new SB("__probe-".concat(this.id,"__"),VB),this.userData={},this.timeStamp("".concat(this.id," started")),UB(this),Object.seal(this)}return C(e,[{key:"level",get:function(){return this.getLevel()},set:function(e){this.setLevel(e)}},{key:"isEnabled",value:function(){return this._storage.config.enabled}},{key:"getLevel",value:function(){return this._storage.config.level}},{key:"getTotal",value:function(){return Number((NB()-this._startTs).toPrecision(10))}},{key:"getDelta",value:function(){return Number((NB()-this._deltaTs).toPrecision(10))}},{key:"priority",get:function(){return this.level},set:function(e){this.level=e}},{key:"getPriority",value:function(){return this.level}},{key:"enable",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}},{key:"setLevel",value:function(e){return this._storage.updateConfiguration({level:e}),this}},{key:"assert",value:function(e,t){OB(e,t)}},{key:"warn",value:function(e){return this._getLogFunction(0,e,QB.warn,arguments,GB)}},{key:"error",value:function(e){return this._getLogFunction(0,e,QB.error,arguments)}},{key:"deprecated",value:function(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}},{key:"removed",value:function(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}},{key:"probe",value:function(e,t){return this._getLogFunction(e,t,QB.log,arguments,{time:!0,once:!0})}},{key:"log",value:function(e,t){return this._getLogFunction(e,t,QB.debug,arguments)}},{key:"info",value:function(e,t){return this._getLogFunction(e,t,console.info,arguments)}},{key:"once",value:function(e,t){return this._getLogFunction(e,t,QB.debug||QB.info,arguments,GB)}},{key:"table",value:function(e,t,i){return t?this._getLogFunction(e,t,console.table||HB,i&&[i],{tag:zB(t)}):HB}},{key:"image",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){var t=e.logLevel,i=e.priority,s=e.image,r=e.message,n=void 0===r?"":r,o=e.scale,a=void 0===o?1:o;return this._shouldLog(t||i)?IB?function(e){var t=e.image,i=e.message,s=void 0===i?"":i,r=e.scale,n=void 0===r?1:r;if("string"==typeof t){var o=new Image;return o.onload=function(){var e,t=TB(o,s,n);(e=console).log.apply(e,A(t))},o.src=t,HB}var a=t.nodeName||"";if("img"===a.toLowerCase()){var l;return(l=console).log.apply(l,A(TB(t,s,n))),HB}if("canvas"===a.toLowerCase()){var u=new Image;return u.onload=function(){var e;return(e=console).log.apply(e,A(TB(u,s,n)))},u.src=t.toDataURL(),HB}return HB}({image:s,message:n,scale:a}):function(e){var t=e.image,i=(e.message,e.scale),s=void 0===i?1:i,r=null;try{r=module.require("asciify-image")}catch(e){}if(r)return function(){return r(t,{fit:"box",width:"".concat(Math.round(80*s),"%")}).then((function(e){return console.log(e)}))};return HB}({image:s,message:n,scale:a}):HB}))},{key:"settings",value:function(){console.table?console.table(this._storage.config):console.log(this._storage.config)}},{key:"get",value:function(e){return this._storage.config[e]}},{key:"set",value:function(e,t){this._storage.updateConfiguration(o({},e,t))}},{key:"time",value:function(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}},{key:"timeEnd",value:function(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}},{key:"timeStamp",value:function(e,t){return this._getLogFunction(e,t,console.timeStamp||HB)}},{key:"group",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1},s=i=XB({logLevel:e,message:t,opts:i}),r=s.collapsed;return i.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(i)}},{key:"groupCollapsed",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},i,{collapsed:!0}))}},{key:"groupEnd",value:function(e){return this._getLogFunction(e,"",console.groupEnd||HB)}},{key:"withGroup",value:function(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}},{key:"trace",value:function(){console.trace&&console.trace()}},{key:"_shouldLog",value:function(e){return this.isEnabled()&&this.getLevel()>=KB(e)}},{key:"_getLogFunction",value:function(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],r=arguments.length>4?arguments[4]:void 0;if(this._shouldLog(e)){var n;r=XB({logLevel:e,message:t,args:s,opts:r}),OB(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=NB();var o=r.tag||r.message;if(r.once){if(jB[o])return HB;jB[o]=NB()}return t=JB(this.id,r.message,r),(n=i).bind.apply(n,[console,t].concat(A(r.args)))}return HB}}]),e}();function KB(e){if(!e)return 0;var t;switch(w(e)){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return OB(Number.isFinite(t)&&t>=0),t}function XB(e){var t=e.logLevel,i=e.message;e.logLevel=KB(t);for(var s=e.args?Array.from(e.args):[];s.length&&s.shift()!==i;);switch(e.args=s,w(t)){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());var r=w(e.message);return OB("string"===r||"object"===r),Object.assign(e,e.opts)}function JB(e,t,i){if("string"==typeof t){var s=i.time?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8,i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}((r=i.total)<10?"".concat(r.toFixed(2),"ms"):r<100?"".concat(r.toFixed(1),"ms"):r<1e3?"".concat(r.toFixed(0),"ms"):"".concat((r/1e3).toFixed(2),"s")):"";t=function(e,t,i){return IB||"string"!=typeof e||(t&&(t=LB(t),e="[".concat(t,"m").concat(e,"")),i&&(t=LB(i),e="[".concat(i+10,"m").concat(e,""))),e}(t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),i.color,i.background)}var r;return t}WB.VERSION=kB;var YB=new WB({id:"loaders.gl"}),ZB=function(){function e(){x(this,e)}return C(e,[{key:"log",value:function(){return function(){}}},{key:"info",value:function(){return function(){}}},{key:"warn",value:function(){return function(){}}},{key:"error",value:function(){return function(){}}}]),e}(),qB={fetch:null,mimeType:void 0,nothrow:!1,log:new(function(){function e(){x(this,e),pb(this,"console",void 0),this.console=console}return C(e,[{key:"log",value:function(){for(var e,t=arguments.length,i=new Array(t),s=0;s=0)}()}var cw={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"===("undefined"==typeof process?"undefined":w(process))&&process},hw=cw.window||cw.self||cw.global,dw=cw.process||{},pw="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";function fw(e){try{var t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}Aw();var vw,gw=function(){function e(t){x(this,e);var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";pb(this,"storage",void 0),pb(this,"id",void 0),pb(this,"config",{}),this.storage=fw(s),this.id=t,this.config={},Object.assign(this.config,i),this._loadConfiguration()}return C(e,[{key:"getConfiguration",value:function(){return this.config}},{key:"setConfiguration",value:function(e){return this.config={},this.updateConfiguration(e)}},{key:"updateConfiguration",value:function(e){if(Object.assign(this.config,e),this.storage){var t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}return this}},{key:"_loadConfiguration",value:function(){var e={};if(this.storage){var t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}]),e}();function mw(e,t,i){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600,r=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>s&&(i=Math.min(i,s/e.width));var n=e.width*i,o=e.height*i,a=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(n/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(r,");"),"background-size:".concat(n,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}function _w(e){return"string"==typeof e?vw[e.toUpperCase()]||vw.WHITE:e}function yw(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"],s=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(s),n=c(r);try{var o=function(){var s=t.value;"function"==typeof e[s]&&(i.find((function(e){return s===e}))||(e[s]=e[s].bind(e)))};for(n.s();!(t=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function bw(e,t){if(!e)throw new Error(t||"Assertion failed")}function Bw(){var e,t,i;if(Aw&&"performance"in hw)e=null==hw||null===(t=hw.performance)||void 0===t||null===(i=t.now)||void 0===i?void 0:i.call(t);else if("hrtime"in dw){var s,r=null==dw||null===(s=dw.hrtime)||void 0===s?void 0:s.call(dw);e=1e3*r[0]+r[1]/1e6}else e=Date.now();return e}!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(vw||(vw={}));var ww={debug:Aw&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},xw={enabled:!0,level:0};function Pw(){}var Cw={},Mw={once:!0},Fw=function(){function e(){x(this,e);var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""},i=t.id;pb(this,"id",void 0),pb(this,"VERSION",pw),pb(this,"_startTs",Bw()),pb(this,"_deltaTs",Bw()),pb(this,"_storage",void 0),pb(this,"userData",{}),pb(this,"LOG_THROTTLE_TIMEOUT",0),this.id=i,this._storage=new gw("__probe-".concat(this.id,"__"),xw),this.userData={},this.timeStamp("".concat(this.id," started")),yw(this),Object.seal(this)}return C(e,[{key:"level",get:function(){return this.getLevel()},set:function(e){this.setLevel(e)}},{key:"isEnabled",value:function(){return this._storage.config.enabled}},{key:"getLevel",value:function(){return this._storage.config.level}},{key:"getTotal",value:function(){return Number((Bw()-this._startTs).toPrecision(10))}},{key:"getDelta",value:function(){return Number((Bw()-this._deltaTs).toPrecision(10))}},{key:"priority",get:function(){return this.level},set:function(e){this.level=e}},{key:"getPriority",value:function(){return this.level}},{key:"enable",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}},{key:"setLevel",value:function(e){return this._storage.updateConfiguration({level:e}),this}},{key:"get",value:function(e){return this._storage.config[e]}},{key:"set",value:function(e,t){this._storage.updateConfiguration(o({},e,t))}},{key:"settings",value:function(){console.table?console.table(this._storage.config):console.log(this._storage.config)}},{key:"assert",value:function(e,t){bw(e,t)}},{key:"warn",value:function(e){return this._getLogFunction(0,e,ww.warn,arguments,Mw)}},{key:"error",value:function(e){return this._getLogFunction(0,e,ww.error,arguments)}},{key:"deprecated",value:function(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}},{key:"removed",value:function(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}},{key:"probe",value:function(e,t){return this._getLogFunction(e,t,ww.log,arguments,{time:!0,once:!0})}},{key:"log",value:function(e,t){return this._getLogFunction(e,t,ww.debug,arguments)}},{key:"info",value:function(e,t){return this._getLogFunction(e,t,console.info,arguments)}},{key:"once",value:function(e,t){for(var i=arguments.length,s=new Array(i>2?i-2:0),r=2;r2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1},s=kw({logLevel:e,message:t,opts:i}),r=i.collapsed;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}},{key:"groupCollapsed",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},i,{collapsed:!0}))}},{key:"groupEnd",value:function(e){return this._getLogFunction(e,"",console.groupEnd||Pw)}},{key:"withGroup",value:function(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}},{key:"trace",value:function(){console.trace&&console.trace()}},{key:"_shouldLog",value:function(e){return this.isEnabled()&&this.getLevel()>=Ew(e)}},{key:"_getLogFunction",value:function(e,t,i,s,r){if(this._shouldLog(e)){var n;r=kw({logLevel:e,message:t,args:s,opts:r}),bw(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Bw();var o=r.tag||r.message;if(r.once){if(Cw[o])return Pw;Cw[o]=Bw()}return t=function(e,t,i){if("string"==typeof t){var s=i.time?function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8,i=Math.max(t-e.length,0);return"".concat(" ".repeat(i)).concat(e)}((r=i.total)<10?"".concat(r.toFixed(2),"ms"):r<100?"".concat(r.toFixed(1),"ms"):r<1e3?"".concat(r.toFixed(0),"ms"):"".concat((r/1e3).toFixed(2),"s")):"";t=function(e,t,i){return Aw||"string"!=typeof e||(t&&(t=_w(t),e="[".concat(t,"m").concat(e,"")),i&&(t=_w(i),e="[".concat(i+10,"m").concat(e,""))),e}(t=i.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),i.color,i.background)}var r;return t}(this.id,r.message,r),(n=i).bind.apply(n,[console,t].concat(A(r.args)))}return Pw}}]),e}();function Ew(e){if(!e)return 0;var t;switch(w(e)){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return bw(Number.isFinite(t)&&t>=0),t}function kw(e){var t=e.logLevel,i=e.message;e.logLevel=Ew(t);for(var s=e.args?Array.from(e.args):[];s.length&&s.shift()!==i;);switch(w(t)){case"string":case"function":void 0!==i&&s.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());var r=w(e.message);return bw("string"===r||"object"===r),Object.assign(e,{args:s},e.opts)}function Iw(e){for(var t in e)for(var i in e[t])return i||"untitled";return"empty"}pb(Fw,"VERSION",pw);var Dw=new Fw({id:"loaders.gl"}),Sw=/\.([^.]+)$/;function Tw(e){return Rw.apply(this,arguments)}function Rw(){return Rw=u(a().mark((function e(t){var i,s,r,o,l=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=l.length>1&&void 0!==l[1]?l[1]:[],s=l.length>2?l[2]:void 0,r=l.length>3?l[3]:void 0,Ow(t)){e.next=5;break}return e.abrupt("return",null);case 5:if(!(o=Lw(t,i,n(n({},s),{},{nothrow:!0}),r))){e.next=8;break}return e.abrupt("return",o);case 8:if(!oB(t)){e.next=13;break}return e.next=11,t.slice(0,10).arrayBuffer();case 11:t=e.sent,o=Lw(t,i,s,r);case 13:if(o||null!=s&&s.nothrow){e.next=15;break}throw new Error(Nw(t));case 15:return e.abrupt("return",o);case 16:case"end":return e.stop()}}),e)}))),Rw.apply(this,arguments)}function Lw(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;if(!Ow(e))return null;if(t&&!Array.isArray(t))return lw(t);var r,n=[];(t&&(n=n.concat(t)),null!=i&&i.ignoreRegisteredLoaders)||(r=n).push.apply(r,A(uw()));Qw(n);var o=Uw(e,n,i,s);if(!(o||null!=i&&i.nothrow))throw new Error(Nw(e));return o}function Uw(e,t,i,s){var r,n=dB(e),o=n.url,a=n.type,l=o||(null==s?void 0:s.url),u=null,A="";(null!=i&&i.mimeType&&(u=Vw(t,null==i?void 0:i.mimeType),A="match forced by supplied MIME type ".concat(null==i?void 0:i.mimeType)),u=u||function(e,t){var i=t&&Sw.exec(t),s=i&&i[1];return s?function(e,t){t=t.toLowerCase();var i,s=c(e);try{for(s.s();!(i=s.n()).done;){var r,n=i.value,o=c(n.extensions);try{for(o.s();!(r=o.n()).done;){if(r.value.toLowerCase()===t)return n}}catch(e){o.e(e)}finally{o.f()}}}catch(e){s.e(e)}finally{s.f()}return null}(e,s):null}(t,l),A=A||(u?"matched url ".concat(l):""),u=u||Vw(t,a),A=A||(u?"matched MIME type ".concat(a):""),u=u||function(e,t){if(!t)return null;var i,s=c(e);try{for(s.s();!(i=s.n()).done;){var r=i.value;if("string"==typeof t){if(Hw(t,r))return r}else if(ArrayBuffer.isView(t)){if(jw(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer){if(jw(t,0,r))return r}}}catch(e){s.e(e)}finally{s.f()}return null}(t,e),A=A||(u?"matched initial data ".concat(Gw(e)):""),u=u||Vw(t,null==i?void 0:i.fallbackMimeType),A=A||(u?"matched fallback MIME type ".concat(a):""))&&Dw.log(1,"selectLoader selected ".concat(null===(r=u)||void 0===r?void 0:r.name,": ").concat(A,"."));return u}function Ow(e){return!(e instanceof Response&&204===e.status)}function Nw(e){var t=dB(e),i=t.url,s=t.type,r="No valid loader found (";r+=i?"".concat(function(e){var t=e&&e.lastIndexOf("/");return t>=0?e.substr(t+1):""}(i),", "):"no url provided, ",r+="MIME type: ".concat(s?'"'.concat(s,'"'):"not provided",", ");var n=e?Gw(e):"";return r+=n?' first bytes: "'.concat(n,'"'):"first bytes: not available",r+=")"}function Qw(e){var t,i=c(e);try{for(i.s();!(t=i.n()).done;){lw(t.value)}}catch(e){i.e(e)}finally{i.f()}}function Vw(e,t){var i,s=c(e);try{for(s.s();!(i=s.n()).done;){var r=i.value;if(r.mimeTypes&&r.mimeTypes.includes(t))return r;if(t==="application/x.".concat(r.id))return r}}catch(e){s.e(e)}finally{s.f()}return null}function Hw(e,t){return t.testText?t.testText(e):(Array.isArray(t.tests)?t.tests:[t.tests]).some((function(t){return e.startsWith(t)}))}function jw(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some((function(s){return function(e,t,i,s){if(s instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLength1&&void 0!==arguments[1]?arguments[1]:5;if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return zw(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){var i=0;return zw(e,i,t)}return""}function zw(e,t,i){if(e.byteLength1&&void 0!==A[1]?A[1]:{},s=t.chunkSize,r=void 0===s?262144:s,n=0;case 3:if(!(n2&&void 0!==arguments[2]?arguments[2]:null;if(i)return i;var s=n({fetch:sw(t,e)},e);return Array.isArray(s.loaders)||(s.loaders=null),s}function rx(e,t){if(!t&&e&&!Array.isArray(e))return e;var i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){var s=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[].concat(A(i),A(s)):s}return i&&i.length?i:null}function nx(e,t,i,s){return ox.apply(this,arguments)}function ox(){return(ox=u(a().mark((function e(t,i,s,r){var n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return ab(!r||"object"===w(r)),!i||Array.isArray(i)||aw(i)||(r=void 0,s=i,i=void 0),e.next=4,t;case 4:return t=e.sent,s=s||{},n=dB(t),o=n.url,l=rx(i,r),e.next=11,Tw(t,l,s);case 11:if(u=e.sent){e.next=14;break}return e.abrupt("return",null);case 14:return s=iw(s,u,l,o),r=sx({url:o,parse:nx,loaders:l},s,r),e.next=18,ax(u,t,s,r);case 18:return e.abrupt("return",e.sent);case 19:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ax(e,t,i,s){return lx.apply(this,arguments)}function lx(){return(lx=u(a().mark((function e(t,i,s,r){var n,o,l,u,A,c,h,d;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Fb(t),nB(i)&&(o=(n=i).ok,l=n.redirected,u=n.status,A=n.statusText,c=n.type,h=n.url,d=Object.fromEntries(n.headers.entries()),r.response={headers:d,ok:o,redirected:l,status:u,statusText:A,type:c,url:h}),e.next=4,tx(i,t,s);case 4:if(i=e.sent,!t.parseTextSync||"string"!=typeof i){e.next=8;break}return s.dataType="text",e.abrupt("return",t.parseTextSync(i,s,r,t));case 8:if(!Ub(t,s)){e.next=12;break}return e.next=11,Ob(t,i,s,r,nx);case 11:case 15:case 19:return e.abrupt("return",e.sent);case 12:if(!t.parseText||"string"!=typeof i){e.next=16;break}return e.next=15,t.parseText(i,s,r,t);case 16:if(!t.parse){e.next=20;break}return e.next=19,t.parse(i,s,r,t);case 20:throw ab(!t.parseSync),new Error("".concat(t.id," loader - no parser found and worker is disabled"));case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ux,Ax,cx="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.wasm"),hx="https://unpkg.com/@loaders.gl/textures@".concat("3.2.6","/dist/libs/basis_encoder.js");function dx(e){return px.apply(this,arguments)}function px(){return(px=u(a().mark((function e(t){var i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(i=t.modules||{}).basis){e.next=3;break}return e.abrupt("return",i.basis);case 3:return ux=ux||fx(t),e.next=6,ux;case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fx(e){return vx.apply(this,arguments)}function vx(){return(vx=u(a().mark((function e(t){var i,s,r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null,s=null,e.t0=Promise,e.next=5,Ib("basis_transcoder.js","textures",t);case 5:return e.t1=e.sent,e.next=8,Ib("basis_transcoder.wasm","textures",t);case 8:return e.t2=e.sent,e.t3=[e.t1,e.t2],e.next=12,e.t0.all.call(e.t0,e.t3);case 12:return r=e.sent,n=h(r,2),i=n[0],s=n[1],i=i||globalThis.BASIS,e.next=19,gx(i,s);case 19:return e.abrupt("return",e.sent);case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function gx(e,t){var i={};return t&&(i.wasmBinary=t),new Promise((function(t){e(i).then((function(e){var i=e.BasisFile;(0,e.initializeBasis)(),t({BasisFile:i})}))}))}function mx(e){return _x.apply(this,arguments)}function _x(){return(_x=u(a().mark((function e(t){var i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(i=t.modules||{}).basisEncoder){e.next=3;break}return e.abrupt("return",i.basisEncoder);case 3:return Ax=Ax||yx(t),e.next=6,Ax;case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yx(e){return bx.apply(this,arguments)}function bx(){return(bx=u(a().mark((function e(t){var i,s,r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null,s=null,e.t0=Promise,e.next=5,Ib(hx,"textures",t);case 5:return e.t1=e.sent,e.next=8,Ib(cx,"textures",t);case 8:return e.t2=e.sent,e.t3=[e.t1,e.t2],e.next=12,e.t0.all.call(e.t0,e.t3);case 12:return r=e.sent,n=h(r,2),i=n[0],s=n[1],i=i||globalThis.BASIS,e.next=19,Bx(i,s);case 19:return e.abrupt("return",e.sent);case 20:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Bx(e,t){var i={};return t&&(i.wasmBinary=t),new Promise((function(t){e(i).then((function(e){var i=e.BasisFile,s=e.KTX2File,r=e.initializeBasis,n=e.BasisEncoder;r(),t({BasisFile:i,KTX2File:s,BasisEncoder:n})}))}))}var wx,xx,Px,Cx,Mx,Fx,Ex,kx,Ix,Dx=33776,Sx=33779,Tx=35840,Rx=35842,Lx=36196,Ux=37808,Ox=["","WEBKIT_","MOZ_"],Nx={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"},Qx=null;function Vx(e){if(!Qx){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Qx=new Set;var t,i=c(Ox);try{for(i.s();!(t=i.n()).done;){var s=t.value;for(var r in Nx)if(e&&e.getExtension("".concat(s).concat(r))){var n=Nx[r];Qx.add(n)}}}catch(e){i.e(e)}finally{i.f()}}return Qx}(Ix=wx||(wx={}))[Ix.NONE=0]="NONE",Ix[Ix.BASISLZ=1]="BASISLZ",Ix[Ix.ZSTD=2]="ZSTD",Ix[Ix.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(xx||(xx={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(Px||(Px={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(Cx||(Cx={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(Mx||(Mx={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(Fx||(Fx={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(Ex||(Ex={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(kx||(kx={}));var Hx=[171,75,84,88,32,50,48,187,13,10,26,10];function jx(e){var t=new Uint8Array(e);return!(t.byteLength1&&void 0!==s[1]?s[1]:null)&&vP||(i=null),!i){e.next=13;break}return e.prev=3,e.next=6,createImageBitmap(t,i);case 6:return e.abrupt("return",e.sent);case 9:e.prev=9,e.t0=e.catch(3),console.warn(e.t0),vP=!1;case 13:return e.next=15,createImageBitmap(t);case 15:return e.abrupt("return",e.sent);case 16:case"end":return e.stop()}}),e,null,[[3,9]])}))),yP.apply(this,arguments)}function bP(e){for(var t in e||fP)return!1;return!0}function BP(e){var t=wP(e);return function(e){var t=wP(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,false)))return null;return{mimeType:"image/png",width:t.getUint32(16,false),height:t.getUint32(20,false)}}(t)||function(e){var t=wP(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,false)&&255===t.getUint8(2)))return null;var i=function(){for(var e=new Set([65499,65476,65484,65501,65534]),t=65504;t<65520;++t)e.add(t);var i=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:i}}(),s=i.tableMarkers,r=i.sofMarkers,n=2;for(;n+9=10&&1195984440===t.getUint32(0,false)))return null;return{mimeType:"image/gif",width:t.getUint16(6,true),height:t.getUint16(8,true)}}(t)||function(e){var t=wP(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,false)&&t.getUint32(2,true)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,true),height:t.getUint32(22,true)}}(t)}function wP(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}function xP(e,t){return PP.apply(this,arguments)}function PP(){return PP=u(a().mark((function e(t,i){var s,r,n;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=BP(t)||{},r=s.mimeType,rb(n=globalThis._parseImageNode),e.next=5,n(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e)}))),PP.apply(this,arguments)}function CP(){return(CP=u(a().mark((function e(t,i,s){var r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=(i=i||{}).image||{},n=r.type||"auto",o=(s||{}).url,l=MP(n),e.t0=l,e.next="imagebitmap"===e.t0?8:"image"===e.t0?12:"data"===e.t0?16:20;break;case 8:return e.next=10,gP(t,i,o);case 10:return u=e.sent,e.abrupt("break",21);case 12:return e.next=14,cP(t,i,o);case 14:return u=e.sent,e.abrupt("break",21);case 16:return e.next=18,xP(t);case 18:return u=e.sent,e.abrupt("break",21);case 20:rb(!1);case 21:return"data"===n&&(u=nP(u)),e.abrupt("return",u);case 23:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function MP(e){switch(e){case"auto":case"data":return function(){if(tP)return"imagebitmap";if(eP)return"image";if(sP)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return tP||eP||sP;case"imagebitmap":return tP;case"image":return eP;case"data":return sP;default:throw new Error("@loaders.gl/images: image ".concat(e," not supported in this environment"))}}(e),e}}var FP={id:"image",module:"images",name:"Images",version:"3.2.6",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:function(e,t,i){return CP.apply(this,arguments)},tests:[function(e){return Boolean(BP(new DataView(e)))}],options:{image:{type:"auto",decode:!0}}},EP=["image/png","image/jpeg","image/gif"],kP={};function IP(e){return void 0===kP[e]&&(kP[e]=function(e){switch(e){case"image/webp":return function(){if(!nb)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch(e){return!1}}();case"image/svg":return nb;default:if(!nb){var t=globalThis._parseImageNode;return Boolean(t)&&EP.includes(e)}return!0}}(e)),kP[e]}function DP(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function SP(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;var i=t.baseUri||t.uri;if(!i)throw new Error("'baseUri' must be provided to resolve relative url ".concat(e));return i.substr(0,i.lastIndexOf("/")+1)+e}function TP(e,t,i){var s=e.bufferViews[i];DP(s);var r=t[s.buffer];DP(r);var n=(s.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,n,s.byteLength)}var RP=["SCALAR","VEC2","VEC3","VEC4"],LP=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],UP=new Map(LP),OP={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},NP={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},QP={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function VP(e){return RP[e-1]||RP[0]}function HP(e){var t=UP.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function jP(e,t){var i=QP[e.componentType],s=OP[e.type],r=NP[e.componentType],n=e.count*s,o=e.count*s*r;return DP(o>=0&&o<=t.byteLength),{ArrayType:i,length:n,byteLength:o}}var GP,zP={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]},WP=function(){function e(t){x(this,e),pb(this,"gltf",void 0),pb(this,"sourceBuffers",void 0),pb(this,"byteLength",void 0),this.gltf=t||{json:n({},zP),buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}return C(e,[{key:"json",get:function(){return this.gltf.json}},{key:"getApplicationData",value:function(e){return this.json[e]}},{key:"getExtraData",value:function(e){return(this.json.extras||{})[e]}},{key:"getExtension",value:function(e){var t=this.getUsedExtensions().find((function(t){return t===e})),i=this.json.extensions||{};return t?i[e]||!0:null}},{key:"getRequiredExtension",value:function(e){var t=this.getRequiredExtensions().find((function(t){return t===e}));return t?this.getExtension(e):null}},{key:"getRequiredExtensions",value:function(){return this.json.extensionsRequired||[]}},{key:"getUsedExtensions",value:function(){return this.json.extensionsUsed||[]}},{key:"getObjectExtension",value:function(e,t){return(e.extensions||{})[t]}},{key:"getScene",value:function(e){return this.getObject("scenes",e)}},{key:"getNode",value:function(e){return this.getObject("nodes",e)}},{key:"getSkin",value:function(e){return this.getObject("skins",e)}},{key:"getMesh",value:function(e){return this.getObject("meshes",e)}},{key:"getMaterial",value:function(e){return this.getObject("materials",e)}},{key:"getAccessor",value:function(e){return this.getObject("accessors",e)}},{key:"getTexture",value:function(e){return this.getObject("textures",e)}},{key:"getSampler",value:function(e){return this.getObject("samplers",e)}},{key:"getImage",value:function(e){return this.getObject("images",e)}},{key:"getBufferView",value:function(e){return this.getObject("bufferViews",e)}},{key:"getBuffer",value:function(e){return this.getObject("buffers",e)}},{key:"getObject",value:function(e,t){if("object"===w(t))return t;var i=this.json[e]&&this.json[e][t];if(!i)throw new Error("glTF file error: Could not find ".concat(e,"[").concat(t,"]"));return i}},{key:"getTypedArrayForBufferView",value:function(e){var t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];DP(i);var s=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,s,e.byteLength)}},{key:"getTypedArrayForAccessor",value:function(e){e=this.getAccessor(e);var t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,s=jP(e,t),r=s.ArrayType,n=s.length;return new r(i,t.byteOffset+e.byteOffset,n)}},{key:"getTypedArrayForImageData",value:function(e){e=this.getAccessor(e);var t=this.getBufferView(e.bufferView),i=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(i,s,t.byteLength)}},{key:"addApplicationData",value:function(e,t){return this.json[e]=t,this}},{key:"addExtraData",value:function(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}},{key:"addObjectExtension",value:function(e,t,i){return e.extensions=e.extensions||{},e.extensions[t]=i,this.registerUsedExtension(t),this}},{key:"setObjectExtension",value:function(e,t,i){(e.extensions||{})[t]=i}},{key:"removeObjectExtension",value:function(e,t){var i=e.extensions||{},s=i[t];return delete i[t],s}},{key:"addExtension",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return DP(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}},{key:"addRequiredExtension",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return DP(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}},{key:"registerUsedExtension",value:function(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find((function(t){return t===e}))||this.json.extensionsUsed.push(e)}},{key:"registerRequiredExtension",value:function(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find((function(t){return t===e}))||this.json.extensionsRequired.push(e)}},{key:"removeExtension",value:function(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}},{key:"setDefaultScene",value:function(e){this.json.scene=e}},{key:"addScene",value:function(e){var t=e.nodeIndices;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}},{key:"addNode",value:function(e){var t=e.meshIndex,i=e.matrix;this.json.nodes=this.json.nodes||[];var s={mesh:t};return i&&(s.matrix=i),this.json.nodes.push(s),this.json.nodes.length-1}},{key:"addMesh",value:function(e){var t=e.attributes,i=e.indices,s=e.material,r=e.mode,n=void 0===r?4:r,o={primitives:[{attributes:this._addAttributes(t),mode:n}]};if(i){var a=this._addIndices(i);o.primitives[0].indices=a}return Number.isFinite(s)&&(o.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}},{key:"addPointCloud",value:function(e){var t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}},{key:"addImage",value:function(e,t){var i=BP(e),s=t||(null==i?void 0:i.mimeType),r={bufferView:this.addBufferView(e),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}},{key:"addBufferView",value:function(e){var t=e.byteLength;DP(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);var i={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=Xb(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}},{key:"addAccessor",value:function(e,t){var i={bufferView:e,type:VP(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}},{key:"addBinaryBuffer",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{size:3},i=this.addBufferView(e),s={min:t.min,max:t.max};s.min&&s.max||(s=this._getAccessorMinMax(e,t.size));var r={size:t.size,componentType:HP(e),count:Math.round(e.length/t.size),min:s.min,max:s.max};return this.addAccessor(i,Object.assign(r,t))}},{key:"addTexture",value:function(e){var t={source:e.imageIndex};return this.json.textures=this.json.textures||[],this.json.textures.push(t),this.json.textures.length-1}},{key:"addMaterial",value:function(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}},{key:"createBinaryChunk",value:function(){var e,t;this.gltf.buffers=[];var i,s=this.byteLength,r=new ArrayBuffer(s),n=new Uint8Array(r),o=0,a=c(this.sourceBuffers||[]);try{for(a.s();!(i=a.n()).done;){o=Jb(i.value,n,o)}}catch(e){a.e(e)}finally{a.f()}null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=s:this.json.buffers=[{byteLength:s}],this.gltf.binary=r,this.sourceBuffers=[r]}},{key:"_removeStringFromArray",value:function(e,t){for(var i=!0;i;){var s=e.indexOf(t);s>-1?e.splice(s,1):i=!1}}},{key:"_addAttributes",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={};for(var i in e){var s=e[i],r=this._getGltfAttributeName(i),n=this.addBinaryBuffer(s.value,s);t[r]=n}return t}},{key:"_addIndices",value:function(e){return this.addBinaryBuffer(e,{size:1})}},{key:"_getGltfAttributeName",value:function(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}},{key:"_getAccessorMinMax",value:function(e,t){var i={min:null,max:null};if(e.length5&&void 0!==u[5]?u[5]:"NONE",e.next=3,tC();case 3:oC(l=e.sent,l.exports[qP[n]],t,i,s,r,l.exports[ZP[o||"NONE"]]);case 5:case"end":return e.stop()}}),e)}))),eC.apply(this,arguments)}function tC(){return iC.apply(this,arguments)}function iC(){return(iC=u(a().mark((function e(){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return GP||(GP=sC()),e.abrupt("return",GP);case 2:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function sC(){return rC.apply(this,arguments)}function rC(){return(rC=u(a().mark((function e(){var t,i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=KP,WebAssembly.validate(JP)&&(t=XP,console.log("Warning: meshopt_decoder is using experimental SIMD support")),e.next=4,WebAssembly.instantiate(nC(t),{});case 4:return i=e.sent,e.next=7,i.instance.exports.__wasm_call_ctors();case 7:return e.abrupt("return",i.instance);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function nC(e){for(var t=new Uint8Array(e.length),i=0;i96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}for(var r=0,n=0;nr?A:r,n=c>n?c:n,o=h>o?h:o}return[[t,i,s],[r,n,o]]}var fC=function(){function e(t,i){x(this,e),pb(this,"fields",void 0),pb(this,"metadata",void 0),function(e,t){if(!e)throw new Error(t||"loader assertion failed.")}(Array.isArray(t)),function(e){var t,i={},s=c(e);try{for(s.s();!(t=s.n()).done;){var r=t.value;i[r.name]&&console.warn("Schema: duplicated field name",r.name,r),i[r.name]=!0}}catch(e){s.e(e)}finally{s.f()}}(t),this.fields=t,this.metadata=i||new Map}return C(e,[{key:"compareTo",value:function(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(var t=0;t2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Map;x(this,e),pb(this,"name",void 0),pb(this,"type",void 0),pb(this,"nullable",void 0),pb(this,"metadata",void 0),this.name=t,this.type=i,this.nullable=s,this.metadata=r}return C(e,[{key:"typeId",get:function(){return this.type&&this.type.typeId}},{key:"clone",value:function(){return new e(this.name,this.type,this.nullable,this.metadata)}},{key:"compareTo",value:function(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}},{key:"toString",value:function(){return"".concat(this.type).concat(this.nullable?", nullable":"").concat(this.metadata?", metadata: ".concat(this.metadata):"")}}]),e}();!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(gC||(gC={}));var _C=function(){function e(){x(this,e)}return C(e,[{key:"typeId",get:function(){return gC.NONE}},{key:"compareTo",value:function(e){return this===e}}],[{key:"isNull",value:function(e){return e&&e.typeId===gC.Null}},{key:"isInt",value:function(e){return e&&e.typeId===gC.Int}},{key:"isFloat",value:function(e){return e&&e.typeId===gC.Float}},{key:"isBinary",value:function(e){return e&&e.typeId===gC.Binary}},{key:"isUtf8",value:function(e){return e&&e.typeId===gC.Utf8}},{key:"isBool",value:function(e){return e&&e.typeId===gC.Bool}},{key:"isDecimal",value:function(e){return e&&e.typeId===gC.Decimal}},{key:"isDate",value:function(e){return e&&e.typeId===gC.Date}},{key:"isTime",value:function(e){return e&&e.typeId===gC.Time}},{key:"isTimestamp",value:function(e){return e&&e.typeId===gC.Timestamp}},{key:"isInterval",value:function(e){return e&&e.typeId===gC.Interval}},{key:"isList",value:function(e){return e&&e.typeId===gC.List}},{key:"isStruct",value:function(e){return e&&e.typeId===gC.Struct}},{key:"isUnion",value:function(e){return e&&e.typeId===gC.Union}},{key:"isFixedSizeBinary",value:function(e){return e&&e.typeId===gC.FixedSizeBinary}},{key:"isFixedSizeList",value:function(e){return e&&e.typeId===gC.FixedSizeList}},{key:"isMap",value:function(e){return e&&e.typeId===gC.Map}},{key:"isDictionary",value:function(e){return e&&e.typeId===gC.Dictionary}}]),e}(),yC=function(e,t){g(s,_C);var i=_(s);function s(e,t){var r;return x(this,s),pb(b(r=i.call(this)),"isSigned",void 0),pb(b(r),"bitWidth",void 0),r.isSigned=e,r.bitWidth=t,r}return C(s,[{key:"typeId",get:function(){return gC.Int}},{key:t,get:function(){return"Int"}},{key:"toString",value:function(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}}]),s}(0,Symbol.toStringTag),bC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!0,8)}return C(i)}(),BC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!0,16)}return C(i)}(),wC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!0,32)}return C(i)}(),xC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!1,8)}return C(i)}(),PC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!1,16)}return C(i)}(),CC=function(e){g(i,yC);var t=_(i);function i(){return x(this,i),t.call(this,!1,32)}return C(i)}(),MC=32,FC=64,EC=function(e,t){g(s,_C);var i=_(s);function s(e){var t;return x(this,s),pb(b(t=i.call(this)),"precision",void 0),t.precision=e,t}return C(s,[{key:"typeId",get:function(){return gC.Float}},{key:t,get:function(){return"Float"}},{key:"toString",value:function(){return"Float".concat(this.precision)}}]),s}(0,Symbol.toStringTag),kC=function(e){g(i,EC);var t=_(i);function i(){return x(this,i),t.call(this,MC)}return C(i)}(),IC=function(e){g(i,EC);var t=_(i);function i(){return x(this,i),t.call(this,FC)}return C(i)}(),DC=function(e,t){g(s,_C);var i=_(s);function s(e,t){var r;return x(this,s),pb(b(r=i.call(this)),"listSize",void 0),pb(b(r),"children",void 0),r.listSize=e,r.children=[t],r}return C(s,[{key:"typeId",get:function(){return gC.FixedSizeList}},{key:"valueType",get:function(){return this.children[0].type}},{key:"valueField",get:function(){return this.children[0]}},{key:t,get:function(){return"FixedSizeList"}},{key:"toString",value:function(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}}]),s}(0,Symbol.toStringTag);function SC(e,t,i){var s=function(e){switch(e.constructor){case Int8Array:return new bC;case Uint8Array:return new xC;case Int16Array:return new BC;case Uint16Array:return new PC;case Int32Array:return new wC;case Uint32Array:return new CC;case Float32Array:return new kC;case Float64Array:return new IC;default:throw new Error("array type not supported")}}(t.value),r=i||function(e){var t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new mC(e,new DC(t.size,new mC("value",s)),!1,r)}function TC(e,t,i){var s=LC(t.metadata),r=[],n=function(e){var t={};for(var i in e){var s=e[i];t[s.name||"undefined"]=s}return t}(t.attributes);for(var o in e){var a=RC(o,e[o],n[o]);r.push(a)}if(i){var l=RC("indices",i);r.push(l)}return new fC(r,s)}function RC(e,t,i){return SC(e,t,i?LC(i.metadata):void 0)}function LC(e){var t=new Map;for(var i in e)t.set("".concat(i,".string"),JSON.stringify(e[i]));return t}var UC={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},OC={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},NC=function(){function e(t){x(this,e),pb(this,"draco",void 0),pb(this,"decoder",void 0),pb(this,"metadataQuerier",void 0),this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}return C(e,[{key:"destroy",value:function(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}},{key:"parseSync",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);var s=this.decoder.GetEncodedGeometryType(i),r=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{var o;switch(s){case this.draco.TRIANGULAR_MESH:o=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:o=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!o.ok()||!r.ptr){var a="DRACO decompression failed: ".concat(o.error_msg());throw new Error(a)}var l=this._getDracoLoaderData(r,s,t),u=this._getMeshData(r,l,t),A=pC(u.attributes),c=TC(u.attributes,l,u.indices),h=n(n({loader:"draco",loaderData:l,header:{vertexCount:r.num_points(),boundingBox:A}},u),{},{schema:c});return h}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}},{key:"_getDracoLoaderData",value:function(e,t,i){var s=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:s,attributes:r}}},{key:"_getDracoAttributes",value:function(e,t){for(var i={},s=0;s2&&void 0!==arguments[2]&&arguments[2];if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),s=t.length/i);return{buffer:t,size:i,count:s}}(e),i=t.buffer,s=t.size;return{value:i,size:s,byteOffset:0,count:t.count,type:VP(s),componentType:HP(i)}}function $C(){return($C=u(a().mark((function e(t,i,s){var r,n,o,l,u,A;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=i&&null!==(r=i.gltf)&&void 0!==r&&r.decompressMeshes){e.next=2;break}return e.abrupt("return");case 2:n=new WP(t),o=[],l=c(rM(n));try{for(l.s();!(u=l.n()).done;)A=u.value,n.getObjectExtension(A,"KHR_draco_mesh_compression")&&o.push(eM(n,A,i,s))}catch(e){l.e(e)}finally{l.f()}return e.next=8,Promise.all(o);case 8:n.removeExtension("KHR_draco_mesh_compression");case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function eM(e,t,i,s){return tM.apply(this,arguments)}function tM(){return tM=u(a().mark((function e(t,i,s,r){var o,l,u,A,c,d,p,f,v,g,m,_,y,b;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t.getObjectExtension(i,"KHR_draco_mesh_compression")){e.next=3;break}return e.abrupt("return");case 3:return l=t.getTypedArrayForBufferView(o.bufferView),u=Kb(l.buffer,l.byteOffset),A=r.parse,delete(c=n({},s))["3d-tiles"],e.next=10,A(u,JC,c,r);case 10:for(d=e.sent,p=ZC(d.attributes),f=0,v=Object.entries(p);f2&&void 0!==arguments[2]?arguments[2]:4,r=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");var a=r.DracoWriter.encodeSync({attributes:e}),l=null==n||null===(i=n.parseSync)||void 0===i?void 0:i.call(n,{attributes:e}),u=r._addFauxAttributes(l.attributes),A=r.addBufferView(a),c={primitives:[{attributes:u,mode:s,extensions:o({},"KHR_draco_mesh_compression",{bufferView:A,attributes:u})}]};return c}function sM(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function rM(e){var t,i,r,n,o,l;return a().wrap((function(s){for(;;)switch(s.prev=s.next){case 0:t=c(e.json.meshes||[]),s.prev=1,t.s();case 3:if((i=t.n()).done){s.next=24;break}r=i.value,n=c(r.primitives),s.prev=6,n.s();case 8:if((o=n.n()).done){s.next=14;break}return l=o.value,s.next=12,l;case 12:s.next=8;break;case 14:s.next=19;break;case 16:s.prev=16,s.t0=s.catch(6),n.e(s.t0);case 19:return s.prev=19,n.f(),s.finish(19);case 22:s.next=3;break;case 24:s.next=29;break;case 26:s.prev=26,s.t1=s.catch(1),t.e(s.t1);case 29:return s.prev=29,t.f(),s.finish(29);case 32:case"end":return s.stop()}}),s,null,[[1,26,29,32],[6,16,19,22]])}function nM(){return(nM=u(a().mark((function e(t){var i,s,r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new WP(t),s=i.json,(r=i.getExtension("KHR_lights_punctual"))&&(i.json.lights=r.lights,i.removeExtension("KHR_lights_punctual")),n=c(s.nodes||[]);try{for(n.s();!(o=n.n()).done;)l=o.value,(u=i.getObjectExtension(l,"KHR_lights_punctual"))&&(l.light=u.light),i.removeObjectExtension(l,"KHR_lights_punctual")}catch(e){n.e(e)}finally{n.f()}case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oM(){return(oM=u(a().mark((function e(t){var i,s,r,n,o,l,u;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=new WP(t),(s=i.json).lights&&(DP(!(r=i.addExtension("KHR_lights_punctual")).lights),r.lights=s.lights,delete s.lights),i.json.lights){n=c(i.json.lights);try{for(n.s();!(o=n.n()).done;)l=o.value,u=l.node,i.addObjectExtension(u,"KHR_lights_punctual",l)}catch(e){n.e(e)}finally{n.f()}delete i.json.lights}case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function aM(){return(aM=u(a().mark((function e(t){var i,s,r,n,o;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=new WP(t),s=i.json,i.removeExtension("KHR_materials_unlit"),r=c(s.materials||[]);try{for(r.s();!(n=r.n()).done;)o=n.value,o.extensions&&o.extensions.KHR_materials_unlit&&(o.unlit=!0),i.removeObjectExtension(o,"KHR_materials_unlit")}catch(e){r.e(e)}finally{r.f()}case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function lM(){return(lM=u(a().mark((function e(t){var i,s,r,n,o,l,u,A;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=new WP(t),s=i.json,r=i.getExtension("KHR_techniques_webgl")){n=AM(r,i),o=c(s.materials||[]);try{for(o.s();!(l=o.n()).done;)u=l.value,(A=i.getObjectExtension(u,"KHR_techniques_webgl"))&&(u.technique=Object.assign({},A,n[A.technique]),u.technique.values=cM(u.technique,i)),i.removeObjectExtension(u,"KHR_techniques_webgl")}catch(e){o.e(e)}finally{o.f()}i.removeExtension("KHR_techniques_webgl")}case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function uM(){return(uM=u(a().mark((function e(t,i){return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function AM(e,t){var i=e.programs,s=void 0===i?[]:i,r=e.shaders,n=void 0===r?[]:r,o=e.techniques,a=void 0===o?[]:o,l=new TextDecoder;return n.forEach((function(e){if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=l.decode(t.getTypedArrayForBufferView(e.bufferView))})),s.forEach((function(e){e.fragmentShader=n[e.fragmentShader],e.vertexShader=n[e.vertexShader]})),a.forEach((function(e){e.program=s[e.program]})),a}function cM(e,t){var i=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach((function(t){e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)})),Object.keys(i).forEach((function(e){"object"===w(i[e])&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))})),i}var hM=[AC,cC,hC,Object.freeze({__proto__:null,name:"KHR_draco_mesh_compression",preprocess:function(e,t,i){var s,r=new WP(e),n=c(rM(r));try{for(n.s();!(s=n.n()).done;){var o=s.value;r.getObjectExtension(o,"KHR_draco_mesh_compression")}}catch(e){n.e(e)}finally{n.f()}},decode:function(e,t,i){return $C.apply(this,arguments)},encode:function(e){var t,i=new WP(e),s=c(i.json.meshes||[]);try{for(s.s();!(t=s.n()).done;){var r=t.value;iM(r),i.addRequiredExtension("KHR_draco_mesh_compression")}}catch(e){s.e(e)}finally{s.f()}}}),Object.freeze({__proto__:null,name:"KHR_lights_punctual",decode:function(e){return nM.apply(this,arguments)},encode:function(e){return oM.apply(this,arguments)}}),Object.freeze({__proto__:null,name:"KHR_materials_unlit",decode:function(e){return aM.apply(this,arguments)},encode:function(e){var t=new WP(e),i=t.json;if(t.materials){var s,r=c(i.materials||[]);try{for(r.s();!(s=r.n()).done;){var n=s.value;n.unlit&&(delete n.unlit,t.addObjectExtension(n,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}}catch(e){r.e(e)}finally{r.f()}}}}),Object.freeze({__proto__:null,name:"KHR_techniques_webgl",decode:function(e){return lM.apply(this,arguments)},encode:function(e,t){return uM.apply(this,arguments)}})];function dM(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0,r=hM.filter((function(e){return vM(e.name,i)})),n=c(r);try{for(n.s();!(t=n.n()).done;){var o,a=t.value;null===(o=a.preprocess)||void 0===o||o.call(a,e,i,s)}}catch(e){n.e(e)}finally{n.f()}}function pM(e){return fM.apply(this,arguments)}function fM(){return fM=u(a().mark((function e(t){var i,s,r,n,o,l,u,A=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=A.length>1&&void 0!==A[1]?A[1]:{},s=A.length>2?A[2]:void 0,r=hM.filter((function(e){return vM(e.name,i)})),n=c(r),e.prev=4,n.s();case 6:if((o=n.n()).done){e.next=12;break}return l=o.value,e.next=10,null===(u=l.decode)||void 0===u?void 0:u.call(l,t,i,s);case 10:e.next=6;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(4),n.e(e.t0);case 17:return e.prev=17,n.f(),e.finish(17);case 20:case"end":return e.stop()}}),e,null,[[4,14,17,20]])}))),fM.apply(this,arguments)}function vM(e,t){var i,s=(null==t||null===(i=t.gltf)||void 0===i?void 0:i.excludeExtensions)||{};return!(e in s&&!s[e])}var gM={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},mM={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},_M=function(){function e(){x(this,e),pb(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),pb(this,"json",void 0)}return C(e,[{key:"normalize",value:function(e,t){this.json=e.json;var i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version ".concat(i.asset.version))}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){var t,i=new WP(e),s=i.json,r=c(s.images||[]);try{for(r.s();!(t=r.n()).done;){var n=t.value,o=i.getObjectExtension(n,"KHR_binary_glTF");o&&Object.assign(n,o),i.removeObjectExtension(n,"KHR_binary_glTF")}}catch(e){r.e(e)}finally{r.f()}s.buffers&&s.buffers[0]&&delete s.buffers[0].uri,i.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}},{key:"_addAsset",value:function(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}},{key:"_convertTopLevelObjectsToArrays",value:function(e){for(var t in gM)this._convertTopLevelObjectToArray(e,t)}},{key:"_convertTopLevelObjectToArray",value:function(e,t){var i=e[t];if(i&&!Array.isArray(i))for(var s in e[t]=[],i){var r=i[s];r.id=r.id||s;var n=e[t].length;e[t].push(r),this.idToIndexMap[t][s]=n}}},{key:"_convertObjectIdsToArrayIndices",value:function(e){for(var t in gM)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));var i,s=c(e.textures);try{for(s.s();!(i=s.n()).done;){var r=i.value;this._convertTextureIds(r)}}catch(e){s.e(e)}finally{s.f()}var n,o=c(e.meshes);try{for(o.s();!(n=o.n()).done;){var a=n.value;this._convertMeshIds(a)}}catch(e){o.e(e)}finally{o.f()}var l,u=c(e.nodes);try{for(u.s();!(l=u.n()).done;){var A=l.value;this._convertNodeIds(A)}}catch(e){u.e(e)}finally{u.f()}var h,d=c(e.scenes);try{for(d.s();!(h=d.n()).done;){var p=h.value;this._convertSceneIds(p)}}catch(e){d.e(e)}finally{d.f()}}},{key:"_convertTextureIds",value:function(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}},{key:"_convertMeshIds",value:function(e){var t,i=c(e.primitives);try{for(i.s();!(t=i.n()).done;){var s=t.value,r=s.attributes,n=s.indices,o=s.material;for(var a in r)r[a]=this._convertIdToIndex(r[a],"accessor");n&&(s.indices=this._convertIdToIndex(n,"accessor")),o&&(s.material=this._convertIdToIndex(o,"material"))}}catch(e){i.e(e)}finally{i.f()}}},{key:"_convertNodeIds",value:function(e){var t=this;e.children&&(e.children=e.children.map((function(e){return t._convertIdToIndex(e,"node")}))),e.meshes&&(e.meshes=e.meshes.map((function(e){return t._convertIdToIndex(e,"mesh")})))}},{key:"_convertSceneIds",value:function(e){var t=this;e.nodes&&(e.nodes=e.nodes.map((function(e){return t._convertIdToIndex(e,"node")})))}},{key:"_convertIdsToIndices",value:function(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute ".concat(t)),e[t]=[]);var i,s=c(e[t]);try{for(s.s();!(i=s.n()).done;){var r=i.value;for(var n in r){var o=r[n],a=this._convertIdToIndex(o,n);r[n]=a}}}catch(e){s.e(e)}finally{s.f()}}},{key:"_convertIdToIndex",value:function(e,t){var i=mM[t];if(i in this.idToIndexMap){var s=this.idToIndexMap[i][e];if(!Number.isFinite(s))throw new Error("gltf v1: failed to resolve ".concat(t," with id ").concat(e));return s}return e}},{key:"_updateObjects",value:function(e){var t,i=c(this.json.buffers);try{for(i.s();!(t=i.n()).done;){delete t.value.type}}catch(e){i.e(e)}finally{i.f()}}},{key:"_updateMaterial",value:function(e){var t,i=c(e.materials);try{var s=function(){var i=t.value;i.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};var s=(null===(r=i.values)||void 0===r?void 0:r.tex)||(null===(n=i.values)||void 0===n?void 0:n.texture2d_0),o=e.textures.findIndex((function(e){return e.id===s}));-1!==o&&(i.pbrMetallicRoughness.baseColorTexture={index:o})};for(i.s();!(t=i.n()).done;){var r,n;s()}}catch(e){i.e(e)}finally{i.f()}}}]),e}();function yM(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(new _M).normalize(e,t)}var bM={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},BM={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},wM=10240,xM=10241,PM=10242,CM=10243,MM=10497,FM=9986,EM={magFilter:wM,minFilter:xM,wrapS:PM,wrapT:CM},kM=(o(e={},wM,9729),o(e,xM,FM),o(e,PM,MM),o(e,CM,MM),e);var IM=function(){function e(){x(this,e),pb(this,"baseUri",""),pb(this,"json",{}),pb(this,"buffers",[]),pb(this,"images",[])}return C(e,[{key:"postProcess",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e.json,s=e.buffers,r=void 0===s?[]:s,n=e.images,o=void 0===n?[]:n,a=e.baseUri,l=void 0===a?"":a;return DP(i),this.baseUri=l,this.json=i,this.buffers=r,this.images=o,this._resolveTree(this.json,t),this.json}},{key:"_resolveTree",value:function(e){var t=this;e.bufferViews&&(e.bufferViews=e.bufferViews.map((function(e,i){return t._resolveBufferView(e,i)}))),e.images&&(e.images=e.images.map((function(e,i){return t._resolveImage(e,i)}))),e.samplers&&(e.samplers=e.samplers.map((function(e,i){return t._resolveSampler(e,i)}))),e.textures&&(e.textures=e.textures.map((function(e,i){return t._resolveTexture(e,i)}))),e.accessors&&(e.accessors=e.accessors.map((function(e,i){return t._resolveAccessor(e,i)}))),e.materials&&(e.materials=e.materials.map((function(e,i){return t._resolveMaterial(e,i)}))),e.meshes&&(e.meshes=e.meshes.map((function(e,i){return t._resolveMesh(e,i)}))),e.nodes&&(e.nodes=e.nodes.map((function(e,i){return t._resolveNode(e,i)}))),e.skins&&(e.skins=e.skins.map((function(e,i){return t._resolveSkin(e,i)}))),e.scenes&&(e.scenes=e.scenes.map((function(e,i){return t._resolveScene(e,i)}))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}},{key:"getScene",value:function(e){return this._get("scenes",e)}},{key:"getNode",value:function(e){return this._get("nodes",e)}},{key:"getSkin",value:function(e){return this._get("skins",e)}},{key:"getMesh",value:function(e){return this._get("meshes",e)}},{key:"getMaterial",value:function(e){return this._get("materials",e)}},{key:"getAccessor",value:function(e){return this._get("accessors",e)}},{key:"getCamera",value:function(e){return null}},{key:"getTexture",value:function(e){return this._get("textures",e)}},{key:"getSampler",value:function(e){return this._get("samplers",e)}},{key:"getImage",value:function(e){return this._get("images",e)}},{key:"getBufferView",value:function(e){return this._get("bufferViews",e)}},{key:"getBuffer",value:function(e){return this._get("buffers",e)}},{key:"_get",value:function(e,t){if("object"===w(t))return t;var i=this.json[e]&&this.json[e][t];return i||console.warn("glTF file error: Could not find ".concat(e,"[").concat(t,"]")),i}},{key:"_resolveScene",value:function(e,t){var i=this;return e.id=e.id||"scene-".concat(t),e.nodes=(e.nodes||[]).map((function(e){return i.getNode(e)})),e}},{key:"_resolveNode",value:function(e,t){var i=this;return e.id=e.id||"node-".concat(t),e.children&&(e.children=e.children.map((function(e){return i.getNode(e)}))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce((function(e,t){var s=i.getMesh(t);return e.id=s.id,e.primitives=e.primitives.concat(s.primitives),e}),{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}},{key:"_resolveSkin",value:function(e,t){return e.id=e.id||"skin-".concat(t),e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}},{key:"_resolveMesh",value:function(e,t){var i=this;return e.id=e.id||"mesh-".concat(t),e.primitives&&(e.primitives=e.primitives.map((function(e){var t=(e=n({},e)).attributes;for(var s in e.attributes={},t)e.attributes[s]=i.getAccessor(t[s]);return void 0!==e.indices&&(e.indices=i.getAccessor(e.indices)),void 0!==e.material&&(e.material=i.getMaterial(e.material)),e}))),e}},{key:"_resolveMaterial",value:function(e,t){if(e.id=e.id||"material-".concat(t),e.normalTexture&&(e.normalTexture=n({},e.normalTexture),e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture=n({},e.occlustionTexture),e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture=n({},e.emmisiveTexture),e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness=n({},e.pbrMetallicRoughness);var i=e.pbrMetallicRoughness;i.baseColorTexture&&(i.baseColorTexture=n({},i.baseColorTexture),i.baseColorTexture.texture=this.getTexture(i.baseColorTexture.index)),i.metallicRoughnessTexture&&(i.metallicRoughnessTexture=n({},i.metallicRoughnessTexture),i.metallicRoughnessTexture.texture=this.getTexture(i.metallicRoughnessTexture.index))}return e}},{key:"_resolveAccessor",value:function(e,t){var i,s;if(e.id=e.id||"accessor-".concat(t),void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(i=e.componentType,BM[i]),e.components=(s=e.type,bM[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){var r=e.bufferView.buffer,n=jP(e,e.bufferView),o=n.ArrayType,a=n.byteLength,l=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+r.byteOffset,u=r.arrayBuffer.slice(l,l+a);e.bufferView.byteStride&&(u=this._getValueFromInterleavedBuffer(r,l,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new o(u)}return e}},{key:"_getValueFromInterleavedBuffer",value:function(e,t,i,s,r){for(var n=new Uint8Array(r*s),o=0;o1&&void 0!==arguments[1]?arguments[1]:0;return"".concat(String.fromCharCode(e.getUint8(t+0))).concat(String.fromCharCode(e.getUint8(t+1))).concat(String.fromCharCode(e.getUint8(t+2))).concat(String.fromCharCode(e.getUint8(t+3)))}function RM(e,t,i){rb(e.header.byteLength>20);var s=t.getUint32(i+0,SM),r=t.getUint32(i+4,SM);return i+=8,rb(0===r),UM(e,t,i,s),i+=s,i+=OM(e,t,i,e.header.byteLength)}function LM(e,t,i,s){return rb(e.header.byteLength>20),function(e,t,i,s){for(;i+8<=e.header.byteLength;){var r=t.getUint32(i+0,SM),n=t.getUint32(i+4,SM);switch(i+=8,n){case 1313821514:UM(e,t,i,r);break;case 5130562:OM(e,t,i,r);break;case 0:s.strict||UM(e,t,i,r);break;case 1:s.strict||OM(e,t,i,r)}i+=Xb(r,4)}}(e,t,i,s),i+e.header.byteLength}function UM(e,t,i,s){var r=new Uint8Array(t.buffer,i,s),n=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(n),Xb(s,4)}function OM(e,t,i,s){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:s,arrayBuffer:t.buffer}),Xb(s,4)}function NM(e,t){return QM.apply(this,arguments)}function QM(){return QM=u(a().mark((function e(t,i){var s,r,n,o,l,u,A,c,h,d,p=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=p.length>2&&void 0!==p[2]?p[2]:0,r=p.length>3?p[3]:void 0,n=p.length>4?p[4]:void 0,VM(t,i,s,r),yM(t,{normalize:null==r||null===(o=r.gltf)||void 0===o?void 0:o.normalize}),dM(t,r,n),c=[],null==r||null===(l=r.gltf)||void 0===l||!l.loadBuffers||!t.json.buffers){e.next=10;break}return e.next=10,HM(t,r,n);case 10:return null!=r&&null!==(u=r.gltf)&&void 0!==u&&u.loadImages&&(h=GM(t,r,n),c.push(h)),d=pM(t,r,n),c.push(d),e.next=15,Promise.all(c);case 15:return e.abrupt("return",null!=r&&null!==(A=r.gltf)&&void 0!==A&&A.postProcess?DM(t,r):t);case 16:case"end":return e.stop()}}),e)}))),QM.apply(this,arguments)}function VM(e,t,i,s){(s.uri&&(e.baseUri=s.uri),t instanceof ArrayBuffer&&!function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=new DataView(e),r=i.magic,n=void 0===r?1735152710:r,o=s.getUint32(t,!1);return o===n||1735152710===o}(t,i,s))&&(t=(new TextDecoder).decode(t));if("string"==typeof t)e.json=jb(t);else if(t instanceof ArrayBuffer){var r={};i=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=new DataView(t),r=TM(s,i+0),n=s.getUint32(i+4,SM),o=s.getUint32(i+8,SM);switch(Object.assign(e,{header:{byteOffset:i,byteLength:o,hasBinChunk:!1},type:r,version:n,json:{},binChunks:[]}),i+=12,e.version){case 1:return RM(e,s,i);case 2:return LM(e,s,i,{});default:throw new Error("Invalid GLB version ".concat(e.version,". Only supports v1 and v2."))}}(r,t,i,s.glb),DP("glTF"===r.type,"Invalid GLB magic string ".concat(r.type)),e._glb=r,e.json=r.json}else DP(!1,"GLTF: must be ArrayBuffer or string");var n=e.json.buffers||[];if(e.buffers=new Array(n.length).fill(null),e._glb&&e._glb.header.hasBinChunk){var o=e._glb.binChunks;e.buffers[0]={arrayBuffer:o[0].arrayBuffer,byteOffset:o[0].byteOffset,byteLength:o[0].byteLength}}var a=e.json.images||[];e.images=new Array(a.length).fill({})}function HM(e,t,i){return jM.apply(this,arguments)}function jM(){return(jM=u(a().mark((function e(t,i,s){var r,n,o,l,u,A,c,h;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.json.buffers||[],n=0;case 2:if(!(n1&&void 0!==u[1]?u[1]:{},s=u.length>2?u[2]:void 0,(i=n(n({},JM.options),i)).gltf=n(n({},JM.options.gltf),i.gltf),r=i.byteOffset,o=void 0===r?0:r,l={},e.next=8,NM(l,t,o,i,s);case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e)}))),YM.apply(this,arguments)}var ZM=function(){function e(t){x(this,e)}return C(e,[{key:"load",value:function(e,t,i,s,r,n,o){!function(e,t,i,s,r,n,o){var a=e.viewer.scene.canvas.spinner;a.processes++,"glb"===t.split(".").pop()?e.dataSource.getGLB(t,(function(o){s.basePath=$M(t),eF(e,t,o,i,s,r,n),a.processes--}),(function(e){a.processes--,o(e)})):e.dataSource.getGLTF(t,(function(o){s.basePath=$M(t),eF(e,t,o,i,s,r,n),a.processes--}),(function(e){a.processes--,o(e)}))}(e,t,i,s=s||{},r,(function(){_e.scheduleTask((function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1)})),n&&n()}),(function(t){e.error(t),o&&o(t),r.fire("error",t)}))}},{key:"parse",value:function(e,t,i,s,r,n,o){eF(e,"",t,i,s=s||{},r,(function(){r.scene.fire("modelLoaded",r.id),r.fire("loaded",!0,!1),n&&n()}))}}]),e}();function qM(e){for(var t={},i={},s=e.metaObjects||[],r={},n=0,o=s.length;n0)for(var A=0;A0){null==y&&e.log("Warning: 'name' properties not found on glTF scene nodes - will randomly-generate object IDs in XKT");var b=y;if(e.metaModelCorrections){var B=e.metaModelCorrections.eachChildRoot[b];if(B){var w=e.metaModelCorrections.eachRootStats[B.id];w.countChildren++,w.countChildren>=w.numChildren&&(n.createEntity({id:B.id,meshIds:nF}),nF.length=0)}else{e.metaModelCorrections.metaObjectsMap[b]&&(n.createEntity({id:b,meshIds:nF}),nF.length=0)}}else n.createEntity({id:b,meshIds:nF}),nF.length=0}}function aF(e,t){e.plugin.error(t)}var lF={DEFAULT:{}},uF=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"GLTFLoader",e,r))._sceneModelLoader=new ZM(b(s),r),s.dataSource=r.dataSource,s.objectDefaults=r.objectDefaults,s}return C(i,[{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new Ih}},{key:"objectDefaults",get:function(){return this._objectDefaults},set:function(e){this._objectDefaults=e||lF}},{key:"load",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.id&&this.viewer.scene.components[t.id]&&(this.error("Component with this ID already exists in viewer: "+t.id+" - will autogenerate this ID"),delete t.id);var i=new Ah(this.viewer.scene,le.apply(t,{isModel:!0,dtxEnabled:t.dtxEnabled})),s=i.id;if(!t.src&&!t.gltf)return this.error("load() param expected: src or gltf"),i;if(t.metaModelSrc||t.metaModelJSON){var r=t.objectDefaults||this._objectDefaults||lF,n=function(n){var o;if(e.viewer.metaScene.createMetaModel(s,n,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes}),e.viewer.scene.canvas.spinner.processes--,t.includeTypes){o={};for(var a=0,l=t.includeTypes.length;a2&&void 0!==arguments[2]?arguments[2]:{},s="lightgrey",r=i.hoverColor||"rgba(0,0,0,0.4)",n=i.textColor||"black",o=500,a=o+o/3,l=a/24,u=[{boundary:[6,6,6,6],color:i.frontColor||i.color||"#55FF55"},{boundary:[18,6,6,6],color:i.backColor||i.color||"#55FF55"},{boundary:[12,6,6,6],color:i.rightColor||i.color||"#FF5555"},{boundary:[0,6,6,6],color:i.leftColor||i.color||"#FF5555"},{boundary:[6,0,6,6],color:i.topColor||i.color||"#7777FF"},{boundary:[6,12,6,6],color:i.bottomColor||i.color||"#7777FF"}],A=[{label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,1,0],up:[0,0,1]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,-1,0],up:[0,0,1]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,0,1]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,0,1]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,0,1],up:[0,-1,0]},{boundaries:[[7,5,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,0,-1],up:[1,0,1]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-1,-1],up:[0,-1,1]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,0,-1],up:[-1,0,1]},{boundaries:[[7,11,4,2]],dir:[0,1,1],up:[0,-1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,0,1],up:[-1,0,1]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,-1,1],up:[0,1,1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,0,1],up:[1,0,1]},{boundaries:[[5,7,2,4]],dir:[1,1,0],up:[0,0,1]},{boundaries:[[11,7,2,4]],dir:[-1,1,0],up:[0,0,1]},{boundaries:[[17,7,2,4]],dir:[-1,-1,0],up:[0,0,1]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,-1,0],up:[0,0,1]},{boundaries:[[5,11,2,2]],dir:[1,1,1],up:[-1,-1,1]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[1,-1,1],up:[-1,1,1]},{boundaries:[[5,5,2,2]],dir:[1,1,-1],up:[1,1,1]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-1,-1,1],up:[1,1,1]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-1,-1,-1],up:[-1,-1,1]},{boundaries:[[11,11,2,2]],dir:[-1,1,1],up:[1,-1,1]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[1,-1,-1],up:[1,-1,1]},{boundaries:[[11,5,2,2]],dir:[-1,1,-1],up:[-1,1,1]}];i.frontColor||i.color,i.backColor||i.color,i.rightColor||i.color,i.leftColor||i.color,i.topColor||i.color,i.bottomColor||i.color;for(var c=[{yUp:"",label:"NavCube.front",boundaries:[[7,7,4,4]],dir:[0,0,-1],up:[0,1,0]},{label:"NavCube.back",boundaries:[[19,7,4,4]],dir:[0,0,1],up:[0,1,0]},{label:"NavCube.right",boundaries:[[13,7,4,4]],dir:[-1,0,0],up:[0,1,0]},{label:"NavCube.left",boundaries:[[1,7,4,4]],dir:[1,0,0],up:[0,1,0]},{label:"NavCube.top",boundaries:[[7,1,4,4]],dir:[0,-1,0],up:[0,0,-1]},{label:"NavCube.bottom",boundaries:[[7,13,4,4]],dir:[0,1,0],up:[0,0,1]},{boundaries:[[7,5,4,2]],dir:[0,-.7071,-.7071],up:[0,.7071,-.7071]},{boundaries:[[1,6,4,1],[6,1,1,4]],dir:[1,-1,0],up:[1,1,0]},{boundaries:[[7,0,4,1],[19,6,4,1]],dir:[0,-.7071,.7071],up:[0,.7071,.7071]},{boundaries:[[13,6,4,1],[11,1,1,4]],dir:[-1,-1,0],up:[-1,1,0]},{boundaries:[[7,11,4,2]],dir:[0,1,-1],up:[0,1,1]},{boundaries:[[1,11,4,1],[6,13,1,4]],dir:[1,1,0],up:[-1,1,0]},{boundaries:[[7,17,4,1],[19,11,4,1]],dir:[0,1,1],up:[0,1,-1]},{boundaries:[[13,11,4,1],[11,13,1,4]],dir:[-1,1,0],up:[1,1,0]},{boundaries:[[5,7,2,4]],dir:[1,0,-1],up:[0,1,0]},{boundaries:[[11,7,2,4]],dir:[-1,0,-1],up:[0,1,0]},{boundaries:[[17,7,2,4]],dir:[-1,0,1],up:[0,1,0]},{boundaries:[[0,7,1,4],[23,7,1,4]],dir:[1,0,1],up:[0,1,0]},{boundaries:[[5,11,2,2]],dir:[.5,.7071,-.5],up:[-.5,.7071,.5]},{boundaries:[[23,11,1,1],[6,17,1,1],[0,11,1,1]],dir:[.5,.7071,.5],up:[-.5,.7071,-.5]},{boundaries:[[5,5,2,2]],dir:[.5,-.7071,-.5],up:[.5,.7071,-.5]},{boundaries:[[11,17,1,1],[17,11,2,1]],dir:[-.5,.7071,.5],up:[.5,.7071,-.5]},{boundaries:[[17,6,2,1],[11,0,1,1]],dir:[-.5,-.7071,.5],up:[-.5,.7071,.5]},{boundaries:[[11,11,2,2]],dir:[-.5,.7071,-.5],up:[.5,.7071,.5]},{boundaries:[[0,6,1,1],[6,0,1,1],[23,6,1,1]],dir:[.5,-.7071,.5],up:[.5,.7071,.5]},{boundaries:[[11,5,2,2]],dir:[-.5,-.7071,-.5],up:[-.5,.7071,-.5]}],h=0,d=A.length;h=c[0]*l&&t<=(c[0]+c[2])*l&&i>=c[1]*l&&i<=(c[1]+c[3])*l)return s}return-1},this.setAreaHighlighted=function(e,t){var i=v[e];if(!i)throw"Area not found: "+e;i.highlighted=!!t,y()},this.getAreaDir=function(e){var t=v[e];if(!t)throw"Unknown area: "+e;return t.dir},this.getAreaUp=function(e){var t=v[e];if(!t)throw"Unknown area: "+e;return t.up},this.getImage=function(){return this._textureCanvas},this.destroy=function(){this._textureCanvas&&(this._textureCanvas.parentNode.removeChild(this._textureCanvas),this._textureCanvas=null)}}var cF=$.vec3(),hF=$.vec3();$.mat4();var dF=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),s=t.call(this,"NavCube",e,r),e.navCube=b(s);var n=!0;try{s._navCubeScene=new Zi(e,{canvasId:r.canvasId,canvasElement:r.canvasElement,transparent:!0}),s._navCubeCanvas=s._navCubeScene.canvas.canvas,s._navCubeScene.input.keyboardEnabled=!1}catch(e){return s.error(e),y(s)}var o=s._navCubeScene;o.clearLights(),new yi(o,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new yi(o,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new yi(o,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),s._navCubeCamera=o.camera,s._navCubeCamera.ortho.scale=7,s._navCubeCamera.ortho.near=.1,s._navCubeCamera.ortho.far=2e3,o.edgeMaterial.edgeColor=[.2,.2,.2],o.edgeMaterial.edgeAlpha=.6,s._zUp=Boolean(e.camera.zUp);var a=b(s);s.setIsProjectNorth(r.isProjectNorth),s.setProjectNorthOffsetAngle(r.projectNorthOffsetAngle);var l,u=(l=$.mat4(),function(e,t,i){return $.identityMat4(l),$.rotationMat4v(e*a._projectNorthOffsetAngle*$.DEGTORAD,[0,1,0],l),$.transformVec3(l,t,i)});s._synchCamera=function(){var t=$.rotationMat4c(-90*$.DEGTORAD,1,0,0),i=$.vec3(),s=$.vec3(),r=$.vec3();return function(){var n=e.camera.eye,o=e.camera.look,l=e.camera.up;i=$.mulVec3Scalar($.normalizeVec3($.subVec3(n,o,i)),5),a._isProjectNorth&&a._projectNorthOffsetAngle&&(i=u(-1,i,cF),l=u(-1,l,hF)),a._zUp?($.transformVec3(t,i,s),$.transformVec3(t,l,r),a._navCubeCamera.look=[0,0,0],a._navCubeCamera.eye=$.transformVec3(t,i,s),a._navCubeCamera.up=$.transformPoint3(t,l,r)):(a._navCubeCamera.look=[0,0,0],a._navCubeCamera.eye=i,a._navCubeCamera.up=l)}}(),s._cubeTextureCanvas=new AF(e,o,r),s._cubeSampler=new Ln(o,{image:s._cubeTextureCanvas.getImage(),flipY:!0,wrapS:1001,wrapT:1001}),s._cubeMesh=new sn(o,{geometry:new Si(o,{primitive:"triangles",normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[.5,.6666,.25,.6666,.25,.3333,.5,.3333,.5,.6666,.5,.3333,.75,.3333,.75,.6666,.5,.6666,.5,1,.25,1,.25,.6666,.25,.6666,0,.6666,0,.3333,.25,.3333,.25,0,.5,0,.5,.3333,.25,.3333,.75,.3333,1,.3333,1,.6666,.75,.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),material:new Oi(o,{diffuse:[.4,.4,.4],specular:[.4,.4,.4],emissive:[.6,.6,.6],diffuseMap:s._cubeSampler,emissiveMap:s._cubeSampler}),visible:!!n,edges:!0}),s._shadow=!1===r.shadowVisible?null:new sn(o,{geometry:new Si(o,nn({center:[0,0,0],radiusTop:.001,radiusBottom:1.4,height:.01,radialSegments:20,heightSegments:1,openEnded:!0})),material:new Oi(o,{diffuse:[0,0,0],specular:[0,0,0],emissive:[0,0,0],alpha:.5}),position:[0,-1.5,0],visible:!!n,pickable:!1,backfaces:!1}),s._onCameraMatrix=e.camera.on("matrix",s._synchCamera),s._onCameraWorldAxis=e.camera.on("worldAxis",(function(){e.camera.zUp?(s._zUp=!0,s._cubeTextureCanvas.setZUp(),s._repaint(),s._synchCamera()):e.camera.yUp&&(s._zUp=!1,s._cubeTextureCanvas.setYUp(),s._repaint(),s._synchCamera())})),s._onCameraFOV=e.camera.perspective.on("fov",(function(e){s._synchProjection&&(s._navCubeCamera.perspective.fov=e)})),s._onCameraProjection=e.camera.on("projection",(function(e){s._synchProjection&&(s._navCubeCamera.projection="ortho"===e||"perspective"===e?e:"perspective")}));var A=-1;function c(t,i){var s=(t-d)*-_,r=(i-p)*-_;e.camera.orbitYaw(s),e.camera.orbitPitch(-r),d=t,p=i}function h(e){var t=[0,0];if(e){for(var i=e.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;t[0]=e.pageX-s,t[1]=e.pageY-r}else e=window.event,t[0]=e.x,t[1]=e.y;return t}var d,p,f=null,v=null,g=!1,m=!1,_=.5;a._navCubeCanvas.addEventListener("mouseenter",a._onMouseEnter=function(e){m=!0}),a._navCubeCanvas.addEventListener("mouseleave",a._onMouseLeave=function(e){m=!1}),a._navCubeCanvas.addEventListener("mousedown",a._onMouseDown=function(e){if(1===e.which){f=e.x,v=e.y,d=e.clientX,p=e.clientY;var t=h(e),i=o.pick({canvasPos:t});g=!!i}}),document.addEventListener("mouseup",a._onMouseUp=function(e){if(1===e.which&&(g=!1,null!==f)){var t=h(e),i=o.pick({canvasPos:t,pickSurface:!0});if(i&&i.uv){var s=a._cubeTextureCanvas.getArea(i.uv);if(s>=0&&(document.body.style.cursor="pointer",A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1),s>=0)){if(a._cubeTextureCanvas.setAreaHighlighted(s,!0),A=s,a._repaint(),e.xf+3||e.yv+3)return;var r=a._cubeTextureCanvas.getAreaDir(s);if(r){var n=a._cubeTextureCanvas.getAreaUp(s);a._isProjectNorth&&a._projectNorthOffsetAngle&&(r=u(1,r,cF),n=u(1,n,hF)),B(r,n,(function(){A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1),document.body.style.cursor="pointer",A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1),s>=0&&(a._cubeTextureCanvas.setAreaHighlighted(s,!1),A=-1,a._repaint())}))}}}}}),document.addEventListener("mousemove",a._onMouseMove=function(e){if(A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1),1!==e.buttons||g){if(g){var t=e.clientX,i=e.clientY;return document.body.style.cursor="move",void c(t,i)}if(m){var s=h(e),r=o.pick({canvasPos:s,pickSurface:!0});if(r){if(r.uv){document.body.style.cursor="pointer";var n=a._cubeTextureCanvas.getArea(r.uv);if(n===A)return;A>=0&&a._cubeTextureCanvas.setAreaHighlighted(A,!1),n>=0&&(a._cubeTextureCanvas.setAreaHighlighted(n,!0),a._repaint(),A=n)}}else document.body.style.cursor="default",A>=0&&(a._cubeTextureCanvas.setAreaHighlighted(A,!1),a._repaint(),A=-1)}}});var B=function(){var t=$.vec3();return function(i,s,r){var n=a._fitVisible?e.scene.getAABB(e.scene.visibleObjectIds):e.scene.aabb,o=$.getAABB3Diag(n);$.getAABB3Center(n,t);var l=Math.abs(o/Math.tan(a._cameraFitFOV*$.DEGTORAD));e.cameraControl.pivotPos=t,a._cameraFly?e.cameraFlight.flyTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:s||[0,1,0],orthoScale:1.1*o,fitFOV:a._cameraFitFOV,duration:a._cameraFlyDuration},r):e.cameraFlight.jumpTo({look:t,eye:[t[0]-l*i[0],t[1]-l*i[1],t[2]-l*i[2]],up:s||[0,1,0],orthoScale:1.1*o,fitFOV:a._cameraFitFOV},r)}}();return s._onUpdated=e.localeService.on("updated",(function(){s._cubeTextureCanvas.clear(),s._repaint()})),s.setVisible(r.visible),s.setCameraFitFOV(r.cameraFitFOV),s.setCameraFly(r.cameraFly),s.setCameraFlyDuration(r.cameraFlyDuration),s.setFitVisible(r.fitVisible),s.setSynchProjection(r.synchProjection),s}return C(i,[{key:"send",value:function(e,t){if("language"===e)this._cubeTextureCanvas.clear(),this._repaint()}},{key:"_repaint",value:function(){var e=this._cubeTextureCanvas.getImage();this._cubeMesh.material.diffuseMap.image=e,this._cubeMesh.material.emissiveMap.image=e}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._navCubeCanvas&&(this._cubeMesh.visible=e,this._shadow&&(this._shadow.visible=e),this._navCubeCanvas.style.visibility=e?"visible":"hidden")}},{key:"getVisible",value:function(){return!!this._navCubeCanvas&&this._cubeMesh.visible}},{key:"setFitVisible",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._fitVisible=e}},{key:"getFitVisible",value:function(){return this._fitVisible}},{key:"setCameraFly",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._cameraFly=e}},{key:"getCameraFly",value:function(){return this._cameraFly}},{key:"setCameraFitFOV",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:45;this._cameraFitFOV=e}},{key:"getCameraFitFOV",value:function(){return this._cameraFitFOV}},{key:"setCameraFlyDuration",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5;this._cameraFlyDuration=e}},{key:"getCameraFlyDuration",value:function(){return this._cameraFlyDuration}},{key:"setSynchProjection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._synchProjection=e}},{key:"getSynchProjection",value:function(){return this._synchProjection}},{key:"setIsProjectNorth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._isProjectNorth=e}},{key:"getIsProjectNorth",value:function(){return this._isProjectNorth}},{key:"setProjectNorthOffsetAngle",value:function(e){this._projectNorthOffsetAngle=e}},{key:"getProjectNorthOffsetAngle",value:function(){return this._projectNorthOffsetAngle}},{key:"destroy",value:function(){this._navCubeCanvas&&(this.viewer.localeService.off(this._onUpdated),this.viewer.camera.off(this._onCameraMatrix),this.viewer.camera.off(this._onCameraWorldAxis),this.viewer.camera.perspective.off(this._onCameraFOV),this.viewer.camera.off(this._onCameraProjection),this._navCubeCanvas.removeEventListener("mouseenter",this._onMouseEnter),this._navCubeCanvas.removeEventListener("mouseleave",this._onMouseLeave),this._navCubeCanvas.removeEventListener("mousedown",this._onMouseDown),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),this._navCubeCanvas=null,this._cubeTextureCanvas.destroy(),this._cubeTextureCanvas=null,this._onMouseEnter=null,this._onMouseLeave=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null),this._navCubeScene.destroy(),this._navCubeScene=null,this._cubeMesh=null,this._shadow=null,f(B(i.prototype),"destroy",this).call(this)}}]),i}(),pF=$.vec3(),fF=function(){function e(){x(this,e)}return C(e,[{key:"load",value:function(e,t){var i=e.scene.canvas.spinner;i.processes++,vF(e,t,(function(t){mF(e,t,(function(){bF(e,t),i.processes--,_e.scheduleTask((function(){e.fire("loaded",!0,!1)}))}))}))}},{key:"parse",value:function(e,t,i,s){if(t){var r=gF(e,t,null);i&&yF(e,i,s),bF(e,r),e.src=null,e.fire("loaded",!0,!1)}else this.warn("load() param expected: objText")}}]),e}(),vF=function(e,t,i){BF(t,(function(s){var r=gF(e,s,t);i(r)}),(function(t){e.error(t)}))},gF=function(){var e={vertex_pattern:/^v\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,normal_pattern:/^vn\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,uv_pattern:/^vt\s+([\d|\.|\+|\-|e|E]+)\s+([\d|\.|\+|\-|e|E]+)/,face_vertex:/^f\s+(-?\d+)\s+(-?\d+)\s+(-?\d+)(?:\s+(-?\d+))?/,face_vertex_uv:/^f\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+))?/,face_vertex_uv_normal:/^f\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)\s+(-?\d+)\/(-?\d+)\/(-?\d+)(?:\s+(-?\d+)\/(-?\d+)\/(-?\d+))?/,face_vertex_normal:/^f\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)\s+(-?\d+)\/\/(-?\d+)(?:\s+(-?\d+)\/\/(-?\d+))?/,object_pattern:/^[og]\s*(.+)?/,smoothing_pattern:/^s\s+(\d+|on|off)/,material_library_pattern:/^mtllib /,material_use_pattern:/^usemtl /};return function(s,r,n){var o={src:n=n||"",basePath:t(n),objects:[],object:{},positions:[],normals:[],uv:[],materialLibraries:{}};i(o,"",!1),-1!==r.indexOf("\r\n")&&(r=r.replace("\r\n","\n"));for(var a=r.split("\n"),l="",u="",A="",d=[],p="function"==typeof"".trimLeft,f=0,v=a.length;f=0?i-1:i+t/3)}function r(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)}function n(e,t){var i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)}function o(e,t,i,s){var r=e.positions,n=e.object.geometry.positions;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2])}function a(e,t){var i=e.positions,s=e.object.geometry.positions;s.push(i[t+0]),s.push(i[t+1]),s.push(i[t+2])}function l(e,t,i,s){var r=e.normals,n=e.object.geometry.normals;n.push(r[t+0]),n.push(r[t+1]),n.push(r[t+2]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[i+2]),n.push(r[s+0]),n.push(r[s+1]),n.push(r[s+2])}function u(e,t,i,s){var r=e.uv,n=e.object.geometry.uv;n.push(r[t+0]),n.push(r[t+1]),n.push(r[i+0]),n.push(r[i+1]),n.push(r[s+0]),n.push(r[s+1])}function A(e,t){var i=e.uv,s=e.object.geometry.uv;s.push(i[t+0]),s.push(i[t+1])}function c(e,t,i,a,A,c,h,d,p,f,v,g,m){var _,y=e.positions.length,b=s(t,y),B=s(i,y),w=s(a,y);if(void 0===A?o(e,b,B,w):(o(e,b,B,_=s(A,y)),o(e,B,w,_)),void 0!==c){var x=e.uv.length;b=n(c,x),B=n(h,x),w=n(d,x),void 0===A?u(e,b,B,w):(u(e,b,B,_=n(p,x)),u(e,B,w,_))}if(void 0!==f){var P=e.normals.length;b=r(f,P),B=f===v?b:r(v,P),w=f===g?b:r(g,P),void 0===A?l(e,b,B,w):(l(e,b,B,_=r(m,P)),l(e,B,w,_))}}function h(e,t,i){e.object.geometry.type="Line";for(var r=e.positions.length,o=e.uv.length,l=0,u=t.length;l=0?o.substring(0,a):o).toLowerCase(),u=(u=a>=0?o.substring(a+1):"").trim(),l.toLowerCase()){case"newmtl":i(e,h),h={id:u},d=!0;break;case"ka":h.ambient=s(u);break;case"kd":h.diffuse=s(u);break;case"ks":h.specular=s(u);break;case"map_kd":h.diffuseMap||(h.diffuseMap=t(e,n,u,"sRGB"));break;case"map_ks":h.specularMap||(h.specularMap=t(e,n,u,"linear"));break;case"map_bump":case"bump":h.normalMap||(h.normalMap=t(e,n,u));break;case"ns":h.shininess=parseFloat(u);break;case"d":(A=parseFloat(u))<1&&(h.alpha=A,h.alphaMode="blend");break;case"tr":(A=parseFloat(u))>0&&(h.alpha=1-A,h.alphaMode="blend")}d&&i(e,h)};function t(e,t,i,s){var r={},n=i.split(/\s+/),o=n.indexOf("-bm");return o>=0&&n.splice(o,2),(o=n.indexOf("-s"))>=0&&(r.scale=[parseFloat(n[o+1]),parseFloat(n[o+2])],n.splice(o,4)),(o=n.indexOf("-o"))>=0&&(r.translate=[parseFloat(n[o+1]),parseFloat(n[o+2])],n.splice(o,4)),r.src=t+n.join(" ").trim(),r.flipY=!0,r.encoding=s||"linear",new Ln(e,r).id}function i(e,t){new Oi(e,t)}function s(t){var i=t.split(e,3);return[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])]}}();function bF(e,t){for(var i=0,s=t.objects.length;i0&&(o.normals=n.normals),n.uv.length>0&&(o.uv=n.uv);for(var a=new Array(o.positions.length/3),l=0;l0&&void 0!==arguments[0]?arguments[0]:{};t.id&&this.viewer.scene.components[t.id]&&(this.error("Component with this ID already exists in viewer: "+t.id+" - will autogenerate this ID"),delete t.id);var i=new yn(this.viewer.scene,le.apply(t,{isModel:!0})),s=i.id,r=t.src;if(!r)return this.error("load() param expected: src"),i;if(t.metaModelSrc){var n=t.metaModelSrc;le.loadJSON(n,(function(n){e.viewer.metaScene.createMetaModel(s,n),e._sceneGraphLoader.load(i,r,t)}),(function(t){e.error("load(): Failed to load model modelMetadata for model '".concat(s," from '").concat(n,"' - ").concat(t))}))}else this._sceneGraphLoader.load(i,r,t);return i.once("destroyed",(function(){e.viewer.metaScene.destroyMetaModel(s)})),i}},{key:"destroy",value:function(){f(B(i.prototype),"destroy",this).call(this)}}]),i}(),xF=new Float64Array([0,0,1]),PF=new Float64Array(4),CF=function(){function e(t){x(this,e),this.id=null,this._viewer=t.viewer,this._visible=!1,this._pos=$.vec3(),this._origin=$.vec3(),this._rtcPos=$.vec3(),this._baseDir=$.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}return C(e,[{key:"_setSectionPlane",value:function(e){var t=this;this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(function(){t._setPos(t._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(function(){t._ignoreNextSectionPlaneDirUpdate?t._ignoreNextSectionPlaneDirUpdate=!1:t._setDir(t._sectionPlane.dir)})))}},{key:"sectionPlane",get:function(){return this._sectionPlane}},{key:"_setPos",value:function(e){this._pos.set(e),Le(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}},{key:"_setDir",value:function(e){this._baseDir.set(e),this._rootNode.quaternion=$.vec3PairToQuaternion(xF,e,PF)}},{key:"_setSectionPlaneDir",value:function(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}},{key:"getVisible",value:function(){return this._visible}},{key:"setCulled",value:function(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}},{key:"_createNodes",value:function(){var e=!1,t=this._viewer.scene,i=.01;this._rootNode=new yn(t,{position:[0,0,0],scale:[5,5,5],isObject:!1});var s,r,n=this._rootNode,o={arrowHead:new Si(n,nn({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Si(n,nn({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),arrowHeadHandle:new Si(n,nn({radiusTop:.09,radiusBottom:.09,radialSegments:8,heightSegments:1,height:.37,openEnded:!1})),curve:new Si(n,Xn({radius:.8,tube:i,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),curveHandle:new Si(n,Xn({radius:.8,tube:.06,radialSegments:64,tubeSegments:14,arc:2*Math.PI/4})),hoop:new Si(n,Xn({radius:.8,tube:i,radialSegments:64,tubeSegments:8,arc:2*Math.PI})),axis:new Si(n,nn({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1})),axisHandle:new Si(n,nn({radiusTop:.08,radiusBottom:.08,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},a={pickable:new Oi(n,{diffuse:[1,1,0],alpha:0,alphaMode:"blend"}),red:new Oi(n,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Qi(n,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6}),green:new Oi(n,{diffuse:[0,1,0],emissive:[0,1,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightGreen:new Qi(n,{edges:!1,fill:!0,fillColor:[0,1,0],fillAlpha:.6}),blue:new Oi(n,{diffuse:[0,0,1],emissive:[0,0,1],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightBlue:new Qi(n,{edges:!1,fill:!0,fillColor:[0,0,1],fillAlpha:.2}),center:new Oi(n,{diffuse:[0,0,0],emissive:[0,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80}),highlightBall:new Qi(n,{edges:!1,fill:!0,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1}),highlightPlane:new Qi(n,{edges:!0,edgeWidth:3,fill:!1,fillColor:[.5,.5,.5],fillAlpha:.5,vertices:!1})};this._displayMeshes={plane:n.addChild(new sn(n,{geometry:new Si(n,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Oi(n,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,ghostMaterial:new Qi(n,{edges:!1,filled:!0,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:.1,backfaces:!0}),pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1],isObject:!1}),e),planeFrame:n.addChild(new sn(n,{geometry:new Si(n,Xn({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Oi(n,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),highlightMaterial:new Qi(n,{edges:!1,edgeColor:[0,0,0],filled:!0,fillColor:[.8,.8,.8],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45],isObject:!1}),e),xCurve:n.addChild(new sn(n,{geometry:o.curve,material:a.red,matrix:(s=$.rotationMat4v(90*$.DEGTORAD,[0,1,0],$.identityMat4()),r=$.rotationMat4v(270*$.DEGTORAD,[1,0,0],$.identityMat4()),$.mulMat4(r,s,$.identityMat4())),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveHandle:n.addChild(new sn(n,{geometry:o.curveHandle,material:a.pickable,matrix:function(){var e=$.rotationMat4v(90*$.DEGTORAD,[0,1,0],$.identityMat4()),t=$.rotationMat4v(270*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xCurveArrow1:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.red,matrix:function(){var e=$.translateMat4c(0,-.07,-.8,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(0*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xCurveArrow2:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.red,matrix:function(){var e=$.translateMat4c(0,-.8,-.07,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurve:n.addChild(new sn(n,{geometry:o.curve,material:a.green,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveHandle:n.addChild(new sn(n,{geometry:o.curveHandle,material:a.pickable,rotation:[-90,0,0],pickable:!0,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),yCurveArrow1:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.green,matrix:function(){var e=$.translateMat4c(.07,0,-.8,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yCurveArrow2:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.green,matrix:function(){var e=$.translateMat4c(.8,0,-.07,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurve:n.addChild(new sn(n,{geometry:o.curve,material:a.blue,matrix:$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4()),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveHandle:n.addChild(new sn(n,{geometry:o.curveHandle,material:a.pickable,matrix:$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4()),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveCurveArrow1:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.blue,matrix:function(){var e=$.translateMat4c(.8,-.07,0,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4());return $.mulMat4(e,t,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zCurveArrow2:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.blue,matrix:function(){var e=$.translateMat4c(.05,-.8,0,$.identityMat4()),t=$.scaleMat4v([.6,.6,.6],$.identityMat4()),i=$.rotationMat4v(90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4($.mulMat4(e,t,$.identityMat4()),i,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),center:n.addChild(new sn(n,{geometry:new Si(n,on({radius:.05})),material:a.center,pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.red,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisArrowHandle:n.addChild(new sn(n,{geometry:o.arrowHeadHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxis:n.addChild(new sn(n,{geometry:o.axis,material:a.red,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),xAxisHandle:n.addChild(new sn(n,{geometry:o.axisHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.green,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrowHandle:n.addChild(new sn(n,{geometry:o.arrowHeadHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,opacity:.2,isObject:!1}),e),yShaft:n.addChild(new sn(n,{geometry:o.axis,material:a.green,position:[0,-.5,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yShaftHandle:n.addChild(new sn(n,{geometry:o.axisHandle,material:a.pickable,position:[0,-.5,0],pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHead,material:a.blue,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrowHandle:n.addChild(new sn(n,{geometry:o.arrowHeadHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!0,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zShaft:n.addChild(new sn(n,{geometry:o.axis,material:a.blue,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1,isObject:!1}),e),zAxisHandle:n.addChild(new sn(n,{geometry:o.axisHandle,material:a.pickable,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),clippable:!1,pickable:!0,collidable:!0,visible:!1,isObject:!1}),e)},this._affordanceMeshes={planeFrame:n.addChild(new sn(n,{geometry:new Si(n,Xn({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Oi(n,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Qi(n,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45],isObject:!1}),e),xHoop:n.addChild(new sn(n,{geometry:o.hoop,material:a.red,highlighted:!0,highlightMaterial:a.highlightRed,matrix:function(){var e=$.rotationMat4v(90*$.DEGTORAD,[0,1,0],$.identityMat4()),t=$.rotationMat4v(270*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yHoop:n.addChild(new sn(n,{geometry:o.hoop,material:a.green,highlighted:!0,highlightMaterial:a.highlightGreen,rotation:[-90,0,0],pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zHoop:n.addChild(new sn(n,{geometry:o.hoop,material:a.blue,highlighted:!0,highlightMaterial:a.highlightBlue,matrix:$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4()),pickable:!1,collidable:!0,clippable:!1,backfaces:!0,visible:!1,isObject:!1}),e),xAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHeadBig,material:a.red,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[0,0,1],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),yAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHeadBig,material:a.green,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(180*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e),zAxisArrow:n.addChild(new sn(n,{geometry:o.arrowHeadBig,material:a.blue,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1,isObject:!1}),e)}}},{key:"_bindEvents",value:function(){var e=this,t=this,i=!1,s=-1,r=0,n=1,o=2,a=3,l=4,u=5,A=this._rootNode,c=null,h=null,d=$.vec2(),p=$.vec3([1,0,0]),f=$.vec3([0,1,0]),v=$.vec3([0,0,1]),g=this._viewer.scene.canvas.canvas,m=this._viewer.camera,_=this._viewer.scene,y=$.vec3([0,0,0]),b=-1;this._onCameraViewMatrix=_.camera.on("viewMatrix",(function(){})),this._onCameraProjMatrix=_.camera.on("projMatrix",(function(){})),this._onSceneTick=_.on("tick",(function(){var t=Math.abs($.lenVec3($.subVec3(_.camera.eye,e._pos,y)));if(t!==b&&"perspective"===m.projection){var i=.07*(Math.tan(m.perspective.fov*$.DEGTORAD)*t);A.scale=[i,i,i],b=t}if("ortho"===m.projection){var s=m.ortho.scale/10;A.scale=[s,s,s],b=t}}));var B,w,x,P,C,M=function(){var e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),F=function(){var e=$.mat4();return function(i,s){return $.quaternionToMat4(t._rootNode.quaternion,e),$.transformVec3(e,i,s),$.normalizeVec3(s),s}}(),E=(B=$.vec3(),function(e){var t=Math.abs(e[0]);return t>Math.abs(e[1])&&t>Math.abs(e[2])?$.cross3Vec3(e,[0,1,0],B):$.cross3Vec3(e,[1,0,0],B),$.cross3Vec3(B,e,B),$.normalizeVec3(B),B}),k=(w=$.vec3(),x=$.vec3(),P=$.vec4(),function(e,i,s){F(e,P);var r=E(P,i,s);D(i,r,w),D(s,r,x),$.subVec3(x,w);var n=$.dotVec3(x,P);t._pos[0]+=P[0]*n,t._pos[1]+=P[1]*n,t._pos[2]+=P[2]*n,t._rootNode.position=t._pos,t._sectionPlane&&(t._sectionPlane.pos=t._pos)}),I=function(){var e=$.vec4(),i=$.vec4(),s=$.vec4(),r=$.vec4();return function(n,o,a){if(F(n,r),!(D(o,r,e)&&D(a,r,i))){var l=E(r,o,a);D(o,l,e,1),D(a,l,i,1);var u=$.dotVec3(e,r);e[0]-=u*r[0],e[1]-=u*r[1],e[2]-=u*r[2],u=$.dotVec3(i,r),i[0]-=u*r[0],i[1]-=u*r[1],i[2]-=u*r[2]}$.normalizeVec3(e),$.normalizeVec3(i),u=$.dotVec3(e,i),u=$.clamp(u,-1,1);var A=Math.acos(u)*$.RADTODEG;$.cross3Vec3(e,i,s),$.dotVec3(s,r)<0&&(A=-A),t._rootNode.rotate(n,A),S()}}(),D=function(){var e=$.vec4([0,0,0,1]),i=$.mat4();return function(s,r,n,o){o=o||0,e[0]=s[0]/g.width*2-1,e[1]=-(s[1]/g.height*2-1),e[2]=0,e[3]=1,$.mulMat4(m.projMatrix,m.viewMatrix,i),$.inverseMat4(i),$.transformVec4(i,e,e),$.mulVec4Scalar(e,1/e[3]);var a=m.eye;$.subVec4(e,a,e);var l=t._sectionPlane.pos,u=-$.dotVec3(l,r)-o,A=$.dotVec3(r,e);if(Math.abs(A)>.005){var c=-($.dotVec3(r,a)+u)/A;return $.mulVec3Scalar(e,c,n),$.addVec3(n,a),$.subVec3(n,l,n),!0}return!1}}(),S=function(){var e=$.vec3(),i=$.mat4();return function(){t.sectionPlane&&($.quaternionToMat4(A.quaternion,i),$.transformVec3(i,[0,0,1],e),t._setSectionPlaneDir(e))}}(),T=!1;this._onCameraControlHover=this._viewer.cameraControl.on("hoverEnter",(function(t){if(e._visible&&!T){var A;switch(i=!1,C&&(C.visible=!1),t.entity.id){case e._displayMeshes.xAxisArrowHandle.id:case e._displayMeshes.xAxisHandle.id:A=e._affordanceMeshes.xAxisArrow,c=r;break;case e._displayMeshes.yAxisArrowHandle.id:case e._displayMeshes.yShaftHandle.id:A=e._affordanceMeshes.yAxisArrow,c=n;break;case e._displayMeshes.zAxisArrowHandle.id:case e._displayMeshes.zAxisHandle.id:A=e._affordanceMeshes.zAxisArrow,c=o;break;case e._displayMeshes.xCurveHandle.id:A=e._affordanceMeshes.xHoop,c=a;break;case e._displayMeshes.yCurveHandle.id:A=e._affordanceMeshes.yHoop,c=l;break;case e._displayMeshes.zCurveHandle.id:A=e._affordanceMeshes.zHoop,c=u;break;default:return void(c=s)}A&&(A.visible=!0),C=A,i=!0}})),this._onCameraControlHoverLeave=this._viewer.cameraControl.on("hoverOutEntity",(function(t){e._visible&&(C&&(C.visible=!1),C=null,c=s)})),g.addEventListener("mousedown",this._canvasMouseDownListener=function(t){if(t.preventDefault(),e._visible&&i&&(e._viewer.cameraControl.pointerEnabled=!1,1===t.which)){T=!0;var s=M(t);h=c,d[0]=s[0],d[1]=s[1]}}),g.addEventListener("mousemove",this._canvasMouseMoveListener=function(t){if(e._visible&&T){var i=M(t),s=i[0],A=i[1];switch(h){case r:k(p,d,i);break;case n:k(f,d,i);break;case o:k(v,d,i);break;case a:I(p,d,i);break;case l:I(f,d,i);break;case u:I(v,d,i)}d[0]=s,d[1]=A}}),g.addEventListener("mouseup",this._canvasMouseUpListener=function(t){e._visible&&(e._viewer.cameraControl.pointerEnabled=!0,T&&(t.which,T=!1,i=!1))}),g.addEventListener("wheel",this._canvasWheelListener=function(t){if(e._visible)Math.max(-1,Math.min(1,40*-t.deltaY))})}},{key:"_destroy",value:function(){this._unbindEvents(),this._destroyNodes()}},{key:"_unbindEvents",value:function(){var e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=e.cameraControl;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix),r.off(this._onCameraControlHover),r.off(this._onCameraControlHoverLeave)}},{key:"_destroyNodes",value:function(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}]),e}(),MF=function(){function e(t,i,s){var r=this;x(this,e),this.id=s.id,this._sectionPlane=s,this._mesh=new sn(i,{id:s.id,geometry:new Si(i,Ti({xSize:.5,ySize:.5,zSize:.001})),material:new Oi(i,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new Hi(i,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Qi(i,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Qi(i,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});var n=$.vec3([0,0,0]),o=$.vec3(),a=$.vec3([0,0,1]),l=$.vec4(4),u=$.vec3(),A=function(){var e=r._sectionPlane.scene.center,t=[-r._sectionPlane.dir[0],-r._sectionPlane.dir[1],-r._sectionPlane.dir[2]];$.subVec3(e,r._sectionPlane.pos,n);var i=-$.dotVec3(t,n);$.normalizeVec3(t),$.mulVec3Scalar(t,i,o);var s=$.vec3PairToQuaternion(a,r._sectionPlane.dir,l);u[0]=.1*o[0],u[1]=.1*o[1],u[2]=.1*o[2],r._mesh.quaternion=s,r._mesh.position=u};this._onSectionPlanePos=this._sectionPlane.on("pos",A),this._onSectionPlaneDir=this._sectionPlane.on("dir",A),this._highlighted=!1,this._selected=!1}return C(e,[{key:"setHighlighted",value:function(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}},{key:"getHighlighted",value:function(){return this._highlighted}},{key:"setSelected",value:function(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}},{key:"getSelected",value:function(){return this._selected}},{key:"destroy",value:function(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}]),e}(),FF=function(){function e(t,i){var s=this;if(x(this,e),!(i.onHoverEnterPlane&&i.onHoverLeavePlane&&i.onClickedNothing&&i.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=t,this._viewer=t.viewer,this._onHoverEnterPlane=i.onHoverEnterPlane,this._onHoverLeavePlane=i.onHoverLeavePlane,this._onClickedNothing=i.onClickedNothing,this._onClickedPlane=i.onClickedPlane,this._visible=!0,this._planes={},this._canvas=i.overviewCanvas,this._scene=new Zi(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new yi(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new yi(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new yi(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;var r=this._scene.camera,n=$.rotationMat4c(-90*$.DEGTORAD,1,0,0),o=$.vec3(),a=$.vec3(),l=$.vec3();this._synchCamera=function(){var e=s._viewer.camera.eye,t=s._viewer.camera.look,i=s._viewer.camera.up;$.mulVec3Scalar($.normalizeVec3($.subVec3(e,t,o)),7),s._zUp?($.transformVec3(n,o,a),$.transformVec3(n,i,l),r.look=[0,0,0],r.eye=$.transformVec3(n,o,a),r.up=$.transformPoint3(n,i,l)):(r.look=[0,0,0],r.eye=o,r.up=i)},this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(function(e){s._scene.camera.perspective.fov=e}));var u=null;this._onInputMouseMove=this._scene.input.on("mousemove",(function(e){var t=s._scene.pick({canvasPos:e});if(t){if(!u||t.entity.id!==u.id){if(u)s._planes[u.id]&&s._onHoverLeavePlane(u.id);u=t.entity,s._planes[u.id]&&s._onHoverEnterPlane(u.id)}}else u&&(s._onHoverLeavePlane(u.id),u=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=function(){u?s._planes[u.id]&&s._onClickedPlane(u.id):s._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=function(){u&&(s._onHoverLeavePlane(u.id),u=null)}),this.setVisible(i.overviewVisible)}return C(e,[{key:"addSectionPlane",value:function(e){this._planes[e.id]=new MF(this,this._scene,e)}},{key:"setPlaneHighlighted",value:function(e,t){var i=this._planes[e];i&&i.setHighlighted(t)}},{key:"setPlaneSelected",value:function(e,t){var i=this._planes[e];i&&i.setSelected(t)}},{key:"removeSectionPlane",value:function(e){var t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}},{key:"getVisible",value:function(){return this._visible}},{key:"destroy",value:function(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}]),e}(),EF=$.AABB3(),kF=$.vec3(),IF=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,"SectionPlanes",e))._freeControls=[],s._sectionPlanes=e.scene.sectionPlanes,s._controls={},s._shownControlId=null,null!==r.overviewCanvasId&&void 0!==r.overviewCanvasId){var n=document.getElementById(r.overviewCanvasId);n?s._overview=new FF(b(s),{overviewCanvas:n,visible:r.overviewVisible,onHoverEnterPlane:function(e){s._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:function(e){s._overview.setPlaneHighlighted(e,!1)},onClickedPlane:function(e){if(s.getShownControl()!==e){s.showControl(e);var t=s.sectionPlanes[e].pos;EF.set(s.viewer.scene.aabb),$.getAABB3Center(EF,kF),EF[0]+=t[0]-kF[0],EF[1]+=t[1]-kF[1],EF[2]+=t[2]-kF[2],EF[3]+=t[0]-kF[0],EF[4]+=t[1]-kF[1],EF[5]+=t[2]-kF[2],s.viewer.cameraFlight.flyTo({aabb:EF,fitFOV:65})}else s.hideControl()},onClickedNothing:function(){s.hideControl()}}):s.warn("Can't find overview canvas: '"+r.overviewCanvasId+"' - will create plugin without overview")}return s._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(function(e){s._sectionPlaneCreated(e)})),s}return C(i,[{key:"setOverviewVisible",value:function(e){this._overview&&this._overview.setVisible(e)}},{key:"getOverviewVisible",value:function(){if(this._overview)return this._overview.getVisible()}},{key:"sectionPlanes",get:function(){return this._sectionPlanes}},{key:"createSectionPlane",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);var t=new An(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0});return t}},{key:"_sectionPlaneCreated",value:function(e){var t=this,i=this._freeControls.length>0?this._freeControls.pop():new CF(this);i._setSectionPlane(e),i.setVisible(!1),this._controls[e.id]=i,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(function(){t._sectionPlaneDestroyed(e)}))}},{key:"flipSectionPlanes",value:function(){var e=this.viewer.scene.sectionPlanes;for(var t in e){e[t].flipDir()}}},{key:"showControl",value:function(e){var t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}},{key:"getShownControl",value:function(){return this._shownControlId}},{key:"hideControl",value:function(){for(var e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}},{key:"destroySectionPlane",value:function(e){var t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}},{key:"_sectionPlaneDestroyed",value:function(e){this._overview&&this._overview.removeSectionPlane(e);var t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}},{key:"clear",value:function(){for(var e=Object.keys(this._sectionPlanes),t=0,i=e.length;t1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"StoreyViews",e))._objectsMemento=new ld,s._cameraMemento=new rd,s.storeys={},s.modelStoreys={},s._fitStoreyMaps=!!r.fitStoreyMaps,s._onModelLoaded=s.viewer.scene.on("modelLoaded",(function(e){s._registerModelStoreys(e),s.fire("storeys",s.storeys)})),s}return C(i,[{key:"_registerModelStoreys",value:function(e){var t=this,i=this.viewer,s=i.scene,r=i.metaScene,n=r.metaModels[e],o=s.models[e];if(n&&n.rootMetaObjects)for(var a=n.rootMetaObjects,l=0,u=a.length;l.5?p.length:0,g=new DF(this,o.aabb,f,e,d,v);g._onModelDestroyed=o.once("destroyed",(function(){t._deregisterModelStoreys(e),t.fire("storeys",t.storeys)})),this.storeys[d]=g,this.modelStoreys[e]||(this.modelStoreys[e]={}),this.modelStoreys[e][d]=g}}},{key:"_deregisterModelStoreys",value:function(e){var t=this.modelStoreys[e];if(t){var i=this.viewer.scene;for(var s in t)if(t.hasOwnProperty(s)){var r=t[s],n=i.models[r.modelId];n&&n.off(r._onModelDestroyed),delete this.storeys[s]}delete this.modelStoreys[e]}}},{key:"fitStoreyMaps",get:function(){return this._fitStoreyMaps}},{key:"gotoStoreyCamera",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),void(t.done&&t.done());var s=this.viewer,r=s.scene,n=r.camera,o=i.storeyAABB;if(o[3]1&&void 0!==arguments[1]?arguments[1]:{},i=this.storeys[e];if(i){var s=this.viewer,r=s.scene,n=s.metaScene,o=n.metaObjects[e];o&&(t.hideOthers&&r.setObjectsVisible(s.scene.visibleObjectIds,!1),this.withStoreyObjects(e,(function(e,t){e&&(e.visible=!0)})))}else this.error("IfcBuildingStorey not found with this ID: "+e)}},{key:"withStoreyObjects",value:function(e,t){var i=this.viewer,s=i.scene,r=i.metaScene,n=r.metaObjects[e];if(n)for(var o=n.getObjectIDsInSubtree(),a=0,l=o.length;a1&&void 0!==arguments[1]?arguments[1]:{},i=this.storeys[e];if(!i)return this.error("IfcBuildingStorey not found with this ID: "+e),LF;var s,r,n=this.viewer,o=n.scene,a=t.format||"png",l=this._fitStoreyMaps?i.storeyAABB:i.modelAABB,u=Math.abs((l[5]-l[2])/(l[3]-l[0])),A=t.padding||0;t.width&&t.height?(s=t.width,r=t.height):t.height?(r=t.height,s=Math.round(r/u)):t.width?(s=t.width,r=Math.round(s*u)):(s=300,r=Math.round(s*u)),this._objectsMemento.saveObjects(o),this._cameraMemento.saveCamera(o),this.showStoreyObjects(e,le.apply(t,{hideOthers:!0})),this._arrangeStoreyMapCamera(i);var c=n.getSnapshot({width:s,height:r,format:a});return this._objectsMemento.restoreObjects(o),this._cameraMemento.restoreCamera(o),new SF(e,c,a,s,r,A)}},{key:"_arrangeStoreyMapCamera",value:function(e){var t=this.viewer,i=t.scene.camera,s=this._fitStoreyMaps?e.storeyAABB:e.modelAABB,r=$.getAABB3Center(s),n=TF;n[0]=r[0]+.5*i.worldUp[0],n[1]=r[1]+.5*i.worldUp[1],n[2]=r[2]+.5*i.worldUp[2];var o=i.worldForward;t.cameraFlight.jumpTo({eye:n,look:r,up:o});var a=(s[3]-s[0])/2,l=(s[4]-s[1])/2,u=(s[5]-s[2])/2,A=-a,c=+a,h=-l,d=+l,p=-u,f=+u;t.camera.customProjection.matrix=$.orthoMat4c(A,c,p,f,h,d,RF),t.camera.projection="customProjection"}},{key:"pickStoreyMap",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),null;var n=1-t[0]/e.width,o=1-t[1]/e.height,a=this._fitStoreyMaps?r.storeyAABB:r.modelAABB,l=a[0],u=a[1],A=a[2],c=a[3],h=a[4],d=a[5],p=c-l,f=h-u,v=d-A,g=$.vec3([l+p*n,u+.5*f,A+v*o]),m=$.vec3([0,-1,0]),_=$.addVec3(g,m,TF),y=this.viewer.camera.worldForward,b=$.lookAtMat4v(g,_,y,RF),B=this.viewer.scene.pick({pickSurface:i.pickSurface,pickInvisible:!0,matrix:b});return B}},{key:"storeyMapToWorldPos",value:function(e,t){var i=e.storeyId,s=this.storeys[i];if(!s)return this.error("IfcBuildingStorey not found with this ID: "+i),null;var r=1-t[0]/e.width,n=1-t[1]/e.height,o=this._fitStoreyMaps?s.storeyAABB:s.modelAABB,a=o[0],l=o[1],u=o[2],A=o[3],c=o[4],h=o[5],d=A-a,p=c-l,f=h-u,v=$.vec3([a+d*r,l+.5*p,u+f*n]);return v}},{key:"getStoreyContainingWorldPos",value:function(e){for(var t in this.storeys){var i=this.storeys[t];if($.point3AABB3Intersect(i.storeyAABB,e))return t}return null}},{key:"worldPosToStoreyMap",value:function(e,t,i){var s=e.storeyId,r=this.storeys[s];if(!r)return this.error("IfcBuildingStorey not found with this ID: "+s),!1;var n=this._fitStoreyMaps?r.storeyAABB:r.modelAABB,o=n[0],a=n[1],l=n[2],u=n[3]-o,A=n[4]-a,c=n[5]-l,h=this.viewer.camera.worldUp,d=h[0]>h[1]&&h[0]>h[2],p=!d&&h[1]>h[0]&&h[1]>h[2];!d&&!p&&h[2]>h[0]&&(h[2],h[1]);var f=e.width/u,v=p?e.height/c:e.height/A;return i[0]=Math.floor(e.width-(t[0]-o)*f),i[1]=Math.floor(e.height-(t[2]-l)*v),i[0]>=0&&i[0]=0&&i[1]<=e.height}},{key:"worldDirToStoreyMap",value:function(e,t,i){var s=this.viewer.camera,r=s.eye,n=s.look,o=$.subVec3(n,r,TF),a=s.worldUp,l=a[0]>a[1]&&a[0]>a[2],u=!l&&a[1]>a[0]&&a[1]>a[2];!l&&!u&&a[2]>a[0]&&(a[2],a[1]),l?(i[0]=o[1],i[1]=o[2]):u?(i[0]=o[0],i[1]=o[2]):(i[0]=o[0],i[1]=o[1]),$.normalizeVec2(i)}},{key:"destroy",value:function(){this.viewer.scene.off(this._onModelLoaded),f(B(i.prototype),"destroy",this).call(this)}}]),i}(),OF=new Float64Array([0,0,1]),NF=new Float64Array(4),QF=function(){function e(t){x(this,e),this.id=null,this._viewer=t.viewer,this._plugin=t,this._visible=!1,this._pos=$.vec3(),this._origin=$.vec3(),this._rtcPos=$.vec3(),this._baseDir=$.vec3(),this._rootNode=null,this._displayMeshes=null,this._affordanceMeshes=null,this._ignoreNextSectionPlaneDirUpdate=!1,this._createNodes(),this._bindEvents()}return C(e,[{key:"_setSectionPlane",value:function(e){var t=this;this._sectionPlane&&(this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._onSectionPlanePos=null,this._onSectionPlaneDir=null,this._sectionPlane=null),e&&(this.id=e.id,this._setPos(e.pos),this._setDir(e.dir),this._sectionPlane=e,this._onSectionPlanePos=e.on("pos",(function(){t._setPos(t._sectionPlane.pos)})),this._onSectionPlaneDir=e.on("dir",(function(){t._ignoreNextSectionPlaneDirUpdate?t._ignoreNextSectionPlaneDirUpdate=!1:t._setDir(t._sectionPlane.dir)})))}},{key:"sectionPlane",get:function(){return this._sectionPlane}},{key:"_setPos",value:function(e){this._pos.set(e),Le(this._pos,this._origin,this._rtcPos),this._rootNode.origin=this._origin,this._rootNode.position=this._rtcPos}},{key:"_setDir",value:function(e){this._baseDir.set(e),this._rootNode.quaternion=$.vec3PairToQuaternion(OF,e,NF)}},{key:"_setSectionPlaneDir",value:function(e){this._sectionPlane&&(this._ignoreNextSectionPlaneDirUpdate=!0,this._sectionPlane.dir=e)}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(this._visible!==e){var t;for(t in this._visible=e,this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].visible=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].visible=e)}}},{key:"getVisible",value:function(){return this._visible}},{key:"setCulled",value:function(e){var t;for(t in this._displayMeshes)this._displayMeshes.hasOwnProperty(t)&&(this._displayMeshes[t].culled=e);if(!e)for(t in this._affordanceMeshes)this._affordanceMeshes.hasOwnProperty(t)&&(this._affordanceMeshes[t].culled=e)}},{key:"_createNodes",value:function(){var e=!1,t=this._viewer.scene,i=.01;this._rootNode=new yn(t,{position:[0,0,0],scale:[5,5,5]});var s=this._rootNode,r={arrowHead:new Si(s,nn({radiusTop:.001,radiusBottom:.07,radialSegments:32,heightSegments:1,height:.2,openEnded:!1})),arrowHeadBig:new Si(s,nn({radiusTop:.001,radiusBottom:.09,radialSegments:32,heightSegments:1,height:.25,openEnded:!1})),axis:new Si(s,nn({radiusTop:i,radiusBottom:i,radialSegments:20,heightSegments:1,height:1,openEnded:!1}))},n={red:new Oi(s,{diffuse:[1,0,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),green:new Oi(s,{diffuse:[0,1,0],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),blue:new Oi(s,{diffuse:[0,0,1],emissive:[1,0,0],ambient:[0,0,0],specular:[.6,.6,.3],shininess:80,lineWidth:2}),highlightRed:new Qi(s,{edges:!1,fill:!0,fillColor:[1,0,0],fillAlpha:.6})};this._displayMeshes={plane:s.addChild(new sn(s,{geometry:new Si(s,{primitive:"triangles",positions:[.5,.5,0,.5,-.5,0,-.5,-.5,0,-.5,.5,0,.5,.5,-0,.5,-.5,-0,-.5,-.5,-0,-.5,.5,-0],indices:[0,1,2,2,3,0]}),material:new Oi(s,{emissive:[0,0,0],diffuse:[0,0,0],backfaces:!0}),opacity:.6,ghosted:!0,pickable:!1,collidable:!0,clippable:!1,visible:!1,scale:[2.4,2.4,1]}),e),planeFrame:s.addChild(new sn(s,{geometry:new Si(s,Xn({center:[0,0,0],radius:1.7,tube:.02,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Oi(s,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,.1],rotation:[0,0,45]}),e),center:s.addChild(new sn(s,{geometry:new Si(s,on({radius:.05})),material:n.center,pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zAxisArrow:s.addChild(new sn(s,{geometry:r.arrowHead,material:n.blue,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e),zShaft:s.addChild(new sn(s,{geometry:r.axis,material:n.blue,matrix:function(){var e=$.translateMat4c(0,.5,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[1,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),clippable:!1,pickable:!1,collidable:!0,visible:!1}),e)},this._affordanceMeshes={planeFrame:s.addChild(new sn(s,{geometry:new Si(s,Xn({center:[0,0,0],radius:2,tube:i,radialSegments:4,tubeSegments:4,arc:2*Math.PI})),material:new Oi(s,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:!0,highlightMaterial:new Qi(s,{edges:!1,filled:!0,fillColor:[1,1,0],fillAlpha:1}),pickable:!1,collidable:!1,clippable:!1,visible:!1,scale:[1,1,1],rotation:[0,0,45]}),e),zAxisArrow:s.addChild(new sn(s,{geometry:r.arrowHeadBig,material:n.blue,matrix:function(){var e=$.translateMat4c(0,1.1,0,$.identityMat4()),t=$.rotationMat4v(-90*$.DEGTORAD,[.8,0,0],$.identityMat4());return $.mulMat4(t,e,$.identityMat4())}(),pickable:!1,collidable:!0,clippable:!1,visible:!1}),e)}}},{key:"_bindEvents",value:function(){var e=this,t=this._rootNode,i=$.vec2(),s=this._viewer.camera,r=this._viewer.scene,n=0,o=!1,a=$.vec3([0,0,0]),l=-1;this._onCameraViewMatrix=r.camera.on("viewMatrix",(function(){})),this._onCameraProjMatrix=r.camera.on("projMatrix",(function(){})),this._onSceneTick=r.on("tick",(function(){o=!1;var i=Math.abs($.lenVec3($.subVec3(r.camera.eye,e._pos,a)));if(i!==l&&"perspective"===s.projection){var u=.07*(Math.tan(s.perspective.fov*$.DEGTORAD)*i);t.scale=[u,u,u],l=i}if("ortho"===s.projection){var c=s.ortho.scale/10;t.scale=[c,c,c],l=i}0!==n&&(A(n),n=0)}));var u=function(){var e=new Float64Array(2);return function(t){if(t){for(var i=t.target,s=0,r=0;i.offsetParent;)s+=i.offsetLeft,r+=i.offsetTop,i=i.offsetParent;e[0]=t.pageX-s,e[1]=t.pageY-r}else t=window.event,e[0]=t.x,e[1]=t.y;return e}}(),A=function(t){var i=e._sectionPlane.pos,s=e._sectionPlane.dir;$.addVec3(i,$.mulVec3Scalar(s,.1*t*e._plugin.getDragSensitivity(),$.vec3())),e._sectionPlane.pos=i},c=!1;this._plugin._controlElement.addEventListener("mousedown",this._canvasMouseDownListener=function(t){if(t.preventDefault(),e._visible&&(e._viewer.cameraControl.pointerEnabled=!1,1===t.which)){c=!0;var s=u(t);i[0]=s[0],i[1]=s[1]}}),this._plugin._controlElement.addEventListener("mousemove",this._canvasMouseMoveListener=function(t){if(e._visible&&c&&!o){var s=u(t),r=s[0],n=s[1];A(n-i[1]),i[0]=r,i[1]=n}}),this._plugin._controlElement.addEventListener("mouseup",this._canvasMouseUpListener=function(t){e._visible&&(e._viewer.cameraControl.pointerEnabled=!0,c&&(t.which,c=!1))}),this._plugin._controlElement.addEventListener("wheel",this._canvasWheelListener=function(t){e._visible&&(n+=Math.max(-1,Math.min(1,40*-t.deltaY)))});var h,d,p=null;this._plugin._controlElement.addEventListener("touchstart",this._handleTouchStart=function(t){t.stopPropagation(),t.preventDefault(),e._visible&&(h=t.touches[0].clientY,p=h,n=0)}),this._plugin._controlElement.addEventListener("touchmove",this._handleTouchMove=function(t){t.stopPropagation(),t.preventDefault(),e._visible&&(o||(o=!0,d=t.touches[0].clientY,null!==p&&(n+=d-p),p=d))}),this._plugin._controlElement.addEventListener("touchend",this._handleTouchEnd=function(t){t.stopPropagation(),t.preventDefault(),e._visible&&(h=null,d=null,n=0)})}},{key:"_destroy",value:function(){this._unbindEvents(),this._destroyNodes()}},{key:"_unbindEvents",value:function(){var e=this._viewer,t=e.scene,i=t.canvas.canvas,s=e.camera,r=this._plugin._controlElement;t.off(this._onSceneTick),i.removeEventListener("mousedown",this._canvasMouseDownListener),i.removeEventListener("mousemove",this._canvasMouseMoveListener),i.removeEventListener("mouseup",this._canvasMouseUpListener),i.removeEventListener("wheel",this._canvasWheelListener),r.removeEventListener("touchstart",this._handleTouchStart),r.removeEventListener("touchmove",this._handleTouchMove),r.removeEventListener("touchend",this._handleTouchEnd),s.off(this._onCameraViewMatrix),s.off(this._onCameraProjMatrix)}},{key:"_destroyNodes",value:function(){this._setSectionPlane(null),this._rootNode.destroy(),this._displayMeshes={},this._affordanceMeshes={}}}]),e}(),VF=function(){function e(t,i,s){var r=this;x(this,e),this.id=s.id,this._sectionPlane=s,this._mesh=new sn(i,{id:s.id,geometry:new Si(i,Ti({xSize:.5,ySize:.5,zSize:.001})),material:new Oi(i,{emissive:[1,1,1],diffuse:[0,0,0],backfaces:!1}),edgeMaterial:new Hi(i,{edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),highlightMaterial:new Qi(i,{fill:!0,fillColor:[.5,1,.5],fillAlpha:.7,edges:!0,edgeColor:[0,0,0],edgeAlpha:1,edgeWidth:1}),selectedMaterial:new Qi(i,{fill:!0,fillColor:[0,0,1],fillAlpha:.7,edges:!0,edgeColor:[1,0,0],edgeAlpha:1,edgeWidth:1}),highlighted:!0,scale:[3,3,3],position:[0,0,0],rotation:[0,0,0],opacity:.3,edges:!0});var n=$.vec3([0,0,0]),o=$.vec3(),a=$.vec3([0,0,1]),l=$.vec4(4),u=$.vec3(),A=function(){var e=r._sectionPlane.scene.center,t=[-r._sectionPlane.dir[0],-r._sectionPlane.dir[1],-r._sectionPlane.dir[2]];$.subVec3(e,r._sectionPlane.pos,n);var i=-$.dotVec3(t,n);$.normalizeVec3(t),$.mulVec3Scalar(t,i,o);var s=$.vec3PairToQuaternion(a,r._sectionPlane.dir,l);u[0]=.1*o[0],u[1]=.1*o[1],u[2]=.1*o[2],r._mesh.quaternion=s,r._mesh.position=u};this._onSectionPlanePos=this._sectionPlane.on("pos",A),this._onSectionPlaneDir=this._sectionPlane.on("dir",A),this._highlighted=!1,this._selected=!1}return C(e,[{key:"setHighlighted",value:function(e){this._highlighted=!!e,this._mesh.highlighted=this._highlighted,this._mesh.highlightMaterial.fillColor=e?[0,.7,0]:[0,0,0]}},{key:"getHighlighted",value:function(){return this._highlighted}},{key:"setSelected",value:function(e){this._selected=!!e,this._mesh.edgeMaterial.edgeWidth=e?3:1,this._mesh.highlightMaterial.edgeWidth=e?3:1}},{key:"getSelected",value:function(){return this._selected}},{key:"destroy",value:function(){this._sectionPlane.off(this._onSectionPlanePos),this._sectionPlane.off(this._onSectionPlaneDir),this._mesh.destroy()}}]),e}(),HF=function(){function e(t,i){var s=this;if(x(this,e),!(i.onHoverEnterPlane&&i.onHoverLeavePlane&&i.onClickedNothing&&i.onClickedPlane))throw"Missing config(s): onHoverEnterPlane, onHoverLeavePlane, onClickedNothing || onClickedPlane";this.plugin=t,this._viewer=t.viewer,this._onHoverEnterPlane=i.onHoverEnterPlane,this._onHoverLeavePlane=i.onHoverLeavePlane,this._onClickedNothing=i.onClickedNothing,this._onClickedPlane=i.onClickedPlane,this._visible=!0,this._planes={},this._canvas=i.overviewCanvas,this._scene=new Zi(this._viewer,{canvasId:this._canvas.id,transparent:!0}),this._scene.clearLights(),new yi(this._scene,{dir:[.4,-.4,.8],color:[.8,1,1],intensity:1,space:"view"}),new yi(this._scene,{dir:[-.8,-.3,-.4],color:[.8,.8,.8],intensity:1,space:"view"}),new yi(this._scene,{dir:[.8,-.6,-.8],color:[1,1,1],intensity:1,space:"view"}),this._scene.camera,this._scene.camera.perspective.fov=70,this._zUp=!1;var r=this._scene.camera,n=$.rotationMat4c(-90*$.DEGTORAD,1,0,0),o=$.vec3(),a=$.vec3(),l=$.vec3();this._synchCamera=function(){var e=s._viewer.camera.eye,t=s._viewer.camera.look,i=s._viewer.camera.up;$.mulVec3Scalar($.normalizeVec3($.subVec3(e,t,o)),7),s._zUp?($.transformVec3(n,o,a),$.transformVec3(n,i,l),r.look=[0,0,0],r.eye=$.transformVec3(n,o,a),r.up=$.transformPoint3(n,i,l)):(r.look=[0,0,0],r.eye=o,r.up=i)},this._onViewerCameraMatrix=this._viewer.camera.on("matrix",this._synchCamera),this._onViewerCameraWorldAxis=this._viewer.camera.on("worldAxis",this._synchCamera),this._onViewerCameraFOV=this._viewer.camera.perspective.on("fov",(function(e){s._scene.camera.perspective.fov=e}));var u=null;this._onInputMouseMove=this._scene.input.on("mousemove",(function(e){var t=s._scene.pick({canvasPos:e});if(t){if(!u||t.entity.id!==u.id){if(u)s._planes[u.id]&&s._onHoverLeavePlane(u.id);u=t.entity,s._planes[u.id]&&s._onHoverEnterPlane(u.id)}}else u&&(s._onHoverLeavePlane(u.id),u=null)})),this._scene.canvas.canvas.addEventListener("mouseup",this._onCanvasMouseUp=function(){u?s._planes[u.id]&&s._onClickedPlane(u.id):s._onClickedNothing()}),this._scene.canvas.canvas.addEventListener("mouseout",this._onCanvasMouseOut=function(){u&&(s._onHoverLeavePlane(u.id),u=null)}),this.setVisible(i.overviewVisible)}return C(e,[{key:"addSectionPlane",value:function(e){this._planes[e.id]=new VF(this,this._scene,e)}},{key:"setPlaneHighlighted",value:function(e,t){var i=this._planes[e];i&&i.setHighlighted(t)}},{key:"setPlaneSelected",value:function(e,t){var i=this._planes[e];i&&i.setSelected(t)}},{key:"removeSectionPlane",value:function(e){var t=this._planes[e.id];t&&(t.destroy(),delete this._planes[e.id])}},{key:"setVisible",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._visible=e,this._canvas.style.visibility=e?"visible":"hidden"}},{key:"getVisible",value:function(){return this._visible}},{key:"destroy",value:function(){this._viewer.camera.off(this._onViewerCameraMatrix),this._viewer.camera.off(this._onViewerCameraWorldAxis),this._viewer.camera.perspective.off(this._onViewerCameraFOV),this._scene.input.off(this._onInputMouseMove),this._scene.canvas.canvas.removeEventListener("mouseup",this._onCanvasMouseUp),this._scene.canvas.canvas.removeEventListener("mouseout",this._onCanvasMouseOut),this._scene.destroy()}}]),e}(),jF=$.AABB3(),GF=$.vec3(),zF=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,"FaceAlignedSectionPlanesPlugin",e))._freeControls=[],s._sectionPlanes=e.scene.sectionPlanes,s._controls={},s._shownControlId=null,s._dragSensitivity=r.dragSensitivity||1,null!==r.overviewCanvasId&&void 0!==r.overviewCanvasId){var n=document.getElementById(r.overviewCanvasId);n?s._overview=new HF(b(s),{overviewCanvas:n,visible:r.overviewVisible,onHoverEnterPlane:function(e){s._overview.setPlaneHighlighted(e,!0)},onHoverLeavePlane:function(e){s._overview.setPlaneHighlighted(e,!1)},onClickedPlane:function(e){if(s.getShownControl()!==e){s.showControl(e);var t=s.sectionPlanes[e].pos;jF.set(s.viewer.scene.aabb),$.getAABB3Center(jF,GF),jF[0]+=t[0]-GF[0],jF[1]+=t[1]-GF[1],jF[2]+=t[2]-GF[2],jF[3]+=t[0]-GF[0],jF[4]+=t[1]-GF[1],jF[5]+=t[2]-GF[2],s.viewer.cameraFlight.flyTo({aabb:jF,fitFOV:65})}else s.hideControl()},onClickedNothing:function(){s.hideControl()}}):s.warn("Can't find overview canvas: '"+r.overviewCanvasId+"' - will create plugin without overview")}return null===r.controlElementId||void 0===r.controlElementId?s.error("Parameter expected: controlElementId"):(s._controlElement=document.getElementById(r.controlElementId),s._controlElement||s.warn("Can't find control element: '"+r.controlElementId+"' - will create plugin without control element")),s._onSceneSectionPlaneCreated=e.scene.on("sectionPlaneCreated",(function(e){s._sectionPlaneCreated(e)})),s}return C(i,[{key:"setDragSensitivity",value:function(e){this._dragSensitivity=e||1}},{key:"getDragSensitivity",value:function(){return this._dragSensitivity}},{key:"setOverviewVisible",value:function(e){this._overview&&this._overview.setVisible(e)}},{key:"getOverviewVisible",value:function(){if(this._overview)return this._overview.getVisible()}},{key:"sectionPlanes",get:function(){return this._sectionPlanes}},{key:"createSectionPlane",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};void 0!==e.id&&null!==e.id&&this.viewer.scene.components[e.id]&&(this.error("Viewer component with this ID already exists: "+e.id),delete e.id);var t=new An(this.viewer.scene,{id:e.id,pos:e.pos,dir:e.dir,active:!0});return t}},{key:"_sectionPlaneCreated",value:function(e){var t=this,i=this._freeControls.length>0?this._freeControls.pop():new QF(this);i._setSectionPlane(e),i.setVisible(!1),this._controls[e.id]=i,this._overview&&this._overview.addSectionPlane(e),e.once("destroyed",(function(){t._sectionPlaneDestroyed(e)}))}},{key:"flipSectionPlanes",value:function(){var e=this.viewer.scene.sectionPlanes;for(var t in e){e[t].flipDir()}}},{key:"showControl",value:function(e){var t=this._controls[e];t?(this.hideControl(),t.setVisible(!0),this._overview&&this._overview.setPlaneSelected(e,!0),this._shownControlId=e):this.error("Control not found: "+e)}},{key:"getShownControl",value:function(){return this._shownControlId}},{key:"hideControl",value:function(){for(var e in this._controls)this._controls.hasOwnProperty(e)&&(this._controls[e].setVisible(!1),this._overview&&this._overview.setPlaneSelected(e,!1));this._shownControlId=null}},{key:"destroySectionPlane",value:function(e){var t=this.viewer.scene.sectionPlanes[e];t?(this._sectionPlaneDestroyed(t),t.destroy(),e===this._shownControlId&&(this._shownControlId=null)):this.error("SectionPlane not found: "+e)}},{key:"_sectionPlaneDestroyed",value:function(e){this._overview&&this._overview.removeSectionPlane(e);var t=this._controls[e.id];t&&(t.setVisible(!1),t._setSectionPlane(null),delete this._controls[e.id],this._freeControls.push(t))}},{key:"clear",value:function(){for(var e=Object.keys(this._sectionPlanes),t=0,i=e.length;t>5&31)/31,o=(F>>10&31)/31):(r=l,n=u,o=A),(B&&r!==p||n!==f||o!==v)&&(null!==p&&(g=!0),p=r,f=n,v=o)}for(var E=1;E<=3;E++){var k=x+12*E;y.push(c.getFloat32(k,!0)),y.push(c.getFloat32(k+4,!0)),y.push(c.getFloat32(k+8,!0)),b.push(P,C,M),d&&a.push(r,n,o,1)}B&&g&&($F(i,y,b,a,_,s),y=[],b=[],a=a?[]:null,g=!1)}y.length>0&&$F(i,y,b,a,_,s)}function qF(e,t,i,s){for(var r,n,o,a,l,u,A,c=/facet([\s\S]*?)endfacet/g,h=0,d=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,p=new RegExp("vertex"+d+d+d,"g"),f=new RegExp("normal"+d+d+d,"g"),v=[],g=[];null!==(a=c.exec(t));){for(l=0,u=0,A=a[0];null!==(a=f.exec(A));)r=parseFloat(a[1]),n=parseFloat(a[2]),o=parseFloat(a[3]),u++;for(;null!==(a=p.exec(A));)v.push(parseFloat(a[1]),parseFloat(a[2]),parseFloat(a[3])),g.push(r,n,o),l++;1!==u&&e.error("Error in normal of face "+h),3!==l&&e.error("Error in positions of face "+h),h++}$F(i,v,g,null,new xn(i,{roughness:.5}),s)}function $F(e,t,i,s,r,n){for(var o=new Int32Array(t.length/3),a=0,l=o.length;a0?i:null,s=s&&s.length>0?s:null,n.smoothNormals&&$.faceToVertexNormals(t,i,n);var u=XF;Ue(t,t,u);var A=new Si(e,{primitive:"triangles",positions:t,normals:i,colors:s,indices:o}),c=new sn(e,{origin:0!==u[0]||0!==u[1]||0!==u[2]?u:null,geometry:A,material:r,edges:n.edges});e.addChild(c)}function eE(e){return"string"!=typeof e?function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",i=0,s=e.length;i1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"STLLoader",e,r))._sceneGraphLoader=new JF,s.dataSource=r.dataSource,s}return C(i,[{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new KF}},{key:"load",value:function(e){e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new yn(this.viewer.scene,le.apply(e,{isModel:!0})),i=e.src,s=e.stl;return i||s?(i?this._sceneGraphLoader.load(this,t,i,e):this._sceneGraphLoader.parse(this,t,s,e),t):(this.error("load() param expected: either 'src' or 'stl'"),t)}}]),i}(),sE=function(){function e(){x(this,e)}return C(e,[{key:"createRootNode",value:function(){return document.createElement("ul")}},{key:"createNodeElement",value:function(e,t,i,s,r){var n=document.createElement("li");if(n.id=e.nodeId,e.xrayed&&n.classList.add("xrayed-node"),e.children.length>0){var o=document.createElement("a");o.href="#",o.id="switch-".concat(e.nodeId),o.textContent="+",o.classList.add("plus"),t&&o.addEventListener("click",t),n.appendChild(o)}var a=document.createElement("input");a.id="checkbox-".concat(e.nodeId),a.type="checkbox",a.checked=e.checked,a.style["pointer-events"]="all",i&&a.addEventListener("change",i),n.appendChild(a);var l=document.createElement("span");return l.textContent=e.title,n.appendChild(l),s&&(l.oncontextmenu=s),r&&(l.onclick=r),n}},{key:"createDisabledNodeElement",value:function(e){var t=document.createElement("li"),i=document.createElement("a");i.href="#",i.textContent="!",i.classList.add("warn"),i.classList.add("warning"),t.appendChild(i);var s=document.createElement("span");return s.textContent=e,t.appendChild(s),t}},{key:"addChildren",value:function(e,t){var i=document.createElement("ul");t.forEach((function(e){i.appendChild(e)})),e.parentElement.appendChild(i)}},{key:"expand",value:function(e,t,i){e.classList.remove("plus"),e.classList.add("minus"),e.textContent="-",e.removeEventListener("click",t),e.addEventListener("click",i)}},{key:"collapse",value:function(e,t,i){if(e){var s=e.parentElement;if(s){var r=s.querySelector("ul");r&&(s.removeChild(r),e.classList.remove("minus"),e.classList.add("plus"),e.textContent="+",e.removeEventListener("click",i),e.addEventListener("click",t))}}}},{key:"isExpanded",value:function(e){return void 0!==e.parentElement.getElementsByTagName("li")[0]}},{key:"getId",value:function(e){return e.parentElement.id}},{key:"getIdFromCheckbox",value:function(e){return e.id.replace("checkbox-","")}},{key:"getSwitchElement",value:function(e){return document.getElementById("switch-".concat(e))}},{key:"isChecked",value:function(e){return e.checked}},{key:"setCheckbox",value:function(e,t){var i=document.getElementById("checkbox-".concat(e));i&&t!==i.checked&&(i.checked=t)}},{key:"setXRayed",value:function(e,t){var i=document.getElementById(e);i&&(t?i.classList.add("xrayed-node"):i.classList.remove("xrayed-node"))}},{key:"setHighlighted",value:function(e,t){var i=document.getElementById(e);i&&(t?(i.scrollIntoView({block:"center"}),i.classList.add("highlighted-node")):i.classList.remove("highlighted-node"))}}]),e}(),rE=[],nE=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,i),(s=t.call(this,"TreeViewPlugin",e)).errors=[],s.valid=!0;var n=r.containerElement||document.getElementById(r.containerElementId);if(!(n instanceof HTMLElement))return s.error("Mandatory config expected: valid containerElementId or containerElement"),y(s);for(var o=0;;o++)if(!rE[o]){rE[o]=b(s),s._index=o,s._id="tree-".concat(o);break}if(s._containerElement=n,s._metaModels={},s._autoAddModels=!1!==r.autoAddModels,s._autoExpandDepth=r.autoExpandDepth||0,s._sortNodes=!1!==r.sortNodes,s._viewer=e,s._rootElement=null,s._muteSceneEvents=!1,s._muteTreeEvents=!1,s._rootNodes=[],s._objectNodes={},s._nodeNodes={},s._rootNames={},s._sortNodes=r.sortNodes,s._pruneEmptyNodes=r.pruneEmptyNodes,s._showListItemElementId=null,s._renderService=r.renderService||new sE,!s._renderService)throw new Error("TreeViewPlugin: no render service set");if(s._containerElement.oncontextmenu=function(e){e.preventDefault()},s._onObjectVisibility=s._viewer.scene.on("objectVisibility",(function(e){if(!s._muteSceneEvents){var t=e.id,i=s._objectNodes[t];if(i){var r=e.visible;if(r!==i.checked){s._muteTreeEvents=!0,i.checked=r,r?i.numVisibleEntities++:i.numVisibleEntities--,s._renderService.setCheckbox(i.nodeId,r);for(var n=i.parent;n;)n.checked=r,r?n.numVisibleEntities++:n.numVisibleEntities--,s._renderService.setCheckbox(n.nodeId,n.numVisibleEntities>0),n=n.parent;s._muteTreeEvents=!1}}}})),s._onObjectXrayed=s._viewer.scene.on("objectXRayed",(function(e){if(!s._muteSceneEvents){var t=e.id,i=s._objectNodes[t];if(i){s._muteTreeEvents=!0;var r=e.xrayed;r!==i.xrayed&&(i.xrayed=r,s._renderService.setXRayed(i.nodeId,r),s._muteTreeEvents=!1)}}})),s._switchExpandHandler=function(e){e.preventDefault(),e.stopPropagation();var t=e.target;s._expandSwitchElement(t)},s._switchCollapseHandler=function(e){e.preventDefault(),e.stopPropagation();var t=e.target;s._collapseSwitchElement(t)},s._checkboxChangeHandler=function(e){if(!s._muteTreeEvents){s._muteSceneEvents=!0;var t=e.target,i=s._renderService.isChecked(t),r=s._renderService.getIdFromCheckbox(t),n=s._nodeNodes[r],o=s._viewer.scene.objects,a=0;s._withNodeTree(n,(function(e){var t=e.objectId,r=o[t],n=0===e.children.length;e.numVisibleEntities=i?e.numEntities:0,n&&i!==e.checked&&a++,e.checked=i,s._renderService.setCheckbox(e.nodeId,i),r&&(r.visible=i)}));for(var l=n.parent;l;)l.checked=i,i?l.numVisibleEntities+=a:l.numVisibleEntities-=a,s._renderService.setCheckbox(l.nodeId,l.numVisibleEntities>0),l=l.parent;s._muteSceneEvents=!1}},s._hierarchy=r.hierarchy||"containment",s._autoExpandDepth=r.autoExpandDepth||0,s._autoAddModels){for(var a=Object.keys(s.viewer.metaScene.metaModels),l=0,u=a.length;l1&&void 0!==arguments[1]?arguments[1]:{};if(this._containerElement){var s=this.viewer.scene.models[e];if(!s)throw"Model not found: "+e;var r=this.viewer.metaScene.metaModels[e];r?this._metaModels[e]?this.warn("Model already added: "+e):(this._metaModels[e]=r,i&&i.rootName&&(this._rootNames[e]=i.rootName),s.on("destroyed",(function(){t.removeModel(s.id)})),this._createNodes()):this.error("MetaModel not found: "+e)}}},{key:"removeModel",value:function(e){this._containerElement&&(this._metaModels[e]&&(this._rootNames[e]&&delete this._rootNames[e],delete this._metaModels[e],this._createNodes()))}},{key:"showNode",value:function(e){this.unShowNode();var t=this._objectNodes[e];if(t){var i=t.nodeId,s=this._renderService.getSwitchElement(i);if(s)return this._expandSwitchElement(s),s.scrollIntoView(),!0;var r=[];r.unshift(t);for(var n=t.parent;n;)r.unshift(n),n=n.parent;for(var o=0,a=r.length;o0;return this.valid}},{key:"_validateMetaModelForStoreysHierarchy",value:function(){return!0}},{key:"_createEnabledNodes",value:function(){switch(this._pruneEmptyNodes&&this._findEmptyNodes(),this._hierarchy){case"storeys":this._createStoreysNodes(),0===this._rootNodes.length&&this.error("Failed to build storeys hierarchy");break;case"types":this._createTypesNodes();break;default:this._createContainmentNodes()}this._sortNodes&&this._doSortNodes(),this._synchNodesToEntities(),this._createTrees(),this.expandToDepth(this._autoExpandDepth)}},{key:"_createDisabledNodes",value:function(){var e=this._renderService.createRootNode();this._rootElement=e,this._containerElement.appendChild(e);var t=this._viewer.metaScene.rootMetaObjects;for(var i in t){var s=t[i],r=s.type,n=s.name,o=n&&""!==n&&"Undefined"!==n&&"Default"!==n?n:r,a=this._renderService.createDisabledNodeElement(o);e.appendChild(a)}}},{key:"_findEmptyNodes",value:function(){var e=this._viewer.metaScene.rootMetaObjects;for(var t in e)this._findEmptyNodes2(e[t])}},{key:"_findEmptyNodes2",value:function(e){var t=this.viewer,i=t.scene,s=e.children,r=e.id,n=i.objects[r];if(e._countEntities=0,n&&e._countEntities++,s)for(var o=0,a=s.length;or.aabb[n]?-1:e.aabb[n]s?1:0}},{key:"_synchNodesToEntities",value:function(){for(var e=Object.keys(this.viewer.metaScene.metaObjects),t=this._viewer.metaScene.metaObjects,i=this._viewer.scene.objects,s=0,r=e.length;s0){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"ViewCull",e))._objectCullStates=lE(e.scene),s._maxTreeDepth=r.maxTreeDepth||8,s._modelInfos={},s._frustum=new Me,s._kdRoot=null,s._frustumDirty=!1,s._kdTreeDirty=!1,s._onViewMatrix=e.scene.camera.on("viewMatrix",(function(){s._frustumDirty=!0})),s._onProjMatrix=e.scene.camera.on("projMatMatrix",(function(){s._frustumDirty=!0})),s._onModelLoaded=e.scene.on("modelLoaded",(function(e){var t=s.viewer.scene.models[e];t&&s._addModel(t)})),s._onSceneTick=e.scene.on("tick",(function(){s._doCull()})),s}return C(i,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}},{key:"_addModel",value:function(e){var t=this,i={model:e,onDestroyed:e.on("destroyed",(function(){t._removeModel(e)}))};this._modelInfos[e.id]=i,this._kdTreeDirty=!0}},{key:"_removeModel",value:function(e){var t=this._modelInfos[e.id];t&&(t.model.off(t.onDestroyed),delete this._modelInfos[e.id],this._kdTreeDirty=!0)}},{key:"_doCull",value:function(){var e=this._frustumDirty||this._kdTreeDirty;if(this._frustumDirty&&this._buildFrustum(),this._kdTreeDirty&&this._buildKDTree(),e){var t=this._kdRoot;t&&this._visitKDNode(t)}}},{key:"_buildFrustum",value:function(){var e=this.viewer.scene.camera;Fe(this._frustum,e.viewMatrix,e.projMatrix),this._frustumDirty=!1}},{key:"_buildKDTree",value:function(){var e=this.viewer.scene;this._kdRoot,this._kdRoot={aabb:e.getAABB(),intersection:Me.INTERSECT};for(var t=0,i=this._objectCullStates.numObjects;t=this._maxTreeDepth)return e.objects=e.objects||[],e.objects.push(i),void $.expandAABB3(e.aabb,r);if(e.left&&$.containsAABB3(e.left.aabb,r))this._insertEntityIntoKDTree(e.left,t,i,s+1);else if(e.right&&$.containsAABB3(e.right.aabb,r))this._insertEntityIntoKDTree(e.right,t,i,s+1);else{var n=e.aabb;uE[0]=n[3]-n[0],uE[1]=n[4]-n[1],uE[2]=n[5]-n[2];var o=0;if(uE[1]>uE[o]&&(o=1),uE[2]>uE[o]&&(o=2),!e.left){var a=n.slice();if(a[o+3]=(n[o]+n[o+3])/2,e.left={aabb:a,intersection:Me.INTERSECT},$.containsAABB3(a,r))return void this._insertEntityIntoKDTree(e.left,t,i,s+1)}if(!e.right){var l=n.slice();if(l[o]=(n[o]+n[o+3])/2,e.right={aabb:l,intersection:Me.INTERSECT},$.containsAABB3(l,r))return void this._insertEntityIntoKDTree(e.right,t,i,s+1)}e.objects=e.objects||[],e.objects.push(i),$.expandAABB3(e.aabb,r)}}},{key:"_visitKDNode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Me.INTERSECT;if(t===Me.INTERSECT||e.intersects!==t){t===Me.INTERSECT&&(t=Ee(this._frustum,e.aabb),e.intersects=t);var i=t===Me.OUTSIDE,s=e.objects;if(s&&s.length>0)for(var r=0,n=s.length;r=0;)e[t]=0}var i=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),s=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),r=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o=new Array(576);t(o);var a=new Array(60);t(a);var l=new Array(512);t(l);var u=new Array(256);t(u);var A=new Array(29);t(A);var c,h,d,p=new Array(30);function f(e,t,i,s,r){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=s,this.max_length=r,this.has_stree=e&&e.length}function v(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}t(p);var g=function(e){return e<256?l[e]:l[256+(e>>>7)]},m=function(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},_=function(e,t,i){e.bi_valid>16-i?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<>>=1,i<<=1}while(--t>0);return i>>>1},B=function(e,t,i){var s,r,n=new Array(16),o=0;for(s=1;s<=15;s++)o=o+i[s-1]<<1,n[s]=o;for(r=0;r<=t;r++){var a=e[2*r+1];0!==a&&(e[2*r]=b(n[a]++,a))}},x=function(e){var t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},P=function(e){e.bi_valid>8?m(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},C=function(e,t,i,s){var r=2*t,n=2*i;return e[r]>1;i>=1;i--)M(e,n,i);r=l;do{i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],M(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=s,n[2*r]=n[2*i]+n[2*s],e.depth[r]=(e.depth[i]>=e.depth[s]?e.depth[i]:e.depth[s])+1,n[2*i+1]=n[2*s+1]=r,e.heap[1]=r++,M(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,s,r,n,o,a,l=t.dyn_tree,u=t.max_code,A=t.stat_desc.static_tree,c=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,f=0;for(n=0;n<=15;n++)e.bl_count[n]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<573;i++)(n=l[2*l[2*(s=e.heap[i])+1]+1]+1)>p&&(n=p,f++),l[2*s+1]=n,s>u||(e.bl_count[n]++,o=0,s>=d&&(o=h[s-d]),a=l[2*s],e.opt_len+=a*(n+o),c&&(e.static_len+=a*(A[2*s+1]+o)));if(0!==f){do{for(n=p-1;0===e.bl_count[n];)n--;e.bl_count[n]--,e.bl_count[n+1]+=2,e.bl_count[p]--,f-=2}while(f>0);for(n=p;0!==n;n--)for(s=e.bl_count[n];0!==s;)(r=e.heap[--i])>u||(l[2*r+1]!==n&&(e.opt_len+=(n-l[2*r+1])*l[2*r],l[2*r+1]=n),s--)}}(e,t),B(n,u,e.bl_count)},k=function(e,t,i){var s,r,n=-1,o=t[1],a=0,l=7,u=4;for(0===o&&(l=138,u=3),t[2*(i+1)+1]=65535,s=0;s<=i;s++)r=o,o=t[2*(s+1)+1],++a>=7;v<30;v++)for(p[v]=g<<7,e=0;e<1<0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),E(e,e.l_desc),E(e,e.d_desc),u=function(e){var t;for(k(e,e.dyn_ltree,e.l_desc.max_code),k(e,e.dyn_dtree,e.d_desc.max_code),E(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*n[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),r=e.opt_len+3+7>>>3,(l=e.static_len+3+7>>>3)<=r&&(r=l)):r=l=i+5,i+4<=r&&-1!==t?S(e,t,i,s):4===e.strategy||l===r?(_(e,2+(s?1:0),3),F(e,o,a)):(_(e,4+(s?1:0),3),function(e,t,i,s){var r;for(_(e,t-257,5),_(e,i-1,5),_(e,s-4,4),r=0;r>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(u[i]+256+1)]++,e.dyn_dtree[2*g(t)]++),e.sym_next===e.sym_end},O=function(e){_(e,2,3),y(e,256,o),function(e){16===e.bi_valid?(m(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)},N=function(e,t,i,s){for(var r=65535&e|0,n=e>>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(r=r+t[s++]|0)|0}while(--o);r%=65521,n%=65521}return r|n<<16|0},Q=new Uint32Array(function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}()),V=function(e,t,i,s){var r=Q,n=s+i;e^=-1;for(var o=s;o>>8^r[255&(e^t[o])];return-1^e},H={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},j={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},G=T,z=R,W=L,K=U,X=O,J=j.Z_NO_FLUSH,Y=j.Z_PARTIAL_FLUSH,Z=j.Z_FULL_FLUSH,q=j.Z_FINISH,$=j.Z_BLOCK,ee=j.Z_OK,te=j.Z_STREAM_END,ie=j.Z_STREAM_ERROR,se=j.Z_DATA_ERROR,re=j.Z_BUF_ERROR,ne=j.Z_DEFAULT_COMPRESSION,oe=j.Z_FILTERED,ae=j.Z_HUFFMAN_ONLY,le=j.Z_RLE,ue=j.Z_FIXED,Ae=j.Z_UNKNOWN,ce=j.Z_DEFLATED,he=258,de=262,pe=42,fe=113,ve=666,ge=function(e,t){return e.msg=H[t],t},me=function(e){return 2*e-(e>4?9:0)},_e=function(e){for(var t=e.length;--t>=0;)e[t]=0},ye=function(e){var t,i,s,r=e.w_size;s=t=e.hash_size;do{i=e.head[--s],e.head[s]=i>=r?i-r:0}while(--t);s=t=r;do{i=e.prev[--s],e.prev[s]=i>=r?i-r:0}while(--t)},be=function(e,t,i){return(t<e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},we=function(e,t){W(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Be(e.strm)},xe=function(e,t){e.pending_buf[e.pending++]=t},Pe=function(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},Ce=function(e,t,i,s){var r=e.avail_in;return r>s&&(r=s),0===r?0:(e.avail_in-=r,t.set(e.input.subarray(e.next_in,e.next_in+r),i),1===e.state.wrap?e.adler=N(e.adler,t,r,i):2===e.state.wrap&&(e.adler=V(e.adler,t,r,i)),e.next_in+=r,e.total_in+=r,r)},Me=function(e,t){var i,s,r=e.max_chain_length,n=e.strstart,o=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-de?e.strstart-(e.w_size-de):0,u=e.window,A=e.w_mask,c=e.prev,h=e.strstart+he,d=u[n+o-1],p=u[n+o];e.prev_length>=e.good_match&&(r>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(i=t)+o]===p&&u[i+o-1]===d&&u[i]===u[n]&&u[++i]===u[n+1]){n+=2,i++;do{}while(u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&u[++n]===u[++i]&&no){if(e.match_start=t,o=s,s>=a)break;d=u[n+o-1],p=u[n+o]}}}while((t=c[t&A])>l&&0!=--r);return o<=e.lookahead?o:e.lookahead},Fe=function(e){var t,i,s,r=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=r+(r-de)&&(e.window.set(e.window.subarray(r,r+r-i),0),e.match_start-=r,e.strstart-=r,e.block_start-=r,e.insert>e.strstart&&(e.insert=e.strstart),ye(e),i+=r),0===e.strm.avail_in)break;if(t=Ce(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=t,e.lookahead+e.insert>=3)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=be(e,e.ins_h,e.window[s+1]);e.insert&&(e.ins_h=be(e,e.ins_h,e.window[s+3-1]),e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookaheade.w_size?e.w_size:e.pending_buf_size-5,o=0,a=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_out(s=e.strstart-e.block_start)+e.strm.avail_in&&(i=s+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,Be(e.strm),s&&(s>i&&(s=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+s),e.strm.next_out),e.strm.next_out+=s,e.strm.avail_out-=s,e.strm.total_out+=s,e.block_start+=s,i-=s),i&&(Ce(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===o);return(a-=e.strm.avail_in)&&(a>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=a&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-a,e.strm.next_in),e.strstart),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(Ce(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,n=(r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r)>e.w_size?e.w_size:r,((s=e.strstart-e.block_start)>=n||(s||t===q)&&t!==J&&0===e.strm.avail_in&&s<=r)&&(i=s>r?r:s,o=t===q&&0===e.strm.avail_in&&i===s?1:0,z(e,e.block_start,i,o),e.block_start+=i,Be(e.strm)),o?3:1)},ke=function(e,t){for(var i,s;;){if(e.lookahead=3&&(e.ins_h=be(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-de&&(e.match_length=Me(e,i)),e.match_length>=3)if(s=K(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=be(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=be(e,e.ins_h,e.window[e.strstart+1]);else s=K(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(s&&(we(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===q?(we(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(we(e,!1),0===e.strm.avail_out)?1:2},Ie=function(e,t){for(var i,s,r;;){if(e.lookahead=3&&(e.ins_h=be(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-3,s=K(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=r&&(e.ins_h=be(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,s&&(we(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((s=K(e,0,e.window[e.strstart-1]))&&we(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(s=K(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===q?(we(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(we(e,!1),0===e.strm.avail_out)?1:2};function De(e,t,i,s,r){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=s,this.func=r}var Se=[new De(0,0,0,0,Ee),new De(4,4,8,4,ke),new De(4,5,16,8,ke),new De(4,6,32,32,ke),new De(4,4,16,16,Ie),new De(8,16,32,32,Ie),new De(8,16,128,128,Ie),new De(8,32,128,256,Ie),new De(32,128,258,1024,Ie),new De(32,258,258,4096,Ie)];function Te(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ce,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),_e(this.dyn_ltree),_e(this.dyn_dtree),_e(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),_e(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),_e(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Re=function(e){if(!e)return 1;var t=e.state;return!t||t.strm!==e||t.status!==pe&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==fe&&t.status!==ve?1:0},Le=function(e){if(Re(e))return ge(e,ie);e.total_in=e.total_out=0,e.data_type=Ae;var t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?pe:fe,e.adler=2===t.wrap?0:1,t.last_flush=-2,G(t),ee},Ue=function(e){var t,i=Le(e);return i===ee&&((t=e.state).window_size=2*t.w_size,_e(t.head),t.max_lazy_match=Se[t.level].max_lazy,t.good_match=Se[t.level].good_length,t.nice_match=Se[t.level].nice_length,t.max_chain_length=Se[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),i},Oe=function(e,t,i,s,r,n){if(!e)return ie;var o=1;if(t===ne&&(t=6),s<0?(o=0,s=-s):s>15&&(o=2,s-=16),r<1||r>9||i!==ce||s<8||s>15||t<0||t>9||n<0||n>ue||8===s&&1!==o)return ge(e,ie);8===s&&(s=9);var a=new Te;return e.state=a,a.strm=e,a.status=pe,a.wrap=o,a.gzhead=null,a.w_bits=s,a.w_size=1<$||t<0)return e?ge(e,ie):ie;var i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===ve&&t!==q)return ge(e,0===e.avail_out?re:ie);var s=i.last_flush;if(i.last_flush=t,0!==i.pending){if(Be(e),0===e.avail_out)return i.last_flush=-1,ee}else if(0===e.avail_in&&me(t)<=me(s)&&t!==q)return ge(e,re);if(i.status===ve&&0!==e.avail_in)return ge(e,re);if(i.status===pe&&0===i.wrap&&(i.status=fe),i.status===pe){var r=ce+(i.w_bits-8<<4)<<8;if(r|=(i.strategy>=ae||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(r|=32),Pe(i,r+=31-r%31),0!==i.strstart&&(Pe(i,e.adler>>>16),Pe(i,65535&e.adler)),e.adler=1,i.status=fe,Be(e),0!==i.pending)return i.last_flush=-1,ee}if(57===i.status)if(e.adler=0,xe(i,31),xe(i,139),xe(i,8),i.gzhead)xe(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),xe(i,255&i.gzhead.time),xe(i,i.gzhead.time>>8&255),xe(i,i.gzhead.time>>16&255),xe(i,i.gzhead.time>>24&255),xe(i,9===i.level?2:i.strategy>=ae||i.level<2?4:0),xe(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(xe(i,255&i.gzhead.extra.length),xe(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=V(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(xe(i,0),xe(i,0),xe(i,0),xe(i,0),xe(i,0),xe(i,9===i.level?2:i.strategy>=ae||i.level<2?4:0),xe(i,3),i.status=fe,Be(e),0!==i.pending)return i.last_flush=-1,ee;if(69===i.status){if(i.gzhead.extra){for(var n=i.pending,o=(65535&i.gzhead.extra.length)-i.gzindex;i.pending+o>i.pending_buf_size;){var a=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+a),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>n&&(e.adler=V(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex+=a,Be(e),0!==i.pending)return i.last_flush=-1,ee;n=0,o-=a}var l=new Uint8Array(i.gzhead.extra);i.pending_buf.set(l.subarray(i.gzindex,i.gzindex+o),i.pending),i.pending+=o,i.gzhead.hcrc&&i.pending>n&&(e.adler=V(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){var u,A=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>A&&(e.adler=V(e.adler,i.pending_buf,i.pending-A,A)),Be(e),0!==i.pending)return i.last_flush=-1,ee;A=0}u=i.gzindexA&&(e.adler=V(e.adler,i.pending_buf,i.pending-A,A)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){var c,h=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>h&&(e.adler=V(e.adler,i.pending_buf,i.pending-h,h)),Be(e),0!==i.pending)return i.last_flush=-1,ee;h=0}c=i.gzindexh&&(e.adler=V(e.adler,i.pending_buf,i.pending-h,h))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(Be(e),0!==i.pending))return i.last_flush=-1,ee;xe(i,255&e.adler),xe(i,e.adler>>8&255),e.adler=0}if(i.status=fe,Be(e),0!==i.pending)return i.last_flush=-1,ee}if(0!==e.avail_in||0!==i.lookahead||t!==J&&i.status!==ve){var d=0===i.level?Ee(i,t):i.strategy===ae?function(e,t){for(var i;;){if(0===e.lookahead&&(Fe(e),0===e.lookahead)){if(t===J)return 1;break}if(e.match_length=0,i=K(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(we(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===q?(we(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(we(e,!1),0===e.strm.avail_out)?1:2}(i,t):i.strategy===le?function(e,t){for(var i,s,r,n,o=e.window;;){if(e.lookahead<=he){if(Fe(e),e.lookahead<=he&&t===J)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&((s=o[r=e.strstart-1])===o[++r]&&s===o[++r]&&s===o[++r])){n=e.strstart+he;do{}while(s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&s===o[++r]&&re.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=K(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=K(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(we(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===q?(we(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(we(e,!1),0===e.strm.avail_out)?1:2}(i,t):Se[i.level].func(i,t);if(3!==d&&4!==d||(i.status=ve),1===d||3===d)return 0===e.avail_out&&(i.last_flush=-1),ee;if(2===d&&(t===Y?X(i):t!==$&&(z(i,0,0,!1),t===Z&&(_e(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),Be(e),0===e.avail_out))return i.last_flush=-1,ee}return t!==q?ee:i.wrap<=0?te:(2===i.wrap?(xe(i,255&e.adler),xe(i,e.adler>>8&255),xe(i,e.adler>>16&255),xe(i,e.adler>>24&255),xe(i,255&e.total_in),xe(i,e.total_in>>8&255),xe(i,e.total_in>>16&255),xe(i,e.total_in>>24&255)):(Pe(i,e.adler>>>16),Pe(i,65535&e.adler)),Be(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?ee:te)},He=function(e){if(Re(e))return ie;var t=e.state.status;return e.state=null,t===fe?ge(e,se):ee},je=function(e,t){var i=t.length;if(Re(e))return ie;var s=e.state,r=s.wrap;if(2===r||1===r&&s.status!==pe||s.lookahead)return ie;if(1===r&&(e.adler=N(e.adler,t,i,0)),s.wrap=0,i>=s.w_size){0===r&&(_e(s.head),s.strstart=0,s.block_start=0,s.insert=0);var n=new Uint8Array(s.w_size);n.set(t.subarray(i-s.w_size,i),0),t=n,i=s.w_size}var o=e.avail_in,a=e.next_in,l=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,Fe(s);s.lookahead>=3;){var u=s.strstart,A=s.lookahead-2;do{s.ins_h=be(s,s.ins_h,s.window[u+3-1]),s.prev[u&s.w_mask]=s.head[s.ins_h],s.head[s.ins_h]=u,u++}while(--A);s.strstart=u,s.lookahead=2,Fe(s)}return s.strstart+=s.lookahead,s.block_start=s.strstart,s.insert=s.lookahead,s.lookahead=0,s.match_length=s.prev_length=2,s.match_available=0,e.next_in=a,e.input=l,e.avail_in=o,s.wrap=r,ee},Ge=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},ze=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=w(i))throw new TypeError(i+"must be non-object");for(var s in i)Ge(i,s)&&(e[s]=i[s])}}return e},We=function(e){for(var t=0,i=0,s=e.length;i=252?6:Je>=248?5:Je>=240?4:Je>=224?3:Je>=192?2:1;Xe[254]=Xe[254]=1;var Ye=function(e){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);var t,i,s,r,n,o=e.length,a=0;for(r=0;r>>6,t[n++]=128|63&i):i<65536?(t[n++]=224|i>>>12,t[n++]=128|i>>>6&63,t[n++]=128|63&i):(t[n++]=240|i>>>18,t[n++]=128|i>>>12&63,t[n++]=128|i>>>6&63,t[n++]=128|63&i);return t},Ze=function(e,t){var i,s,r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));var n=new Array(2*r);for(s=0,i=0;i4)n[s++]=65533,i+=a-1;else{for(o&=2===a?31:3===a?15:7;a>1&&i1?n[s++]=65533:o<65536?n[s++]=o:(o-=65536,n[s++]=55296|o>>10&1023,n[s++]=56320|1023&o)}}}return function(e,t){if(t<65534&&e.subarray&&Ke)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));for(var i="",s=0;se.length&&(t=e.length);for(var i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Xe[e[i]]>t?i:t},$e=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},et=Object.prototype.toString,tt=j.Z_NO_FLUSH,it=j.Z_SYNC_FLUSH,st=j.Z_FULL_FLUSH,rt=j.Z_FINISH,nt=j.Z_OK,ot=j.Z_STREAM_END,at=j.Z_DEFAULT_COMPRESSION,lt=j.Z_DEFAULT_STRATEGY,ut=j.Z_DEFLATED;function At(e){this.options=ze({level:at,method:ut,chunkSize:16384,windowBits:15,memLevel:8,strategy:lt},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $e,this.strm.avail_out=0;var i=Ne(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==nt)throw new Error(H[i]);if(t.header&&Qe(this.strm,t.header),t.dictionary){var s;if(s="string"==typeof t.dictionary?Ye(t.dictionary):"[object ArrayBuffer]"===et.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,(i=je(this.strm,s))!==nt)throw new Error(H[i]);this._dict_set=!0}}function ct(e,t){var i=new At(t);if(i.push(e,!0),i.err)throw i.msg||H[i.err];return i.result}At.prototype.push=function(e,t){var i,s,r=this.strm,n=this.options.chunkSize;if(this.ended)return!1;for(s=t===~~t?t:!0===t?rt:tt,"string"==typeof e?r.input=Ye(e):"[object ArrayBuffer]"===et.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(s===it||s===st)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if((i=Ve(r,s))===ot)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=He(this.strm),this.onEnd(i),this.ended=!0,i===nt;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},At.prototype.onData=function(e){this.chunks.push(e)},At.prototype.onEnd=function(e){e===nt&&(this.result=We(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var ht=At,dt=ct,pt=function(e,t){return(t=t||{}).raw=!0,ct(e,t)},ft=function(e,t){return(t=t||{}).gzip=!0,ct(e,t)},vt=16209,gt=function(e,t){var i,s,r,n,o,a,l,u,A,c,h,d,p,f,v,g,m,_,y,b,B,w,x,P,C=e.state;i=e.next_in,x=e.input,s=i+(e.avail_in-5),r=e.next_out,P=e.output,n=r-(t-e.avail_out),o=r+(e.avail_out-257),a=C.dmax,l=C.wsize,u=C.whave,A=C.wnext,c=C.window,h=C.hold,d=C.bits,p=C.lencode,f=C.distcode,v=(1<>>=_=m>>>24,d-=_,0===(_=m>>>16&255))P[r++]=65535&m;else{if(!(16&_)){if(0==(64&_)){m=p[(65535&m)+(h&(1<<_)-1)];continue t}if(32&_){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=vt;break e}y=65535&m,(_&=15)&&(d<_&&(h+=x[i++]<>>=_,d-=_),d<15&&(h+=x[i++]<>>=_=m>>>24,d-=_,!(16&(_=m>>>16&255))){if(0==(64&_)){m=f[(65535&m)+(h&(1<<_)-1)];continue i}e.msg="invalid distance code",C.mode=vt;break e}if(b=65535&m,d<(_&=15)&&(h+=x[i++]<a){e.msg="invalid distance too far back",C.mode=vt;break e}if(h>>>=_,d-=_,b>(_=r-n)){if((_=b-_)>u&&C.sane){e.msg="invalid distance too far back",C.mode=vt;break e}if(B=0,w=c,0===A){if(B+=l-_,_2;)P[r++]=w[B++],P[r++]=w[B++],P[r++]=w[B++],y-=3;y&&(P[r++]=w[B++],y>1&&(P[r++]=w[B++]))}else{B=r-b;do{P[r++]=P[B++],P[r++]=P[B++],P[r++]=P[B++],y-=3}while(y>2);y&&(P[r++]=P[B++],y>1&&(P[r++]=P[B++]))}break}}break}}while(i>3,h&=(1<<(d-=y<<3))-1,e.next_in=i,e.next_out=r,e.avail_in=i=1&&0===E[b];b--);if(B>b&&(B=b),0===b)return r[n++]=20971520,r[n++]=20971520,a.bits=1,0;for(y=1;y0&&(0===e||1!==b))return-1;for(k[1]=0,m=1;m<15;m++)k[m+1]=k[m]+E[m];for(_=0;_852||2===e&&C>592)return 1;for(;;){p=m-x,o[_]+1=d?(f=I[o[_]-d],v=F[o[_]-d]):(f=96,v=0),l=1<>x)+(u-=l)]=p<<24|f<<16|v|0}while(0!==u);for(l=1<>=1;if(0!==l?(M&=l-1,M+=l):M=0,_++,0==--E[m]){if(m===b)break;m=t[i+o[_]]}if(m>B&&(M&c)!==A){for(0===x&&(x=B),h+=y,P=1<<(w=m-x);w+x852||2===e&&C>592)return 1;r[A=M&c]=B<<24|w<<16|h-n|0}}return 0!==M&&(r[h+M]=m-x<<24|64<<16|0),a.bits=B,0},wt=j.Z_FINISH,xt=j.Z_BLOCK,Pt=j.Z_TREES,Ct=j.Z_OK,Mt=j.Z_STREAM_END,Ft=j.Z_NEED_DICT,Et=j.Z_STREAM_ERROR,kt=j.Z_DATA_ERROR,It=j.Z_MEM_ERROR,Dt=j.Z_BUF_ERROR,St=j.Z_DEFLATED,Tt=16180,Rt=16190,Lt=16191,Ut=16192,Ot=16194,Nt=16199,Qt=16200,Vt=16206,Ht=16209,jt=function(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)};function Gt(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var zt,Wt,Kt=function(e){if(!e)return 1;var t=e.state;return!t||t.strm!==e||t.mode16211?1:0},Xt=function(e){if(Kt(e))return Et;var t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Tt,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Ct},Jt=function(e){if(Kt(e))return Et;var t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Xt(e)},Yt=function(e,t){var i;if(Kt(e))return Et;var s=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Et:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=i,s.wbits=t,Jt(e))},Zt=function(e,t){if(!e)return Et;var i=new Gt;e.state=i,i.strm=e,i.window=null,i.mode=Tt;var s=Yt(e,t);return s!==Ct&&(e.state=null),s},qt=!0,$t=function(e){if(qt){zt=new Int32Array(512),Wt=new Int32Array(32);for(var t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Bt(1,e.lens,0,288,zt,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Bt(2,e.lens,0,32,Wt,0,e.work,{bits:5}),qt=!1}e.lencode=zt,e.lenbits=9,e.distcode=Wt,e.distbits=5},ei=function(e,t,i,s){var r,n=e.state;return null===n.window&&(n.wsize=1<=n.wsize?(n.window.set(t.subarray(i-n.wsize,i),0),n.wnext=0,n.whave=n.wsize):((r=n.wsize-n.wnext)>s&&(r=s),n.window.set(t.subarray(i-s,i-s+r),n.wnext),(s-=r)?(n.window.set(t.subarray(i-s,i),0),n.wnext=s,n.whave=n.wsize):(n.wnext+=r,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=V(i.check,M,2,0),u=0,A=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",i.mode=Ht;break}if((15&u)!==St){e.msg="unknown compression method",i.mode=Ht;break}if(A-=4,B=8+(15&(u>>>=4)),0===i.wbits&&(i.wbits=B),B>15||B>i.wbits){e.msg="invalid window size",i.mode=Ht;break}i.dmax=1<>8&1),512&i.flags&&4&i.wrap&&(M[0]=255&u,M[1]=u>>>8&255,i.check=V(i.check,M,2,0)),u=0,A=0,i.mode=16182;case 16182:for(;A<32;){if(0===a)break e;a--,u+=s[n++]<>>8&255,M[2]=u>>>16&255,M[3]=u>>>24&255,i.check=V(i.check,M,4,0)),u=0,A=0,i.mode=16183;case 16183:for(;A<16;){if(0===a)break e;a--,u+=s[n++]<>8),512&i.flags&&4&i.wrap&&(M[0]=255&u,M[1]=u>>>8&255,i.check=V(i.check,M,2,0)),u=0,A=0,i.mode=16184;case 16184:if(1024&i.flags){for(;A<16;){if(0===a)break e;a--,u+=s[n++]<>>8&255,i.check=V(i.check,M,2,0)),u=0,A=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&((d=i.length)>a&&(d=a),d&&(i.head&&(B=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(s.subarray(n,n+d),B)),512&i.flags&&4&i.wrap&&(i.check=V(i.check,s,d,n)),a-=d,n+=d,i.length-=d),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===a)break e;d=0;do{B=s[n+d++],i.head&&B&&i.length<65536&&(i.head.name+=String.fromCharCode(B))}while(B&&d>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Lt;break;case 16189:for(;A<32;){if(0===a)break e;a--,u+=s[n++]<>>=7&A,A-=7&A,i.mode=Vt;break}for(;A<3;){if(0===a)break e;a--,u+=s[n++]<>>=1)){case 0:i.mode=16193;break;case 1:if($t(i),i.mode=Nt,t===Pt){u>>>=2,A-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=Ht}u>>>=2,A-=2;break;case 16193:for(u>>>=7&A,A-=7&A;A<32;){if(0===a)break e;a--,u+=s[n++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=Ht;break}if(i.length=65535&u,u=0,A=0,i.mode=Ot,t===Pt)break e;case Ot:i.mode=16195;case 16195:if(d=i.length){if(d>a&&(d=a),d>l&&(d=l),0===d)break e;r.set(s.subarray(n,n+d),o),a-=d,n+=d,l-=d,o+=d,i.length-=d;break}i.mode=Lt;break;case 16196:for(;A<14;){if(0===a)break e;a--,u+=s[n++]<>>=5,A-=5,i.ndist=1+(31&u),u>>>=5,A-=5,i.ncode=4+(15&u),u>>>=4,A-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Ht;break}i.have=0,i.mode=16197;case 16197:for(;i.have>>=3,A-=3}for(;i.have<19;)i.lens[F[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,x={bits:i.lenbits},w=Bt(0,i.lens,0,19,i.lencode,0,i.work,x),i.lenbits=x.bits,w){e.msg="invalid code lengths set",i.mode=Ht;break}i.have=0,i.mode=16198;case 16198:for(;i.have>>16&255,m=65535&C,!((v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>>=v,A-=v,i.lens[i.have++]=m;else{if(16===m){for(P=v+2;A>>=v,A-=v,0===i.have){e.msg="invalid bit length repeat",i.mode=Ht;break}B=i.lens[i.have-1],d=3+(3&u),u>>>=2,A-=2}else if(17===m){for(P=v+3;A>>=v)),u>>>=3,A-=3}else{for(P=v+7;A>>=v)),u>>>=7,A-=7}if(i.have+d>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Ht;break}for(;d--;)i.lens[i.have++]=B}}if(i.mode===Ht)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Ht;break}if(i.lenbits=9,x={bits:i.lenbits},w=Bt(1,i.lens,0,i.nlen,i.lencode,0,i.work,x),i.lenbits=x.bits,w){e.msg="invalid literal/lengths set",i.mode=Ht;break}if(i.distbits=6,i.distcode=i.distdyn,x={bits:i.distbits},w=Bt(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,x),i.distbits=x.bits,w){e.msg="invalid distances set",i.mode=Ht;break}if(i.mode=Nt,t===Pt)break e;case Nt:i.mode=Qt;case Qt:if(a>=6&&l>=258){e.next_out=o,e.avail_out=l,e.next_in=n,e.avail_in=a,i.hold=u,i.bits=A,gt(e,h),o=e.next_out,r=e.output,l=e.avail_out,n=e.next_in,s=e.input,a=e.avail_in,u=i.hold,A=i.bits,i.mode===Lt&&(i.back=-1);break}for(i.back=0;g=(C=i.lencode[u&(1<>>16&255,m=65535&C,!((v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>_)])>>>16&255,m=65535&C,!(_+(v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>>=_,A-=_,i.back+=_}if(u>>>=v,A-=v,i.back+=v,i.length=m,0===g){i.mode=16205;break}if(32&g){i.back=-1,i.mode=Lt;break}if(64&g){e.msg="invalid literal/length code",i.mode=Ht;break}i.extra=15&g,i.mode=16201;case 16201:if(i.extra){for(P=i.extra;A>>=i.extra,A-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;g=(C=i.distcode[u&(1<>>16&255,m=65535&C,!((v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>_)])>>>16&255,m=65535&C,!(_+(v=C>>>24)<=A);){if(0===a)break e;a--,u+=s[n++]<>>=_,A-=_,i.back+=_}if(u>>>=v,A-=v,i.back+=v,64&g){e.msg="invalid distance code",i.mode=Ht;break}i.offset=m,i.extra=15&g,i.mode=16203;case 16203:if(i.extra){for(P=i.extra;A>>=i.extra,A-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Ht;break}i.mode=16204;case 16204:if(0===l)break e;if(d=h-l,i.offset>d){if((d=i.offset-d)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Ht;break}d>i.wnext?(d-=i.wnext,p=i.wsize-d):p=i.wnext-d,d>i.length&&(d=i.length),f=i.window}else f=r,p=o-i.offset,d=i.length;d>l&&(d=l),l-=d,i.length-=d;do{r[o++]=f[p++]}while(--d);0===i.length&&(i.mode=Qt);break;case 16205:if(0===l)break e;r[o++]=i.length,l--,i.mode=Qt;break;case Vt:if(i.wrap){for(;A<32;){if(0===a)break e;a--,u|=s[n++]<=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $e,this.strm.avail_out=0;var i=ii(this.strm,t.windowBits);if(i!==ci)throw new Error(H[i]);if(this.header=new ai,ni(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Ye(t.dictionary):"[object ArrayBuffer]"===li.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=oi(this.strm,t.dictionary))!==ci))throw new Error(H[i])}function mi(e,t){var i=new gi(t);if(i.push(e),i.err)throw i.msg||H[i.err];return i.result}gi.prototype.push=function(e,t){var i,s,r,n=this.strm,o=this.options.chunkSize,a=this.options.dictionary;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Ai:ui,"[object ArrayBuffer]"===li.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(o),n.next_out=0,n.avail_out=o),(i=si(n,s))===di&&a&&((i=oi(n,a))===ci?i=si(n,s):i===fi&&(i=di));n.avail_in>0&&i===hi&&n.state.wrap>0&&0!==e[n.next_in];)ti(n),i=si(n,s);switch(i){case pi:case fi:case di:case vi:return this.onEnd(i),this.ended=!0,!1}if(r=n.avail_out,n.next_out&&(0===n.avail_out||i===hi))if("string"===this.options.to){var l=qe(n.output,n.next_out),u=n.next_out-l,A=Ze(n.output,l);n.next_out=u,n.avail_out=o-u,u&&n.output.set(n.output.subarray(l,l+u),0),this.onData(A)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(i!==ci||0!==r){if(i===hi)return i=ri(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},gi.prototype.onData=function(e){this.chunks.push(e)},gi.prototype.onEnd=function(e){e===ci&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=We(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var _i=function(e,t){return(t=t||{}).raw=!0,mi(e,t)},yi=ht,bi=dt,Bi=pt,wi=ft,xi=gi,Pi=mi,Ci=_i,Mi=mi,Fi=j,Ei={Deflate:yi,deflate:bi,deflateRaw:Bi,gzip:wi,Inflate:xi,inflate:Pi,inflateRaw:Ci,ungzip:Mi,constants:Fi};e.Deflate=yi,e.Inflate=xi,e.constants=Fi,e.default=Ei,e.deflate=bi,e.deflateRaw=Bi,e.gzip=wi,e.inflate=Pi,e.inflateRaw=Ci,e.ungzip=Mi,Object.defineProperty(e,"__esModule",{value:!0})}));var hE=Object.freeze({__proto__:null}),dE=window.pako||hE;dE.inflate||(dE=dE.default);var pE,fE=(pE=new Float32Array(3),function(e){return pE[0]=e[0]/255,pE[1]=e[1]/255,pE[2]=e[2]/255,pE});var vE={version:1,parse:function(e,t,i,s,r,n){var o=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],meshPositions:e[4],meshIndices:e[5],meshEdgesIndices:e[6],meshColors:e[7],entityIDs:e[8],entityMeshes:e[9],entityIsObjects:e[10],positionsDecodeMatrix:e[11]}}(i),a=function(e){return{positions:new Uint16Array(dE.inflate(e.positions).buffer),normals:new Int8Array(dE.inflate(e.normals).buffer),indices:new Uint32Array(dE.inflate(e.indices).buffer),edgeIndices:new Uint32Array(dE.inflate(e.edgeIndices).buffer),meshPositions:new Uint32Array(dE.inflate(e.meshPositions).buffer),meshIndices:new Uint32Array(dE.inflate(e.meshIndices).buffer),meshEdgesIndices:new Uint32Array(dE.inflate(e.meshEdgesIndices).buffer),meshColors:new Uint8Array(dE.inflate(e.meshColors).buffer),entityIDs:dE.inflate(e.entityIDs,{to:"string"}),entityMeshes:new Uint32Array(dE.inflate(e.entityMeshes).buffer),entityIsObjects:new Uint8Array(dE.inflate(e.entityIsObjects).buffer),positionsDecodeMatrix:new Float32Array(dE.inflate(e.positionsDecodeMatrix).buffer)}}(o);!function(e,t,i,s,r,n){n.getNextId(),s.positionsCompression="precompressed",s.normalsCompression="precompressed";for(var o=i.positions,a=i.normals,l=i.indices,u=i.edgeIndices,A=i.meshPositions,c=i.meshIndices,h=i.meshEdgesIndices,d=i.meshColors,p=JSON.parse(i.entityIDs),f=i.entityMeshes,v=i.entityIsObjects,g=A.length,m=f.length,_=0;_v[t]?1:0}));for(var F=0;F1||(E[L]=k)}for(var U=0;U1,V=xE(g.subarray(4*O,4*O+3)),H=g[4*O+3]/255,j=a.subarray(d[O],N?a.length:d[O+1]),G=l.subarray(d[O],N?l.length:d[O+1]),z=u.subarray(p[O],N?u.length:p[O+1]),W=A.subarray(f[O],N?A.length:f[O+1]),K=c.subarray(v[O],v[O]+16);if(Q){var X="".concat(o,"-geometry.").concat(O);s.createGeometry({id:X,primitive:"triangles",positionsCompressed:j,normalsCompressed:G,indices:z,edgeIndices:W,positionsDecodeMatrix:K})}else{var J="".concat(o,"-").concat(O);_[E[O]],s.createMesh(le.apply({},{id:J,primitive:"triangles",positionsCompressed:j,normalsCompressed:G,indices:z,edgeIndices:W,positionsDecodeMatrix:K,color:V,opacity:H}))}}for(var Y=0,Z=0;Z1){var oe="".concat(o,"-instance.").concat(Y++),ae="".concat(o,"-geometry.").concat(ne),ue=16*b[Z],Ae=h.subarray(ue,ue+16);s.createMesh(le.apply({},{id:oe,geometryId:ae,matrix:Ae})),se.push(oe)}else se.push(ne)}se.length>0&&s.createEntity(le.apply({},{id:ee,isObject:!0,meshIds:se}))}}(0,0,a,s,0,n)}},CE=window.pako||hE;CE.inflate||(CE=CE.default);var ME=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();var FE={version:5,parse:function(e,t,i,s,r,n){var o=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],eachPrimitivePositionsAndNormalsPortion:e[5],eachPrimitiveIndicesPortion:e[6],eachPrimitiveEdgeIndicesPortion:e[7],eachPrimitiveColor:e[8],primitiveInstances:e[9],eachEntityId:e[10],eachEntityPrimitiveInstancesPortion:e[11],eachEntityMatricesPortion:e[12]}}(i),a=function(e){return{positions:new Float32Array(CE.inflate(e.positions).buffer),normals:new Int8Array(CE.inflate(e.normals).buffer),indices:new Uint32Array(CE.inflate(e.indices).buffer),edgeIndices:new Uint32Array(CE.inflate(e.edgeIndices).buffer),matrices:new Float32Array(CE.inflate(e.matrices).buffer),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(CE.inflate(e.eachPrimitivePositionsAndNormalsPortion).buffer),eachPrimitiveIndicesPortion:new Uint32Array(CE.inflate(e.eachPrimitiveIndicesPortion).buffer),eachPrimitiveEdgeIndicesPortion:new Uint32Array(CE.inflate(e.eachPrimitiveEdgeIndicesPortion).buffer),eachPrimitiveColor:new Uint8Array(CE.inflate(e.eachPrimitiveColor).buffer),primitiveInstances:new Uint32Array(CE.inflate(e.primitiveInstances).buffer),eachEntityId:CE.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(CE.inflate(e.eachEntityPrimitiveInstancesPortion).buffer),eachEntityMatricesPortion:new Uint32Array(CE.inflate(e.eachEntityMatricesPortion).buffer)}}(o);!function(e,t,i,s,r,n){var o=n.getNextId();s.positionsCompression="disabled",s.normalsCompression="precompressed";for(var a=i.positions,l=i.normals,u=i.indices,A=i.edgeIndices,c=i.matrices,h=i.eachPrimitivePositionsAndNormalsPortion,d=i.eachPrimitiveIndicesPortion,p=i.eachPrimitiveEdgeIndicesPortion,f=i.eachPrimitiveColor,v=i.primitiveInstances,g=JSON.parse(i.eachEntityId),m=i.eachEntityPrimitiveInstancesPortion,_=i.eachEntityMatricesPortion,y=h.length,b=v.length,B=new Uint8Array(y),w=g.length,x=0;x1||(P[D]=C)}for(var S=0;S1,L=ME(f.subarray(4*S,4*S+3)),U=f[4*S+3]/255,O=a.subarray(h[S],T?a.length:h[S+1]),N=l.subarray(h[S],T?l.length:h[S+1]),Q=u.subarray(d[S],T?u.length:d[S+1]),V=A.subarray(p[S],T?A.length:p[S+1]);if(R){var H="".concat(o,"-geometry.").concat(S);s.createGeometry({id:H,primitive:"triangles",positionsCompressed:O,normalsCompressed:N,indices:Q,edgeIndices:V})}else{var j=S;g[P[S]],s.createMesh(le.apply({},{id:j,primitive:"triangles",positionsCompressed:O,normalsCompressed:N,indices:Q,edgeIndices:V,color:L,opacity:U}))}}for(var G=0,z=0;z1){var ee="instance."+G++,te="geometry"+$,ie=16*_[z],se=c.subarray(ie,ie+16);s.createMesh(le.apply({},{id:ee,geometryId:te,matrix:se})),Z.push(ee)}else Z.push($)}Z.length>0&&s.createEntity(le.apply({},{id:X,isObject:!0,meshIds:Z}))}}(0,0,a,s,0,n)}},EE=window.pako||hE;EE.inflate||(EE=EE.default);var kE,IE=(kE=new Float32Array(3),function(e){return kE[0]=e[0]/255,kE[1]=e[1]/255,kE[2]=e[2]/255,kE});var DE={version:6,parse:function(e,t,i,s,r,n){var o=function(e){return{positions:e[0],normals:e[1],indices:e[2],edgeIndices:e[3],matrices:e[4],reusedPrimitivesDecodeMatrix:e[5],eachPrimitivePositionsAndNormalsPortion:e[6],eachPrimitiveIndicesPortion:e[7],eachPrimitiveEdgeIndicesPortion:e[8],eachPrimitiveColorAndOpacity:e[9],primitiveInstances:e[10],eachEntityId:e[11],eachEntityPrimitiveInstancesPortion:e[12],eachEntityMatricesPortion:e[13],eachTileAABB:e[14],eachTileEntitiesPortion:e[15]}}(i),a=function(e){function t(e,t){return 0===e.length?[]:EE.inflate(e,t).buffer}return{positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedPrimitivesDecodeMatrix:new Float32Array(t(e.reusedPrimitivesDecodeMatrix)),eachPrimitivePositionsAndNormalsPortion:new Uint32Array(t(e.eachPrimitivePositionsAndNormalsPortion)),eachPrimitiveIndicesPortion:new Uint32Array(t(e.eachPrimitiveIndicesPortion)),eachPrimitiveEdgeIndicesPortion:new Uint32Array(t(e.eachPrimitiveEdgeIndicesPortion)),eachPrimitiveColorAndOpacity:new Uint8Array(t(e.eachPrimitiveColorAndOpacity)),primitiveInstances:new Uint32Array(t(e.primitiveInstances)),eachEntityId:EE.inflate(e.eachEntityId,{to:"string"}),eachEntityPrimitiveInstancesPortion:new Uint32Array(t(e.eachEntityPrimitiveInstancesPortion)),eachEntityMatricesPortion:new Uint32Array(t(e.eachEntityMatricesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(o);!function(e,t,i,s,r,n){for(var o=n.getNextId(),a=i.positions,l=i.normals,u=i.indices,A=i.edgeIndices,c=i.matrices,h=i.reusedPrimitivesDecodeMatrix,d=i.eachPrimitivePositionsAndNormalsPortion,p=i.eachPrimitiveIndicesPortion,f=i.eachPrimitiveEdgeIndicesPortion,v=i.eachPrimitiveColorAndOpacity,g=i.primitiveInstances,m=JSON.parse(i.eachEntityId),_=i.eachEntityPrimitiveInstancesPortion,y=i.eachEntityMatricesPortion,b=i.eachTileAABB,B=i.eachTileEntitiesPortion,w=d.length,x=g.length,P=m.length,C=B.length,M=new Uint32Array(w),F=0;F1,se=te===w-1,re=a.subarray(d[te],se?a.length:d[te+1]),ne=l.subarray(d[te],se?l.length:d[te+1]),oe=u.subarray(p[te],se?u.length:p[te+1]),ae=A.subarray(f[te],se?A.length:f[te+1]),ue=IE(v.subarray(4*te,4*te+3)),Ae=v[4*te+3]/255,ce=n.getNextId();if(ie){var he="".concat(o,"-geometry.").concat(D,".").concat(te);N[he]||(s.createGeometry({id:he,primitive:"triangles",positionsCompressed:re,indices:oe,edgeIndices:ae,positionsDecodeMatrix:h}),N[he]=!0),s.createMesh(le.apply(Z,{id:ce,geometryId:he,origin:k,matrix:G,color:ue,opacity:Ae})),X.push(ce)}else s.createMesh(le.apply(Z,{id:ce,origin:k,primitive:"triangles",positionsCompressed:re,normalsCompressed:ne,indices:oe,edgeIndices:ae,positionsDecodeMatrix:O,color:ue,opacity:Ae})),X.push(ce)}X.length>0&&s.createEntity(le.apply(Y,{id:H,isObject:!0,meshIds:X}))}}}(e,t,a,s,0,n)}},SE=window.pako||hE;SE.inflate||(SE=SE.default);var TE=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function RE(e){for(var t=[],i=0,s=e.length;i1,ne=se===M-1,oe=TE(B.subarray(6*ie,6*ie+3)),ae=B[6*ie+3]/255,ue=B[6*ie+4]/255,Ae=B[6*ie+5]/255,ce=n.getNextId();if(re){var he=b[ie],de=h.slice(he,he+16),pe="".concat(o,"-geometry.").concat(L,".").concat(se);if(!j[pe]){var fe=void 0,ve=void 0,ge=void 0,me=void 0,_e=void 0,ye=void 0;switch(p[se]){case 0:fe="solid",ve=a.subarray(f[se],ne?a.length:f[se+1]),ge=l.subarray(v[se],ne?l.length:v[se+1]),_e=A.subarray(m[se],ne?A.length:m[se+1]),ye=c.subarray(_[se],ne?c.length:_[se+1]);break;case 1:fe="surface",ve=a.subarray(f[se],ne?a.length:f[se+1]),ge=l.subarray(v[se],ne?l.length:v[se+1]),_e=A.subarray(m[se],ne?A.length:m[se+1]),ye=c.subarray(_[se],ne?c.length:_[se+1]);break;case 2:fe="points",ve=a.subarray(f[se],ne?a.length:f[se+1]),me=RE(u.subarray(g[se],ne?u.length:g[se+1]));break;case 3:fe="lines",ve=a.subarray(f[se],ne?a.length:f[se+1]),_e=A.subarray(m[se],ne?A.length:m[se+1]);break;default:continue}s.createGeometry({id:pe,primitive:fe,positionsCompressed:ve,normalsCompressed:ge,colors:me,indices:_e,edgeIndices:ye,positionsDecodeMatrix:d}),j[pe]=!0}s.createMesh(le.apply(ee,{id:ce,geometryId:pe,origin:T,matrix:de,color:oe,metallic:ue,roughness:Ae,opacity:ae})),Y.push(ce)}else{var be=void 0,Be=void 0,we=void 0,xe=void 0,Pe=void 0,Ce=void 0;switch(p[se]){case 0:be="solid",Be=a.subarray(f[se],ne?a.length:f[se+1]),we=l.subarray(v[se],ne?l.length:v[se+1]),Pe=A.subarray(m[se],ne?A.length:m[se+1]),Ce=c.subarray(_[se],ne?c.length:_[se+1]);break;case 1:be="surface",Be=a.subarray(f[se],ne?a.length:f[se+1]),we=l.subarray(v[se],ne?l.length:v[se+1]),Pe=A.subarray(m[se],ne?A.length:m[se+1]),Ce=c.subarray(_[se],ne?c.length:_[se+1]);break;case 2:be="points",Be=a.subarray(f[se],ne?a.length:f[se+1]),xe=RE(u.subarray(g[se],ne?u.length:g[se+1]));break;case 3:be="lines",Be=a.subarray(f[se],ne?a.length:f[se+1]),Pe=A.subarray(m[se],ne?A.length:m[se+1]);break;default:continue}s.createMesh(le.apply(ee,{id:ce,origin:T,primitive:be,positionsCompressed:Be,normalsCompressed:we,colors:xe,indices:Pe,edgeIndices:Ce,positionsDecodeMatrix:H,color:oe,metallic:ue,roughness:Ae,opacity:ae})),Y.push(ce)}}Y.length>0&&s.createEntity(le.apply(q,{id:W,isObject:!0,meshIds:Y}))}}}(e,t,a,s,0,n)}},UE=window.pako||hE;UE.inflate||(UE=UE.default);var OE=$.vec4(),NE=$.vec4();var QE=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function VE(e){for(var t=[],i=0,s=e.length;i1,ye=me===S-1,be=QE(M.subarray(6*ge,6*ge+3)),Be=M[6*ge+3]/255,we=M[6*ge+4]/255,xe=M[6*ge+5]/255,Pe=n.getNextId();if(_e){var Ce=C[ge],Me=g.slice(Ce,Ce+16),Fe="".concat(o,"-geometry.").concat(Y,".").concat(me),Ee=J[Fe];if(!Ee){Ee={batchThisMesh:!t.reuseGeometries};var ke=!1;switch(_[me]){case 0:Ee.primitiveName="solid",Ee.geometryPositions=h.subarray(y[me],ye?h.length:y[me+1]),Ee.geometryNormals=d.subarray(b[me],ye?d.length:b[me+1]),Ee.geometryIndices=f.subarray(w[me],ye?f.length:w[me+1]),Ee.geometryEdgeIndices=v.subarray(x[me],ye?v.length:x[me+1]),ke=Ee.geometryPositions.length>0&&Ee.geometryIndices.length>0;break;case 1:Ee.primitiveName="surface",Ee.geometryPositions=h.subarray(y[me],ye?h.length:y[me+1]),Ee.geometryNormals=d.subarray(b[me],ye?d.length:b[me+1]),Ee.geometryIndices=f.subarray(w[me],ye?f.length:w[me+1]),Ee.geometryEdgeIndices=v.subarray(x[me],ye?v.length:x[me+1]),ke=Ee.geometryPositions.length>0&&Ee.geometryIndices.length>0;break;case 2:Ee.primitiveName="points",Ee.geometryPositions=h.subarray(y[me],ye?h.length:y[me+1]),Ee.geometryColors=VE(p.subarray(B[me],ye?p.length:B[me+1])),ke=Ee.geometryPositions.length>0;break;case 3:Ee.primitiveName="lines",Ee.geometryPositions=h.subarray(y[me],ye?h.length:y[me+1]),Ee.geometryIndices=f.subarray(w[me],ye?f.length:w[me+1]),ke=Ee.geometryPositions.length>0&&Ee.geometryIndices.length>0;break;default:continue}if(ke||(Ee=null),Ee&&(Ee.geometryPositions.length,Ee.batchThisMesh)){Ee.decompressedPositions=new Float32Array(Ee.geometryPositions.length);for(var Ie=Ee.geometryPositions,De=Ee.decompressedPositions,Se=0,Te=Ie.length;Se0&&je.length>0;break;case 1:Ne="surface",Qe=h.subarray(y[me],ye?h.length:y[me+1]),Ve=d.subarray(b[me],ye?d.length:b[me+1]),je=f.subarray(w[me],ye?f.length:w[me+1]),Ge=v.subarray(x[me],ye?v.length:x[me+1]),ze=Qe.length>0&&je.length>0;break;case 2:Ne="points",Qe=h.subarray(y[me],ye?h.length:y[me+1]),He=VE(p.subarray(B[me],ye?p.length:B[me+1])),ze=Qe.length>0;break;case 3:Ne="lines",Qe=h.subarray(y[me],ye?h.length:y[me+1]),je=f.subarray(w[me],ye?f.length:w[me+1]),ze=Qe.length>0&&je.length>0;break;default:continue}ze&&(s.createMesh(le.apply(fe,{id:Pe,origin:K,primitive:Ne,positionsCompressed:Qe,normalsCompressed:Ve,colorsCompressed:He,indices:je,edgeIndices:Ge,positionsDecodeMatrix:se,color:be,metallic:we,roughness:xe,opacity:Be})),he.push(Pe))}}he.length>0&&s.createEntity(le.apply(pe,{id:ae,isObject:!0,meshIds:he}))}}}(e,t,a,s,r,n)}},jE=window.pako||hE;jE.inflate||(jE=jE.default);var GE=$.vec4(),zE=$.vec4();var WE=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();var KE={version:9,parse:function(e,t,i,s,r,n){var o=function(e){return{metadata:e[0],positions:e[1],normals:e[2],colors:e[3],indices:e[4],edgeIndices:e[5],matrices:e[6],reusedGeometriesDecodeMatrix:e[7],eachGeometryPrimitiveType:e[8],eachGeometryPositionsPortion:e[9],eachGeometryNormalsPortion:e[10],eachGeometryColorsPortion:e[11],eachGeometryIndicesPortion:e[12],eachGeometryEdgeIndicesPortion:e[13],eachMeshGeometriesPortion:e[14],eachMeshMatricesPortion:e[15],eachMeshMaterial:e[16],eachEntityId:e[17],eachEntityMeshesPortion:e[18],eachTileAABB:e[19],eachTileEntitiesPortion:e[20]}}(i),a=function(e){function t(e,t){return 0===e.length?[]:jE.inflate(e,t).buffer}return{metadata:JSON.parse(jE.inflate(e.metadata,{to:"string"})),positions:new Uint16Array(t(e.positions)),normals:new Int8Array(t(e.normals)),colors:new Uint8Array(t(e.colors)),indices:new Uint32Array(t(e.indices)),edgeIndices:new Uint32Array(t(e.edgeIndices)),matrices:new Float32Array(t(e.matrices)),reusedGeometriesDecodeMatrix:new Float32Array(t(e.reusedGeometriesDecodeMatrix)),eachGeometryPrimitiveType:new Uint8Array(t(e.eachGeometryPrimitiveType)),eachGeometryPositionsPortion:new Uint32Array(t(e.eachGeometryPositionsPortion)),eachGeometryNormalsPortion:new Uint32Array(t(e.eachGeometryNormalsPortion)),eachGeometryColorsPortion:new Uint32Array(t(e.eachGeometryColorsPortion)),eachGeometryIndicesPortion:new Uint32Array(t(e.eachGeometryIndicesPortion)),eachGeometryEdgeIndicesPortion:new Uint32Array(t(e.eachGeometryEdgeIndicesPortion)),eachMeshGeometriesPortion:new Uint32Array(t(e.eachMeshGeometriesPortion)),eachMeshMatricesPortion:new Uint32Array(t(e.eachMeshMatricesPortion)),eachMeshMaterial:new Uint8Array(t(e.eachMeshMaterial)),eachEntityId:JSON.parse(jE.inflate(e.eachEntityId,{to:"string"})),eachEntityMeshesPortion:new Uint32Array(t(e.eachEntityMeshesPortion)),eachTileAABB:new Float64Array(t(e.eachTileAABB)),eachTileEntitiesPortion:new Uint32Array(t(e.eachTileEntitiesPortion))}}(o);!function(e,t,i,s,r,n){var o=n.getNextId(),a=i.metadata,l=i.positions,u=i.normals,A=i.colors,c=i.indices,h=i.edgeIndices,d=i.matrices,p=i.reusedGeometriesDecodeMatrix,f=i.eachGeometryPrimitiveType,v=i.eachGeometryPositionsPortion,g=i.eachGeometryNormalsPortion,m=i.eachGeometryColorsPortion,_=i.eachGeometryIndicesPortion,y=i.eachGeometryEdgeIndicesPortion,b=i.eachMeshGeometriesPortion,B=i.eachMeshMatricesPortion,w=i.eachMeshMaterial,x=i.eachEntityId,P=i.eachEntityMeshesPortion,C=i.eachTileAABB,M=i.eachTileEntitiesPortion,F=v.length,E=b.length,k=P.length,I=M.length;r&&r.loadData(a,{includeTypes:t.includeTypes,excludeTypes:t.excludeTypes,globalizeObjectIds:t.globalizeObjectIds});for(var D=new Uint32Array(F),S=0;S1,ae=ne===F-1,ue=WE(w.subarray(6*re,6*re+3)),Ae=w[6*re+3]/255,ce=w[6*re+4]/255,he=w[6*re+5]/255,de=n.getNextId();if(oe){var pe=B[re],fe=d.slice(pe,pe+16),ve="".concat(o,"-geometry.").concat(O,".").concat(ne),ge=U[ve];if(!ge){ge={batchThisMesh:!t.reuseGeometries};var me=!1;switch(f[ne]){case 0:ge.primitiveName="solid",ge.geometryPositions=l.subarray(v[ne],ae?l.length:v[ne+1]),ge.geometryNormals=u.subarray(g[ne],ae?u.length:g[ne+1]),ge.geometryIndices=c.subarray(_[ne],ae?c.length:_[ne+1]),ge.geometryEdgeIndices=h.subarray(y[ne],ae?h.length:y[ne+1]),me=ge.geometryPositions.length>0&&ge.geometryIndices.length>0;break;case 1:ge.primitiveName="surface",ge.geometryPositions=l.subarray(v[ne],ae?l.length:v[ne+1]),ge.geometryNormals=u.subarray(g[ne],ae?u.length:g[ne+1]),ge.geometryIndices=c.subarray(_[ne],ae?c.length:_[ne+1]),ge.geometryEdgeIndices=h.subarray(y[ne],ae?h.length:y[ne+1]),me=ge.geometryPositions.length>0&&ge.geometryIndices.length>0;break;case 2:ge.primitiveName="points",ge.geometryPositions=l.subarray(v[ne],ae?l.length:v[ne+1]),ge.geometryColors=A.subarray(m[ne],ae?A.length:m[ne+1]),me=ge.geometryPositions.length>0;break;case 3:ge.primitiveName="lines",ge.geometryPositions=l.subarray(v[ne],ae?l.length:v[ne+1]),ge.geometryIndices=c.subarray(_[ne],ae?c.length:_[ne+1]),me=ge.geometryPositions.length>0&&ge.geometryIndices.length>0;break;default:continue}if(me||(ge=null),ge&&(ge.geometryPositions.length,ge.batchThisMesh)){ge.decompressedPositions=new Float32Array(ge.geometryPositions.length),ge.transformedAndRecompressedPositions=new Uint16Array(ge.geometryPositions.length);for(var _e=ge.geometryPositions,ye=ge.decompressedPositions,be=0,Be=_e.length;be0&&Ie.length>0;break;case 1:Me="surface",Fe=l.subarray(v[ne],ae?l.length:v[ne+1]),Ee=u.subarray(g[ne],ae?u.length:g[ne+1]),Ie=c.subarray(_[ne],ae?c.length:_[ne+1]),De=h.subarray(y[ne],ae?h.length:y[ne+1]),Se=Fe.length>0&&Ie.length>0;break;case 2:Me="points",Fe=l.subarray(v[ne],ae?l.length:v[ne+1]),ke=A.subarray(m[ne],ae?A.length:m[ne+1]),Se=Fe.length>0;break;case 3:Me="lines",Fe=l.subarray(v[ne],ae?l.length:v[ne+1]),Ie=c.subarray(_[ne],ae?c.length:_[ne+1]),Se=Fe.length>0&&Ie.length>0;break;default:continue}Se&&(s.createMesh(le.apply(ie,{id:de,origin:R,primitive:Me,positionsCompressed:Fe,normalsCompressed:Ee,colorsCompressed:ke,indices:Ie,edgeIndices:De,positionsDecodeMatrix:G,color:ue,metallic:ce,roughness:he,opacity:Ae})),q.push(de))}}q.length>0&&s.createEntity(le.apply(te,{id:X,isObject:!0,meshIds:q}))}}}(e,t,a,s,r,n)}},XE=window.pako||hE;XE.inflate||(XE=XE.default);var JE=$.vec4(),YE=$.vec4();var ZE=function(){var e=new Float32Array(3);return function(t){return e[0]=t[0]/255,e[1]=t[1]/255,e[2]=t[2]/255,e}}();function qE(e,t){var i=[];if(t.length>1)for(var s=0,r=t.length-1;s1)for(var n=0,o=e.length/3-1;n0,W=9*V,K=1===A[W+0],X=A[W+1];A[W+2],A[W+3];var J=A[W+4],Y=A[W+5],Z=A[W+6],q=A[W+7],ee=A[W+8];if(z){var te=new Uint8Array(l.subarray(j,G)).buffer,ie="".concat(o,"-texture-").concat(V);if(K)s.createTexture({id:ie,buffers:[te],minFilter:J,magFilter:Y,wrapS:Z,wrapT:q,wrapR:ee});else{var se=new Blob([te],{type:10001===X?"image/jpeg":10002===X?"image/png":"image/gif"}),re=(window.URL||window.webkitURL).createObjectURL(se),ne=document.createElement("img");ne.src=re,s.createTexture({id:ie,image:ne,minFilter:J,magFilter:Y,wrapS:Z,wrapT:q,wrapR:ee})}}}for(var oe=0;oe=0?"".concat(o,"-texture-").concat(Ae):null,normalsTextureId:he>=0?"".concat(o,"-texture-").concat(he):null,metallicRoughnessTextureId:ce>=0?"".concat(o,"-texture-").concat(ce):null,emissiveTextureId:de>=0?"".concat(o,"-texture-").concat(de):null,occlusionTextureId:pe>=0?"".concat(o,"-texture-").concat(pe):null})}for(var fe=new Uint32Array(U),ve=0;ve1,je=Ve===U-1,Ge=E[Qe],ze=Ge>=0?"".concat(o,"-textureSet-").concat(Ge):null,We=ZE(k.subarray(6*Qe,6*Qe+3)),Ke=k[6*Qe+3]/255,Xe=k[6*Qe+4]/255,Je=k[6*Qe+5]/255,Ye=n.getNextId();if(He){var Ze=F[Qe],qe=m.slice(Ze,Ze+16),$e="".concat(o,"-geometry.").concat(be,".").concat(Ve),et=ye[$e];if(!et){et={batchThisMesh:!t.reuseGeometries};var tt=!1;switch(y[Ve]){case 0:et.primitiveName="solid",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryNormals=h.subarray(B[Ve],je?h.length:B[Ve+1]),et.geometryUVs=p.subarray(x[Ve],je?p.length:x[Ve+1]),et.geometryIndices=f.subarray(P[Ve],je?f.length:P[Ve+1]),et.geometryEdgeIndices=v.subarray(C[Ve],je?v.length:C[Ve+1]),tt=et.geometryPositions.length>0&&et.geometryIndices.length>0;break;case 1:et.primitiveName="surface",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryNormals=h.subarray(B[Ve],je?h.length:B[Ve+1]),et.geometryUVs=p.subarray(x[Ve],je?p.length:x[Ve+1]),et.geometryIndices=f.subarray(P[Ve],je?f.length:P[Ve+1]),et.geometryEdgeIndices=v.subarray(C[Ve],je?v.length:C[Ve+1]),tt=et.geometryPositions.length>0&&et.geometryIndices.length>0;break;case 2:et.primitiveName="points",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryColors=d.subarray(w[Ve],je?d.length:w[Ve+1]),tt=et.geometryPositions.length>0;break;case 3:et.primitiveName="lines",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryIndices=f.subarray(P[Ve],je?f.length:P[Ve+1]),tt=et.geometryPositions.length>0&&et.geometryIndices.length>0;break;case 4:et.primitiveName="lines",et.geometryPositions=c.subarray(b[Ve],je?c.length:b[Ve+1]),et.geometryIndices=qE(et.geometryPositions,f.subarray(P[Ve],je?f.length:P[Ve+1])),tt=et.geometryPositions.length>0&&et.geometryIndices.length>0;break;default:continue}if(tt||(et=null),et&&(et.geometryPositions.length,et.batchThisMesh)){et.decompressedPositions=new Float32Array(et.geometryPositions.length),et.transformedAndRecompressedPositions=new Uint16Array(et.geometryPositions.length);for(var it=et.geometryPositions,st=et.decompressedPositions,rt=0,nt=it.length;rt0&&ft.length>0;break;case 1:At="surface",ct=c.subarray(b[Ve],je?c.length:b[Ve+1]),ht=h.subarray(B[Ve],je?h.length:B[Ve+1]),dt=p.subarray(x[Ve],je?p.length:x[Ve+1]),ft=f.subarray(P[Ve],je?f.length:P[Ve+1]),vt=v.subarray(C[Ve],je?v.length:C[Ve+1]),gt=ct.length>0&&ft.length>0;break;case 2:At="points",ct=c.subarray(b[Ve],je?c.length:b[Ve+1]),pt=d.subarray(w[Ve],je?d.length:w[Ve+1]),gt=ct.length>0;break;case 3:At="lines",ct=c.subarray(b[Ve],je?c.length:b[Ve+1]),ft=f.subarray(P[Ve],je?f.length:P[Ve+1]),gt=ct.length>0&&ft.length>0;break;case 4:At="lines",ft=qE(ct=c.subarray(b[Ve],je?c.length:b[Ve+1]),f.subarray(P[Ve],je?f.length:P[Ve+1])),gt=ct.length>0&&ft.length>0;break;default:continue}gt&&(s.createMesh(le.apply(Oe,{id:Ye,textureSetId:ze,origin:me,primitive:At,positionsCompressed:ct,normalsCompressed:ht,uv:dt&&dt.length>0?dt:null,colorsCompressed:pt,indices:ft,edgeIndices:vt,positionsDecodeMatrix:Me,color:We,metallic:Xe,roughness:Je,opacity:Ke})),Re.push(Ye))}}Re.length>0&&s.createEntity(le.apply(Ue,{id:Ie,isObject:!0,meshIds:Re}))}}}(e,t,a,s,r,n)}},ek={};ek[vE.version]=vE,ek[_E.version]=_E,ek[BE.version]=BE,ek[PE.version]=PE,ek[FE.version]=FE,ek[DE.version]=DE,ek[LE.version]=LE,ek[HE.version]=HE,ek[KE.version]=KE,ek[$E.version]=$E;var tk=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"XKTLoader",e,r))._maxGeometryBatchSize=r.maxGeometryBatchSize,s.textureTranscoder=r.textureTranscoder,s.dataSource=r.dataSource,s.objectDefaults=r.objectDefaults,s.includeTypes=r.includeTypes,s.excludeTypes=r.excludeTypes,s.excludeUnclassifiedObjects=r.excludeUnclassifiedObjects,s.reuseGeometries=r.reuseGeometries,s}return C(i,[{key:"supportedVersions",get:function(){return Object.keys(ek)}},{key:"textureTranscoder",get:function(){return this._textureTranscoder},set:function(e){this._textureTranscoder=e}},{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new cE}},{key:"objectDefaults",get:function(){return this._objectDefaults},set:function(e){this._objectDefaults=e||lF}},{key:"includeTypes",get:function(){return this._includeTypes},set:function(e){this._includeTypes=e}},{key:"excludeTypes",get:function(){return this._excludeTypes},set:function(e){this._excludeTypes=e}},{key:"excludeUnclassifiedObjects",get:function(){return this._excludeUnclassifiedObjects},set:function(e){this._excludeUnclassifiedObjects=!!e}},{key:"globalizeObjectIds",get:function(){return this._globalizeObjectIds},set:function(e){this._globalizeObjectIds=!!e}},{key:"reuseGeometries",get:function(){return this._reuseGeometries},set:function(e){this._reuseGeometries=!1!==e}},{key:"load",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t.id&&this.viewer.scene.components[t.id]&&(this.error("Component with this ID already exists in viewer: "+t.id+" - will autogenerate this ID"),delete t.id),!(t.src||t.xkt||t.manifestSrc||t.manifest))return this.error("load() param expected: src, xkt, manifestSrc or manifestData"),A;var i={},s=t.includeTypes||this._includeTypes,r=t.excludeTypes||this._excludeTypes,n=t.objectDefaults||this._objectDefaults;if(i.reuseGeometries=null!==t.reuseGeometries&&void 0!==t.reuseGeometries?t.reuseGeometries:!1!==this._reuseGeometries,s){i.includeTypesMap={};for(var o=0,a=s.length;o=t.length?n():e._dataSource.getMetaModel("".concat(m).concat(t[a]),(function(t){h.loadData(t,{includeTypes:s,excludeTypes:r,globalizeObjectIds:i.globalizeObjectIds}),a++,e.scheduleTask(l,100)}),o)}()},y=function(s,r,n){var o=0;!function a(){o>=s.length?r():e._dataSource.getXKT("".concat(m).concat(s[o]),(function(s){e._parseModel(s,t,i,A,null,v),o++,e.scheduleTask(a,100)}),n)}()},b=function(s,r,n){var o=0;!function a(){o>=s.length?r():e._dataSource.getXKT("".concat(m).concat(s[o]),(function(s){e._parseModel(s,t,i,A,h,v),o++,e.scheduleTask(a,100)}),n)}()};if(t.manifest){var B=t.manifest,w=B.xktFiles;if(!w||0===w.length)return void p("load(): Failed to load model manifest - manifest not valid");var x=B.metaModelFiles;x?_(x,(function(){y(w,d,p)}),p):b(w,d,p)}else this._dataSource.getManifest(t.manifestSrc,(function(e){if(!A.destroyed){var t=e.xktFiles;if(t&&0!==t.length){var i=e.metaModelFiles;i?_(i,(function(){y(t,d,p)}),p):b(t,d,p)}else p("load(): Failed to load model manifest - manifest not valid")}}),p)}return A}},{key:"_loadModel",value:function(e,t,i,s,r,n,o,a){var l=this;this._dataSource.getXKT(t.src,(function(e){l._parseModel(e,t,i,s,r,n),o()}),a)}},{key:"_parseModel",value:function(e,t,i,s,r,n){if(!s.destroyed){var o=new DataView(e),a=new Uint8Array(e),l=o.getUint32(0,!0),u=ek[l];if(u){this.log("Loading .xkt V"+l);for(var A=o.getUint32(4,!0),c=[],h=4*(A+2),d=0;de.size)throw new RangeError("offset:"+t+", length:"+i+", size:"+e.size);return e.slice?e.slice(t,t+i):e.webkitSlice?e.webkitSlice(t,t+i):e.mozSlice?e.mozSlice(t,t+i):e.msSlice?e.msSlice(t,t+i):void 0}(e,t,i))}catch(e){r(e)}}}function p(){}function f(e){var i,s=this;s.init=function(e){i=new Blob([],{type:o}),e()},s.writeUint8Array=function(e,s){i=new Blob([i,t?e:e.buffer],{type:o}),s()},s.getData=function(t,s){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=s,r.readAsText(i,e)}}function v(t){var i=this,s="",r="";i.init=function(e){s+="data:"+(t||"")+";base64,",e()},i.writeUint8Array=function(t,i){var n,o=r.length,a=r;for(r="",n=0;n<3*Math.floor((o+t.length)/3)-o;n++)a+=String.fromCharCode(t[n]);for(;n2?s+=e.btoa(a):r=a,i()},i.getData=function(t){t(s+e.btoa(r))}}function g(e){var i,s=this;s.init=function(t){i=new Blob([],{type:e}),t()},s.writeUint8Array=function(s,r){i=new Blob([i,t?s:s.buffer],{type:e}),r()},s.getData=function(e){e(i)}}function m(e,t,i,s,r,o,a,l,u,A){var c,h,d,p=0,f=t.sn;function v(){e.removeEventListener("message",g,!1),l(h,d)}function g(t){var i=t.data,r=i.data,n=i.error;if(n)return n.toString=function(){return"Error: "+this.message},void u(n);if(i.sn===f)switch("number"==typeof i.codecTime&&(e.codecTime+=i.codecTime),"number"==typeof i.crcTime&&(e.crcTime+=i.crcTime),i.type){case"append":r?(h+=r.length,s.writeUint8Array(r,(function(){m()}),A)):m();break;case"flush":d=i.crc,r?(h+=r.length,s.writeUint8Array(r,(function(){v()}),A)):v();break;case"progress":a&&a(c+i.loaded,o);break;case"importScripts":case"newTask":case"echo":break;default:console.warn("zip.js:launchWorkerProcess: unknown message: ",i)}}function m(){(c=p*n)<=o?i.readUint8Array(r+c,Math.min(n,o-c),(function(i){a&&a(c,o);var s=0===c?t:{sn:f};s.type="append",s.data=i;try{e.postMessage(s,[i.buffer])}catch(t){e.postMessage(s)}p++}),u):e.postMessage({sn:f,type:"flush"})}h=0,e.addEventListener("message",g,!1),m()}function _(e,t,i,s,r,o,l,u,A,c){var h,d=0,p=0,f="input"===o,v="output"===o,g=new a;!function o(){var a;if((h=d*n)127?r[i-128]:String.fromCharCode(i);return s}function B(e){return decodeURIComponent(escape(e))}function w(e){var t,i="";for(t=0;t>16,i=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&i)>>11,(2016&i)>>5,2*(31&i),0)}catch(e){}}(e.lastModDateRaw),1!=(1&e.bitFlag)?((s||8!=(8&e.bitFlag))&&(e.crc32=t.view.getUint32(i+10,!0),e.compressedSize=t.view.getUint32(i+14,!0),e.uncompressedSize=t.view.getUint32(i+18,!0)),4294967295!==e.compressedSize&&4294967295!==e.uncompressedSize?(e.filenameLength=t.view.getUint16(i+22,!0),e.extraFieldLength=t.view.getUint16(i+24,!0)):r("File is using Zip64 (4gb+ file size).")):r("File contains encrypted entry.")}function P(t,n,o){var a=0;function l(){}l.prototype.getData=function(s,n,l,A){var c=this;function h(e,t){A&&!function(e){var t=u(4);return t.view.setUint32(0,e),c.crc32==t.view.getUint32(0)}(t)?o("CRC failed."):s.getData((function(e){n(e)}))}function d(e){o(e||r)}function p(e){o(e||"Error while writing file data.")}t.readUint8Array(c.offset,30,(function(r){var n,f=u(r.length,r);1347093252==f.view.getUint32(0)?(x(c,f,4,!1,o),n=c.offset+30+c.filenameLength+c.extraFieldLength,s.init((function(){0===c.compressionMethod?y(c._worker,a++,t,s,n,c.compressedSize,A,h,l,d,p):function(t,i,s,r,n,o,a,l,u,A,c){var h=a?"output":"none";e.zip.useWebWorkers?m(t,{sn:i,codecClass:"Inflater",crcType:h},s,r,n,o,u,l,A,c):_(new e.zip.Inflater,s,r,n,o,h,u,l,A,c)}(c._worker,a++,t,s,n,c.compressedSize,A,h,l,d,p)}),p)):o(i)}),d)};var A={getEntries:function(e){var r=this._worker;!function(e){t.size<22?o(i):r(22,(function(){r(Math.min(65558,t.size),(function(){o(i)}))}));function r(i,r){t.readUint8Array(t.size-i,i,(function(t){for(var i=t.length-22;i>=0;i--)if(80===t[i]&&75===t[i+1]&&5===t[i+2]&&6===t[i+3])return void e(new DataView(t.buffer,i,22));r()}),(function(){o(s)}))}}((function(n){var a,A;a=n.getUint32(16,!0),A=n.getUint16(8,!0),a<0||a>=t.size?o(i):t.readUint8Array(a,t.size-a,(function(t){var s,n,a,c,h=0,d=[],p=u(t.length,t);for(s=0;s>>8^i[255&(t^e[s])];this.crc=t},a.prototype.get=function(){return~this.crc},a.prototype.table=function(){var e,t,i,s=[];for(e=0;e<256;e++){for(i=e,t=0;t<8;t++)1&i?i=i>>>1^3988292384:i>>>=1;s[e]=i}return s}(),l.prototype.append=function(e,t){return e},l.prototype.flush=function(){},c.prototype=new A,c.prototype.constructor=c,h.prototype=new A,h.prototype.constructor=h,d.prototype=new A,d.prototype.constructor=d,p.prototype.getData=function(e){e(this.data)},f.prototype=new p,f.prototype.constructor=f,v.prototype=new p,v.prototype.constructor=v,g.prototype=new p,g.prototype.constructor=g;var E={deflater:["z-worker.js","deflate.js"],inflater:["z-worker.js","inflate.js"]};function k(t,i,s){if(null===e.zip.workerScripts||null===e.zip.workerScriptsPath){var r;if(e.zip.workerScripts){if(r=e.zip.workerScripts[t],!Array.isArray(r))return void s(new Error("zip.workerScripts."+t+" is not an array!"));r=function(e){var t=document.createElement("a");return e.map((function(e){return t.href=e,t.href}))}(r)}else(r=E[t].slice(0))[0]=(e.zip.workerScriptsPath||"")+r[0];var n=new Worker(r[0]);n.codecTime=n.crcTime=0,n.postMessage({type:"importScripts",scripts:r.slice(1)}),n.addEventListener("message",(function e(t){var r=t.data;if(r.error)return n.terminate(),void s(r.error);"importScripts"===r.type&&(n.removeEventListener("message",e),n.removeEventListener("error",o),i(n))})),n.addEventListener("error",o)}else s(new Error("Either zip.workerScripts or zip.workerScriptsPath may be set, not both."));function o(e){n.terminate(),s(e)}}function I(e){console.error(e)}e.zip={Reader:A,Writer:p,BlobReader:d,Data64URIReader:h,TextReader:c,BlobWriter:g,Data64URIWriter:v,TextWriter:f,createReader:function(e,t,i){i=i||I,e.init((function(){P(e,t,i)}),i)},createWriter:function(e,t,i,s){i=i||I,s=!!s,e.init((function(){F(e,t,i,s)}),i)},useWebWorkers:!0,workerScriptsPath:null,workerScripts:null}}(sk);var rk=sk.zip;!function(e){var t,i,s=e.Reader,r=e.Writer;try{i=0===new Blob([new DataView(new ArrayBuffer(0))]).size}catch(e){}function n(e){var t=this;function i(i,s){var r;t.data?i():((r=new XMLHttpRequest).addEventListener("load",(function(){t.size||(t.size=Number(r.getResponseHeader("Content-Length"))||Number(r.response.byteLength)),t.data=new Uint8Array(r.response),i()}),!1),r.addEventListener("error",s,!1),r.open("GET",e),r.responseType="arraybuffer",r.send())}t.size=0,t.init=function(s,r){if(function(e){var t=document.createElement("a");return t.href=e,"http:"===t.protocol||"https:"===t.protocol}(e)){var n=new XMLHttpRequest;n.addEventListener("load",(function(){t.size=Number(n.getResponseHeader("Content-Length")),t.size?s():i(s,r)}),!1),n.addEventListener("error",r,!1),n.open("HEAD",e),n.send()}else i(s,r)},t.readUint8Array=function(e,s,r,n){i((function(){r(new Uint8Array(t.data.subarray(e,e+s)))}),n)}}function o(e){var t=this;t.size=0,t.init=function(i,s){var r=new XMLHttpRequest;r.addEventListener("load",(function(){t.size=Number(r.getResponseHeader("Content-Length")),"bytes"==r.getResponseHeader("Accept-Ranges")?i():s("HTTP Range not supported.")}),!1),r.addEventListener("error",s,!1),r.open("HEAD",e),r.send()},t.readUint8Array=function(t,i,s,r){!function(t,i,s,r){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="arraybuffer",n.setRequestHeader("Range","bytes="+t+"-"+(t+i-1)),n.addEventListener("load",(function(){s(n.response)}),!1),n.addEventListener("error",r,!1),n.send()}(t,i,(function(e){s(new Uint8Array(e))}),r)}}function a(e){var t=this;t.size=0,t.init=function(i,s){t.size=e.byteLength,i()},t.readUint8Array=function(t,i,s,r){s(new Uint8Array(e.slice(t,t+i)))}}function l(){var e,t=this;t.init=function(t,i){e=new Uint8Array,t()},t.writeUint8Array=function(t,i,s){var r=new Uint8Array(e.length+t.length);r.set(e),r.set(t,e.length),e=r,i()},t.getData=function(t){t(e.buffer)}}function u(e,t){var s,r=this;r.init=function(t,i){e.createWriter((function(e){s=e,t()}),i)},r.writeUint8Array=function(e,r,n){var o=new Blob([i?e:e.buffer],{type:t});s.onwrite=function(){s.onwrite=null,r()},s.onerror=n,s.write(o)},r.getData=function(t){e.file(t)}}n.prototype=new s,n.prototype.constructor=n,o.prototype=new s,o.prototype.constructor=o,a.prototype=new s,a.prototype.constructor=a,l.prototype=new r,l.prototype.constructor=l,u.prototype=new r,u.prototype.constructor=u,e.FileWriter=u,e.HttpReader=n,e.HttpRangeReader=o,e.ArrayBufferReader=a,e.ArrayBufferWriter=l,e.fs&&((t=e.fs.ZipDirectoryEntry).prototype.addHttpContent=function(i,s,r){return function(i,s,r,n){if(i.directory)return n?new t(i.fs,s,r,i):new e.fs.ZipFileEntry(i.fs,s,r,i);throw"Parent entry is not a directory."}(this,i,{data:s,Reader:r?o:n})},t.prototype.importHttpContent=function(e,t,i,s){this.importZip(t?new o(e):new n(e),i,s)},e.fs.FS.prototype.importHttpContent=function(e,i,s,r){this.entries=[],this.root=new t(this),this.root.importHttpContent(e,i,s,r)})}(rk);var nk=["4.2"],ok=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};x(this,e),this.supportedSchemas=nk,this._xrayOpacity=.7,this._src=null,this._options=i,this.viewpoint=null,i.workerScriptsPath?(rk.workerScriptsPath=i.workerScriptsPath,this.src=i.src,this.xrayOpacity=.7,this.displayEffect=i.displayEffect,this.createMetaModel=i.createMetaModel):t.error("Config expected: workerScriptsPath")}return C(e,[{key:"load",value:function(e,t,i,s,r,n){switch(s.materialType){case"MetallicMaterial":t._defaultMaterial=new xn(t,{baseColor:[1,1,1],metallic:.6,roughness:.6});break;case"SpecularMaterial":t._defaultMaterial=new Mn(t,{diffuse:[1,1,1],specular:$.vec3([1,1,1]),glossiness:.5});break;default:t._defaultMaterial=new Oi(t,{reflectivity:.75,shiness:100,diffuse:[1,1,1]})}t._wireframeMaterial=new bn(t,{color:[0,0,0],lineWidth:2});var o=t.scene.canvas.spinner;o.processes++,ak(e,t,i,s,(function(){o.processes--,r&&r(),t.fire("loaded",!0,!1)}),(function(e){o.processes--,t.error(e),n&&n(e),t.fire("error",e)}),(function(e){console.log("Error, Will Robinson: "+e)}))}}]),e}(),ak=function(e,t,i,s,r,n){!function(e,t,i){var s=new fk;s.load(e,(function(){t(s)}),(function(e){i("Error loading ZIP archive: "+e)}))}(i,(function(i){lk(e,i,s,t,r,n)}),n)},lk=function(){return function(t,i,s,r,n){var o={plugin:t,zip:i,edgeThreshold:30,materialType:s.materialType,scene:r.scene,modelNode:r,info:{references:{}},materials:{}};s.createMetaModel&&(o.metaModelData={modelId:r.id,metaObjects:[{name:r.id,type:"Default",id:r.id}]}),r.scene.loading++,function(t,i){t.zip.getFile("Manifest.xml",(function(s,r){for(var n=r.children,o=0,a=n.length;o0){for(var o=n.trim().split(" "),a=new Int16Array(o.length),l=0,u=0,A=o.length;u0){i.primitive="triangles";for(var n=[],o=0,a=r.length;o=t.length)i();else{var a=t[n].id,l=a.lastIndexOf(":");l>0&&(a=a.substring(l+1));var u=a.lastIndexOf("#");u>0&&(a=a.substring(0,u)),s[a]?r(n+1):function(e,t,i){e.zip.getFile(t,(function(t,s){!function(e,t,i){for(var s,r=t.children,n=0,o=r.length;n0)for(var s=0,r=t.length;s1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),s=t.call(this,"XML3DLoader",e,r),r.workerScriptsPath?(s._workerScriptsPath=r.workerScriptsPath,s._loader=new ok(b(s),r),s.supportedSchemas=s._loader.supportedSchemas,s):(s.error("Config expected: workerScriptsPath"),y(s))}return C(i,[{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.workerScriptsPath=this._workerScriptsPath,e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new yn(this.viewer.scene,le.apply(e,{isModel:!0})),i=e.src;return i?(this._loader.load(this,t,i,e),t):(this.error("load() param expected: src"),t)}}]),i}(),mk=function(){function e(){x(this,e)}return C(e,[{key:"getIFC",value:function(e,t,i){var s=function(){};t=t||s,i=i||s;var r=e.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){var n=!!r[2],o=r[3];o=window.decodeURIComponent(o),n&&(o=window.atob(o));try{for(var a=new ArrayBuffer(o.length),l=new Uint8Array(a),u=0;u1&&void 0!==arguments[1]?arguments[1]:{};if(x(this,i),(s=t.call(this,"ifcLoader",e,r)).dataSource=r.dataSource,s.objectDefaults=r.objectDefaults,s.includeTypes=r.includeTypes,s.excludeTypes=r.excludeTypes,s.excludeUnclassifiedObjects=r.excludeUnclassifiedObjects,!r.WebIFC)throw"Parameter expected: WebIFC";if(!r.IfcAPI)throw"Parameter expected: IfcAPI";return s._webIFC=r.WebIFC,s._ifcAPI=r.IfcAPI,s}return C(i,[{key:"supportedVersions",get:function(){return["2x3","4"]}},{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new mk}},{key:"objectDefaults",get:function(){return this._objectDefaults},set:function(e){this._objectDefaults=e||lF}},{key:"includeTypes",get:function(){return this._includeTypes},set:function(e){this._includeTypes=e}},{key:"excludeTypes",get:function(){return this._excludeTypes},set:function(e){this._excludeTypes=e}},{key:"excludeUnclassifiedObjects",get:function(){return this._excludeUnclassifiedObjects},set:function(e){this._excludeUnclassifiedObjects=!!e}},{key:"globalizeObjectIds",get:function(){return this._globalizeObjectIds},set:function(e){this._globalizeObjectIds=!!e}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new Ah(this.viewer.scene,le.apply(e,{isModel:!0}));if(!e.src&&!e.ifc)return this.error("load() param expected: src or IFC"),t;var i={autoNormals:!0};if(!1!==e.loadMetadata){var s=e.includeTypes||this._includeTypes,r=e.excludeTypes||this._excludeTypes,n=e.objectDefaults||this._objectDefaults;if(s){i.includeTypesMap={};for(var o=0,a=s.length;o0){for(var l=n.Name.value,u=[],A=0,c=a.length;A1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"lasLoader",e,r)).dataSource=r.dataSource,s.skip=r.skip,s.fp64=r.fp64,s.colorDepth=r.colorDepth,s}return C(i,[{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new yk}},{key:"skip",get:function(){return this._skip},set:function(e){this._skip=e||1}},{key:"fp64",get:function(){return this._fp64},set:function(e){this._fp64=!!e}},{key:"colorDepth",get:function(){return this._colorDepth},set:function(e){this._colorDepth=e||"auto"}},{key:"load",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.id&&this.viewer.scene.components[t.id]&&(this.error("Component with this ID already exists in viewer: "+t.id+" - will autogenerate this ID"),delete t.id);var i=new Ah(this.viewer.scene,le.apply(t,{isModel:!0}));if(!t.src&&!t.las)return this.error("load() param expected: src or las"),i;var s={las:{skip:this._skip,fp64:this._fp64,colorDepth:this._colorDepth}};if(t.src)this._loadModel(t.src,t,s,i);else{var r=this.viewer.scene.canvas.spinner;r.processes++,this._parseModel(t.las,t,s,i).then((function(){r.processes--}),(function(t){r.processes--,e.error(t),i.fire("error",t)}))}return i}},{key:"_loadModel",value:function(e,t,i,s){var r=this,n=this.viewer.scene.canvas.spinner;n.processes++,this._dataSource.getLAS(t.src,(function(e){r._parseModel(e,t,i,s).then((function(){n.processes--}),(function(e){n.processes--,r.error(e),s.fire("error",e)}))}),(function(e){n.processes--,r.error(e),s.fire("error",e)}))}},{key:"_parseModel",value:function(e,t,i,s){var r=this;function n(e){var i=e.value;if(t.rotateX&&i)for(var s=0,r=i.length;s=e.length)return e;for(var i=[],s=0;s80*i){s=n=e[0],r=o=e[1];for(var p=i;pn&&(n=a),l>o&&(o=l);u=0!==(u=Math.max(n-s,o-r))?1/u:0}return Sk(h,d,i,s,r,u),d}function Ik(e,t,i,s,r){var n,o;if(r===tI(e,t,i,s)>0)for(n=t;n=t;n-=s)o=qk(n,e[n],e[n+1],o);return o&&Wk(o,o.next)&&($k(o),o=o.next),o}function Dk(e,t){if(!e)return e;t||(t=e);var i,s=e;do{if(i=!1,s.steiner||!Wk(s,s.next)&&0!==zk(s.prev,s,s.next))s=s.next;else{if($k(s),(s=t=s.prev)===s.next)break;i=!0}}while(i||s!==t);return t}function Sk(e,t,i,s,r,n,o){if(e){!o&&n&&function(e,t,i,s){var r=e;do{null===r.z&&(r.z=Vk(r.x,r.y,t,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t,i,s,r,n,o,a,l,u=1;do{for(i=e,e=null,n=null,o=0;i;){for(o++,s=i,a=0,t=0;t0||l>0&&s;)0!==a&&(0===l||!s||i.z<=s.z)?(r=i,i=i.nextZ,a--):(r=s,s=s.nextZ,l--),n?n.nextZ=r:e=r,r.prevZ=n,n=r;i=s}n.nextZ=null,u*=2}while(o>1)}(r)}(e,s,r,n);for(var a,l,u=e;e.prev!==e.next;)if(a=e.prev,l=e.next,n?Rk(e,s,r,n):Tk(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),$k(e),e=l.next,u=l.next;else if((e=l)===u){o?1===o?Sk(e=Lk(Dk(e),t,i),t,i,s,r,n,2):2===o&&Uk(e,t,i,s,r,n):Sk(Dk(e),t,i,s,r,n,1);break}}}function Tk(e){var t=e.prev,i=e,s=e.next;if(zk(t,i,s)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(jk(t.x,t.y,i.x,i.y,s.x,s.y,r.x,r.y)&&zk(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Rk(e,t,i,s){var r=e.prev,n=e,o=e.next;if(zk(r,n,o)>=0)return!1;for(var a=r.xn.x?r.x>o.x?r.x:o.x:n.x>o.x?n.x:o.x,A=r.y>n.y?r.y>o.y?r.y:o.y:n.y>o.y?n.y:o.y,c=Vk(a,l,t,i,s),h=Vk(u,A,t,i,s),d=e.prevZ,p=e.nextZ;d&&d.z>=c&&p&&p.z<=h;){if(d!==e.prev&&d!==e.next&&jk(r.x,r.y,n.x,n.y,o.x,o.y,d.x,d.y)&&zk(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&&jk(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&zk(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=c;){if(d!==e.prev&&d!==e.next&&jk(r.x,r.y,n.x,n.y,o.x,o.y,d.x,d.y)&&zk(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=h;){if(p!==e.prev&&p!==e.next&&jk(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&zk(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Lk(e,t,i){var s=e;do{var r=s.prev,n=s.next.next;!Wk(r,n)&&Kk(r,s,s.next,n)&&Yk(r,n)&&Yk(n,r)&&(t.push(r.i/i),t.push(s.i/i),t.push(n.i/i),$k(s),$k(s.next),s=e=n),s=s.next}while(s!==e);return Dk(s)}function Uk(e,t,i,s,r,n){var o=e;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Gk(o,a)){var l=Zk(o,a);return o=Dk(o,o.next),l=Dk(l,l.next),Sk(o,t,i,s,r,n),void Sk(l,t,i,s,r,n)}a=a.next}o=o.next}while(o!==e)}function Ok(e,t){return e.x-t.x}function Nk(e,t){if(t=function(e,t){var i,s=t,r=e.x,n=e.y,o=-1/0;do{if(n<=s.y&&n>=s.next.y&&s.next.y!==s.y){var a=s.x+(n-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(a<=r&&a>o){if(o=a,a===r){if(n===s.y)return s;if(n===s.next.y)return s.next}i=s.x=s.x&&s.x>=A&&r!==s.x&&jk(ni.x||s.x===i.x&&Qk(i,s)))&&(i=s,h=l)),s=s.next}while(s!==u);return i}(e,t),t){var i=Zk(t,e);Dk(t,t.next),Dk(i,i.next)}}function Qk(e,t){return zk(e.prev,e,t.prev)<0&&zk(t.next,e,e.next)<0}function Vk(e,t,i,s,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Hk(e){var t=e,i=e;do{(t.x=0&&(e-o)*(s-a)-(i-o)*(t-a)>=0&&(i-o)*(n-a)-(r-o)*(s-a)>=0}function Gk(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Kk(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Yk(e,t)&&Yk(t,e)&&function(e,t){var i=e,s=!1,r=(e.x+t.x)/2,n=(e.y+t.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==e);return s}(e,t)&&(zk(e.prev,e,t.prev)||zk(e,t.prev,t))||Wk(e,t)&&zk(e.prev,e,e.next)>0&&zk(t.prev,t,t.next)>0)}function zk(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Wk(e,t){return e.x===t.x&&e.y===t.y}function Kk(e,t,i,s){var r=Jk(zk(e,t,i)),n=Jk(zk(e,t,s)),o=Jk(zk(i,s,e)),a=Jk(zk(i,s,t));return r!==n&&o!==a||(!(0!==r||!Xk(e,i,t))||(!(0!==n||!Xk(e,s,t))||(!(0!==o||!Xk(i,e,s))||!(0!==a||!Xk(i,t,s)))))}function Xk(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Jk(e){return e>0?1:e<0?-1:0}function Yk(e,t){return zk(e.prev,e,e.next)<0?zk(e,t,e.next)>=0&&zk(e,e.prev,t)>=0:zk(e,t,e.prev)<0||zk(e,e.next,t)<0}function Zk(e,t){var i=new eI(e.i,e.x,e.y),s=new eI(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,s.next=i,i.prev=s,n.next=s,s.prev=n,s}function qk(e,t,i,s){var r=new eI(e,t,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function $k(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function eI(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function tI(e,t,i,s){for(var r=0,n=t,o=i-s;n0&&(s+=e[r-1].length,i.holes.push(s))}return i};var iI=$.vec2(),sI=$.vec3(),rI=$.vec3(),nI=$.vec3(),oI=function(e){g(i,Se);var t=_(i);function i(e){var s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return x(this,i),(s=t.call(this,"cityJSONLoader",e,r)).dataSource=r.dataSource,s}return C(i,[{key:"dataSource",get:function(){return this._dataSource},set:function(e){this._dataSource=e||new Ek}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.id&&this.viewer.scene.components[e.id]&&(this.error("Component with this ID already exists in viewer: "+e.id+" - will autogenerate this ID"),delete e.id);var t=new Ah(this.viewer.scene,le.apply(e,{isModel:!0,edges:!0}));if(!e.src&&!e.cityJSON)return this.error("load() param expected: src or cityJSON"),t;var i={};if(e.src)this._loadModel(e.src,e,i,t);else{var s=this.viewer.scene.canvas.spinner;s.processes++,this._parseModel(e.cityJSON,e,i,t),s.processes--}return t}},{key:"_loadModel",value:function(e,t,i,s){var r=this,n=this.viewer.scene.canvas.spinner;n.processes++,this._dataSource.getCityJSON(t.src,(function(e){r._parseModel(e,t,i,s),n.processes--}),(function(e){n.processes--,r.error(e),s.fire("error",e)}))}},{key:"_parseModel",value:function(e,t,i,s){if(!s.destroyed){var r=e.transform?this._transformVertices(e.vertices,e.transform,i.rotateX):e.vertices,n=t.stats||{};n.sourceFormat=e.type||"CityJSON",n.schemaVersion=e.version||"",n.title="",n.author="",n.created="",n.numMetaObjects=0,n.numPropertySets=0,n.numObjects=0,n.numGeometries=0,n.numTriangles=0,n.numVertices=0;var o=!1!==t.loadMetadata,a=o?{id:$.createUUID(),name:"Model",type:"Model"}:null,l=o?{id:"",projectId:"",author:"",createdAt:"",schema:e.version||"",creatingApplication:"",metaObjects:[a],propertySets:[]}:null,u={data:e,vertices:r,sceneModel:s,loadMetadata:o,metadata:l,rootMetaObject:a,nextId:0,stats:n};if(this._parseCityJSON(u),s.finalize(),o){var A=s.id;this.viewer.metaScene.createMetaModel(A,u.metadata,i)}s.scene.once("tick",(function(){s.destroyed||(s.scene.fire("modelLoaded",s.id),s.fire("loaded",!0,!1))}))}}},{key:"_transformVertices",value:function(e,t,i){for(var s=[],r=t.scale||$.vec3([1,1,1]),n=t.translate||$.vec3([0,0,0]),o=0,a=0;o0){for(var u=[],A=0,c=t.geometry.length;A0){var _=g[m[0]];if(void 0!==_.value)d=v[_.value];else{var y=_.values;if(y){p=[];for(var b=0,B=y.length;b0&&(s.createEntity({id:i,meshIds:u,isObject:!0}),e.stats.numObjects++)}}},{key:"_parseGeometrySurfacesWithOwnMaterials",value:function(e,t,i,s){switch(t.type){case"MultiPoint":case"MultiLineString":break;case"MultiSurface":case"CompositeSurface":var r=t.boundaries;this._parseSurfacesWithOwnMaterials(e,i,r,s);break;case"Solid":for(var n=t.boundaries,o=0;o0&&c.push(u.length);var f=this._extractLocalIndices(e,a[p],h,d);u.push.apply(u,A(f))}if(3===u.length)d.indices.push(u[0]),d.indices.push(u[1]),d.indices.push(u[2]);else if(u.length>3){for(var v=[],g=0;g0&&o.indices.length>0){var f=""+e.nextId++;r.createMesh({id:f,primitive:"triangles",positions:o.positions,indices:o.indices,color:i&&i.diffuseColor?i.diffuseColor:[.8,.8,.8],opacity:1}),s.push(f),e.stats.numGeometries++,e.stats.numVertices+=o.positions.length/3,e.stats.numTriangles+=o.indices.length/3}}},{key:"_parseSurfacesWithSharedMaterial",value:function(e,t,i,s){for(var r=e.vertices,n=0;n0&&a.push(o.length);var u=this._extractLocalIndices(e,t[n][l],i,s);o.push.apply(o,A(u))}if(3===o.length)s.indices.push(o[0]),s.indices.push(o[1]),s.indices.push(o[2]);else if(o.length>3){for(var c=[],h=0;h