@aibee/crc-bmap 0.8.48 → 0.8.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7741,4 +7741,4 @@ void main() {
7741
7741
 
7742
7742
  }\`,cm=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,o){if(this.texture===null){let a=new ki,l=t.properties.get(a);l.__webglTexture=e.texture,(e.depthNear!=o.depthNear||e.depthFar!=o.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=a}}render(t,e){if(this.texture!==null){if(this.mesh===null){let o=e.cameras[0].viewport,a=new bo({extensions:{fragDepth:!0},vertexShader:eF,fragmentShader:nF,uniforms:{depthColor:{value:this.texture},depthWidth:{value:o.z},depthHeight:{value:o.w}}});this.mesh=new uo(new Lf(20,20),a)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}},fm=class extends Is{constructor(t,e){super();let o=this,a=null,l=1,h=null,f="local-floor",p=1,d=null,g=null,x=null,_=null,S=null,T=null,P=new cm,v=e.getContextAttributes(),y=null,C=null,M=[],D=[],B=new nn,z=null,U=new Ci;U.layers.enable(1),U.viewport=new Rr;let R=new Ci;R.layers.enable(2),R.viewport=new Rr;let rt=[U,R],O=new lm;O.layers.enable(1),O.layers.enable(2);let W=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let xt=M[K];return xt===void 0&&(xt=new Ml,M[K]=xt),xt.getTargetRaySpace()},this.getControllerGrip=function(K){let xt=M[K];return xt===void 0&&(xt=new Ml,M[K]=xt),xt.getGripSpace()},this.getHand=function(K){let xt=M[K];return xt===void 0&&(xt=new Ml,M[K]=xt),xt.getHandSpace()};function _t(K){let xt=D.indexOf(K.inputSource);if(xt===-1)return;let Lt=M[xt];Lt!==void 0&&(Lt.update(K.inputSource,K.frame,d||h),Lt.dispatchEvent({type:K.type,data:K.inputSource}))}function Y(){a.removeEventListener("select",_t),a.removeEventListener("selectstart",_t),a.removeEventListener("selectend",_t),a.removeEventListener("squeeze",_t),a.removeEventListener("squeezestart",_t),a.removeEventListener("squeezeend",_t),a.removeEventListener("end",Y),a.removeEventListener("inputsourceschange",ut);for(let K=0;K<M.length;K++){let xt=D[K];xt!==null&&(D[K]=null,M[K].disconnect(xt))}W=null,G=null,P.reset(),t.setRenderTarget(y),S=null,_=null,x=null,a=null,C=null,Zt.stop(),o.isPresenting=!1,t.setPixelRatio(z),t.setSize(B.width,B.height,!1),o.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){l=K,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){f=K,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||h},this.setReferenceSpace=function(K){d=K},this.getBaseLayer=function(){return _!==null?_:S},this.getBinding=function(){return x},this.getFrame=function(){return T},this.getSession=function(){return a},this.setSession=function(K){return uc(this,null,function*(){if(a=K,a!==null){if(y=t.getRenderTarget(),a.addEventListener("select",_t),a.addEventListener("selectstart",_t),a.addEventListener("selectend",_t),a.addEventListener("squeeze",_t),a.addEventListener("squeezestart",_t),a.addEventListener("squeezeend",_t),a.addEventListener("end",Y),a.addEventListener("inputsourceschange",ut),v.xrCompatible!==!0&&(yield e.makeXRCompatible()),z=t.getPixelRatio(),t.getSize(B),a.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let xt={antialias:a.renderState.layers===void 0?v.antialias:!0,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:l};S=new XRWebGLLayer(a,e,xt),a.updateRenderState({baseLayer:S}),t.setPixelRatio(1),t.setSize(S.framebufferWidth,S.framebufferHeight,!1),C=new is(S.framebufferWidth,S.framebufferHeight,{format:ao,type:Cs,colorSpace:t.outputColorSpace,stencilBuffer:v.stencil})}else{let xt=null,Lt=null,Xt=null;v.depth&&(Xt=v.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,xt=v.stencil?yu:fa,Lt=v.stencil?ca:bs);let Ct={colorFormat:e.RGBA8,depthFormat:Xt,scaleFactor:l};x=new XRWebGLBinding(a,e),_=x.createProjectionLayer(Ct),a.updateRenderState({layers:[_]}),t.setPixelRatio(1),t.setSize(_.textureWidth,_.textureHeight,!1),C=new is(_.textureWidth,_.textureHeight,{format:ao,type:Cs,depthTexture:new Of(_.textureWidth,_.textureHeight,Lt,void 0,void 0,void 0,void 0,void 0,void 0,xt),stencilBuffer:v.stencil,colorSpace:t.outputColorSpace,samples:v.antialias?4:0});let Pt=t.properties.get(C);Pt.__ignoreDepthValues=_.ignoreDepthValues}C.isXRRenderTarget=!0,this.setFoveation(p),d=null,h=yield a.requestReferenceSpace(f),Zt.setContext(a),Zt.start(),o.isPresenting=!0,o.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(a!==null)return a.environmentBlendMode};function ut(K){for(let xt=0;xt<K.removed.length;xt++){let Lt=K.removed[xt],Xt=D.indexOf(Lt);Xt>=0&&(D[Xt]=null,M[Xt].disconnect(Lt))}for(let xt=0;xt<K.added.length;xt++){let Lt=K.added[xt],Xt=D.indexOf(Lt);if(Xt===-1){for(let Pt=0;Pt<M.length;Pt++)if(Pt>=D.length){D.push(Lt),Xt=Pt;break}else if(D[Pt]===null){D[Pt]=Lt,Xt=Pt;break}if(Xt===-1)break}let Ct=M[Xt];Ct&&Ct.connect(Lt)}}let ct=new mt,dt=new mt;function j(K,xt,Lt){ct.setFromMatrixPosition(xt.matrixWorld),dt.setFromMatrixPosition(Lt.matrixWorld);let Xt=ct.distanceTo(dt),Ct=xt.projectionMatrix.elements,Pt=Lt.projectionMatrix.elements,wt=Ct[14]/(Ct[10]-1),Wt=Ct[14]/(Ct[10]+1),Q=(Ct[9]+1)/Ct[5],Qe=(Ct[9]-1)/Ct[5],zt=(Ct[8]-1)/Ct[0],te=(Pt[8]+1)/Pt[0],Vt=wt*zt,J=wt*te,N=Xt/(-zt+te),A=N*-zt;xt.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(A),K.translateZ(N),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert();let L=wt+N,b=Wt+N,w=Vt-A,q=J+(Xt-A),Z=Q*Wt/b*L,X=Qe*Wt/b*L;K.projectionMatrix.makePerspective(w,q,Z,X,L,b),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}function it(K,xt){xt===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(xt.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(a===null)return;P.texture!==null&&(K.near=P.depthNear,K.far=P.depthFar),O.near=R.near=U.near=K.near,O.far=R.far=U.far=K.far,(W!==O.near||G!==O.far)&&(a.updateRenderState({depthNear:O.near,depthFar:O.far}),W=O.near,G=O.far,U.near=W,U.far=G,R.near=W,R.far=G,U.updateProjectionMatrix(),R.updateProjectionMatrix(),K.updateProjectionMatrix());let xt=K.parent,Lt=O.cameras;it(O,xt);for(let Xt=0;Xt<Lt.length;Xt++)it(Lt[Xt],xt);Lt.length===2?j(O,U,R):O.projectionMatrix.copy(U.projectionMatrix),H(K,O,xt)};function H(K,xt,Lt){Lt===null?K.matrix.copy(xt.matrixWorld):(K.matrix.copy(Lt.matrixWorld),K.matrix.invert(),K.matrix.multiply(xt.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(xt.projectionMatrix),K.projectionMatrixInverse.copy(xt.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Yd*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(!(_===null&&S===null))return p},this.setFoveation=function(K){p=K,_!==null&&(_.fixedFoveation=K),S!==null&&S.fixedFoveation!==void 0&&(S.fixedFoveation=K)},this.hasDepthSensing=function(){return P.texture!==null};let Et=null;function Mt(K,xt){if(g=xt.getViewerPose(d||h),T=xt,g!==null){let Lt=g.views;S!==null&&(t.setRenderTargetFramebuffer(C,S.framebuffer),t.setRenderTarget(C));let Xt=!1;Lt.length!==O.cameras.length&&(O.cameras.length=0,Xt=!0);for(let Pt=0;Pt<Lt.length;Pt++){let wt=Lt[Pt],Wt=null;if(S!==null)Wt=S.getViewport(wt);else{let Qe=x.getViewSubImage(_,wt);Wt=Qe.viewport,Pt===0&&(t.setRenderTargetTextures(C,Qe.colorTexture,_.ignoreDepthValues?void 0:Qe.depthStencilTexture),t.setRenderTarget(C))}let Q=rt[Pt];Q===void 0&&(Q=new Ci,Q.layers.enable(Pt),Q.viewport=new Rr,rt[Pt]=Q),Q.matrix.fromArray(wt.transform.matrix),Q.matrix.decompose(Q.position,Q.quaternion,Q.scale),Q.projectionMatrix.fromArray(wt.projectionMatrix),Q.projectionMatrixInverse.copy(Q.projectionMatrix).invert(),Q.viewport.set(Wt.x,Wt.y,Wt.width,Wt.height),Pt===0&&(O.matrix.copy(Q.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),Xt===!0&&O.cameras.push(Q)}let Ct=a.enabledFeatures;if(Ct&&Ct.includes("depth-sensing")){let Pt=x.getDepthInformation(Lt[0]);Pt&&Pt.isValid&&Pt.texture&&P.init(t,Pt,a.renderState)}}for(let Lt=0;Lt<M.length;Lt++){let Xt=D[Lt],Ct=M[Lt];Xt!==null&&Ct!==void 0&&Ct.update(Xt,xt,d||h)}P.render(t,O),Et&&Et(K,xt),xt.detectedPlanes&&o.dispatchEvent({type:"planesdetected",data:xt}),T=null}let Zt=new DE;Zt.setAnimationLoop(Mt),this.setAnimationLoop=function(K){Et=K},this.dispose=function(){}}},oa=new pa,rF=new vr;function iF(r,t){function e(v,y){v.matrixAutoUpdate===!0&&v.updateMatrix(),y.value.copy(v.matrix)}function o(v,y){y.color.getRGB(v.fogColor.value,OE(r)),y.isFog?(v.fogNear.value=y.near,v.fogFar.value=y.far):y.isFogExp2&&(v.fogDensity.value=y.density)}function a(v,y,C,M,D){y.isMeshBasicMaterial||y.isMeshLambertMaterial?l(v,y):y.isMeshToonMaterial?(l(v,y),x(v,y)):y.isMeshPhongMaterial?(l(v,y),g(v,y)):y.isMeshStandardMaterial?(l(v,y),_(v,y),y.isMeshPhysicalMaterial&&S(v,y,D)):y.isMeshMatcapMaterial?(l(v,y),T(v,y)):y.isMeshDepthMaterial?l(v,y):y.isMeshDistanceMaterial?(l(v,y),P(v,y)):y.isMeshNormalMaterial?l(v,y):y.isLineBasicMaterial?(h(v,y),y.isLineDashedMaterial&&f(v,y)):y.isPointsMaterial?p(v,y,C,M):y.isSpriteMaterial?d(v,y):y.isShadowMaterial?(v.color.value.copy(y.color),v.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function l(v,y){v.opacity.value=y.opacity,y.color&&v.diffuse.value.copy(y.color),y.emissive&&v.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(v.map.value=y.map,e(y.map,v.mapTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,e(y.alphaMap,v.alphaMapTransform)),y.bumpMap&&(v.bumpMap.value=y.bumpMap,e(y.bumpMap,v.bumpMapTransform),v.bumpScale.value=y.bumpScale,y.side===gi&&(v.bumpScale.value*=-1)),y.normalMap&&(v.normalMap.value=y.normalMap,e(y.normalMap,v.normalMapTransform),v.normalScale.value.copy(y.normalScale),y.side===gi&&v.normalScale.value.negate()),y.displacementMap&&(v.displacementMap.value=y.displacementMap,e(y.displacementMap,v.displacementMapTransform),v.displacementScale.value=y.displacementScale,v.displacementBias.value=y.displacementBias),y.emissiveMap&&(v.emissiveMap.value=y.emissiveMap,e(y.emissiveMap,v.emissiveMapTransform)),y.specularMap&&(v.specularMap.value=y.specularMap,e(y.specularMap,v.specularMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest);let C=t.get(y),M=C.envMap,D=C.envMapRotation;if(M&&(v.envMap.value=M,oa.copy(D),oa.x*=-1,oa.y*=-1,oa.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(oa.y*=-1,oa.z*=-1),v.envMapRotation.value.setFromMatrix4(rF.makeRotationFromEuler(oa)),v.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=y.reflectivity,v.ior.value=y.ior,v.refractionRatio.value=y.refractionRatio),y.lightMap){v.lightMap.value=y.lightMap;let B=r._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=y.lightMapIntensity*B,e(y.lightMap,v.lightMapTransform)}y.aoMap&&(v.aoMap.value=y.aoMap,v.aoMapIntensity.value=y.aoMapIntensity,e(y.aoMap,v.aoMapTransform))}function h(v,y){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,y.map&&(v.map.value=y.map,e(y.map,v.mapTransform))}function f(v,y){v.dashSize.value=y.dashSize,v.totalSize.value=y.dashSize+y.gapSize,v.scale.value=y.scale}function p(v,y,C,M){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,v.size.value=y.size*C,v.scale.value=M*.5,y.map&&(v.map.value=y.map,e(y.map,v.uvTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,e(y.alphaMap,v.alphaMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest)}function d(v,y){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,v.rotation.value=y.rotation,y.map&&(v.map.value=y.map,e(y.map,v.mapTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,e(y.alphaMap,v.alphaMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest)}function g(v,y){v.specular.value.copy(y.specular),v.shininess.value=Math.max(y.shininess,1e-4)}function x(v,y){y.gradientMap&&(v.gradientMap.value=y.gradientMap)}function _(v,y){v.metalness.value=y.metalness,y.metalnessMap&&(v.metalnessMap.value=y.metalnessMap,e(y.metalnessMap,v.metalnessMapTransform)),v.roughness.value=y.roughness,y.roughnessMap&&(v.roughnessMap.value=y.roughnessMap,e(y.roughnessMap,v.roughnessMapTransform)),t.get(y).envMap&&(v.envMapIntensity.value=y.envMapIntensity)}function S(v,y,C){v.ior.value=y.ior,y.sheen>0&&(v.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),v.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(v.sheenColorMap.value=y.sheenColorMap,e(y.sheenColorMap,v.sheenColorMapTransform)),y.sheenRoughnessMap&&(v.sheenRoughnessMap.value=y.sheenRoughnessMap,e(y.sheenRoughnessMap,v.sheenRoughnessMapTransform))),y.clearcoat>0&&(v.clearcoat.value=y.clearcoat,v.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(v.clearcoatMap.value=y.clearcoatMap,e(y.clearcoatMap,v.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,e(y.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(v.clearcoatNormalMap.value=y.clearcoatNormalMap,e(y.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===gi&&v.clearcoatNormalScale.value.negate())),y.iridescence>0&&(v.iridescence.value=y.iridescence,v.iridescenceIOR.value=y.iridescenceIOR,v.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(v.iridescenceMap.value=y.iridescenceMap,e(y.iridescenceMap,v.iridescenceMapTransform)),y.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=y.iridescenceThicknessMap,e(y.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),y.transmission>0&&(v.transmission.value=y.transmission,v.transmissionSamplerMap.value=C.texture,v.transmissionSamplerSize.value.set(C.width,C.height),y.transmissionMap&&(v.transmissionMap.value=y.transmissionMap,e(y.transmissionMap,v.transmissionMapTransform)),v.thickness.value=y.thickness,y.thicknessMap&&(v.thicknessMap.value=y.thicknessMap,e(y.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=y.attenuationDistance,v.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(v.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(v.anisotropyMap.value=y.anisotropyMap,e(y.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=y.specularIntensity,v.specularColor.value.copy(y.specularColor),y.specularColorMap&&(v.specularColorMap.value=y.specularColorMap,e(y.specularColorMap,v.specularColorMapTransform)),y.specularIntensityMap&&(v.specularIntensityMap.value=y.specularIntensityMap,e(y.specularIntensityMap,v.specularIntensityMapTransform))}function T(v,y){y.matcap&&(v.matcap.value=y.matcap)}function P(v,y){let C=t.get(y).light;v.referencePosition.value.setFromMatrixPosition(C.matrixWorld),v.nearDistance.value=C.shadow.camera.near,v.farDistance.value=C.shadow.camera.far}return{refreshFogUniforms:o,refreshMaterialUniforms:a}}function oF(r,t,e,o){let a={},l={},h=[],f=e.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function p(C,M){let D=M.program;o.uniformBlockBinding(C,D)}function d(C,M){let D=a[C.id];D===void 0&&(T(C),D=g(C),a[C.id]=D,C.addEventListener("dispose",v));let B=M.program;o.updateUBOMapping(C,B);let z=t.render.frame;l[C.id]!==z&&(_(C),l[C.id]=z)}function g(C){let M=x();C.__bindingPointIndex=M;let D=r.createBuffer(),B=C.__size,z=C.usage;return r.bindBuffer(r.UNIFORM_BUFFER,D),r.bufferData(r.UNIFORM_BUFFER,B,z),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,M,D),D}function x(){for(let C=0;C<f;C++)if(h.indexOf(C)===-1)return h.push(C),C;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function _(C){let M=a[C.id],D=C.uniforms,B=C.__cache;r.bindBuffer(r.UNIFORM_BUFFER,M);for(let z=0,U=D.length;z<U;z++){let R=Array.isArray(D[z])?D[z]:[D[z]];for(let rt=0,O=R.length;rt<O;rt++){let W=R[rt];if(S(W,z,rt,B)===!0){let G=W.__offset,_t=Array.isArray(W.value)?W.value:[W.value],Y=0;for(let ut=0;ut<_t.length;ut++){let ct=_t[ut],dt=P(ct);typeof ct=="number"||typeof ct=="boolean"?(W.__data[0]=ct,r.bufferSubData(r.UNIFORM_BUFFER,G+Y,W.__data)):ct.isMatrix3?(W.__data[0]=ct.elements[0],W.__data[1]=ct.elements[1],W.__data[2]=ct.elements[2],W.__data[3]=0,W.__data[4]=ct.elements[3],W.__data[5]=ct.elements[4],W.__data[6]=ct.elements[5],W.__data[7]=0,W.__data[8]=ct.elements[6],W.__data[9]=ct.elements[7],W.__data[10]=ct.elements[8],W.__data[11]=0):(ct.toArray(W.__data,Y),Y+=dt.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,G,W.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function S(C,M,D,B){let z=C.value,U=M+"_"+D;if(B[U]===void 0)return typeof z=="number"||typeof z=="boolean"?B[U]=z:B[U]=z.clone(),!0;{let R=B[U];if(typeof z=="number"||typeof z=="boolean"){if(R!==z)return B[U]=z,!0}else if(R.equals(z)===!1)return R.copy(z),!0}return!1}function T(C){let M=C.uniforms,D=0,B=16;for(let U=0,R=M.length;U<R;U++){let rt=Array.isArray(M[U])?M[U]:[M[U]];for(let O=0,W=rt.length;O<W;O++){let G=rt[O],_t=Array.isArray(G.value)?G.value:[G.value];for(let Y=0,ut=_t.length;Y<ut;Y++){let ct=_t[Y],dt=P(ct),j=D%B;j!==0&&B-j<dt.boundary&&(D+=B-j),G.__data=new Float32Array(dt.storage/Float32Array.BYTES_PER_ELEMENT),G.__offset=D,D+=dt.storage}}}let z=D%B;return z>0&&(D+=B-z),C.__size=D,C.__cache={},this}function P(C){let M={boundary:0,storage:0};return typeof C=="number"||typeof C=="boolean"?(M.boundary=4,M.storage=4):C.isVector2?(M.boundary=8,M.storage=8):C.isVector3||C.isColor?(M.boundary=16,M.storage=12):C.isVector4?(M.boundary=16,M.storage=16):C.isMatrix3?(M.boundary=48,M.storage=48):C.isMatrix4?(M.boundary=64,M.storage=64):C.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",C),M}function v(C){let M=C.target;M.removeEventListener("dispose",v);let D=h.indexOf(M.__bindingPointIndex);h.splice(D,1),r.deleteBuffer(a[M.id]),delete a[M.id],delete l[M.id]}function y(){for(let C in a)r.deleteBuffer(a[C]);h=[],a={},l={}}return{bind:p,update:d,dispose:y}}var hm=class{constructor(t={}){let{canvas:e=uN(),context:o=null,depth:a=!0,stencil:l=!0,alpha:h=!1,antialias:f=!1,premultipliedAlpha:p=!0,preserveDrawingBuffer:d=!1,powerPreference:g="default",failIfMajorPerformanceCaveat:x=!1}=t;this.isWebGLRenderer=!0;let _;o!==null?_=o.getContextAttributes().alpha:_=h;let S=new Uint32Array(4),T=new Int32Array(4),P=null,v=null,y=[],C=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=So,this._useLegacyLights=!1,this.toneMapping=As,this.toneMappingExposure=1;let M=this,D=!1,B=0,z=0,U=null,R=-1,rt=null,O=new Rr,W=new Rr,G=null,_t=new dn(0),Y=0,ut=e.width,ct=e.height,dt=1,j=null,it=null,H=new Rr(0,0,ut,ct),Et=new Rr(0,0,ut,ct),Mt=!1,Zt=new Rf,K=!1,xt=!1,Lt=null,Xt=new vr,Ct=new nn,Pt=new mt,wt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Wt(){return U===null?dt:1}let Q=o;function Qe(k,tt){for(let pt=0;pt<k.length;pt++){let st=k[pt],et=e.getContext(st,tt);if(et!==null)return et}return null}try{let k={alpha:!0,depth:a,stencil:l,antialias:f,premultipliedAlpha:p,preserveDrawingBuffer:d,powerPreference:g,failIfMajorPerformanceCaveat:x};if("setAttribute"in e&&e.setAttribute("data-engine",\`three.js r\${wm}\`),e.addEventListener("webglcontextlost",ce,!1),e.addEventListener("webglcontextrestored",V,!1),e.addEventListener("webglcontextcreationerror",Rt,!1),Q===null){let tt=["webgl2","webgl","experimental-webgl"];if(M.isWebGL1Renderer===!0&&tt.shift(),Q=Qe(tt,k),Q===null)throw Qe(tt)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&Q instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),Q.getShaderPrecisionFormat===void 0&&(Q.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(k){throw console.error("THREE.WebGLRenderer: "+k.message),k}let zt,te,Vt,J,N,A,L,b,w,q,Z,X,ot,Tt,ht,vt,St,Ut,yt,ie,Qt,kt,Bt,Dt;function Yt(){zt=new ED(Q),te=new mD(Q,zt,t),zt.init(te),kt=new Q3(Q,zt,te),Vt=new K3(Q,zt,te),J=new wD(Q),N=new z3,A=new j3(Q,zt,Vt,N,te,kt,J),L=new yD(M),b=new xD(M),w=new IN(Q,te),Bt=new pD(Q,zt,w,te),q=new SD(Q,w,J,Bt),Z=new CD(Q,q,w,J),yt=new AD(Q,te,A),vt=new gD(N),X=new B3(M,L,b,zt,te,Bt,vt),ot=new iF(M,N),Tt=new G3,ht=new Y3(zt,te),Ut=new hD(M,L,b,Vt,Z,_,p),St=new J3(M,Z,te),Dt=new oF(Q,J,te,Vt),ie=new dD(Q,zt,J,te),Qt=new MD(Q,zt,J,te),J.programs=X.programs,M.capabilities=te,M.extensions=zt,M.properties=N,M.renderLists=Tt,M.shadowMap=St,M.state=Vt,M.info=J}Yt();let ne=new fm(M,Q);this.xr=ne,this.getContext=function(){return Q},this.getContextAttributes=function(){return Q.getContextAttributes()},this.forceContextLoss=function(){let k=zt.get("WEBGL_lose_context");k&&k.loseContext()},this.forceContextRestore=function(){let k=zt.get("WEBGL_lose_context");k&&k.restoreContext()},this.getPixelRatio=function(){return dt},this.setPixelRatio=function(k){k!==void 0&&(dt=k,this.setSize(ut,ct,!1))},this.getSize=function(k){return k.set(ut,ct)},this.setSize=function(k,tt,pt=!0){if(ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ut=k,ct=tt,e.width=Math.floor(k*dt),e.height=Math.floor(tt*dt),pt===!0&&(e.style.width=k+"px",e.style.height=tt+"px"),this.setViewport(0,0,k,tt)},this.getDrawingBufferSize=function(k){return k.set(ut*dt,ct*dt).floor()},this.setDrawingBufferSize=function(k,tt,pt){ut=k,ct=tt,dt=pt,e.width=Math.floor(k*pt),e.height=Math.floor(tt*pt),this.setViewport(0,0,k,tt)},this.getCurrentViewport=function(k){return k.copy(O)},this.getViewport=function(k){return k.copy(H)},this.setViewport=function(k,tt,pt,st){k.isVector4?H.set(k.x,k.y,k.z,k.w):H.set(k,tt,pt,st),Vt.viewport(O.copy(H).multiplyScalar(dt).round())},this.getScissor=function(k){return k.copy(Et)},this.setScissor=function(k,tt,pt,st){k.isVector4?Et.set(k.x,k.y,k.z,k.w):Et.set(k,tt,pt,st),Vt.scissor(W.copy(Et).multiplyScalar(dt).round())},this.getScissorTest=function(){return Mt},this.setScissorTest=function(k){Vt.setScissorTest(Mt=k)},this.setOpaqueSort=function(k){j=k},this.setTransparentSort=function(k){it=k},this.getClearColor=function(k){return k.copy(Ut.getClearColor())},this.setClearColor=function(){Ut.setClearColor.apply(Ut,arguments)},this.getClearAlpha=function(){return Ut.getClearAlpha()},this.setClearAlpha=function(){Ut.setClearAlpha.apply(Ut,arguments)},this.clear=function(k=!0,tt=!0,pt=!0){let st=0;if(k){let et=!1;if(U!==null){let qt=U.texture.format;et=qt===PE||qt===CE||qt===AE}if(et){let qt=U.texture.type,Ht=qt===Cs||qt===bs||qt===bm||qt===ca||qt===bE||qt===TE,ee=Ut.getClearColor(),$t=Ut.getClearAlpha(),fe=ee.r,re=ee.g,oe=ee.b;Ht?(S[0]=fe,S[1]=re,S[2]=oe,S[3]=$t,Q.clearBufferuiv(Q.COLOR,0,S)):(T[0]=fe,T[1]=re,T[2]=oe,T[3]=$t,Q.clearBufferiv(Q.COLOR,0,T))}else st|=Q.COLOR_BUFFER_BIT}tt&&(st|=Q.DEPTH_BUFFER_BIT),pt&&(st|=Q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Q.clear(st)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",ce,!1),e.removeEventListener("webglcontextrestored",V,!1),e.removeEventListener("webglcontextcreationerror",Rt,!1),Tt.dispose(),ht.dispose(),N.dispose(),L.dispose(),b.dispose(),Z.dispose(),Bt.dispose(),Dt.dispose(),X.dispose(),ne.dispose(),ne.removeEventListener("sessionstart",ci),ne.removeEventListener("sessionend",pn),Lt&&(Lt.dispose(),Lt=null),wr.stop()};function ce(k){k.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),D=!0}function V(){console.log("THREE.WebGLRenderer: Context Restored."),D=!1;let k=J.autoReset,tt=St.enabled,pt=St.autoUpdate,st=St.needsUpdate,et=St.type;Yt(),J.autoReset=k,St.enabled=tt,St.autoUpdate=pt,St.needsUpdate=st,St.type=et}function Rt(k){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",k.statusMessage)}function lt(k){let tt=k.target;tt.removeEventListener("dispose",lt),gt(tt)}function gt(k){Nt(k),N.remove(k)}function Nt(k){let tt=N.get(k).programs;tt!==void 0&&(tt.forEach(function(pt){X.releaseProgram(pt)}),k.isShaderMaterial&&X.releaseShaderCache(k))}this.renderBufferDirect=function(k,tt,pt,st,et,qt){tt===null&&(tt=wt);let Ht=et.isMesh&&et.matrixWorld.determinant()<0,ee=Hn(k,tt,pt,st,et);Vt.setMaterial(st,Ht);let $t=pt.index,fe=1;if(st.wireframe===!0){if($t=q.getWireframeAttribute(pt),$t===void 0)return;fe=2}let re=pt.drawRange,oe=pt.attributes.position,tn=re.start*fe,ur=(re.start+re.count)*fe;qt!==null&&(tn=Math.max(tn,qt.start*fe),ur=Math.min(ur,(qt.start+qt.count)*fe)),$t!==null?(tn=Math.max(tn,0),ur=Math.min(ur,$t.count)):oe!=null&&(tn=Math.max(tn,0),ur=Math.min(ur,oe.count));let Cn=ur-tn;if(Cn<0||Cn===1/0)return;Bt.setup(et,st,ee,pt,$t);let $r,gn=ie;if($t!==null&&($r=w.get($t),gn=Qt,gn.setIndex($r)),et.isMesh)st.wireframe===!0?(Vt.setLineWidth(st.wireframeLinewidth*Wt()),gn.setMode(Q.LINES)):gn.setMode(Q.TRIANGLES);else if(et.isLine){let Jt=st.linewidth;Jt===void 0&&(Jt=1),Vt.setLineWidth(Jt*Wt()),et.isLineSegments?gn.setMode(Q.LINES):et.isLineLoop?gn.setMode(Q.LINE_LOOP):gn.setMode(Q.LINE_STRIP)}else et.isPoints?gn.setMode(Q.POINTS):et.isSprite&&gn.setMode(Q.TRIANGLES);if(et.isBatchedMesh)gn.renderMultiDraw(et._multiDrawStarts,et._multiDrawCounts,et._multiDrawCount);else if(et.isInstancedMesh)gn.renderInstances(tn,Cn,et.count);else if(pt.isInstancedBufferGeometry){let Jt=pt._maxInstanceCount!==void 0?pt._maxInstanceCount:1/0,Aa=Math.min(pt.instanceCount,Jt);gn.renderInstances(tn,Cn,Aa)}else gn.render(tn,Cn)};function ue(k,tt,pt){k.transparent===!0&&k.side===ts&&k.forceSinglePass===!1?(k.side=gi,k.needsUpdate=!0,ar(k,tt,pt),k.side=Ps,k.needsUpdate=!0,ar(k,tt,pt),k.side=ts):ar(k,tt,pt)}this.compile=function(k,tt,pt=null){pt===null&&(pt=k),v=ht.get(pt),v.init(),C.push(v),pt.traverseVisible(function(et){et.isLight&&et.layers.test(tt.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),k!==pt&&k.traverseVisible(function(et){et.isLight&&et.layers.test(tt.layers)&&(v.pushLight(et),et.castShadow&&v.pushShadow(et))}),v.setupLights(M._useLegacyLights);let st=new Set;return k.traverse(function(et){let qt=et.material;if(qt)if(Array.isArray(qt))for(let Ht=0;Ht<qt.length;Ht++){let ee=qt[Ht];ue(ee,pt,et),st.add(ee)}else ue(qt,pt,et),st.add(qt)}),C.pop(),v=null,st},this.compileAsync=function(k,tt,pt=null){let st=this.compile(k,tt,pt);return new Promise(et=>{function qt(){if(st.forEach(function(Ht){N.get(Ht).currentProgram.isReady()&&st.delete(Ht)}),st.size===0){et(k);return}setTimeout(qt,10)}zt.get("KHR_parallel_shader_compile")!==null?qt():setTimeout(qt,10)})};let ye=null;function mn(k){ye&&ye(k)}function ci(){wr.stop()}function pn(){wr.start()}let wr=new DE;wr.setAnimationLoop(mn),typeof self!="undefined"&&wr.setContext(self),this.setAnimationLoop=function(k){ye=k,ne.setAnimationLoop(k),k===null?wr.stop():wr.start()},ne.addEventListener("sessionstart",ci),ne.addEventListener("sessionend",pn),this.render=function(k,tt){if(tt!==void 0&&tt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;k.matrixWorldAutoUpdate===!0&&k.updateMatrixWorld(),tt.parent===null&&tt.matrixWorldAutoUpdate===!0&&tt.updateMatrixWorld(),ne.enabled===!0&&ne.isPresenting===!0&&(ne.cameraAutoUpdate===!0&&ne.updateCamera(tt),tt=ne.getCamera()),k.isScene===!0&&k.onBeforeRender(M,k,tt,U),v=ht.get(k,C.length),v.init(),C.push(v),Xt.multiplyMatrices(tt.projectionMatrix,tt.matrixWorldInverse),Zt.setFromProjectionMatrix(Xt),xt=this.localClippingEnabled,K=vt.init(this.clippingPlanes,xt),P=Tt.get(k,y.length),P.init(),y.push(P),kn(k,tt,0,M.sortObjects),P.finish(),M.sortObjects===!0&&P.sort(j,it),this.info.render.frame++,K===!0&&vt.beginShadows();let pt=v.state.shadowsArray;if(St.render(pt,k,tt),K===!0&&vt.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ne.enabled===!1||ne.isPresenting===!1||ne.hasDepthSensing()===!1)&&Ut.render(P,k),v.setupLights(M._useLegacyLights),tt.isArrayCamera){let st=tt.cameras;for(let et=0,qt=st.length;et<qt;et++){let Ht=st[et];ss(P,k,Ht,Ht.viewport)}}else ss(P,k,tt);U!==null&&(A.updateMultisampleRenderTarget(U),A.updateRenderTargetMipmap(U)),k.isScene===!0&&k.onAfterRender(M,k,tt),Bt.resetDefaultState(),R=-1,rt=null,C.pop(),C.length>0?v=C[C.length-1]:v=null,y.pop(),y.length>0?P=y[y.length-1]:P=null};function kn(k,tt,pt,st){if(k.visible===!1)return;if(k.layers.test(tt.layers)){if(k.isGroup)pt=k.renderOrder;else if(k.isLOD)k.autoUpdate===!0&&k.update(tt);else if(k.isLight)v.pushLight(k),k.castShadow&&v.pushShadow(k);else if(k.isSprite){if(!k.frustumCulled||Zt.intersectsSprite(k)){st&&Pt.setFromMatrixPosition(k.matrixWorld).applyMatrix4(Xt);let Ht=Z.update(k),ee=k.material;ee.visible&&P.push(k,Ht,ee,pt,Pt.z,null)}}else if((k.isMesh||k.isLine||k.isPoints)&&(!k.frustumCulled||Zt.intersectsObject(k))){let Ht=Z.update(k),ee=k.material;if(st&&(k.boundingSphere!==void 0?(k.boundingSphere===null&&k.computeBoundingSphere(),Pt.copy(k.boundingSphere.center)):(Ht.boundingSphere===null&&Ht.computeBoundingSphere(),Pt.copy(Ht.boundingSphere.center)),Pt.applyMatrix4(k.matrixWorld).applyMatrix4(Xt)),Array.isArray(ee)){let $t=Ht.groups;for(let fe=0,re=$t.length;fe<re;fe++){let oe=$t[fe],tn=ee[oe.materialIndex];tn&&tn.visible&&P.push(k,Ht,tn,pt,Pt.z,oe)}}else ee.visible&&P.push(k,Ht,ee,pt,Pt.z,null)}}let qt=k.children;for(let Ht=0,ee=qt.length;Ht<ee;Ht++)kn(qt[Ht],tt,pt,st)}function ss(k,tt,pt,st){let et=k.opaque,qt=k.transmissive,Ht=k.transparent;v.setupLightsView(pt),K===!0&&vt.setGlobalState(M.clippingPlanes,pt),qt.length>0&&Ta(et,qt,tt,pt),st&&Vt.viewport(O.copy(st)),et.length>0&&xi(et,tt,pt),qt.length>0&&xi(qt,tt,pt),Ht.length>0&&xi(Ht,tt,pt),Vt.buffers.depth.setTest(!0),Vt.buffers.depth.setMask(!0),Vt.buffers.color.setMask(!0),Vt.setPolygonOffset(!1)}function Ta(k,tt,pt,st){if((pt.isScene===!0?pt.overrideMaterial:null)!==null)return;let qt=te.isWebGL2;Lt===null&&(Lt=new is(1,1,{generateMipmaps:!0,type:zt.has("EXT_color_buffer_half_float")?wl:Cs,minFilter:la,samples:qt?4:0})),M.getDrawingBufferSize(Ct),qt?Lt.setSize(Ct.x,Ct.y):Lt.setSize($d(Ct.x),$d(Ct.y));let Ht=M.getRenderTarget();M.setRenderTarget(Lt),M.getClearColor(_t),Y=M.getClearAlpha(),Y<1&&M.setClearColor(16777215,.5),M.clear();let ee=M.toneMapping;M.toneMapping=As,xi(k,pt,st),A.updateMultisampleRenderTarget(Lt),A.updateRenderTargetMipmap(Lt);let $t=!1;for(let fe=0,re=tt.length;fe<re;fe++){let oe=tt[fe],tn=oe.object,ur=oe.geometry,Cn=oe.material,$r=oe.group;if(Cn.side===ts&&tn.layers.test(st.layers)){let gn=Cn.side;Cn.side=gi,Cn.needsUpdate=!0,me(tn,pt,st,ur,Cn,$r),Cn.side=gn,Cn.needsUpdate=!0,$t=!0}}$t===!0&&(A.updateMultisampleRenderTarget(Lt),A.updateRenderTargetMipmap(Lt)),M.setRenderTarget(Ht),M.setClearColor(_t,Y),M.toneMapping=ee}function xi(k,tt,pt){let st=tt.isScene===!0?tt.overrideMaterial:null;for(let et=0,qt=k.length;et<qt;et++){let Ht=k[et],ee=Ht.object,$t=Ht.geometry,fe=st===null?Ht.material:st,re=Ht.group;ee.layers.test(pt.layers)&&me(ee,tt,pt,$t,fe,re)}}function me(k,tt,pt,st,et,qt){k.onBeforeRender(M,tt,pt,st,et,qt),k.modelViewMatrix.multiplyMatrices(pt.matrixWorldInverse,k.matrixWorld),k.normalMatrix.getNormalMatrix(k.modelViewMatrix),et.onBeforeRender(M,tt,pt,st,k,qt),et.transparent===!0&&et.side===ts&&et.forceSinglePass===!1?(et.side=gi,et.needsUpdate=!0,M.renderBufferDirect(pt,tt,st,et,k,qt),et.side=Ps,et.needsUpdate=!0,M.renderBufferDirect(pt,tt,st,et,k,qt),et.side=ts):M.renderBufferDirect(pt,tt,st,et,k,qt),k.onAfterRender(M,tt,pt,st,et,qt)}function ar(k,tt,pt){tt.isScene!==!0&&(tt=wt);let st=N.get(k),et=v.state.lights,qt=v.state.shadowsArray,Ht=et.state.version,ee=X.getParameters(k,et.state,qt,tt,pt),$t=X.getProgramCacheKey(ee),fe=st.programs;st.environment=k.isMeshStandardMaterial?tt.environment:null,st.fog=tt.fog,st.envMap=(k.isMeshStandardMaterial?b:L).get(k.envMap||st.environment),st.envMapRotation=st.environment!==null&&k.envMap===null?tt.environmentRotation:k.envMapRotation,fe===void 0&&(k.addEventListener("dispose",lt),fe=new Map,st.programs=fe);let re=fe.get($t);if(re!==void 0){if(st.currentProgram===re&&st.lightsStateVersion===Ht)return Fr(k,ee),re}else ee.uniforms=X.getUniforms(k),k.onBuild(pt,ee,M),k.onBeforeCompile(ee,M),re=X.acquireProgram(ee,$t),fe.set($t,re),st.uniforms=ee.uniforms;let oe=st.uniforms;return(!k.isShaderMaterial&&!k.isRawShaderMaterial||k.clipping===!0)&&(oe.clippingPlanes=vt.uniform),Fr(k,ee),st.needsLights=Ur(k),st.lightsStateVersion=Ht,st.needsLights&&(oe.ambientLightColor.value=et.state.ambient,oe.lightProbe.value=et.state.probe,oe.directionalLights.value=et.state.directional,oe.directionalLightShadows.value=et.state.directionalShadow,oe.spotLights.value=et.state.spot,oe.spotLightShadows.value=et.state.spotShadow,oe.rectAreaLights.value=et.state.rectArea,oe.ltc_1.value=et.state.rectAreaLTC1,oe.ltc_2.value=et.state.rectAreaLTC2,oe.pointLights.value=et.state.point,oe.pointLightShadows.value=et.state.pointShadow,oe.hemisphereLights.value=et.state.hemi,oe.directionalShadowMap.value=et.state.directionalShadowMap,oe.directionalShadowMatrix.value=et.state.directionalShadowMatrix,oe.spotShadowMap.value=et.state.spotShadowMap,oe.spotLightMatrix.value=et.state.spotLightMatrix,oe.spotLightMap.value=et.state.spotLightMap,oe.pointShadowMap.value=et.state.pointShadowMap,oe.pointShadowMatrix.value=et.state.pointShadowMatrix),st.currentProgram=re,st.uniformsList=null,re}function Yr(k){if(k.uniformsList===null){let tt=k.currentProgram.getUniforms();k.uniformsList=du.seqWithValue(tt.seq,k.uniforms)}return k.uniformsList}function Fr(k,tt){let pt=N.get(k);pt.outputColorSpace=tt.outputColorSpace,pt.batching=tt.batching,pt.instancing=tt.instancing,pt.instancingColor=tt.instancingColor,pt.instancingMorph=tt.instancingMorph,pt.skinning=tt.skinning,pt.morphTargets=tt.morphTargets,pt.morphNormals=tt.morphNormals,pt.morphColors=tt.morphColors,pt.morphTargetsCount=tt.morphTargetsCount,pt.numClippingPlanes=tt.numClippingPlanes,pt.numIntersection=tt.numClipIntersection,pt.vertexAlphas=tt.vertexAlphas,pt.vertexTangents=tt.vertexTangents,pt.toneMapping=tt.toneMapping}function Hn(k,tt,pt,st,et){tt.isScene!==!0&&(tt=wt),A.resetTextureUnits();let qt=tt.fog,Ht=st.isMeshStandardMaterial?tt.environment:null,ee=U===null?M.outputColorSpace:U.isXRRenderTarget===!0?U.texture.colorSpace:Ls,$t=(st.isMeshStandardMaterial?b:L).get(st.envMap||Ht),fe=st.vertexColors===!0&&!!pt.attributes.color&&pt.attributes.color.itemSize===4,re=!!pt.attributes.tangent&&(!!st.normalMap||st.anisotropy>0),oe=!!pt.morphAttributes.position,tn=!!pt.morphAttributes.normal,ur=!!pt.morphAttributes.color,Cn=As;st.toneMapped&&(U===null||U.isXRRenderTarget===!0)&&(Cn=M.toneMapping);let $r=pt.morphAttributes.position||pt.morphAttributes.normal||pt.morphAttributes.color,gn=$r!==void 0?$r.length:0,Jt=N.get(st),Aa=v.state.lights;if(K===!0&&(xt===!0||k!==rt)){let Zr=k===rt&&st.id===R;vt.setState(st,k,Zr)}let en=!1;st.version===Jt.__version?(Jt.needsLights&&Jt.lightsStateVersion!==Aa.state.version||Jt.outputColorSpace!==ee||et.isBatchedMesh&&Jt.batching===!1||!et.isBatchedMesh&&Jt.batching===!0||et.isInstancedMesh&&Jt.instancing===!1||!et.isInstancedMesh&&Jt.instancing===!0||et.isSkinnedMesh&&Jt.skinning===!1||!et.isSkinnedMesh&&Jt.skinning===!0||et.isInstancedMesh&&Jt.instancingColor===!0&&et.instanceColor===null||et.isInstancedMesh&&Jt.instancingColor===!1&&et.instanceColor!==null||et.isInstancedMesh&&Jt.instancingMorph===!0&&et.morphTexture===null||et.isInstancedMesh&&Jt.instancingMorph===!1&&et.morphTexture!==null||Jt.envMap!==$t||st.fog===!0&&Jt.fog!==qt||Jt.numClippingPlanes!==void 0&&(Jt.numClippingPlanes!==vt.numPlanes||Jt.numIntersection!==vt.numIntersection)||Jt.vertexAlphas!==fe||Jt.vertexTangents!==re||Jt.morphTargets!==oe||Jt.morphNormals!==tn||Jt.morphColors!==ur||Jt.toneMapping!==Cn||te.isWebGL2===!0&&Jt.morphTargetsCount!==gn)&&(en=!0):(en=!0,Jt.__version=st.version);let qi=Jt.currentProgram;en===!0&&(qi=ar(st,tt,et));let Xu=!1,he=!1,Gs=!1,yn=qi.getUniforms(),Vi=Jt.uniforms;if(Vt.useProgram(qi.program)&&(Xu=!0,he=!0,Gs=!0),st.id!==R&&(R=st.id,he=!0),Xu||rt!==k){yn.setValue(Q,"projectionMatrix",k.projectionMatrix),yn.setValue(Q,"viewMatrix",k.matrixWorldInverse);let Zr=yn.map.cameraPosition;Zr!==void 0&&Zr.setValue(Q,Pt.setFromMatrixPosition(k.matrixWorld)),te.logarithmicDepthBuffer&&yn.setValue(Q,"logDepthBufFC",2/(Math.log(k.far+1)/Math.LN2)),(st.isMeshPhongMaterial||st.isMeshToonMaterial||st.isMeshLambertMaterial||st.isMeshBasicMaterial||st.isMeshStandardMaterial||st.isShaderMaterial)&&yn.setValue(Q,"isOrthographic",k.isOrthographicCamera===!0),rt!==k&&(rt=k,he=!0,Gs=!0)}if(et.isSkinnedMesh){yn.setOptional(Q,et,"bindMatrix"),yn.setOptional(Q,et,"bindMatrixInverse");let Zr=et.skeleton;Zr&&(te.floatVertexTextures?(Zr.boneTexture===null&&Zr.computeBoneTexture(),yn.setValue(Q,"boneTexture",Zr.boneTexture,A)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}et.isBatchedMesh&&(yn.setOptional(Q,et,"batchingTexture"),yn.setValue(Q,"batchingTexture",et._matricesTexture,A));let le=pt.morphAttributes;if((le.position!==void 0||le.normal!==void 0||le.color!==void 0&&te.isWebGL2===!0)&&yt.update(et,pt,qi),(he||Jt.receiveShadow!==et.receiveShadow)&&(Jt.receiveShadow=et.receiveShadow,yn.setValue(Q,"receiveShadow",et.receiveShadow)),st.isMeshGouraudMaterial&&st.envMap!==null&&(Vi.envMap.value=$t,Vi.flipEnvMap.value=$t.isCubeTexture&&$t.isRenderTargetTexture===!1?-1:1),he&&(yn.setValue(Q,"toneMappingExposure",M.toneMappingExposure),Jt.needsLights&&po(Vi,Gs),qt&&st.fog===!0&&ot.refreshFogUniforms(Vi,qt),ot.refreshMaterialUniforms(Vi,st,dt,ct,Lt),du.upload(Q,Yr(Jt),Vi,A)),st.isShaderMaterial&&st.uniformsNeedUpdate===!0&&(du.upload(Q,Yr(Jt),Vi,A),st.uniformsNeedUpdate=!1),st.isSpriteMaterial&&yn.setValue(Q,"center",et.center),yn.setValue(Q,"modelViewMatrix",et.modelViewMatrix),yn.setValue(Q,"normalMatrix",et.normalMatrix),yn.setValue(Q,"modelMatrix",et.matrixWorld),st.isShaderMaterial||st.isRawShaderMaterial){let Zr=st.uniformsGroups;for(let Yu=0,Ca=Zr.length;Yu<Ca;Yu++)if(te.isWebGL2){let Jr=Zr[Yu];Dt.update(Jr,qi),Dt.bind(Jr,qi)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return qi}function po(k,tt){k.ambientLightColor.needsUpdate=tt,k.lightProbe.needsUpdate=tt,k.directionalLights.needsUpdate=tt,k.directionalLightShadows.needsUpdate=tt,k.pointLights.needsUpdate=tt,k.pointLightShadows.needsUpdate=tt,k.spotLights.needsUpdate=tt,k.spotLightShadows.needsUpdate=tt,k.rectAreaLights.needsUpdate=tt,k.hemisphereLights.needsUpdate=tt}function Ur(k){return k.isMeshLambertMaterial||k.isMeshToonMaterial||k.isMeshPhongMaterial||k.isMeshStandardMaterial||k.isShadowMaterial||k.isShaderMaterial&&k.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return U},this.setRenderTargetTextures=function(k,tt,pt){N.get(k.texture).__webglTexture=tt,N.get(k.depthTexture).__webglTexture=pt;let st=N.get(k);st.__hasExternalTextures=!0,st.__autoAllocateDepthBuffer=pt===void 0,st.__autoAllocateDepthBuffer||zt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),st.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(k,tt){let pt=N.get(k);pt.__webglFramebuffer=tt,pt.__useDefaultFramebuffer=tt===void 0},this.setRenderTarget=function(k,tt=0,pt=0){U=k,B=tt,z=pt;let st=!0,et=null,qt=!1,Ht=!1;if(k){let $t=N.get(k);$t.__useDefaultFramebuffer!==void 0?(Vt.bindFramebuffer(Q.FRAMEBUFFER,null),st=!1):$t.__webglFramebuffer===void 0?A.setupRenderTarget(k):$t.__hasExternalTextures&&A.rebindTextures(k,N.get(k.texture).__webglTexture,N.get(k.depthTexture).__webglTexture);let fe=k.texture;(fe.isData3DTexture||fe.isDataArrayTexture||fe.isCompressedArrayTexture)&&(Ht=!0);let re=N.get(k).__webglFramebuffer;k.isWebGLCubeRenderTarget?(Array.isArray(re[tt])?et=re[tt][pt]:et=re[tt],qt=!0):te.isWebGL2&&k.samples>0&&A.useMultisampledRTT(k)===!1?et=N.get(k).__webglMultisampledFramebuffer:Array.isArray(re)?et=re[pt]:et=re,O.copy(k.viewport),W.copy(k.scissor),G=k.scissorTest}else O.copy(H).multiplyScalar(dt).floor(),W.copy(Et).multiplyScalar(dt).floor(),G=Mt;if(Vt.bindFramebuffer(Q.FRAMEBUFFER,et)&&te.drawBuffers&&st&&Vt.drawBuffers(k,et),Vt.viewport(O),Vt.scissor(W),Vt.setScissorTest(G),qt){let $t=N.get(k.texture);Q.framebufferTexture2D(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_CUBE_MAP_POSITIVE_X+tt,$t.__webglTexture,pt)}else if(Ht){let $t=N.get(k.texture),fe=tt||0;Q.framebufferTextureLayer(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0,$t.__webglTexture,pt||0,fe)}R=-1},this.readRenderTargetPixels=function(k,tt,pt,st,et,qt,Ht){if(!(k&&k.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let ee=N.get(k).__webglFramebuffer;if(k.isWebGLCubeRenderTarget&&Ht!==void 0&&(ee=ee[Ht]),ee){Vt.bindFramebuffer(Q.FRAMEBUFFER,ee);try{let $t=k.texture,fe=$t.format,re=$t.type;if(fe!==ao&&kt.convert(fe)!==Q.getParameter(Q.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let oe=re===wl&&(zt.has("EXT_color_buffer_half_float")||te.isWebGL2&&zt.has("EXT_color_buffer_float"));if(re!==Cs&&kt.convert(re)!==Q.getParameter(Q.IMPLEMENTATION_COLOR_READ_TYPE)&&!(re===es&&(te.isWebGL2||zt.has("OES_texture_float")||zt.has("WEBGL_color_buffer_float")))&&!oe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}tt>=0&&tt<=k.width-st&&pt>=0&&pt<=k.height-et&&Q.readPixels(tt,pt,st,et,kt.convert(fe),kt.convert(re),qt)}finally{let $t=U!==null?N.get(U).__webglFramebuffer:null;Vt.bindFramebuffer(Q.FRAMEBUFFER,$t)}}},this.copyFramebufferToTexture=function(k,tt,pt=0){let st=Math.pow(2,-pt),et=Math.floor(tt.image.width*st),qt=Math.floor(tt.image.height*st);A.setTexture2D(tt,0),Q.copyTexSubImage2D(Q.TEXTURE_2D,pt,0,0,k.x,k.y,et,qt),Vt.unbindTexture()},this.copyTextureToTexture=function(k,tt,pt,st=0){let et=tt.image.width,qt=tt.image.height,Ht=kt.convert(pt.format),ee=kt.convert(pt.type);A.setTexture2D(pt,0),Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL,pt.flipY),Q.pixelStorei(Q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,pt.premultiplyAlpha),Q.pixelStorei(Q.UNPACK_ALIGNMENT,pt.unpackAlignment),tt.isDataTexture?Q.texSubImage2D(Q.TEXTURE_2D,st,k.x,k.y,et,qt,Ht,ee,tt.image.data):tt.isCompressedTexture?Q.compressedTexSubImage2D(Q.TEXTURE_2D,st,k.x,k.y,tt.mipmaps[0].width,tt.mipmaps[0].height,Ht,tt.mipmaps[0].data):Q.texSubImage2D(Q.TEXTURE_2D,st,k.x,k.y,Ht,ee,tt.image),st===0&&pt.generateMipmaps&&Q.generateMipmap(Q.TEXTURE_2D),Vt.unbindTexture()},this.copyTextureToTexture3D=function(k,tt,pt,st,et=0){if(M.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let qt=Math.round(k.max.x-k.min.x),Ht=Math.round(k.max.y-k.min.y),ee=k.max.z-k.min.z+1,$t=kt.convert(st.format),fe=kt.convert(st.type),re;if(st.isData3DTexture)A.setTexture3D(st,0),re=Q.TEXTURE_3D;else if(st.isDataArrayTexture||st.isCompressedArrayTexture)A.setTexture2DArray(st,0),re=Q.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL,st.flipY),Q.pixelStorei(Q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,st.premultiplyAlpha),Q.pixelStorei(Q.UNPACK_ALIGNMENT,st.unpackAlignment);let oe=Q.getParameter(Q.UNPACK_ROW_LENGTH),tn=Q.getParameter(Q.UNPACK_IMAGE_HEIGHT),ur=Q.getParameter(Q.UNPACK_SKIP_PIXELS),Cn=Q.getParameter(Q.UNPACK_SKIP_ROWS),$r=Q.getParameter(Q.UNPACK_SKIP_IMAGES),gn=pt.isCompressedTexture?pt.mipmaps[et]:pt.image;Q.pixelStorei(Q.UNPACK_ROW_LENGTH,gn.width),Q.pixelStorei(Q.UNPACK_IMAGE_HEIGHT,gn.height),Q.pixelStorei(Q.UNPACK_SKIP_PIXELS,k.min.x),Q.pixelStorei(Q.UNPACK_SKIP_ROWS,k.min.y),Q.pixelStorei(Q.UNPACK_SKIP_IMAGES,k.min.z),pt.isDataTexture||pt.isData3DTexture?Q.texSubImage3D(re,et,tt.x,tt.y,tt.z,qt,Ht,ee,$t,fe,gn.data):st.isCompressedArrayTexture?Q.compressedTexSubImage3D(re,et,tt.x,tt.y,tt.z,qt,Ht,ee,$t,gn.data):Q.texSubImage3D(re,et,tt.x,tt.y,tt.z,qt,Ht,ee,$t,fe,gn),Q.pixelStorei(Q.UNPACK_ROW_LENGTH,oe),Q.pixelStorei(Q.UNPACK_IMAGE_HEIGHT,tn),Q.pixelStorei(Q.UNPACK_SKIP_PIXELS,ur),Q.pixelStorei(Q.UNPACK_SKIP_ROWS,Cn),Q.pixelStorei(Q.UNPACK_SKIP_IMAGES,$r),et===0&&st.generateMipmaps&&Q.generateMipmap(re),Vt.unbindTexture()},this.initTexture=function(k){k.isCubeTexture?A.setTextureCube(k,0):k.isData3DTexture?A.setTexture3D(k,0):k.isDataArrayTexture||k.isCompressedArrayTexture?A.setTexture2DArray(k,0):A.setTexture2D(k,0),Vt.unbindTexture()},this.resetState=function(){B=0,z=0,U=null,Vt.reset(),Bt.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ns}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===Tm?"display-p3":"srgb",e.unpackColorSpace=xn.workingColorSpace===Ff?"display-p3":"srgb"}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},pm=class extends hm{};pm.prototype.isWebGL1Renderer=!0;function pf(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function sF(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var xu=class{constructor(t,e,o,a){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=a!==void 0?a:new e.constructor(o),this.sampleValues=e,this.valueSize=o,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,o=this._cachedIndex,a=e[o],l=e[o-1];n:{t:{let h;e:{r:if(!(t<a)){for(let f=o+2;;){if(a===void 0){if(t<l)break r;return o=e.length,this._cachedIndex=o,this.copySampleValue_(o-1)}if(o===f)break;if(l=a,a=e[++o],t<a)break t}h=e.length;break e}if(!(t>=l)){let f=e[1];t<f&&(o=2,l=f);for(let p=o-2;;){if(l===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(o===p)break;if(a=l,l=e[--o-1],t>=l)break t}h=o,o=0;break e}break n}for(;o<h;){let f=o+h>>>1;t<e[f]?h=f:o=f+1}if(a=e[o],l=e[o-1],l===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(a===void 0)return o=e.length,this._cachedIndex=o,this.copySampleValue_(o-1)}this._cachedIndex=o,this.intervalChanged_(o,l,a)}return this.interpolate_(o,l,t,a)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=t*a;for(let h=0;h!==a;++h)e[h]=o[l+h];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},dm=class extends xu{constructor(t,e,o,a){super(t,e,o,a),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:P1,endingEnd:P1}}intervalChanged_(t,e,o){let a=this.parameterPositions,l=t-2,h=t+1,f=a[l],p=a[h];if(f===void 0)switch(this.getSettings_().endingStart){case I1:l=t,f=2*e-o;break;case R1:l=a.length-2,f=e+a[l]-a[l+1];break;default:l=t,f=o}if(p===void 0)switch(this.getSettings_().endingEnd){case I1:h=t,p=2*o-e;break;case R1:h=1,p=o+a[1]-a[0];break;default:h=t-1,p=e}let d=(o-e)*.5,g=this.valueSize;this._weightPrev=d/(e-f),this._weightNext=d/(p-o),this._offsetPrev=l*g,this._offsetNext=h*g}interpolate_(t,e,o,a){let l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,p=t*f,d=p-f,g=this._offsetPrev,x=this._offsetNext,_=this._weightPrev,S=this._weightNext,T=(o-e)/(a-e),P=T*T,v=P*T,y=-_*v+2*_*P-_*T,C=(1+_)*v+(-1.5-2*_)*P+(-.5+_)*T+1,M=(-1-S)*v+(1.5+S)*P+.5*T,D=S*v-S*P;for(let B=0;B!==f;++B)l[B]=y*h[g+B]+C*h[d+B]+M*h[p+B]+D*h[x+B];return l}},mm=class extends xu{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t,e,o,a){let l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,p=t*f,d=p-f,g=(o-e)/(a-e),x=1-g;for(let _=0;_!==f;++_)l[_]=h[d+_]*x+h[p+_]*g;return l}},gm=class extends xu{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t){return this.copySampleValue_(t-1)}},lo=class{constructor(t,e,o,a){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=pf(e,this.TimeBufferType),this.values=pf(o,this.ValueBufferType),this.setInterpolation(a||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,o;if(e.toJSON!==this.toJSON)o=e.toJSON(t);else{o={name:t.name,times:pf(t.times,Array),values:pf(t.values,Array)};let a=t.getInterpolation();a!==t.DefaultInterpolation&&(o.interpolation=a)}return o.type=t.ValueTypeName,o}InterpolantFactoryMethodDiscrete(t){return new gm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new mm(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new dm(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case mf:e=this.InterpolantFactoryMethodDiscrete;break;case gf:e=this.InterpolantFactoryMethodLinear;break;case pd:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let o="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(o);return console.warn("THREE.KeyframeTrack:",o),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return mf;case this.InterpolantFactoryMethodLinear:return gf;case this.InterpolantFactoryMethodSmooth:return pd}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let o=0,a=e.length;o!==a;++o)e[o]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let o=0,a=e.length;o!==a;++o)e[o]*=t}return this}trim(t,e){let o=this.times,a=o.length,l=0,h=a-1;for(;l!==a&&o[l]<t;)++l;for(;h!==-1&&o[h]>e;)--h;if(++h,l!==0||h!==a){l>=h&&(h=Math.max(h,1),l=h-1);let f=this.getValueSize();this.times=o.slice(l,h),this.values=this.values.slice(l*f,h*f)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let o=this.times,a=this.values,l=o.length;l===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let h=null;for(let f=0;f!==l;f++){let p=o[f];if(typeof p=="number"&&isNaN(p)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,p),t=!1;break}if(h!==null&&h>p){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,p,h),t=!1;break}h=p}if(a!==void 0&&sF(a))for(let f=0,p=a.length;f!==p;++f){let d=a[f];if(isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),o=this.getValueSize(),a=this.getInterpolation()===pd,l=t.length-1,h=1;for(let f=1;f<l;++f){let p=!1,d=t[f],g=t[f+1];if(d!==g&&(f!==1||d!==t[0]))if(a)p=!0;else{let x=f*o,_=x-o,S=x+o;for(let T=0;T!==o;++T){let P=e[x+T];if(P!==e[_+T]||P!==e[S+T]){p=!0;break}}}if(p){if(f!==h){t[h]=t[f];let x=f*o,_=h*o;for(let S=0;S!==o;++S)e[_+S]=e[x+S]}++h}}if(l>0){t[h]=t[l];for(let f=l*o,p=h*o,d=0;d!==o;++d)e[p+d]=e[f+d];++h}return h!==t.length?(this.times=t.slice(0,h),this.values=e.slice(0,h*o)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),o=this.constructor,a=new o(this.name,t,e);return a.createInterpolant=this.createInterpolant,a}};lo.prototype.TimeBufferType=Float32Array;lo.prototype.ValueBufferType=Float32Array;lo.prototype.DefaultInterpolation=gf;var ma=class extends lo{};ma.prototype.ValueTypeName="bool";ma.prototype.ValueBufferType=Array;ma.prototype.DefaultInterpolation=mf;ma.prototype.InterpolantFactoryMethodLinear=void 0;ma.prototype.InterpolantFactoryMethodSmooth=void 0;var ym=class extends lo{};ym.prototype.ValueTypeName="color";var vm=class extends lo{};vm.prototype.ValueTypeName="number";var _m=class extends xu{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t,e,o,a){let l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,p=(o-e)/(a-e),d=t*f;for(let g=d+f;d!==g;d+=4)Rs.slerpFlat(l,0,h,d-f,h,d,p);return l}},Al=class extends lo{InterpolantFactoryMethodLinear(t){return new _m(this.times,this.values,this.getValueSize(),t)}};Al.prototype.ValueTypeName="quaternion";Al.prototype.DefaultInterpolation=gf;Al.prototype.InterpolantFactoryMethodSmooth=void 0;var ga=class extends lo{};ga.prototype.ValueTypeName="string";ga.prototype.ValueBufferType=Array;ga.prototype.DefaultInterpolation=mf;ga.prototype.InterpolantFactoryMethodLinear=void 0;ga.prototype.InterpolantFactoryMethodSmooth=void 0;var xm=class extends lo{};xm.prototype.ValueTypeName="vector";var Em=class{constructor(t,e,o){let a=this,l=!1,h=0,f=0,p,d=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=o,this.itemStart=function(g){f++,l===!1&&a.onStart!==void 0&&a.onStart(g,h,f),l=!0},this.itemEnd=function(g){h++,a.onProgress!==void 0&&a.onProgress(g,h,f),h===f&&(l=!1,a.onLoad!==void 0&&a.onLoad())},this.itemError=function(g){a.onError!==void 0&&a.onError(g)},this.resolveURL=function(g){return p?p(g):g},this.setURLModifier=function(g){return p=g,this},this.addHandler=function(g,x){return d.push(g,x),this},this.removeHandler=function(g){let x=d.indexOf(g);return x!==-1&&d.splice(x,2),this},this.getHandler=function(g){for(let x=0,_=d.length;x<_;x+=2){let S=d[x],T=d[x+1];if(S.global&&(S.lastIndex=0),S.test(g))return T}return null}}},aF=new Em,Sm=class{constructor(t){this.manager=t!==void 0?t:aF,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let o=this;return new Promise(function(a,l){o.load(t,a,e,l)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};Sm.DEFAULT_MATERIAL_NAME="__DEFAULT";var Cm="\\\\[\\\\]\\\\.:\\\\/",uF=new RegExp("["+Cm+"]","g"),Pm="[^"+Cm+"]",lF="[^"+Cm.replace("\\\\.","")+"]",cF=/((?:WC+[\\/:])*)/.source.replace("WC",Pm),fF=/(WCOD+)?/.source.replace("WCOD",lF),hF=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",Pm),pF=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",Pm),dF=new RegExp("^"+cF+fF+hF+pF+"$"),mF=["material","materials","bones","map"],Mm=class{constructor(t,e,o){let a=o||Nn.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,a)}getValue(t,e){this.bind();let o=this._targetGroup.nCachedObjects_,a=this._bindings[o];a!==void 0&&a.getValue(t,e)}setValue(t,e){let o=this._bindings;for(let a=this._targetGroup.nCachedObjects_,l=o.length;a!==l;++a)o[a].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,o=t.length;e!==o;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,o=t.length;e!==o;++e)t[e].unbind()}},Nn=class r{constructor(t,e,o){this.path=e,this.parsedPath=o||r.parseTrackName(e),this.node=r.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,o){return t&&t.isAnimationObjectGroup?new r.Composite(t,e,o):new r(t,e,o)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(uF,"")}static parseTrackName(t){let e=dF.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let o={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},a=o.nodeName&&o.nodeName.lastIndexOf(".");if(a!==void 0&&a!==-1){let l=o.nodeName.substring(a+1);mF.indexOf(l)!==-1&&(o.nodeName=o.nodeName.substring(0,a),o.objectName=l)}if(o.propertyName===null||o.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return o}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let o=t.skeleton.getBoneByName(e);if(o!==void 0)return o}if(t.children){let o=function(l){for(let h=0;h<l.length;h++){let f=l[h];if(f.name===e||f.uuid===e)return f;let p=o(f.children);if(p)return p}return null},a=o(t.children);if(a)return a}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let o=this.resolvedProperty;for(let a=0,l=o.length;a!==l;++a)t[e++]=o[a]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let o=this.resolvedProperty;for(let a=0,l=o.length;a!==l;++a)o[a]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let o=this.resolvedProperty;for(let a=0,l=o.length;a!==l;++a)o[a]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let o=this.resolvedProperty;for(let a=0,l=o.length;a!==l;++a)o[a]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,o=e.objectName,a=e.propertyName,l=e.propertyIndex;if(t||(t=r.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(o){let d=e.objectIndex;switch(o){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let g=0;g<t.length;g++)if(t[g].name===d){d=g;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[o]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[o]}if(d!==void 0){if(t[d]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[d]}}let h=t[a];if(h===void 0){let d=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+d+"."+a+" but it wasn't found.",t);return}let f=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?f=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(f=this.Versioning.MatrixWorldNeedsUpdate);let p=this.BindingType.Direct;if(l!==void 0){if(a==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[l]!==void 0&&(l=t.morphTargetDictionary[l])}p=this.BindingType.ArrayElement,this.resolvedProperty=h,this.propertyIndex=l}else h.fromArray!==void 0&&h.toArray!==void 0?(p=this.BindingType.HasFromToArray,this.resolvedProperty=h):Array.isArray(h)?(p=this.BindingType.EntireArray,this.resolvedProperty=h):this.propertyName=a;this.getValue=this.GetterByBindingType[p],this.setValue=this.SetterByBindingTypeAndVersioning[p][f]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Nn.Composite=Mm;Nn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Nn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Nn.prototype.GetterByBindingType=[Nn.prototype._getValue_direct,Nn.prototype._getValue_array,Nn.prototype._getValue_arrayElement,Nn.prototype._getValue_toArray];Nn.prototype.SetterByBindingTypeAndVersioning=[[Nn.prototype._setValue_direct,Nn.prototype._setValue_direct_setNeedsUpdate,Nn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Nn.prototype._setValue_array,Nn.prototype._setValue_array_setNeedsUpdate,Nn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Nn.prototype._setValue_arrayElement,Nn.prototype._setValue_arrayElement_setNeedsUpdate,Nn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Nn.prototype._setValue_fromArray,Nn.prototype._setValue_fromArray_setNeedsUpdate,Nn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Aq=new Float32Array(1);typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:wm}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=wm);var _r=63710088e-1,Iq={centimeters:_r*100,centimetres:_r*100,degrees:_r/111325,feet:_r*3.28084,inches:_r*39.37,kilometers:_r/1e3,kilometres:_r/1e3,meters:_r,metres:_r,miles:_r/1609.344,millimeters:_r*1e3,millimetres:_r*1e3,nauticalmiles:_r/1852,radians:1,yards:_r*1.0936},Rq={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/_r,yards:1.0936133};function si(r,t,e){e===void 0&&(e={});var o={type:"Feature"};return(e.id===0||e.id)&&(o.id=e.id),e.bbox&&(o.bbox=e.bbox),o.properties=t||{},o.geometry=r,o}function wn(r,t,e){if(e===void 0&&(e={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!To(r[0])||!To(r[1]))throw new Error("coordinates must contain numbers");var o={type:"Point",coordinates:r};return si(o,t,e)}function On(r,t,e){e===void 0&&(e={});for(var o=0,a=r;o<a.length;o++){var l=a[o];if(l.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var h=0;h<l[l.length-1].length;h++)if(l[l.length-1][h]!==l[0][h])throw new Error("First and last Position are not equivalent.")}var f={type:"Polygon",coordinates:r};return si(f,t,e)}function xr(r,t,e){if(e===void 0&&(e={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var o={type:"LineString",coordinates:r};return si(o,t,e)}function Im(r,t,e){e===void 0&&(e={});var o={type:"MultiPoint",coordinates:r};return si(o,t,e)}function To(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function rr(r,t,e){if(r!==null)for(var o,a,l,h,f,p,d,g=0,x=0,_,S=r.type,T=S==="FeatureCollection",P=S==="Feature",v=T?r.features.length:1,y=0;y<v;y++){d=T?r.features[y].geometry:P?r.geometry:r,_=d?d.type==="GeometryCollection":!1,f=_?d.geometries.length:1;for(var C=0;C<f;C++){var M=0,D=0;if(h=_?d.geometries[C]:d,h!==null){p=h.coordinates;var B=h.type;switch(g=e&&(B==="Polygon"||B==="MultiPolygon")?1:0,B){case null:break;case"Point":if(t(p,x,y,M,D)===!1)return!1;x++,M++;break;case"LineString":case"MultiPoint":for(o=0;o<p.length;o++){if(t(p[o],x,y,M,D)===!1)return!1;x++,B==="MultiPoint"&&M++}B==="LineString"&&M++;break;case"Polygon":case"MultiLineString":for(o=0;o<p.length;o++){for(a=0;a<p[o].length-g;a++){if(t(p[o][a],x,y,M,D)===!1)return!1;x++}B==="MultiLineString"&&M++,B==="Polygon"&&D++}B==="Polygon"&&M++;break;case"MultiPolygon":for(o=0;o<p.length;o++){for(D=0,a=0;a<p[o].length;a++){for(l=0;l<p[o][a].length-g;l++){if(t(p[o][a][l],x,y,M,D)===!1)return!1;x++}D++}M++}break;case"GeometryCollection":for(o=0;o<h.geometries.length;o++)if(rr(h.geometries[o],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function GE(r,t,e,o){var a=e;return rr(r,function(l,h,f,p,d){h===0&&e===void 0?a=l:a=t(a,l,h,f,p,d)},o),a}function Ns(r,t){var e,o,a,l,h,f,p,d,g,x,_=0,S=r.type==="FeatureCollection",T=r.type==="Feature",P=S?r.features.length:1;for(e=0;e<P;e++){for(f=S?r.features[e].geometry:T?r.geometry:r,d=S?r.features[e].properties:T?r.properties:{},g=S?r.features[e].bbox:T?r.bbox:void 0,x=S?r.features[e].id:T?r.id:void 0,p=f?f.type==="GeometryCollection":!1,h=p?f.geometries.length:1,a=0;a<h;a++){if(l=p?f.geometries[a]:f,l===null){if(t(null,_,d,g,x)===!1)return!1;continue}switch(l.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(t(l,_,d,g,x)===!1)return!1;break}case"GeometryCollection":{for(o=0;o<l.geometries.length;o++)if(t(l.geometries[o],_,d,g,x)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}_++}}function Pi(r,t){Ns(r,function(e,o,a,l,h){var f=e===null?null:e.type;switch(f){case null:case"Point":case"LineString":case"Polygon":return t(si(e,a,{bbox:l,id:h}),o,0)===!1?!1:void 0}var p;switch(f){case"MultiPoint":p="Point";break;case"MultiLineString":p="LineString";break;case"MultiPolygon":p="Polygon";break}for(var d=0;d<e.coordinates.length;d++){var g=e.coordinates[d],x={type:p,coordinates:g};if(t(si(x,a),o,d)===!1)return!1}})}function Rm(r){var t=[1/0,1/0,-1/0,-1/0];return rr(r,function(e){t[0]>e[0]&&(t[0]=e[0]),t[1]>e[1]&&(t[1]=e[1]),t[2]<e[0]&&(t[2]=e[0]),t[3]<e[1]&&(t[3]=e[1])}),t}Rm.default=Rm;var ai=Rm;function Lr(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Lm(r,t,e){if(!r)throw new Error("No feature passed");if(!e)throw new Error(".featureOf() requires a name");if(!r||r.type!=="Feature"||!r.geometry)throw new Error("Invalid input to "+e+", Feature with geometry required");if(!r.geometry||r.geometry.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+r.geometry.type)}function Nr(r){return r.type==="Feature"?r.geometry:r}var MF=hn(Bf(),1);var NF=hn(oS(),1);function Er(r,t,e){if(e===void 0&&(e={}),!r)throw new Error("point is required");if(!t)throw new Error("polygon is required");var o=Lr(r),a=Nr(t),l=a.type,h=t.bbox,f=a.coordinates;if(h&&OF(o,h)===!1)return!1;l==="Polygon"&&(f=[f]);for(var p=!1,d=0;d<f.length&&!p;d++)if(sS(o,f[d][0],e.ignoreBoundary)){for(var g=!1,x=1;x<f[d].length&&!g;)sS(o,f[d][x],!e.ignoreBoundary)&&(g=!0),x++;g||(p=!0)}return p}function sS(r,t,e){var o=!1;t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&(t=t.slice(0,t.length-1));for(var a=0,l=t.length-1;a<t.length;l=a++){var h=t[a][0],f=t[a][1],p=t[l][0],d=t[l][1],g=r[1]*(h-p)+f*(p-r[0])+d*(r[0]-h)===0&&(h-r[0])*(p-r[0])<=0&&(f-r[1])*(d-r[1])<=0;if(g)return!e;var x=f>r[1]!=d>r[1]&&r[0]<(p-h)*(r[1]-f)/(d-f)+h;x&&(o=!o)}return o}function OF(r,t){return t[0]<=r[0]&&t[1]<=r[1]&&t[2]>=r[0]&&t[3]>=r[1]}var lS=new ArrayBuffer(16),sH=new Float64Array(lS),aH=new Uint32Array(lS);var ZF=hn($m(),1);var N6=function(){function r(t){this.points=t.points||[],this.duration=t.duration||1e4,this.sharpness=t.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=t.stepLength||60,this.length=this.points.length,this.delay=0;for(var e=0;e<this.length;e++)this.points[e].z=this.points[e].z||0;for(var e=0;e<this.length-1;e++){var o=this.points[e],a=this.points[e+1];this.centers.push({x:(o.x+a.x)/2,y:(o.y+a.y)/2,z:(o.z+a.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var e=0;e<this.centers.length-1;e++){var l=this.points[e+1].x-(this.centers[e].x+this.centers[e+1].x)/2,h=this.points[e+1].y-(this.centers[e].y+this.centers[e+1].y)/2,f=this.points[e+1].z-(this.centers[e].y+this.centers[e+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e].x+l),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e].y+h),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e].z+f)},{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e+1].x+l),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e+1].y+h),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e+1].z+f)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return r.prototype.cacheSteps=function(t){var e=[],o=this.pos(0);e.push(0);for(var a=0;a<this.duration;a+=10){var l=this.pos(a),h=Math.sqrt((l.x-o.x)*(l.x-o.x)+(l.y-o.y)*(l.y-o.y)+(l.z-o.z)*(l.z-o.z));h>t&&(e.push(a),o=l)}return e},r.prototype.vector=function(t){var e=this.pos(t+10),o=this.pos(t-10);return{angle:180*Math.atan2(e.y-o.y,e.x-o.x)/3.14,speed:Math.sqrt((o.x-e.x)*(o.x-e.x)+(o.y-e.y)*(o.y-e.y)+(o.z-e.z)*(o.z-e.z))}},r.prototype.pos=function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var o=e/this.duration;if(o>=1)return this.points[this.length-1];var a=Math.floor((this.points.length-1)*o),l=(this.length-1)*o-a;return JF(l,this.points[a],this.controls[a][1],this.controls[a+1][0],this.points[a+1])},r}();function JF(r,t,e,o,a){var l=KF(r),h={x:a.x*l[0]+o.x*l[1]+e.x*l[2]+t.x*l[3],y:a.y*l[0]+o.y*l[1]+e.y*l[2]+t.y*l[3],z:a.z*l[0]+o.z*l[1]+e.z*l[2]+t.z*l[3]};return h}function KF(r){var t=r*r,e=t*r;return[e,3*t*(1-r),3*r*(1-r)*(1-r),(1-r)*(1-r)*(1-r)]}function Ll(r,t){t===void 0&&(t={});var e=Number(r[0]),o=Number(r[1]),a=Number(r[2]),l=Number(r[3]);if(r.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var h=[e,o],f=[e,l],p=[a,l],d=[a,o];return On([[h,d,p,f,h]],t.properties,{bbox:r,id:t.id})}function jF(r){return Ll(ai(r))}var Zm=jF;var mU=hn(xS(),1);var qU=hn(eh(),1);var HU=hn(Bf(),1);var YU=hn($m(),1);var BS=Math.PI/180,zS=180/Math.PI,zl=function(r,t){this.lon=r,this.lat=t,this.x=BS*r,this.y=BS*t};zl.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)};zl.prototype.antipode=function(){var r=-1*this.lat,t=this.lon<0?180+this.lon:(180-this.lon)*-1;return new zl(t,r)};var kS=function(){this.coords=[],this.length=0};kS.prototype.move_to=function(r){this.length++,this.coords.push(r)};var mg=function(r){this.properties=r||{},this.geometries=[]};mg.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:"LineString",coordinates:null},type:"Feature",properties:this.properties};if(this.geometries.length===1)return{geometry:{type:"LineString",coordinates:this.geometries[0].coords},type:"Feature",properties:this.properties};for(var r=[],t=0;t<this.geometries.length;t++)r.push(this.geometries[t].coords);return{geometry:{type:"MultiLineString",coordinates:r},type:"Feature",properties:this.properties}};mg.prototype.wkt=function(){for(var r="",t="LINESTRING(",e=function(l){t+=l[0]+" "+l[1]+","},o=0;o<this.geometries.length;o++){if(this.geometries[o].coords.length===0)return"LINESTRING(empty)";var a=this.geometries[o].coords;a.forEach(e),r+=t.substring(0,t.length-1)+")"}return r};var GS=function(r,t,e){if(!r||r.x===void 0||r.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!t||t.x===void 0||t.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start=new zl(r.x,r.y),this.end=new zl(t.x,t.y),this.properties=e||{};var o=this.start.x-this.end.x,a=this.start.y-this.end.y,l=Math.pow(Math.sin(a/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(o/2),2);if(this.g=2*Math.asin(Math.sqrt(l)),this.g===Math.PI)throw new Error("it appears "+r.view()+" and "+t.view()+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+r+" and "+t)};GS.prototype.interpolate=function(r){var t=Math.sin((1-r)*this.g)/Math.sin(this.g),e=Math.sin(r*this.g)/Math.sin(this.g),o=t*Math.cos(this.start.y)*Math.cos(this.start.x)+e*Math.cos(this.end.y)*Math.cos(this.end.x),a=t*Math.cos(this.start.y)*Math.sin(this.start.x)+e*Math.cos(this.end.y)*Math.sin(this.end.x),l=t*Math.sin(this.start.y)+e*Math.sin(this.end.y),h=zS*Math.atan2(l,Math.sqrt(Math.pow(o,2)+Math.pow(a,2))),f=zS*Math.atan2(a,o);return[f,h]};GS.prototype.Arc=function(r,t){var e=[];if(!r||r<=2)e.push([this.start.lon,this.start.lat]),e.push([this.end.lon,this.end.lat]);else for(var o=1/(r-1),a=0;a<r;++a){var l=o*a,h=this.interpolate(l);e.push(h)}for(var f=!1,p=0,d=t&&t.offset?t.offset:10,g=180-d,x=-180+d,_=360-d,S=1;S<e.length;++S){var T=e[S-1][0],P=e[S][0],v=Math.abs(P-T);v>_&&(P>g&&T<x||T>g&&P<x)?f=!0:v>p&&(p=v)}var y=[];if(f&&p<d){var C=[];y.push(C);for(var M=0;M<e.length;++M){var D=parseFloat(e[M][0]);if(M>0&&Math.abs(D-e[M-1][0])>_){var B=parseFloat(e[M-1][0]),z=parseFloat(e[M-1][1]),U=parseFloat(e[M][0]),R=parseFloat(e[M][1]);if(B>-180&&B<x&&U===180&&M+1<e.length&&e[M-1][0]>-180&&e[M-1][0]<x){C.push([-180,e[M][1]]),M++,C.push([e[M][0],e[M][1]]);continue}else if(B>g&&B<180&&U===-180&&M+1<e.length&&e[M-1][0]>g&&e[M-1][0]<180){C.push([180,e[M][1]]),M++,C.push([e[M][0],e[M][1]]);continue}if(B<x&&U>g){var rt=B;B=U,U=rt;var O=z;z=R,R=O}if(B>g&&U<x&&(U+=360),B<=180&&U>=180&&B<U){var W=(180-B)/(U-B),G=W*R+(1-W)*z;C.push([e[M-1][0]>g?180:-180,G]),C=[],C.push([e[M-1][0]>g?-180:180,G]),y.push(C)}else C=[],y.push(C);C.push([D,e[M][1]])}else C.push([e[M][0],e[M][1]])}}else{var _t=[];y.push(_t);for(var Y=0;Y<e.length;++Y)_t.push([e[Y][0],e[Y][1]])}for(var ut=new mg(this.properties),ct=0;ct<y.length;++ct){var dt=new kS;ut.geometries.push(dt);for(var j=y[ct],it=0;it<j.length;++it)dt.move_to(j[it])}return ut};var JU=hn(eh(),1);var wz=hn(eh(),1);var bz=hn(Ug(),1);var Cz=hn(Bf(),1);var _e=[],xe=[],Ee=[],Se=[],Me=[],we=[],be=[],Te=[],Ae=[],Ce=[],Pe=[],Ie=[],Re=[],Le=[],Ne=[],Oe=[],De=[],Fe=[],Ue=[],Be=[],ze=[],ke=[],Ge=[],qe=[];be[85]=Ce[85]=-1;Te[85]=Pe[85]=0;Ae[85]=Ie[85]=1;Ue[85]=ke[85]=1;Be[85]=Ge[85]=0;ze[85]=qe[85]=1;_e[85]=Se[85]=0;xe[85]=Me[85]=-1;Ee[85]=Ne[85]=0;Oe[85]=Re[85]=0;De[85]=Le[85]=1;we[85]=Fe[85]=1;ke[1]=ke[169]=0;Ge[1]=Ge[169]=-1;qe[1]=qe[169]=0;Re[1]=Re[169]=-1;Le[1]=Le[169]=0;Ne[1]=Ne[169]=0;Ce[4]=Ce[166]=0;Pe[4]=Pe[166]=-1;Ie[4]=Ie[166]=1;Oe[4]=Oe[166]=1;De[4]=De[166]=0;Fe[4]=Fe[166]=0;be[16]=be[154]=0;Te[16]=Te[154]=1;Ae[16]=Ae[154]=1;Se[16]=Se[154]=1;Me[16]=Me[154]=0;we[16]=we[154]=1;Ue[64]=Ue[106]=0;Be[64]=Be[106]=1;ze[64]=ze[106]=0;_e[64]=_e[106]=-1;xe[64]=xe[106]=0;Ee[64]=Ee[106]=1;Ue[2]=Ue[168]=0;Be[2]=Be[168]=-1;ze[2]=ze[168]=1;ke[2]=ke[168]=0;Ge[2]=Ge[168]=-1;qe[2]=qe[168]=0;Re[2]=Re[168]=-1;Le[2]=Le[168]=0;Ne[2]=Ne[168]=0;Oe[2]=Oe[168]=-1;De[2]=De[168]=0;Fe[2]=Fe[168]=1;be[8]=be[162]=0;Te[8]=Te[162]=-1;Ae[8]=Ae[162]=0;Ce[8]=Ce[162]=0;Pe[8]=Pe[162]=-1;Ie[8]=Ie[162]=1;Re[8]=Re[162]=1;Le[8]=Le[162]=0;Ne[8]=Ne[162]=1;Oe[8]=Oe[162]=1;De[8]=De[162]=0;Fe[8]=Fe[162]=0;be[32]=be[138]=0;Te[32]=Te[138]=1;Ae[32]=Ae[138]=1;Ce[32]=Ce[138]=0;Pe[32]=Pe[138]=1;Ie[32]=Ie[138]=0;_e[32]=_e[138]=1;xe[32]=xe[138]=0;Ee[32]=Ee[138]=0;Se[32]=Se[138]=1;Me[32]=Me[138]=0;we[32]=we[138]=1;ke[128]=ke[42]=0;Ge[128]=Ge[42]=1;qe[128]=qe[42]=1;Ue[128]=Ue[42]=0;Be[128]=Be[42]=1;ze[128]=ze[42]=0;_e[128]=_e[42]=-1;xe[128]=xe[42]=0;Ee[128]=Ee[42]=1;Se[128]=Se[42]=-1;Me[128]=Me[42]=0;we[128]=we[42]=0;Ce[5]=Ce[165]=-1;Pe[5]=Pe[165]=0;Ie[5]=Ie[165]=0;ke[5]=ke[165]=1;Ge[5]=Ge[165]=0;qe[5]=qe[165]=0;Oe[20]=Oe[150]=0;De[20]=De[150]=1;Fe[20]=Fe[150]=1;Se[20]=Se[150]=0;Me[20]=Me[150]=-1;we[20]=we[150]=1;be[80]=be[90]=-1;Te[80]=Te[90]=0;Ae[80]=Ae[90]=1;Ue[80]=Ue[90]=1;Be[80]=Be[90]=0;ze[80]=ze[90]=1;Re[65]=Re[105]=0;Le[65]=Le[105]=1;Ne[65]=Ne[105]=0;_e[65]=_e[105]=0;xe[65]=xe[105]=-1;Ee[65]=Ee[105]=0;be[160]=be[10]=-1;Te[160]=Te[10]=0;Ae[160]=Ae[10]=1;Ce[160]=Ce[10]=-1;Pe[160]=Pe[10]=0;Ie[160]=Ie[10]=0;ke[160]=ke[10]=1;Ge[160]=Ge[10]=0;qe[160]=qe[10]=0;Ue[160]=Ue[10]=1;Be[160]=Be[10]=0;ze[160]=ze[10]=1;Oe[130]=Oe[40]=0;De[130]=De[40]=1;Fe[130]=Fe[40]=1;Re[130]=Re[40]=0;Le[130]=Le[40]=1;Ne[130]=Ne[40]=0;_e[130]=_e[40]=0;xe[130]=xe[40]=-1;Ee[130]=Ee[40]=0;Se[130]=Se[40]=0;Me[130]=Me[40]=-1;we[130]=we[40]=1;Ce[37]=Ce[133]=0;Pe[37]=Pe[133]=1;Ie[37]=Ie[133]=1;ke[37]=ke[133]=0;Ge[37]=Ge[133]=1;qe[37]=qe[133]=0;_e[37]=_e[133]=-1;xe[37]=xe[133]=0;Ee[37]=Ee[133]=0;Se[37]=Se[133]=1;Me[37]=Me[133]=0;we[37]=we[133]=0;Oe[148]=Oe[22]=-1;De[148]=De[22]=0;Fe[148]=Fe[22]=0;ke[148]=ke[22]=0;Ge[148]=Ge[22]=-1;qe[148]=qe[22]=1;Ue[148]=Ue[22]=0;Be[148]=Be[22]=1;ze[148]=ze[22]=1;Se[148]=Se[22]=-1;Me[148]=Me[22]=0;we[148]=we[22]=1;be[82]=be[88]=0;Te[82]=Te[88]=-1;Ae[82]=Ae[88]=1;Oe[82]=Oe[88]=1;De[82]=De[88]=0;Fe[82]=Fe[88]=1;Re[82]=Re[88]=-1;Le[82]=Le[88]=0;Ne[82]=Ne[88]=1;Ue[82]=Ue[88]=0;Be[82]=Be[88]=-1;ze[82]=ze[88]=0;be[73]=be[97]=0;Te[73]=Te[97]=1;Ae[73]=Ae[97]=0;Ce[73]=Ce[97]=0;Pe[73]=Pe[97]=-1;Ie[73]=Ie[97]=0;Re[73]=Re[97]=1;Le[73]=Le[97]=0;Ne[73]=Ne[97]=0;_e[73]=_e[97]=1;xe[73]=xe[97]=0;Ee[73]=Ee[97]=1;be[145]=be[25]=0;Te[145]=Te[25]=-1;Ae[145]=Ae[25]=0;Re[145]=Re[25]=1;Le[145]=Le[25]=0;Ne[145]=Ne[25]=1;ke[145]=ke[25]=0;Ge[145]=Ge[25]=1;qe[145]=qe[25]=1;Se[145]=Se[25]=-1;Me[145]=Me[25]=0;we[145]=we[25]=0;Ce[70]=Ce[100]=0;Pe[70]=Pe[100]=1;Ie[70]=Ie[100]=0;Oe[70]=Oe[100]=-1;De[70]=De[100]=0;Fe[70]=Fe[100]=1;Ue[70]=Ue[100]=0;Be[70]=Be[100]=-1;ze[70]=ze[100]=1;_e[70]=_e[100]=1;xe[70]=xe[100]=0;Ee[70]=Ee[100]=0;Ce[101]=Ce[69]=0;Pe[101]=Pe[69]=1;Ie[101]=Ie[69]=0;_e[101]=_e[69]=1;xe[101]=xe[69]=0;Ee[101]=Ee[69]=0;ke[149]=ke[21]=0;Ge[149]=Ge[21]=1;qe[149]=qe[21]=1;Se[149]=Se[21]=-1;Me[149]=Me[21]=0;we[149]=we[21]=0;Oe[86]=Oe[84]=-1;De[86]=De[84]=0;Fe[86]=Fe[84]=1;Ue[86]=Ue[84]=0;Be[86]=Be[84]=-1;ze[86]=ze[84]=1;be[89]=be[81]=0;Te[89]=Te[81]=-1;Ae[89]=Ae[81]=0;Re[89]=Re[81]=1;Le[89]=Le[81]=0;Ne[89]=Ne[81]=1;be[96]=be[74]=0;Te[96]=Te[74]=1;Ae[96]=Ae[74]=0;Ce[96]=Ce[74]=-1;Pe[96]=Pe[74]=0;Ie[96]=Ie[74]=1;Ue[96]=Ue[74]=1;Be[96]=Be[74]=0;ze[96]=ze[74]=0;_e[96]=_e[74]=1;xe[96]=xe[74]=0;Ee[96]=Ee[74]=1;be[24]=be[146]=0;Te[24]=Te[146]=-1;Ae[24]=Ae[146]=1;Oe[24]=Oe[146]=1;De[24]=De[146]=0;Fe[24]=Fe[146]=1;Re[24]=Re[146]=0;Le[24]=Le[146]=1;Ne[24]=Ne[146]=1;Se[24]=Se[146]=0;Me[24]=Me[146]=-1;we[24]=we[146]=0;Ce[6]=Ce[164]=-1;Pe[6]=Pe[164]=0;Ie[6]=Ie[164]=1;Oe[6]=Oe[164]=-1;De[6]=De[164]=0;Fe[6]=Fe[164]=0;ke[6]=ke[164]=0;Ge[6]=Ge[164]=-1;qe[6]=qe[164]=1;Ue[6]=Ue[164]=1;Be[6]=Be[164]=0;ze[6]=ze[164]=0;Re[129]=Re[41]=0;Le[129]=Le[41]=1;Ne[129]=Ne[41]=1;ke[129]=ke[41]=0;Ge[129]=Ge[41]=1;qe[129]=qe[41]=0;_e[129]=_e[41]=-1;xe[129]=xe[41]=0;Ee[129]=Ee[41]=0;Se[129]=Se[41]=0;Me[129]=Me[41]=-1;we[129]=we[41]=0;Oe[66]=Oe[104]=0;De[66]=De[104]=1;Fe[66]=Fe[104]=0;Re[66]=Re[104]=-1;Le[66]=Le[104]=0;Ne[66]=Ne[104]=1;Ue[66]=Ue[104]=0;Be[66]=Be[104]=-1;ze[66]=ze[104]=0;_e[66]=_e[104]=0;xe[66]=xe[104]=-1;Ee[66]=Ee[104]=1;be[144]=be[26]=-1;Te[144]=Te[26]=0;Ae[144]=Ae[26]=0;ke[144]=ke[26]=1;Ge[144]=Ge[26]=0;qe[144]=qe[26]=1;Ue[144]=Ue[26]=0;Be[144]=Be[26]=1;ze[144]=ze[26]=1;Se[144]=Se[26]=-1;Me[144]=Me[26]=0;we[144]=we[26]=1;Ce[36]=Ce[134]=0;Pe[36]=Pe[134]=1;Ie[36]=Ie[134]=1;Oe[36]=Oe[134]=0;De[36]=De[134]=1;Fe[36]=Fe[134]=0;_e[36]=_e[134]=0;xe[36]=xe[134]=-1;Ee[36]=Ee[134]=1;Se[36]=Se[134]=1;Me[36]=Me[134]=0;we[36]=we[134]=0;be[9]=be[161]=-1;Te[9]=Te[161]=0;Ae[9]=Ae[161]=0;Ce[9]=Ce[161]=0;Pe[9]=Pe[161]=-1;Ie[9]=Ie[161]=0;Re[9]=Re[161]=1;Le[9]=Le[161]=0;Ne[9]=Ne[161]=0;ke[9]=ke[161]=1;Ge[9]=Ge[161]=0;qe[9]=qe[161]=1;be[136]=0;Te[136]=1;Ae[136]=1;Ce[136]=0;Pe[136]=1;Ie[136]=0;Oe[136]=-1;De[136]=0;Fe[136]=1;Re[136]=-1;Le[136]=0;Ne[136]=0;ke[136]=0;Ge[136]=-1;qe[136]=0;Ue[136]=0;Be[136]=-1;ze[136]=1;_e[136]=1;xe[136]=0;Ee[136]=0;Se[136]=1;Me[136]=0;we[136]=1;be[34]=0;Te[34]=-1;Ae[34]=0;Ce[34]=0;Pe[34]=-1;Ie[34]=1;Oe[34]=1;De[34]=0;Fe[34]=0;Re[34]=1;Le[34]=0;Ne[34]=1;ke[34]=0;Ge[34]=1;qe[34]=1;Ue[34]=0;Be[34]=1;ze[34]=0;_e[34]=-1;xe[34]=0;Ee[34]=1;Se[34]=-1;Me[34]=0;we[34]=0;be[35]=0;Te[35]=1;Ae[35]=1;Ce[35]=0;Pe[35]=-1;Ie[35]=1;Oe[35]=1;De[35]=0;Fe[35]=0;Re[35]=-1;Le[35]=0;Ne[35]=0;ke[35]=0;Ge[35]=-1;qe[35]=0;Ue[35]=0;Be[35]=1;ze[35]=0;_e[35]=-1;xe[35]=0;Ee[35]=1;Se[35]=1;Me[35]=0;we[35]=1;be[153]=0;Te[153]=1;Ae[153]=1;Re[153]=-1;Le[153]=0;Ne[153]=0;ke[153]=0;Ge[153]=-1;qe[153]=0;Se[153]=1;Me[153]=0;we[153]=1;Ce[102]=0;Pe[102]=-1;Ie[102]=1;Oe[102]=1;De[102]=0;Fe[102]=0;Ue[102]=0;Be[102]=1;ze[102]=0;_e[102]=-1;xe[102]=0;Ee[102]=1;be[155]=0;Te[155]=-1;Ae[155]=0;Re[155]=1;Le[155]=0;Ne[155]=1;ke[155]=0;Ge[155]=1;qe[155]=1;Se[155]=-1;Me[155]=0;we[155]=0;Ce[103]=0;Pe[103]=1;Ie[103]=0;Oe[103]=-1;De[103]=0;Fe[103]=1;Ue[103]=0;Be[103]=-1;ze[103]=1;_e[103]=1;xe[103]=0;Ee[103]=0;be[152]=0;Te[152]=1;Ae[152]=1;Oe[152]=-1;De[152]=0;Fe[152]=1;Re[152]=-1;Le[152]=0;Ne[152]=0;ke[152]=0;Ge[152]=-1;qe[152]=0;Ue[152]=0;Be[152]=-1;ze[152]=1;Se[152]=1;Me[152]=0;we[152]=1;be[156]=0;Te[156]=-1;Ae[156]=1;Oe[156]=1;De[156]=0;Fe[156]=1;Re[156]=-1;Le[156]=0;Ne[156]=0;ke[156]=0;Ge[156]=-1;qe[156]=0;Ue[156]=0;Be[156]=1;ze[156]=1;Se[156]=-1;Me[156]=0;we[156]=1;be[137]=0;Te[137]=1;Ae[137]=1;Ce[137]=0;Pe[137]=1;Ie[137]=0;Re[137]=-1;Le[137]=0;Ne[137]=0;ke[137]=0;Ge[137]=-1;qe[137]=0;_e[137]=1;xe[137]=0;Ee[137]=0;Se[137]=1;Me[137]=0;we[137]=1;be[139]=0;Te[139]=1;Ae[139]=1;Ce[139]=0;Pe[139]=-1;Ie[139]=0;Re[139]=1;Le[139]=0;Ne[139]=0;ke[139]=0;Ge[139]=1;qe[139]=0;_e[139]=-1;xe[139]=0;Ee[139]=0;Se[139]=1;Me[139]=0;we[139]=1;be[98]=0;Te[98]=-1;Ae[98]=0;Ce[98]=0;Pe[98]=-1;Ie[98]=1;Oe[98]=1;De[98]=0;Fe[98]=0;Re[98]=1;Le[98]=0;Ne[98]=1;Ue[98]=0;Be[98]=1;ze[98]=0;_e[98]=-1;xe[98]=0;Ee[98]=1;be[99]=0;Te[99]=1;Ae[99]=0;Ce[99]=0;Pe[99]=-1;Ie[99]=1;Oe[99]=1;De[99]=0;Fe[99]=0;Re[99]=-1;Le[99]=0;Ne[99]=1;Ue[99]=0;Be[99]=-1;ze[99]=0;_e[99]=1;xe[99]=0;Ee[99]=1;Ce[38]=0;Pe[38]=-1;Ie[38]=1;Oe[38]=1;De[38]=0;Fe[38]=0;ke[38]=0;Ge[38]=1;qe[38]=1;Ue[38]=0;Be[38]=1;ze[38]=0;_e[38]=-1;xe[38]=0;Ee[38]=1;Se[38]=-1;Me[38]=0;we[38]=0;Ce[39]=0;Pe[39]=1;Ie[39]=1;Oe[39]=-1;De[39]=0;Fe[39]=0;ke[39]=0;Ge[39]=-1;qe[39]=1;Ue[39]=0;Be[39]=1;ze[39]=0;_e[39]=-1;xe[39]=0;Ee[39]=1;Se[39]=1;Me[39]=0;we[39]=0;var Bg=function(r){return[[r.bottomleft,0],[0,0],[0,r.leftbottom]]},zg=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0]]},kg=function(r){return[[r.topright,1],[1,1],[1,r.righttop]]},Gg=function(r){return[[0,r.lefttop],[0,1],[r.topleft,1]]},qg=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop]]},Vg=function(r){return[[r.bottomright,0],[r.bottomleft,0],[1,r.righttop],[1,r.rightbottom]]},Hg=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.topleft,1],[r.topright,1]]},Wg=function(r){return[[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},Pz=function(r){return[[0,0],[0,r.leftbottom],[1,r.rightbottom],[1,0]]},Iz=function(r){return[[1,0],[r.bottomright,0],[r.topright,1],[1,1]]},Rz=function(r){return[[1,1],[1,r.righttop],[0,r.lefttop],[0,1]]},Lz=function(r){return[[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},Nz=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.leftbottom],[0,r.lefttop]]},Oz=function(r){return[[r.topleft,1],[r.topright,1],[r.bottomright,0],[r.bottomleft,0]]},Dz=function(){return[[0,0],[0,1],[1,1],[1,0]]},Fz=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,1],[r.topleft,1]]},Uz=function(r){return[[r.topright,1],[1,1],[1,0],[0,0],[0,r.leftbottom]]},Bz=function(r){return[[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[1,1]]},zz=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,1]]},kz=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.lefttop],[0,1],[r.topleft,1]]},Gz=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[r.topright,1]]},qz=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop]]},Vz=function(r){return[[r.topright,1],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1]]},Hz=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},Wz=function(r){return[[1,1],[1,r.righttop],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},Xz=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[r.topleft,1],[r.topright,1]]},Yz=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom]]},$z=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},Zz=function(r){return[[1,1],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},Jz=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1]]},Kz=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},jz=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},Qz=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},tk=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},ek=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},nk=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},rk=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},ik=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},ok=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},sk=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},We=[],Xe=[],Ye=[],$e=[],Ze=[],Je=[],Ke=[],je=[];$e[1]=Ze[1]=18;$e[169]=Ze[169]=18;Ye[4]=Xe[4]=12;Ye[166]=Xe[166]=12;We[16]=je[16]=4;We[154]=je[154]=4;Je[64]=Ke[64]=22;Je[106]=Ke[106]=22;Ye[2]=Je[2]=17;$e[2]=Ze[2]=18;Ye[168]=Je[168]=17;$e[168]=Ze[168]=18;We[8]=$e[8]=9;Xe[8]=Ye[8]=12;We[162]=$e[162]=9;Xe[162]=Ye[162]=12;We[32]=je[32]=4;Xe[32]=Ke[32]=1;We[138]=je[138]=4;Xe[138]=Ke[138]=1;Ze[128]=je[128]=21;Je[128]=Ke[128]=22;Ze[42]=je[42]=21;Je[42]=Ke[42]=22;Xe[5]=Ze[5]=14;Xe[165]=Ze[165]=14;Ye[20]=je[20]=6;Ye[150]=je[150]=6;We[80]=Je[80]=11;We[90]=Je[90]=11;$e[65]=Ke[65]=3;$e[105]=Ke[105]=3;We[160]=Je[160]=11;Xe[160]=Ze[160]=14;We[10]=Je[10]=11;Xe[10]=Ze[10]=14;Ye[130]=je[130]=6;$e[130]=Ke[130]=3;Ye[40]=je[40]=6;$e[40]=Ke[40]=3;Xe[101]=Ke[101]=1;Xe[69]=Ke[69]=1;Ze[149]=je[149]=21;Ze[21]=je[21]=21;Ye[86]=Je[86]=17;Ye[84]=Je[84]=17;We[89]=$e[89]=9;We[81]=$e[81]=9;We[96]=Ke[96]=0;Xe[96]=Je[96]=15;We[74]=Ke[74]=0;Xe[74]=Je[74]=15;We[24]=Ye[24]=8;$e[24]=je[24]=7;We[146]=Ye[146]=8;$e[146]=je[146]=7;Xe[6]=Je[6]=15;Ye[6]=Ze[6]=16;Xe[164]=Je[164]=15;Ye[164]=Ze[164]=16;$e[129]=je[129]=7;Ze[129]=Ke[129]=20;$e[41]=je[41]=7;Ze[41]=Ke[41]=20;Ye[66]=Ke[66]=2;$e[66]=Je[66]=19;Ye[104]=Ke[104]=2;$e[104]=Je[104]=19;We[144]=Ze[144]=10;Je[144]=je[144]=23;We[26]=Ze[26]=10;Je[26]=je[26]=23;Xe[36]=je[36]=5;Ye[36]=Ke[36]=2;Xe[134]=je[134]=5;Ye[134]=Ke[134]=2;We[9]=Ze[9]=10;Xe[9]=$e[9]=13;We[161]=Ze[161]=10;Xe[161]=$e[161]=13;Xe[37]=je[37]=5;Ze[37]=Ke[37]=20;Xe[133]=je[133]=5;Ze[133]=Ke[133]=20;Ye[148]=Ze[148]=16;Je[148]=je[148]=23;Ye[22]=Ze[22]=16;Je[22]=je[22]=23;We[82]=Ye[82]=8;$e[82]=Je[82]=19;We[88]=Ye[88]=8;$e[88]=Je[88]=19;We[73]=Ke[73]=0;Xe[73]=$e[73]=13;We[97]=Ke[97]=0;Xe[97]=$e[97]=13;We[145]=$e[145]=9;Ze[145]=je[145]=21;We[25]=$e[25]=9;Ze[25]=je[25]=21;Xe[70]=Ke[70]=1;Ye[70]=Je[70]=17;Xe[100]=Ke[100]=1;Ye[100]=Je[100]=17;We[34]=$e[34]=9;Xe[34]=Ye[34]=12;Ze[34]=je[34]=21;Je[34]=Ke[34]=22;We[136]=je[136]=4;Xe[136]=Ke[136]=1;Ye[136]=Je[136]=17;$e[136]=Ze[136]=18;We[35]=je[35]=4;Xe[35]=Ye[35]=12;$e[35]=Ze[35]=18;Je[35]=Ke[35]=22;We[153]=je[153]=4;$e[153]=Ze[153]=18;Xe[102]=Ye[102]=12;Je[102]=Ke[102]=22;We[155]=$e[155]=9;Ze[155]=je[155]=23;Xe[103]=Ke[103]=1;Ye[103]=Je[103]=17;We[152]=je[152]=4;Ye[152]=Je[152]=17;$e[152]=Ze[152]=18;We[156]=Ye[156]=8;$e[156]=Ze[156]=18;Je[156]=je[156]=23;We[137]=je[137]=4;Xe[137]=Ke[137]=1;$e[137]=Ze[137]=18;We[139]=je[139]=4;Xe[139]=$e[139]=13;Ze[139]=Ke[139]=20;We[98]=$e[98]=9;Xe[98]=Ye[98]=12;Je[98]=Ke[98]=22;We[99]=Ke[99]=0;Xe[99]=Ye[99]=12;$e[99]=Je[99]=19;Xe[38]=Ye[38]=12;Ze[38]=je[38]=21;Je[38]=Ke[38]=22;Xe[39]=je[39]=5;Ye[39]=Ze[39]=16;Je[39]=Ke[39]=22;var Ot=[];Ot[1]=Ot[169]=Bg;Ot[4]=Ot[166]=zg;Ot[16]=Ot[154]=kg;Ot[64]=Ot[106]=Gg;Ot[168]=Ot[2]=qg;Ot[162]=Ot[8]=Vg;Ot[138]=Ot[32]=Hg;Ot[42]=Ot[128]=Wg;Ot[5]=Ot[165]=Pz;Ot[20]=Ot[150]=Iz;Ot[80]=Ot[90]=Rz;Ot[65]=Ot[105]=Lz;Ot[160]=Ot[10]=Nz;Ot[130]=Ot[40]=Oz;Ot[85]=Dz;Ot[101]=Ot[69]=Fz;Ot[149]=Ot[21]=Uz;Ot[86]=Ot[84]=Bz;Ot[89]=Ot[81]=zz;Ot[96]=Ot[74]=kz;Ot[24]=Ot[146]=Gz;Ot[6]=Ot[164]=qz;Ot[129]=Ot[41]=Vz;Ot[66]=Ot[104]=Hz;Ot[144]=Ot[26]=Wz;Ot[36]=Ot[134]=Xz;Ot[9]=Ot[161]=Yz;Ot[37]=Ot[133]=$z;Ot[148]=Ot[22]=Zz;Ot[82]=Ot[88]=Jz;Ot[73]=Ot[97]=Kz;Ot[145]=Ot[25]=jz;Ot[70]=Ot[100]=Qz;Ot[34]=function(r){return[Wg(r),Vg(r)]};Ot[35]=tk;Ot[136]=function(r){return[Hg(r),qg(r)]};Ot[153]=function(r){return[kg(r),Bg(r)]};Ot[102]=function(r){return[zg(r),Gg(r)]};Ot[155]=ek;Ot[103]=nk;Ot[152]=function(r){return[kg(r),qg(r)]};Ot[156]=rk;Ot[137]=function(r){return[Hg(r),Bg(r)]};Ot[139]=ik;Ot[98]=function(r){return[Vg(r),Gg(r)]};Ot[99]=ok;Ot[38]=function(r){return[zg(r),Wg(r)]};Ot[39]=sk;function uk(r){return(r>0)-(r<0)||+r}function Uu(r,t,e){var o=t[0]-r[0],a=t[1]-r[1],l=e[0]-t[0],h=e[1]-t[1];return uk(o*h-l*a)}function Nw(r,t){var e=r.geometry.coordinates[0].map(function(h){return h[0]}),o=r.geometry.coordinates[0].map(function(h){return h[1]}),a=t.geometry.coordinates[0].map(function(h){return h[0]}),l=t.geometry.coordinates[0].map(function(h){return h[1]});return Math.max.apply(null,e)===Math.max.apply(null,a)&&Math.max.apply(null,o)===Math.max.apply(null,l)&&Math.min.apply(null,e)===Math.min.apply(null,a)&&Math.min.apply(null,o)===Math.min.apply(null,l)}function Xg(r,t){return t.geometry.coordinates[0].every(function(e){return Er(wn(e),r)})}function Ow(r,t){return r[0]===t[0]&&r[1]===t[1]}var lk=function(){function r(t){this.id=r.buildId(t),this.coordinates=t,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}return r.buildId=function(t){return t.join(",")},r.prototype.removeInnerEdge=function(t){this.innerEdges=this.innerEdges.filter(function(e){return e.from.id!==t.from.id})},r.prototype.removeOuterEdge=function(t){this.outerEdges=this.outerEdges.filter(function(e){return e.to.id!==t.to.id})},r.prototype.addOuterEdge=function(t){this.outerEdges.push(t),this.outerEdgesSorted=!1},r.prototype.sortOuterEdges=function(){var t=this;this.outerEdgesSorted||(this.outerEdges.sort(function(e,o){var a=e.to,l=o.to;if(a.coordinates[0]-t.coordinates[0]>=0&&l.coordinates[0]-t.coordinates[0]<0)return 1;if(a.coordinates[0]-t.coordinates[0]<0&&l.coordinates[0]-t.coordinates[0]>=0)return-1;if(a.coordinates[0]-t.coordinates[0]===0&&l.coordinates[0]-t.coordinates[0]===0)return a.coordinates[1]-t.coordinates[1]>=0||l.coordinates[1]-t.coordinates[1]>=0?a.coordinates[1]-l.coordinates[1]:l.coordinates[1]-a.coordinates[1];var h=Uu(t.coordinates,a.coordinates,l.coordinates);if(h<0)return 1;if(h>0)return-1;var f=Math.pow(a.coordinates[0]-t.coordinates[0],2)+Math.pow(a.coordinates[1]-t.coordinates[1],2),p=Math.pow(l.coordinates[0]-t.coordinates[0],2)+Math.pow(l.coordinates[1]-t.coordinates[1],2);return f-p}),this.outerEdgesSorted=!0)},r.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges},r.prototype.getOuterEdge=function(t){return this.sortOuterEdges(),this.outerEdges[t]},r.prototype.addInnerEdge=function(t){this.innerEdges.push(t)},r}(),Yg=lk;var ck=function(){function r(t,e){this.from=t,this.to=e,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}return r.prototype.getSymetric=function(){return this.symetric||(this.symetric=new r(this.to,this.from),this.symetric.symetric=this),this.symetric},r.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)},r.prototype.isEqual=function(t){return this.from.id===t.from.id&&this.to.id===t.to.id},r.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }"},r.prototype.toLineString=function(){return xr([this.from.coordinates,this.to.coordinates])},r.prototype.compareTo=function(t){return Uu(t.from.coordinates,t.to.coordinates,this.to.coordinates)},r}(),Dw=ck;var fk=function(){function r(){this.edges=[],this.polygon=void 0,this.envelope=void 0}return r.prototype.push=function(t){this.edges.push(t),this.polygon=this.envelope=void 0},r.prototype.get=function(t){return this.edges[t]},Object.defineProperty(r.prototype,"length",{get:function(){return this.edges.length},enumerable:!0,configurable:!0}),r.prototype.forEach=function(t){this.edges.forEach(t)},r.prototype.map=function(t){return this.edges.map(t)},r.prototype.some=function(t){return this.edges.some(t)},r.prototype.isValid=function(){return!0},r.prototype.isHole=function(){var t=this,e=this.edges.reduce(function(h,f,p){return f.from.coordinates[1]>t.edges[h].from.coordinates[1]&&(h=p),h},0),o=(e===0?this.length:e)-1,a=(e+1)%this.length,l=Uu(this.edges[o].from.coordinates,this.edges[e].from.coordinates,this.edges[a].from.coordinates);return l===0?this.edges[o].from.coordinates[0]>this.edges[a].from.coordinates[0]:l>0},r.prototype.toMultiPoint=function(){return Im(this.edges.map(function(t){return t.from.coordinates}))},r.prototype.toPolygon=function(){if(this.polygon)return this.polygon;var t=this.edges.map(function(e){return e.from.coordinates});return t.push(this.edges[0].from.coordinates),this.polygon=On([t])},r.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=Zm(this.toPolygon())},r.findEdgeRingContaining=function(t,e){var o=t.getEnvelope(),a,l;return e.forEach(function(h){var f=h.getEnvelope();if(l&&(a=l.getEnvelope()),!Nw(f,o)&&Xg(f,o)){for(var p=t.map(function(T){return T.from.coordinates}),d=void 0,g=function(T){h.some(function(P){return Ow(T,P.from.coordinates)})||(d=T)},x=0,_=p;x<_.length;x++){var S=_[x];g(S)}d&&h.inside(wn(d))&&(!l||Xg(a,f))&&(l=h)}}),l},r.prototype.inside=function(t){return Er(t,this.toPolygon())},r}(),$g=fk;function hk(r){if(!r)throw new Error("No geojson passed");if(r.type!=="FeatureCollection"&&r.type!=="GeometryCollection"&&r.type!=="MultiLineString"&&r.type!=="LineString"&&r.type!=="Feature")throw new Error("Invalid input type '"+r.type+"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")}var dY=function(){function r(){this.edges=[],this.nodes={}}return r.fromGeoJson=function(t){hk(t);var e=new r;return Pi(t,function(o){Lm(o,"LineString","Graph::fromGeoJson"),GE(o,function(a,l){if(a){var h=e.getNode(a),f=e.getNode(l);e.addEdge(h,f)}return l})}),e},r.prototype.getNode=function(t){var e=Yg.buildId(t),o=this.nodes[e];return o||(o=this.nodes[e]=new Yg(t)),o},r.prototype.addEdge=function(t,e){var o=new Dw(t,e),a=o.getSymetric();this.edges.push(o),this.edges.push(a)},r.prototype.deleteDangles=function(){var t=this;Object.keys(this.nodes).map(function(e){return t.nodes[e]}).forEach(function(e){return t._removeIfDangle(e)})},r.prototype._removeIfDangle=function(t){var e=this;if(t.innerEdges.length<=1){var o=t.getOuterEdges().map(function(a){return a.to});this.removeNode(t),o.forEach(function(a){return e._removeIfDangle(a)})}},r.prototype.deleteCutEdges=function(){var t=this;this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach(function(e){e.label===e.symetric.label&&(t.removeEdge(e.symetric),t.removeEdge(e))})},r.prototype._computeNextCWEdges=function(t){var e=this;typeof t=="undefined"?Object.keys(this.nodes).forEach(function(o){return e._computeNextCWEdges(e.nodes[o])}):t.getOuterEdges().forEach(function(o,a){t.getOuterEdge((a===0?t.getOuterEdges().length:a)-1).symetric.next=o})},r.prototype._computeNextCCWEdges=function(t,e){for(var o=t.getOuterEdges(),a,l,h=o.length-1;h>=0;--h){var f=o[h],p=f.symetric,d=void 0,g=void 0;f.label===e&&(d=f),p.label===e&&(g=p),!(!d||!g)&&(g&&(l=g),d&&(l&&(l.next=d,l=void 0),a||(a=d)))}l&&(l.next=a)},r.prototype._findLabeledEdgeRings=function(){var t=[],e=0;return this.edges.forEach(function(o){if(!(o.label>=0)){t.push(o);var a=o;do a.label=e,a=a.next;while(!o.isEqual(a));e++}}),t},r.prototype.getEdgeRings=function(){var t=this;this._computeNextCWEdges(),this.edges.forEach(function(o){o.label=void 0}),this._findLabeledEdgeRings().forEach(function(o){t._findIntersectionNodes(o).forEach(function(a){t._computeNextCCWEdges(a,o.label)})});var e=[];return this.edges.forEach(function(o){o.ring||e.push(t._findEdgeRing(o))}),e},r.prototype._findIntersectionNodes=function(t){var e=[],o=t,a=function(){var l=0;o.from.getOuterEdges().forEach(function(h){h.label===t.label&&++l}),l>1&&e.push(o.from),o=o.next};do a();while(!t.isEqual(o));return e},r.prototype._findEdgeRing=function(t){var e=t,o=new $g;do o.push(e),e.ring=o,e=e.next;while(!t.isEqual(e));return o},r.prototype.removeNode=function(t){var e=this;t.getOuterEdges().forEach(function(o){return e.removeEdge(o)}),t.innerEdges.forEach(function(o){return e.removeEdge(o)}),delete this.nodes[t.id]},r.prototype.removeEdge=function(t){this.edges=this.edges.filter(function(e){return!e.isEqual(t)}),t.deleteEdge()},r}();var gk=hn(Zg(),1);var yk=hn(Zg(),1);var _k=hn(Hw(),1);var Tk=hn(tb(),1);function nb(r){for(var t=r,e=[];t.parent;)e.unshift(t),t=t.parent;return e}function Ck(){return new rb(function(r){return r.f})}var Qg={search:function(r,t,e,o){r.cleanDirty(),o=o||{};var a=o.heuristic||Qg.heuristics.manhattan,l=o.closest||!1,h=Ck(),f=t;for(t.h=a(t,e),h.push(t);h.size()>0;){var p=h.pop();if(p===e)return nb(p);p.closed=!0;for(var d=r.neighbors(p),g=0,x=d.length;g<x;++g){var _=d[g];if(!(_.closed||_.isWall())){var S=p.g+_.getCost(p),T=_.visited;(!T||S<_.g)&&(_.visited=!0,_.parent=p,_.h=_.h||a(_,e),_.g=S,_.f=_.g+_.h,r.markDirty(_),l&&(_.h<f.h||_.h===f.h&&_.g<f.g)&&(f=_),T?h.rescoreElement(_):h.push(_))}}}return l?nb(f):[]},heuristics:{manhattan:function(r,t){var e=Math.abs(t.x-r.x),o=Math.abs(t.y-r.y);return e+o},diagonal:function(r,t){var e=1,o=Math.sqrt(2),a=Math.abs(t.x-r.x),l=Math.abs(t.y-r.y);return e*(a+l)+(o-2*e)*Math.min(a,l)}},cleanNode:function(r){r.f=0,r.g=0,r.h=0,r.visited=!1,r.closed=!1,r.parent=null}};function $l(r,t){t=t||{},this.nodes=[],this.diagonal=!!t.diagonal,this.grid=[];for(var e=0;e<r.length;e++){this.grid[e]=[];for(var o=0,a=r[e];o<a.length;o++){var l=new wh(e,o,a[o]);this.grid[e][o]=l,this.nodes.push(l)}}this.init()}$l.prototype.init=function(){this.dirtyNodes=[];for(var r=0;r<this.nodes.length;r++)Qg.cleanNode(this.nodes[r])};$l.prototype.cleanDirty=function(){for(var r=0;r<this.dirtyNodes.length;r++)Qg.cleanNode(this.dirtyNodes[r]);this.dirtyNodes=[]};$l.prototype.markDirty=function(r){this.dirtyNodes.push(r)};$l.prototype.neighbors=function(r){var t=[],e=r.x,o=r.y,a=this.grid;return a[e-1]&&a[e-1][o]&&t.push(a[e-1][o]),a[e+1]&&a[e+1][o]&&t.push(a[e+1][o]),a[e]&&a[e][o-1]&&t.push(a[e][o-1]),a[e]&&a[e][o+1]&&t.push(a[e][o+1]),this.diagonal&&(a[e-1]&&a[e-1][o-1]&&t.push(a[e-1][o-1]),a[e+1]&&a[e+1][o-1]&&t.push(a[e+1][o-1]),a[e-1]&&a[e-1][o+1]&&t.push(a[e-1][o+1]),a[e+1]&&a[e+1][o+1]&&t.push(a[e+1][o+1])),t};$l.prototype.toString=function(){for(var r=[],t=this.grid,e,o,a,l,h=0,f=t.length;h<f;h++){for(e=[],o=t[h],a=0,l=o.length;a<l;a++)e.push(o[a].weight);r.push(e.join(" "))}return r.join(\`
7743
7743
  \`)};function wh(r,t,e){this.x=r,this.y=t,this.weight=e}wh.prototype.toString=function(){return"["+this.x+" "+this.y+"]"};wh.prototype.getCost=function(r){return r&&r.x!==this.x&&r.y!==this.y?this.weight*1.41421:this.weight};wh.prototype.isWall=function(){return this.weight===0};function rb(r){this.content=[],this.scoreFunction=r}rb.prototype={push:function(r){this.content.push(r),this.sinkDown(this.content.length-1)},pop:function(){var r=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),r},remove:function(r){var t=this.content.indexOf(r),e=this.content.pop();t!==this.content.length-1&&(this.content[t]=e,this.scoreFunction(e)<this.scoreFunction(r)?this.sinkDown(t):this.bubbleUp(t))},size:function(){return this.content.length},rescoreElement:function(r){this.sinkDown(this.content.indexOf(r))},sinkDown:function(r){for(var t=this.content[r];r>0;){var e=(r+1>>1)-1,o=this.content[e];if(this.scoreFunction(t)<this.scoreFunction(o))this.content[e]=t,this.content[r]=o,r=e;else break}},bubbleUp:function(r){for(var t=this.content.length,e=this.content[r],o=this.scoreFunction(e);;){var a=r+1<<1,l=a-1,h=null,f;if(l<t){var p=this.content[l];f=this.scoreFunction(p),f<o&&(h=l)}if(a<t){var d=this.content[a],g=this.scoreFunction(d);g<(h===null?o:f)&&(h=a)}if(h!==null)this.content[r]=this.content[h],this.content[h]=e,r=h;else break}}};function t0(){this._=null}function zu(r){r.U=r.C=r.L=r.R=r.P=r.N=null}t0.prototype={constructor:t0,insert:function(r,t){var e,o,a;if(r){if(t.P=r,t.N=r.N,r.N&&(r.N.P=t),r.N=t,r.R){for(r=r.R;r.L;)r=r.L;r.L=t}else r.R=t;e=r}else this._?(r=ib(this._),t.P=null,t.N=r,r.P=r.L=t,e=r):(t.P=t.N=null,this._=t,e=null);for(t.L=t.R=null,t.U=e,t.C=!0,r=t;e&&e.C;)o=e.U,e===o.L?(a=o.R,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.R&&(Zl(this,e),r=e,e=r.U),e.C=!1,o.C=!0,Jl(this,o))):(a=o.L,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.L&&(Jl(this,e),r=e,e=r.U),e.C=!1,o.C=!0,Zl(this,o))),e=r.U;this._.C=!1},remove:function(r){r.N&&(r.N.P=r.P),r.P&&(r.P.N=r.N),r.N=r.P=null;var t=r.U,e,o=r.L,a=r.R,l,h;if(o?a?l=ib(a):l=o:l=a,t?t.L===r?t.L=l:t.R=l:this._=l,o&&a?(h=l.C,l.C=r.C,l.L=o,o.U=l,l!==a?(t=l.U,l.U=r.U,r=l.R,t.L=r,l.R=a,a.U=l):(l.U=t,t=l,r=l.R)):(h=r.C,r=l),r&&(r.U=t),!h){if(r&&r.C){r.C=!1;return}do{if(r===this._)break;if(r===t.L){if(e=t.R,e.C&&(e.C=!1,t.C=!0,Zl(this,t),e=t.R),e.L&&e.L.C||e.R&&e.R.C){(!e.R||!e.R.C)&&(e.L.C=!1,e.C=!0,Jl(this,e),e=t.R),e.C=t.C,t.C=e.R.C=!1,Zl(this,t),r=this._;break}}else if(e=t.L,e.C&&(e.C=!1,t.C=!0,Jl(this,t),e=t.L),e.L&&e.L.C||e.R&&e.R.C){(!e.L||!e.L.C)&&(e.R.C=!1,e.C=!0,Zl(this,e),e=t.L),e.C=t.C,t.C=e.L.C=!1,Jl(this,t),r=this._;break}e.C=!0,r=t,t=t.U}while(!r.C);r&&(r.C=!1)}}};function Zl(r,t){var e=t,o=t.R,a=e.U;a?a.L===e?a.L=o:a.R=o:r._=o,o.U=a,e.U=o,e.R=o.L,e.R&&(e.R.U=e),o.L=e}function Jl(r,t){var e=t,o=t.L,a=e.U;a?a.L===e?a.L=o:a.R=o:r._=o,o.U=a,e.U=o,e.L=o.R,e.L&&(e.L.U=e),o.R=e}function ib(r){for(;r.L;)r=r.L;return r}var e0=t0;function ku(r,t,e,o){var a=[null,null],l=Mr.push(a)-1;return a.left=r,a.right=t,e&&Kl(a,r,t,e),o&&Kl(a,t,r,o),ui[r.index].halfedges.push(l),ui[t.index].halfedges.push(l),a}function Gu(r,t,e){var o=[t,e];return o.left=r,o}function Kl(r,t,e,o){!r[0]&&!r[1]?(r[0]=o,r.left=t,r.right=e):r.left===e?r[1]=o:r[0]=o}function Pk(r,t,e,o,a){var l=r[0],h=r[1],f=l[0],p=l[1],d=h[0],g=h[1],x=0,_=1,S=d-f,T=g-p,P;if(P=t-f,!(!S&&P>0)){if(P/=S,S<0){if(P<x)return;P<_&&(_=P)}else if(S>0){if(P>_)return;P>x&&(x=P)}if(P=o-f,!(!S&&P<0)){if(P/=S,S<0){if(P>_)return;P>x&&(x=P)}else if(S>0){if(P<x)return;P<_&&(_=P)}if(P=e-p,!(!T&&P>0)){if(P/=T,T<0){if(P<x)return;P<_&&(_=P)}else if(T>0){if(P>_)return;P>x&&(x=P)}if(P=a-p,!(!T&&P<0)){if(P/=T,T<0){if(P>_)return;P>x&&(x=P)}else if(T>0){if(P<x)return;P<_&&(_=P)}return!(x>0)&&!(_<1)||(x>0&&(r[0]=[f+x*S,p+x*T]),_<1&&(r[1]=[f+_*S,p+_*T])),!0}}}}}function Ik(r,t,e,o,a){var l=r[1];if(l)return!0;var h=r[0],f=r.left,p=r.right,d=f[0],g=f[1],x=p[0],_=p[1],S=(d+x)/2,T=(g+_)/2,P,v;if(_===g){if(S<t||S>=o)return;if(d>x){if(!h)h=[S,e];else if(h[1]>=a)return;l=[S,a]}else{if(!h)h=[S,a];else if(h[1]<e)return;l=[S,e]}}else if(P=(d-x)/(_-g),v=T-P*S,P<-1||P>1)if(d>x){if(!h)h=[(e-v)/P,e];else if(h[1]>=a)return;l=[(a-v)/P,a]}else{if(!h)h=[(a-v)/P,a];else if(h[1]<e)return;l=[(e-v)/P,e]}else if(g<_){if(!h)h=[t,P*t+v];else if(h[0]>=o)return;l=[o,P*o+v]}else{if(!h)h=[o,P*o+v];else if(h[0]<t)return;l=[t,P*t+v]}return r[0]=h,r[1]=l,!0}function ob(r,t,e,o){for(var a=Mr.length,l;a--;)(!Ik(l=Mr[a],r,t,e,o)||!Pk(l,r,t,e,o)||!(Math.abs(l[0][0]-l[1][0])>En||Math.abs(l[0][1]-l[1][1])>En))&&delete Mr[a]}function sb(r){return ui[r.index]={site:r,halfedges:[]}}function Rk(r,t){var e=r.site,o=t.left,a=t.right;return e===a&&(a=o,o=e),a?Math.atan2(a[1]-o[1],a[0]-o[0]):(e===o?(o=t[1],a=t[0]):(o=t[0],a=t[1]),Math.atan2(o[0]-a[0],a[1]-o[1]))}function n0(r,t){return t[+(t.left!==r.site)]}function Lk(r,t){return t[+(t.left===r.site)]}function ab(){for(var r=0,t=ui.length,e,o,a,l;r<t;++r)if((e=ui[r])&&(l=(o=e.halfedges).length)){var h=new Array(l),f=new Array(l);for(a=0;a<l;++a)h[a]=a,f[a]=Rk(e,Mr[o[a]]);for(h.sort(function(p,d){return f[d]-f[p]}),a=0;a<l;++a)f[a]=o[h[a]];for(a=0;a<l;++a)o[a]=f[a]}}function ub(r,t,e,o){var a=ui.length,l,h,f,p,d,g,x,_,S,T,P,v,y=!0;for(l=0;l<a;++l)if(h=ui[l]){for(f=h.site,d=h.halfedges,p=d.length;p--;)Mr[d[p]]||d.splice(p,1);for(p=0,g=d.length;p<g;)T=Lk(h,Mr[d[p]]),P=T[0],v=T[1],x=n0(h,Mr[d[++p%g]]),_=x[0],S=x[1],(Math.abs(P-_)>En||Math.abs(v-S)>En)&&(d.splice(p,0,Mr.push(Gu(f,T,Math.abs(P-r)<En&&o-v>En?[r,Math.abs(_-r)<En?S:o]:Math.abs(v-o)<En&&e-P>En?[Math.abs(S-o)<En?_:e,o]:Math.abs(P-e)<En&&v-t>En?[e,Math.abs(_-e)<En?S:t]:Math.abs(v-t)<En&&P-r>En?[Math.abs(S-t)<En?_:r,t]:null))-1),++g);g&&(y=!1)}if(y){var C,M,D,B=1/0;for(l=0,y=null;l<a;++l)(h=ui[l])&&(f=h.site,C=f[0]-r,M=f[1]-t,D=C*C+M*M,D<B&&(B=D,y=h));if(y){var z=[r,t],U=[r,o],R=[e,o],rt=[e,t];y.halfedges.push(Mr.push(Gu(f=y.site,z,U))-1,Mr.push(Gu(f,U,R))-1,Mr.push(Gu(f,R,rt))-1,Mr.push(Gu(f,rt,z))-1)}}for(l=0;l<a;++l)(h=ui[l])&&(h.halfedges.length||delete ui[l])}var lb=[],bh;function Nk(){zu(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ea(r){var t=r.P,e=r.N;if(!(!t||!e)){var o=t.site,a=r.site,l=e.site;if(o!==l){var h=a[0],f=a[1],p=o[0]-h,d=o[1]-f,g=l[0]-h,x=l[1]-f,_=2*(p*x-d*g);if(!(_>=-cb)){var S=p*p+d*d,T=g*g+x*x,P=(x*S-d*T)/_,v=(p*T-g*S)/_,y=lb.pop()||new Nk;y.arc=r,y.site=a,y.x=P+h,y.y=(y.cy=v+f)+Math.sqrt(P*P+v*v),r.circle=y;for(var C=null,M=qu._;M;)if(y.y<M.y||y.y===M.y&&y.x<=M.x)if(M.L)M=M.L;else{C=M.P;break}else if(M.R)M=M.R;else{C=M;break}qu.insert(C,y),C||(bh=y)}}}}function Sa(r){var t=r.circle;t&&(t.P||(bh=t.N),qu.remove(t),lb.push(t),zu(t),r.circle=null)}var hb=[];function Ok(){zu(this),this.edge=this.site=this.circle=null}function fb(r){var t=hb.pop()||new Ok;return t.site=r,t}function r0(r){Sa(r),Ma.remove(r),hb.push(r),zu(r)}function pb(r){var t=r.circle,e=t.x,o=t.cy,a=[e,o],l=r.P,h=r.N,f=[r];r0(r);for(var p=l;p.circle&&Math.abs(e-p.circle.x)<En&&Math.abs(o-p.circle.cy)<En;)l=p.P,f.unshift(p),r0(p),p=l;f.unshift(p),Sa(p);for(var d=h;d.circle&&Math.abs(e-d.circle.x)<En&&Math.abs(o-d.circle.cy)<En;)h=d.N,f.push(d),r0(d),d=h;f.push(d),Sa(d);var g=f.length,x;for(x=1;x<g;++x)d=f[x],p=f[x-1],Kl(d.edge,p.site,d.site,a);p=f[0],d=f[g-1],d.edge=ku(p.site,d.site,null,a),Ea(p),Ea(d)}function db(r){for(var t=r[0],e=r[1],o,a,l,h,f=Ma._;f;)if(l=mb(f,e)-t,l>En)f=f.L;else if(h=t-Dk(f,e),h>En){if(!f.R){o=f;break}f=f.R}else{l>-En?(o=f.P,a=f):h>-En?(o=f,a=f.N):o=a=f;break}sb(r);var p=fb(r);if(Ma.insert(o,p),!(!o&&!a)){if(o===a){Sa(o),a=fb(o.site),Ma.insert(p,a),p.edge=a.edge=ku(o.site,p.site),Ea(o),Ea(a);return}if(!a){p.edge=ku(o.site,p.site);return}Sa(o),Sa(a);var d=o.site,g=d[0],x=d[1],_=r[0]-g,S=r[1]-x,T=a.site,P=T[0]-g,v=T[1]-x,y=2*(_*v-S*P),C=_*_+S*S,M=P*P+v*v,D=[(v*C-S*M)/y+g,(_*M-P*C)/y+x];Kl(a.edge,d,T,D),p.edge=ku(d,r,null,D),a.edge=ku(r,T,null,D),Ea(o),Ea(a)}}function mb(r,t){var e=r.site,o=e[0],a=e[1],l=a-t;if(!l)return o;var h=r.P;if(!h)return-1/0;e=h.site;var f=e[0],p=e[1],d=p-t;if(!d)return f;var g=f-o,x=1/l-1/d,_=g/d;return x?(-_+Math.sqrt(_*_-2*x*(g*g/(-2*d)-p+d/2+a-l/2)))/x+o:(o+f)/2}function Dk(r,t){var e=r.N;if(e)return mb(e,t);var o=r.site;return o[1]===t?o[0]:1/0}var En=1e-6,cb=1e-12,Ma,ui,qu,Mr;function Fk(r,t,e){return(r[0]-e[0])*(t[1]-r[1])-(r[0]-t[0])*(e[1]-r[1])}function Uk(r,t){return t[1]-r[1]||t[0]-r[0]}function Th(r,t){var e=r.sort(Uk).pop(),o,a,l;for(Mr=[],ui=new Array(r.length),Ma=new e0,qu=new e0;;)if(l=bh,e&&(!l||e[1]<l.y||e[1]===l.y&&e[0]<l.x))(e[0]!==o||e[1]!==a)&&(db(e),o=e[0],a=e[1]),e=r.pop();else if(l)pb(l.arc);else break;if(ab(),t){var h=+t[0][0],f=+t[0][1],p=+t[1][0],d=+t[1][1];ob(h,f,p,d),ub(h,f,p,d)}this.edges=Mr,this.cells=ui,Ma=qu=Mr=ui=null}Th.prototype={constructor:Th,polygons:function(){var r=this.edges;return this.cells.map(function(t){var e=t.halfedges.map(function(o){return n0(t,r[o])});return e.data=t.site.data,e})},triangles:function(){var r=[],t=this.edges;return this.cells.forEach(function(e,o){if(f=(l=e.halfedges).length)for(var a=e.site,l,h=-1,f,p,d=t[l[f-1]],g=d.left===a?d.right:d.left;++h<f;)p=g,d=t[l[h]],g=d.left===a?d.right:d.left,p&&g&&o<p.index&&o<g.index&&Fk(a,p,g)<0&&r.push([a.data,p.data,g.data])}),r},links:function(){return this.edges.filter(function(r){return r.right}).map(function(r){return{source:r.left.data,target:r.right.data}})},find:function(r,t,e){for(var o=this,a,l=o._found||0,h=o.cells.length,f;!(f=o.cells[l]);)if(++l>=h)return null;var p=r-f.site[0],d=t-f.site[1],g=p*p+d*d;do f=o.cells[a=l],l=null,f.halfedges.forEach(function(x){var _=o.edges[x],S=_.left;if(!((S===f.site||!S)&&!(S=_.right))){var T=r-S[0],P=t-S[1],v=T*T+P*P;v<g&&(g=v,l=S.index)}});while(l!==null);return o._found=a,e==null||g<=e*e?f.site:null}};var Wk=hn(Vu(),1);var v0=hn(_b(),1);function yi(){return new Ph}function Ph(){this.reset()}Ph.prototype={constructor:Ph,reset:function(){this.s=this.t=0},add:function(r){xb(Ch,r,this.t),xb(this,Ch.s,this.s),this.s?this.t+=Ch.t:this.s=Ch.t},valueOf:function(){return this.s}};var Ch=new Ph;function xb(r,t,e){var o=r.s=t+e,a=o-t,l=o-a;r.t=t-l+(e-a)}var cn=1e-6;var _n=Math.PI,sr=_n/2,Ih=_n/4,Io=_n*2,wa=180/_n,vi=_n/180,zn=Math.abs,fo=Math.atan,_i=Math.atan2,on=Math.cos;var Rh=Math.exp;var jl=Math.log;var ve=Math.sin;var Dr=Math.sqrt,Ql=Math.tan;function s0(r){return r>1?0:r<-1?_n:Math.acos(r)}function li(r){return r>1?sr:r<-1?-sr:Math.asin(r)}function ho(){}var Xk=yi(),uJ=yi();function ba(r){var t=r[0],e=r[1],o=on(e);return[o*on(t),o*ve(t),ve(e)]}function tc(r,t){return[r[1]*t[2]-r[2]*t[1],r[2]*t[0]-r[0]*t[2],r[0]*t[1]-r[1]*t[0]]}function ec(r){var t=Dr(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);r[0]/=t,r[1]/=t,r[2]/=t}var vJ=yi();function Sb(r,t){return[r>_n?r-Io:r<-_n?r+Io:r,t]}Sb.invert=Sb;function a0(){var r=[],t;return{point:function(e,o){t.push([e,o])},lineStart:function(){r.push(t=[])},lineEnd:ho,rejoin:function(){r.length>1&&r.push(r.pop().concat(r.shift()))},result:function(){var e=r;return r=[],t=null,e}}}function u0(r,t){return zn(r[0]-t[0])<cn&&zn(r[1]-t[1])<cn}function Lh(r,t,e,o){this.x=r,this.z=t,this.o=e,this.e=o,this.v=!1,this.n=this.p=null}function l0(r,t,e,o,a){var l=[],h=[],f,p;if(r.forEach(function(T){if(!((P=T.length-1)<=0)){var P,v=T[0],y=T[P],C;if(u0(v,y)){for(a.lineStart(),f=0;f<P;++f)a.point((v=T[f])[0],v[1]);a.lineEnd();return}l.push(C=new Lh(v,T,null,!0)),h.push(C.o=new Lh(v,null,C,!1)),l.push(C=new Lh(y,T,null,!1)),h.push(C.o=new Lh(y,null,C,!0))}}),!!l.length){for(h.sort(t),Mb(l),Mb(h),f=0,p=h.length;f<p;++f)h[f].e=e=!e;for(var d=l[0],g,x;;){for(var _=d,S=!0;_.v;)if((_=_.n)===d)return;g=_.z,a.lineStart();do{if(_.v=_.o.v=!0,_.e){if(S)for(f=0,p=g.length;f<p;++f)a.point((x=g[f])[0],x[1]);else o(_.x,_.n.x,1,a);_=_.n}else{if(S)for(g=_.p.z,f=g.length-1;f>=0;--f)a.point((x=g[f])[0],x[1]);else o(_.x,_.p.x,-1,a);_=_.p}_=_.o,g=_.z,S=!S}while(!_.v);a.lineEnd()}}}function Mb(r){if(t=r.length){for(var t,e=0,o=r[0],a;++e<t;)o.n=a=r[e],a.p=o,o=a;o.n=a=r[0],a.p=o}}function Bs(r,t){return r<t?-1:r>t?1:r>=t?0:NaN}function c0(r){return r.length===1&&(r=Zk(r)),{left:function(t,e,o,a){for(o==null&&(o=0),a==null&&(a=t.length);o<a;){var l=o+a>>>1;r(t[l],e)<0?o=l+1:a=l}return o},right:function(t,e,o,a){for(o==null&&(o=0),a==null&&(a=t.length);o<a;){var l=o+a>>>1;r(t[l],e)>0?a=l:o=l+1}return o}}}function Zk(r){return function(t,e){return Bs(r(t),e)}}var wb=c0(Bs),Jk=wb.right,Kk=wb.left;var bb=Array.prototype,Qk=bb.slice,tG=bb.map;var cK=Math.sqrt(50),fK=Math.sqrt(10),hK=Math.sqrt(2);function Oh(r){for(var t=r.length,e,o=-1,a=0,l,h;++o<t;)a+=r[o].length;for(l=new Array(a);--t>=0;)for(h=r[t],e=h.length;--e>=0;)l[--a]=h[e];return l}var uG=1e9,Zj=-uG;var f0=yi();function h0(r,t){var e=t[0],o=t[1],a=[ve(e),-on(e),0],l=0,h=0;f0.reset();for(var f=0,p=r.length;f<p;++f)if(g=(d=r[f]).length)for(var d,g,x=d[g-1],_=x[0],S=x[1]/2+Ih,T=ve(S),P=on(S),v=0;v<g;++v,_=C,T=D,P=B,x=y){var y=d[v],C=y[0],M=y[1]/2+Ih,D=ve(M),B=on(M),z=C-_,U=z>=0?1:-1,R=U*z,rt=R>_n,O=T*D;if(f0.add(_i(O*U*ve(R),P*B+O*on(R))),l+=rt?z+U*Io:z,rt^_>=e^C>=e){var W=tc(ba(x),ba(y));ec(W);var G=tc(a,W);ec(G);var _t=(rt^z>=0?-1:1)*li(G[2]);(o>_t||o===_t&&(W[0]||W[1]))&&(h+=rt^z>=0?1:-1)}}return(l<-cn||l<cn&&f0<-cn)^h&1}var oQ=yi();var wQ=yi(),bQ=yi();var fG=1/0;var CQ=-fG;function p0(r){this._context=r}p0.prototype={_radius:4.5,pointRadius:function(r){return this._radius=r,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(r,t){switch(this._point){case 0:{this._context.moveTo(r,t),this._point=1;break}case 1:{this._context.lineTo(r,t);break}default:{this._context.moveTo(r+this._radius,t),this._context.arc(r,t,this._radius,0,Io);break}}},result:ho};var BQ=yi();function d0(){this._string=[]}d0.prototype={_radius:4.5,_circle:Cb(4.5),pointRadius:function(r){return(r=+r)!==this._radius&&(this._radius=r,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._string.push("Z"),this._point=NaN},point:function(r,t){switch(this._point){case 0:{this._string.push("M",r,",",t),this._point=1;break}case 1:{this._string.push("L",r,",",t);break}default:{this._circle==null&&(this._circle=Cb(this._radius)),this._string.push("M",r,",",t,this._circle);break}}},result:function(){if(this._string.length){var r=this._string.join("");return this._string=[],r}else return null}};function Cb(r){return"m0,"+r+"a"+r+","+r+" 0 1,1 0,"+-2*r+"a"+r+","+r+" 0 1,1 0,"+2*r+"z"}function m0(r,t,e,o){return function(a,l){var h=t(l),f=a.invert(o[0],o[1]),p=a0(),d=t(p),g=!1,x,_,S,T={point:P,lineStart:y,lineEnd:C,polygonStart:function(){T.point=M,T.lineStart=D,T.lineEnd=B,_=[],x=[]},polygonEnd:function(){T.point=P,T.lineStart=y,T.lineEnd=C,_=Oh(_);var z=h0(x,f);_.length?(g||(l.polygonStart(),g=!0),l0(_,dG,z,e,l)):z&&(g||(l.polygonStart(),g=!0),l.lineStart(),e(null,null,1,l),l.lineEnd()),g&&(l.polygonEnd(),g=!1),_=x=null},sphere:function(){l.polygonStart(),l.lineStart(),e(null,null,1,l),l.lineEnd(),l.polygonEnd()}};function P(z,U){var R=a(z,U);r(z=R[0],U=R[1])&&l.point(z,U)}function v(z,U){var R=a(z,U);h.point(R[0],R[1])}function y(){T.point=v,h.lineStart()}function C(){T.point=P,h.lineEnd()}function M(z,U){S.push([z,U]);var R=a(z,U);d.point(R[0],R[1])}function D(){d.lineStart(),S=[]}function B(){M(S[0][0],S[0][1]),d.lineEnd();var z=d.clean(),U=p.result(),R,rt=U.length,O,W,G;if(S.pop(),x.push(S),S=null,!!rt){if(z&1){if(W=U[0],(O=W.length-1)>0){for(g||(l.polygonStart(),g=!0),l.lineStart(),R=0;R<O;++R)l.point((G=W[R])[0],G[1]);l.lineEnd()}return}rt>1&&z&2&&U.push(U.pop().concat(U.shift())),_.push(U.filter(pG))}}return T}}function pG(r){return r.length>1}function dG(r,t){return((r=r.x)[0]<0?r[1]-sr-cn:sr-r[1])-((t=t.x)[0]<0?t[1]-sr-cn:sr-t[1])}var mG=m0(function(){return!0},gG,vG,[-_n,-sr]);function gG(r){var t=NaN,e=NaN,o=NaN,a;return{lineStart:function(){r.lineStart(),a=1},point:function(l,h){var f=l>0?_n:-_n,p=zn(l-t);zn(p-_n)<cn?(r.point(t,e=(e+h)/2>0?sr:-sr),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(f,e),r.point(l,e),a=0):o!==f&&p>=_n&&(zn(t-o)<cn&&(t-=o*cn),zn(l-f)<cn&&(l-=f*cn),e=yG(t,e,l,h),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(f,e),a=0),r.point(t=l,e=h),o=f},lineEnd:function(){r.lineEnd(),t=e=NaN},clean:function(){return 2-a}}}function yG(r,t,e,o){var a,l,h=ve(r-e);return zn(h)>cn?fo((ve(t)*(l=on(o))*ve(e)-ve(o)*(a=on(t))*ve(r))/(a*l*h)):(t+o)/2}function vG(r,t,e,o){var a;if(r==null)a=e*sr,o.point(-_n,a),o.point(0,a),o.point(_n,a),o.point(_n,0),o.point(_n,-a),o.point(0,-a),o.point(-_n,-a),o.point(-_n,0),o.point(-_n,a);else if(zn(r[0]-t[0])>cn){var l=r[0]<t[0]?_n:-_n;a=e*l/2,o.point(-l,a),o.point(0,a),o.point(l,a)}else o.point(t[0],t[1])}function Dh(r){return function(t){var e=new g0;for(var o in r)e[o]=r[o];return e.stream=t,e}}function g0(){}g0.prototype={constructor:g0,point:function(r,t){this.stream.point(r,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var btt=on(30*vi);var ztt=Dh({point:function(r,t){this.stream.point(r*vi,t*vi)}});function Fh(r){return function(t,e){var o=on(t),a=on(e),l=r(o*a);return[l*a*ve(t),l*ve(e)]}}function Ro(r){return function(t,e){var o=Dr(t*t+e*e),a=r(o),l=ve(a),h=on(a);return[_i(t*l,o*h),li(o&&e*l/o)]}}var Db=Fh(function(r){return Dr(2/(1+r))});Db.invert=Ro(function(r){return 2*li(r/2)});var Fb=Fh(function(r){return(r=s0(r))&&r/ve(r)});Fb.invert=Ro(function(r){return r});function y0(r,t){return[r,jl(Ql((sr+t)/2))]}y0.invert=function(r,t){return[r,2*fo(Rh(t))-sr]};function Uh(r,t){return[r,t]}Uh.invert=Uh;function Ub(r,t){var e=on(t),o=on(r)*e;return[e*ve(r)/o,ve(t)/o]}Ub.invert=Ro(fo);function Bb(r,t){var e=t*t,o=e*e;return[r*(.8707-.131979*e+o*(-.013791+o*(.003971*e-.001529*o))),t*(1.007226+e*(.015085+o*(-.044475+.028874*e-.005916*o)))]}Bb.invert=function(r,t){var e=t,o=25,a;do{var l=e*e,h=l*l;e-=a=(e*(1.007226+l*(.015085+h*(-.044475+.028874*l-.005916*h)))-t)/(1.007226+l*(.015085*3+h*(-.044475*7+.028874*9*l-.005916*11*h)))}while(zn(a)>cn&&--o>0);return[r/(.8707+(l=e*e)*(-.131979+l*(-.013791+l*l*l*(.003971-.001529*l)))),e]};function zb(r,t){return[on(t)*ve(r),ve(t)]}zb.invert=Ro(li);function kb(r,t){var e=on(t),o=1+on(r)*e;return[e*ve(r)/o,ve(t)/o]}kb.invert=Ro(function(r){return 2*fo(r)});function Gb(r,t){return[jl(Ql((sr+t)/2)),-r]}Gb.invert=function(r,t){return[-t,2*fo(Rh(r))-sr]};var wG=hn(Vu(),1);var bG=hn(Vu(),1);var AG=hn(Vu(),1);var CG=hn(Vu(),1);function ks(r,t){return Math.sqrt((t[0]-r[0])**2+(t[1]-r[1])**2)}function _0(r){let t=0;for(let e=0;e<r.length-1;e++)t+=ks(r[e],r[e+1]);return t}function Vb(r,t,e){let o=new nn(t[0]-r[0],t[1]-r[1]),a=new nn(t[0]-e[0],t[1]-e[1]),h=o.angleTo(a)*180/Math.PI,f=new nn(t[0]-r[0],t[1]-r[1]);return new nn(e[0]-r[0],e[1]-r[1]).cross(f)>0?h:-h}var Gi="___",Bh=class{initRoute(t){this.clear(),this.roadInfo=t,t.length&&(t.forEach(e=>{e.points.forEach(o=>{let a=""+e.floor+Gi+o.id;if(this.pointMap.set(a,o),this.nodeMap.set(""+o.floor+Gi+o.nodeId,a),o.type==="straightLadder"){let l=this.straightLadderMap.get(o.name)||[];l.push(ka({},o)),this.straightLadderMap.set(o.name,l)}if(o.type==="staircase"){let l=this.staircaseMap.get(o.name)||[];l.push(ka({},o)),this.staircaseMap.set(o.name,l)}if(o.type==="escalator"){let l=this.escalatorMap.get(o.name)||{};o.escalatorDirection==="exit"?l.end={floor:o.floor,id:o.id}:l.start={floor:o.floor,id:o.id},this.escalatorMap.set(o.name,l)}if(o.type==="facility"){let l=this.facilityMap.get(o.targetId)||[];l.push(ka({},o)),this.facilityMap.set(o.targetId,l)}}),e.lines.filter(o=>o.direction!=="no").forEach(o=>{var a,l;let h=""+e.floor+Gi+o.from,f=""+e.floor+Gi+o.to,p=(a=this.pointMap.get(h))==null?void 0:a.cds,d=(l=this.pointMap.get(f))==null?void 0:l.cds;if(p!=null&&p.length&&(d!=null&&d.length)){let g=ks(p,d);this.addLineItem(h,f,g),o.direction==="double"&&this.addLineItem(f,h,g)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(t,e,o,a){a===void 0&&(a=this.lineMap);let l=a.get(t)||new Map;l.set(e,o),a.set(t,l)}addFacilityToLineMap(t,e,o,a){[...this.straightLadderMap,...this.staircaseMap].forEach(l=>{let[h,f]=l;if(!(f.length<2))for(let g=0;g<f.length;g++){let x=""+f[g].floor+Gi+f[g].id;for(let _=0;_<f.length;_++)if(g!==_){var p,d;let S=""+f[_].floor+Gi+f[_].id,T=(p=this.pointMap.get(x))==null?void 0:p.cds,P=(d=this.pointMap.get(S))==null?void 0:d.cds;if(T!=null&&T.length&&(P!=null&&P.length))if(f[g].type==="straightLadder"){let v=e;this.addLineItem(x,S,v,a)}else{let v=o;this.addLineItem(x,S,v,a)}}}}),this.escalatorMap.forEach((l,h)=>{if(l.start&&l.end){var f,p;let d=""+l.start.floor+Gi+l.start.id,g=""+l.end.floor+Gi+l.end.id,x=(f=this.pointMap.get(d))==null?void 0:f.cds,_=(p=this.pointMap.get(g))==null?void 0:p.cds;if(x!=null&&x.length&&(_!=null&&_.length)){let S=t;this.addLineItem(d,g,S,a)}}})}initBaseRoute(){let t=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Lo.default(t)}initEscalatorRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(1*e,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new Lo.default(t)}initStraightLadderRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Lo.default(t)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility?!0:this.checkStart(t)}transformStart(t){var e;if(t.nodeId){let o=this.nodeMap.get(""+t.floor+Gi+t.nodeId);if(o){let[a,l]=o.split(Gi);return{floor:a,id:l}}}if((e=t.coord)!=null&&e.length){let o=this.roadInfo.find(l=>l.floor===t.floor);if(!o)return null;let a=o.points.reduce((l,h)=>{let f=ks(t.coord,h.cds);return f<l.min&&(l.min=f,l.point=h),l},{min:1/0,point:o.points[0]});return{floor:a.point.floor,id:a.point.id}}return null}transformEnd(t){if(t.floor){let e=this.transformStart(t);if(e)return e}if(t.facility){let e=this.facilityMap.get(t.facility);if(e!=null&&e.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,o){if(o===void 0&&(o=""),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let a=this.transformStart(t);if(!a)return"no-start";let l=this.transformEnd(e);if(!l)return"no-end";let h=this.getBasePath.bind(this);switch(o){case"escalator":h=this.getEscalatorPath.bind(this);break;case"straightLadder":h=this.getStraightLadderPath.bind(this);break;default:h=this.getBasePath.bind(this);break}if(l.id)return h(a,l);if(l.facility){let f=this.facilityMap.get(l.facility).filter(d=>l.floor?d.floor===l.floor:!0);if(!f.length)return null;let p=f.map(d=>h(a,{floor:d.floor,id:d.id})).filter(d=>!!d);return p.reduce((d,g)=>{let x=g.reduce((_,S)=>_+_0(S.points),0);return x<d.distance&&(d.distance=x,d.path=g),d},{distance:1/0,path:p[0]}).path}}getRoutePath(t,e,o){let a=""+t.floor+Gi+t.id,l=""+e.floor+Gi+e.id,h=o.path(a,l);if(!h)return null;let f=[];return h.map(p=>{let d=this.pointMap.get(p);if(d){var g;let{floor:x}=d;if(((g=f[f.length-1])==null?void 0:g.floor)===x){let _=f[f.length-1];_.points.push(d.cds),_.endType=d.type,_.destId=d.nodeId,_.distance=_0(_.points)}else f.push({floor:x,points:[d.cds],endType:d.type,destId:d.nodeId,distance:0})}}),f}getBasePath(t,e){return this.getRoutePath(t,e,this.baseRoute)}getEscalatorPath(t,e){return this.getRoutePath(t,e,this.escalatorRoute)}getStraightLadderPath(t,e){return this.getRoutePath(t,e,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new Lo.default,this.escalatorRoute=new Lo.default,this.straightLadderRoute=new Lo.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.staircaseMap=new Map,this.lineMap=new Map,this.baseRoute=new Lo.default,this.escalatorRoute=new Lo.default,this.straightLadderRoute=new Lo.default}};var tat=hn(Bc(),1),eat=hn(Dp(),1);var UG=hn($b(),1);function BG(r,t,e){let o=Vb(r,t,e);return 180-Math.abs(o)<15?"front":o>135?"right_front":o<-135?"left_front":o<=135&&o>=60?"right":o>=-135&&o<=-60?"left":o<60&&o>0?"right_back":o>-60&&o<0?"left_back":"front"}function Zb(r){if(!r.length)return[];if(r.length===1)return[{direction:"start",distance:0,points:r}];let t=[{direction:"start",distance:ks(r[0],r[1]),points:[r[0],r[1]]}];for(let e=2;e<r.length;e++){let o=BG(r[e-2],r[e-1],r[e]);if(o==="front"){let a=t[t.length-1],l=ks(r[e-1],r[e]);a.distance+=l,e!==2&&a.points.push(r[e-1])}else t.push({direction:o,distance:ks(r[e-1],r[e]),points:[r[e-1],r[e]]})}return t.push({direction:"end",distance:0,points:[r[r.length-1]]}),t}var hat=hn(ST(),1),pat=hn(Hc(),1);function MT(r){return r.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function wT(r){let t={};for(let o in r)o.startsWith("on")&&(t[MT(o.slice(2))]=r[o]);let e=o=>uc(this,null,function*(){let{data:a}=o;if(t[a.type])try{let l=yield t[a.type](a.data);self.postMessage({type:""+a.type+"_result",key:a.key,data:l})}catch(l){self.postMessage({type:""+a.type+"_result",key:a.key,error:l})}else self.postMessage({type:""+a.type+"_result",key:a.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}var A0=new Bh;wT({onSetRoadInfo(r){let{roadData:t}=r;A0.initRoute(t)},onGetPath(r){let{start:t,end:e,type:o}=r;return A0.getPath(t,e,o)},onGetDirectionPath(r){return Zb(r)},onClear(){A0.clear()}});
7744
- `],{type:"text/javascript"}),t=URL.createObjectURL(r),e=new Worker(t);return URL.revokeObjectURL(t),e}var rl=class extends f_.EventDispatcher{setRoadData(t){return x(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield ee(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,n){return x(this,null,function*(){return n===void 0&&(n=""),new Promise((i,o)=>{let s=()=>{ee(this.worker,"get_path",{start:t,end:e,type:n}).then(a=>{a?typeof a=="string"?o(a):i(a):o("no-path")})};if(this.initRoadStatus)s();else{let a=u=>{let{status:l}=u;l&&(this.removeEventListener("init-road-status",a),s())};this.addEventListener("init-road-status",a)}})})}getDirectionPath(t){return ee(this.worker,"get_direction_path",t)}dispose(){return x(this,null,function*(){ee(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=nl(),this.initRoadStatus=!1}};var Ek=d(T(),1),Sk=d(le(),1),bk=d(ce(),1),Mk=d(he(),1),wk=d(pe(),1),Tk=d(fe(),1),Ik=d(de(),1),Rk=d(ge(),1),Pk=d(U(),1);var d_=require("three"),xs=class extends Ft{setEnable(t){super.setEnable(t),dt(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:n,clientHeight:i}}}=this,o=I(this.startPoint,e,n,i),s=I(this.endPoint,e,n,i),a={x:Math.min(o.x,s.x),y:Math.min(o.y,s.y)},u={x:Math.max(o.x,s.x),y:Math.max(o.y,s.y)},l=this.searchMapInFrustum(a,u);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(o=>o instanceof K&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,n){let{context:{camera:i,container:{clientWidth:o,clientHeight:s}}}=this;if(!t)return!1;if(!t.mesh){let h=t.getPosition();if(h){let g=I(h,i,o,s);return Be(g,e,n)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let a=t.mesh.geometry.boundingBox;if(!a)return!1;let{min:u,max:l}=a,c=I(u,i,o,s),p=I(l,i,o,s);return!(!Be(c,e,n)||!Be(p,e,n))}dispose(){this.unRegistryEvent()}constructor(t){super(t),this.frustum=new d_.Frustum,this.onPointerDown=i=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(i);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=i=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(i);o&&(this.endPoint=o)},this.onPointerUp=i=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(i);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let i=this.getSvgCoordinate(this.startPoint),o=E({},i);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let s={x:Math.min(i.x,o.x),y:Math.min(i.y,o.y)},a=Math.abs(o.x-i.x),u=Math.abs(o.y-i.y);dt(this.rect,s.x,s.y,a,u)}else dt(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:n}}}=t;this.rect=Ne(n,e),this.svg.appendChild(this.rect),this.registryEvent()}};var JP={boxSelection:!1,elements:["graphic","poi"]},il=class extends qt{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=n=>{this.downPoint={x:n.offsetX,y:n.offsetY}},this.onPointerUp=n=>{if(!this.downPoint)return;let{offsetX:i,offsetY:o}=n,{x:s,y:a}=this.downPoint;if(Math.sqrt((s-i)**2+(a-o)**2)>3)return;let u=new Set,l=[],c=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(i,o);p.map(h=>u.add(h.options.id)),l.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(i,o);c.push(...p),p.forEach(h=>{if(!u.has(h.options.id)){var g;let y=((g=this.bmap.context.currentFloor)==null?void 0:g.graphicLayer.graphicMap.get(h.options.id))||null;y&&(u.add(h.options.id),l.push(y))}})}(!this.options.boxSelection||!(mn?n.metaKey:n.ctrlKey))&&(this._list.clear(),this._poiList.clear()),l.forEach(p=>this._list.add(p)),c.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=n=>{this.disableBoxSelection()},this.onKeyDown=n=>{yn(n.key)&&this.enableBoxSelection()},this.onKeyUp=n=>{yn(n.key)&&this.disableBoxSelection()},this.onBoxSelected=n=>{let{list:i}=n;this._list.clear(),this._poiList.clear(),i.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let s=this.bmap.getPoiById(o.options.id);s&&this._poiList.add(s)}}),this.selectEnd()},this.options=E({},JP,e),this.boxSelection=new xs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var Fk=d(U(),1),Mt=require("lodash");var g_=require("three");var X=function(r){return r.COMPASS="compass",r.DEVICE_MOTION="deviceMotion",r.ACCELERATION="acceleration",r.GPS="gps",r}({});var ZP={time:1e3,elements:[X.COMPASS,X.DEVICE_MOTION,X.ACCELERATION,X.GPS]},yi=class extends g_.EventDispatcher{start(){this.options.elements.some(t=>[X.DEVICE_MOTION,X.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(X.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(X.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,Mt.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){Jn?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{this.addDataItem({type:X.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return x(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return x(this,null,function*(){var t;if(!Jn)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(n){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),Jn?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,Mt.isNil)(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new Z,this.dispatchTimer=null,this.addAcceleration=(0,Mt.throttle)(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=(0,Mt.throttle)(e=>{let n=Date.now(),{alpha:i,beta:o,gamma:s}=e;if((0,Mt.isNil)(i)||(0,Mt.isNil)(o)||(0,Mt.isNil)(s))return;let a;Jn?a=e.webkitCompassHeading:a=360-i,this.options.elements.includes(X.DEVICE_MOTION)&&this.addDataItem({type:X.DEVICE_MOTION,timestamp:n,res:[i,o,s]}),this.options.elements.includes(X.COMPASS)&&this.addDataItem({type:X.COMPASS,timestamp:n,res:a})},200),this.handleAcceleration=e=>{let n=e.accelerationIncludingGravity;(0,Mt.isNil)(n)||(0,Mt.isNil)(n.x)||(0,Mt.isNil)(n.y)||(0,Mt.isNil)(n.z)||this.addAcceleration({type:X.ACCELERATION,timestamp:Date.now(),res:[n.x,n.y,n.z]})},this.options=E({},ZP,t)}};var iG=d(T(),1),y_=require("three");var Jk=d(U(),1);var Vk=d(U(),1),Xk=d(T(),1);function Cs(r,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(r,2)/(2*Math.pow(t,2)))}function vi(r){return(r+360)%360}function m_(r,t){let n=6378137*r*Math.PI/180,i=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:n,y:i}}function cr(r,t,e,n){return Math.sqrt(Math.pow(Math.abs(r-e),2)+Math.pow(Math.abs(t-n),2))}var Es=require("mathjs"),As=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=vi(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let n=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+n,this.particleX[2][e]=vi(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let i=0;i<this.NumParticle;i++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][i]+=(.65+o)*Math.sin(-this.particleX[2][i]/180*Math.PI),this.particleX[1][i]+=(.65+o)*Math.cos(this.particleX[2][i]/180*Math.PI),e(this.particleX[0][i],this.particleX[1][i])||(this.particleWeight[0][i]*=this.unaccess_weight)}let n=this.particleWeight[0].reduce((i,o)=>i+o,0);this.particleWeight[0]=this.particleWeight[0].map(i=>i/n)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let n=360-t;n+=this.delta_yaw,n=vi(n),Math.abs(n-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let s=Math.abs(this.particleX[2][o]-n);s>180&&(s=360-s),this.particleWeight[0][o]*=Cs(s,this.sigmaCompass)}let i=this.particleWeight[0].reduce((o,s)=>o+s,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/i),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,n)=>e+n*n,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((a,u,l)=>a.concat(a[l]+u),[0]),i=this.particleWeight[0].map(()=>1/this.NumParticle).map((a,u)=>a+Math.random()/this.NumParticle),o=[],s=0;for(let a=0;a<this.NumParticle;a++){for(;i[a]>e[s];)s++;o.push(s)}this.particleX=this.particleX.map((a,u)=>o.map(l=>a[l])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let i=0;i<this.NumParticle;i++){let o=cr(this.particleX[0][i],this.particleX[1][i],t.x,t.y);this.particleWeight[0][i]=Math.max(1e-7,this.particleWeight[0][i]*Cs(o,e))}let n=this.particleWeight[0].reduce((i,o)=>i+o,0);this.particleWeight[0]=this.particleWeight[0].map(i=>i/n)}updateCar(t,e){let n=t.x-this.xEst[0][0],i=t.y-this.xEst[1][0];for(let s=0;s<this.NumParticle;s++){let a=cr(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*Cs(a,e)),this.particleX[0][s]+=n,this.particleX[1][s]+=i}let o=this.particleWeight[0].reduce((s,a)=>s+a,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=(0,Es.reshape)(this.particleWeight,[this.NumParticle,1]),e=(0,Es.multiply)(this.particleX,t);return this.xEst=e,this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),n=[this.particleX[0][t],this.particleX[1][t]],i=[this.particleX[0][e],this.particleX[1][e]],o=cr(n[0],n[1],i[0],i[1]),s=o*.67;return console.log(o,s),s}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,n){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let i=0;for(;i<this.NumParticle;){let s=(2*Math.random()-1)*this.initial_xy_uncertainty,a=(2*Math.random()-1)*this.initial_xy_uncertainty;n(t+s,e+a)||(this.particleWeight[0][i]*=this.unaccess_weight),this.particleX[0][i]=t+s,this.particleX[1][i]=e+a,i++}let o=this.particleWeight[0].reduce((s,a)=>s+a,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=vi(e),console.log("Init Yaw: "+e);for(let n=0;n<this.NumParticle;n++){let i=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][n]=e+i}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};var Wk=d(U(),1),Qk=d(T(),1),Ss=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,n){let i=0;return n.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,n)),e.length===3&&(i=this.getStepLength(t,e)),i!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let n=!1,i=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(i),this.accH_time_fifo.push(t),this.imuFreUpdate(),this.accH_fifo.length<this.accH_fifo_len+1)n=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let o=this.PVStepDetec(),s=this.FFTStepDetec(),a=this.recheckState(),u=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=u:this.abnor_fft_detected||(this.abnor_start_time=0),o&&s&&a?(this.step_count+=1,this.last_step_time=u,n=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=u,n=!0):(u-this.last_step_time>2&&(this.state_count=0),n=!1)}if(n){let o=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(o),this.delta_py=this.const_step_length*Math.sin(o),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),n=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=e[Math.floor(e.length/2)],o=n[Math.floor(n.length/2)],s=Math.max(...e),a=Math.min(...e),u=!1,l=!1;return Math.abs(i-a)<.01&&i<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?l=!0:l=o-this.last_valley_time>this.min_step_time,l&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(i-s)<.01&&i>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?u=!0:u=o-this.last_peak_time>this.min_step_time,u&&(this.last_peak_time=o,this.peak_num+=1)),i===s&&i>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=i),this.peak_num===this.valley_num&&(u||l)&&(t=!0),t}FFTStepDetec(){return!0}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let n=[0,0,0];this.last_rot.length===3&&(n=e.map((a,u)=>a-this.last_rot[u]));for(let a=0;a<e.length;a++)n[a]<-180?n[a]+=360:n[a]>180&&(n[a]-=360);let i=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((a,u)=>i*a+(1-i)*n[u]):this.delta_rot=n,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((a,u)=>a+Math.abs(u),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let s=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(s=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,s):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0}};var tL={using_gps:!0},bs=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:n,res:i}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===X.ACCELERATION){let s=i,a=this.pdr.getStepLength(n/1e3,s);a!==0&&(this.particleFilter.motionModelStepLength(a,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===X.GPS&&(this.last_beacon_time===null||n-this.last_beacon_time>5e3)){let s=this.getGpsPosition(i);o=s!==null,s&&(this.particleFilter.update(s,this.gps_horizontalAccuracy),this.resetParticleFilterDist(s,"gps",i[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}if(e===X.DEVICE_MOTION){let s=this.pdr.getDeltaYawFromRot(n/1e3,i);s!==null&&this.particleFilter.motionModelRotYaw(s)}e===X.COMPASS&&this.particleFilter.motionModelCompassYaw(i,n),this.last_pos_time&&n-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===X.GPS){let s=this.getGpsPosition(i);o=s!==null,console.log("gps_pos",s,i),s?(this.particleFilter.initParticlesByPos(s.x,s.y,()=>!0),this.last_pos_time=n,console.log("init Pos by gps success time "+n),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+n)}else if(!this.particleFilter.getYawInitFlag()&&e===X.COMPASS){let s=i;this.particleFilter.initParticlesByCompass(s),this.particleFilter.setLastCompassTime(n),console.log("init yaw by compass success time "+n)}return o&&(this.last_pos_time=n),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let n=this.cacheSensorData.filter(i=>i.timestamp>e);console.log("\u521D\u59CBsensorData",n),n.map(i=>this.pfFusionPDRiBeacon(i))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:m_(t[0],t[1])}resetParticleFilterDist(t,e,n){let i=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),s=cr(i,o,t.x,t.y);(e==="gps"?n&&s>n||s>this.GpsMaxEstimateErr:s>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0)):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=null,this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=4,this.cacheSensorData=[];let e=E({},tL,t);this.using_gps=e.using_gps,this.particleFilter=new As({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new Ss}};var ol=class extends y_.EventDispatcher{checkSensor(){return this.sensor.checkSensor()}start(){this.sensor.start(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[n,i,o]=this.pdr.pfFusionPDRiBeacon(t);return n&&e&&this.dispatchEvent({type:"position",x:i,y:o,_type:t.type===X.GPS?"gps":"pdr"}),[n,i,o]}setBeaconPosition(t,e){let[n,i]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:n,y:i,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t={}){super(),this._pause=!1,this.sensor=new yi(t.sensor),this.pdr=new bs(t.pdr||{})}};var xG=d(T(),1),CG=d(U(),1);var lG=d(T(),1),cG=d(U(),1),ut=require("three");var v_={texture_url:is,lineWidth:8,color:16777215},Ms=class extends ut.Object3D{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:n,height:i}}}}}=this,o=t.map(a=>{let[u,l,c]=a;return I(new ut.Vector3(u,l,c),e,n,i)}).map(a=>{let{x:u,y:l}=a;return[u,l]});return Bt(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new ut.Vector2(t,1)}loadTexture(t){return new Promise((e,n)=>{new ut.TextureLoader().load(t,e,void 0,n)})}transformPoints(t){let e=[];for(let n=0;n<t.length;n++)e.push(...t[n]);return e}updatePoints(t){this.points=t,this.changeRepeat();let e=this.transformPoints(t);this.geometry&&this.geometry.setPoints(e)}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return x(this,null,function*(){let e=this.geometry=new Ct;if(this.updatePoints(t),!this.texture){let o=this.texture=yield this.loadTexture(this.config.texture_url);o.wrapS=o.wrapT=ut.RepeatWrapping}let n=this.material=new Pn({useMap:!0,color:new ut.Color(this.config.color),transparent:!0,resolution:new ut.Vector2(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,sizeAttenuation:!1,lineWidth:this.config.lineWidth*2,map:this.texture,blending:ut.NormalBlending,repeat:new ut.Vector2(this.getRepeat(),1)}),i=this.mesh=new ut.Mesh(e,n);return i.renderOrder=9,this.add(i),i})}dispose(){var t,e,n;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(n=this.texture)==null||n.dispose()}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=v_,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let n=this.navigation.bmap.context.camera.zoom;n!==this.prevCameraZoom&&(this.prevCameraZoom=n,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:n,height:i}=this.navigation.bmap.context.clientSize;this.material.resolution.set(n,i)}},this.config=Object.assign({},v_,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};var __=require("@tweenjs/tween.js");var J=require("three"),ws=class extends J.Object3D{getBaseScale(t){let{clientSize:{width:e,height:n},camera:i}=this.bmap.context,o=new J.Box3().setFromObject(t),{max:s,min:a}=o,u=new J.Vector3(a.x,s.y,s.z),l=new J.Vector3(s.x,s.y,s.z),c=new J.Vector3(s.x,a.y,a.z),p=new J.Vector3(a.x,a.y,a.z),h=I(u,i,e,n),g=I(l,i,e,n),y=I(p,i,e,n),v=I(c,i,e,n),C=new J.Box2().setFromPoints([new J.Vector2(h.x,h.y),new J.Vector2(g.x,g.y),new J.Vector2(y.x,y.y),new J.Vector2(v.x,v.y)]).getSize(new J.Vector2),b=40/C.x,R=40/C.y,B=Math.min(b,R),P=i.zoom;return B*P}registryEvent(){this.bmap.context.addEventListener("update",this._update),this.bmap.context.addEventListener("control-zoom-change",this._onChangeZoom)}unRegistryEvent(){this.bmap.context.removeEventListener("update",this._update),this.bmap.context.removeEventListener("control-zoom-change",this._onChangeZoom)}printGraph(t){console.group(" <"+t.type+"> "+t.name),t.children.forEach(e=>this.printGraph(e)),console.groupEnd()}setClips(t){this.clearClips(),t.length&&(this.mixer=new J.AnimationMixer(this.model.scene),t.forEach(e=>this.mixer.clipAction(e).play()))}startClips(){var t;this.setClips(((t=this.model)==null?void 0:t.animations)||[])}clearClips(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null)}dispose(){this.unRegistryEvent(),this.clearClips(),this.clear(),this.model&&tt(this.model.scene)}constructor(t,e){super(),this.bmap=t,this.group=new J.Object3D,this.mixer=null,this.previewTime=0,this.basicScale=1,this._update=()=>{let n=Date.now();if(!this.previewTime)this.previewTime=n;else{var i;let o=n-this.previewTime;this.previewTime=n,(i=this.mixer)==null||i.update(o/1e3)}},this._onChangeZoom=n=>{let{zoom:i}=n;var o;let s=this.basicScale/i;(o=this.model)==null||o.scene.scale.set(s,s,s)},this.add(this.group),Ht.loadModel(e,!1).then(n=>{this.model=n;let i=this.getBaseScale(n.scene);this.basicScale=i;let o=this.bmap.context.camera.zoom;n.scene.scale.set(i/o,i/o,i/o),this.group.add(n.scene),this.setClips(n.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};var _i=require("three"),x_=require("lodash");var sl=class extends qt{registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate)}pauseAnimation(){this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue()}clearTween(){this.tweenUtil.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate)}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.movedDistance=0,this.clearTween()),this.startModel&&(this.startModel.visible=!1),this.translatePath=null}addPath(t){this.paths=t;let e=t.map(n=>E({},n,{points:this.translatePoints(n.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(e);else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(e)};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,n]=this.bmap.buildingCenter;return t.map(i=>[i[0]-e,i[1]-n])}renderPath(t){if(!t.length)return this.clearPath();let e=[];t.forEach((n,i,o)=>{let s=this.catmullRomCurve3(n.points),a=this.mulFloor.floors.find(u=>u.name===n.floor);if(e.push(...s.map(u=>{let[l,c]=u;return[l,c,a.position.z+a.groundMaxHeight]})),i!==o.length-1){let u=this.mulFloor.floors.find(l=>l.name===o[i+1].floor);e.push([...o[i+1].points[0],u.position.z])}}),this.cPath=e,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(e):(this.path=new Ms(this),this.path.create(e),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(e[0][0],e[0][1],e[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return kr(t,!1,!0,.1,170,2.5)}getPathDirection(t,e){if(t.length<2)return null;let n=ye(t,e),i=t[n],o=t[n+1],s=new _i.Vector3(o[0]-i[0],o[1]-i[1],0).normalize(),a=new _i.Vector3(0,1,0).normalize(),u=s.angleTo(a),l=new _i.Vector3().crossVectors(a,s);return(Object.is(l.y,0)?-1:1)*u}startSimulation(t){return x(this,null,function*(){t===void 0&&(t=1);let{paths:e,movedDistance:n}=this;if(!e.length)return;let i=e.reduce((s,a)=>s+a.distance,0);if(!i||n>=i)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let o=i/t;return this.startModel.startClips(),new Promise(s=>{let a=this.simulationTween=new __.Tween({distance:this.movedDistance},this.tweenUtil.group).to({distance:i},o*1e3).onUpdate(u=>{var l;this.movedDistance=u.distance;let c=u.distance,p=0;for(let C=0;C<e.length;C++)if(e[C].distance>=c){p=C;break}else c-=e[C].distance;let h=_n(e[p].points,c);if(h===null)return;this.currentPathPosition=h;let g=this.translatePoints([h])[0],y=this.mulFloor.floors.find(C=>C.name===e[p].floor),v=y?y.position.z+y.groundMaxHeight:(l=this.startModel)==null?void 0:l.position.z;this.startModel&&this.startModel.position.set(g[0],g[1],v);let _=this.getPathDirection(e[p].points,h);(0,x_.isNil)(_)||this.startModel.setRotationFromAxisAngle(new _i.Vector3(0,0,1),_)}).onComplete(()=>{this.tweenUtil.remove(a),this.startModel.clearClips(),s(!0)}).start()})})}setStartPoiRotate(t){if(this.startPoi){let n=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-n)%360}}dispose(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.startModel&&(this.bmap.context.scene.remove(this.startModel),this.startModel.dispose()),this.tweenUtil.dispose(),this.unRegistryEvent()}constructor(t,e){super(t),this.mulFloor=e,this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.pathTween=null,this.startPoi=null,this.movedDistance=0,this.tweenUtil=new Oe,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new ws(t,Tv),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};var hr=require("three");var al=class extends hr.EventDispatcher{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose()}constructor(t,e){super(),this.bmap=t,this.mulFloors=e,this._click=n=>{let{e:i}=n;if(!this.mulFloors.showStatus)return;let o=new hr.Vector2,{offsetX:s,offsetY:a}=i,{clientSize:u}=this.bmap.context;o.x=s/u.width*2-1,o.y=a/u.height*-2+1;let l=new hr.Raycaster;l.setFromCamera(o,this.bmap.context.camera),l.ray.origin.sub(l.ray.direction.clone().multiplyScalar(1e4));let p=this.mulFloors.poiLayer.pois.map(g=>{if(!g.canSelect)return null;let y=l.intersectObjects(g.children,!0);return y.length?y[0]:null}).reduce((g,y)=>y&&(!g||y.distance<g.distance)?y:g,null),h=p==null?void 0:p.object;p&&p.object.isSprite&&(h=p.object.parent),h&&h instanceof ot&&this.dispatchEvent({type:"select",pois:[h]})},this.clickHelper=new Xr(this.bmap.context.container),this.registryEvent()}};var VG=d(C_(),1),XG=d(A_(),1),qG=d(U(),1),S_=require("three");var UG=d(T(),1),FG=d(U(),1),$G=d(gu(),1),pr=require("three");function aL(r){let t=r.length,e=0,n=0,i=0,o=0;r.forEach(u=>{e+=u[0],n+=u[1],i+=u[0]*u[1],o+=u[0]*u[0]});let s=(t*i-e*n)/(t*o-e*e),a=(n-s*e)/t;return{m:s,b:a}}function uL(r,t,e){let n=e[0][0],i=e.slice(-1)[0][0],o=r*n+t,s=r*i+t;return{start:[n,o],end:[i,s]}}function xi(r){if(r.length<2)return null;let t=r.filter((u,l)=>{let c=[...r];return c.splice(l,1),c.every(p=>p[0]!==u[0]&&p[1]!==u[1])});if(t.length<2)return null;let{m:e,b:n}=aL(t),{start:i,end:o}=uL(e,n,t),a=360-(new pr.Vector2().subVectors(new pr.Vector2(o[0],o[1]),new pr.Vector2(i[0],i[1])).angle()/Math.PI*180-90+360)%360;return Number.isNaN(a)?null:a}function lL(r){let t=[];for(let e=1;e<r.length;e++){let n=r[e-1],i=r[e],o=i.position[0]-n.position[0],s=i.position[1]-n.position[1],a=Math.sqrt(o**2+s**2),u=i.time-n.time;if(u>0){let l=a/u;console.log("speedDelta",n.type,i.type,Ts(l),a,u),t.push(l)}else t.push(0)}return t}function cL(r,t){let e=r[0],n=r.slice(-1)[0],i=k(n.position,e.position),o=n.time-e.time;return o<100||i<3?null:i/o}function Ts(r){return r*60*60}function fr(r,t,e,n){let i=(e+90)%360*(Math.PI/180),o=t*n,s=new pr.Vector2(r[0],r[1]),a=Math.cos(i),u=Math.sin(i),l=new pr.Vector2(a,u);return s.add(l.normalize().multiplyScalar(o)),[s.x,s.y]}function hL(r){let t=[...r].sort((l,c)=>l-c),e=E_(t,25),n=E_(t,75),i=n-e,o=e-1.5*i,s=n+1.5*i,a=t.filter(l=>l>=o&&l<=s);return r.filter(l=>a.includes(l))}function E_(r,t){let e=t/100*(r.length-1),n=Math.floor(e),i=Math.ceil(e);if(n===i)return r[n];let o=e-n;return r[n]*(1-o)+r[i]*o}var Is=class{filter(t){let e=this.estimate,n=this.errorEstimate+this.processNoise,i=n/(n+this.measurementNoise);return this.estimate=e+i*(t-e),this.errorEstimate=(1-i)*n,this.estimate}constructor(t={}){this.estimate=0,this.errorEstimate=1,this.processNoise=.1,this.measurementNoise=1,this.measurementNoise=t.measurementNoise||1,this.processNoise=t.processNoise||.1,this.errorEstimate=t.errorEstimate||1}};var Ci=require("lodash"),ul=class extends S_.EventDispatcher{setPathAngle(t){this.pathAngle=t,this.dispatchEvent({type:"change-compass",value:this.pathAngle}),(0,Ci.isNil)(this.angle)&&(this.angle=t)}changeSpeed(){let t=this.history.filter(u=>["vision"].includes(u.type));if(t.length<2){this.speedFilter.filter(0),this.speed=0;return}let e=t[0],n=t.slice(-1)[0],i=k(n.position,e.position),o=n.time-e.time,s=o>0?i/o:0,a=this.speedFilter.filter(s);this.speed=a}changeAngle(t){t===void 0&&(t=this.visionHistory),t.length<2&&(this.angle=null);let e=xi(t.map(n=>n.position));e!==null&&this.setAngle(e)}setAngle(t,e){e===void 0&&(e=!0),this.angle=t,e&&this.dispatchEvent({type:"change-position-compass",value:t})}setPosition(t,e,n){let i={position:t,time:e,clientTime:Date.now()-n,type:"vision"};if(this._setVisionHistoryForAngle(i),(0,Ci.isNil)(this.angle)||!this.speed){this.addHistory(i);return}let o=this.history.findLastIndex(a=>a.type==="vision"),s=this.history[o];if(s){if(s.time>e)return;let a=xi([this.history.slice(-1)[0].position,t]);if(a&&Math.abs(a-this.angle)<60){this.addHistory(i);return}let u=fr(t,this.speed,360-this.pathAngle,n);k(u,this.history.slice(-1)[0].position)>10?this.visionExcessesCount++:this.visionExcessesCount=0,this.visionExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21\u89C6\u89C9\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528\u89C6\u89C9\u6821\u51C6"),this.addHistory(i),this.visionExcessesCount=0)}}resetPdrPosition(){let t=this.history.findLast(e=>e.type==="vision");if(t&&this.speed){let e=fr(t.position,this.speed,360-this.pathAngle,Date.now()-t.clientTime);e&&this.history.push({position:e,time:Date.now(),clientTime:Date.now(),type:"pdr"})}}getLastVisionPdrPos(){let t=this.history.findLastIndex(n=>n.type==="vision");if(t!==-1){var e;return(e=this.history[t+1])!=null?e:this.history[t]}return null}_setVisionHistoryForAngle(t){if(!this.visionHistory.length){this.visionHistory.push(t);return}let e=xi([this.visionHistory.slice(-1)[0].position,t.position]);if(e!==null&&(this.angle&&Math.abs(this.angle-e)>60?this.angleExcessesCount++:(this.angleExcessesCount=0,this.visionHistory.push(t))),this.angleExcessesCount>3)console.warn("\u8FDE\u7EED\u4E09\u6B21\u89D2\u5EA6\u6BD4\u8F83\u6B6A\uFF0C\u91CD\u65B0\u77EB\u6B63"),this.visionHistory=[t],this.angleExcessesCount=0;else{let n=k(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position);for(;n>5&&this.visionHistory.length>15;)this.visionHistory.shift(),n=k(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position)}this.changeAngle()}addHistory(t){this.history.push(t);let e=this.history.filter(a=>a.type==="vision"),n=e.length?Date.now()-e.slice(-1)[0].clientTime:0,i=k(this.history[0].position,this.history.slice(-1)[0].position),o=n>5e3?10:3,s=n>5e3?0:5;for(n>5e3&&console.warn("\u89C6\u89C9\u7ED3\u679C\u8D85\u51FA5s\u4E0D\u53EF\u7528\uFF0C\u5168\u90E8\u6E05\u7A7A");e.length>s&&i>o;)this.history.shift(),e=this.history.filter(a=>a.type==="vision"),i=k(this.history[0].position,this.history.slice(-1)[0].position);s===0?this.changeSpeed():t.type==="vision"&&this.changeSpeed(),this.changePosition(t.type)}setBeaconPosition(t,e,n){let i=Date.now()-n,o={position:t,time:e,clientTime:i,type:"beacon"},s=this.history.findLastIndex(c=>c.type!=="pdr"),a=this.history[s];if(!a){this.addHistory(o);return}if((0,Ci.isNil)(this.pathAngle)||!this.speed){this.addHistory(o);return}if(a&&a.time>e)return;let u=fr(t,this.speed,360-this.pathAngle,n);k(u,this.history.slice(-1)[0].position)>5?this.beaconExcessesCount++:this.beaconExcessesCount=0,this.beaconExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21beacon\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528beacon\u6821\u51C6"),this.addHistory(o),this.beaconExcessesCount=0)}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=this.timer.setInterval(()=>{this.changePosition()},20)}changePosition(t){t===void 0&&(t="pdr");let e=this.getPosition(t);e.success&&(this.history.push({position:e.pos,time:Date.now(),clientTime:Date.now(),type:"pdr"}),this.speed?this.dispatchEvent({type:"change-pos",value:E({},e)}):this.dispatchEvent({type:"change-pos",value:e}))}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let e=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};if((0,Ci.isNil)(this.pathAngle)||!this.speed)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};let n=e.clientTime,i=Date.now()-n;return{success:!0,pos:this.pathAngle?fr(e.position,this.speed,360-this.pathAngle,i):e.position,compass:this.pathAngle,speed:Ts(this.speed)}}dispose(){this.timer.dispose()}constructor(){super(),this.history=[],this.visionHistory=[],this.speed=0,this.angle=null,this.timer=new Z,this.positionTimer=null,this.speedFilter=new Is,this.visionExcessesCount=0,this.beaconExcessesCount=0,this.angleExcessesCount=0,this.pathAngle=0,this.startPositionTimer()}};function ll(r,t){return x(this,null,function*(){let{brand:e,project:n}=r,{apiDomain:i,apiPath:{floorRange:o},apiInfo:s}=t,a=""+i+o+"?brand="+e+"&project="+n+"&phase="+n+"&building="+n;return yield fetch(a,s).then(l=>l.json()).then(l=>l.data).then(l=>{let c=(l||[])[0];return c&&(c.info=JSON.parse(c.info)),c})})}function cl(r,t){return x(this,null,function*(){let{brand:e,project:n,floor:i,ts:o,resource_type_list:s}=r,{apiDomain:a,apiPath:{floorGraphic:u},apiInfo:l}=t,c=""+a+u+"?brand="+e+"&project="+n+"&phase="+n+"&building="+n+"&floor="+i+"&ts="+o+"&resource_type_list="+s;return yield fetch(c,l).then(h=>h.json()).then(h=>h.data).then(h=>((h||[]).map(g=>g.info=JSON.parse(g.info)),h||[]))})}function pL(r,t){return x(this,null,function*(){let{project:e,floor:n}=r,{apiDomain:i,apiInfo:o}=t,s=i+"/api/inception-map/external_street/get?projectCode="+e+"&floorCode="+n;return yield fetch(s,o).then(u=>u.json()).then(u=>u.data).then(u=>JSON.parse(u[0].streetInfo||"{}")).then(u=>u.fileId?fL(u.fileId,t):null)})}function fL(r,t){return x(this,null,function*(){let{apiDomain:e,apiInfo:n}=t;return fetch(e+"/api/inception-map/file/getFileStream?fileId="+r,n).then(i=>i.arrayBuffer()).then(i=>{let s=new TextDecoder("utf-8").decode(i);return s?JSON.parse(s):null})})}var u7=d(T(),1);var oe;function b_(r,t){return r===void 0&&(r="aibee_map"),t===void 0&&(t=1),new Promise((e,n)=>{if(oe)return e({db:oe,type:"success"});let i=indexedDB.open(r,t);i.onupgradeneeded=function(o){oe=o.target.result,console.log("onupgradeneeded"),e({db:oe,type:"onupgradeneeded"})},i.onsuccess=o=>{oe=o.target.result,e({db:oe,type:"success"})},i.onerror=o=>{n(o)}})}function hl(r,t,e){return e===void 0&&(e=oe),new Promise((n,i)=>{e||i("\u6CA1\u6709db");let s=e.transaction([r],"readonly").objectStore(r).get(t);s.onsuccess=()=>{s.result?n(s.result.value):n(null)},s.onerror=a=>{console.log("[getVersionByKey]",a),n(null)}})}function M_(r,t,e,n){return n===void 0&&(n=oe),new Promise((i,o)=>(n||o("\u6CA1\u6709db"),new Promise((s,a)=>x(this,null,function*(){let u=yield hl(r,t),l=n.transaction([r],"readwrite").objectStore(r),c=u!==null?l.put({key:t,value:e}):l.add({key:t,value:e});c.onsuccess=function(p){s(p)},c.onerror=function(p){a(p)}}))))}function Ln(r,t){t===void 0&&(t=oe),t&&(t.objectStoreNames.contains(r)||t.createObjectStore(r,{keyPath:"key"}))}function w_(r){r===void 0&&(r=oe),r==null||r.close(),oe=null}var Ps=require("three");var n7=d(U(),1),r7=d(T(),1);function T_(r,t,e){switch(r.l_type){case"graph":return dL(r,t);case"wall":return gL(r,t);case"lane":return mL(r,t);case"texture2d":case"texture3d":return yL(r,t);case"glb":return vL(r,t);case"store":return _L(r,t);case"facility":return xL(r,t);case"parkingSpace":return CL(r,t,e);case"text":return AL(r,t)}}function dL(r,t){let e=t.userData.center;yt(r.elements,e);let n=[];r.elements.forEach(o=>{o.group==="ground"?t.createGround(o):n.push(o)});let i=n.reduce((o,s)=>{let{fillColor:a,fillOpacity:u,strokeColor:l,strokeOpacity:c,height:p,airHeight:h}=s,g=a.toLowerCase()+"-"+u+"-"+l.toLowerCase()+"-"+c+"-"+p+"-"+h;return c===0&&(g=a.toLowerCase()+"-"+u+"-"+p+"-"+h),o[g]?o[g].push(s):o[g]=[s],o},{});Object.values(i).forEach(o=>{let s=new Tn(t.context,o);t.mergeGraphicLayer.add(s)})}function gL(r,t){let e=t.userData.center;yt(r.elements,e);let n=r.elements.reduce((i,o)=>{let{fillColor:s,fillOpacity:a,strokeColor:u,strokeOpacity:l,height:c}=o,p=s.toLowerCase()+"-"+a+"-"+u.toLowerCase()+"-"+l+"-"+c;return l===0&&(p=s.toLowerCase()+"-"+a+"-"+c),i[p]?i[p].push(o):i[p]=[o],i},{});Object.values(n).forEach(i=>{let o=new ci(t.context,i);t.wallLayer.add(o)})}function mL(r,t){let e=t.userData.center;yt(r.elements,e);let n=r.elements.reduce((i,o)=>{let{fillColor:s,fillOpacity:a,strokeColor:u,strokeOpacity:l}=o,c=s.toLowerCase()+"-"+a+"-"+u.toLowerCase()+"-"+l;return l===0&&(c=s.toLowerCase()+"-"+a),i[c]?i[c].push(o):i[c]=[o],i},{});Object.values(n).forEach(i=>{let o=new pi(t.context,i);t.laneLayer.add(o)})}function yL(r,t){let e=t.userData.center;if(yt(r.elements,e),r.elements.length){let n=new wn(t.context,r.elements);t.textureLayer.add(n)}}function vL(r,t){let e=t.userData.center;yt(r.elements,e),r.elements.forEach(n=>{let i=new hi(t.context,E({},n,{url:n.secondUrl,rotate:n.secondRotate,width:n.secondWidth,center_x:n.center_coord_x,center_y:n.center_coord_y}));t.glbModelLayer.add(i)})}function _L(r,t){let e=t.userData.center;yt(r.elements,e),r.elements.map(n=>{let i=t.addGraphic(n);t.userData.graphics.push(i),t.userData.graphicMap.set(n.id,i);try{let o=new ot(t.context,{id:n.id,icon:n.poi_info.icon,text:n.poi_info.showName||n.store_name||n.poi_info.text,position:{x:n.center_coord_x,y:n.center_coord_y,z:n.airHeight+n.height},icon_size:[24,24],level:n.poi_info.level||0});t.poiLayer2.pushPoi(o),o&&(o.userData.type="store",o.userData.data=n,o.userData.floor=t.name)}catch(o){console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25",o,n)}})}function xL(r,t){let e=t.userData.center;yt(r.elements,e),r.elements.map(n=>{let i=t.addGraphic(n);if(t.userData.graphics.push(i),t.userData.graphicMap.set(n.id,i),n.poi_info){let o=new ot(t.context,{id:n.id,icon:n.poi_info.icon,text:n.poi_info.showName||n.store_name||n.poi_info.text,position:{x:n.center_coord_x,y:n.center_coord_y,z:n.airHeight+n.height},icon_size:[24,24],level:n.poi_info.level||0});t.poiLayer2.pushPoi(o),o.userData.type="facility",o.userData.data=n,o.userData.floor=t.name}else console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info",n)})}function CL(r,t,e){let n=t.userData.center;yt(r.elements,n),t.parkingSpaceLayer.createParkings(r.elements,e.mergeParkingSpace),r.elements.forEach(i=>{if(i.texts[0]){let o=new ot(t.context,{id:i.id,text:i.texts[0],position:{x:i.center_coord_x,y:i.center_coord_y,z:i.airHeight+i.height}});o&&(o.userData.type="parkingSpace",o.userData.data=i,o.userData.floor=t.name),t.poiLayer2.pushPoi(o)}}),t.userData.parkingSpaces=t.parkingSpaceLayer.graphicMap.values(),t.userData.parkingSpacesGraphicMap=t.parkingSpaceLayer.graphicMap}function AL(r,t){let e=t.userData.center;yt(r.elements,e);let n=new fi(t.context,r.elements.map(i=>E({},i,{center_x:i.center_coord_x,center_y:i.center_coord_y})));t.textTextureLayer.add(n)}var pl="map_version",fl="route_version",dl="facility_version",gl="map_data",Rs="road_network_data",ml="facility_data",EL={mergeParkingSpace:!0},yl=class extends Ps.EventDispatcher{initDb(){return x(this,null,function*(){try{let{db:t,type:e}=yield b_("aibee_map",2);e==="onupgradeneeded"&&(Ln(pl),Ln(fl),Ln(dl),Ln(gl),Ln(Rs),Ln(ml)),this.db=t}catch(t){console.log("[\u6253\u5F00indexDb\u9519\u8BEF]",t)}})}load(t){return x(this,null,function*(){if(Array.isArray(t))this.floors=t;else{let e=yield fetch(t).then(n=>n.json());e.code==="0"&&(this.floors=e.data.list)}})}setCacheData(t,e,n){return this.initDbPromise.then(()=>M_(t,""+e,n,this.db))}getCacheData(t,e){return this.initDbPromise.then(()=>hl(t,""+e,this.db))}getFloorCacheKey(t){return""+t.floor_id}getFloorData(t){return x(this,null,function*(){let e=yield this.getFloorJsonData(t);return e?this.getDataByJson(e):null})}getFloorDataByFloorInfo(t){return x(this,null,function*(){let e=yield this.getFloorJsonDataByFloorInfo(t);return this.getDataByJson(e)})}getFloorJsonDataByFloorInfo(t){return x(this,null,function*(){let e=this.getFloorCacheKey(t);console.time("zstd_json");let n=yield fetch(t.map_url).then(i=>i.json());return n.floor=t.floor,console.timeEnd("zstd_json"),this.setCacheData(gl,e,n),this.setCacheData(pl,e,t.version_id),n})}getFloorJsonData(t){return x(this,null,function*(){let e=this.floors.find(i=>i.floor===t);if(!e)return null;let n=this.getFloorCacheKey(e);try{if((yield this.getCacheData(pl,n))===e.version_id){let o=yield this.getCacheData(gl,n);if(o)return o}return this.getFloorJsonDataByFloorInfo(e)}catch(i){return console.log("[get floor data error]",i),this.getFloorJsonDataByFloorInfo(e)}})}getRoadNetworkData(){return x(this,null,function*(){return(yield Promise.all(this.floors.map(e=>x(this,null,function*(){let n=this.getFloorCacheKey(e);try{if((yield this.getCacheData(fl,n))===e.version_id){let s=yield this.getCacheData(Rs,n);if(s)return s}let o=yield fetch(e.route_url).then(s=>s.json());return this.setCacheData(Rs,n,o),this.setCacheData(fl,n,e.version_id),o}catch(i){let o=yield fetch(e.route_url).then(s=>s.json());return this.setCacheData(Rs,n,o),o}})))).filter(e=>e.points)})}getFacilitiesData(){return x(this,null,function*(){let t=this.floors.reduce((i,o)=>i.updated_at>o.updated_at?i:o,this.floors[0]);if(!t)return null;let e=this.getFloorCacheKey(t),n=()=>x(this,null,function*(){let i=yield fetch(t.entry_infra_url).then(o=>o.json());return i&&(this.setCacheData(ml,e,i),this.setCacheData(dl,e,t.version_id)),i});try{if((yield this.getCacheData(dl,e))===t.version_id){let o=yield this.getCacheData(ml,e);if(o)return o}return n()}catch(i){return console.log("[get facility error]",i),n()}})}getOtherDataByFreeTime(){return x(this,null,function*(){})}getMulFloorsData(t){return x(this,null,function*(){return Promise.all(t.map(e=>this.getFloorData(e))).then(e=>e.filter(n=>n))})}getDataByUrl(t){return x(this,null,function*(){let e=yield fetch(t).then(n=>n.json());return this.getDataByJson(e)})}getDataByJson(t,e){return x(this,null,function*(){return e=this.getFloorBaseLayer(t,e),this.getFloorContentLayer(t,e),this.changeFloorBox(t,e),e})}changeFloorBox(t,e){e.updateBox();let n=e.box.getSize(new Ps.Vector3),i=Math.max(n.x,n.y,n.z);e.userData.height=i/4+t.floorHeight}switchFloor(t){return x(this,null,function*(){return new Promise(e=>{let n={run:()=>this._switchFloor(t),meta:{type:"switchFloor"}},i=this.taskQueue.replaceByMetaType(n),o=s=>{let{task:a,res:u}=s;a.tid===i&&(this.taskQueue.removeEventListener("active-task-end",o),e(u))};this.taskQueue.addEventListener("active-task-end",o)})})}_switchFloor(t){return x(this,null,function*(){var e;let n=t;if(typeof t=="string"){let u=yield this.getFloorJsonData(t);if(u)n=u;else return null}let i=new Ut(this.bmap.context),o=this.floors.find(u=>u.floor===n.floor);var s;let a=(s=o==null?void 0:o.map_angle)!=null?s:0;return this.bmap.dispatchEvent({type:gt.SWITCH_FLOOR_BEFORE,data:{curFloor:i,graphics:[]}}),this.dispatchEvent({type:"switch-floor-before",data:{curFloor:i,graphics:[]}}),this.bmap.context.control.setAzimuthalAngle(a/180*Math.PI,!0),this.getFloorBaseLayer(n,i),this.bmap.buildingCenter=i.userData.center,this.bmap.currentBuildGround=(e=i.userData.data.layers.find(u=>u.l_type==="range"))==null?void 0:e.elements[0],this.getFloorContentLayer(n,i),this.changeFloorBox(n,i),this.bmap.context.switchFloor(i),this.dispatchEvent({type:"switch-floor-ground",data:{curFloor:i,graphics:[]}}),this.dispatchEvent({type:"switch-floor-after",data:{curFloor:i,graphics:i.graphicLayer.children}}),this.bmap.dispatchEvent({type:gt.SWITCH_FLOOR_AFTER,data:{curFloor:i,graphics:i.graphicLayer.children}}),i})}getFloorBaseLayer(t,e){e||(e=new Ut(this.bmap.context));let n=[0,0];return t.layers.forEach(i=>{switch(i.l_type){case"range":let o=i.elements[0];n=[o.center_x,o.center_y];break;case"ground":yt(i.elements,n);let s=i.elements.map(a=>new K(this.bmap.context,a));e.addGrounds(s);break;default:break}}),e.userData.center=n,e.name=t.floor,e.userData.data=t,e}getFloorContentLayer(t,e){e||(e=new Ut(this.bmap.context)),e.userData.graphics=[],e.userData.graphicMap=new Map;let n=Date.now();for(let i=0;i<t.layers.length;i++){let o=t.layers[i];["range","ground"].includes(o.l_type)||(T_(o,e,this.options),console.log("time",Date.now()-n,o.l_type))}return e}clear(){return x(this,null,function*(){var t;w_((t=this.db)!=null?t:void 0)})}dispose(){this.clear()}constructor(t,e={}){super(),this.bmap=t,this.floors=[],this.initDbPromise=Promise.resolve(),this.db=null,this.taskQueue=new Cn,this.options=E({},EL,e),this.initDbPromise=this.initDb()}};var m7=d(T(),1);var vl=class{load(t){return x(this,null,function*(){let e=vn(t);if(this.cacheData.has(e))return this.cacheData.get(e);let[,n]=yield Promise.all([this.loadBuildGround(t),cl(t,this.bmap.config)]),i=vn({floor:t.floor,ts:t.ts});yt(n.map(s=>s.info),this.bmap.buildingCenter,this.floorDataLengthMap.get(i)||0),n.forEach(s=>s.info.transformToBuildingGround=!1),this.cacheData.set(e,n);let o=this.floorDataLengthMap.get(i)||0;return this.floorDataLengthMap.set(i,o+n.length),this.loadExternalStreet(t),n})}loadExternalStreet(t){return x(this,null,function*(){})}switchFloorByData(t,e){if(!t.length)return;let n=e.userData.legacyToGraphicMap||new Map,i=e.userData.graphicMap||new Map,{ground:o,markGraphic:s,graphic:a}=this.bmap.config;for(let u=0;u<t.length;u++){let l=t[u];l.info.group==="ground"?(l.info.fillColor=o.color,l.info.fillOpacity=o.opacity,l.info.height=o.height,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity):l.info.userData.mark?(l.info.height=s.height,l.info.fillColor=s.color,l.info.fillOpacity=s.opacity,l.info.stroke=s.stroke,l.info.strokeColor=s.strokeColor,l.info.strokeOpacity=s.strokeOpacity):(l.info.fillOpacity=a.fillOpacity,this.bmap.config.initTransToMark&&(l.info.height=s.height,l.info.fillColor=s.color,l.info.stroke=s.stroke,l.info.strokeColor=s.strokeColor,l.info.strokeOpacity=s.strokeOpacity))}for(let u of t){if(u.info.group==="ground")e.createGround(u.info);else{let l=e.addGraphic(u.info);l.userData.data=u,n.set(u.legacy_id,l)}i.set(u.element_uuid,u)}e.userData.legacyToGraphicMap=n,e.userData.graphicMap=i,e.updateBox(),e===this.bmap.context.currentFloor?(this.bmap.triggerHooks(gt.SWITCH_FLOOR_BEFORE,{curFloor:e,graphics:e.graphicLayer.children}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks(gt.SWITCH_FLOOR_AFTER,{curFloor:e,graphics:e.graphicLayer.children})):this.bmap.switchFloorByFloor(e)}filterData(t,e){let n=e.userData.graphicMap||new Map;return t.filter(i=>!n.has(i.element_uuid))}switchFloorByStoreData(t,e){return x(this,null,function*(){let n=yield this.load(E({},t,{resource_type_list:"6"})),i=this.filterData(n,e);this.switchFloorByData(i,e)})}switchFloorByOtherData(t,e){return x(this,null,function*(){let n=yield this.load(E({},t,{resource_type_list:"1,2,3,4"})),i=this.filterData(n,e);this.switchFloorByData(i,e)})}loadBuildGround(t){return x(this,null,function*(){let{brand:e,project:n}=t,i=yield this.loadBuildingGround({brand:e,project:n});return this.bmap.currentBuildGround=i,this.bmap.changeBuildingCenter(i,{brand:e,project:n}),this.bmap.currentBuildGround})}loadBuildingGround(t){return x(this,null,function*(){let{brand:e,project:n}=t,i=vn({brand:e,project:n});if(this.buildingGroundMap.has(i))return this.buildingGroundMap.get(i);let o=ll({brand:e,project:n},this.bmap.config).then(s=>(this.buildingGroundMap.set(i,s),s));return this.buildingGroundMap.set(i,o),o})}switchFloor(t){return x(this,null,function*(){let e=new Ut(this.bmap.context);e.userData.graphicMap=new Map,e.name=t.floor;try{yield Promise.all([this.switchFloorByStoreData(t,e),this.switchFloorByOtherData(t,e)])}catch(n){console.log(n)}return e})}dispose(){this.cacheData.clear(),this.floorDataLengthMap.clear(),this.buildingGroundMap.clear()}constructor(t){this.bmap=t,this.cacheData=new Map,this.floorDataLengthMap=new Map,this.buildingGroundMap=new Map,this.externalStreetMap=new Map}};
7744
+ `],{type:"text/javascript"}),t=URL.createObjectURL(r),e=new Worker(t);return URL.revokeObjectURL(t),e}var rl=class extends f_.EventDispatcher{setRoadData(t){return x(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield ee(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,n){return x(this,null,function*(){return n===void 0&&(n=""),new Promise((i,o)=>{let s=()=>{ee(this.worker,"get_path",{start:t,end:e,type:n}).then(a=>{a?typeof a=="string"?o(a):i(a):o("no-path")})};if(this.initRoadStatus)s();else{let a=u=>{let{status:l}=u;l&&(this.removeEventListener("init-road-status",a),s())};this.addEventListener("init-road-status",a)}})})}getDirectionPath(t){return ee(this.worker,"get_direction_path",t)}dispose(){return x(this,null,function*(){ee(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=nl(),this.initRoadStatus=!1}};var Ek=d(T(),1),Sk=d(le(),1),bk=d(ce(),1),Mk=d(he(),1),wk=d(pe(),1),Tk=d(fe(),1),Ik=d(de(),1),Rk=d(ge(),1),Pk=d(U(),1);var d_=require("three"),xs=class extends Ft{setEnable(t){super.setEnable(t),dt(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:n,clientHeight:i}}}=this,o=I(this.startPoint,e,n,i),s=I(this.endPoint,e,n,i),a={x:Math.min(o.x,s.x),y:Math.min(o.y,s.y)},u={x:Math.max(o.x,s.x),y:Math.max(o.y,s.y)},l=this.searchMapInFrustum(a,u);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(o=>o instanceof K&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,n){let{context:{camera:i,container:{clientWidth:o,clientHeight:s}}}=this;if(!t)return!1;if(!t.mesh){let h=t.getPosition();if(h){let g=I(h,i,o,s);return Be(g,e,n)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let a=t.mesh.geometry.boundingBox;if(!a)return!1;let{min:u,max:l}=a,c=I(u,i,o,s),p=I(l,i,o,s);return!(!Be(c,e,n)||!Be(p,e,n))}dispose(){this.unRegistryEvent()}constructor(t){super(t),this.frustum=new d_.Frustum,this.onPointerDown=i=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(i);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=i=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(i);o&&(this.endPoint=o)},this.onPointerUp=i=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(i);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let i=this.getSvgCoordinate(this.startPoint),o=E({},i);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let s={x:Math.min(i.x,o.x),y:Math.min(i.y,o.y)},a=Math.abs(o.x-i.x),u=Math.abs(o.y-i.y);dt(this.rect,s.x,s.y,a,u)}else dt(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:n}}}=t;this.rect=Ne(n,e),this.svg.appendChild(this.rect),this.registryEvent()}};var JP={boxSelection:!1,elements:["graphic","poi"]},il=class extends qt{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=n=>{this.downPoint={x:n.offsetX,y:n.offsetY}},this.onPointerUp=n=>{if(!this.downPoint)return;let{offsetX:i,offsetY:o}=n,{x:s,y:a}=this.downPoint;if(Math.sqrt((s-i)**2+(a-o)**2)>3)return;let u=new Set,l=[],c=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(i,o);p.map(h=>u.add(h.options.id)),l.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(i,o);c.push(...p),p.forEach(h=>{if(!u.has(h.options.id)){var g;let y=((g=this.bmap.context.currentFloor)==null?void 0:g.graphicLayer.graphicMap.get(h.options.id))||null;y&&(u.add(h.options.id),l.push(y))}})}(!this.options.boxSelection||!(mn?n.metaKey:n.ctrlKey))&&(this._list.clear(),this._poiList.clear()),l.forEach(p=>this._list.add(p)),c.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=n=>{this.disableBoxSelection()},this.onKeyDown=n=>{yn(n.key)&&this.enableBoxSelection()},this.onKeyUp=n=>{yn(n.key)&&this.disableBoxSelection()},this.onBoxSelected=n=>{let{list:i}=n;this._list.clear(),this._poiList.clear(),i.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let s=this.bmap.getPoiById(o.options.id);s&&this._poiList.add(s)}}),this.selectEnd()},this.options=E({},JP,e),this.boxSelection=new xs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var Fk=d(U(),1),Mt=require("lodash");var g_=require("three");var X=function(r){return r.COMPASS="compass",r.DEVICE_MOTION="deviceMotion",r.ACCELERATION="acceleration",r.GPS="gps",r}({});var ZP={time:1e3,elements:[X.COMPASS,X.DEVICE_MOTION,X.ACCELERATION,X.GPS]},yi=class extends g_.EventDispatcher{start(){this.options.elements.some(t=>[X.DEVICE_MOTION,X.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(X.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(X.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,Mt.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){Jn?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{this.addDataItem({type:X.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return x(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return x(this,null,function*(){var t;if(!Jn)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(n){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),Jn?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,Mt.isNil)(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new Z,this.dispatchTimer=null,this.addAcceleration=(0,Mt.throttle)(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=(0,Mt.throttle)(e=>{let n=Date.now(),{alpha:i,beta:o,gamma:s}=e;if((0,Mt.isNil)(i)||(0,Mt.isNil)(o)||(0,Mt.isNil)(s))return;let a;Jn?a=e.webkitCompassHeading:a=360-i,this.options.elements.includes(X.DEVICE_MOTION)&&this.addDataItem({type:X.DEVICE_MOTION,timestamp:n,res:[i,o,s]}),this.options.elements.includes(X.COMPASS)&&this.addDataItem({type:X.COMPASS,timestamp:n,res:a})},200),this.handleAcceleration=e=>{let n=e.accelerationIncludingGravity;(0,Mt.isNil)(n)||(0,Mt.isNil)(n.x)||(0,Mt.isNil)(n.y)||(0,Mt.isNil)(n.z)||this.addAcceleration({type:X.ACCELERATION,timestamp:Date.now(),res:[n.x,n.y,n.z]})},this.options=E({},ZP,t)}};var iG=d(T(),1),y_=require("three");var Jk=d(U(),1);var Vk=d(U(),1),Xk=d(T(),1);function Cs(r,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(r,2)/(2*Math.pow(t,2)))}function vi(r){return(r+360)%360}function m_(r,t){let n=6378137*r*Math.PI/180,i=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:n,y:i}}function cr(r,t,e,n){return Math.sqrt(Math.pow(Math.abs(r-e),2)+Math.pow(Math.abs(t-n),2))}var Es=require("mathjs"),As=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=vi(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let n=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+n,this.particleX[2][e]=vi(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let i=0;i<this.NumParticle;i++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][i]+=(.65+o)*Math.sin(-this.particleX[2][i]/180*Math.PI),this.particleX[1][i]+=(.65+o)*Math.cos(this.particleX[2][i]/180*Math.PI),e(this.particleX[0][i],this.particleX[1][i])||(this.particleWeight[0][i]*=this.unaccess_weight)}let n=this.particleWeight[0].reduce((i,o)=>i+o,0);this.particleWeight[0]=this.particleWeight[0].map(i=>i/n)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let n=360-t;n+=this.delta_yaw,n=vi(n),Math.abs(n-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let s=Math.abs(this.particleX[2][o]-n);s>180&&(s=360-s),this.particleWeight[0][o]*=Cs(s,this.sigmaCompass)}let i=this.particleWeight[0].reduce((o,s)=>o+s,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/i),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,n)=>e+n*n,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((a,u,l)=>a.concat(a[l]+u),[0]),i=this.particleWeight[0].map(()=>1/this.NumParticle).map((a,u)=>a+Math.random()/this.NumParticle),o=[],s=0;for(let a=0;a<this.NumParticle;a++){for(;i[a]>e[s];)s++;o.push(s)}this.particleX=this.particleX.map((a,u)=>o.map(l=>a[l])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let i=0;i<this.NumParticle;i++){let o=cr(this.particleX[0][i],this.particleX[1][i],t.x,t.y);this.particleWeight[0][i]=Math.max(1e-7,this.particleWeight[0][i]*Cs(o,e))}let n=this.particleWeight[0].reduce((i,o)=>i+o,0);this.particleWeight[0]=this.particleWeight[0].map(i=>i/n)}updateCar(t,e){let n=t.x-this.xEst[0][0],i=t.y-this.xEst[1][0];for(let s=0;s<this.NumParticle;s++){let a=cr(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*Cs(a,e)),this.particleX[0][s]+=n,this.particleX[1][s]+=i}let o=this.particleWeight[0].reduce((s,a)=>s+a,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=(0,Es.reshape)(this.particleWeight,[this.NumParticle,1]),e=(0,Es.multiply)(this.particleX,t);return this.xEst=e,this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),n=[this.particleX[0][t],this.particleX[1][t]],i=[this.particleX[0][e],this.particleX[1][e]],o=cr(n[0],n[1],i[0],i[1]),s=o*.67;return console.log(o,s),s}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,n){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let i=0;for(;i<this.NumParticle;){let s=(2*Math.random()-1)*this.initial_xy_uncertainty,a=(2*Math.random()-1)*this.initial_xy_uncertainty;n(t+s,e+a)||(this.particleWeight[0][i]*=this.unaccess_weight),this.particleX[0][i]=t+s,this.particleX[1][i]=e+a,i++}let o=this.particleWeight[0].reduce((s,a)=>s+a,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=vi(e),console.log("Init Yaw: "+e);for(let n=0;n<this.NumParticle;n++){let i=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][n]=e+i}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};var Wk=d(U(),1),Qk=d(T(),1),Ss=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,n){let i=0;return n.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,n)),e.length===3&&(i=this.getStepLength(t,e)),i!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let n=!1,i=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(i),this.accH_time_fifo.push(t),this.imuFreUpdate(),this.accH_fifo.length<this.accH_fifo_len+1)n=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let o=this.PVStepDetec(),s=this.FFTStepDetec(),a=this.recheckState(),u=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=u:this.abnor_fft_detected||(this.abnor_start_time=0),o&&s&&a?(this.step_count+=1,this.last_step_time=u,n=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=u,n=!0):(u-this.last_step_time>2&&(this.state_count=0),n=!1)}if(n){let o=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(o),this.delta_py=this.const_step_length*Math.sin(o),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),n=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=e[Math.floor(e.length/2)],o=n[Math.floor(n.length/2)],s=Math.max(...e),a=Math.min(...e),u=!1,l=!1;return Math.abs(i-a)<.01&&i<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?l=!0:l=o-this.last_valley_time>this.min_step_time,l&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(i-s)<.01&&i>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?u=!0:u=o-this.last_peak_time>this.min_step_time,u&&(this.last_peak_time=o,this.peak_num+=1)),i===s&&i>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=i),this.peak_num===this.valley_num&&(u||l)&&(t=!0),t}FFTStepDetec(){return!0}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let n=[0,0,0];this.last_rot.length===3&&(n=e.map((a,u)=>a-this.last_rot[u]));for(let a=0;a<e.length;a++)n[a]<-180?n[a]+=360:n[a]>180&&(n[a]-=360);let i=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((a,u)=>i*a+(1-i)*n[u]):this.delta_rot=n,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((a,u)=>a+Math.abs(u),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let s=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(s=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,s):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0}};var tL={using_gps:!0},bs=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:n,res:i}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===X.ACCELERATION){let s=i,a=this.pdr.getStepLength(n/1e3,s);a!==0&&(this.particleFilter.motionModelStepLength(a,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===X.GPS&&(this.last_beacon_time===null||n-this.last_beacon_time>5e3)){let s=this.getGpsPosition(i);o=s!==null,s&&(this.particleFilter.update(s,this.gps_horizontalAccuracy),this.resetParticleFilterDist(s,"gps",i[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}if(e===X.DEVICE_MOTION){let s=this.pdr.getDeltaYawFromRot(n/1e3,i);s!==null&&this.particleFilter.motionModelRotYaw(s)}e===X.COMPASS&&this.particleFilter.motionModelCompassYaw(i,n),this.last_pos_time&&n-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===X.GPS){let s=this.getGpsPosition(i);o=s!==null,console.log("gps_pos",s,i),s?(this.particleFilter.initParticlesByPos(s.x,s.y,()=>!0),this.last_pos_time=n,console.log("init Pos by gps success time "+n),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+n)}else if(!this.particleFilter.getYawInitFlag()&&e===X.COMPASS){let s=i;this.particleFilter.initParticlesByCompass(s),this.particleFilter.setLastCompassTime(n),console.log("init yaw by compass success time "+n)}return o&&(this.last_pos_time=n),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let n=this.cacheSensorData.filter(i=>i.timestamp>e);console.log("\u521D\u59CBsensorData",n),n.map(i=>this.pfFusionPDRiBeacon(i))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:m_(t[0],t[1])}resetParticleFilterDist(t,e,n){let i=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),s=cr(i,o,t.x,t.y);(e==="gps"?n&&s>n||s>this.GpsMaxEstimateErr:s>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0)):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=null,this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=4,this.cacheSensorData=[];let e=E({},tL,t);this.using_gps=e.using_gps,this.particleFilter=new As({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new Ss}};var ol=class extends y_.EventDispatcher{checkSensor(){return this.sensor.checkSensor()}start(){this.sensor.start(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[n,i,o]=this.pdr.pfFusionPDRiBeacon(t);return n&&e&&this.dispatchEvent({type:"position",x:i,y:o,_type:t.type===X.GPS?"gps":"pdr"}),[n,i,o]}setBeaconPosition(t,e){let[n,i]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:n,y:i,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t={}){super(),this._pause=!1,this.sensor=new yi(t.sensor),this.pdr=new bs(t.pdr||{})}};var xG=d(T(),1),CG=d(U(),1);var lG=d(T(),1),cG=d(U(),1),ut=require("three");var v_={texture_url:is,lineWidth:8,color:16777215},Ms=class extends ut.Object3D{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:n,height:i}}}}}=this,o=t.map(a=>{let[u,l,c]=a;return I(new ut.Vector3(u,l,c),e,n,i)}).map(a=>{let{x:u,y:l}=a;return[u,l]});return Bt(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new ut.Vector2(t,1)}loadTexture(t){return new Promise((e,n)=>{new ut.TextureLoader().load(t,e,void 0,n)})}transformPoints(t){let e=[];for(let n=0;n<t.length;n++)e.push(...t[n]);return e}updatePoints(t){this.points=t,this.changeRepeat();let e=this.transformPoints(t);this.geometry&&this.geometry.setPoints(e)}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return x(this,null,function*(){let e=this.geometry=new Ct;if(this.updatePoints(t),!this.texture){let o=this.texture=yield this.loadTexture(this.config.texture_url);o.wrapS=o.wrapT=ut.RepeatWrapping}let n=this.material=new Pn({useMap:!0,color:new ut.Color(this.config.color),transparent:!0,resolution:new ut.Vector2(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,sizeAttenuation:!1,lineWidth:this.config.lineWidth*2,map:this.texture,blending:ut.NormalBlending,repeat:new ut.Vector2(this.getRepeat(),1)}),i=this.mesh=new ut.Mesh(e,n);return i.renderOrder=9,this.add(i),i})}dispose(){var t,e,n;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(n=this.texture)==null||n.dispose()}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=v_,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let n=this.navigation.bmap.context.camera.zoom;n!==this.prevCameraZoom&&(this.prevCameraZoom=n,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:n,height:i}=this.navigation.bmap.context.clientSize;this.material.resolution.set(n,i)}},this.config=Object.assign({},v_,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};var __=require("@tweenjs/tween.js");var J=require("three"),ws=class extends J.Object3D{getBaseScale(t){let{clientSize:{width:e,height:n},camera:i}=this.bmap.context,o=new J.Box3().setFromObject(t),{max:s,min:a}=o,u=new J.Vector3(a.x,s.y,s.z),l=new J.Vector3(s.x,s.y,s.z),c=new J.Vector3(s.x,a.y,a.z),p=new J.Vector3(a.x,a.y,a.z),h=I(u,i,e,n),g=I(l,i,e,n),y=I(p,i,e,n),v=I(c,i,e,n),C=new J.Box2().setFromPoints([new J.Vector2(h.x,h.y),new J.Vector2(g.x,g.y),new J.Vector2(y.x,y.y),new J.Vector2(v.x,v.y)]).getSize(new J.Vector2),b=40/C.x,R=40/C.y,B=Math.min(b,R),P=i.zoom;return B*P}registryEvent(){this.bmap.context.addEventListener("update",this._update),this.bmap.context.addEventListener("control-zoom-change",this._onChangeZoom)}unRegistryEvent(){this.bmap.context.removeEventListener("update",this._update),this.bmap.context.removeEventListener("control-zoom-change",this._onChangeZoom)}printGraph(t){console.group(" <"+t.type+"> "+t.name),t.children.forEach(e=>this.printGraph(e)),console.groupEnd()}setClips(t){this.clearClips(),t.length&&(this.mixer=new J.AnimationMixer(this.model.scene),t.forEach(e=>this.mixer.clipAction(e).play()))}startClips(){var t;this.setClips(((t=this.model)==null?void 0:t.animations)||[])}clearClips(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null)}dispose(){this.unRegistryEvent(),this.clearClips(),this.clear(),this.model&&tt(this.model.scene)}constructor(t,e){super(),this.bmap=t,this.group=new J.Object3D,this.mixer=null,this.previewTime=0,this.basicScale=1,this._update=()=>{let n=Date.now();if(!this.previewTime)this.previewTime=n;else{var i;let o=n-this.previewTime;this.previewTime=n,(i=this.mixer)==null||i.update(o/1e3)}},this._onChangeZoom=n=>{let{zoom:i}=n;var o;let s=this.basicScale/i;(o=this.model)==null||o.scene.scale.set(s,s,s)},this.add(this.group),Ht.loadModel(e,!1).then(n=>{this.model=n;let i=this.getBaseScale(n.scene);this.basicScale=i;let o=this.bmap.context.camera.zoom;n.scene.scale.set(i/o,i/o,i/o),this.group.add(n.scene),this.setClips(n.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};var _i=require("three"),x_=require("lodash");var sl=class extends qt{registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate)}pauseAnimation(){this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue()}clearTween(){this.tweenUtil.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate)}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.movedDistance=0,this.clearTween()),this.startModel&&(this.startModel.visible=!1),this.translatePath=null}addPath(t){this.paths=t;let e=t.map(n=>E({},n,{points:this.translatePoints(n.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(e);else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(e)};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,n]=this.bmap.buildingCenter;return t.map(i=>[i[0]-e,i[1]-n])}renderPath(t){if(!t.length)return this.clearPath();let e=[];t.forEach((n,i,o)=>{let s=this.catmullRomCurve3(n.points),a=this.mulFloor.floors.find(u=>u.name===n.floor);if(e.push(...s.map(u=>{let[l,c]=u;return[l,c,a.position.z+a.groundMaxHeight]})),i!==o.length-1){let u=this.mulFloor.floors.find(l=>l.name===o[i+1].floor);e.push([...o[i+1].points[0],u.position.z])}}),this.cPath=e,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(e):(this.path=new Ms(this),this.path.create(e),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(e[0][0],e[0][1],e[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return kr(t,!1,!0,.1,170,2.5)}getPathDirection(t,e){if(t.length<2)return null;let n=ye(t,e),i=t[n],o=t[n+1],s=new _i.Vector3(o[0]-i[0],o[1]-i[1],0).normalize(),a=new _i.Vector3(0,1,0).normalize(),u=s.angleTo(a),l=new _i.Vector3().crossVectors(a,s);return(Object.is(l.y,0)?-1:1)*u}startSimulation(t){return x(this,null,function*(){t===void 0&&(t=1);let{paths:e,movedDistance:n}=this;if(!e.length)return;let i=e.reduce((s,a)=>s+a.distance,0);if(!i||n>=i)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let o=i/t;return this.startModel.startClips(),new Promise(s=>{let a=this.simulationTween=new __.Tween({distance:this.movedDistance},this.tweenUtil.group).to({distance:i},o*1e3).onUpdate(u=>{var l;this.movedDistance=u.distance;let c=u.distance,p=0;for(let C=0;C<e.length;C++)if(e[C].distance>=c){p=C;break}else c-=e[C].distance;let h=_n(e[p].points,c);if(h===null)return;this.currentPathPosition=h;let g=this.translatePoints([h])[0],y=this.mulFloor.floors.find(C=>C.name===e[p].floor),v=y?y.position.z+y.groundMaxHeight:(l=this.startModel)==null?void 0:l.position.z;this.startModel&&this.startModel.position.set(g[0],g[1],v);let _=this.getPathDirection(e[p].points,h);(0,x_.isNil)(_)||this.startModel.setRotationFromAxisAngle(new _i.Vector3(0,0,1),_)}).onComplete(()=>{this.tweenUtil.remove(a),this.startModel.clearClips(),s(!0)}).start()})})}setStartPoiRotate(t){if(this.startPoi){let n=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-n)%360}}dispose(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.startModel&&(this.bmap.context.scene.remove(this.startModel),this.startModel.dispose()),this.tweenUtil.dispose(),this.unRegistryEvent()}constructor(t,e){super(t),this.mulFloor=e,this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.pathTween=null,this.startPoi=null,this.movedDistance=0,this.tweenUtil=new Oe,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new ws(t,Tv),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};var hr=require("three");var al=class extends hr.EventDispatcher{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose()}constructor(t,e){super(),this.bmap=t,this.mulFloors=e,this._click=n=>{let{e:i}=n;if(!this.mulFloors.showStatus)return;let o=new hr.Vector2,{offsetX:s,offsetY:a}=i,{clientSize:u}=this.bmap.context;o.x=s/u.width*2-1,o.y=a/u.height*-2+1;let l=new hr.Raycaster;l.setFromCamera(o,this.bmap.context.camera),l.ray.origin.sub(l.ray.direction.clone().multiplyScalar(1e4));let p=this.mulFloors.poiLayer.pois.map(g=>{if(!g.canSelect)return null;let y=l.intersectObjects(g.children,!0);return y.length?y[0]:null}).reduce((g,y)=>y&&(!g||y.distance<g.distance)?y:g,null),h=p==null?void 0:p.object;p&&p.object.isSprite&&(h=p.object.parent),h&&h instanceof ot&&this.dispatchEvent({type:"select",pois:[h]})},this.clickHelper=new Xr(this.bmap.context.container),this.registryEvent()}};var VG=d(C_(),1),XG=d(A_(),1),qG=d(U(),1),S_=require("three");var UG=d(T(),1),FG=d(U(),1),$G=d(gu(),1),pr=require("three");function aL(r){let t=r.length,e=0,n=0,i=0,o=0;r.forEach(u=>{e+=u[0],n+=u[1],i+=u[0]*u[1],o+=u[0]*u[0]});let s=(t*i-e*n)/(t*o-e*e),a=(n-s*e)/t;return{m:s,b:a}}function uL(r,t,e){let n=e[0][0],i=e.slice(-1)[0][0],o=r*n+t,s=r*i+t;return{start:[n,o],end:[i,s]}}function xi(r){if(r.length<2)return null;let t=r.filter((u,l)=>{let c=[...r];return c.splice(l,1),c.every(p=>p[0]!==u[0]&&p[1]!==u[1])});if(t.length<2)return null;let{m:e,b:n}=aL(t),{start:i,end:o}=uL(e,n,t),a=360-(new pr.Vector2().subVectors(new pr.Vector2(o[0],o[1]),new pr.Vector2(i[0],i[1])).angle()/Math.PI*180-90+360)%360;return Number.isNaN(a)?null:a}function lL(r){let t=[];for(let e=1;e<r.length;e++){let n=r[e-1],i=r[e],o=i.position[0]-n.position[0],s=i.position[1]-n.position[1],a=Math.sqrt(o**2+s**2),u=i.time-n.time;if(u>0){let l=a/u;console.log("speedDelta",n.type,i.type,Ts(l),a,u),t.push(l)}else t.push(0)}return t}function cL(r,t){let e=r[0],n=r.slice(-1)[0],i=k(n.position,e.position),o=n.time-e.time;return o<100||i<3?null:i/o}function Ts(r){return r*60*60}function fr(r,t,e,n){let i=(e+90)%360*(Math.PI/180),o=t*n,s=new pr.Vector2(r[0],r[1]),a=Math.cos(i),u=Math.sin(i),l=new pr.Vector2(a,u);return s.add(l.normalize().multiplyScalar(o)),[s.x,s.y]}function hL(r){let t=[...r].sort((l,c)=>l-c),e=E_(t,25),n=E_(t,75),i=n-e,o=e-1.5*i,s=n+1.5*i,a=t.filter(l=>l>=o&&l<=s);return r.filter(l=>a.includes(l))}function E_(r,t){let e=t/100*(r.length-1),n=Math.floor(e),i=Math.ceil(e);if(n===i)return r[n];let o=e-n;return r[n]*(1-o)+r[i]*o}var Is=class{filter(t){let e=this.estimate,n=this.errorEstimate+this.processNoise,i=n/(n+this.measurementNoise);return this.estimate=e+i*(t-e),this.errorEstimate=(1-i)*n,this.estimate}constructor(t={}){this.estimate=0,this.errorEstimate=1,this.processNoise=.1,this.measurementNoise=1,this.measurementNoise=t.measurementNoise||1,this.processNoise=t.processNoise||.1,this.errorEstimate=t.errorEstimate||1}};var Ci=require("lodash"),ul=class extends S_.EventDispatcher{setPathAngle(t){this.pathAngle=t,this.dispatchEvent({type:"change-compass",value:this.pathAngle}),(0,Ci.isNil)(this.angle)&&(this.angle=t)}changeSpeed(){let t=this.history.filter(u=>["vision"].includes(u.type));if(t.length<2){this.speedFilter.filter(0),this.speed=0;return}let e=t[0],n=t.slice(-1)[0],i=k(n.position,e.position),o=n.time-e.time,s=o>0?i/o:0,a=this.speedFilter.filter(s);this.speed=a}changeAngle(t){t===void 0&&(t=this.visionHistory),t.length<2&&(this.angle=null);let e=xi(t.map(n=>n.position));e!==null&&this.setAngle(e)}setAngle(t,e){e===void 0&&(e=!0),this.angle=t,e&&this.dispatchEvent({type:"change-position-compass",value:t})}setPosition(t,e,n){let i={position:t,time:e,clientTime:Date.now()-n,type:"vision"};if(this._setVisionHistoryForAngle(i),(0,Ci.isNil)(this.angle)||!this.speed){this.addHistory(i);return}let o=this.history.findLastIndex(a=>a.type==="vision"),s=this.history[o];if(s){if(s.time>e)return;let a=xi([this.history.slice(-1)[0].position,t]);if(a&&Math.abs(a-this.angle)<60){this.addHistory(i);return}let u=fr(t,this.speed,360-this.pathAngle,n);k(u,this.history.slice(-1)[0].position)>10?this.visionExcessesCount++:this.visionExcessesCount=0,this.visionExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21\u89C6\u89C9\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528\u89C6\u89C9\u6821\u51C6"),this.addHistory(i),this.visionExcessesCount=0)}}resetPdrPosition(){let t=this.history.findLast(e=>e.type==="vision");if(t&&this.speed){let e=fr(t.position,this.speed,360-this.pathAngle,Date.now()-t.clientTime);e&&this.history.push({position:e,time:Date.now(),clientTime:Date.now(),type:"pdr"})}}getLastVisionPdrPos(){let t=this.history.findLastIndex(n=>n.type==="vision");if(t!==-1){var e;return(e=this.history[t+1])!=null?e:this.history[t]}return null}_setVisionHistoryForAngle(t){if(!this.visionHistory.length){this.visionHistory.push(t);return}let e=xi([this.visionHistory.slice(-1)[0].position,t.position]);if(e!==null&&(this.angle&&Math.abs(this.angle-e)>60?this.angleExcessesCount++:(this.angleExcessesCount=0,this.visionHistory.push(t))),this.angleExcessesCount>3)console.warn("\u8FDE\u7EED\u4E09\u6B21\u89D2\u5EA6\u6BD4\u8F83\u6B6A\uFF0C\u91CD\u65B0\u77EB\u6B63"),this.visionHistory=[t],this.angleExcessesCount=0;else{let n=k(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position);for(;n>5&&this.visionHistory.length>15;)this.visionHistory.shift(),n=k(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position)}this.changeAngle()}addHistory(t){this.history.push(t);let e=this.history.filter(a=>a.type==="vision"),n=e.length?Date.now()-e.slice(-1)[0].clientTime:0,i=k(this.history[0].position,this.history.slice(-1)[0].position),o=n>5e3?10:3,s=n>5e3?0:5;for(n>5e3&&console.warn("\u89C6\u89C9\u7ED3\u679C\u8D85\u51FA5s\u4E0D\u53EF\u7528\uFF0C\u5168\u90E8\u6E05\u7A7A");e.length>s&&i>o;)this.history.shift(),e=this.history.filter(a=>a.type==="vision"),i=k(this.history[0].position,this.history.slice(-1)[0].position);s===0?this.changeSpeed():t.type==="vision"&&this.changeSpeed(),this.changePosition(t.type)}setBeaconPosition(t,e,n){let i=Date.now()-n,o={position:t,time:e,clientTime:i,type:"beacon"},s=this.history.findLastIndex(c=>c.type!=="pdr"),a=this.history[s];if(!a){this.addHistory(o);return}if((0,Ci.isNil)(this.pathAngle)||!this.speed){this.addHistory(o);return}if(a&&a.time>e)return;let u=fr(t,this.speed,360-this.pathAngle,n);k(u,this.history.slice(-1)[0].position)>5?this.beaconExcessesCount++:this.beaconExcessesCount=0,this.beaconExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21beacon\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528beacon\u6821\u51C6"),this.addHistory(o),this.beaconExcessesCount=0)}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=this.timer.setInterval(()=>{this.changePosition()},20)}changePosition(t){t===void 0&&(t="pdr");let e=this.getPosition(t);e.success&&(this.history.push({position:e.pos,time:Date.now(),clientTime:Date.now(),type:"pdr"}),this.speed?this.dispatchEvent({type:"change-pos",value:E({},e)}):this.dispatchEvent({type:"change-pos",value:e}))}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let e=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};if((0,Ci.isNil)(this.pathAngle)||!this.speed)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};let n=e.clientTime,i=Date.now()-n;return{success:!0,pos:this.pathAngle?fr(e.position,this.speed,360-this.pathAngle,i):e.position,compass:this.pathAngle,speed:Ts(this.speed)}}dispose(){this.timer.dispose()}constructor(){super(),this.history=[],this.visionHistory=[],this.speed=0,this.angle=null,this.timer=new Z,this.positionTimer=null,this.speedFilter=new Is,this.visionExcessesCount=0,this.beaconExcessesCount=0,this.angleExcessesCount=0,this.pathAngle=0,this.startPositionTimer()}};function ll(r,t){return x(this,null,function*(){let{brand:e,project:n}=r,{apiDomain:i,apiPath:{floorRange:o},apiInfo:s}=t,a=""+i+o+"?brand="+e+"&project="+n+"&phase="+n+"&building="+n;return yield fetch(a,s).then(l=>l.json()).then(l=>l.data).then(l=>{let c=(l||[])[0];return c&&(c.info=JSON.parse(c.info)),c})})}function cl(r,t){return x(this,null,function*(){let{brand:e,project:n,floor:i,ts:o,resource_type_list:s}=r,{apiDomain:a,apiPath:{floorGraphic:u},apiInfo:l}=t,c=""+a+u+"?brand="+e+"&project="+n+"&phase="+n+"&building="+n+"&floor="+i+"&ts="+o+"&resource_type_list="+s;return yield fetch(c,l).then(h=>h.json()).then(h=>h.data).then(h=>((h||[]).map(g=>g.info=JSON.parse(g.info)),h||[]))})}function pL(r,t){return x(this,null,function*(){let{project:e,floor:n}=r,{apiDomain:i,apiInfo:o}=t,s=i+"/api/inception-map/external_street/get?projectCode="+e+"&floorCode="+n;return yield fetch(s,o).then(u=>u.json()).then(u=>u.data).then(u=>JSON.parse(u[0].streetInfo||"{}")).then(u=>u.fileId?fL(u.fileId,t):null)})}function fL(r,t){return x(this,null,function*(){let{apiDomain:e,apiInfo:n}=t;return fetch(e+"/api/inception-map/file/getFileStream?fileId="+r,n).then(i=>i.arrayBuffer()).then(i=>{let s=new TextDecoder("utf-8").decode(i);return s?JSON.parse(s):null})})}var u7=d(T(),1);var oe;function b_(r,t){return r===void 0&&(r="aibee_map"),t===void 0&&(t=1),new Promise((e,n)=>{if(oe)return e({db:oe,type:"success"});let i=indexedDB.open(r,t);i.onupgradeneeded=function(o){oe=o.target.result,console.log("onupgradeneeded"),e({db:oe,type:"onupgradeneeded"})},i.onsuccess=o=>{oe=o.target.result,e({db:oe,type:"success"})},i.onerror=o=>{n(o)}})}function hl(r,t,e){return e===void 0&&(e=oe),new Promise((n,i)=>{e||i("\u6CA1\u6709db");let s=e.transaction([r],"readonly").objectStore(r).get(t);s.onsuccess=()=>{s.result?n(s.result.value):n(null)},s.onerror=a=>{console.log("[getVersionByKey]",a),n(null)}})}function M_(r,t,e,n){return n===void 0&&(n=oe),new Promise((i,o)=>(n||o("\u6CA1\u6709db"),new Promise((s,a)=>x(this,null,function*(){let u=yield hl(r,t),l=n.transaction([r],"readwrite").objectStore(r),c=u!==null?l.put({key:t,value:e}):l.add({key:t,value:e});c.onsuccess=function(p){s(p)},c.onerror=function(p){a(p)}}))))}function Ln(r,t){t===void 0&&(t=oe),t&&(t.objectStoreNames.contains(r)||t.createObjectStore(r,{keyPath:"key"}))}function w_(r){r===void 0&&(r=oe),r==null||r.close(),oe=null}var Ps=require("three");var n7=d(U(),1),r7=d(T(),1);function T_(r,t,e){switch(r.l_type){case"graph":return dL(r,t);case"wall":return gL(r,t);case"lane":return mL(r,t);case"texture2d":case"texture3d":return yL(r,t);case"glb":return vL(r,t);case"store":return _L(r,t);case"facility":return xL(r,t);case"parkingSpace":return CL(r,t,e);case"text":return AL(r,t)}}function dL(r,t){let e=t.userData.center;yt(r.elements,e);let n=[];r.elements.forEach(o=>{o.group==="ground"?t.createGround(o):n.push(o)});let i=n.reduce((o,s)=>{let{fillColor:a,fillOpacity:u,strokeColor:l,strokeOpacity:c,height:p,airHeight:h}=s,g=a.toLowerCase()+"-"+u+"-"+l.toLowerCase()+"-"+c+"-"+p+"-"+h;return c===0&&(g=a.toLowerCase()+"-"+u+"-"+p+"-"+h),o[g]?o[g].push(s):o[g]=[s],o},{});Object.values(i).forEach(o=>{let s=new Tn(t.context,o);t.mergeGraphicLayer.add(s)})}function gL(r,t){let e=t.userData.center;yt(r.elements,e);let n=r.elements.reduce((i,o)=>{let{fillColor:s,fillOpacity:a,strokeColor:u,strokeOpacity:l,height:c}=o,p=s.toLowerCase()+"-"+a+"-"+u.toLowerCase()+"-"+l+"-"+c;return l===0&&(p=s.toLowerCase()+"-"+a+"-"+c),i[p]?i[p].push(o):i[p]=[o],i},{});Object.values(n).forEach(i=>{let o=new ci(t.context,i);t.wallLayer.add(o)})}function mL(r,t){let e=t.userData.center;yt(r.elements,e);let n=r.elements.reduce((i,o)=>{let{fillColor:s,fillOpacity:a,strokeColor:u,strokeOpacity:l}=o,c=s.toLowerCase()+"-"+a+"-"+u.toLowerCase()+"-"+l;return l===0&&(c=s.toLowerCase()+"-"+a),i[c]?i[c].push(o):i[c]=[o],i},{});Object.values(n).forEach(i=>{let o=new pi(t.context,i);t.laneLayer.add(o)})}function yL(r,t){let e=t.userData.center;if(yt(r.elements,e),r.elements.length){let n=new wn(t.context,r.elements);t.textureLayer.add(n)}}function vL(r,t){let e=t.userData.center;yt(r.elements,e),r.elements.forEach(n=>{let i=new hi(t.context,E({},n,{url:n.secondUrl,rotate:n.secondRotate,width:n.secondWidth,center_x:n.center_coord_x,center_y:n.center_coord_y}));t.glbModelLayer.add(i)})}function _L(r,t){let e=t.userData.center;yt(r.elements,e),r.elements.map(n=>{let i=t.addGraphic(n);t.userData.graphics.push(i),t.userData.graphicMap.set(n.id,i);try{let o=new ot(t.context,{id:n.id,icon:n.poi_info.icon,text:n.poi_info.showName||n.store_name||n.poi_info.text,position:{x:n.center_coord_x,y:n.center_coord_y,z:n.airHeight+n.height},icon_size:[24,24],level:n.poi_info.level||0});t.poiLayer2.pushPoi(o),o&&(o.userData.type="store",o.userData.data=n,o.userData.floor=t.name)}catch(o){console.log("\u521B\u5EFA\u5E97\u94FApoi\u5931\u8D25",o,n)}})}function xL(r,t){let e=t.userData.center;yt(r.elements,e),r.elements.map(n=>{let i=t.addGraphic(n);if(t.userData.graphics.push(i),t.userData.graphicMap.set(n.id,i),n.poi_info){let o=new ot(t.context,{id:n.id,icon:n.poi_info.icon,text:n.poi_info.showName||n.store_name||n.poi_info.text,position:{x:n.center_coord_x,y:n.center_coord_y,z:n.airHeight+n.height},icon_size:[24,24],level:n.poi_info.level||0});t.poiLayer2.pushPoi(o),o.userData.type="facility",o.userData.data=n,o.userData.floor=t.name}else console.log("\u6DFB\u52A0facility\u5931\u8D25\u6CA1\u6709poi_info",n)})}function CL(r,t,e){let n=t.userData.center;yt(r.elements,n),t.parkingSpaceLayer.createParkings(r.elements,e.mergeParkingSpace),r.elements.forEach(i=>{if(i.texts[0]){let o=new ot(t.context,{id:i.id,text:i.texts[0],position:{x:i.center_coord_x,y:i.center_coord_y,z:i.airHeight+i.height}});o&&(o.userData.type="parkingSpace",o.userData.data=i,o.userData.floor=t.name),t.poiLayer2.pushPoi(o)}}),t.userData.parkingSpaces=t.parkingSpaceLayer.graphicMap.values(),t.userData.parkingSpacesGraphicMap=t.parkingSpaceLayer.graphicMap}function AL(r,t){let e=t.userData.center;yt(r.elements,e);let n=new fi(t.context,r.elements.map(i=>E({},i,{center_x:i.center_coord_x,center_y:i.center_coord_y})));t.textTextureLayer.add(n)}var pl="map_version",fl="route_version",dl="facility_version",gl="map_data",Rs="road_network_data",ml="facility_data",EL={mergeParkingSpace:!0},yl=class extends Ps.EventDispatcher{initDb(){return x(this,null,function*(){try{let{db:t,type:e}=yield b_("aibee_map",2);e==="onupgradeneeded"&&(Ln(pl),Ln(fl),Ln(dl),Ln(gl),Ln(Rs),Ln(ml)),this.db=t}catch(t){console.log("[\u6253\u5F00indexDb\u9519\u8BEF]",t)}})}load(t){return x(this,null,function*(){if(Array.isArray(t))this.floors=t;else{let e=yield fetch(t).then(n=>n.json());e.code==="0"&&(this.floors=e.data.list)}})}setCacheData(t,e,n){return this.initDbPromise.then(()=>M_(t,""+e,n,this.db))}getCacheData(t,e){return this.initDbPromise.then(()=>hl(t,""+e,this.db))}getFloorCacheKey(t){return""+t.floor_id}getFloorData(t){return x(this,null,function*(){let e=yield this.getFloorJsonData(t);return e?this.getDataByJson(e):null})}getFloorDataByFloorInfo(t){return x(this,null,function*(){let e=yield this.getFloorJsonDataByFloorInfo(t);return this.getDataByJson(e)})}getFloorJsonDataByFloorInfo(t){return x(this,null,function*(){let e=this.getFloorCacheKey(t);console.time("zstd_json");let n=yield fetch(t.map_url).then(i=>i.json());return n.floor=t.floor,console.timeEnd("zstd_json"),this.setCacheData(gl,e,n),this.setCacheData(pl,e,t.version_id),n})}getFloorJsonData(t){return x(this,null,function*(){let e=this.floors.find(i=>i.floor===t);if(!e)return null;let n=this.getFloorCacheKey(e);try{if((yield this.getCacheData(pl,n))===e.version_id){let o=yield this.getCacheData(gl,n);if(o)return o}return this.getFloorJsonDataByFloorInfo(e)}catch(i){return console.log("[get floor data error]",i),this.getFloorJsonDataByFloorInfo(e)}})}getRoadNetworkData(){return x(this,null,function*(){return(yield Promise.all(this.floors.map(e=>x(this,null,function*(){let n=this.getFloorCacheKey(e);try{if((yield this.getCacheData(fl,n))===e.version_id){let s=yield this.getCacheData(Rs,n);if(s)return s}let o=yield fetch(e.route_url).then(s=>s.json());return this.setCacheData(Rs,n,o),this.setCacheData(fl,n,e.version_id),o}catch(i){let o=yield fetch(e.route_url).then(s=>s.json());return this.setCacheData(Rs,n,o),o}})))).filter(e=>e.points)})}getFacilitiesData(){return x(this,null,function*(){let t=this.floors.reduce((i,o)=>i.updated_at>o.updated_at?i:o,this.floors[0]);if(!t)return null;let e=this.getFloorCacheKey(t),n=()=>x(this,null,function*(){let i=yield fetch(t.entry_infra_url).then(o=>o.json());return i&&(this.setCacheData(ml,e,i),this.setCacheData(dl,e,t.version_id)),i});try{if((yield this.getCacheData(dl,e))===t.version_id){let o=yield this.getCacheData(ml,e);if(o)return o}return n()}catch(i){return console.log("[get facility error]",i),n()}})}getOtherDataByFreeTime(){return x(this,null,function*(){})}getMulFloorsData(t){return x(this,null,function*(){return Promise.all(t.map(e=>this.getFloorData(e))).then(e=>e.filter(n=>n))})}getDataByUrl(t){return x(this,null,function*(){let e=yield fetch(t).then(n=>n.json());return this.getDataByJson(e)})}getDataByJson(t,e){return x(this,null,function*(){return e=this.getFloorBaseLayer(t,e),this.getFloorContentLayer(t,e),this.changeFloorBox(t,e),e})}changeFloorBox(t,e){e.updateBox();let n=e.box.getSize(new Ps.Vector3),i=Math.max(n.x,n.y,n.z);e.userData.height=i/4+t.floorHeight}switchFloor(t){return x(this,null,function*(){return new Promise(e=>{let n={run:()=>this._switchFloor(t),meta:{type:"switchFloor"}},i=this.taskQueue.replaceByMetaType(n),o=s=>{let{task:a,res:u}=s;a.tid===i&&(this.taskQueue.removeEventListener("active-task-end",o),e(u))};this.taskQueue.addEventListener("active-task-end",o)})})}_switchFloor(t){return x(this,null,function*(){var e;let n=t;if(typeof t=="string"){let u=yield this.getFloorJsonData(t);if(u)n=u;else return null}let i=new Ut(this.bmap.context),o=this.floors.find(u=>u.floor===n.floor);var s;let a=(s=o==null?void 0:o.map_angle)!=null?s:0;return this.bmap.dispatchEvent({type:gt.SWITCH_FLOOR_BEFORE,data:{curFloor:i,graphics:[]}}),this.dispatchEvent({type:"switch-floor-before",data:{curFloor:i,graphics:[]}}),this.bmap.context.control.setAzimuthalAngle(a/180*Math.PI,!0),this.getFloorBaseLayer(n,i),this.bmap.buildingCenter=i.userData.center,this.bmap.currentBuildGround=(e=i.userData.data.layers.find(u=>u.l_type==="range"))==null?void 0:e.elements[0],this.getFloorContentLayer(n,i),this.changeFloorBox(n,i),this.bmap.context.switchFloor(i),this.bmap.initialFloorCamera(),this.dispatchEvent({type:"switch-floor-ground",data:{curFloor:i,graphics:[]}}),this.dispatchEvent({type:"switch-floor-after",data:{curFloor:i,graphics:i.graphicLayer.children}}),this.bmap.dispatchEvent({type:gt.SWITCH_FLOOR_AFTER,data:{curFloor:i,graphics:i.graphicLayer.children}}),i})}getFloorBaseLayer(t,e){e||(e=new Ut(this.bmap.context));let n=[0,0];return t.layers.forEach(i=>{switch(i.l_type){case"range":let o=i.elements[0];n=[o.center_x,o.center_y];break;case"ground":yt(i.elements,n);let s=i.elements.map(a=>new K(this.bmap.context,a));e.addGrounds(s);break;default:break}}),e.userData.center=n,e.name=t.floor,e.userData.data=t,e}getFloorContentLayer(t,e){e||(e=new Ut(this.bmap.context)),e.userData.graphics=[],e.userData.graphicMap=new Map;let n=Date.now();for(let i=0;i<t.layers.length;i++){let o=t.layers[i];["range","ground"].includes(o.l_type)||(T_(o,e,this.options),console.log("time",Date.now()-n,o.l_type))}return e}clear(){return x(this,null,function*(){var t;w_((t=this.db)!=null?t:void 0)})}dispose(){this.clear()}constructor(t,e={}){super(),this.bmap=t,this.floors=[],this.initDbPromise=Promise.resolve(),this.db=null,this.taskQueue=new Cn,this.options=E({},EL,e),this.initDbPromise=this.initDb()}};var m7=d(T(),1);var vl=class{load(t){return x(this,null,function*(){let e=vn(t);if(this.cacheData.has(e))return this.cacheData.get(e);let[,n]=yield Promise.all([this.loadBuildGround(t),cl(t,this.bmap.config)]),i=vn({floor:t.floor,ts:t.ts});yt(n.map(s=>s.info),this.bmap.buildingCenter,this.floorDataLengthMap.get(i)||0),n.forEach(s=>s.info.transformToBuildingGround=!1),this.cacheData.set(e,n);let o=this.floorDataLengthMap.get(i)||0;return this.floorDataLengthMap.set(i,o+n.length),this.loadExternalStreet(t),n})}loadExternalStreet(t){return x(this,null,function*(){})}switchFloorByData(t,e){if(!t.length)return;let n=e.userData.legacyToGraphicMap||new Map,i=e.userData.graphicMap||new Map,{ground:o,markGraphic:s,graphic:a}=this.bmap.config;for(let u=0;u<t.length;u++){let l=t[u];l.info.group==="ground"?(l.info.fillColor=o.color,l.info.fillOpacity=o.opacity,l.info.height=o.height,l.info.stroke=o.stroke,l.info.strokeColor=o.strokeColor,l.info.strokeOpacity=o.strokeOpacity):l.info.userData.mark?(l.info.height=s.height,l.info.fillColor=s.color,l.info.fillOpacity=s.opacity,l.info.stroke=s.stroke,l.info.strokeColor=s.strokeColor,l.info.strokeOpacity=s.strokeOpacity):(l.info.fillOpacity=a.fillOpacity,this.bmap.config.initTransToMark&&(l.info.height=s.height,l.info.fillColor=s.color,l.info.stroke=s.stroke,l.info.strokeColor=s.strokeColor,l.info.strokeOpacity=s.strokeOpacity))}for(let u of t){if(u.info.group==="ground")e.createGround(u.info);else{let l=e.addGraphic(u.info);l.userData.data=u,n.set(u.legacy_id,l)}i.set(u.element_uuid,u)}e.userData.legacyToGraphicMap=n,e.userData.graphicMap=i,e.updateBox(),e===this.bmap.context.currentFloor?(this.bmap.triggerHooks(gt.SWITCH_FLOOR_BEFORE,{curFloor:e,graphics:e.graphicLayer.children}),this.bmap.initialFloorCamera(),this.bmap.triggerHooks(gt.SWITCH_FLOOR_AFTER,{curFloor:e,graphics:e.graphicLayer.children})):this.bmap.switchFloorByFloor(e)}filterData(t,e){let n=e.userData.graphicMap||new Map;return t.filter(i=>!n.has(i.element_uuid))}switchFloorByStoreData(t,e){return x(this,null,function*(){let n=yield this.load(E({},t,{resource_type_list:"6"})),i=this.filterData(n,e);this.switchFloorByData(i,e)})}switchFloorByOtherData(t,e){return x(this,null,function*(){let n=yield this.load(E({},t,{resource_type_list:"1,2,3,4"})),i=this.filterData(n,e);this.switchFloorByData(i,e)})}loadBuildGround(t){return x(this,null,function*(){let{brand:e,project:n}=t,i=yield this.loadBuildingGround({brand:e,project:n});return this.bmap.currentBuildGround=i,this.bmap.changeBuildingCenter(i,{brand:e,project:n}),this.bmap.currentBuildGround})}loadBuildingGround(t){return x(this,null,function*(){let{brand:e,project:n}=t,i=vn({brand:e,project:n});if(this.buildingGroundMap.has(i))return this.buildingGroundMap.get(i);let o=ll({brand:e,project:n},this.bmap.config).then(s=>(this.buildingGroundMap.set(i,s),s));return this.buildingGroundMap.set(i,o),o})}switchFloor(t){return x(this,null,function*(){let e=new Ut(this.bmap.context);e.userData.graphicMap=new Map,e.name=t.floor;try{yield Promise.all([this.switchFloorByStoreData(t,e),this.switchFloorByOtherData(t,e)])}catch(n){console.log(n)}return e})}dispose(){this.cacheData.clear(),this.floorDataLengthMap.clear(),this.buildingGroundMap.clear()}constructor(t){this.bmap=t,this.cacheData=new Map,this.floorDataLengthMap=new Map,this.buildingGroundMap=new Map,this.externalStreetMap=new Map}};