@aibee/crc-bmap 0.12.37 → 0.12.39

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.
@@ -23645,7 +23645,7 @@ void main() {
23645
23645
 
23646
23646
  }\`,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 Hi,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 Io({extensions:{fragDepth:!0},vertexShader:bU,fragmentShader:TU,uniforms:{depthColor:{value:this.texture},depthWidth:{value:o.z},depthHeight:{value:o.w}}});this.mesh=new ho(new qf(20,20),a)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}},Pm=class extends Ds{constructor(t,e){super();let o=this,a=null,l=1,h=null,f="local-floor",p=1,d=null,g=null,x=null,v=null,M=null,b=null,T=new Cm,_=e.getContextAttributes(),y=null,A=null,S=[],L=[],G=new ye,z=null,F=new Li;F.layers.enable(1),F.viewport=new zr;let I=new Li;I.layers.enable(2),I.viewport=new zr;let ut=[F,I],R=new Am;R.layers.enable(1),R.layers.enable(2);let W=null,V=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(tt){let wt=S[tt];return wt===void 0&&(wt=new Ll,S[tt]=wt),wt.getTargetRaySpace()},this.getControllerGrip=function(tt){let wt=S[tt];return wt===void 0&&(wt=new Ll,S[tt]=wt),wt.getGripSpace()},this.getHand=function(tt){let wt=S[tt];return wt===void 0&&(wt=new Ll,S[tt]=wt),wt.getHandSpace()};function Mt(tt){let wt=L.indexOf(tt.inputSource);if(wt===-1)return;let Bt=S[wt];Bt!==void 0&&(Bt.update(tt.inputSource,tt.frame,d||h),Bt.dispatchEvent({type:tt.type,data:tt.inputSource}))}function X(){a.removeEventListener("select",Mt),a.removeEventListener("selectstart",Mt),a.removeEventListener("selectend",Mt),a.removeEventListener("squeeze",Mt),a.removeEventListener("squeezestart",Mt),a.removeEventListener("squeezeend",Mt),a.removeEventListener("end",X),a.removeEventListener("inputsourceschange",mt);for(let tt=0;tt<S.length;tt++){let wt=L[tt];wt!==null&&(L[tt]=null,S[tt].disconnect(wt))}W=null,V=null,T.reset(),t.setRenderTarget(y),M=null,v=null,x=null,a=null,A=null,Yt.stop(),o.isPresenting=!1,t.setPixelRatio(z),t.setSize(G.width,G.height,!1),o.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(tt){l=tt,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(tt){f=tt,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||h},this.setReferenceSpace=function(tt){d=tt},this.getBaseLayer=function(){return v!==null?v:M},this.getBinding=function(){return x},this.getFrame=function(){return b},this.getSession=function(){return a},this.setSession=function(tt){return gc(this,null,function*(){if(a=tt,a!==null){if(y=t.getRenderTarget(),a.addEventListener("select",Mt),a.addEventListener("selectstart",Mt),a.addEventListener("selectend",Mt),a.addEventListener("squeeze",Mt),a.addEventListener("squeezestart",Mt),a.addEventListener("squeezeend",Mt),a.addEventListener("end",X),a.addEventListener("inputsourceschange",mt),_.xrCompatible!==!0&&(yield e.makeXRCompatible()),z=t.getPixelRatio(),t.getSize(G),a.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let wt={antialias:a.renderState.layers===void 0?_.antialias:!0,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:l};M=new XRWebGLLayer(a,e,wt),a.updateRenderState({baseLayer:M}),t.setPixelRatio(1),t.setSize(M.framebufferWidth,M.framebufferHeight,!1),A=new us(M.framebufferWidth,M.framebufferHeight,{format:fo,type:Ls,colorSpace:t.outputColorSpace,stencilBuffer:_.stencil})}else{let wt=null,Bt=null,$t=null;_.depth&&($t=_.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,wt=_.stencil?bu:va,Bt=_.stencil?ya:Ps);let Ut={colorFormat:e.RGBA8,depthFormat:$t,scaleFactor:l};x=new XRWebGLBinding(a,e),v=x.createProjectionLayer(Ut),a.updateRenderState({layers:[v]}),t.setPixelRatio(1),t.setSize(v.textureWidth,v.textureHeight,!1),A=new us(v.textureWidth,v.textureHeight,{format:fo,type:Ls,depthTexture:new Hf(v.textureWidth,v.textureHeight,Bt,void 0,void 0,void 0,void 0,void 0,void 0,wt),stencilBuffer:_.stencil,colorSpace:t.outputColorSpace,samples:_.antialias?4:0});let Dt=t.properties.get(A);Dt.__ignoreDepthValues=v.ignoreDepthValues}A.isXRRenderTarget=!0,this.setFoveation(p),d=null,h=yield a.requestReferenceSpace(f),Yt.setContext(a),Yt.start(),o.isPresenting=!0,o.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(a!==null)return a.environmentBlendMode};function mt(tt){for(let wt=0;wt<tt.removed.length;wt++){let Bt=tt.removed[wt],$t=L.indexOf(Bt);$t>=0&&(L[$t]=null,S[$t].disconnect(Bt))}for(let wt=0;wt<tt.added.length;wt++){let Bt=tt.added[wt],$t=L.indexOf(Bt);if($t===-1){for(let Dt=0;Dt<S.length;Dt++)if(Dt>=L.length){L.push(Bt),$t=Dt;break}else if(L[Dt]===null){L[Dt]=Bt,$t=Dt;break}if($t===-1)break}let Ut=S[$t];Ut&&Ut.connect(Bt)}}let dt=new yt,_t=new yt;function it(tt,wt,Bt){dt.setFromMatrixPosition(wt.matrixWorld),_t.setFromMatrixPosition(Bt.matrixWorld);let $t=dt.distanceTo(_t),Ut=wt.projectionMatrix.elements,Dt=Bt.projectionMatrix.elements,At=Ut[14]/(Ut[10]-1),te=Ut[14]/(Ut[10]+1),rt=(Ut[9]+1)/Ut[5],an=(Ut[9]-1)/Ut[5],zt=(Ut[8]-1)/Ut[0],ne=(Dt[8]+1)/Dt[0],Wt=At*zt,ie=At*ne,ce=$t/(-zt+ne),Lt=ce*-zt;wt.matrixWorld.decompose(tt.position,tt.quaternion,tt.scale),tt.translateX(Lt),tt.translateZ(ce),tt.matrixWorld.compose(tt.position,tt.quaternion,tt.scale),tt.matrixWorldInverse.copy(tt.matrixWorld).invert();let se=At+ce,Y=te+ce,N=Wt-Lt,xt=ie+($t-Lt),Et=rt*te/Y*se,ot=an*te/Y*se;tt.projectionMatrix.makePerspective(N,xt,Et,ot,se,Y),tt.projectionMatrixInverse.copy(tt.projectionMatrix).invert()}function lt(tt,wt){wt===null?tt.matrixWorld.copy(tt.matrix):tt.matrixWorld.multiplyMatrices(wt.matrixWorld,tt.matrix),tt.matrixWorldInverse.copy(tt.matrixWorld).invert()}this.updateCamera=function(tt){if(a===null)return;T.texture!==null&&(tt.near=T.depthNear,tt.far=T.depthFar),R.near=I.near=F.near=tt.near,R.far=I.far=F.far=tt.far,(W!==R.near||V!==R.far)&&(a.updateRenderState({depthNear:R.near,depthFar:R.far}),W=R.near,V=R.far,F.near=W,F.far=V,I.near=W,I.far=V,F.updateProjectionMatrix(),I.updateProjectionMatrix(),tt.updateProjectionMatrix());let wt=tt.parent,Bt=R.cameras;lt(R,wt);for(let $t=0;$t<Bt.length;$t++)lt(Bt[$t],wt);Bt.length===2?it(R,F,I):R.projectionMatrix.copy(F.projectionMatrix),H(tt,R,wt)};function H(tt,wt,Bt){Bt===null?tt.matrix.copy(wt.matrixWorld):(tt.matrix.copy(Bt.matrixWorld),tt.matrix.invert(),tt.matrix.multiply(wt.matrixWorld)),tt.matrix.decompose(tt.position,tt.quaternion,tt.scale),tt.updateMatrixWorld(!0),tt.projectionMatrix.copy(wt.projectionMatrix),tt.projectionMatrixInverse.copy(wt.projectionMatrixInverse),tt.isPerspectiveCamera&&(tt.fov=fm*2*Math.atan(1/tt.projectionMatrix.elements[5]),tt.zoom=1)}this.getCamera=function(){return R},this.getFoveation=function(){if(!(v===null&&M===null))return p},this.setFoveation=function(tt){p=tt,v!==null&&(v.fixedFoveation=tt),M!==null&&M.fixedFoveation!==void 0&&(M.fixedFoveation=tt)},this.hasDepthSensing=function(){return T.texture!==null};let bt=null;function Tt(tt,wt){if(g=wt.getViewerPose(d||h),b=wt,g!==null){let Bt=g.views;M!==null&&(t.setRenderTargetFramebuffer(A,M.framebuffer),t.setRenderTarget(A));let $t=!1;Bt.length!==R.cameras.length&&(R.cameras.length=0,$t=!0);for(let Dt=0;Dt<Bt.length;Dt++){let At=Bt[Dt],te=null;if(M!==null)te=M.getViewport(At);else{let an=x.getViewSubImage(v,At);te=an.viewport,Dt===0&&(t.setRenderTargetTextures(A,an.colorTexture,v.ignoreDepthValues?void 0:an.depthStencilTexture),t.setRenderTarget(A))}let rt=ut[Dt];rt===void 0&&(rt=new Li,rt.layers.enable(Dt),rt.viewport=new zr,ut[Dt]=rt),rt.matrix.fromArray(At.transform.matrix),rt.matrix.decompose(rt.position,rt.quaternion,rt.scale),rt.projectionMatrix.fromArray(At.projectionMatrix),rt.projectionMatrixInverse.copy(rt.projectionMatrix).invert(),rt.viewport.set(te.x,te.y,te.width,te.height),Dt===0&&(R.matrix.copy(rt.matrix),R.matrix.decompose(R.position,R.quaternion,R.scale)),$t===!0&&R.cameras.push(rt)}let Ut=a.enabledFeatures;if(Ut&&Ut.includes("depth-sensing")){let Dt=x.getDepthInformation(Bt[0]);Dt&&Dt.isValid&&Dt.texture&&T.init(t,Dt,a.renderState)}}for(let Bt=0;Bt<S.length;Bt++){let $t=L[Bt],Ut=S[Bt];$t!==null&&Ut!==void 0&&Ut.update($t,wt,d||h)}T.render(t,R),bt&&bt(tt,wt),wt.detectedPlanes&&o.dispatchEvent({type:"planesdetected",data:wt}),b=null}let Yt=new cM;Yt.setAnimationLoop(Tt),this.setAnimationLoop=function(tt){bt=tt},this.dispose=function(){}}},fa=new xa,AU=new cr;function CU(r,t){function e(_,y){_.matrixAutoUpdate===!0&&_.updateMatrix(),y.value.copy(_.matrix)}function o(_,y){y.color.getRGB(_.fogColor.value,lM(r)),y.isFog?(_.fogNear.value=y.near,_.fogFar.value=y.far):y.isFogExp2&&(_.fogDensity.value=y.density)}function a(_,y,A,S,L){y.isMeshBasicMaterial||y.isMeshLambertMaterial?l(_,y):y.isMeshToonMaterial?(l(_,y),x(_,y)):y.isMeshPhongMaterial?(l(_,y),g(_,y)):y.isMeshStandardMaterial?(l(_,y),v(_,y),y.isMeshPhysicalMaterial&&M(_,y,L)):y.isMeshMatcapMaterial?(l(_,y),b(_,y)):y.isMeshDepthMaterial?l(_,y):y.isMeshDistanceMaterial?(l(_,y),T(_,y)):y.isMeshNormalMaterial?l(_,y):y.isLineBasicMaterial?(h(_,y),y.isLineDashedMaterial&&f(_,y)):y.isPointsMaterial?p(_,y,A,S):y.isSpriteMaterial?d(_,y):y.isShadowMaterial?(_.color.value.copy(y.color),_.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function l(_,y){_.opacity.value=y.opacity,y.color&&_.diffuse.value.copy(y.color),y.emissive&&_.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(_.map.value=y.map,e(y.map,_.mapTransform)),y.alphaMap&&(_.alphaMap.value=y.alphaMap,e(y.alphaMap,_.alphaMapTransform)),y.bumpMap&&(_.bumpMap.value=y.bumpMap,e(y.bumpMap,_.bumpMapTransform),_.bumpScale.value=y.bumpScale,y.side===Ei&&(_.bumpScale.value*=-1)),y.normalMap&&(_.normalMap.value=y.normalMap,e(y.normalMap,_.normalMapTransform),_.normalScale.value.copy(y.normalScale),y.side===Ei&&_.normalScale.value.negate()),y.displacementMap&&(_.displacementMap.value=y.displacementMap,e(y.displacementMap,_.displacementMapTransform),_.displacementScale.value=y.displacementScale,_.displacementBias.value=y.displacementBias),y.emissiveMap&&(_.emissiveMap.value=y.emissiveMap,e(y.emissiveMap,_.emissiveMapTransform)),y.specularMap&&(_.specularMap.value=y.specularMap,e(y.specularMap,_.specularMapTransform)),y.alphaTest>0&&(_.alphaTest.value=y.alphaTest);let A=t.get(y),S=A.envMap,L=A.envMapRotation;if(S&&(_.envMap.value=S,fa.copy(L),fa.x*=-1,fa.y*=-1,fa.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(fa.y*=-1,fa.z*=-1),_.envMapRotation.value.setFromMatrix4(AU.makeRotationFromEuler(fa)),_.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,_.reflectivity.value=y.reflectivity,_.ior.value=y.ior,_.refractionRatio.value=y.refractionRatio),y.lightMap){_.lightMap.value=y.lightMap;let G=r._useLegacyLights===!0?Math.PI:1;_.lightMapIntensity.value=y.lightMapIntensity*G,e(y.lightMap,_.lightMapTransform)}y.aoMap&&(_.aoMap.value=y.aoMap,_.aoMapIntensity.value=y.aoMapIntensity,e(y.aoMap,_.aoMapTransform))}function h(_,y){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,y.map&&(_.map.value=y.map,e(y.map,_.mapTransform))}function f(_,y){_.dashSize.value=y.dashSize,_.totalSize.value=y.dashSize+y.gapSize,_.scale.value=y.scale}function p(_,y,A,S){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,_.size.value=y.size*A,_.scale.value=S*.5,y.map&&(_.map.value=y.map,e(y.map,_.uvTransform)),y.alphaMap&&(_.alphaMap.value=y.alphaMap,e(y.alphaMap,_.alphaMapTransform)),y.alphaTest>0&&(_.alphaTest.value=y.alphaTest)}function d(_,y){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,_.rotation.value=y.rotation,y.map&&(_.map.value=y.map,e(y.map,_.mapTransform)),y.alphaMap&&(_.alphaMap.value=y.alphaMap,e(y.alphaMap,_.alphaMapTransform)),y.alphaTest>0&&(_.alphaTest.value=y.alphaTest)}function g(_,y){_.specular.value.copy(y.specular),_.shininess.value=Math.max(y.shininess,1e-4)}function x(_,y){y.gradientMap&&(_.gradientMap.value=y.gradientMap)}function v(_,y){_.metalness.value=y.metalness,y.metalnessMap&&(_.metalnessMap.value=y.metalnessMap,e(y.metalnessMap,_.metalnessMapTransform)),_.roughness.value=y.roughness,y.roughnessMap&&(_.roughnessMap.value=y.roughnessMap,e(y.roughnessMap,_.roughnessMapTransform)),t.get(y).envMap&&(_.envMapIntensity.value=y.envMapIntensity)}function M(_,y,A){_.ior.value=y.ior,y.sheen>0&&(_.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),_.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(_.sheenColorMap.value=y.sheenColorMap,e(y.sheenColorMap,_.sheenColorMapTransform)),y.sheenRoughnessMap&&(_.sheenRoughnessMap.value=y.sheenRoughnessMap,e(y.sheenRoughnessMap,_.sheenRoughnessMapTransform))),y.clearcoat>0&&(_.clearcoat.value=y.clearcoat,_.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(_.clearcoatMap.value=y.clearcoatMap,e(y.clearcoatMap,_.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,e(y.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(_.clearcoatNormalMap.value=y.clearcoatNormalMap,e(y.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===Ei&&_.clearcoatNormalScale.value.negate())),y.iridescence>0&&(_.iridescence.value=y.iridescence,_.iridescenceIOR.value=y.iridescenceIOR,_.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(_.iridescenceMap.value=y.iridescenceMap,e(y.iridescenceMap,_.iridescenceMapTransform)),y.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=y.iridescenceThicknessMap,e(y.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),y.transmission>0&&(_.transmission.value=y.transmission,_.transmissionSamplerMap.value=A.texture,_.transmissionSamplerSize.value.set(A.width,A.height),y.transmissionMap&&(_.transmissionMap.value=y.transmissionMap,e(y.transmissionMap,_.transmissionMapTransform)),_.thickness.value=y.thickness,y.thicknessMap&&(_.thicknessMap.value=y.thicknessMap,e(y.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=y.attenuationDistance,_.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(_.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(_.anisotropyMap.value=y.anisotropyMap,e(y.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=y.specularIntensity,_.specularColor.value.copy(y.specularColor),y.specularColorMap&&(_.specularColorMap.value=y.specularColorMap,e(y.specularColorMap,_.specularColorMapTransform)),y.specularIntensityMap&&(_.specularIntensityMap.value=y.specularIntensityMap,e(y.specularIntensityMap,_.specularIntensityMapTransform))}function b(_,y){y.matcap&&(_.matcap.value=y.matcap)}function T(_,y){let A=t.get(y).light;_.referencePosition.value.setFromMatrixPosition(A.matrixWorld),_.nearDistance.value=A.shadow.camera.near,_.farDistance.value=A.shadow.camera.far}return{refreshFogUniforms:o,refreshMaterialUniforms:a}}function PU(r,t,e,o){let a={},l={},h=[],f=e.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function p(A,S){let L=S.program;o.uniformBlockBinding(A,L)}function d(A,S){let L=a[A.id];L===void 0&&(b(A),L=g(A),a[A.id]=L,A.addEventListener("dispose",_));let G=S.program;o.updateUBOMapping(A,G);let z=t.render.frame;l[A.id]!==z&&(v(A),l[A.id]=z)}function g(A){let S=x();A.__bindingPointIndex=S;let L=r.createBuffer(),G=A.__size,z=A.usage;return r.bindBuffer(r.UNIFORM_BUFFER,L),r.bufferData(r.UNIFORM_BUFFER,G,z),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,S,L),L}function x(){for(let A=0;A<f;A++)if(h.indexOf(A)===-1)return h.push(A),A;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function v(A){let S=a[A.id],L=A.uniforms,G=A.__cache;r.bindBuffer(r.UNIFORM_BUFFER,S);for(let z=0,F=L.length;z<F;z++){let I=Array.isArray(L[z])?L[z]:[L[z]];for(let ut=0,R=I.length;ut<R;ut++){let W=I[ut];if(M(W,z,ut,G)===!0){let V=W.__offset,Mt=Array.isArray(W.value)?W.value:[W.value],X=0;for(let mt=0;mt<Mt.length;mt++){let dt=Mt[mt],_t=T(dt);typeof dt=="number"||typeof dt=="boolean"?(W.__data[0]=dt,r.bufferSubData(r.UNIFORM_BUFFER,V+X,W.__data)):dt.isMatrix3?(W.__data[0]=dt.elements[0],W.__data[1]=dt.elements[1],W.__data[2]=dt.elements[2],W.__data[3]=0,W.__data[4]=dt.elements[3],W.__data[5]=dt.elements[4],W.__data[6]=dt.elements[5],W.__data[7]=0,W.__data[8]=dt.elements[6],W.__data[9]=dt.elements[7],W.__data[10]=dt.elements[8],W.__data[11]=0):(dt.toArray(W.__data,X),X+=_t.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,V,W.__data)}}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function M(A,S,L,G){let z=A.value,F=S+"_"+L;if(G[F]===void 0)return typeof z=="number"||typeof z=="boolean"?G[F]=z:G[F]=z.clone(),!0;{let I=G[F];if(typeof z=="number"||typeof z=="boolean"){if(I!==z)return G[F]=z,!0}else if(I.equals(z)===!1)return I.copy(z),!0}return!1}function b(A){let S=A.uniforms,L=0,G=16;for(let F=0,I=S.length;F<I;F++){let ut=Array.isArray(S[F])?S[F]:[S[F]];for(let R=0,W=ut.length;R<W;R++){let V=ut[R],Mt=Array.isArray(V.value)?V.value:[V.value];for(let X=0,mt=Mt.length;X<mt;X++){let dt=Mt[X],_t=T(dt),it=L%G;it!==0&&G-it<_t.boundary&&(L+=G-it),V.__data=new Float32Array(_t.storage/Float32Array.BYTES_PER_ELEMENT),V.__offset=L,L+=_t.storage}}}let z=L%G;return z>0&&(L+=G-z),A.__size=L,A.__cache={},this}function T(A){let S={boundary:0,storage:0};return typeof A=="number"||typeof A=="boolean"?(S.boundary=4,S.storage=4):A.isVector2?(S.boundary=8,S.storage=8):A.isVector3||A.isColor?(S.boundary=16,S.storage=12):A.isVector4?(S.boundary=16,S.storage=16):A.isMatrix3?(S.boundary=48,S.storage=48):A.isMatrix4?(S.boundary=64,S.storage=64):A.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",A),S}function _(A){let S=A.target;S.removeEventListener("dispose",_);let L=h.indexOf(S.__bindingPointIndex);h.splice(L,1),r.deleteBuffer(a[S.id]),delete a[S.id],delete l[S.id]}function y(){for(let A in a)r.deleteBuffer(a[A]);h=[],a={},l={}}return{bind:p,update:d,dispose:y}}var Im=class{constructor(t={}){let{canvas:e=N2(),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 v;o!==null?v=o.getContextAttributes().alpha:v=h;let M=new Uint32Array(4),b=new Int32Array(4),T=null,_=null,y=[],A=[];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=Ao,this._useLegacyLights=!1,this.toneMapping=Rs,this.toneMappingExposure=1;let S=this,L=!1,G=0,z=0,F=null,I=-1,ut=null,R=new zr,W=new zr,V=null,Mt=new vn(0),X=0,mt=e.width,dt=e.height,_t=1,it=null,lt=null,H=new zr(0,0,mt,dt),bt=new zr(0,0,mt,dt),Tt=!1,Yt=new kf,tt=!1,wt=!1,Bt=null,$t=new cr,Ut=new ye,Dt=new yt,At={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function te(){return F===null?_t:1}let rt=o;function an(q,st){for(let vt=0;vt<q.length;vt++){let ht=q[vt],at=e.getContext(ht,st);if(at!==null)return at}return null}try{let q={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",ct,!1),e.addEventListener("webglcontextrestored",O,!1),e.addEventListener("webglcontextcreationerror",K,!1),rt===null){let st=["webgl2","webgl","experimental-webgl"];if(S.isWebGL1Renderer===!0&&st.shift(),rt=an(st,q),rt===null)throw an(st)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&rt instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),rt.getShaderPrecisionFormat===void 0&&(rt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(q){throw console.error("THREE.WebGLRenderer: "+q.message),q}let zt,ne,Wt,ie,ce,Lt,se,Y,N,xt,Et,ot,Pt,ue,Ct,Ot,kt,J,w,P,D,k,B,et;function j(){zt=new W3(rt),ne=new z3(rt,zt,t),zt.init(ne),k=new SU(rt,zt,ne),Wt=new EU(rt,zt,ne),ie=new $3(rt),ce=new lU,Lt=new MU(rt,zt,Wt,ce,ne,k,ie),se=new k3(S),Y=new H3(S),N=new tO(rt,ne),B=new U3(rt,zt,N,ne),xt=new X3(rt,N,ie,B),Et=new j3(rt,xt,N,ie),w=new K3(rt,ne,Lt),Ot=new G3(ce),ot=new uU(S,se,Y,zt,ne,B,Ot),Pt=new CU(S,ce),ue=new fU,Ct=new yU(zt,ne),J=new F3(S,se,Y,Wt,Et,v,p),kt=new xU(S,Et,ne),et=new PU(rt,ie,ne,Wt),P=new B3(rt,zt,ie,ne),D=new Y3(rt,zt,ie,ne),ie.programs=ot.programs,S.capabilities=ne,S.extensions=zt,S.properties=ce,S.renderLists=ue,S.shadowMap=kt,S.state=Wt,S.info=ie}j();let ft=new Pm(S,rt);this.xr=ft,this.getContext=function(){return rt},this.getContextAttributes=function(){return rt.getContextAttributes()},this.forceContextLoss=function(){let q=zt.get("WEBGL_lose_context");q&&q.loseContext()},this.forceContextRestore=function(){let q=zt.get("WEBGL_lose_context");q&&q.restoreContext()},this.getPixelRatio=function(){return _t},this.setPixelRatio=function(q){q!==void 0&&(_t=q,this.setSize(mt,dt,!1))},this.getSize=function(q){return q.set(mt,dt)},this.setSize=function(q,st,vt=!0){if(ft.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}mt=q,dt=st,e.width=Math.floor(q*_t),e.height=Math.floor(st*_t),vt===!0&&(e.style.width=q+"px",e.style.height=st+"px"),this.setViewport(0,0,q,st)},this.getDrawingBufferSize=function(q){return q.set(mt*_t,dt*_t).floor()},this.setDrawingBufferSize=function(q,st,vt){mt=q,dt=st,_t=vt,e.width=Math.floor(q*vt),e.height=Math.floor(st*vt),this.setViewport(0,0,q,st)},this.getCurrentViewport=function(q){return q.copy(R)},this.getViewport=function(q){return q.copy(H)},this.setViewport=function(q,st,vt,ht){q.isVector4?H.set(q.x,q.y,q.z,q.w):H.set(q,st,vt,ht),Wt.viewport(R.copy(H).multiplyScalar(_t).round())},this.getScissor=function(q){return q.copy(bt)},this.setScissor=function(q,st,vt,ht){q.isVector4?bt.set(q.x,q.y,q.z,q.w):bt.set(q,st,vt,ht),Wt.scissor(W.copy(bt).multiplyScalar(_t).round())},this.getScissorTest=function(){return Tt},this.setScissorTest=function(q){Wt.setScissorTest(Tt=q)},this.setOpaqueSort=function(q){it=q},this.setTransparentSort=function(q){lt=q},this.getClearColor=function(q){return q.copy(J.getClearColor())},this.setClearColor=function(){J.setClearColor.apply(J,arguments)},this.getClearAlpha=function(){return J.getClearAlpha()},this.setClearAlpha=function(){J.setClearAlpha.apply(J,arguments)},this.clear=function(q=!0,st=!0,vt=!0){let ht=0;if(q){let at=!1;if(F!==null){let Ht=F.texture.format;at=Ht===rM||Ht===nM||Ht===eM}if(at){let Ht=F.texture.type,Xt=Ht===Ls||Ht===Ps||Ht===Xm||Ht===ya||Ht===QE||Ht===tM,re=J.getClearColor(),Zt=J.getClearAlpha(),me=re.r,oe=re.g,ae=re.b;Xt?(M[0]=me,M[1]=oe,M[2]=ae,M[3]=Zt,rt.clearBufferuiv(rt.COLOR,0,M)):(b[0]=me,b[1]=oe,b[2]=ae,b[3]=Zt,rt.clearBufferiv(rt.COLOR,0,b))}else ht|=rt.COLOR_BUFFER_BIT}st&&(ht|=rt.DEPTH_BUFFER_BIT),vt&&(ht|=rt.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),rt.clear(ht)},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",ct,!1),e.removeEventListener("webglcontextrestored",O,!1),e.removeEventListener("webglcontextcreationerror",K,!1),ue.dispose(),Ct.dispose(),ce.dispose(),se.dispose(),Y.dispose(),Et.dispose(),B.dispose(),et.dispose(),ot.dispose(),kt.dispose(),ft.dispose(),ft.removeEventListener("sessionstart",Ee),ft.removeEventListener("sessionend",de),Bt&&(Bt.dispose(),Bt=null),Se.stop()};function ct(q){q.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),L=!0}function O(){console.log("THREE.WebGLRenderer: Context Restored."),L=!1;let q=ie.autoReset,st=kt.enabled,vt=kt.autoUpdate,ht=kt.needsUpdate,at=kt.type;j(),ie.autoReset=q,kt.enabled=st,kt.autoUpdate=vt,kt.needsUpdate=ht,kt.type=at}function K(q){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",q.statusMessage)}function $(q){let st=q.target;st.removeEventListener("dispose",$),Q(st)}function Q(q){St(q),ce.remove(q)}function St(q){let st=ce.get(q).programs;st!==void 0&&(st.forEach(function(vt){ot.releaseProgram(vt)}),q.isShaderMaterial&&ot.releaseShaderCache(q))}this.renderBufferDirect=function(q,st,vt,ht,at,Ht){st===null&&(st=At);let Xt=at.isMesh&&at.matrixWorld.determinant()<0,re=En(q,st,vt,ht,at);Wt.setMaterial(ht,Xt);let Zt=vt.index,me=1;if(ht.wireframe===!0){if(Zt=xt.getWireframeAttribute(vt),Zt===void 0)return;me=2}let oe=vt.drawRange,ae=vt.attributes.position,un=oe.start*me,vr=(oe.start+oe.count)*me;Ht!==null&&(un=Math.max(un,Ht.start*me),vr=Math.min(vr,(Ht.start+Ht.count)*me)),Zt!==null?(un=Math.max(un,0),vr=Math.min(vr,Zt.count)):ae!=null&&(un=Math.max(un,0),vr=Math.min(vr,ae.count));let Bn=vr-un;if(Bn<0||Bn===1/0)return;B.setup(at,ht,re,vt,Zt);let ti,Mn=P;if(Zt!==null&&(ti=N.get(Zt),Mn=D,Mn.setIndex(ti)),at.isMesh)ht.wireframe===!0?(Wt.setLineWidth(ht.wireframeLinewidth*te()),Mn.setMode(rt.LINES)):Mn.setMode(rt.TRIANGLES);else if(at.isLine){let jt=ht.linewidth;jt===void 0&&(jt=1),Wt.setLineWidth(jt*te()),at.isLineSegments?Mn.setMode(rt.LINES):at.isLineLoop?Mn.setMode(rt.LINE_LOOP):Mn.setMode(rt.LINE_STRIP)}else at.isPoints?Mn.setMode(rt.POINTS):at.isSprite&&Mn.setMode(rt.TRIANGLES);if(at.isBatchedMesh)Mn.renderMultiDraw(at._multiDrawStarts,at._multiDrawCounts,at._multiDrawCount);else if(at.isInstancedMesh)Mn.renderInstances(un,Bn,at.count);else if(vt.isInstancedBufferGeometry){let jt=vt._maxInstanceCount!==void 0?vt._maxInstanceCount:1/0,Na=Math.min(vt.instanceCount,jt);Mn.renderInstances(un,Bn,Na)}else Mn.render(un,Bn)};function Nt(q,st,vt){q.transparent===!0&&q.side===is&&q.forceSinglePass===!1?(q.side=Ei,q.needsUpdate=!0,xn(q,st,vt),q.side=Os,q.needsUpdate=!0,xn(q,st,vt),q.side=is):xn(q,st,vt)}this.compile=function(q,st,vt=null){vt===null&&(vt=q),_=Ct.get(vt),_.init(),A.push(_),vt.traverseVisible(function(at){at.isLight&&at.layers.test(st.layers)&&(_.pushLight(at),at.castShadow&&_.pushShadow(at))}),q!==vt&&q.traverseVisible(function(at){at.isLight&&at.layers.test(st.layers)&&(_.pushLight(at),at.castShadow&&_.pushShadow(at))}),_.setupLights(S._useLegacyLights);let ht=new Set;return q.traverse(function(at){let Ht=at.material;if(Ht)if(Array.isArray(Ht))for(let Xt=0;Xt<Ht.length;Xt++){let re=Ht[Xt];Nt(re,vt,at),ht.add(re)}else Nt(Ht,vt,at),ht.add(Ht)}),A.pop(),_=null,ht},this.compileAsync=function(q,st,vt=null){let ht=this.compile(q,st,vt);return new Promise(at=>{function Ht(){if(ht.forEach(function(Xt){ce.get(Xt).currentProgram.isReady()&&ht.delete(Xt)}),ht.size===0){at(q);return}setTimeout(Ht,10)}zt.get("KHR_parallel_shader_compile")!==null?Ht():setTimeout(Ht,10)})};let Jt=null;function Kt(q){Jt&&Jt(q)}function Ee(){Se.stop()}function de(){Se.start()}let Se=new cM;Se.setAnimationLoop(Kt),typeof self!="undefined"&&Se.setContext(self),this.setAnimationLoop=function(q){Jt=q,ft.setAnimationLoop(q),q===null?Se.stop():Se.start()},ft.addEventListener("sessionstart",Ee),ft.addEventListener("sessionend",de),this.render=function(q,st){if(st!==void 0&&st.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;q.matrixWorldAutoUpdate===!0&&q.updateMatrixWorld(),st.parent===null&&st.matrixWorldAutoUpdate===!0&&st.updateMatrixWorld(),ft.enabled===!0&&ft.isPresenting===!0&&(ft.cameraAutoUpdate===!0&&ft.updateCamera(st),st=ft.getCamera()),q.isScene===!0&&q.onBeforeRender(S,q,st,F),_=Ct.get(q,A.length),_.init(),A.push(_),$t.multiplyMatrices(st.projectionMatrix,st.matrixWorldInverse),Yt.setFromProjectionMatrix($t),wt=this.localClippingEnabled,tt=Ot.init(this.clippingPlanes,wt),T=ue.get(q,y.length),T.init(),y.push(T),we(q,st,0,S.sortObjects),T.finish(),S.sortObjects===!0&&T.sort(it,lt),this.info.render.frame++,tt===!0&&Ot.beginShadows();let vt=_.state.shadowsArray;if(kt.render(vt,q,st),tt===!0&&Ot.endShadows(),this.info.autoReset===!0&&this.info.reset(),(ft.enabled===!1||ft.isPresenting===!1||ft.hasDepthSensing()===!1)&&J.render(T,q),_.setupLights(S._useLegacyLights),st.isArrayCamera){let ht=st.cameras;for(let at=0,Ht=ht.length;at<Ht;at++){let Xt=ht[at];On(T,q,Xt,Xt.viewport)}}else On(T,q,st);F!==null&&(Lt.updateMultisampleRenderTarget(F),Lt.updateRenderTargetMipmap(F)),q.isScene===!0&&q.onAfterRender(S,q,st),B.resetDefaultState(),I=-1,ut=null,A.pop(),A.length>0?_=A[A.length-1]:_=null,y.pop(),y.length>0?T=y[y.length-1]:T=null};function we(q,st,vt,ht){if(q.visible===!1)return;if(q.layers.test(st.layers)){if(q.isGroup)vt=q.renderOrder;else if(q.isLOD)q.autoUpdate===!0&&q.update(st);else if(q.isLight)_.pushLight(q),q.castShadow&&_.pushShadow(q);else if(q.isSprite){if(!q.frustumCulled||Yt.intersectsSprite(q)){ht&&Dt.setFromMatrixPosition(q.matrixWorld).applyMatrix4($t);let Xt=Et.update(q),re=q.material;re.visible&&T.push(q,Xt,re,vt,Dt.z,null)}}else if((q.isMesh||q.isLine||q.isPoints)&&(!q.frustumCulled||Yt.intersectsObject(q))){let Xt=Et.update(q),re=q.material;if(ht&&(q.boundingSphere!==void 0?(q.boundingSphere===null&&q.computeBoundingSphere(),Dt.copy(q.boundingSphere.center)):(Xt.boundingSphere===null&&Xt.computeBoundingSphere(),Dt.copy(Xt.boundingSphere.center)),Dt.applyMatrix4(q.matrixWorld).applyMatrix4($t)),Array.isArray(re)){let Zt=Xt.groups;for(let me=0,oe=Zt.length;me<oe;me++){let ae=Zt[me],un=re[ae.materialIndex];un&&un.visible&&T.push(q,Xt,un,vt,Dt.z,ae)}}else re.visible&&T.push(q,Xt,re,vt,Dt.z,null)}}let Ht=q.children;for(let Xt=0,re=Ht.length;Xt<re;Xt++)we(Ht[Xt],st,vt,ht)}function On(q,st,vt,ht){let at=q.opaque,Ht=q.transmissive,Xt=q.transparent;_.setupLightsView(vt),tt===!0&&Ot.setGlobalState(S.clippingPlanes,vt),Ht.length>0&&sr(at,Ht,st,vt),ht&&Wt.viewport(R.copy(ht)),at.length>0&&_n(at,st,vt),Ht.length>0&&_n(Ht,st,vt),Xt.length>0&&_n(Xt,st,vt),Wt.buffers.depth.setTest(!0),Wt.buffers.depth.setMask(!0),Wt.buffers.color.setMask(!0),Wt.setPolygonOffset(!1)}function sr(q,st,vt,ht){if((vt.isScene===!0?vt.overrideMaterial:null)!==null)return;let Ht=ne.isWebGL2;Bt===null&&(Bt=new us(1,1,{generateMipmaps:!0,type:zt.has("EXT_color_buffer_half_float")?Nl:Ls,minFilter:ma,samples:Ht?4:0})),S.getDrawingBufferSize(Ut),Ht?Bt.setSize(Ut.x,Ut.y):Bt.setSize(hm(Ut.x),hm(Ut.y));let Xt=S.getRenderTarget();S.setRenderTarget(Bt),S.getClearColor(Mt),X=S.getClearAlpha(),X<1&&S.setClearColor(16777215,.5),S.clear();let re=S.toneMapping;S.toneMapping=Rs,_n(q,vt,ht),Lt.updateMultisampleRenderTarget(Bt),Lt.updateRenderTargetMipmap(Bt);let Zt=!1;for(let me=0,oe=st.length;me<oe;me++){let ae=st[me],un=ae.object,vr=ae.geometry,Bn=ae.material,ti=ae.group;if(Bn.side===is&&un.layers.test(ht.layers)){let Mn=Bn.side;Bn.side=Ei,Bn.needsUpdate=!0,le(un,vt,ht,vr,Bn,ti),Bn.side=Mn,Bn.needsUpdate=!0,Zt=!0}}Zt===!0&&(Lt.updateMultisampleRenderTarget(Bt),Lt.updateRenderTargetMipmap(Bt)),S.setRenderTarget(Xt),S.setClearColor(Mt,X),S.toneMapping=re}function _n(q,st,vt){let ht=st.isScene===!0?st.overrideMaterial:null;for(let at=0,Ht=q.length;at<Ht;at++){let Xt=q[at],re=Xt.object,Zt=Xt.geometry,me=ht===null?Xt.material:ht,oe=Xt.group;re.layers.test(vt.layers)&&le(re,st,vt,Zt,me,oe)}}function le(q,st,vt,ht,at,Ht){q.onBeforeRender(S,st,vt,ht,at,Ht),q.modelViewMatrix.multiplyMatrices(vt.matrixWorldInverse,q.matrixWorld),q.normalMatrix.getNormalMatrix(q.modelViewMatrix),at.onBeforeRender(S,st,vt,ht,q,Ht),at.transparent===!0&&at.side===is&&at.forceSinglePass===!1?(at.side=Ei,at.needsUpdate=!0,S.renderBufferDirect(vt,st,ht,at,q,Ht),at.side=Os,at.needsUpdate=!0,S.renderBufferDirect(vt,st,ht,at,q,Ht),at.side=is):S.renderBufferDirect(vt,st,ht,at,q,Ht),q.onAfterRender(S,st,vt,ht,at,Ht)}function xn(q,st,vt){st.isScene!==!0&&(st=At);let ht=ce.get(q),at=_.state.lights,Ht=_.state.shadowsArray,Xt=at.state.version,re=ot.getParameters(q,at.state,Ht,st,vt),Zt=ot.getProgramCacheKey(re),me=ht.programs;ht.environment=q.isMeshStandardMaterial?st.environment:null,ht.fog=st.fog,ht.envMap=(q.isMeshStandardMaterial?Y:se).get(q.envMap||ht.environment),ht.envMapRotation=ht.environment!==null&&q.envMap===null?st.environmentRotation:q.envMapRotation,me===void 0&&(q.addEventListener("dispose",$),me=new Map,ht.programs=me);let oe=me.get(Zt);if(oe!==void 0){if(ht.currentProgram===oe&&ht.lightsStateVersion===Xt)return Tn(q,re),oe}else re.uniforms=ot.getUniforms(q),q.onBuild(vt,re,S),q.onBeforeCompile(re,S),oe=ot.acquireProgram(re,Zt),me.set(Zt,oe),ht.uniforms=re.uniforms;let ae=ht.uniforms;return(!q.isShaderMaterial&&!q.isRawShaderMaterial||q.clipping===!0)&&(ae.clippingPlanes=Ot.uniform),Tn(q,re),ht.needsLights=yr(q),ht.lightsStateVersion=Xt,ht.needsLights&&(ae.ambientLightColor.value=at.state.ambient,ae.lightProbe.value=at.state.probe,ae.directionalLights.value=at.state.directional,ae.directionalLightShadows.value=at.state.directionalShadow,ae.spotLights.value=at.state.spot,ae.spotLightShadows.value=at.state.spotShadow,ae.rectAreaLights.value=at.state.rectArea,ae.ltc_1.value=at.state.rectAreaLTC1,ae.ltc_2.value=at.state.rectAreaLTC2,ae.pointLights.value=at.state.point,ae.pointLightShadows.value=at.state.pointShadow,ae.hemisphereLights.value=at.state.hemi,ae.directionalShadowMap.value=at.state.directionalShadowMap,ae.directionalShadowMatrix.value=at.state.directionalShadowMatrix,ae.spotShadowMap.value=at.state.spotShadowMap,ae.spotLightMatrix.value=at.state.spotLightMatrix,ae.spotLightMap.value=at.state.spotLightMap,ae.pointShadowMap.value=at.state.pointShadowMap,ae.pointShadowMatrix.value=at.state.pointShadowMatrix),ht.currentProgram=oe,ht.uniformsList=null,oe}function In(q){if(q.uniformsList===null){let st=q.currentProgram.getUniforms();q.uniformsList=Mu.seqWithValue(st.seq,q.uniforms)}return q.uniformsList}function Tn(q,st){let vt=ce.get(q);vt.outputColorSpace=st.outputColorSpace,vt.batching=st.batching,vt.instancing=st.instancing,vt.instancingColor=st.instancingColor,vt.instancingMorph=st.instancingMorph,vt.skinning=st.skinning,vt.morphTargets=st.morphTargets,vt.morphNormals=st.morphNormals,vt.morphColors=st.morphColors,vt.morphTargetsCount=st.morphTargetsCount,vt.numClippingPlanes=st.numClippingPlanes,vt.numIntersection=st.numClipIntersection,vt.vertexAlphas=st.vertexAlphas,vt.vertexTangents=st.vertexTangents,vt.toneMapping=st.toneMapping}function En(q,st,vt,ht,at){st.isScene!==!0&&(st=At),Lt.resetTextureUnits();let Ht=st.fog,Xt=ht.isMeshStandardMaterial?st.environment:null,re=F===null?S.outputColorSpace:F.isXRRenderTarget===!0?F.texture.colorSpace:Bs,Zt=(ht.isMeshStandardMaterial?Y:se).get(ht.envMap||Xt),me=ht.vertexColors===!0&&!!vt.attributes.color&&vt.attributes.color.itemSize===4,oe=!!vt.attributes.tangent&&(!!ht.normalMap||ht.anisotropy>0),ae=!!vt.morphAttributes.position,un=!!vt.morphAttributes.normal,vr=!!vt.morphAttributes.color,Bn=Rs;ht.toneMapped&&(F===null||F.isXRRenderTarget===!0)&&(Bn=S.toneMapping);let ti=vt.morphAttributes.position||vt.morphAttributes.normal||vt.morphAttributes.color,Mn=ti!==void 0?ti.length:0,jt=ce.get(ht),Na=_.state.lights;if(tt===!0&&(wt===!0||q!==ut)){let ei=q===ut&&ht.id===I;Ot.setState(ht,q,ei)}let ln=!1;ht.version===jt.__version?(jt.needsLights&&jt.lightsStateVersion!==Na.state.version||jt.outputColorSpace!==re||at.isBatchedMesh&&jt.batching===!1||!at.isBatchedMesh&&jt.batching===!0||at.isInstancedMesh&&jt.instancing===!1||!at.isInstancedMesh&&jt.instancing===!0||at.isSkinnedMesh&&jt.skinning===!1||!at.isSkinnedMesh&&jt.skinning===!0||at.isInstancedMesh&&jt.instancingColor===!0&&at.instanceColor===null||at.isInstancedMesh&&jt.instancingColor===!1&&at.instanceColor!==null||at.isInstancedMesh&&jt.instancingMorph===!0&&at.morphTexture===null||at.isInstancedMesh&&jt.instancingMorph===!1&&at.morphTexture!==null||jt.envMap!==Zt||ht.fog===!0&&jt.fog!==Ht||jt.numClippingPlanes!==void 0&&(jt.numClippingPlanes!==Ot.numPlanes||jt.numIntersection!==Ot.numIntersection)||jt.vertexAlphas!==me||jt.vertexTangents!==oe||jt.morphTargets!==ae||jt.morphNormals!==un||jt.morphColors!==vr||jt.toneMapping!==Bn||ne.isWebGL2===!0&&jt.morphTargetsCount!==Mn)&&(ln=!0):(ln=!0,jt.__version=ht.version);let Xi=jt.currentProgram;ln===!0&&(Xi=xn(ht,st,at));let Qu=!1,ge=!1,Ys=!1,Sn=Xi.getUniforms(),Yi=jt.uniforms;if(Wt.useProgram(Xi.program)&&(Qu=!0,ge=!0,Ys=!0),ht.id!==I&&(I=ht.id,ge=!0),Qu||ut!==q){Sn.setValue(rt,"projectionMatrix",q.projectionMatrix),Sn.setValue(rt,"viewMatrix",q.matrixWorldInverse);let ei=Sn.map.cameraPosition;ei!==void 0&&ei.setValue(rt,Dt.setFromMatrixPosition(q.matrixWorld)),ne.logarithmicDepthBuffer&&Sn.setValue(rt,"logDepthBufFC",2/(Math.log(q.far+1)/Math.LN2)),(ht.isMeshPhongMaterial||ht.isMeshToonMaterial||ht.isMeshLambertMaterial||ht.isMeshBasicMaterial||ht.isMeshStandardMaterial||ht.isShaderMaterial)&&Sn.setValue(rt,"isOrthographic",q.isOrthographicCamera===!0),ut!==q&&(ut=q,ge=!0,Ys=!0)}if(at.isSkinnedMesh){Sn.setOptional(rt,at,"bindMatrix"),Sn.setOptional(rt,at,"bindMatrixInverse");let ei=at.skeleton;ei&&(ne.floatVertexTextures?(ei.boneTexture===null&&ei.computeBoneTexture(),Sn.setValue(rt,"boneTexture",ei.boneTexture,Lt)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}at.isBatchedMesh&&(Sn.setOptional(rt,at,"batchingTexture"),Sn.setValue(rt,"batchingTexture",at._matricesTexture,Lt));let pe=vt.morphAttributes;if((pe.position!==void 0||pe.normal!==void 0||pe.color!==void 0&&ne.isWebGL2===!0)&&w.update(at,vt,Xi),(ge||jt.receiveShadow!==at.receiveShadow)&&(jt.receiveShadow=at.receiveShadow,Sn.setValue(rt,"receiveShadow",at.receiveShadow)),ht.isMeshGouraudMaterial&&ht.envMap!==null&&(Yi.envMap.value=Zt,Yi.flipEnvMap.value=Zt.isCubeTexture&&Zt.isRenderTargetTexture===!1?-1:1),ge&&(Sn.setValue(rt,"toneMappingExposure",S.toneMappingExposure),jt.needsLights&&Hr(Yi,Ys),Ht&&ht.fog===!0&&Pt.refreshFogUniforms(Yi,Ht),Pt.refreshMaterialUniforms(Yi,ht,_t,dt,Bt),Mu.upload(rt,In(jt),Yi,Lt)),ht.isShaderMaterial&&ht.uniformsNeedUpdate===!0&&(Mu.upload(rt,In(jt),Yi,Lt),ht.uniformsNeedUpdate=!1),ht.isSpriteMaterial&&Sn.setValue(rt,"center",at.center),Sn.setValue(rt,"modelViewMatrix",at.modelViewMatrix),Sn.setValue(rt,"normalMatrix",at.normalMatrix),Sn.setValue(rt,"modelMatrix",at.matrixWorld),ht.isShaderMaterial||ht.isRawShaderMaterial){let ei=ht.uniformsGroups;for(let tl=0,Oa=ei.length;tl<Oa;tl++)if(ne.isWebGL2){let ni=ei[tl];et.update(ni,Xi),et.bind(ni,Xi)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Xi}function Hr(q,st){q.ambientLightColor.needsUpdate=st,q.lightProbe.needsUpdate=st,q.directionalLights.needsUpdate=st,q.directionalLightShadows.needsUpdate=st,q.pointLights.needsUpdate=st,q.pointLightShadows.needsUpdate=st,q.spotLights.needsUpdate=st,q.spotLightShadows.needsUpdate=st,q.rectAreaLights.needsUpdate=st,q.hemisphereLights.needsUpdate=st}function yr(q){return q.isMeshLambertMaterial||q.isMeshToonMaterial||q.isMeshPhongMaterial||q.isMeshStandardMaterial||q.isShadowMaterial||q.isShaderMaterial&&q.lights===!0}this.getActiveCubeFace=function(){return G},this.getActiveMipmapLevel=function(){return z},this.getRenderTarget=function(){return F},this.setRenderTargetTextures=function(q,st,vt){ce.get(q.texture).__webglTexture=st,ce.get(q.depthTexture).__webglTexture=vt;let ht=ce.get(q);ht.__hasExternalTextures=!0,ht.__autoAllocateDepthBuffer=vt===void 0,ht.__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"),ht.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(q,st){let vt=ce.get(q);vt.__webglFramebuffer=st,vt.__useDefaultFramebuffer=st===void 0},this.setRenderTarget=function(q,st=0,vt=0){F=q,G=st,z=vt;let ht=!0,at=null,Ht=!1,Xt=!1;if(q){let Zt=ce.get(q);Zt.__useDefaultFramebuffer!==void 0?(Wt.bindFramebuffer(rt.FRAMEBUFFER,null),ht=!1):Zt.__webglFramebuffer===void 0?Lt.setupRenderTarget(q):Zt.__hasExternalTextures&&Lt.rebindTextures(q,ce.get(q.texture).__webglTexture,ce.get(q.depthTexture).__webglTexture);let me=q.texture;(me.isData3DTexture||me.isDataArrayTexture||me.isCompressedArrayTexture)&&(Xt=!0);let oe=ce.get(q).__webglFramebuffer;q.isWebGLCubeRenderTarget?(Array.isArray(oe[st])?at=oe[st][vt]:at=oe[st],Ht=!0):ne.isWebGL2&&q.samples>0&&Lt.useMultisampledRTT(q)===!1?at=ce.get(q).__webglMultisampledFramebuffer:Array.isArray(oe)?at=oe[vt]:at=oe,R.copy(q.viewport),W.copy(q.scissor),V=q.scissorTest}else R.copy(H).multiplyScalar(_t).floor(),W.copy(bt).multiplyScalar(_t).floor(),V=Tt;if(Wt.bindFramebuffer(rt.FRAMEBUFFER,at)&&ne.drawBuffers&&ht&&Wt.drawBuffers(q,at),Wt.viewport(R),Wt.scissor(W),Wt.setScissorTest(V),Ht){let Zt=ce.get(q.texture);rt.framebufferTexture2D(rt.FRAMEBUFFER,rt.COLOR_ATTACHMENT0,rt.TEXTURE_CUBE_MAP_POSITIVE_X+st,Zt.__webglTexture,vt)}else if(Xt){let Zt=ce.get(q.texture),me=st||0;rt.framebufferTextureLayer(rt.FRAMEBUFFER,rt.COLOR_ATTACHMENT0,Zt.__webglTexture,vt||0,me)}I=-1},this.readRenderTargetPixels=function(q,st,vt,ht,at,Ht,Xt){if(!(q&&q.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let re=ce.get(q).__webglFramebuffer;if(q.isWebGLCubeRenderTarget&&Xt!==void 0&&(re=re[Xt]),re){Wt.bindFramebuffer(rt.FRAMEBUFFER,re);try{let Zt=q.texture,me=Zt.format,oe=Zt.type;if(me!==fo&&k.convert(me)!==rt.getParameter(rt.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let ae=oe===Nl&&(zt.has("EXT_color_buffer_half_float")||ne.isWebGL2&&zt.has("EXT_color_buffer_float"));if(oe!==Ls&&k.convert(oe)!==rt.getParameter(rt.IMPLEMENTATION_COLOR_READ_TYPE)&&!(oe===os&&(ne.isWebGL2||zt.has("OES_texture_float")||zt.has("WEBGL_color_buffer_float")))&&!ae){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}st>=0&&st<=q.width-ht&&vt>=0&&vt<=q.height-at&&rt.readPixels(st,vt,ht,at,k.convert(me),k.convert(oe),Ht)}finally{let Zt=F!==null?ce.get(F).__webglFramebuffer:null;Wt.bindFramebuffer(rt.FRAMEBUFFER,Zt)}}},this.copyFramebufferToTexture=function(q,st,vt=0){let ht=Math.pow(2,-vt),at=Math.floor(st.image.width*ht),Ht=Math.floor(st.image.height*ht);Lt.setTexture2D(st,0),rt.copyTexSubImage2D(rt.TEXTURE_2D,vt,0,0,q.x,q.y,at,Ht),Wt.unbindTexture()},this.copyTextureToTexture=function(q,st,vt,ht=0){let at=st.image.width,Ht=st.image.height,Xt=k.convert(vt.format),re=k.convert(vt.type);Lt.setTexture2D(vt,0),rt.pixelStorei(rt.UNPACK_FLIP_Y_WEBGL,vt.flipY),rt.pixelStorei(rt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,vt.premultiplyAlpha),rt.pixelStorei(rt.UNPACK_ALIGNMENT,vt.unpackAlignment),st.isDataTexture?rt.texSubImage2D(rt.TEXTURE_2D,ht,q.x,q.y,at,Ht,Xt,re,st.image.data):st.isCompressedTexture?rt.compressedTexSubImage2D(rt.TEXTURE_2D,ht,q.x,q.y,st.mipmaps[0].width,st.mipmaps[0].height,Xt,st.mipmaps[0].data):rt.texSubImage2D(rt.TEXTURE_2D,ht,q.x,q.y,Xt,re,st.image),ht===0&&vt.generateMipmaps&&rt.generateMipmap(rt.TEXTURE_2D),Wt.unbindTexture()},this.copyTextureToTexture3D=function(q,st,vt,ht,at=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Ht=Math.round(q.max.x-q.min.x),Xt=Math.round(q.max.y-q.min.y),re=q.max.z-q.min.z+1,Zt=k.convert(ht.format),me=k.convert(ht.type),oe;if(ht.isData3DTexture)Lt.setTexture3D(ht,0),oe=rt.TEXTURE_3D;else if(ht.isDataArrayTexture||ht.isCompressedArrayTexture)Lt.setTexture2DArray(ht,0),oe=rt.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}rt.pixelStorei(rt.UNPACK_FLIP_Y_WEBGL,ht.flipY),rt.pixelStorei(rt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ht.premultiplyAlpha),rt.pixelStorei(rt.UNPACK_ALIGNMENT,ht.unpackAlignment);let ae=rt.getParameter(rt.UNPACK_ROW_LENGTH),un=rt.getParameter(rt.UNPACK_IMAGE_HEIGHT),vr=rt.getParameter(rt.UNPACK_SKIP_PIXELS),Bn=rt.getParameter(rt.UNPACK_SKIP_ROWS),ti=rt.getParameter(rt.UNPACK_SKIP_IMAGES),Mn=vt.isCompressedTexture?vt.mipmaps[at]:vt.image;rt.pixelStorei(rt.UNPACK_ROW_LENGTH,Mn.width),rt.pixelStorei(rt.UNPACK_IMAGE_HEIGHT,Mn.height),rt.pixelStorei(rt.UNPACK_SKIP_PIXELS,q.min.x),rt.pixelStorei(rt.UNPACK_SKIP_ROWS,q.min.y),rt.pixelStorei(rt.UNPACK_SKIP_IMAGES,q.min.z),vt.isDataTexture||vt.isData3DTexture?rt.texSubImage3D(oe,at,st.x,st.y,st.z,Ht,Xt,re,Zt,me,Mn.data):ht.isCompressedArrayTexture?rt.compressedTexSubImage3D(oe,at,st.x,st.y,st.z,Ht,Xt,re,Zt,Mn.data):rt.texSubImage3D(oe,at,st.x,st.y,st.z,Ht,Xt,re,Zt,me,Mn),rt.pixelStorei(rt.UNPACK_ROW_LENGTH,ae),rt.pixelStorei(rt.UNPACK_IMAGE_HEIGHT,un),rt.pixelStorei(rt.UNPACK_SKIP_PIXELS,vr),rt.pixelStorei(rt.UNPACK_SKIP_ROWS,Bn),rt.pixelStorei(rt.UNPACK_SKIP_IMAGES,ti),at===0&&ht.generateMipmaps&&rt.generateMipmap(oe),Wt.unbindTexture()},this.initTexture=function(q){q.isCubeTexture?Lt.setTextureCube(q,0):q.isData3DTexture?Lt.setTexture3D(q,0):q.isDataArrayTexture||q.isCompressedArrayTexture?Lt.setTexture2DArray(q,0):Lt.setTexture2D(q,0),Wt.unbindTexture()},this.resetState=function(){G=0,z=0,F=null,Wt.reset(),B.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ss}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===Ym?"display-p3":"srgb",e.unpackColorSpace=Cn.workingColorSpace===Yf?"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}},Rm=class extends Im{};Rm.prototype.isWebGL1Renderer=!0;var Lm=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=lm,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Ns()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return aM("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,o){t*=this.stride,o*=e.stride;for(let a=0,l=this.stride;a<l;a++)this.array[t+a]=e.array[o+a];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ns()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),o=new this.constructor(e,this.stride);return o.setUsage(this.usage),o}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Ns()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},ci=new yt,Wf=class r{constructor(t,e,o,a=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=o,this.normalized=a}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,o=this.data.count;e<o;e++)ci.fromBufferAttribute(this,e),ci.applyMatrix4(t),this.setXYZ(e,ci.x,ci.y,ci.z);return this}applyNormalMatrix(t){for(let e=0,o=this.count;e<o;e++)ci.fromBufferAttribute(this,e),ci.applyNormalMatrix(t),this.setXYZ(e,ci.x,ci.y,ci.z);return this}transformDirection(t){for(let e=0,o=this.count;e<o;e++)ci.fromBufferAttribute(this,e),ci.transformDirection(t),this.setXYZ(e,ci.x,ci.y,ci.z);return this}getComponent(t,e){let o=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(o=Po(o,this.array)),o}setComponent(t,e,o){return this.normalized&&(o=An(o,this.array)),this.data.array[t*this.data.stride+this.offset+e]=o,this}setX(t,e){return this.normalized&&(e=An(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=An(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=An(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=An(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Po(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Po(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Po(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Po(e,this.array)),e}setXY(t,e,o){return t=t*this.data.stride+this.offset,this.normalized&&(e=An(e,this.array),o=An(o,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=o,this}setXYZ(t,e,o,a){return t=t*this.data.stride+this.offset,this.normalized&&(e=An(e,this.array),o=An(o,this.array),a=An(a,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=o,this.data.array[t+2]=a,this}setXYZW(t,e,o,a,l){return t=t*this.data.stride+this.offset,this.normalized&&(e=An(e,this.array),o=An(o,this.array),a=An(a,this.array),l=An(l,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=o,this.data.array[t+2]=a,this.data.array[t+3]=l,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let o=0;o<this.count;o++){let a=o*this.data.stride+this.offset;for(let l=0;l<this.itemSize;l++)e.push(this.data.array[a+l])}return new Ni(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new r(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let o=0;o<this.count;o++){let a=o*this.data.stride+this.offset;for(let l=0;l<this.itemSize;l++)e.push(this.data.array[a+l])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},Nm=class extends Ea{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new vn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},As,Pl=new yt,du=new yt,mu=new yt,gu=new ye,Il=new ye,gM=new cr,xf=new yt,Rl=new yt,Ef=new yt,YE=new ye,nm=new ye,$E=new ye,Om=class extends po{constructor(t=new Nm){if(super(),this.isSprite=!0,this.type="Sprite",As===void 0){As=new Us;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),o=new Lm(e,5);As.setIndex([0,1,2,0,2,3]),As.setAttribute("position",new Wf(o,3,0,!1)),As.setAttribute("uv",new Wf(o,2,3,!1))}this.geometry=As,this.material=t,this.center=new ye(.5,.5)}raycast(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),du.setFromMatrixScale(this.matrixWorld),gM.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),mu.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&du.multiplyScalar(-mu.z);let o=this.material.rotation,a,l;o!==0&&(l=Math.cos(o),a=Math.sin(o));let h=this.center;Mf(xf.set(-.5,-.5,0),mu,h,du,a,l),Mf(Rl.set(.5,-.5,0),mu,h,du,a,l),Mf(Ef.set(.5,.5,0),mu,h,du,a,l),YE.set(0,0),nm.set(1,0),$E.set(1,1);let f=t.ray.intersectTriangle(xf,Rl,Ef,!1,Pl);if(f===null&&(Mf(Rl.set(-.5,.5,0),mu,h,du,a,l),nm.set(0,1),f=t.ray.intersectTriangle(xf,Ef,Rl,!1,Pl),f===null))return;let p=t.ray.origin.distanceTo(Pl);p<t.near||p>t.far||e.push({distance:p,point:Pl.clone(),uv:ga.getInterpolation(Pl,xf,Rl,Ef,YE,nm,$E,new ye),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}};Om.Dispose=function(){As.dispose(),As=void 0};function Mf(r,t,e,o,a,l){gu.subVectors(r,e).addScalar(.5).multiply(o),a!==void 0?(Il.x=l*gu.x-a*gu.y,Il.y=a*gu.x+l*gu.y):Il.copy(gu),r.copy(t),r.x+=Il.x,r.y+=Il.y,r.applyMatrix4(gM)}function Sf(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 IU(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var Au=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 Au{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:nE,endingEnd:nE}}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 rE:l=t,f=2*e-o;break;case iE: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 rE:h=t,p=2*o-e;break;case iE: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,v=this._weightPrev,M=this._weightNext,b=(o-e)/(a-e),T=b*b,_=T*b,y=-v*_+2*v*T-v*b,A=(1+v)*_+(-1.5-2*v)*T+(-.5+v)*b+1,S=(-1-M)*_+(1.5+M)*T+.5*b,L=M*_-M*T;for(let G=0;G!==f;++G)l[G]=y*h[g+G]+A*h[d+G]+S*h[p+G]+L*h[x+G];return l}},Fm=class extends Au{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 v=0;v!==f;++v)l[v]=h[d+v]*x+h[p+v]*g;return l}},Um=class extends Au{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t){return this.copySampleValue_(t-1)}},mo=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=Sf(e,this.TimeBufferType),this.values=Sf(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:Sf(t.times,Array),values:Sf(t.values,Array)};let a=t.getInterpolation();a!==t.DefaultInterpolation&&(o.interpolation=a)}return o.type=t.ValueTypeName,o}InterpolantFactoryMethodDiscrete(t){return new Um(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Fm(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 bf:e=this.InterpolantFactoryMethodDiscrete;break;case Tf: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 bf;case this.InterpolantFactoryMethodLinear:return Tf;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&&IU(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,v=x-o,M=x+o;for(let b=0;b!==o;++b){let T=e[x+b];if(T!==e[v+b]||T!==e[M+b]){p=!0;break}}}if(p){if(f!==h){t[h]=t[f];let x=f*o,v=h*o;for(let M=0;M!==o;++M)e[v+M]=e[x+M]}++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}};mo.prototype.TimeBufferType=Float32Array;mo.prototype.ValueBufferType=Float32Array;mo.prototype.DefaultInterpolation=Tf;var Ma=class extends mo{};Ma.prototype.ValueTypeName="bool";Ma.prototype.ValueBufferType=Array;Ma.prototype.DefaultInterpolation=bf;Ma.prototype.InterpolantFactoryMethodLinear=void 0;Ma.prototype.InterpolantFactoryMethodSmooth=void 0;var Bm=class extends mo{};Bm.prototype.ValueTypeName="color";var zm=class extends mo{};zm.prototype.ValueTypeName="number";var Gm=class extends Au{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)Fs.slerpFlat(l,0,h,d-f,h,d,p);return l}},Fl=class extends mo{InterpolantFactoryMethodLinear(t){return new Gm(this.times,this.values,this.getValueSize(),t)}};Fl.prototype.ValueTypeName="quaternion";Fl.prototype.DefaultInterpolation=Tf;Fl.prototype.InterpolantFactoryMethodSmooth=void 0;var Sa=class extends mo{};Sa.prototype.ValueTypeName="string";Sa.prototype.ValueBufferType=Array;Sa.prototype.DefaultInterpolation=bf;Sa.prototype.InterpolantFactoryMethodLinear=void 0;Sa.prototype.InterpolantFactoryMethodSmooth=void 0;var km=class extends mo{};km.prototype.ValueTypeName="vector";var qm=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,v=d.length;x<v;x+=2){let M=d[x],b=d[x+1];if(M.global&&(M.lastIndex=0),M.test(g))return b}return null}}},RU=new qm,Vm=class{constructor(t){this.manager=t!==void 0?t:RU,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}};Vm.DEFAULT_MATERIAL_NAME="__DEFAULT";var Zm="\\\\[\\\\]\\\\.:\\\\/",LU=new RegExp("["+Zm+"]","g"),Jm="[^"+Zm+"]",NU="[^"+Zm.replace("\\\\.","")+"]",OU=/((?:WC+[\\/:])*)/.source.replace("WC",Jm),DU=/(WCOD+)?/.source.replace("WCOD",NU),FU=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",Jm),UU=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",Jm),BU=new RegExp("^"+OU+DU+FU+UU+"$"),zU=["material","materials","bones","map"],Hm=class{constructor(t,e,o){let a=o||Vn.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()}},Vn=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(LU,"")}static parseTrackName(t){let e=BU.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);zU.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}};Vn.Composite=Hm;Vn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Vn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Vn.prototype.GetterByBindingType=[Vn.prototype._getValue_direct,Vn.prototype._getValue_array,Vn.prototype._getValue_arrayElement,Vn.prototype._getValue_toArray];Vn.prototype.SetterByBindingTypeAndVersioning=[[Vn.prototype._setValue_direct,Vn.prototype._setValue_direct_setNeedsUpdate,Vn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Vn.prototype._setValue_array,Vn.prototype._setValue_array_setNeedsUpdate,Vn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Vn.prototype._setValue_arrayElement,Vn.prototype._setValue_arrayElement_setNeedsUpdate,Vn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Vn.prototype._setValue_fromArray,Vn.prototype._setValue_fromArray_setNeedsUpdate,Vn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var SH=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 Cr=63710088e-1,TH={centimeters:Cr*100,centimetres:Cr*100,degrees:Cr/111325,feet:Cr*3.28084,inches:Cr*39.37,kilometers:Cr/1e3,kilometres:Cr/1e3,meters:Cr,metres:Cr,miles:Cr/1609.344,millimeters:Cr*1e3,millimetres:Cr*1e3,nauticalmiles:Cr/1852,radians:1,yards:Cr*1.0936},AH={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/Cr,yards:1.0936133};function pi(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 Nn(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(!Ro(r[0])||!Ro(r[1]))throw new Error("coordinates must contain numbers");var o={type:"Point",coordinates:r};return pi(o,t,e)}function Hn(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 pi(f,t,e)}function Pr(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 pi(o,t,e)}function Km(r,t,e){e===void 0&&(e={});var o={type:"MultiPoint",coordinates:r};return pi(o,t,e)}function Ro(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function pr(r,t,e){if(r!==null)for(var o,a,l,h,f,p,d,g=0,x=0,v,M=r.type,b=M==="FeatureCollection",T=M==="Feature",_=b?r.features.length:1,y=0;y<_;y++){d=b?r.features[y].geometry:T?r.geometry:r,v=d?d.type==="GeometryCollection":!1,f=v?d.geometries.length:1;for(var A=0;A<f;A++){var S=0,L=0;if(h=v?d.geometries[A]:d,h!==null){p=h.coordinates;var G=h.type;switch(g=e&&(G==="Polygon"||G==="MultiPolygon")?1:0,G){case null:break;case"Point":if(t(p,x,y,S,L)===!1)return!1;x++,S++;break;case"LineString":case"MultiPoint":for(o=0;o<p.length;o++){if(t(p[o],x,y,S,L)===!1)return!1;x++,G==="MultiPoint"&&S++}G==="LineString"&&S++;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,S,L)===!1)return!1;x++}G==="MultiLineString"&&S++,G==="Polygon"&&L++}G==="Polygon"&&S++;break;case"MultiPolygon":for(o=0;o<p.length;o++){for(L=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,S,L)===!1)return!1;x++}L++}S++}break;case"GeometryCollection":for(o=0;o<h.geometries.length;o++)if(pr(h.geometries[o],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function yM(r,t,e,o){var a=e;return pr(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 zs(r,t){var e,o,a,l,h,f,p,d,g,x,v=0,M=r.type==="FeatureCollection",b=r.type==="Feature",T=M?r.features.length:1;for(e=0;e<T;e++){for(f=M?r.features[e].geometry:b?r.geometry:r,d=M?r.features[e].properties:b?r.properties:{},g=M?r.features[e].bbox:b?r.bbox:void 0,x=M?r.features[e].id:b?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,v,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,v,d,g,x)===!1)return!1;break}case"GeometryCollection":{for(o=0;o<l.geometries.length;o++)if(t(l.geometries[o],v,d,g,x)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}v++}}function Oi(r,t){zs(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(pi(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(pi(x,a),o,d)===!1)return!1}})}function jm(r){var t=[1/0,1/0,-1/0,-1/0];return pr(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}jm.default=jm;var di=jm;function Gr(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 Qm(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 kr(r){return r.type==="Feature"?r.geometry:r}var YU=yn(Zf(),1);var rB=yn(DM(),1);function Ir(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=Gr(r),a=kr(t),l=a.type,h=t.bbox,f=a.coordinates;if(h&&iB(o,h)===!1)return!1;l==="Polygon"&&(f=[f]);for(var p=!1,d=0;d<f.length&&!p;d++)if(FM(o,f[d][0],e.ignoreBoundary)){for(var g=!1,x=1;x<f[d].length&&!g;)FM(o,f[d][x],!e.ignoreBoundary)&&(g=!0),x++;g||(p=!0)}return p}function FM(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 iB(r,t){return t[0]<=r[0]&&t[1]<=r[1]&&t[2]>=r[0]&&t[3]>=r[1]}var zM=new ArrayBuffer(16),n8=new Float64Array(zM),r8=new Uint32Array(zM);var _B=yn(mg(),1);var PW=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 xB(l,this.points[a],this.controls[a][1],this.controls[a+1][0],this.points[a+1])},r}();function xB(r,t,e,o,a){var l=EB(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 EB(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 Gl(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 Hn([[h,d,p,f,h]],t.properties,{bbox:r,id:t.id})}function MB(r){return Gl(di(r))}var gg=MB;var zB=yn(JM(),1);var hz=yn(hh(),1);var dz=yn(Zf(),1);var yz=yn(mg(),1);var dS=Math.PI/180,mS=180/Math.PI,Yl=function(r,t){this.lon=r,this.lat=t,this.x=dS*r,this.y=dS*t};Yl.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)};Yl.prototype.antipode=function(){var r=-1*this.lat,t=this.lon<0?180+this.lon:(180-this.lon)*-1;return new Yl(t,r)};var gS=function(){this.coords=[],this.length=0};gS.prototype.move_to=function(r){this.length++,this.coords.push(r)};var Fg=function(r){this.properties=r||{},this.geometries=[]};Fg.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}};Fg.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 yS=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 Yl(r.x,r.y),this.end=new Yl(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)};yS.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=mS*Math.atan2(l,Math.sqrt(Math.pow(o,2)+Math.pow(a,2))),f=mS*Math.atan2(a,o);return[f,h]};yS.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,v=360-d,M=1;M<e.length;++M){var b=e[M-1][0],T=e[M][0],_=Math.abs(T-b);_>v&&(T>g&&b<x||b>g&&T<x)?f=!0:_>p&&(p=_)}var y=[];if(f&&p<d){var A=[];y.push(A);for(var S=0;S<e.length;++S){var L=parseFloat(e[S][0]);if(S>0&&Math.abs(L-e[S-1][0])>v){var G=parseFloat(e[S-1][0]),z=parseFloat(e[S-1][1]),F=parseFloat(e[S][0]),I=parseFloat(e[S][1]);if(G>-180&&G<x&&F===180&&S+1<e.length&&e[S-1][0]>-180&&e[S-1][0]<x){A.push([-180,e[S][1]]),S++,A.push([e[S][0],e[S][1]]);continue}else if(G>g&&G<180&&F===-180&&S+1<e.length&&e[S-1][0]>g&&e[S-1][0]<180){A.push([180,e[S][1]]),S++,A.push([e[S][0],e[S][1]]);continue}if(G<x&&F>g){var ut=G;G=F,F=ut;var R=z;z=I,I=R}if(G>g&&F<x&&(F+=360),G<=180&&F>=180&&G<F){var W=(180-G)/(F-G),V=W*I+(1-W)*z;A.push([e[S-1][0]>g?180:-180,V]),A=[],A.push([e[S-1][0]>g?-180:180,V]),y.push(A)}else A=[],y.push(A);A.push([L,e[S][1]])}else A.push([e[S][0],e[S][1]])}}else{var Mt=[];y.push(Mt);for(var X=0;X<e.length;++X)Mt.push([e[X][0],e[X][1]])}for(var mt=new Fg(this.properties),dt=0;dt<y.length;++dt){var _t=new gS;mt.geometries.push(_t);for(var it=y[dt],lt=0;lt<it.length;++lt)_t.move_to(it[lt])}return mt};var xz=yn(hh(),1);var _k=yn(hh(),1);var xk=yn(c0(),1);var Sk=yn(Zf(),1);var be=[],Te=[],Ae=[],Ce=[],Pe=[],Ie=[],Re=[],Le=[],Ne=[],Oe=[],De=[],Fe=[],Ue=[],Be=[],ze=[],Ge=[],ke=[],qe=[],Ve=[],He=[],We=[],Xe=[],Ye=[],$e=[];Re[85]=Oe[85]=-1;Le[85]=De[85]=0;Ne[85]=Fe[85]=1;Ve[85]=Xe[85]=1;He[85]=Ye[85]=0;We[85]=$e[85]=1;be[85]=Ce[85]=0;Te[85]=Pe[85]=-1;Ae[85]=ze[85]=0;Ge[85]=Ue[85]=0;ke[85]=Be[85]=1;Ie[85]=qe[85]=1;Xe[1]=Xe[169]=0;Ye[1]=Ye[169]=-1;$e[1]=$e[169]=0;Ue[1]=Ue[169]=-1;Be[1]=Be[169]=0;ze[1]=ze[169]=0;Oe[4]=Oe[166]=0;De[4]=De[166]=-1;Fe[4]=Fe[166]=1;Ge[4]=Ge[166]=1;ke[4]=ke[166]=0;qe[4]=qe[166]=0;Re[16]=Re[154]=0;Le[16]=Le[154]=1;Ne[16]=Ne[154]=1;Ce[16]=Ce[154]=1;Pe[16]=Pe[154]=0;Ie[16]=Ie[154]=1;Ve[64]=Ve[106]=0;He[64]=He[106]=1;We[64]=We[106]=0;be[64]=be[106]=-1;Te[64]=Te[106]=0;Ae[64]=Ae[106]=1;Ve[2]=Ve[168]=0;He[2]=He[168]=-1;We[2]=We[168]=1;Xe[2]=Xe[168]=0;Ye[2]=Ye[168]=-1;$e[2]=$e[168]=0;Ue[2]=Ue[168]=-1;Be[2]=Be[168]=0;ze[2]=ze[168]=0;Ge[2]=Ge[168]=-1;ke[2]=ke[168]=0;qe[2]=qe[168]=1;Re[8]=Re[162]=0;Le[8]=Le[162]=-1;Ne[8]=Ne[162]=0;Oe[8]=Oe[162]=0;De[8]=De[162]=-1;Fe[8]=Fe[162]=1;Ue[8]=Ue[162]=1;Be[8]=Be[162]=0;ze[8]=ze[162]=1;Ge[8]=Ge[162]=1;ke[8]=ke[162]=0;qe[8]=qe[162]=0;Re[32]=Re[138]=0;Le[32]=Le[138]=1;Ne[32]=Ne[138]=1;Oe[32]=Oe[138]=0;De[32]=De[138]=1;Fe[32]=Fe[138]=0;be[32]=be[138]=1;Te[32]=Te[138]=0;Ae[32]=Ae[138]=0;Ce[32]=Ce[138]=1;Pe[32]=Pe[138]=0;Ie[32]=Ie[138]=1;Xe[128]=Xe[42]=0;Ye[128]=Ye[42]=1;$e[128]=$e[42]=1;Ve[128]=Ve[42]=0;He[128]=He[42]=1;We[128]=We[42]=0;be[128]=be[42]=-1;Te[128]=Te[42]=0;Ae[128]=Ae[42]=1;Ce[128]=Ce[42]=-1;Pe[128]=Pe[42]=0;Ie[128]=Ie[42]=0;Oe[5]=Oe[165]=-1;De[5]=De[165]=0;Fe[5]=Fe[165]=0;Xe[5]=Xe[165]=1;Ye[5]=Ye[165]=0;$e[5]=$e[165]=0;Ge[20]=Ge[150]=0;ke[20]=ke[150]=1;qe[20]=qe[150]=1;Ce[20]=Ce[150]=0;Pe[20]=Pe[150]=-1;Ie[20]=Ie[150]=1;Re[80]=Re[90]=-1;Le[80]=Le[90]=0;Ne[80]=Ne[90]=1;Ve[80]=Ve[90]=1;He[80]=He[90]=0;We[80]=We[90]=1;Ue[65]=Ue[105]=0;Be[65]=Be[105]=1;ze[65]=ze[105]=0;be[65]=be[105]=0;Te[65]=Te[105]=-1;Ae[65]=Ae[105]=0;Re[160]=Re[10]=-1;Le[160]=Le[10]=0;Ne[160]=Ne[10]=1;Oe[160]=Oe[10]=-1;De[160]=De[10]=0;Fe[160]=Fe[10]=0;Xe[160]=Xe[10]=1;Ye[160]=Ye[10]=0;$e[160]=$e[10]=0;Ve[160]=Ve[10]=1;He[160]=He[10]=0;We[160]=We[10]=1;Ge[130]=Ge[40]=0;ke[130]=ke[40]=1;qe[130]=qe[40]=1;Ue[130]=Ue[40]=0;Be[130]=Be[40]=1;ze[130]=ze[40]=0;be[130]=be[40]=0;Te[130]=Te[40]=-1;Ae[130]=Ae[40]=0;Ce[130]=Ce[40]=0;Pe[130]=Pe[40]=-1;Ie[130]=Ie[40]=1;Oe[37]=Oe[133]=0;De[37]=De[133]=1;Fe[37]=Fe[133]=1;Xe[37]=Xe[133]=0;Ye[37]=Ye[133]=1;$e[37]=$e[133]=0;be[37]=be[133]=-1;Te[37]=Te[133]=0;Ae[37]=Ae[133]=0;Ce[37]=Ce[133]=1;Pe[37]=Pe[133]=0;Ie[37]=Ie[133]=0;Ge[148]=Ge[22]=-1;ke[148]=ke[22]=0;qe[148]=qe[22]=0;Xe[148]=Xe[22]=0;Ye[148]=Ye[22]=-1;$e[148]=$e[22]=1;Ve[148]=Ve[22]=0;He[148]=He[22]=1;We[148]=We[22]=1;Ce[148]=Ce[22]=-1;Pe[148]=Pe[22]=0;Ie[148]=Ie[22]=1;Re[82]=Re[88]=0;Le[82]=Le[88]=-1;Ne[82]=Ne[88]=1;Ge[82]=Ge[88]=1;ke[82]=ke[88]=0;qe[82]=qe[88]=1;Ue[82]=Ue[88]=-1;Be[82]=Be[88]=0;ze[82]=ze[88]=1;Ve[82]=Ve[88]=0;He[82]=He[88]=-1;We[82]=We[88]=0;Re[73]=Re[97]=0;Le[73]=Le[97]=1;Ne[73]=Ne[97]=0;Oe[73]=Oe[97]=0;De[73]=De[97]=-1;Fe[73]=Fe[97]=0;Ue[73]=Ue[97]=1;Be[73]=Be[97]=0;ze[73]=ze[97]=0;be[73]=be[97]=1;Te[73]=Te[97]=0;Ae[73]=Ae[97]=1;Re[145]=Re[25]=0;Le[145]=Le[25]=-1;Ne[145]=Ne[25]=0;Ue[145]=Ue[25]=1;Be[145]=Be[25]=0;ze[145]=ze[25]=1;Xe[145]=Xe[25]=0;Ye[145]=Ye[25]=1;$e[145]=$e[25]=1;Ce[145]=Ce[25]=-1;Pe[145]=Pe[25]=0;Ie[145]=Ie[25]=0;Oe[70]=Oe[100]=0;De[70]=De[100]=1;Fe[70]=Fe[100]=0;Ge[70]=Ge[100]=-1;ke[70]=ke[100]=0;qe[70]=qe[100]=1;Ve[70]=Ve[100]=0;He[70]=He[100]=-1;We[70]=We[100]=1;be[70]=be[100]=1;Te[70]=Te[100]=0;Ae[70]=Ae[100]=0;Oe[101]=Oe[69]=0;De[101]=De[69]=1;Fe[101]=Fe[69]=0;be[101]=be[69]=1;Te[101]=Te[69]=0;Ae[101]=Ae[69]=0;Xe[149]=Xe[21]=0;Ye[149]=Ye[21]=1;$e[149]=$e[21]=1;Ce[149]=Ce[21]=-1;Pe[149]=Pe[21]=0;Ie[149]=Ie[21]=0;Ge[86]=Ge[84]=-1;ke[86]=ke[84]=0;qe[86]=qe[84]=1;Ve[86]=Ve[84]=0;He[86]=He[84]=-1;We[86]=We[84]=1;Re[89]=Re[81]=0;Le[89]=Le[81]=-1;Ne[89]=Ne[81]=0;Ue[89]=Ue[81]=1;Be[89]=Be[81]=0;ze[89]=ze[81]=1;Re[96]=Re[74]=0;Le[96]=Le[74]=1;Ne[96]=Ne[74]=0;Oe[96]=Oe[74]=-1;De[96]=De[74]=0;Fe[96]=Fe[74]=1;Ve[96]=Ve[74]=1;He[96]=He[74]=0;We[96]=We[74]=0;be[96]=be[74]=1;Te[96]=Te[74]=0;Ae[96]=Ae[74]=1;Re[24]=Re[146]=0;Le[24]=Le[146]=-1;Ne[24]=Ne[146]=1;Ge[24]=Ge[146]=1;ke[24]=ke[146]=0;qe[24]=qe[146]=1;Ue[24]=Ue[146]=0;Be[24]=Be[146]=1;ze[24]=ze[146]=1;Ce[24]=Ce[146]=0;Pe[24]=Pe[146]=-1;Ie[24]=Ie[146]=0;Oe[6]=Oe[164]=-1;De[6]=De[164]=0;Fe[6]=Fe[164]=1;Ge[6]=Ge[164]=-1;ke[6]=ke[164]=0;qe[6]=qe[164]=0;Xe[6]=Xe[164]=0;Ye[6]=Ye[164]=-1;$e[6]=$e[164]=1;Ve[6]=Ve[164]=1;He[6]=He[164]=0;We[6]=We[164]=0;Ue[129]=Ue[41]=0;Be[129]=Be[41]=1;ze[129]=ze[41]=1;Xe[129]=Xe[41]=0;Ye[129]=Ye[41]=1;$e[129]=$e[41]=0;be[129]=be[41]=-1;Te[129]=Te[41]=0;Ae[129]=Ae[41]=0;Ce[129]=Ce[41]=0;Pe[129]=Pe[41]=-1;Ie[129]=Ie[41]=0;Ge[66]=Ge[104]=0;ke[66]=ke[104]=1;qe[66]=qe[104]=0;Ue[66]=Ue[104]=-1;Be[66]=Be[104]=0;ze[66]=ze[104]=1;Ve[66]=Ve[104]=0;He[66]=He[104]=-1;We[66]=We[104]=0;be[66]=be[104]=0;Te[66]=Te[104]=-1;Ae[66]=Ae[104]=1;Re[144]=Re[26]=-1;Le[144]=Le[26]=0;Ne[144]=Ne[26]=0;Xe[144]=Xe[26]=1;Ye[144]=Ye[26]=0;$e[144]=$e[26]=1;Ve[144]=Ve[26]=0;He[144]=He[26]=1;We[144]=We[26]=1;Ce[144]=Ce[26]=-1;Pe[144]=Pe[26]=0;Ie[144]=Ie[26]=1;Oe[36]=Oe[134]=0;De[36]=De[134]=1;Fe[36]=Fe[134]=1;Ge[36]=Ge[134]=0;ke[36]=ke[134]=1;qe[36]=qe[134]=0;be[36]=be[134]=0;Te[36]=Te[134]=-1;Ae[36]=Ae[134]=1;Ce[36]=Ce[134]=1;Pe[36]=Pe[134]=0;Ie[36]=Ie[134]=0;Re[9]=Re[161]=-1;Le[9]=Le[161]=0;Ne[9]=Ne[161]=0;Oe[9]=Oe[161]=0;De[9]=De[161]=-1;Fe[9]=Fe[161]=0;Ue[9]=Ue[161]=1;Be[9]=Be[161]=0;ze[9]=ze[161]=0;Xe[9]=Xe[161]=1;Ye[9]=Ye[161]=0;$e[9]=$e[161]=1;Re[136]=0;Le[136]=1;Ne[136]=1;Oe[136]=0;De[136]=1;Fe[136]=0;Ge[136]=-1;ke[136]=0;qe[136]=1;Ue[136]=-1;Be[136]=0;ze[136]=0;Xe[136]=0;Ye[136]=-1;$e[136]=0;Ve[136]=0;He[136]=-1;We[136]=1;be[136]=1;Te[136]=0;Ae[136]=0;Ce[136]=1;Pe[136]=0;Ie[136]=1;Re[34]=0;Le[34]=-1;Ne[34]=0;Oe[34]=0;De[34]=-1;Fe[34]=1;Ge[34]=1;ke[34]=0;qe[34]=0;Ue[34]=1;Be[34]=0;ze[34]=1;Xe[34]=0;Ye[34]=1;$e[34]=1;Ve[34]=0;He[34]=1;We[34]=0;be[34]=-1;Te[34]=0;Ae[34]=1;Ce[34]=-1;Pe[34]=0;Ie[34]=0;Re[35]=0;Le[35]=1;Ne[35]=1;Oe[35]=0;De[35]=-1;Fe[35]=1;Ge[35]=1;ke[35]=0;qe[35]=0;Ue[35]=-1;Be[35]=0;ze[35]=0;Xe[35]=0;Ye[35]=-1;$e[35]=0;Ve[35]=0;He[35]=1;We[35]=0;be[35]=-1;Te[35]=0;Ae[35]=1;Ce[35]=1;Pe[35]=0;Ie[35]=1;Re[153]=0;Le[153]=1;Ne[153]=1;Ue[153]=-1;Be[153]=0;ze[153]=0;Xe[153]=0;Ye[153]=-1;$e[153]=0;Ce[153]=1;Pe[153]=0;Ie[153]=1;Oe[102]=0;De[102]=-1;Fe[102]=1;Ge[102]=1;ke[102]=0;qe[102]=0;Ve[102]=0;He[102]=1;We[102]=0;be[102]=-1;Te[102]=0;Ae[102]=1;Re[155]=0;Le[155]=-1;Ne[155]=0;Ue[155]=1;Be[155]=0;ze[155]=1;Xe[155]=0;Ye[155]=1;$e[155]=1;Ce[155]=-1;Pe[155]=0;Ie[155]=0;Oe[103]=0;De[103]=1;Fe[103]=0;Ge[103]=-1;ke[103]=0;qe[103]=1;Ve[103]=0;He[103]=-1;We[103]=1;be[103]=1;Te[103]=0;Ae[103]=0;Re[152]=0;Le[152]=1;Ne[152]=1;Ge[152]=-1;ke[152]=0;qe[152]=1;Ue[152]=-1;Be[152]=0;ze[152]=0;Xe[152]=0;Ye[152]=-1;$e[152]=0;Ve[152]=0;He[152]=-1;We[152]=1;Ce[152]=1;Pe[152]=0;Ie[152]=1;Re[156]=0;Le[156]=-1;Ne[156]=1;Ge[156]=1;ke[156]=0;qe[156]=1;Ue[156]=-1;Be[156]=0;ze[156]=0;Xe[156]=0;Ye[156]=-1;$e[156]=0;Ve[156]=0;He[156]=1;We[156]=1;Ce[156]=-1;Pe[156]=0;Ie[156]=1;Re[137]=0;Le[137]=1;Ne[137]=1;Oe[137]=0;De[137]=1;Fe[137]=0;Ue[137]=-1;Be[137]=0;ze[137]=0;Xe[137]=0;Ye[137]=-1;$e[137]=0;be[137]=1;Te[137]=0;Ae[137]=0;Ce[137]=1;Pe[137]=0;Ie[137]=1;Re[139]=0;Le[139]=1;Ne[139]=1;Oe[139]=0;De[139]=-1;Fe[139]=0;Ue[139]=1;Be[139]=0;ze[139]=0;Xe[139]=0;Ye[139]=1;$e[139]=0;be[139]=-1;Te[139]=0;Ae[139]=0;Ce[139]=1;Pe[139]=0;Ie[139]=1;Re[98]=0;Le[98]=-1;Ne[98]=0;Oe[98]=0;De[98]=-1;Fe[98]=1;Ge[98]=1;ke[98]=0;qe[98]=0;Ue[98]=1;Be[98]=0;ze[98]=1;Ve[98]=0;He[98]=1;We[98]=0;be[98]=-1;Te[98]=0;Ae[98]=1;Re[99]=0;Le[99]=1;Ne[99]=0;Oe[99]=0;De[99]=-1;Fe[99]=1;Ge[99]=1;ke[99]=0;qe[99]=0;Ue[99]=-1;Be[99]=0;ze[99]=1;Ve[99]=0;He[99]=-1;We[99]=0;be[99]=1;Te[99]=0;Ae[99]=1;Oe[38]=0;De[38]=-1;Fe[38]=1;Ge[38]=1;ke[38]=0;qe[38]=0;Xe[38]=0;Ye[38]=1;$e[38]=1;Ve[38]=0;He[38]=1;We[38]=0;be[38]=-1;Te[38]=0;Ae[38]=1;Ce[38]=-1;Pe[38]=0;Ie[38]=0;Oe[39]=0;De[39]=1;Fe[39]=1;Ge[39]=-1;ke[39]=0;qe[39]=0;Xe[39]=0;Ye[39]=-1;$e[39]=1;Ve[39]=0;He[39]=1;We[39]=0;be[39]=-1;Te[39]=0;Ae[39]=1;Ce[39]=1;Pe[39]=0;Ie[39]=0;var f0=function(r){return[[r.bottomleft,0],[0,0],[0,r.leftbottom]]},h0=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0]]},p0=function(r){return[[r.topright,1],[1,1],[1,r.righttop]]},d0=function(r){return[[0,r.lefttop],[0,1],[r.topleft,1]]},m0=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop]]},g0=function(r){return[[r.bottomright,0],[r.bottomleft,0],[1,r.righttop],[1,r.rightbottom]]},y0=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.topleft,1],[r.topright,1]]},v0=function(r){return[[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},wk=function(r){return[[0,0],[0,r.leftbottom],[1,r.rightbottom],[1,0]]},bk=function(r){return[[1,0],[r.bottomright,0],[r.topright,1],[1,1]]},Tk=function(r){return[[1,1],[1,r.righttop],[0,r.lefttop],[0,1]]},Ak=function(r){return[[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},Ck=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.leftbottom],[0,r.lefttop]]},Pk=function(r){return[[r.topleft,1],[r.topright,1],[r.bottomright,0],[r.bottomleft,0]]},Ik=function(){return[[0,0],[0,1],[1,1],[1,0]]},Rk=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,1],[r.topleft,1]]},Lk=function(r){return[[r.topright,1],[1,1],[1,0],[0,0],[0,r.leftbottom]]},Nk=function(r){return[[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[1,1]]},Ok=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,1]]},Dk=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.lefttop],[0,1],[r.topleft,1]]},Fk=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[r.topright,1]]},Uk=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop]]},Bk=function(r){return[[r.topright,1],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1]]},zk=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},Gk=function(r){return[[1,1],[1,r.righttop],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},kk=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[r.topleft,1],[r.topright,1]]},qk=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom]]},Vk=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},Hk=function(r){return[[1,1],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},Wk=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1]]},Xk=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},Yk=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},$k=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},Zk=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]]},Jk=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},Kk=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},jk=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},Qk=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},t4=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},e4=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},je=[],Qe=[],tn=[],en=[],nn=[],rn=[],on=[],sn=[];en[1]=nn[1]=18;en[169]=nn[169]=18;tn[4]=Qe[4]=12;tn[166]=Qe[166]=12;je[16]=sn[16]=4;je[154]=sn[154]=4;rn[64]=on[64]=22;rn[106]=on[106]=22;tn[2]=rn[2]=17;en[2]=nn[2]=18;tn[168]=rn[168]=17;en[168]=nn[168]=18;je[8]=en[8]=9;Qe[8]=tn[8]=12;je[162]=en[162]=9;Qe[162]=tn[162]=12;je[32]=sn[32]=4;Qe[32]=on[32]=1;je[138]=sn[138]=4;Qe[138]=on[138]=1;nn[128]=sn[128]=21;rn[128]=on[128]=22;nn[42]=sn[42]=21;rn[42]=on[42]=22;Qe[5]=nn[5]=14;Qe[165]=nn[165]=14;tn[20]=sn[20]=6;tn[150]=sn[150]=6;je[80]=rn[80]=11;je[90]=rn[90]=11;en[65]=on[65]=3;en[105]=on[105]=3;je[160]=rn[160]=11;Qe[160]=nn[160]=14;je[10]=rn[10]=11;Qe[10]=nn[10]=14;tn[130]=sn[130]=6;en[130]=on[130]=3;tn[40]=sn[40]=6;en[40]=on[40]=3;Qe[101]=on[101]=1;Qe[69]=on[69]=1;nn[149]=sn[149]=21;nn[21]=sn[21]=21;tn[86]=rn[86]=17;tn[84]=rn[84]=17;je[89]=en[89]=9;je[81]=en[81]=9;je[96]=on[96]=0;Qe[96]=rn[96]=15;je[74]=on[74]=0;Qe[74]=rn[74]=15;je[24]=tn[24]=8;en[24]=sn[24]=7;je[146]=tn[146]=8;en[146]=sn[146]=7;Qe[6]=rn[6]=15;tn[6]=nn[6]=16;Qe[164]=rn[164]=15;tn[164]=nn[164]=16;en[129]=sn[129]=7;nn[129]=on[129]=20;en[41]=sn[41]=7;nn[41]=on[41]=20;tn[66]=on[66]=2;en[66]=rn[66]=19;tn[104]=on[104]=2;en[104]=rn[104]=19;je[144]=nn[144]=10;rn[144]=sn[144]=23;je[26]=nn[26]=10;rn[26]=sn[26]=23;Qe[36]=sn[36]=5;tn[36]=on[36]=2;Qe[134]=sn[134]=5;tn[134]=on[134]=2;je[9]=nn[9]=10;Qe[9]=en[9]=13;je[161]=nn[161]=10;Qe[161]=en[161]=13;Qe[37]=sn[37]=5;nn[37]=on[37]=20;Qe[133]=sn[133]=5;nn[133]=on[133]=20;tn[148]=nn[148]=16;rn[148]=sn[148]=23;tn[22]=nn[22]=16;rn[22]=sn[22]=23;je[82]=tn[82]=8;en[82]=rn[82]=19;je[88]=tn[88]=8;en[88]=rn[88]=19;je[73]=on[73]=0;Qe[73]=en[73]=13;je[97]=on[97]=0;Qe[97]=en[97]=13;je[145]=en[145]=9;nn[145]=sn[145]=21;je[25]=en[25]=9;nn[25]=sn[25]=21;Qe[70]=on[70]=1;tn[70]=rn[70]=17;Qe[100]=on[100]=1;tn[100]=rn[100]=17;je[34]=en[34]=9;Qe[34]=tn[34]=12;nn[34]=sn[34]=21;rn[34]=on[34]=22;je[136]=sn[136]=4;Qe[136]=on[136]=1;tn[136]=rn[136]=17;en[136]=nn[136]=18;je[35]=sn[35]=4;Qe[35]=tn[35]=12;en[35]=nn[35]=18;rn[35]=on[35]=22;je[153]=sn[153]=4;en[153]=nn[153]=18;Qe[102]=tn[102]=12;rn[102]=on[102]=22;je[155]=en[155]=9;nn[155]=sn[155]=23;Qe[103]=on[103]=1;tn[103]=rn[103]=17;je[152]=sn[152]=4;tn[152]=rn[152]=17;en[152]=nn[152]=18;je[156]=tn[156]=8;en[156]=nn[156]=18;rn[156]=sn[156]=23;je[137]=sn[137]=4;Qe[137]=on[137]=1;en[137]=nn[137]=18;je[139]=sn[139]=4;Qe[139]=en[139]=13;nn[139]=on[139]=20;je[98]=en[98]=9;Qe[98]=tn[98]=12;rn[98]=on[98]=22;je[99]=on[99]=0;Qe[99]=tn[99]=12;en[99]=rn[99]=19;Qe[38]=tn[38]=12;nn[38]=sn[38]=21;rn[38]=on[38]=22;Qe[39]=sn[39]=5;tn[39]=nn[39]=16;rn[39]=on[39]=22;var Gt=[];Gt[1]=Gt[169]=f0;Gt[4]=Gt[166]=h0;Gt[16]=Gt[154]=p0;Gt[64]=Gt[106]=d0;Gt[168]=Gt[2]=m0;Gt[162]=Gt[8]=g0;Gt[138]=Gt[32]=y0;Gt[42]=Gt[128]=v0;Gt[5]=Gt[165]=wk;Gt[20]=Gt[150]=bk;Gt[80]=Gt[90]=Tk;Gt[65]=Gt[105]=Ak;Gt[160]=Gt[10]=Ck;Gt[130]=Gt[40]=Pk;Gt[85]=Ik;Gt[101]=Gt[69]=Rk;Gt[149]=Gt[21]=Lk;Gt[86]=Gt[84]=Nk;Gt[89]=Gt[81]=Ok;Gt[96]=Gt[74]=Dk;Gt[24]=Gt[146]=Fk;Gt[6]=Gt[164]=Uk;Gt[129]=Gt[41]=Bk;Gt[66]=Gt[104]=zk;Gt[144]=Gt[26]=Gk;Gt[36]=Gt[134]=kk;Gt[9]=Gt[161]=qk;Gt[37]=Gt[133]=Vk;Gt[148]=Gt[22]=Hk;Gt[82]=Gt[88]=Wk;Gt[73]=Gt[97]=Xk;Gt[145]=Gt[25]=Yk;Gt[70]=Gt[100]=$k;Gt[34]=function(r){return[v0(r),g0(r)]};Gt[35]=Zk;Gt[136]=function(r){return[y0(r),m0(r)]};Gt[153]=function(r){return[p0(r),f0(r)]};Gt[102]=function(r){return[h0(r),d0(r)]};Gt[155]=Jk;Gt[103]=Kk;Gt[152]=function(r){return[p0(r),m0(r)]};Gt[156]=jk;Gt[137]=function(r){return[y0(r),f0(r)]};Gt[139]=Qk;Gt[98]=function(r){return[g0(r),d0(r)]};Gt[99]=t4;Gt[38]=function(r){return[h0(r),v0(r)]};Gt[39]=e4;function r4(r){return(r>0)-(r<0)||+r}function Hu(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 r4(o*h-l*a)}function iT(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 _0(r,t){return t.geometry.coordinates[0].every(function(e){return Ir(Nn(e),r)})}function oT(r,t){return r[0]===t[0]&&r[1]===t[1]}var i4=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=Hu(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}(),x0=i4;var o4=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 Pr([this.from.coordinates,this.to.coordinates])},r.prototype.compareTo=function(t){return Hu(t.from.coordinates,t.to.coordinates,this.to.coordinates)},r}(),sT=o4;var s4=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=Hu(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 Km(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=Hn([t])},r.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=gg(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()),!iT(f,o)&&_0(f,o)){for(var p=t.map(function(b){return b.from.coordinates}),d=void 0,g=function(b){h.some(function(T){return oT(b,T.from.coordinates)})||(d=b)},x=0,v=p;x<v.length;x++){var M=v[x];g(M)}d&&h.inside(Nn(d))&&(!l||_0(a,f))&&(l=h)}}),l},r.prototype.inside=function(t){return Ir(t,this.toPolygon())},r}(),E0=s4;function a4(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 UZ=function(){function r(){this.edges=[],this.nodes={}}return r.fromGeoJson=function(t){a4(t);var e=new r;return Oi(t,function(o){Qm(o,"LineString","Graph::fromGeoJson"),yM(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=x0.buildId(t),o=this.nodes[e];return o||(o=this.nodes[e]=new x0(t)),o},r.prototype.addEdge=function(t,e){var o=new sT(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 E0;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 f4=yn(M0(),1);var h4=yn(M0(),1);var d4=yn(mT(),1);var E4=yn(bT(),1);function AT(r){for(var t=r,e=[];t.parent;)e.unshift(t),t=t.parent;return e}function S4(){return new CT(function(r){return r.f})}var T0={search:function(r,t,e,o){r.cleanDirty(),o=o||{};var a=o.heuristic||T0.heuristics.manhattan,l=o.closest||!1,h=S4(),f=t;for(t.h=a(t,e),h.push(t);h.size()>0;){var p=h.pop();if(p===e)return AT(p);p.closed=!0;for(var d=r.neighbors(p),g=0,x=d.length;g<x;++g){var v=d[g];if(!(v.closed||v.isWall())){var M=p.g+v.getCost(p),b=v.visited;(!b||M<v.g)&&(v.visited=!0,v.parent=p,v.h=v.h||a(v,e),v.g=M,v.f=v.g+v.h,r.markDirty(v),l&&(v.h<f.h||v.h===f.h&&v.g<f.g)&&(f=v),b?h.rescoreElement(v):h.push(v))}}}return l?AT(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 nc(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 zh(e,o,a[o]);this.grid[e][o]=l,this.nodes.push(l)}}this.init()}nc.prototype.init=function(){this.dirtyNodes=[];for(var r=0;r<this.nodes.length;r++)T0.cleanNode(this.nodes[r])};nc.prototype.cleanDirty=function(){for(var r=0;r<this.dirtyNodes.length;r++)T0.cleanNode(this.dirtyNodes[r]);this.dirtyNodes=[]};nc.prototype.markDirty=function(r){this.dirtyNodes.push(r)};nc.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};nc.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(\`
23647
23647
  \`)};function zh(r,t,e){this.x=r,this.y=t,this.weight=e}zh.prototype.toString=function(){return"["+this.x+" "+this.y+"]"};zh.prototype.getCost=function(r){return r&&r.x!==this.x&&r.y!==this.y?this.weight*1.41421:this.weight};zh.prototype.isWall=function(){return this.weight===0};function CT(r){this.content=[],this.scoreFunction=r}CT.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 A0(){this._=null}function Xu(r){r.U=r.C=r.L=r.R=r.P=r.N=null}A0.prototype={constructor:A0,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=PT(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&&(rc(this,e),r=e,e=r.U),e.C=!1,o.C=!0,ic(this,o))):(a=o.L,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.L&&(ic(this,e),r=e,e=r.U),e.C=!1,o.C=!0,rc(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=PT(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,rc(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,ic(this,e),e=t.R),e.C=t.C,t.C=e.R.C=!1,rc(this,t),r=this._;break}}else if(e=t.L,e.C&&(e.C=!1,t.C=!0,ic(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,rc(this,e),e=t.L),e.C=t.C,t.C=e.L.C=!1,ic(this,t),r=this._;break}e.C=!0,r=t,t=t.U}while(!r.C);r&&(r.C=!1)}}};function rc(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 ic(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 PT(r){for(;r.L;)r=r.L;return r}var C0=A0;function Yu(r,t,e,o){var a=[null,null],l=Lr.push(a)-1;return a.left=r,a.right=t,e&&oc(a,r,t,e),o&&oc(a,t,r,o),mi[r.index].halfedges.push(l),mi[t.index].halfedges.push(l),a}function $u(r,t,e){var o=[t,e];return o.left=r,o}function oc(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 w4(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,v=1,M=d-f,b=g-p,T;if(T=t-f,!(!M&&T>0)){if(T/=M,M<0){if(T<x)return;T<v&&(v=T)}else if(M>0){if(T>v)return;T>x&&(x=T)}if(T=o-f,!(!M&&T<0)){if(T/=M,M<0){if(T>v)return;T>x&&(x=T)}else if(M>0){if(T<x)return;T<v&&(v=T)}if(T=e-p,!(!b&&T>0)){if(T/=b,b<0){if(T<x)return;T<v&&(v=T)}else if(b>0){if(T>v)return;T>x&&(x=T)}if(T=a-p,!(!b&&T<0)){if(T/=b,b<0){if(T>v)return;T>x&&(x=T)}else if(b>0){if(T<x)return;T<v&&(v=T)}return!(x>0)&&!(v<1)||(x>0&&(r[0]=[f+x*M,p+x*b]),v<1&&(r[1]=[f+v*M,p+v*b])),!0}}}}}function b4(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],v=p[1],M=(d+x)/2,b=(g+v)/2,T,_;if(v===g){if(M<t||M>=o)return;if(d>x){if(!h)h=[M,e];else if(h[1]>=a)return;l=[M,a]}else{if(!h)h=[M,a];else if(h[1]<e)return;l=[M,e]}}else if(T=(d-x)/(v-g),_=b-T*M,T<-1||T>1)if(d>x){if(!h)h=[(e-_)/T,e];else if(h[1]>=a)return;l=[(a-_)/T,a]}else{if(!h)h=[(a-_)/T,a];else if(h[1]<e)return;l=[(e-_)/T,e]}else if(g<v){if(!h)h=[t,T*t+_];else if(h[0]>=o)return;l=[o,T*o+_]}else{if(!h)h=[o,T*o+_];else if(h[0]<t)return;l=[t,T*t+_]}return r[0]=h,r[1]=l,!0}function IT(r,t,e,o){for(var a=Lr.length,l;a--;)(!b4(l=Lr[a],r,t,e,o)||!w4(l,r,t,e,o)||!(Math.abs(l[0][0]-l[1][0])>Pn||Math.abs(l[0][1]-l[1][1])>Pn))&&delete Lr[a]}function RT(r){return mi[r.index]={site:r,halfedges:[]}}function T4(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 P0(r,t){return t[+(t.left!==r.site)]}function A4(r,t){return t[+(t.left===r.site)]}function LT(){for(var r=0,t=mi.length,e,o,a,l;r<t;++r)if((e=mi[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]=T4(e,Lr[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 NT(r,t,e,o){var a=mi.length,l,h,f,p,d,g,x,v,M,b,T,_,y=!0;for(l=0;l<a;++l)if(h=mi[l]){for(f=h.site,d=h.halfedges,p=d.length;p--;)Lr[d[p]]||d.splice(p,1);for(p=0,g=d.length;p<g;)b=A4(h,Lr[d[p]]),T=b[0],_=b[1],x=P0(h,Lr[d[++p%g]]),v=x[0],M=x[1],(Math.abs(T-v)>Pn||Math.abs(_-M)>Pn)&&(d.splice(p,0,Lr.push($u(f,b,Math.abs(T-r)<Pn&&o-_>Pn?[r,Math.abs(v-r)<Pn?M:o]:Math.abs(_-o)<Pn&&e-T>Pn?[Math.abs(M-o)<Pn?v:e,o]:Math.abs(T-e)<Pn&&_-t>Pn?[e,Math.abs(v-e)<Pn?M:t]:Math.abs(_-t)<Pn&&T-r>Pn?[Math.abs(M-t)<Pn?v:r,t]:null))-1),++g);g&&(y=!1)}if(y){var A,S,L,G=1/0;for(l=0,y=null;l<a;++l)(h=mi[l])&&(f=h.site,A=f[0]-r,S=f[1]-t,L=A*A+S*S,L<G&&(G=L,y=h));if(y){var z=[r,t],F=[r,o],I=[e,o],ut=[e,t];y.halfedges.push(Lr.push($u(f=y.site,z,F))-1,Lr.push($u(f,F,I))-1,Lr.push($u(f,I,ut))-1,Lr.push($u(f,ut,z))-1)}}for(l=0;l<a;++l)(h=mi[l])&&(h.halfedges.length||delete mi[l])}var OT=[],Gh;function C4(){Xu(this),this.x=this.y=this.arc=this.site=this.cy=null}function Ca(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,v=2*(p*x-d*g);if(!(v>=-DT)){var M=p*p+d*d,b=g*g+x*x,T=(x*M-d*b)/v,_=(p*b-g*M)/v,y=OT.pop()||new C4;y.arc=r,y.site=a,y.x=T+h,y.y=(y.cy=_+f)+Math.sqrt(T*T+_*_),r.circle=y;for(var A=null,S=Zu._;S;)if(y.y<S.y||y.y===S.y&&y.x<=S.x)if(S.L)S=S.L;else{A=S.P;break}else if(S.R)S=S.R;else{A=S;break}Zu.insert(A,y),A||(Gh=y)}}}}function Pa(r){var t=r.circle;t&&(t.P||(Gh=t.N),Zu.remove(t),OT.push(t),Xu(t),r.circle=null)}var UT=[];function P4(){Xu(this),this.edge=this.site=this.circle=null}function FT(r){var t=UT.pop()||new P4;return t.site=r,t}function I0(r){Pa(r),Ia.remove(r),UT.push(r),Xu(r)}function BT(r){var t=r.circle,e=t.x,o=t.cy,a=[e,o],l=r.P,h=r.N,f=[r];I0(r);for(var p=l;p.circle&&Math.abs(e-p.circle.x)<Pn&&Math.abs(o-p.circle.cy)<Pn;)l=p.P,f.unshift(p),I0(p),p=l;f.unshift(p),Pa(p);for(var d=h;d.circle&&Math.abs(e-d.circle.x)<Pn&&Math.abs(o-d.circle.cy)<Pn;)h=d.N,f.push(d),I0(d),d=h;f.push(d),Pa(d);var g=f.length,x;for(x=1;x<g;++x)d=f[x],p=f[x-1],oc(d.edge,p.site,d.site,a);p=f[0],d=f[g-1],d.edge=Yu(p.site,d.site,null,a),Ca(p),Ca(d)}function zT(r){for(var t=r[0],e=r[1],o,a,l,h,f=Ia._;f;)if(l=GT(f,e)-t,l>Pn)f=f.L;else if(h=t-I4(f,e),h>Pn){if(!f.R){o=f;break}f=f.R}else{l>-Pn?(o=f.P,a=f):h>-Pn?(o=f,a=f.N):o=a=f;break}RT(r);var p=FT(r);if(Ia.insert(o,p),!(!o&&!a)){if(o===a){Pa(o),a=FT(o.site),Ia.insert(p,a),p.edge=a.edge=Yu(o.site,p.site),Ca(o),Ca(a);return}if(!a){p.edge=Yu(o.site,p.site);return}Pa(o),Pa(a);var d=o.site,g=d[0],x=d[1],v=r[0]-g,M=r[1]-x,b=a.site,T=b[0]-g,_=b[1]-x,y=2*(v*_-M*T),A=v*v+M*M,S=T*T+_*_,L=[(_*A-M*S)/y+g,(v*S-T*A)/y+x];oc(a.edge,d,b,L),p.edge=Yu(d,r,null,L),a.edge=Yu(r,b,null,L),Ca(o),Ca(a)}}function GT(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,v=g/d;return x?(-v+Math.sqrt(v*v-2*x*(g*g/(-2*d)-p+d/2+a-l/2)))/x+o:(o+f)/2}function I4(r,t){var e=r.N;if(e)return GT(e,t);var o=r.site;return o[1]===t?o[0]:1/0}var Pn=1e-6,DT=1e-12,Ia,mi,Zu,Lr;function R4(r,t,e){return(r[0]-e[0])*(t[1]-r[1])-(r[0]-t[0])*(e[1]-r[1])}function L4(r,t){return t[1]-r[1]||t[0]-r[0]}function kh(r,t){var e=r.sort(L4).pop(),o,a,l;for(Lr=[],mi=new Array(r.length),Ia=new C0,Zu=new C0;;)if(l=Gh,e&&(!l||e[1]<l.y||e[1]===l.y&&e[0]<l.x))(e[0]!==o||e[1]!==a)&&(zT(e),o=e[0],a=e[1]),e=r.pop();else if(l)BT(l.arc);else break;if(LT(),t){var h=+t[0][0],f=+t[0][1],p=+t[1][0],d=+t[1][1];IT(h,f,p,d),NT(h,f,p,d)}this.edges=Lr,this.cells=mi,Ia=Zu=Lr=mi=null}kh.prototype={constructor:kh,polygons:function(){var r=this.edges;return this.cells.map(function(t){var e=t.halfedges.map(function(o){return P0(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&&R4(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 v=o.edges[x],M=v.left;if(!((M===f.site||!M)&&!(M=v.right))){var b=r-M[0],T=t-M[1],_=b*b+T*T;_<g&&(g=_,l=M.index)}});while(l!==null);return o._found=a,e==null||g<=e*e?f.site:null}};var G4=yn(Ju(),1);var W0=yn(HT(),1);function Mi(){return new Hh}function Hh(){this.reset()}Hh.prototype={constructor:Hh,reset:function(){this.s=this.t=0},add:function(r){WT(Vh,r,this.t),WT(this,Vh.s,this.s),this.s?this.t+=Vh.t:this.s=Vh.t},valueOf:function(){return this.s}};var Vh=new Hh;function WT(r,t,e){var o=r.s=t+e,a=o-t,l=o-a;r.t=t-l+(e-a)}var mn=1e-6;var bn=Math.PI,gr=bn/2,Wh=bn/4,Do=bn*2,Ra=180/bn,Si=bn/180,Zn=Math.abs,yo=Math.atan,wi=Math.atan2,cn=Math.cos;var Xh=Math.exp;var sc=Math.log;var Me=Math.sin;var Vr=Math.sqrt,ac=Math.tan;function N0(r){return r>1?0:r<-1?bn:Math.acos(r)}function gi(r){return r>1?gr:r<-1?-gr:Math.asin(r)}function vo(){}var k4=Mi(),Rj=Mi();function La(r){var t=r[0],e=r[1],o=cn(e);return[o*cn(t),o*Me(t),Me(e)]}function uc(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 lc(r){var t=Vr(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);r[0]/=t,r[1]/=t,r[2]/=t}var kj=Mi();function YT(r,t){return[r>bn?r-Do:r<-bn?r+Do:r,t]}YT.invert=YT;function O0(){var r=[],t;return{point:function(e,o){t.push([e,o])},lineStart:function(){r.push(t=[])},lineEnd:vo,rejoin:function(){r.length>1&&r.push(r.pop().concat(r.shift()))},result:function(){var e=r;return r=[],t=null,e}}}function D0(r,t){return Zn(r[0]-t[0])<mn&&Zn(r[1]-t[1])<mn}function Yh(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 F0(r,t,e,o,a){var l=[],h=[],f,p;if(r.forEach(function(b){if(!((T=b.length-1)<=0)){var T,_=b[0],y=b[T],A;if(D0(_,y)){for(a.lineStart(),f=0;f<T;++f)a.point((_=b[f])[0],_[1]);a.lineEnd();return}l.push(A=new Yh(_,b,null,!0)),h.push(A.o=new Yh(_,null,A,!1)),l.push(A=new Yh(y,b,null,!1)),h.push(A.o=new Yh(y,null,A,!0))}}),!!l.length){for(h.sort(t),$T(l),$T(h),f=0,p=h.length;f<p;++f)h[f].e=e=!e;for(var d=l[0],g,x;;){for(var v=d,M=!0;v.v;)if((v=v.n)===d)return;g=v.z,a.lineStart();do{if(v.v=v.o.v=!0,v.e){if(M)for(f=0,p=g.length;f<p;++f)a.point((x=g[f])[0],x[1]);else o(v.x,v.n.x,1,a);v=v.n}else{if(M)for(g=v.p.z,f=g.length-1;f>=0;--f)a.point((x=g[f])[0],x[1]);else o(v.x,v.p.x,-1,a);v=v.p}v=v.o,g=v.z,M=!M}while(!v.v);a.lineEnd()}}}function $T(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 Hs(r,t){return r<t?-1:r>t?1:r>=t?0:NaN}function U0(r){return r.length===1&&(r=H4(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 H4(r){return function(t,e){return Hs(r(t),e)}}var ZT=U0(Hs),W4=ZT.right,X4=ZT.left;var JT=Array.prototype,$4=JT.slice,Z4=JT.map;var NQ=Math.sqrt(50),OQ=Math.sqrt(10),DQ=Math.sqrt(2);function Zh(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 r5=1e9,_et=-r5;var B0=Mi();function z0(r,t){var e=t[0],o=t[1],a=[Me(e),-cn(e),0],l=0,h=0;B0.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],v=x[0],M=x[1]/2+Wh,b=Me(M),T=cn(M),_=0;_<g;++_,v=A,b=L,T=G,x=y){var y=d[_],A=y[0],S=y[1]/2+Wh,L=Me(S),G=cn(S),z=A-v,F=z>=0?1:-1,I=F*z,ut=I>bn,R=b*L;if(B0.add(wi(R*F*Me(I),T*G+R*cn(I))),l+=ut?z+F*Do:z,ut^v>=e^A>=e){var W=uc(La(x),La(y));lc(W);var V=uc(a,W);lc(V);var Mt=(ut^z>=0?-1:1)*gi(V[2]);(o>Mt||o===Mt&&(W[0]||W[1]))&&(h+=ut^z>=0?1:-1)}}return(l<-mn||l<mn&&B0<-mn)^h&1}var Iet=Mi();var Zet=Mi(),Jet=Mi();var s5=1/0;var Qet=-s5;function G0(r){this._context=r}G0.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,Do);break}}},result:vo};var lnt=Mi();function k0(){this._string=[]}k0.prototype={_radius:4.5,_circle:QT(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=QT(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 QT(r){return"m0,"+r+"a"+r+","+r+" 0 1,1 0,"+-2*r+"a"+r+","+r+" 0 1,1 0,"+2*r+"z"}function q0(r,t,e,o){return function(a,l){var h=t(l),f=a.invert(o[0],o[1]),p=O0(),d=t(p),g=!1,x,v,M,b={point:T,lineStart:y,lineEnd:A,polygonStart:function(){b.point=S,b.lineStart=L,b.lineEnd=G,v=[],x=[]},polygonEnd:function(){b.point=T,b.lineStart=y,b.lineEnd=A,v=Zh(v);var z=z0(x,f);v.length?(g||(l.polygonStart(),g=!0),F0(v,l5,z,e,l)):z&&(g||(l.polygonStart(),g=!0),l.lineStart(),e(null,null,1,l),l.lineEnd()),g&&(l.polygonEnd(),g=!1),v=x=null},sphere:function(){l.polygonStart(),l.lineStart(),e(null,null,1,l),l.lineEnd(),l.polygonEnd()}};function T(z,F){var I=a(z,F);r(z=I[0],F=I[1])&&l.point(z,F)}function _(z,F){var I=a(z,F);h.point(I[0],I[1])}function y(){b.point=_,h.lineStart()}function A(){b.point=T,h.lineEnd()}function S(z,F){M.push([z,F]);var I=a(z,F);d.point(I[0],I[1])}function L(){d.lineStart(),M=[]}function G(){S(M[0][0],M[0][1]),d.lineEnd();var z=d.clean(),F=p.result(),I,ut=F.length,R,W,V;if(M.pop(),x.push(M),M=null,!!ut){if(z&1){if(W=F[0],(R=W.length-1)>0){for(g||(l.polygonStart(),g=!0),l.lineStart(),I=0;I<R;++I)l.point((V=W[I])[0],V[1]);l.lineEnd()}return}ut>1&&z&2&&F.push(F.pop().concat(F.shift())),v.push(F.filter(u5))}}return b}}function u5(r){return r.length>1}function l5(r,t){return((r=r.x)[0]<0?r[1]-gr-mn:gr-r[1])-((t=t.x)[0]<0?t[1]-gr-mn:gr-t[1])}var c5=q0(function(){return!0},f5,p5,[-bn,-gr]);function f5(r){var t=NaN,e=NaN,o=NaN,a;return{lineStart:function(){r.lineStart(),a=1},point:function(l,h){var f=l>0?bn:-bn,p=Zn(l-t);Zn(p-bn)<mn?(r.point(t,e=(e+h)/2>0?gr:-gr),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(f,e),r.point(l,e),a=0):o!==f&&p>=bn&&(Zn(t-o)<mn&&(t-=o*mn),Zn(l-f)<mn&&(l-=f*mn),e=h5(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 h5(r,t,e,o){var a,l,h=Me(r-e);return Zn(h)>mn?yo((Me(t)*(l=cn(o))*Me(e)-Me(o)*(a=cn(t))*Me(r))/(a*l*h)):(t+o)/2}function p5(r,t,e,o){var a;if(r==null)a=e*gr,o.point(-bn,a),o.point(0,a),o.point(bn,a),o.point(bn,0),o.point(bn,-a),o.point(0,-a),o.point(-bn,-a),o.point(-bn,0),o.point(-bn,a);else if(Zn(r[0]-t[0])>mn){var l=r[0]<t[0]?bn:-bn;a=e*l/2,o.point(-l,a),o.point(0,a),o.point(l,a)}else o.point(t[0],t[1])}function Jh(r){return function(t){var e=new V0;for(var o in r)e[o]=r[o];return e.stream=t,e}}function V0(){}V0.prototype={constructor:V0,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 Jnt=cn(30*Si);var crt=Jh({point:function(r,t){this.stream.point(r*Si,t*Si)}});function Kh(r){return function(t,e){var o=cn(t),a=cn(e),l=r(o*a);return[l*a*Me(t),l*Me(e)]}}function Fo(r){return function(t,e){var o=Vr(t*t+e*e),a=r(o),l=Me(a),h=cn(a);return[wi(t*l,o*h),gi(o&&e*l/o)]}}var sA=Kh(function(r){return Vr(2/(1+r))});sA.invert=Fo(function(r){return 2*gi(r/2)});var aA=Kh(function(r){return(r=N0(r))&&r/Me(r)});aA.invert=Fo(function(r){return r});function H0(r,t){return[r,sc(ac((gr+t)/2))]}H0.invert=function(r,t){return[r,2*yo(Xh(t))-gr]};function jh(r,t){return[r,t]}jh.invert=jh;function uA(r,t){var e=cn(t),o=cn(r)*e;return[e*Me(r)/o,Me(t)/o]}uA.invert=Fo(yo);function lA(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)))]}lA.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)>mn&&--o>0);return[r/(.8707+(l=e*e)*(-.131979+l*(-.013791+l*l*l*(.003971-.001529*l)))),e]};function cA(r,t){return[cn(t)*Me(r),Me(t)]}cA.invert=Fo(gi);function fA(r,t){var e=cn(t),o=1+cn(r)*e;return[e*Me(r)/o,Me(t)/o]}fA.invert=Fo(function(r){return 2*yo(r)});function hA(r,t){return[sc(ac((gr+t)/2)),-r]}hA.invert=function(r,t){return[-t,2*yo(Xh(r))-gr]};var _5=yn(Ju(),1);var x5=yn(Ju(),1);var M5=yn(Ju(),1);var S5=yn(Ju(),1);function Xs(r,t){return Math.sqrt((t[0]-r[0])**2+(t[1]-r[1])**2)}function X0(r){let t=0;for(let e=0;e<r.length-1;e++)t+=Xs(r[e],r[e+1]);return t}function dA(r,t,e){let o=new ye(t[0]-r[0],t[1]-r[1]),a=new ye(t[0]-e[0],t[1]-e[1]),h=o.angleTo(a)*180/Math.PI,f=new ye(t[0]-r[0],t[1]-r[1]);return new ye(e[0]-r[0],e[1]-r[1]).cross(f)>0?h:-h}var Wi="___",Qh=class{initRoute(t){this.clear(),this.roadInfo=t,t.length&&(t.forEach(e=>{e.points.forEach(o=>{let a=""+e.floor+Wi+o.id;if(this.pointMap.set(a,o),this.nodeMap.set(""+o.floor+Wi+o.nodeId,a),o.type==="straightLadder"){let l=this.straightLadderMap.get(o.name)||[];l.push(Xa({},o)),this.straightLadderMap.set(o.name,l)}if(o.type==="staircase"){let l=this.staircaseMap.get(o.name)||[];l.push(Xa({},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(Xa({},o)),this.facilityMap.set(o.targetId,l)}}),e.lines.filter(o=>o.direction!=="no").forEach(o=>{var a,l;let h=""+e.floor+Wi+o.from,f=""+e.floor+Wi+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=Xs(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+Wi+f[g].id;for(let v=0;v<f.length;v++)if(g!==v){var p,d;let M=""+f[v].floor+Wi+f[v].id,b=(p=this.pointMap.get(x))==null?void 0:p.cds,T=(d=this.pointMap.get(M))==null?void 0:d.cds;if(b!=null&&b.length&&(T!=null&&T.length))if(f[g].type==="straightLadder"){let _=e;this.addLineItem(x,M,_,a)}else{let _=o;this.addLineItem(x,M,_,a)}}}}),this.escalatorMap.forEach((l,h)=>{if(l.start&&l.end){var f,p;let d=""+l.start.floor+Wi+l.start.id,g=""+l.end.floor+Wi+l.end.id,x=(f=this.pointMap.get(d))==null?void 0:f.cds,v=(p=this.pointMap.get(g))==null?void 0:p.cds;if(x!=null&&x.length&&(v!=null&&v.length)){let M=t;this.addLineItem(d,g,M,a)}}})}initBaseRoute(){let t=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Uo.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 Uo.default(t)}initStraightLadderRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Uo.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+Wi+t.nodeId);if(o){let[a,l]=o.split(Wi);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=Xs(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((v,M)=>v+X0(M.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+Wi+t.id,l=""+e.floor+Wi+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 v=f[f.length-1];v.points.push(d.cds),v.endType=d.type,v.destId=d.nodeId,v.distance=X0(v.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 Uo.default,this.escalatorRoute=new Uo.default,this.straightLadderRoute=new Uo.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 Uo.default,this.escalatorRoute=new Uo.default,this.straightLadderRoute=new Uo.default}};var Slt=yn(Wc(),1),wlt=yn(Kp(),1);var L5=yn(_A(),1);function N5(r,t,e){let o=dA(r,t,e);return O5(o)}function O5(r){return 180-Math.abs(r)<15?"front":r>135?"right_front":r<-135?"left_front":r<=135&&r>=60?"right":r>=-135&&r<=-60?"left":r<60&&r>0?"right_back":r>-60&&r<0?"left_back":"front"}function xA(r){if(!r.length)return[];if(r.length===1)return[{direction:"start",distance:0,points:r}];let t=[{direction:"start",distance:Xs(r[0],r[1]),points:[r[0],r[1]]}];for(let e=2;e<r.length;e++){let o=N5(r[e-2],r[e-1],r[e]);if(o==="front"){let a=t[t.length-1],l=Xs(r[e-1],r[e]);a.distance+=l,e!==2&&a.points.push(r[e-1])}else t.push({direction:o,distance:Xs(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 Dlt=yn(YA(),1),Flt=yn(Kc(),1);function $A(r){return r.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function ZA(r){let t={};for(let o in r)o.startsWith("on")&&(t[$A(o.slice(2))]=r[o]);let e=o=>gc(this,null,function*(){let{data:a}=o;if(t[a.type])try{let l=yield t[a.type](a.data);if(l!=null&&l.$transfer&&Array.isArray(l.$transfer)){let h=l.$transfer;delete l.$transfer,self.postMessage({type:""+a.type+"_result",key:a.key,data:l},h)}else 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 ty=new Qh;ZA({onSetRoadInfo(r){let{roadData:t}=r;ty.initRoute(t)},onGetPath(r){let{start:t,end:e,type:o}=r;return ty.getPath(t,e,o)},onGetDirectionPath(r){return xA(r)},onClear(){ty.clear()}});
23648
- `],{type:"text/javascript"}),t=URL.createObjectURL(r),e=new Worker(t);return URL.revokeObjectURL(t),e}var $R=class extends Sn{setRoadData(t){return Tt(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield fi(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,n){return Tt(this,null,function*(){return n===void 0&&(n=""),new Promise((i,o)=>{let a=()=>{fi(this.worker,"get_path",{start:t,end:e,type:n}).then(l=>{l?typeof l=="string"?o(l):i(l):o("no-path")})};if(this.initRoadStatus)a();else{let l=c=>{let{status:f}=c;f&&(this.removeEventListener("init-road-status",l),a())};this.addEventListener("init-road-status",l)}})})}getDirectionPath(t){return fi(this.worker,"get_direction_path",t)}dispose(){return Tt(this,null,function*(){fi(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=KR(),this.initRoadStatus=!1}};var sue=H(ze(),1),aue=H(n0(),1),uue=H(r0(),1),lue=H(i0(),1),cue=H(o0(),1),hue=H(s0(),1),fue=H(a0(),1),pue=H(u0(),1),due=H(En(),1);var X6=class extends Ja{setEnable(t){super.setEnable(t),bs(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=sn(this.startPoint,e,n,i),a=sn(this.endPoint,e,n,i),l={x:Math.min(o.x,a.x),y:Math.min(o.y,a.y)},c={x:Math.max(o.x,a.x),y:Math.max(o.y,a.y)},f=this.searchMapInFrustum(l,c);this.dispatchEvent({type:"selected",list:f})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(o=>o instanceof wo&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,n){let{context:{camera:i,container:{clientWidth:o,clientHeight:a}}}=this;if(!t)return!1;if(!t.mesh){let v=t.getPosition();if(v){let x=sn(v,i,o,a);return Yl(x,e,n)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let l=t.mesh.geometry.boundingBox;if(!l)return!1;let{min:c,max:f}=l,g=sn(c,i,o,a),m=sn(f,i,o,a);return!(!Yl(g,e,n)||!Yl(m,e,n))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new B0,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=te({},i);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let a={x:Math.min(i.x,o.x),y:Math.min(i.y,o.y)},l=Math.abs(o.x-i.x),c=Math.abs(o.y-i.y);bs(this.rect,a.x,a.y,l,c)}else bs(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:n}}}=t;this.rect=Zl(n,e),this.svg.appendChild(this.rect),this.registryEvent()}};var uMt={boxSelection:!1,elements:["graphic","poi"]},JR=class extends lo{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(),super.dispose()}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:a,y:l}=this.downPoint;if(Math.sqrt((a-i)**2+(l-o)**2)>3)return;let c=new Set,f=[],g=[];if(this.options.elements.includes("graphic")){let{graphics:m}=this.bmap.context.getGraphicsByDeviceXy(i,o);m.map(v=>c.add(v.options.id)),f.push(...m)}if(this.options.elements.includes("poi")){let m=this.bmap.context.getPoisByDeviceXy(i,o);g.push(...m),m.forEach(v=>{if(!c.has(v.options.id)){var x;let S=((x=this.bmap.context.currentFloor)==null?void 0:x.graphicLayer.graphicMap.get(v.options.id))||null;S&&(c.add(v.options.id),f.push(S))}})}(!this.options.boxSelection||!(Yf?n.metaKey:n.ctrlKey))&&(this._list.clear(),this._poiList.clear()),f.forEach(m=>this._list.add(m)),g.forEach(m=>this._poiList.add(m)),this.selectEnd(),this.downPoint=null},this.onPointerOut=n=>{this.disableBoxSelection()},this.onKeyDown=n=>{Zf(n.key)&&this.enableBoxSelection()},this.onKeyUp=n=>{Zf(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 a=this.bmap.getPoiById(o.options.id);a&&this._poiList.add(a)}}),this.selectEnd()},this.options=te({},uMt,e),this.boxSelection=new X6(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var Eue=H(En(),1),Ma=H(qs(),1);var Gr=function(r){return r.COMPASS="compass",r.DEVICE_MOTION="deviceMotion",r.ACCELERATION="acceleration",r.GPS="gps",r}({});var lMt={time:1e3,elements:[Gr.COMPASS,Gr.DEVICE_MOTION,Gr.ACCELERATION,Gr.GPS]},T_=class extends Zi{start(){this.options.elements.some(t=>[Gr.DEVICE_MOTION,Gr.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(Gr.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(Gr.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,Ma.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){yh?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=>{console.log("watch gps",t.coords),this.addDataItem({type:Gr.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 Tt(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return Tt(this,null,function*(){var t;if(!yh)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),yh?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,Ma.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 ui,this.dispatchTimer=null,this.addAcceleration=(0,Ma.throttle)(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=(0,Ma.throttle)(e=>{let n=Date.now(),{alpha:i,beta:o,gamma:a}=e;if((0,Ma.isNil)(i)||(0,Ma.isNil)(o)||(0,Ma.isNil)(a))return;let l;yh?l=e.webkitCompassHeading:l=360-i,this.options.elements.includes(Gr.DEVICE_MOTION)&&this.addDataItem({type:Gr.DEVICE_MOTION,timestamp:n,res:[i,o,a]}),this.options.elements.includes(Gr.COMPASS)&&this.addDataItem({type:Gr.COMPASS,timestamp:n,res:l})},200),this.handleAcceleration=e=>{let n=e.accelerationIncludingGravity;(0,Ma.isNil)(n)||(0,Ma.isNil)(n.x)||(0,Ma.isNil)(n.y)||(0,Ma.isNil)(n.z)||this.addAcceleration({type:Gr.ACCELERATION,timestamp:Date.now(),res:[n.x,n.y,n.z]})},this.options=te({},lMt,t)}};var kue=H(ze(),1);var Due=H(En(),1);var Aue=H(En(),1),Cue=H(ze(),1);function j6(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 A_(r){return(r+360)%360}function c8(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 yg(r,t,e,n){return Math.sqrt(Math.pow(Math.abs(r-e),2)+Math.pow(Math.abs(t-n),2))}var Y6=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=A_(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]=A_(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=A_(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 a=Math.abs(this.particleX[2][o]-n);a>180&&(a=360-a),this.particleWeight[0][o]*=j6(a,this.sigmaCompass)}let i=this.particleWeight[0].reduce((o,a)=>o+a,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((l,c,f)=>l.concat(l[f]+c),[0]),i=this.particleWeight[0].map(()=>1/this.NumParticle).map((l,c)=>l+Math.random()/this.NumParticle),o=[],a=0;for(let l=0;l<this.NumParticle;l++){for(;i[l]>e[a];)a++;o.push(a)}this.particleX=this.particleX.map((l,c)=>o.map(f=>l[f])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let i=0;i<this.NumParticle;i++){let o=yg(this.particleX[0][i],this.particleX[1][i],t.x,t.y);this.particleWeight[0][i]=Math.max(1e-7,this.particleWeight[0][i]*j6(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 a=0;a<this.NumParticle;a++){let l=yg(this.particleX[0][a],this.particleX[1][a],t.x,t.y);this.particleWeight[0][a]=Math.max(1e-7,this.particleWeight[0][a]*j6(l,e)),this.particleX[0][a]+=n,this.particleX[1][a]+=i}let o=this.particleWeight[0].reduce((a,l)=>a+l,0);this.particleWeight[0]=this.particleWeight[0].map(a=>a/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,0,0];for(let e=0;e<3;e++)for(let n=0;n<this.NumParticle;n++)t[e]+=this.particleX[e][n]*this.particleWeight[0][n];return this.xEst=t.map(e=>[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=yg(n[0],n[1],i[0],i[1]),a=o*.67;return console.log(o,a),a}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 a=(2*Math.random()-1)*this.initial_xy_uncertainty,l=(2*Math.random()-1)*this.initial_xy_uncertainty;n(t+a,e+l)||(this.particleWeight[0][i]*=this.unaccess_weight),this.particleX[0][i]=t+a,this.particleX[1][i]=e+l,i++}let o=this.particleWeight[0].reduce((a,l)=>a+l,0);this.particleWeight[0]=this.particleWeight[0].map(a=>a/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=A_(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 Iue=H(En(),1),Lue=H(ze(),1),Z6=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(),a=this.FFTStepDetec(),l=this.recheckState(),c=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=c:this.abnor_fft_detected||(this.abnor_start_time=0),o&&a&&l?(this.step_count+=1,this.last_step_time=c,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=c,n=!0):(c-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)],a=Math.max(...e),l=Math.min(...e),c=!1,f=!1;return Math.abs(i-l)<.01&&i<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?f=!0:f=o-this.last_valley_time>this.min_step_time,f&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(i-a)<.01&&i>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?c=!0:c=o-this.last_peak_time>this.min_step_time,c&&(this.last_peak_time=o,this.peak_num+=1)),i===a&&i>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=i),this.peak_num===this.valley_num&&(c||f)&&(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((l,c)=>l-this.last_rot[c]));for(let l=0;l<e.length;l++)n[l]<-180?n[l]+=360:n[l]>180&&(n[l]-=360);let i=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((l,c)=>i*l+(1-i)*n[c]):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((l,c)=>l+Math.abs(c),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 a=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(a=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,a):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 cMt={using_gps:!0,gps_max_horizontalAccuracy:20},K6=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===Gr.ACCELERATION){let a=i,l=this.pdr.getStepLength(n/1e3,a);l!==0&&(this.particleFilter.motionModelStepLength(l,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===Gr.GPS)if(this.last_beacon_time===null||n-this.last_beacon_time>5e3){let a=this.getGpsPosition(i);o=a!==null,a&&(this.particleFilter.update(a,this.gps_horizontalAccuracy),this.resetParticleFilterDist(a,"gps",i[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===Gr.DEVICE_MOTION){let a=this.pdr.getDeltaYawFromRot(n/1e3,i);a!==null&&this.particleFilter.motionModelRotYaw(a)}e===Gr.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===Gr.GPS){if(this.startTime&&Date.now()-this.startTime>3e3){let a=this.getGpsPosition(i);o=a!==null,console.log("gps_pos",a,i),a?(this.particleFilter.initParticlesByPos(a.x,a.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===Gr.COMPASS){let a=i;this.particleFilter.initParticlesByCompass(a),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:c8(t[0],t[1])}resetParticleFilterDist(t,e,n){let i=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),a=yg(i,o,t.x,t.y);(e==="gps"?n&&a>n||a>this.GpsMaxEstimateErr:a>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.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=4,this.cacheSensorData=[],this.startTime=null;let e=te({},cMt,t);this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new Y6({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 Z6}};var C_=class extends Zi{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),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&&Li(Rr([i,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:i,y:o,_type:t.type===Gr.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,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new T_(e.sensor),this.pdr=new K6(e.pdr||{})}};var d0e=H(ze(),1),g0e=H(En(),1);var Kue=H(ze(),1),$ue=H(En(),1),Jue=H(R1(),1),Que=H(P1(),1);pe["custom-line"]={linewidth:{value:1},resolution:{value:new ft(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new ft(1,1)},allDistance:{value:1}};ao["custom-line"]={uniforms:Uf.merge([pe.common,pe.fog,pe["custom-line"]]),vertexShader:`
23648
+ `],{type:"text/javascript"}),t=URL.createObjectURL(r),e=new Worker(t);return URL.revokeObjectURL(t),e}var $R=class extends Sn{setRoadData(t){return Tt(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield fi(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,n){return Tt(this,null,function*(){return n===void 0&&(n=""),new Promise((i,o)=>{let a=()=>{fi(this.worker,"get_path",{start:t,end:e,type:n}).then(l=>{l?typeof l=="string"?o(l):i(l):o("no-path")})};if(this.initRoadStatus)a();else{let l=c=>{let{status:f}=c;f&&(this.removeEventListener("init-road-status",l),a())};this.addEventListener("init-road-status",l)}})})}getDirectionPath(t){return fi(this.worker,"get_direction_path",t)}dispose(){return Tt(this,null,function*(){fi(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=KR(),this.initRoadStatus=!1}};var sue=H(ze(),1),aue=H(n0(),1),uue=H(r0(),1),lue=H(i0(),1),cue=H(o0(),1),hue=H(s0(),1),fue=H(a0(),1),pue=H(u0(),1),due=H(En(),1);var X6=class extends Ja{setEnable(t){super.setEnable(t),bs(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=sn(this.startPoint,e,n,i),a=sn(this.endPoint,e,n,i),l={x:Math.min(o.x,a.x),y:Math.min(o.y,a.y)},c={x:Math.max(o.x,a.x),y:Math.max(o.y,a.y)},f=this.searchMapInFrustum(l,c);this.dispatchEvent({type:"selected",list:f})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(o=>o instanceof wo&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,n){let{context:{camera:i,container:{clientWidth:o,clientHeight:a}}}=this;if(!t)return!1;if(!t.mesh){let v=t.getPosition();if(v){let x=sn(v,i,o,a);return Yl(x,e,n)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let l=t.mesh.geometry.boundingBox;if(!l)return!1;let{min:c,max:f}=l,g=sn(c,i,o,a),m=sn(f,i,o,a);return!(!Yl(g,e,n)||!Yl(m,e,n))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new B0,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=te({},i);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let a={x:Math.min(i.x,o.x),y:Math.min(i.y,o.y)},l=Math.abs(o.x-i.x),c=Math.abs(o.y-i.y);bs(this.rect,a.x,a.y,l,c)}else bs(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:n}}}=t;this.rect=Zl(n,e),this.svg.appendChild(this.rect),this.registryEvent()}};var uMt={boxSelection:!1,elements:["graphic","poi"]},JR=class extends lo{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(),super.dispose()}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:a,y:l}=this.downPoint;if(Math.sqrt((a-i)**2+(l-o)**2)>3)return;let c=new Set,f=[],g=[];if(this.options.elements.includes("graphic")){let{graphics:m}=this.bmap.context.getGraphicsByDeviceXy(i,o);m.map(v=>c.add(v.options.id)),f.push(...m)}if(this.options.elements.includes("poi")){let m=this.bmap.context.getPoisByDeviceXy(i,o);g.push(...m),m.forEach(v=>{if(!c.has(v.options.id)){var x;let S=((x=this.bmap.context.currentFloor)==null?void 0:x.graphicLayer.graphicMap.get(v.options.id))||null;S&&(c.add(v.options.id),f.push(S))}})}(!this.options.boxSelection||!(Yf?n.metaKey:n.ctrlKey))&&(this._list.clear(),this._poiList.clear()),f.forEach(m=>this._list.add(m)),g.forEach(m=>this._poiList.add(m)),this.selectEnd(),this.downPoint=null},this.onPointerOut=n=>{this.disableBoxSelection()},this.onKeyDown=n=>{Zf(n.key)&&this.enableBoxSelection()},this.onKeyUp=n=>{Zf(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 a=this.bmap.getPoiById(o.options.id);a&&this._poiList.add(a)}}),this.selectEnd()},this.options=te({},uMt,e),this.boxSelection=new X6(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};var Eue=H(En(),1),Ma=H(qs(),1);var Gr=function(r){return r.COMPASS="compass",r.DEVICE_MOTION="deviceMotion",r.ACCELERATION="acceleration",r.GPS="gps",r}({});var lMt={time:1e3,elements:[Gr.COMPASS,Gr.DEVICE_MOTION,Gr.ACCELERATION,Gr.GPS]},T_=class extends Zi{start(){this.options.elements.some(t=>[Gr.DEVICE_MOTION,Gr.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(Gr.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(Gr.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:(0,Ma.cloneDeep)(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){yh?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=>{console.log("watch gps",t.coords),this.addDataItem({type:Gr.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 Tt(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return Tt(this,null,function*(){var t;if(!yh)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),yh?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),(0,Ma.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 ui,this.dispatchTimer=null,this.addAcceleration=(0,Ma.throttle)(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=(0,Ma.throttle)(e=>{let n=Date.now(),{alpha:i,beta:o,gamma:a}=e;if((0,Ma.isNil)(i)||(0,Ma.isNil)(o)||(0,Ma.isNil)(a))return;let l;yh?l=e.webkitCompassHeading:l=360-i,this.options.elements.includes(Gr.DEVICE_MOTION)&&this.addDataItem({type:Gr.DEVICE_MOTION,timestamp:n,res:[i,o,a]}),this.options.elements.includes(Gr.COMPASS)&&this.addDataItem({type:Gr.COMPASS,timestamp:n,res:l})},200),this.handleAcceleration=e=>{let n=e.accelerationIncludingGravity;(0,Ma.isNil)(n)||(0,Ma.isNil)(n.x)||(0,Ma.isNil)(n.y)||(0,Ma.isNil)(n.z)||this.addAcceleration({type:Gr.ACCELERATION,timestamp:Date.now(),res:[n.x,n.y,n.z]})},this.options=te({},lMt,t)}};var kue=H(ze(),1);var Due=H(En(),1);var Aue=H(En(),1),Cue=H(ze(),1);function j6(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 A_(r){return(r+360)%360}function c8(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 yg(r,t,e,n){return Math.sqrt(Math.pow(Math.abs(r-e),2)+Math.pow(Math.abs(t-n),2))}var Y6=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=A_(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]=A_(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=A_(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 a=Math.abs(this.particleX[2][o]-n);a>180&&(a=360-a),this.particleWeight[0][o]*=j6(a,this.sigmaCompass)}let i=this.particleWeight[0].reduce((o,a)=>o+a,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((l,c,f)=>l.concat(l[f]+c),[0]),i=this.particleWeight[0].map(()=>1/this.NumParticle).map((l,c)=>l+Math.random()/this.NumParticle),o=[],a=0;for(let l=0;l<this.NumParticle;l++){for(;i[l]>e[a];)a++;o.push(a)}this.particleX=this.particleX.map((l,c)=>o.map(f=>l[f])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let i=0;i<this.NumParticle;i++){let o=yg(this.particleX[0][i],this.particleX[1][i],t.x,t.y);this.particleWeight[0][i]=Math.max(1e-7,this.particleWeight[0][i]*j6(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 a=0;a<this.NumParticle;a++){let l=yg(this.particleX[0][a],this.particleX[1][a],t.x,t.y);this.particleWeight[0][a]=Math.max(1e-7,this.particleWeight[0][a]*j6(l,e)),this.particleX[0][a]+=n,this.particleX[1][a]+=i}let o=this.particleWeight[0].reduce((a,l)=>a+l,0);this.particleWeight[0]=this.particleWeight[0].map(a=>a/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,0,0];for(let e=0;e<3;e++)for(let n=0;n<this.NumParticle;n++)t[e]+=this.particleX[e][n]*this.particleWeight[0][n];return this.xEst=t.map(e=>[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=yg(n[0],n[1],i[0],i[1]),a=o*.67;return console.log(o,a),a}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 a=(2*Math.random()-1)*this.initial_xy_uncertainty,l=(2*Math.random()-1)*this.initial_xy_uncertainty;n(t+a,e+l)||(this.particleWeight[0][i]*=this.unaccess_weight),this.particleX[0][i]=t+a,this.particleX[1][i]=e+l,i++}let o=this.particleWeight[0].reduce((a,l)=>a+l,0);this.particleWeight[0]=this.particleWeight[0].map(a=>a/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=A_(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 Iue=H(En(),1),Lue=H(ze(),1);var Z6=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,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=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]}getMotionState(){return this.currentMotionState}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.isMoving(e,this.last_rot))return 0;if(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 a=this.PVStepDetec(),l=this.FFTStepDetec(),c=this.recheckState(),f=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=f:this.abnor_fft_detected||(this.abnor_start_time=0),a&&l&&c?(this.step_count+=1,this.last_step_time=f,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=f,n=!0):(f-this.last_step_time>2&&(this.state_count=0),n=!1)}if(n){let a=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(a),this.delta_py=this.const_step_length*Math.sin(a),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)],a=Math.max(...e),l=Math.min(...e),c=!1,f=!1;return Math.abs(i-l)<.01&&i<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?f=!0:f=o-this.last_valley_time>this.min_step_time,f&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(i-a)<.01&&i>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?c=!0:c=o-this.last_peak_time>this.min_step_time,c&&(this.last_peak_time=o,this.peak_num+=1)),i===a&&i>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=i),this.peak_num===this.valley_num&&(c||f)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let n=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(n),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let i=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(i),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),a=this.rot_variance_buffer.slice(-10),l=this.calculateMean(o),c=this.calculateStdDeviation(o),f=this.calculateMean(a),g=this.calculateStdDeviation(a),m;return l>this.walkingThreshold&&c>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,m="WALKING"):l<this.phoneUseThreshold&&f>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,m="USING_PHONE"):f<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,m="STATIONARY"):m="UNKNOWN",m!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=m,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+l.toFixed(2)+", accStdDev="+c.toFixed(2)+", avgRot="+f.toFixed(2)+", rotStdDev="+g.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,n)=>e+n,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),i=t.map(o=>{let a=o-e;return a*a}).reduce((o,a)=>o+a,0)/t.length;return Math.sqrt(i)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),n=this.calculateMean(t),i=this.calculateMean(e),o=this.calculateStdDeviation(t),a=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+n.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+i.toFixed(2)+", rotStdDev="+a.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:n,avgRotation:i,accStdDeviation:o,rotStdDeviation:a,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}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((l,c)=>l-this.last_rot[c]));for(let l=0;l<e.length;l++)n[l]<-180?n[l]+=360:n[l]>180&&(n[l]-=360);let i=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((l,c)=>i*l+(1-i)*n[c]):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((l,c)=>l+Math.abs(c),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 a=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(a=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,a):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,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var cMt={using_gps:!0,gps_max_horizontalAccuracy:20},K6=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===Gr.ACCELERATION){let a=i,l=this.pdr.getStepLength(n/1e3,a);l!==0&&(this.particleFilter.motionModelStepLength(l,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===Gr.GPS)if(this.last_beacon_time===null||n-this.last_beacon_time>5e3){let a=this.getGpsPosition(i);o=a!==null,a&&(this.particleFilter.update(a,this.gps_horizontalAccuracy),this.resetParticleFilterDist(a,"gps",i[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===Gr.DEVICE_MOTION){let a=this.pdr.getDeltaYawFromRot(n/1e3,i);a!==null&&this.particleFilter.motionModelRotYaw(a)}e===Gr.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===Gr.GPS){if(this.startTime&&Date.now()-this.startTime>3e3){let a=this.getGpsPosition(i);o=a!==null,console.log("gps_pos",a,i),a?(this.particleFilter.initParticlesByPos(a.x,a.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===Gr.COMPASS){let a=i;this.particleFilter.initParticlesByCompass(a),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:c8(t[0],t[1])}resetParticleFilterDist(t,e,n){let i=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),a=yg(i,o,t.x,t.y);(e==="gps"?n&&a>n||a>this.GpsMaxEstimateErr:a>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.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=4,this.cacheSensorData=[],this.startTime=null;let e=te({},cMt,t);this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new Y6({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 Z6}};var C_=class extends Zi{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),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&&Li(Rr([i,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:i,y:o,_type:t.type===Gr.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,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new T_(e.sensor),this.pdr=new K6(e.pdr||{})}};var d0e=H(ze(),1),g0e=H(En(),1);var Kue=H(ze(),1),$ue=H(En(),1),Jue=H(R1(),1),Que=H(P1(),1);pe["custom-line"]={linewidth:{value:1},resolution:{value:new ft(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new ft(1,1)},allDistance:{value:1}};ao["custom-line"]={uniforms:Uf.merge([pe.common,pe.fog,pe["custom-line"]]),vertexShader:`
23649
23649
  #include <common>
23650
23650
  #include <color_pars_vertex>
23651
23651
  #include <fog_pars_vertex>
@@ -27663,4 +27663,4 @@ void main() {
27663
27663
 
27664
27664
  }\`,dv=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,o){if(this.texture===null){let s=new Us,l=t.properties.get(s);l.__webglTexture=e.texture,(e.depthNear!=o.depthNear||e.depthFar!=o.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}render(t,e){if(this.texture!==null){if(this.mesh===null){let o=e.cameras[0].viewport,s=new Ia({extensions:{fragDepth:!0},vertexShader:sX,fragmentShader:aX,uniforms:{depthColor:{value:this.texture},depthWidth:{value:o.z},depthHeight:{value:o.w}}});this.mesh=new ra(new zd(20,20),s)}t.render(this.mesh,e)}}reset(){this.texture=null,this.mesh=null}},gv=class extends Ku{constructor(t,e){super();let o=this,s=null,l=1,p=null,h="local-floor",g=1,m=null,v=null,x=null,E=null,M=null,A=null,I=new dv,S=e.getContextAttributes(),w=null,R=null,C=[],F=[],V=new Ye,X=null,q=new gs;q.layers.enable(1),q.viewport=new ji;let D=new gs;D.layers.enable(2),D.viewport=new ji;let xt=[q,D],B=new pv;B.layers.enable(1),B.layers.enable(2);let j=null,J=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ut){let Ut=C[ut];return Ut===void 0&&(Ut=new sh,C[ut]=Ut),Ut.getTargetRaySpace()},this.getControllerGrip=function(ut){let Ut=C[ut];return Ut===void 0&&(Ut=new sh,C[ut]=Ut),Ut.getGripSpace()},this.getHand=function(ut){let Ut=C[ut];return Ut===void 0&&(Ut=new sh,C[ut]=Ut),Ut.getHandSpace()};function Dt(ut){let Ut=F.indexOf(ut.inputSource);if(Ut===-1)return;let jt=C[Ut];jt!==void 0&&(jt.update(ut.inputSource,ut.frame,m||p),jt.dispatchEvent({type:ut.type,data:ut.inputSource}))}function Q(){s.removeEventListener("select",Dt),s.removeEventListener("selectstart",Dt),s.removeEventListener("selectend",Dt),s.removeEventListener("squeeze",Dt),s.removeEventListener("squeezestart",Dt),s.removeEventListener("squeezeend",Dt),s.removeEventListener("end",Q),s.removeEventListener("inputsourceschange",At);for(let ut=0;ut<C.length;ut++){let Ut=F[ut];Ut!==null&&(F[ut]=null,C[ut].disconnect(Ut))}j=null,J=null,I.reset(),t.setRenderTarget(w),M=null,E=null,x=null,s=null,R=null,ae.stop(),o.isPresenting=!1,t.setPixelRatio(X),t.setSize(V.width,V.height,!1),o.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ut){l=ut,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ut){h=ut,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return m||p},this.setReferenceSpace=function(ut){m=ut},this.getBaseLayer=function(){return E!==null?E:M},this.getBinding=function(){return x},this.getFrame=function(){return A},this.getSession=function(){return s},this.setSession=function(ut){return ac(this,null,function*(){if(s=ut,s!==null){if(w=t.getRenderTarget(),s.addEventListener("select",Dt),s.addEventListener("selectstart",Dt),s.addEventListener("selectend",Dt),s.addEventListener("squeeze",Dt),s.addEventListener("squeezestart",Dt),s.addEventListener("squeezeend",Dt),s.addEventListener("end",Q),s.addEventListener("inputsourceschange",At),S.xrCompatible!==!0&&(yield e.makeXRCompatible()),X=t.getPixelRatio(),t.getSize(V),s.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Ut={antialias:s.renderState.layers===void 0?S.antialias:!0,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:l};M=new XRWebGLLayer(s,e,Ut),s.updateRenderState({baseLayer:M}),t.setPixelRatio(1),t.setSize(M.framebufferWidth,M.framebufferHeight,!1),R=new du(M.framebufferWidth,M.framebufferHeight,{format:na,type:$u,colorSpace:t.outputColorSpace,stencilBuffer:S.stencil})}else{let Ut=null,jt=null,ce=null;S.depth&&(ce=S.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,Ut=S.stencil?Wc:Dl,jt=S.stencil?Ol:Wu);let te={colorFormat:e.RGBA8,depthFormat:ce,scaleFactor:l};x=new XRWebGLBinding(s,e),E=x.createProjectionLayer(te),s.updateRenderState({layers:[E]}),t.setPixelRatio(1),t.setSize(E.textureWidth,E.textureHeight,!1),R=new du(E.textureWidth,E.textureHeight,{format:na,type:$u,depthTexture:new kd(E.textureWidth,E.textureHeight,jt,void 0,void 0,void 0,void 0,void 0,void 0,Ut),stencilBuffer:S.stencil,colorSpace:t.outputColorSpace,samples:S.antialias?4:0});let $t=t.properties.get(R);$t.__ignoreDepthValues=E.ignoreDepthValues}R.isXRRenderTarget=!0,this.setFoveation(g),m=null,p=yield s.requestReferenceSpace(h),ae.setContext(s),ae.start(),o.isPresenting=!0,o.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode};function At(ut){for(let Ut=0;Ut<ut.removed.length;Ut++){let jt=ut.removed[Ut],ce=F.indexOf(jt);ce>=0&&(F[ce]=null,C[ce].disconnect(jt))}for(let Ut=0;Ut<ut.added.length;Ut++){let jt=ut.added[Ut],ce=F.indexOf(jt);if(ce===-1){for(let $t=0;$t<C.length;$t++)if($t>=F.length){F.push(jt),ce=$t;break}else if(F[$t]===null){F[$t]=jt,ce=$t;break}if(ce===-1)break}let te=C[ce];te&&te.connect(jt)}}let Mt=new Rt,Lt=new Rt;function pt(ut,Ut,jt){Mt.setFromMatrixPosition(Ut.matrixWorld),Lt.setFromMatrixPosition(jt.matrixWorld);let ce=Mt.distanceTo(Lt),te=Ut.projectionMatrix.elements,$t=jt.projectionMatrix.elements,qt=te[14]/(te[10]-1),xe=te[14]/(te[10]+1),ft=(te[9]+1)/te[5],We=(te[9]-1)/te[5],ee=(te[8]-1)/te[0],ge=($t[8]+1)/$t[0],fe=qt*ee,Te=qt*ge,be=ce/(-ee+ge),Wt=be*-ee;Ut.matrixWorld.decompose(ut.position,ut.quaternion,ut.scale),ut.translateX(Wt),ut.translateZ(be),ut.matrixWorld.compose(ut.position,ut.quaternion,ut.scale),ut.matrixWorldInverse.copy(ut.matrixWorld).invert();let Me=qt+be,tt=xe+be,z=fe-Wt,Pt=Te+(ce-Wt),Ot=ft*xe/tt*Me,dt=We*xe/tt*Me;ut.projectionMatrix.makePerspective(z,Pt,Ot,dt,Me,tt),ut.projectionMatrixInverse.copy(ut.projectionMatrix).invert()}function yt(ut,Ut){Ut===null?ut.matrixWorld.copy(ut.matrix):ut.matrixWorld.multiplyMatrices(Ut.matrixWorld,ut.matrix),ut.matrixWorldInverse.copy(ut.matrixWorld).invert()}this.updateCamera=function(ut){if(s===null)return;I.texture!==null&&(ut.near=I.depthNear,ut.far=I.depthFar),B.near=D.near=q.near=ut.near,B.far=D.far=q.far=ut.far,(j!==B.near||J!==B.far)&&(s.updateRenderState({depthNear:B.near,depthFar:B.far}),j=B.near,J=B.far,q.near=j,q.far=J,D.near=j,D.far=J,q.updateProjectionMatrix(),D.updateProjectionMatrix(),ut.updateProjectionMatrix());let Ut=ut.parent,jt=B.cameras;yt(B,Ut);for(let ce=0;ce<jt.length;ce++)yt(jt[ce],Ut);jt.length===2?pt(B,q,D):B.projectionMatrix.copy(q.projectionMatrix),K(ut,B,Ut)};function K(ut,Ut,jt){jt===null?ut.matrix.copy(Ut.matrixWorld):(ut.matrix.copy(jt.matrixWorld),ut.matrix.invert(),ut.matrix.multiply(Ut.matrixWorld)),ut.matrix.decompose(ut.position,ut.quaternion,ut.scale),ut.updateMatrixWorld(!0),ut.projectionMatrix.copy(Ut.projectionMatrix),ut.projectionMatrixInverse.copy(Ut.projectionMatrixInverse),ut.isPerspectiveCamera&&(ut.fov=Ky*2*Math.atan(1/ut.projectionMatrix.elements[5]),ut.zoom=1)}this.getCamera=function(){return B},this.getFoveation=function(){if(!(E===null&&M===null))return g},this.setFoveation=function(ut){g=ut,E!==null&&(E.fixedFoveation=ut),M!==null&&M.fixedFoveation!==void 0&&(M.fixedFoveation=ut)},this.hasDepthSensing=function(){return I.texture!==null};let Bt=null;function Gt(ut,Ut){if(v=Ut.getViewerPose(m||p),A=Ut,v!==null){let jt=v.views;M!==null&&(t.setRenderTargetFramebuffer(R,M.framebuffer),t.setRenderTarget(R));let ce=!1;jt.length!==B.cameras.length&&(B.cameras.length=0,ce=!0);for(let $t=0;$t<jt.length;$t++){let qt=jt[$t],xe=null;if(M!==null)xe=M.getViewport(qt);else{let We=x.getViewSubImage(E,qt);xe=We.viewport,$t===0&&(t.setRenderTargetTextures(R,We.colorTexture,E.ignoreDepthValues?void 0:We.depthStencilTexture),t.setRenderTarget(R))}let ft=xt[$t];ft===void 0&&(ft=new gs,ft.layers.enable($t),ft.viewport=new ji,xt[$t]=ft),ft.matrix.fromArray(qt.transform.matrix),ft.matrix.decompose(ft.position,ft.quaternion,ft.scale),ft.projectionMatrix.fromArray(qt.projectionMatrix),ft.projectionMatrixInverse.copy(ft.projectionMatrix).invert(),ft.viewport.set(xe.x,xe.y,xe.width,xe.height),$t===0&&(B.matrix.copy(ft.matrix),B.matrix.decompose(B.position,B.quaternion,B.scale)),ce===!0&&B.cameras.push(ft)}let te=s.enabledFeatures;if(te&&te.includes("depth-sensing")){let $t=x.getDepthInformation(jt[0]);$t&&$t.isValid&&$t.texture&&I.init(t,$t,s.renderState)}}for(let jt=0;jt<C.length;jt++){let ce=F[jt],te=C[jt];ce!==null&&te!==void 0&&te.update(ce,Ut,m||p)}I.render(t,B),Bt&&Bt(ut,Ut),Ut.detectedPlanes&&o.dispatchEvent({type:"planesdetected",data:Ut}),A=null}let ae=new xC;ae.setAnimationLoop(Gt),this.setAnimationLoop=function(ut){Bt=ut},this.dispose=function(){}}},Cl=new Ul,uX=new vi;function lX(n,t){function e(S,w){S.matrixAutoUpdate===!0&&S.updateMatrix(),w.value.copy(S.matrix)}function o(S,w){w.color.getRGB(S.fogColor.value,_C(n)),w.isFog?(S.fogNear.value=w.near,S.fogFar.value=w.far):w.isFogExp2&&(S.fogDensity.value=w.density)}function s(S,w,R,C,F){w.isMeshBasicMaterial||w.isMeshLambertMaterial?l(S,w):w.isMeshToonMaterial?(l(S,w),x(S,w)):w.isMeshPhongMaterial?(l(S,w),v(S,w)):w.isMeshStandardMaterial?(l(S,w),E(S,w),w.isMeshPhysicalMaterial&&M(S,w,F)):w.isMeshMatcapMaterial?(l(S,w),A(S,w)):w.isMeshDepthMaterial?l(S,w):w.isMeshDistanceMaterial?(l(S,w),I(S,w)):w.isMeshNormalMaterial?l(S,w):w.isLineBasicMaterial?(p(S,w),w.isLineDashedMaterial&&h(S,w)):w.isPointsMaterial?g(S,w,R,C):w.isSpriteMaterial?m(S,w):w.isShadowMaterial?(S.color.value.copy(w.color),S.opacity.value=w.opacity):w.isShaderMaterial&&(w.uniformsNeedUpdate=!1)}function l(S,w){S.opacity.value=w.opacity,w.color&&S.diffuse.value.copy(w.color),w.emissive&&S.emissive.value.copy(w.emissive).multiplyScalar(w.emissiveIntensity),w.map&&(S.map.value=w.map,e(w.map,S.mapTransform)),w.alphaMap&&(S.alphaMap.value=w.alphaMap,e(w.alphaMap,S.alphaMapTransform)),w.bumpMap&&(S.bumpMap.value=w.bumpMap,e(w.bumpMap,S.bumpMapTransform),S.bumpScale.value=w.bumpScale,w.side===$o&&(S.bumpScale.value*=-1)),w.normalMap&&(S.normalMap.value=w.normalMap,e(w.normalMap,S.normalMapTransform),S.normalScale.value.copy(w.normalScale),w.side===$o&&S.normalScale.value.negate()),w.displacementMap&&(S.displacementMap.value=w.displacementMap,e(w.displacementMap,S.displacementMapTransform),S.displacementScale.value=w.displacementScale,S.displacementBias.value=w.displacementBias),w.emissiveMap&&(S.emissiveMap.value=w.emissiveMap,e(w.emissiveMap,S.emissiveMapTransform)),w.specularMap&&(S.specularMap.value=w.specularMap,e(w.specularMap,S.specularMapTransform)),w.alphaTest>0&&(S.alphaTest.value=w.alphaTest);let R=t.get(w),C=R.envMap,F=R.envMapRotation;if(C&&(S.envMap.value=C,Cl.copy(F),Cl.x*=-1,Cl.y*=-1,Cl.z*=-1,C.isCubeTexture&&C.isRenderTargetTexture===!1&&(Cl.y*=-1,Cl.z*=-1),S.envMapRotation.value.setFromMatrix4(uX.makeRotationFromEuler(Cl)),S.flipEnvMap.value=C.isCubeTexture&&C.isRenderTargetTexture===!1?-1:1,S.reflectivity.value=w.reflectivity,S.ior.value=w.ior,S.refractionRatio.value=w.refractionRatio),w.lightMap){S.lightMap.value=w.lightMap;let V=n._useLegacyLights===!0?Math.PI:1;S.lightMapIntensity.value=w.lightMapIntensity*V,e(w.lightMap,S.lightMapTransform)}w.aoMap&&(S.aoMap.value=w.aoMap,S.aoMapIntensity.value=w.aoMapIntensity,e(w.aoMap,S.aoMapTransform))}function p(S,w){S.diffuse.value.copy(w.color),S.opacity.value=w.opacity,w.map&&(S.map.value=w.map,e(w.map,S.mapTransform))}function h(S,w){S.dashSize.value=w.dashSize,S.totalSize.value=w.dashSize+w.gapSize,S.scale.value=w.scale}function g(S,w,R,C){S.diffuse.value.copy(w.color),S.opacity.value=w.opacity,S.size.value=w.size*R,S.scale.value=C*.5,w.map&&(S.map.value=w.map,e(w.map,S.uvTransform)),w.alphaMap&&(S.alphaMap.value=w.alphaMap,e(w.alphaMap,S.alphaMapTransform)),w.alphaTest>0&&(S.alphaTest.value=w.alphaTest)}function m(S,w){S.diffuse.value.copy(w.color),S.opacity.value=w.opacity,S.rotation.value=w.rotation,w.map&&(S.map.value=w.map,e(w.map,S.mapTransform)),w.alphaMap&&(S.alphaMap.value=w.alphaMap,e(w.alphaMap,S.alphaMapTransform)),w.alphaTest>0&&(S.alphaTest.value=w.alphaTest)}function v(S,w){S.specular.value.copy(w.specular),S.shininess.value=Math.max(w.shininess,1e-4)}function x(S,w){w.gradientMap&&(S.gradientMap.value=w.gradientMap)}function E(S,w){S.metalness.value=w.metalness,w.metalnessMap&&(S.metalnessMap.value=w.metalnessMap,e(w.metalnessMap,S.metalnessMapTransform)),S.roughness.value=w.roughness,w.roughnessMap&&(S.roughnessMap.value=w.roughnessMap,e(w.roughnessMap,S.roughnessMapTransform)),t.get(w).envMap&&(S.envMapIntensity.value=w.envMapIntensity)}function M(S,w,R){S.ior.value=w.ior,w.sheen>0&&(S.sheenColor.value.copy(w.sheenColor).multiplyScalar(w.sheen),S.sheenRoughness.value=w.sheenRoughness,w.sheenColorMap&&(S.sheenColorMap.value=w.sheenColorMap,e(w.sheenColorMap,S.sheenColorMapTransform)),w.sheenRoughnessMap&&(S.sheenRoughnessMap.value=w.sheenRoughnessMap,e(w.sheenRoughnessMap,S.sheenRoughnessMapTransform))),w.clearcoat>0&&(S.clearcoat.value=w.clearcoat,S.clearcoatRoughness.value=w.clearcoatRoughness,w.clearcoatMap&&(S.clearcoatMap.value=w.clearcoatMap,e(w.clearcoatMap,S.clearcoatMapTransform)),w.clearcoatRoughnessMap&&(S.clearcoatRoughnessMap.value=w.clearcoatRoughnessMap,e(w.clearcoatRoughnessMap,S.clearcoatRoughnessMapTransform)),w.clearcoatNormalMap&&(S.clearcoatNormalMap.value=w.clearcoatNormalMap,e(w.clearcoatNormalMap,S.clearcoatNormalMapTransform),S.clearcoatNormalScale.value.copy(w.clearcoatNormalScale),w.side===$o&&S.clearcoatNormalScale.value.negate())),w.iridescence>0&&(S.iridescence.value=w.iridescence,S.iridescenceIOR.value=w.iridescenceIOR,S.iridescenceThicknessMinimum.value=w.iridescenceThicknessRange[0],S.iridescenceThicknessMaximum.value=w.iridescenceThicknessRange[1],w.iridescenceMap&&(S.iridescenceMap.value=w.iridescenceMap,e(w.iridescenceMap,S.iridescenceMapTransform)),w.iridescenceThicknessMap&&(S.iridescenceThicknessMap.value=w.iridescenceThicknessMap,e(w.iridescenceThicknessMap,S.iridescenceThicknessMapTransform))),w.transmission>0&&(S.transmission.value=w.transmission,S.transmissionSamplerMap.value=R.texture,S.transmissionSamplerSize.value.set(R.width,R.height),w.transmissionMap&&(S.transmissionMap.value=w.transmissionMap,e(w.transmissionMap,S.transmissionMapTransform)),S.thickness.value=w.thickness,w.thicknessMap&&(S.thicknessMap.value=w.thicknessMap,e(w.thicknessMap,S.thicknessMapTransform)),S.attenuationDistance.value=w.attenuationDistance,S.attenuationColor.value.copy(w.attenuationColor)),w.anisotropy>0&&(S.anisotropyVector.value.set(w.anisotropy*Math.cos(w.anisotropyRotation),w.anisotropy*Math.sin(w.anisotropyRotation)),w.anisotropyMap&&(S.anisotropyMap.value=w.anisotropyMap,e(w.anisotropyMap,S.anisotropyMapTransform))),S.specularIntensity.value=w.specularIntensity,S.specularColor.value.copy(w.specularColor),w.specularColorMap&&(S.specularColorMap.value=w.specularColorMap,e(w.specularColorMap,S.specularColorMapTransform)),w.specularIntensityMap&&(S.specularIntensityMap.value=w.specularIntensityMap,e(w.specularIntensityMap,S.specularIntensityMapTransform))}function A(S,w){w.matcap&&(S.matcap.value=w.matcap)}function I(S,w){let R=t.get(w).light;S.referencePosition.value.setFromMatrixPosition(R.matrixWorld),S.nearDistance.value=R.shadow.camera.near,S.farDistance.value=R.shadow.camera.far}return{refreshFogUniforms:o,refreshMaterialUniforms:s}}function cX(n,t,e,o){let s={},l={},p=[],h=e.isWebGL2?n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS):0;function g(R,C){let F=C.program;o.uniformBlockBinding(R,F)}function m(R,C){let F=s[R.id];F===void 0&&(A(R),F=v(R),s[R.id]=F,R.addEventListener("dispose",S));let V=C.program;o.updateUBOMapping(R,V);let X=t.render.frame;l[R.id]!==X&&(E(R),l[R.id]=X)}function v(R){let C=x();R.__bindingPointIndex=C;let F=n.createBuffer(),V=R.__size,X=R.usage;return n.bindBuffer(n.UNIFORM_BUFFER,F),n.bufferData(n.UNIFORM_BUFFER,V,X),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,C,F),F}function x(){for(let R=0;R<h;R++)if(p.indexOf(R)===-1)return p.push(R),R;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function E(R){let C=s[R.id],F=R.uniforms,V=R.__cache;n.bindBuffer(n.UNIFORM_BUFFER,C);for(let X=0,q=F.length;X<q;X++){let D=Array.isArray(F[X])?F[X]:[F[X]];for(let xt=0,B=D.length;xt<B;xt++){let j=D[xt];if(M(j,X,xt,V)===!0){let J=j.__offset,Dt=Array.isArray(j.value)?j.value:[j.value],Q=0;for(let At=0;At<Dt.length;At++){let Mt=Dt[At],Lt=I(Mt);typeof Mt=="number"||typeof Mt=="boolean"?(j.__data[0]=Mt,n.bufferSubData(n.UNIFORM_BUFFER,J+Q,j.__data)):Mt.isMatrix3?(j.__data[0]=Mt.elements[0],j.__data[1]=Mt.elements[1],j.__data[2]=Mt.elements[2],j.__data[3]=0,j.__data[4]=Mt.elements[3],j.__data[5]=Mt.elements[4],j.__data[6]=Mt.elements[5],j.__data[7]=0,j.__data[8]=Mt.elements[6],j.__data[9]=Mt.elements[7],j.__data[10]=Mt.elements[8],j.__data[11]=0):(Mt.toArray(j.__data,Q),Q+=Lt.storage/Float32Array.BYTES_PER_ELEMENT)}n.bufferSubData(n.UNIFORM_BUFFER,J,j.__data)}}}n.bindBuffer(n.UNIFORM_BUFFER,null)}function M(R,C,F,V){let X=R.value,q=C+"_"+F;if(V[q]===void 0)return typeof X=="number"||typeof X=="boolean"?V[q]=X:V[q]=X.clone(),!0;{let D=V[q];if(typeof X=="number"||typeof X=="boolean"){if(D!==X)return V[q]=X,!0}else if(D.equals(X)===!1)return D.copy(X),!0}return!1}function A(R){let C=R.uniforms,F=0,V=16;for(let q=0,D=C.length;q<D;q++){let xt=Array.isArray(C[q])?C[q]:[C[q]];for(let B=0,j=xt.length;B<j;B++){let J=xt[B],Dt=Array.isArray(J.value)?J.value:[J.value];for(let Q=0,At=Dt.length;Q<At;Q++){let Mt=Dt[Q],Lt=I(Mt),pt=F%V;pt!==0&&V-pt<Lt.boundary&&(F+=V-pt),J.__data=new Float32Array(Lt.storage/Float32Array.BYTES_PER_ELEMENT),J.__offset=F,F+=Lt.storage}}}let X=F%V;return X>0&&(F+=V-X),R.__size=F,R.__cache={},this}function I(R){let C={boundary:0,storage:0};return typeof R=="number"||typeof R=="boolean"?(C.boundary=4,C.storage=4):R.isVector2?(C.boundary=8,C.storage=8):R.isVector3||R.isColor?(C.boundary=16,C.storage=12):R.isVector4?(C.boundary=16,C.storage=16):R.isMatrix3?(C.boundary=48,C.storage=48):R.isMatrix4?(C.boundary=64,C.storage=64):R.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",R),C}function S(R){let C=R.target;C.removeEventListener("dispose",S);let F=p.indexOf(C.__bindingPointIndex);p.splice(F,1),n.deleteBuffer(s[C.id]),delete s[C.id],delete l[C.id]}function w(){for(let R in s)n.deleteBuffer(s[R]);p=[],s={},l={}}return{bind:g,update:m,dispose:w}}var mv=class{constructor(t={}){let{canvas:e=d6(),context:o=null,depth:s=!0,stencil:l=!0,alpha:p=!1,antialias:h=!1,premultipliedAlpha:g=!0,preserveDrawingBuffer:m=!1,powerPreference:v="default",failIfMajorPerformanceCaveat:x=!1}=t;this.isWebGLRenderer=!0;let E;o!==null?E=o.getContextAttributes().alpha:E=p;let M=new Uint32Array(4),A=new Int32Array(4),I=null,S=null,w=[],R=[];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=Ta,this._useLegacyLights=!1,this.toneMapping=Yu,this.toneMappingExposure=1;let C=this,F=!1,V=0,X=0,q=null,D=-1,xt=null,B=new ji,j=new ji,J=null,Dt=new ar(0),Q=0,At=e.width,Mt=e.height,Lt=1,pt=null,yt=null,K=new ji(0,0,At,Mt),Bt=new ji(0,0,At,Mt),Gt=!1,ae=new Bd,ut=!1,Ut=!1,jt=null,ce=new vi,te=new Ye,$t=new Rt,qt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function xe(){return q===null?Lt:1}let ft=o;function We(Z,mt){for(let It=0;It<Z.length;It++){let St=Z[It],vt=e.getContext(St,mt);if(vt!==null)return vt}return null}try{let Z={alpha:!0,depth:s,stencil:l,antialias:h,premultipliedAlpha:g,preserveDrawingBuffer:m,powerPreference:v,failIfMajorPerformanceCaveat:x};if("setAttribute"in e&&e.setAttribute("data-engine",\`three.js r\${Rv}\`),e.addEventListener("webglcontextlost",Et,!1),e.addEventListener("webglcontextrestored",G,!1),e.addEventListener("webglcontextcreationerror",ot,!1),ft===null){let mt=["webgl2","webgl","experimental-webgl"];if(C.isWebGL1Renderer===!0&&mt.shift(),ft=We(mt,Z),ft===null)throw We(mt)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&ft instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ft.getShaderPrecisionFormat===void 0&&(ft.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Z){throw console.error("THREE.WebGLRenderer: "+Z.message),Z}let ee,ge,fe,Te,be,Wt,Me,tt,z,Pt,Ot,dt,Ht,Ce,Vt,Zt,ne,rt,P,N,k,$,W,ht;function at(){ee=new AW(ft),ge=new xW(ft,ee,t),ee.init(ge),$=new iX(ft,ee,ge),fe=new nX(ft,ee,ge),Te=new PW(ft),be=new V9,Wt=new rX(ft,ee,fe,be,ge,$,Te),Me=new wW(C),tt=new bW(C),z=new D6(ft,ge),W=new vW(ft,ee,z,ge),Pt=new TW(ft,z,Te,W),Ot=new NW(ft,Pt,z,Te),P=new LW(ft,ge,Wt),Zt=new EW(be),dt=new H9(C,Me,tt,ee,ge,W,Zt),Ht=new lX(C,be),Ce=new X9,Vt=new j9(ee,ge),rt=new yW(C,Me,tt,fe,Ot,E,g),ne=new eX(C,Ot,ge),ht=new cX(ft,Te,ge,fe),N=new _W(ft,ee,Te,ge),k=new CW(ft,ee,Te,ge),Te.programs=dt.programs,C.capabilities=ge,C.extensions=ee,C.properties=be,C.renderLists=Ce,C.shadowMap=ne,C.state=fe,C.info=Te}at();let wt=new gv(C,ft);this.xr=wt,this.getContext=function(){return ft},this.getContextAttributes=function(){return ft.getContextAttributes()},this.forceContextLoss=function(){let Z=ee.get("WEBGL_lose_context");Z&&Z.loseContext()},this.forceContextRestore=function(){let Z=ee.get("WEBGL_lose_context");Z&&Z.restoreContext()},this.getPixelRatio=function(){return Lt},this.setPixelRatio=function(Z){Z!==void 0&&(Lt=Z,this.setSize(At,Mt,!1))},this.getSize=function(Z){return Z.set(At,Mt)},this.setSize=function(Z,mt,It=!0){if(wt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}At=Z,Mt=mt,e.width=Math.floor(Z*Lt),e.height=Math.floor(mt*Lt),It===!0&&(e.style.width=Z+"px",e.style.height=mt+"px"),this.setViewport(0,0,Z,mt)},this.getDrawingBufferSize=function(Z){return Z.set(At*Lt,Mt*Lt).floor()},this.setDrawingBufferSize=function(Z,mt,It){At=Z,Mt=mt,Lt=It,e.width=Math.floor(Z*It),e.height=Math.floor(mt*It),this.setViewport(0,0,Z,mt)},this.getCurrentViewport=function(Z){return Z.copy(B)},this.getViewport=function(Z){return Z.copy(K)},this.setViewport=function(Z,mt,It,St){Z.isVector4?K.set(Z.x,Z.y,Z.z,Z.w):K.set(Z,mt,It,St),fe.viewport(B.copy(K).multiplyScalar(Lt).round())},this.getScissor=function(Z){return Z.copy(Bt)},this.setScissor=function(Z,mt,It,St){Z.isVector4?Bt.set(Z.x,Z.y,Z.z,Z.w):Bt.set(Z,mt,It,St),fe.scissor(j.copy(Bt).multiplyScalar(Lt).round())},this.getScissorTest=function(){return Gt},this.setScissorTest=function(Z){fe.setScissorTest(Gt=Z)},this.setOpaqueSort=function(Z){pt=Z},this.setTransparentSort=function(Z){yt=Z},this.getClearColor=function(Z){return Z.copy(rt.getClearColor())},this.setClearColor=function(){rt.setClearColor.apply(rt,arguments)},this.getClearAlpha=function(){return rt.getClearAlpha()},this.setClearAlpha=function(){rt.setClearAlpha.apply(rt,arguments)},this.clear=function(Z=!0,mt=!0,It=!0){let St=0;if(Z){let vt=!1;if(q!==null){let he=q.texture.format;vt=he===pC||he===hC||he===fC}if(vt){let he=q.texture.type,ue=he===$u||he===Wu||he===Lv||he===Ol||he===lC||he===cC,we=rt.getClearColor(),de=rt.getClearAlpha(),Be=we.r,Ae=we.g,Pe=we.b;ue?(M[0]=Be,M[1]=Ae,M[2]=Pe,M[3]=de,ft.clearBufferuiv(ft.COLOR,0,M)):(A[0]=Be,A[1]=Ae,A[2]=Pe,A[3]=de,ft.clearBufferiv(ft.COLOR,0,A))}else St|=ft.COLOR_BUFFER_BIT}mt&&(St|=ft.DEPTH_BUFFER_BIT),It&&(St|=ft.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ft.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",Et,!1),e.removeEventListener("webglcontextrestored",G,!1),e.removeEventListener("webglcontextcreationerror",ot,!1),Ce.dispose(),Vt.dispose(),be.dispose(),Me.dispose(),tt.dispose(),Ot.dispose(),W.dispose(),ht.dispose(),dt.dispose(),ne.dispose(),wt.dispose(),wt.removeEventListener("sessionstart",qe),wt.removeEventListener("sessionend",Ue),jt&&(jt.dispose(),jt=null),Xe.stop()};function Et(Z){Z.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),F=!0}function G(){console.log("THREE.WebGLRenderer: Context Restored."),F=!1;let Z=Te.autoReset,mt=ne.enabled,It=ne.autoUpdate,St=ne.needsUpdate,vt=ne.type;at(),Te.autoReset=Z,ne.enabled=mt,ne.autoUpdate=It,ne.needsUpdate=St,ne.type=vt}function ot(Z){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Z.statusMessage)}function et(Z){let mt=Z.target;mt.removeEventListener("dispose",et),lt(mt)}function lt(Z){Ft(Z),be.remove(Z)}function Ft(Z){let mt=be.get(Z).programs;mt!==void 0&&(mt.forEach(function(It){dt.releaseProgram(It)}),Z.isShaderMaterial&&dt.releaseShaderCache(Z))}this.renderBufferDirect=function(Z,mt,It,St,vt,he){mt===null&&(mt=qt);let ue=vt.isMesh&&vt.matrixWorld.determinant()<0,we=Qn(Z,mt,It,St,vt);fe.setMaterial(St,ue);let de=It.index,Be=1;if(St.wireframe===!0){if(de=Pt.getWireframeAttribute(It),de===void 0)return;Be=2}let Ae=It.drawRange,Pe=It.attributes.position,en=Ae.start*Be,si=(Ae.start+Ae.count)*Be;he!==null&&(en=Math.max(en,he.start*Be),si=Math.min(si,(he.start+he.count)*Be)),de!==null?(en=Math.max(en,0),si=Math.min(si,de.count)):Pe!=null&&(en=Math.max(en,0),si=Math.min(si,Pe.count));let br=si-en;if(br<0||br===1/0)return;W.setup(vt,St,we,It,de);let Vi,sr=N;if(de!==null&&(Vi=z.get(de),sr=k,sr.setIndex(Vi)),vt.isMesh)St.wireframe===!0?(fe.setLineWidth(St.wireframeLinewidth*xe()),sr.setMode(ft.LINES)):sr.setMode(ft.TRIANGLES);else if(vt.isLine){let ye=St.linewidth;ye===void 0&&(ye=1),fe.setLineWidth(ye*xe()),vt.isLineSegments?sr.setMode(ft.LINES):vt.isLineLoop?sr.setMode(ft.LINE_LOOP):sr.setMode(ft.LINE_STRIP)}else vt.isPoints?sr.setMode(ft.POINTS):vt.isSprite&&sr.setMode(ft.TRIANGLES);if(vt.isBatchedMesh)sr.renderMultiDraw(vt._multiDrawStarts,vt._multiDrawCounts,vt._multiDrawCount);else if(vt.isInstancedMesh)sr.renderInstances(en,br,vt.count);else if(It.isInstancedBufferGeometry){let ye=It._maxInstanceCount!==void 0?It._maxInstanceCount:1/0,Ua=Math.min(It.instanceCount,ye);sr.renderInstances(en,br,Ua)}else sr.render(en,br)};function Kt(Z,mt,It){Z.transparent===!0&&Z.side===cu&&Z.forceSinglePass===!1?(Z.side=$o,Z.needsUpdate=!0,rr(Z,mt,It),Z.side=Ju,Z.needsUpdate=!0,rr(Z,mt,It),Z.side=cu):rr(Z,mt,It)}this.compile=function(Z,mt,It=null){It===null&&(It=Z),S=Vt.get(It),S.init(),R.push(S),It.traverseVisible(function(vt){vt.isLight&&vt.layers.test(mt.layers)&&(S.pushLight(vt),vt.castShadow&&S.pushShadow(vt))}),Z!==It&&Z.traverseVisible(function(vt){vt.isLight&&vt.layers.test(mt.layers)&&(S.pushLight(vt),vt.castShadow&&S.pushShadow(vt))}),S.setupLights(C._useLegacyLights);let St=new Set;return Z.traverse(function(vt){let he=vt.material;if(he)if(Array.isArray(he))for(let ue=0;ue<he.length;ue++){let we=he[ue];Kt(we,It,vt),St.add(we)}else Kt(he,It,vt),St.add(he)}),R.pop(),S=null,St},this.compileAsync=function(Z,mt,It=null){let St=this.compile(Z,mt,It);return new Promise(vt=>{function he(){if(St.forEach(function(ue){be.get(ue).currentProgram.isReady()&&St.delete(ue)}),St.size===0){vt(Z);return}setTimeout(he,10)}ee.get("KHR_parallel_shader_compile")!==null?he():setTimeout(he,10)})};let me=null;function ve(Z){me&&me(Z)}function qe(){Xe.stop()}function Ue(){Xe.start()}let Xe=new xC;Xe.setAnimationLoop(ve),typeof self!="undefined"&&Xe.setContext(self),this.setAnimationLoop=function(Z){me=Z,wt.setAnimationLoop(Z),Z===null?Xe.stop():Xe.start()},wt.addEventListener("sessionstart",qe),wt.addEventListener("sessionend",Ue),this.render=function(Z,mt){if(mt!==void 0&&mt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(F===!0)return;Z.matrixWorldAutoUpdate===!0&&Z.updateMatrixWorld(),mt.parent===null&&mt.matrixWorldAutoUpdate===!0&&mt.updateMatrixWorld(),wt.enabled===!0&&wt.isPresenting===!0&&(wt.cameraAutoUpdate===!0&&wt.updateCamera(mt),mt=wt.getCamera()),Z.isScene===!0&&Z.onBeforeRender(C,Z,mt,q),S=Vt.get(Z,R.length),S.init(),R.push(S),ce.multiplyMatrices(mt.projectionMatrix,mt.matrixWorldInverse),ae.setFromProjectionMatrix(ce),Ut=this.localClippingEnabled,ut=Zt.init(this.clippingPlanes,Ut),I=Ce.get(Z,w.length),I.init(),w.push(I),Je(Z,mt,0,C.sortObjects),I.finish(),C.sortObjects===!0&&I.sort(pt,yt),this.info.render.frame++,ut===!0&&Zt.beginShadows();let It=S.state.shadowsArray;if(ne.render(It,Z,mt),ut===!0&&Zt.endShadows(),this.info.autoReset===!0&&this.info.reset(),(wt.enabled===!1||wt.isPresenting===!1||wt.hasDepthSensing()===!1)&&rt.render(I,Z),S.setupLights(C._useLegacyLights),mt.isArrayCamera){let St=mt.cameras;for(let vt=0,he=St.length;vt<he;vt++){let ue=St[vt];wr(I,Z,ue,ue.viewport)}}else wr(I,Z,mt);q!==null&&(Wt.updateMultisampleRenderTarget(q),Wt.updateRenderTargetMipmap(q)),Z.isScene===!0&&Z.onAfterRender(C,Z,mt),W.resetDefaultState(),D=-1,xt=null,R.pop(),R.length>0?S=R[R.length-1]:S=null,w.pop(),w.length>0?I=w[w.length-1]:I=null};function Je(Z,mt,It,St){if(Z.visible===!1)return;if(Z.layers.test(mt.layers)){if(Z.isGroup)It=Z.renderOrder;else if(Z.isLOD)Z.autoUpdate===!0&&Z.update(mt);else if(Z.isLight)S.pushLight(Z),Z.castShadow&&S.pushShadow(Z);else if(Z.isSprite){if(!Z.frustumCulled||ae.intersectsSprite(Z)){St&&$t.setFromMatrixPosition(Z.matrixWorld).applyMatrix4(ce);let ue=Ot.update(Z),we=Z.material;we.visible&&I.push(Z,ue,we,It,$t.z,null)}}else if((Z.isMesh||Z.isLine||Z.isPoints)&&(!Z.frustumCulled||ae.intersectsObject(Z))){let ue=Ot.update(Z),we=Z.material;if(St&&(Z.boundingSphere!==void 0?(Z.boundingSphere===null&&Z.computeBoundingSphere(),$t.copy(Z.boundingSphere.center)):(ue.boundingSphere===null&&ue.computeBoundingSphere(),$t.copy(ue.boundingSphere.center)),$t.applyMatrix4(Z.matrixWorld).applyMatrix4(ce)),Array.isArray(we)){let de=ue.groups;for(let Be=0,Ae=de.length;Be<Ae;Be++){let Pe=de[Be],en=we[Pe.materialIndex];en&&en.visible&&I.push(Z,ue,en,It,$t.z,Pe)}}else we.visible&&I.push(Z,ue,we,It,$t.z,null)}}let he=Z.children;for(let ue=0,we=he.length;ue<we;ue++)Je(he[ue],mt,It,St)}function wr(Z,mt,It,St){let vt=Z.opaque,he=Z.transmissive,ue=Z.transparent;S.setupLightsView(It),ut===!0&&Zt.setGlobalState(C.clippingPlanes,It),he.length>0&&Jr(vt,he,mt,It),St&&fe.viewport(B.copy(St)),vt.length>0&&nr(vt,mt,It),he.length>0&&nr(he,mt,It),ue.length>0&&nr(ue,mt,It),fe.buffers.depth.setTest(!0),fe.buffers.depth.setMask(!0),fe.buffers.color.setMask(!0),fe.setPolygonOffset(!1)}function Jr(Z,mt,It,St){if((It.isScene===!0?It.overrideMaterial:null)!==null)return;let he=ge.isWebGL2;jt===null&&(jt=new du(1,1,{generateMipmaps:!0,type:ee.has("EXT_color_buffer_half_float")?ah:$u,minFilter:Ll,samples:he?4:0})),C.getDrawingBufferSize(te),he?jt.setSize(te.x,te.y):jt.setSize(jy(te.x),jy(te.y));let ue=C.getRenderTarget();C.setRenderTarget(jt),C.getClearColor(Dt),Q=C.getClearAlpha(),Q<1&&C.setClearColor(16777215,.5),C.clear();let we=C.toneMapping;C.toneMapping=Yu,nr(Z,It,St),Wt.updateMultisampleRenderTarget(jt),Wt.updateRenderTargetMipmap(jt);let de=!1;for(let Be=0,Ae=mt.length;Be<Ae;Be++){let Pe=mt[Be],en=Pe.object,si=Pe.geometry,br=Pe.material,Vi=Pe.group;if(br.side===cu&&en.layers.test(St.layers)){let sr=br.side;br.side=$o,br.needsUpdate=!0,Ie(en,It,St,si,br,Vi),br.side=sr,br.needsUpdate=!0,de=!0}}de===!0&&(Wt.updateMultisampleRenderTarget(jt),Wt.updateRenderTargetMipmap(jt)),C.setRenderTarget(ue),C.setClearColor(Dt,Q),C.toneMapping=we}function nr(Z,mt,It){let St=mt.isScene===!0?mt.overrideMaterial:null;for(let vt=0,he=Z.length;vt<he;vt++){let ue=Z[vt],we=ue.object,de=ue.geometry,Be=St===null?ue.material:St,Ae=ue.group;we.layers.test(It.layers)&&Ie(we,mt,It,de,Be,Ae)}}function Ie(Z,mt,It,St,vt,he){Z.onBeforeRender(C,mt,It,St,vt,he),Z.modelViewMatrix.multiplyMatrices(It.matrixWorldInverse,Z.matrixWorld),Z.normalMatrix.getNormalMatrix(Z.modelViewMatrix),vt.onBeforeRender(C,mt,It,St,Z,he),vt.transparent===!0&&vt.side===cu&&vt.forceSinglePass===!1?(vt.side=$o,vt.needsUpdate=!0,C.renderBufferDirect(It,mt,St,vt,Z,he),vt.side=Ju,vt.needsUpdate=!0,C.renderBufferDirect(It,mt,St,vt,Z,he),vt.side=cu):C.renderBufferDirect(It,mt,St,vt,Z,he),Z.onAfterRender(C,mt,It,St,vt,he)}function rr(Z,mt,It){mt.isScene!==!0&&(mt=qt);let St=be.get(Z),vt=S.state.lights,he=S.state.shadowsArray,ue=vt.state.version,we=dt.getParameters(Z,vt.state,he,mt,It),de=dt.getProgramCacheKey(we),Be=St.programs;St.environment=Z.isMeshStandardMaterial?mt.environment:null,St.fog=mt.fog,St.envMap=(Z.isMeshStandardMaterial?tt:Me).get(Z.envMap||St.environment),St.envMapRotation=St.environment!==null&&Z.envMap===null?mt.environmentRotation:Z.envMapRotation,Be===void 0&&(Z.addEventListener("dispose",et),Be=new Map,St.programs=Be);let Ae=Be.get(de);if(Ae!==void 0){if(St.currentProgram===Ae&&St.lightsStateVersion===ue)return ur(Z,we),Ae}else we.uniforms=dt.getUniforms(Z),Z.onBuild(It,we,C),Z.onBeforeCompile(we,C),Ae=dt.acquireProgram(we,de),Be.set(de,Ae),St.uniforms=we.uniforms;let Pe=St.uniforms;return(!Z.isShaderMaterial&&!Z.isRawShaderMaterial||Z.clipping===!0)&&(Pe.clippingPlanes=Zt.uniform),ur(Z,we),St.needsLights=oi(Z),St.lightsStateVersion=ue,St.needsLights&&(Pe.ambientLightColor.value=vt.state.ambient,Pe.lightProbe.value=vt.state.probe,Pe.directionalLights.value=vt.state.directional,Pe.directionalLightShadows.value=vt.state.directionalShadow,Pe.spotLights.value=vt.state.spot,Pe.spotLightShadows.value=vt.state.spotShadow,Pe.rectAreaLights.value=vt.state.rectArea,Pe.ltc_1.value=vt.state.rectAreaLTC1,Pe.ltc_2.value=vt.state.rectAreaLTC2,Pe.pointLights.value=vt.state.point,Pe.pointLightShadows.value=vt.state.pointShadow,Pe.hemisphereLights.value=vt.state.hemi,Pe.directionalShadowMap.value=vt.state.directionalShadowMap,Pe.directionalShadowMatrix.value=vt.state.directionalShadowMatrix,Pe.spotShadowMap.value=vt.state.spotShadowMap,Pe.spotLightMatrix.value=vt.state.spotLightMatrix,Pe.spotLightMap.value=vt.state.spotLightMap,Pe.pointShadowMap.value=vt.state.pointShadowMap,Pe.pointShadowMatrix.value=vt.state.pointShadowMatrix),St.currentProgram=Ae,St.uniformsList=null,Ae}function pr(Z){if(Z.uniformsList===null){let mt=Z.currentProgram.getUniforms();Z.uniformsList=qc.seqWithValue(mt.seq,Z.uniforms)}return Z.uniformsList}function ur(Z,mt){let It=be.get(Z);It.outputColorSpace=mt.outputColorSpace,It.batching=mt.batching,It.instancing=mt.instancing,It.instancingColor=mt.instancingColor,It.instancingMorph=mt.instancingMorph,It.skinning=mt.skinning,It.morphTargets=mt.morphTargets,It.morphNormals=mt.morphNormals,It.morphColors=mt.morphColors,It.morphTargetsCount=mt.morphTargetsCount,It.numClippingPlanes=mt.numClippingPlanes,It.numIntersection=mt.numClipIntersection,It.vertexAlphas=mt.vertexAlphas,It.vertexTangents=mt.vertexTangents,It.toneMapping=mt.toneMapping}function Qn(Z,mt,It,St,vt){mt.isScene!==!0&&(mt=qt),Wt.resetTextureUnits();let he=mt.fog,ue=St.isMeshStandardMaterial?mt.environment:null,we=q===null?C.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:tl,de=(St.isMeshStandardMaterial?tt:Me).get(St.envMap||ue),Be=St.vertexColors===!0&&!!It.attributes.color&&It.attributes.color.itemSize===4,Ae=!!It.attributes.tangent&&(!!St.normalMap||St.anisotropy>0),Pe=!!It.morphAttributes.position,en=!!It.morphAttributes.normal,si=!!It.morphAttributes.color,br=Yu;St.toneMapped&&(q===null||q.isXRRenderTarget===!0)&&(br=C.toneMapping);let Vi=It.morphAttributes.position||It.morphAttributes.normal||It.morphAttributes.color,sr=Vi!==void 0?Vi.length:0,ye=be.get(St),Ua=S.state.lights;if(ut===!0&&(Ut===!0||Z!==xt)){let Ai=Z===xt&&St.id===D;Zt.setState(St,Z,Ai)}let nn=!1;St.version===ye.__version?(ye.needsLights&&ye.lightsStateVersion!==Ua.state.version||ye.outputColorSpace!==we||vt.isBatchedMesh&&ye.batching===!1||!vt.isBatchedMesh&&ye.batching===!0||vt.isInstancedMesh&&ye.instancing===!1||!vt.isInstancedMesh&&ye.instancing===!0||vt.isSkinnedMesh&&ye.skinning===!1||!vt.isSkinnedMesh&&ye.skinning===!0||vt.isInstancedMesh&&ye.instancingColor===!0&&vt.instanceColor===null||vt.isInstancedMesh&&ye.instancingColor===!1&&vt.instanceColor!==null||vt.isInstancedMesh&&ye.instancingMorph===!0&&vt.morphTexture===null||vt.isInstancedMesh&&ye.instancingMorph===!1&&vt.morphTexture!==null||ye.envMap!==de||St.fog===!0&&ye.fog!==he||ye.numClippingPlanes!==void 0&&(ye.numClippingPlanes!==Zt.numPlanes||ye.numIntersection!==Zt.numIntersection)||ye.vertexAlphas!==Be||ye.vertexTangents!==Ae||ye.morphTargets!==Pe||ye.morphNormals!==en||ye.morphColors!==si||ye.toneMapping!==br||ge.isWebGL2===!0&&ye.morphTargetsCount!==sr)&&(nn=!0):(nn=!0,ye.__version=St.version);let fo=ye.currentProgram;nn===!0&&(fo=rr(St,mt,vt));let ul=!1,ze=!1,vs=!1,ir=fo.getUniforms(),Qo=ye.uniforms;if(fe.useProgram(fo.program)&&(ul=!0,ze=!0,vs=!0),St.id!==D&&(D=St.id,ze=!0),ul||xt!==Z){ir.setValue(ft,"projectionMatrix",Z.projectionMatrix),ir.setValue(ft,"viewMatrix",Z.matrixWorldInverse);let Ai=ir.map.cameraPosition;Ai!==void 0&&Ai.setValue(ft,$t.setFromMatrixPosition(Z.matrixWorld)),ge.logarithmicDepthBuffer&&ir.setValue(ft,"logDepthBufFC",2/(Math.log(Z.far+1)/Math.LN2)),(St.isMeshPhongMaterial||St.isMeshToonMaterial||St.isMeshLambertMaterial||St.isMeshBasicMaterial||St.isMeshStandardMaterial||St.isShaderMaterial)&&ir.setValue(ft,"isOrthographic",Z.isOrthographicCamera===!0),xt!==Z&&(xt=Z,ze=!0,vs=!0)}if(vt.isSkinnedMesh){ir.setOptional(ft,vt,"bindMatrix"),ir.setOptional(ft,vt,"bindMatrixInverse");let Ai=vt.skeleton;Ai&&(ge.floatVertexTextures?(Ai.boneTexture===null&&Ai.computeBoneTexture(),ir.setValue(ft,"boneTexture",Ai.boneTexture,Wt)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}vt.isBatchedMesh&&(ir.setOptional(ft,vt,"batchingTexture"),ir.setValue(ft,"batchingTexture",vt._matricesTexture,Wt));let Le=It.morphAttributes;if((Le.position!==void 0||Le.normal!==void 0||Le.color!==void 0&&ge.isWebGL2===!0)&&P.update(vt,It,fo),(ze||ye.receiveShadow!==vt.receiveShadow)&&(ye.receiveShadow=vt.receiveShadow,ir.setValue(ft,"receiveShadow",vt.receiveShadow)),St.isMeshGouraudMaterial&&St.envMap!==null&&(Qo.envMap.value=de,Qo.flipEnvMap.value=de.isCubeTexture&&de.isRenderTargetTexture===!1?-1:1),ze&&(ir.setValue(ft,"toneMappingExposure",C.toneMappingExposure),ye.needsLights&&bi(Qo,vs),he&&St.fog===!0&&Ht.refreshFogUniforms(Qo,he),Ht.refreshMaterialUniforms(Qo,St,Lt,Mt,jt),qc.upload(ft,pr(ye),Qo,Wt)),St.isShaderMaterial&&St.uniformsNeedUpdate===!0&&(qc.upload(ft,pr(ye),Qo,Wt),St.uniformsNeedUpdate=!1),St.isSpriteMaterial&&ir.setValue(ft,"center",vt.center),ir.setValue(ft,"modelViewMatrix",vt.modelViewMatrix),ir.setValue(ft,"normalMatrix",vt.normalMatrix),ir.setValue(ft,"modelMatrix",vt.matrixWorld),St.isShaderMaterial||St.isRawShaderMaterial){let Ai=St.uniformsGroups;for(let Ba=0,mu=Ai.length;Ba<mu;Ba++)if(ge.isWebGL2){let Ti=Ai[Ba];ht.update(Ti,fo),ht.bind(Ti,fo)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return fo}function bi(Z,mt){Z.ambientLightColor.needsUpdate=mt,Z.lightProbe.needsUpdate=mt,Z.directionalLights.needsUpdate=mt,Z.directionalLightShadows.needsUpdate=mt,Z.pointLights.needsUpdate=mt,Z.pointLightShadows.needsUpdate=mt,Z.spotLights.needsUpdate=mt,Z.spotLightShadows.needsUpdate=mt,Z.rectAreaLights.needsUpdate=mt,Z.hemisphereLights.needsUpdate=mt}function oi(Z){return Z.isMeshLambertMaterial||Z.isMeshToonMaterial||Z.isMeshPhongMaterial||Z.isMeshStandardMaterial||Z.isShadowMaterial||Z.isShaderMaterial&&Z.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return X},this.getRenderTarget=function(){return q},this.setRenderTargetTextures=function(Z,mt,It){be.get(Z.texture).__webglTexture=mt,be.get(Z.depthTexture).__webglTexture=It;let St=be.get(Z);St.__hasExternalTextures=!0,St.__autoAllocateDepthBuffer=It===void 0,St.__autoAllocateDepthBuffer||ee.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(Z,mt){let It=be.get(Z);It.__webglFramebuffer=mt,It.__useDefaultFramebuffer=mt===void 0},this.setRenderTarget=function(Z,mt=0,It=0){q=Z,V=mt,X=It;let St=!0,vt=null,he=!1,ue=!1;if(Z){let de=be.get(Z);de.__useDefaultFramebuffer!==void 0?(fe.bindFramebuffer(ft.FRAMEBUFFER,null),St=!1):de.__webglFramebuffer===void 0?Wt.setupRenderTarget(Z):de.__hasExternalTextures&&Wt.rebindTextures(Z,be.get(Z.texture).__webglTexture,be.get(Z.depthTexture).__webglTexture);let Be=Z.texture;(Be.isData3DTexture||Be.isDataArrayTexture||Be.isCompressedArrayTexture)&&(ue=!0);let Ae=be.get(Z).__webglFramebuffer;Z.isWebGLCubeRenderTarget?(Array.isArray(Ae[mt])?vt=Ae[mt][It]:vt=Ae[mt],he=!0):ge.isWebGL2&&Z.samples>0&&Wt.useMultisampledRTT(Z)===!1?vt=be.get(Z).__webglMultisampledFramebuffer:Array.isArray(Ae)?vt=Ae[It]:vt=Ae,B.copy(Z.viewport),j.copy(Z.scissor),J=Z.scissorTest}else B.copy(K).multiplyScalar(Lt).floor(),j.copy(Bt).multiplyScalar(Lt).floor(),J=Gt;if(fe.bindFramebuffer(ft.FRAMEBUFFER,vt)&&ge.drawBuffers&&St&&fe.drawBuffers(Z,vt),fe.viewport(B),fe.scissor(j),fe.setScissorTest(J),he){let de=be.get(Z.texture);ft.framebufferTexture2D(ft.FRAMEBUFFER,ft.COLOR_ATTACHMENT0,ft.TEXTURE_CUBE_MAP_POSITIVE_X+mt,de.__webglTexture,It)}else if(ue){let de=be.get(Z.texture),Be=mt||0;ft.framebufferTextureLayer(ft.FRAMEBUFFER,ft.COLOR_ATTACHMENT0,de.__webglTexture,It||0,Be)}D=-1},this.readRenderTargetPixels=function(Z,mt,It,St,vt,he,ue){if(!(Z&&Z.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let we=be.get(Z).__webglFramebuffer;if(Z.isWebGLCubeRenderTarget&&ue!==void 0&&(we=we[ue]),we){fe.bindFramebuffer(ft.FRAMEBUFFER,we);try{let de=Z.texture,Be=de.format,Ae=de.type;if(Be!==na&&$.convert(Be)!==ft.getParameter(ft.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Pe=Ae===ah&&(ee.has("EXT_color_buffer_half_float")||ge.isWebGL2&&ee.has("EXT_color_buffer_float"));if(Ae!==$u&&$.convert(Ae)!==ft.getParameter(ft.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Ae===fu&&(ge.isWebGL2||ee.has("OES_texture_float")||ee.has("WEBGL_color_buffer_float")))&&!Pe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}mt>=0&&mt<=Z.width-St&&It>=0&&It<=Z.height-vt&&ft.readPixels(mt,It,St,vt,$.convert(Be),$.convert(Ae),he)}finally{let de=q!==null?be.get(q).__webglFramebuffer:null;fe.bindFramebuffer(ft.FRAMEBUFFER,de)}}},this.copyFramebufferToTexture=function(Z,mt,It=0){let St=Math.pow(2,-It),vt=Math.floor(mt.image.width*St),he=Math.floor(mt.image.height*St);Wt.setTexture2D(mt,0),ft.copyTexSubImage2D(ft.TEXTURE_2D,It,0,0,Z.x,Z.y,vt,he),fe.unbindTexture()},this.copyTextureToTexture=function(Z,mt,It,St=0){let vt=mt.image.width,he=mt.image.height,ue=$.convert(It.format),we=$.convert(It.type);Wt.setTexture2D(It,0),ft.pixelStorei(ft.UNPACK_FLIP_Y_WEBGL,It.flipY),ft.pixelStorei(ft.UNPACK_PREMULTIPLY_ALPHA_WEBGL,It.premultiplyAlpha),ft.pixelStorei(ft.UNPACK_ALIGNMENT,It.unpackAlignment),mt.isDataTexture?ft.texSubImage2D(ft.TEXTURE_2D,St,Z.x,Z.y,vt,he,ue,we,mt.image.data):mt.isCompressedTexture?ft.compressedTexSubImage2D(ft.TEXTURE_2D,St,Z.x,Z.y,mt.mipmaps[0].width,mt.mipmaps[0].height,ue,mt.mipmaps[0].data):ft.texSubImage2D(ft.TEXTURE_2D,St,Z.x,Z.y,ue,we,mt.image),St===0&&It.generateMipmaps&&ft.generateMipmap(ft.TEXTURE_2D),fe.unbindTexture()},this.copyTextureToTexture3D=function(Z,mt,It,St,vt=0){if(C.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let he=Math.round(Z.max.x-Z.min.x),ue=Math.round(Z.max.y-Z.min.y),we=Z.max.z-Z.min.z+1,de=$.convert(St.format),Be=$.convert(St.type),Ae;if(St.isData3DTexture)Wt.setTexture3D(St,0),Ae=ft.TEXTURE_3D;else if(St.isDataArrayTexture||St.isCompressedArrayTexture)Wt.setTexture2DArray(St,0),Ae=ft.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ft.pixelStorei(ft.UNPACK_FLIP_Y_WEBGL,St.flipY),ft.pixelStorei(ft.UNPACK_PREMULTIPLY_ALPHA_WEBGL,St.premultiplyAlpha),ft.pixelStorei(ft.UNPACK_ALIGNMENT,St.unpackAlignment);let Pe=ft.getParameter(ft.UNPACK_ROW_LENGTH),en=ft.getParameter(ft.UNPACK_IMAGE_HEIGHT),si=ft.getParameter(ft.UNPACK_SKIP_PIXELS),br=ft.getParameter(ft.UNPACK_SKIP_ROWS),Vi=ft.getParameter(ft.UNPACK_SKIP_IMAGES),sr=It.isCompressedTexture?It.mipmaps[vt]:It.image;ft.pixelStorei(ft.UNPACK_ROW_LENGTH,sr.width),ft.pixelStorei(ft.UNPACK_IMAGE_HEIGHT,sr.height),ft.pixelStorei(ft.UNPACK_SKIP_PIXELS,Z.min.x),ft.pixelStorei(ft.UNPACK_SKIP_ROWS,Z.min.y),ft.pixelStorei(ft.UNPACK_SKIP_IMAGES,Z.min.z),It.isDataTexture||It.isData3DTexture?ft.texSubImage3D(Ae,vt,mt.x,mt.y,mt.z,he,ue,we,de,Be,sr.data):St.isCompressedArrayTexture?ft.compressedTexSubImage3D(Ae,vt,mt.x,mt.y,mt.z,he,ue,we,de,sr.data):ft.texSubImage3D(Ae,vt,mt.x,mt.y,mt.z,he,ue,we,de,Be,sr),ft.pixelStorei(ft.UNPACK_ROW_LENGTH,Pe),ft.pixelStorei(ft.UNPACK_IMAGE_HEIGHT,en),ft.pixelStorei(ft.UNPACK_SKIP_PIXELS,si),ft.pixelStorei(ft.UNPACK_SKIP_ROWS,br),ft.pixelStorei(ft.UNPACK_SKIP_IMAGES,Vi),vt===0&&St.generateMipmaps&&ft.generateMipmap(Ae),fe.unbindTexture()},this.initTexture=function(Z){Z.isCubeTexture?Wt.setTextureCube(Z,0):Z.isData3DTexture?Wt.setTexture3D(Z,0):Z.isDataArrayTexture||Z.isCompressedArrayTexture?Wt.setTexture2DArray(Z,0):Wt.setTexture2D(Z,0),fe.unbindTexture()},this.resetState=function(){V=0,X=0,q=null,fe.reset(),W.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return hu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===Nv?"display-p3":"srgb",e.unpackColorSpace=xr.workingColorSpace===Vd?"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}},yv=class extends mv{};yv.prototype.isWebGL1Renderer=!0;var vv=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Zy,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Zu()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return yC("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,o){t*=this.stride,o*=e.stride;for(let s=0,l=this.stride;s<l;s++)this.array[t+s]=e.array[o+s];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zu()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),o=new this.constructor(e,this.stride);return o.setUsage(this.usage),o}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Zu()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},wo=new Rt,qd=class n{constructor(t,e,o,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=o,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,o=this.data.count;e<o;e++)wo.fromBufferAttribute(this,e),wo.applyMatrix4(t),this.setXYZ(e,wo.x,wo.y,wo.z);return this}applyNormalMatrix(t){for(let e=0,o=this.count;e<o;e++)wo.fromBufferAttribute(this,e),wo.applyNormalMatrix(t),this.setXYZ(e,wo.x,wo.y,wo.z);return this}transformDirection(t){for(let e=0,o=this.count;e<o;e++)wo.fromBufferAttribute(this,e),wo.transformDirection(t),this.setXYZ(e,wo.x,wo.y,wo.z);return this}getComponent(t,e){let o=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(o=Pa(o,this.array)),o}setComponent(t,e,o){return this.normalized&&(o=_r(o,this.array)),this.data.array[t*this.data.stride+this.offset+e]=o,this}setX(t,e){return this.normalized&&(e=_r(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=_r(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=_r(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=_r(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Pa(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Pa(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Pa(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Pa(e,this.array)),e}setXY(t,e,o){return t=t*this.data.stride+this.offset,this.normalized&&(e=_r(e,this.array),o=_r(o,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=o,this}setXYZ(t,e,o,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=_r(e,this.array),o=_r(o,this.array),s=_r(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=o,this.data.array[t+2]=s,this}setXYZW(t,e,o,s,l){return t=t*this.data.stride+this.offset,this.normalized&&(e=_r(e,this.array),o=_r(o,this.array),s=_r(s,this.array),l=_r(l,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=o,this.data.array[t+2]=s,this.data.array[t+3]=l,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let o=0;o<this.count;o++){let s=o*this.data.stride+this.offset;for(let l=0;l<this.itemSize;l++)e.push(this.data.array[s+l])}return new ms(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new n(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let o=0;o<this.count;o++){let s=o*this.data.stride+this.offset;for(let l=0;l<this.itemSize;l++)e.push(this.data.array[s+l])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},_v=class extends Bl{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ar(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},Hu,rh=new Rt,Oc=new Rt,Dc=new Rt,Fc=new Ye,ih=new Ye,AC=new vi,yd=new Rt,oh=new Rt,vd=new Rt,rC=new Ye,qy=new Ye,iC=new Ye,xv=class extends ia{constructor(t=new _v){if(super(),this.isSprite=!0,this.type="Sprite",Hu===void 0){Hu=new Qu;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),o=new vv(e,5);Hu.setIndex([0,1,2,0,2,3]),Hu.setAttribute("position",new qd(o,3,0,!1)),Hu.setAttribute("uv",new qd(o,2,3,!1))}this.geometry=Hu,this.material=t,this.center=new Ye(.5,.5)}raycast(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Oc.setFromMatrixScale(this.matrixWorld),AC.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Dc.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Oc.multiplyScalar(-Dc.z);let o=this.material.rotation,s,l;o!==0&&(l=Math.cos(o),s=Math.sin(o));let p=this.center;_d(yd.set(-.5,-.5,0),Dc,p,Oc,s,l),_d(oh.set(.5,-.5,0),Dc,p,Oc,s,l),_d(vd.set(.5,.5,0),Dc,p,Oc,s,l),rC.set(0,0),qy.set(1,0),iC.set(1,1);let h=t.ray.intersectTriangle(yd,oh,vd,!1,rh);if(h===null&&(_d(oh.set(-.5,.5,0),Dc,p,Oc,s,l),qy.set(0,1),h=t.ray.intersectTriangle(yd,vd,oh,!1,rh),h===null))return;let g=t.ray.origin.distanceTo(rh);g<t.near||g>t.far||e.push({distance:g,point:rh.clone(),uv:Nl.getInterpolation(rh,yd,oh,vd,rC,qy,iC,new Ye),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}};xv.Dispose=function(){Hu.dispose(),Hu=void 0};function _d(n,t,e,o,s,l){Fc.subVectors(n,e).addScalar(.5).multiply(o),s!==void 0?(ih.x=l*Fc.x-s*Fc.y,ih.y=s*Fc.x+l*Fc.y):ih.copy(Fc),n.copy(t),n.x+=ih.x,n.y+=ih.y,n.applyMatrix4(AC)}function xd(n,t,e){return!n||!e&&n.constructor===t?n:typeof t.BYTES_PER_ELEMENT=="number"?new t(n):Array.prototype.slice.call(n)}function fX(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}var Yc=class{constructor(t,e,o,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(o),this.sampleValues=e,this.valueSize=o,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,o=this._cachedIndex,s=e[o],l=e[o-1];t:{e:{let p;n:{r:if(!(t<s)){for(let h=o+2;;){if(s===void 0){if(t<l)break r;return o=e.length,this._cachedIndex=o,this.copySampleValue_(o-1)}if(o===h)break;if(l=s,s=e[++o],t<s)break e}p=e.length;break n}if(!(t>=l)){let h=e[1];t<h&&(o=2,l=h);for(let g=o-2;;){if(l===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(o===g)break;if(s=l,l=e[--o-1],t>=l)break e}p=o,o=0;break n}break t}for(;o<p;){let h=o+p>>>1;t<e[h]?p=h:o=h+1}if(s=e[o],l=e[o-1],l===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(s===void 0)return o=e.length,this._cachedIndex=o,this.copySampleValue_(o-1)}this._cachedIndex=o,this.intervalChanged_(o,l,s)}return this.interpolate_(o,l,t,s)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,o=this.sampleValues,s=this.valueSize,l=t*s;for(let p=0;p!==s;++p)e[p]=o[l+p];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Ev=class extends Yc{constructor(t,e,o,s){super(t,e,o,s),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:hT,endingEnd:hT}}intervalChanged_(t,e,o){let s=this.parameterPositions,l=t-2,p=t+1,h=s[l],g=s[p];if(h===void 0)switch(this.getSettings_().endingStart){case pT:l=t,h=2*e-o;break;case dT:l=s.length-2,h=e+s[l]-s[l+1];break;default:l=t,h=o}if(g===void 0)switch(this.getSettings_().endingEnd){case pT:p=t,g=2*o-e;break;case dT:p=1,g=o+s[1]-s[0];break;default:p=t-1,g=e}let m=(o-e)*.5,v=this.valueSize;this._weightPrev=m/(e-h),this._weightNext=m/(g-o),this._offsetPrev=l*v,this._offsetNext=p*v}interpolate_(t,e,o,s){let l=this.resultBuffer,p=this.sampleValues,h=this.valueSize,g=t*h,m=g-h,v=this._offsetPrev,x=this._offsetNext,E=this._weightPrev,M=this._weightNext,A=(o-e)/(s-e),I=A*A,S=I*A,w=-E*S+2*E*I-E*A,R=(1+E)*S+(-1.5-2*E)*I+(-.5+E)*A+1,C=(-1-M)*S+(1.5+M)*I+.5*A,F=M*S-M*I;for(let V=0;V!==h;++V)l[V]=w*p[v+V]+R*p[m+V]+C*p[g+V]+F*p[x+V];return l}},wv=class extends Yc{constructor(t,e,o,s){super(t,e,o,s)}interpolate_(t,e,o,s){let l=this.resultBuffer,p=this.sampleValues,h=this.valueSize,g=t*h,m=g-h,v=(o-e)/(s-e),x=1-v;for(let E=0;E!==h;++E)l[E]=p[m+E]*x+p[g+E]*v;return l}},Sv=class extends Yc{constructor(t,e,o,s){super(t,e,o,s)}interpolate_(t){return this.copySampleValue_(t-1)}},oa=class{constructor(t,e,o,s){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=xd(e,this.TimeBufferType),this.values=xd(o,this.ValueBufferType),this.setInterpolation(s||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:xd(t.times,Array),values:xd(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(o.interpolation=s)}return o.type=t.ValueTypeName,o}InterpolantFactoryMethodDiscrete(t){return new Sv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new wv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Ev(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case wd:e=this.InterpolantFactoryMethodDiscrete;break;case Sd:e=this.InterpolantFactoryMethodLinear;break;case gy: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 wd;case this.InterpolantFactoryMethodLinear:return Sd;case this.InterpolantFactoryMethodSmooth:return gy}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let o=0,s=e.length;o!==s;++o)e[o]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let o=0,s=e.length;o!==s;++o)e[o]*=t}return this}trim(t,e){let o=this.times,s=o.length,l=0,p=s-1;for(;l!==s&&o[l]<t;)++l;for(;p!==-1&&o[p]>e;)--p;if(++p,l!==0||p!==s){l>=p&&(p=Math.max(p,1),l=p-1);let h=this.getValueSize();this.times=o.slice(l,p),this.values=this.values.slice(l*h,p*h)}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,s=this.values,l=o.length;l===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let p=null;for(let h=0;h!==l;h++){let g=o[h];if(typeof g=="number"&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,h,g),t=!1;break}if(p!==null&&p>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,h,g,p),t=!1;break}p=g}if(s!==void 0&&fX(s))for(let h=0,g=s.length;h!==g;++h){let m=s[h];if(isNaN(m)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,h,m),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),o=this.getValueSize(),s=this.getInterpolation()===gy,l=t.length-1,p=1;for(let h=1;h<l;++h){let g=!1,m=t[h],v=t[h+1];if(m!==v&&(h!==1||m!==t[0]))if(s)g=!0;else{let x=h*o,E=x-o,M=x+o;for(let A=0;A!==o;++A){let I=e[x+A];if(I!==e[E+A]||I!==e[M+A]){g=!0;break}}}if(g){if(h!==p){t[p]=t[h];let x=h*o,E=p*o;for(let M=0;M!==o;++M)e[E+M]=e[x+M]}++p}}if(l>0){t[p]=t[l];for(let h=l*o,g=p*o,m=0;m!==o;++m)e[g+m]=e[h+m];++p}return p!==t.length?(this.times=t.slice(0,p),this.values=e.slice(0,p*o)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),o=this.constructor,s=new o(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};oa.prototype.TimeBufferType=Float32Array;oa.prototype.ValueBufferType=Float32Array;oa.prototype.DefaultInterpolation=Sd;var zl=class extends oa{};zl.prototype.ValueTypeName="bool";zl.prototype.ValueBufferType=Array;zl.prototype.DefaultInterpolation=wd;zl.prototype.InterpolantFactoryMethodLinear=void 0;zl.prototype.InterpolantFactoryMethodSmooth=void 0;var Mv=class extends oa{};Mv.prototype.ValueTypeName="color";var bv=class extends oa{};bv.prototype.ValueTypeName="number";var Av=class extends Yc{constructor(t,e,o,s){super(t,e,o,s)}interpolate_(t,e,o,s){let l=this.resultBuffer,p=this.sampleValues,h=this.valueSize,g=(o-e)/(s-e),m=t*h;for(let v=m+h;m!==v;m+=4)ju.slerpFlat(l,0,p,m-h,p,m,g);return l}},ch=class extends oa{InterpolantFactoryMethodLinear(t){return new Av(this.times,this.values,this.getValueSize(),t)}};ch.prototype.ValueTypeName="quaternion";ch.prototype.DefaultInterpolation=Sd;ch.prototype.InterpolantFactoryMethodSmooth=void 0;var Gl=class extends oa{};Gl.prototype.ValueTypeName="string";Gl.prototype.ValueBufferType=Array;Gl.prototype.DefaultInterpolation=wd;Gl.prototype.InterpolantFactoryMethodLinear=void 0;Gl.prototype.InterpolantFactoryMethodSmooth=void 0;var Tv=class extends oa{};Tv.prototype.ValueTypeName="vector";var Cv=class{constructor(t,e,o){let s=this,l=!1,p=0,h=0,g,m=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=o,this.itemStart=function(v){h++,l===!1&&s.onStart!==void 0&&s.onStart(v,p,h),l=!0},this.itemEnd=function(v){p++,s.onProgress!==void 0&&s.onProgress(v,p,h),p===h&&(l=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(v){s.onError!==void 0&&s.onError(v)},this.resolveURL=function(v){return g?g(v):v},this.setURLModifier=function(v){return g=v,this},this.addHandler=function(v,x){return m.push(v,x),this},this.removeHandler=function(v){let x=m.indexOf(v);return x!==-1&&m.splice(x,2),this},this.getHandler=function(v){for(let x=0,E=m.length;x<E;x+=2){let M=m[x],A=m[x+1];if(M.global&&(M.lastIndex=0),M.test(v))return A}return null}}},hX=new Cv,Pv=class{constructor(t){this.manager=t!==void 0?t:hX,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let o=this;return new Promise(function(s,l){o.load(t,s,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}};Pv.DEFAULT_MATERIAL_NAME="__DEFAULT";var Dv="\\\\[\\\\]\\\\.:\\\\/",pX=new RegExp("["+Dv+"]","g"),Fv="[^"+Dv+"]",dX="[^"+Dv.replace("\\\\.","")+"]",gX=/((?:WC+[\\/:])*)/.source.replace("WC",Fv),mX=/(WCOD+)?/.source.replace("WCOD",dX),yX=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",Fv),vX=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",Fv),_X=new RegExp("^"+gX+mX+yX+vX+"$"),xX=["material","materials","bones","map"],Iv=class{constructor(t,e,o){let s=o||Or.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,s)}getValue(t,e){this.bind();let o=this._targetGroup.nCachedObjects_,s=this._bindings[o];s!==void 0&&s.getValue(t,e)}setValue(t,e){let o=this._bindings;for(let s=this._targetGroup.nCachedObjects_,l=o.length;s!==l;++s)o[s].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()}},Or=class n{constructor(t,e,o){this.path=e,this.parsedPath=o||n.parseTrackName(e),this.node=n.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 n.Composite(t,e,o):new n(t,e,o)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(pX,"")}static parseTrackName(t){let e=_X.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]},s=o.nodeName&&o.nodeName.lastIndexOf(".");if(s!==void 0&&s!==-1){let l=o.nodeName.substring(s+1);xX.indexOf(l)!==-1&&(o.nodeName=o.nodeName.substring(0,s),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 p=0;p<l.length;p++){let h=l[p];if(h.name===e||h.uuid===e)return h;let g=o(h.children);if(g)return g}return null},s=o(t.children);if(s)return s}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 s=0,l=o.length;s!==l;++s)t[e++]=o[s]}_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 s=0,l=o.length;s!==l;++s)o[s]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let o=this.resolvedProperty;for(let s=0,l=o.length;s!==l;++s)o[s]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let o=this.resolvedProperty;for(let s=0,l=o.length;s!==l;++s)o[s]=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,s=e.propertyName,l=e.propertyIndex;if(t||(t=n.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 m=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 v=0;v<t.length;v++)if(t[v].name===m){m=v;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(m!==void 0){if(t[m]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[m]}}let p=t[s];if(p===void 0){let m=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+m+"."+s+" but it wasn't found.",t);return}let h=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?h=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(h=this.Versioning.MatrixWorldNeedsUpdate);let g=this.BindingType.Direct;if(l!==void 0){if(s==="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])}g=this.BindingType.ArrayElement,this.resolvedProperty=p,this.propertyIndex=l}else p.fromArray!==void 0&&p.toArray!==void 0?(g=this.BindingType.HasFromToArray,this.resolvedProperty=p):Array.isArray(p)?(g=this.BindingType.EntireArray,this.resolvedProperty=p):this.propertyName=s;this.getValue=this.GetterByBindingType[g],this.setValue=this.SetterByBindingTypeAndVersioning[g][h]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Or.Composite=Iv;Or.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Or.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Or.prototype.GetterByBindingType=[Or.prototype._getValue_direct,Or.prototype._getValue_array,Or.prototype._getValue_arrayElement,Or.prototype._getValue_toArray];Or.prototype.SetterByBindingTypeAndVersioning=[[Or.prototype._setValue_direct,Or.prototype._setValue_direct_setNeedsUpdate,Or.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Or.prototype._setValue_array,Or.prototype._setValue_array_setNeedsUpdate,Or.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Or.prototype._setValue_arrayElement,Or.prototype._setValue_arrayElement_setNeedsUpdate,Or.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Or.prototype._setValue_fromArray,Or.prototype._setValue_fromArray_setNeedsUpdate,Or.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Ytt=new Float32Array(1);typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Rv}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Rv);var zi=63710088e-1,Jtt={centimeters:zi*100,centimetres:zi*100,degrees:zi/111325,feet:zi*3.28084,inches:zi*39.37,kilometers:zi/1e3,kilometres:zi/1e3,meters:zi,metres:zi,miles:zi/1609.344,millimeters:zi*1e3,millimetres:zi*1e3,nauticalmiles:zi/1852,radians:1,yards:zi*1.0936},Ktt={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/zi,yards:1.0936133};function bo(n,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=n,o}function Pr(n,t,e){if(e===void 0&&(e={}),!n)throw new Error("coordinates is required");if(!Array.isArray(n))throw new Error("coordinates must be an Array");if(n.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ra(n[0])||!Ra(n[1]))throw new Error("coordinates must contain numbers");var o={type:"Point",coordinates:n};return bo(o,t,e)}function Dr(n,t,e){e===void 0&&(e={});for(var o=0,s=n;o<s.length;o++){var l=s[o];if(l.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var p=0;p<l[l.length-1].length;p++)if(l[l.length-1][p]!==l[0][p])throw new Error("First and last Position are not equivalent.")}var h={type:"Polygon",coordinates:n};return bo(h,t,e)}function Gi(n,t,e){if(e===void 0&&(e={}),n.length<2)throw new Error("coordinates must be an array of two or more positions");var o={type:"LineString",coordinates:n};return bo(o,t,e)}function Uv(n,t,e){e===void 0&&(e={});var o={type:"MultiPoint",coordinates:n};return bo(o,t,e)}function Ra(n){return!isNaN(n)&&n!==null&&!Array.isArray(n)}function Ei(n,t,e){if(n!==null)for(var o,s,l,p,h,g,m,v=0,x=0,E,M=n.type,A=M==="FeatureCollection",I=M==="Feature",S=A?n.features.length:1,w=0;w<S;w++){m=A?n.features[w].geometry:I?n.geometry:n,E=m?m.type==="GeometryCollection":!1,h=E?m.geometries.length:1;for(var R=0;R<h;R++){var C=0,F=0;if(p=E?m.geometries[R]:m,p!==null){g=p.coordinates;var V=p.type;switch(v=e&&(V==="Polygon"||V==="MultiPolygon")?1:0,V){case null:break;case"Point":if(t(g,x,w,C,F)===!1)return!1;x++,C++;break;case"LineString":case"MultiPoint":for(o=0;o<g.length;o++){if(t(g[o],x,w,C,F)===!1)return!1;x++,V==="MultiPoint"&&C++}V==="LineString"&&C++;break;case"Polygon":case"MultiLineString":for(o=0;o<g.length;o++){for(s=0;s<g[o].length-v;s++){if(t(g[o][s],x,w,C,F)===!1)return!1;x++}V==="MultiLineString"&&C++,V==="Polygon"&&F++}V==="Polygon"&&C++;break;case"MultiPolygon":for(o=0;o<g.length;o++){for(F=0,s=0;s<g[o].length;s++){for(l=0;l<g[o][s].length-v;l++){if(t(g[o][s][l],x,w,C,F)===!1)return!1;x++}F++}C++}break;case"GeometryCollection":for(o=0;o<p.geometries.length;o++)if(Ei(p.geometries[o],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function TC(n,t,e,o){var s=e;return Ei(n,function(l,p,h,g,m){p===0&&e===void 0?s=l:s=t(s,l,p,h,g,m)},o),s}function el(n,t){var e,o,s,l,p,h,g,m,v,x,E=0,M=n.type==="FeatureCollection",A=n.type==="Feature",I=M?n.features.length:1;for(e=0;e<I;e++){for(h=M?n.features[e].geometry:A?n.geometry:n,m=M?n.features[e].properties:A?n.properties:{},v=M?n.features[e].bbox:A?n.bbox:void 0,x=M?n.features[e].id:A?n.id:void 0,g=h?h.type==="GeometryCollection":!1,p=g?h.geometries.length:1,s=0;s<p;s++){if(l=g?h.geometries[s]:h,l===null){if(t(null,E,m,v,x)===!1)return!1;continue}switch(l.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(t(l,E,m,v,x)===!1)return!1;break}case"GeometryCollection":{for(o=0;o<l.geometries.length;o++)if(t(l.geometries[o],E,m,v,x)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}E++}}function ys(n,t){el(n,function(e,o,s,l,p){var h=e===null?null:e.type;switch(h){case null:case"Point":case"LineString":case"Polygon":return t(bo(e,s,{bbox:l,id:p}),o,0)===!1?!1:void 0}var g;switch(h){case"MultiPoint":g="Point";break;case"MultiLineString":g="LineString";break;case"MultiPolygon":g="Polygon";break}for(var m=0;m<e.coordinates.length;m++){var v=e.coordinates[m],x={type:g,coordinates:v};if(t(bo(x,s),o,m)===!1)return!1}})}function Bv(n){var t=[1/0,1/0,-1/0,-1/0];return Ei(n,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}Bv.default=Bv;var Ao=Bv;function Qi(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return n.geometry.coordinates;if(n.type==="Point")return n.coordinates}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return n;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function zv(n,t,e){if(!n)throw new Error("No feature passed");if(!e)throw new Error(".featureOf() requires a name");if(!n||n.type!=="Feature"||!n.geometry)throw new Error("Invalid input to "+e+", Feature with geometry required");if(!n.geometry||n.geometry.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+n.geometry.type)}function to(n){return n.type==="Feature"?n.geometry:n}var CX=sn(Xd(),1);var BX=sn(WC(),1);function ki(n,t,e){if(e===void 0&&(e={}),!n)throw new Error("point is required");if(!t)throw new Error("polygon is required");var o=Qi(n),s=to(t),l=s.type,p=t.bbox,h=s.coordinates;if(p&&zX(o,p)===!1)return!1;l==="Polygon"&&(h=[h]);for(var g=!1,m=0;m<h.length&&!g;m++)if(XC(o,h[m][0],e.ignoreBoundary)){for(var v=!1,x=1;x<h[m].length&&!v;)XC(o,h[m][x],!e.ignoreBoundary)&&(v=!0),x++;v||(g=!0)}return g}function XC(n,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 s=0,l=t.length-1;s<t.length;l=s++){var p=t[s][0],h=t[s][1],g=t[l][0],m=t[l][1],v=n[1]*(p-g)+h*(g-n[0])+m*(n[0]-p)===0&&(p-n[0])*(g-n[0])<=0&&(h-n[1])*(m-n[1])<=0;if(v)return!e;var x=h>n[1]!=m>n[1]&&n[0]<(g-p)*(n[1]-h)/(m-h)+p;x&&(o=!o)}return o}function zX(n,t){return t[0]<=n[0]&&t[1]<=n[1]&&t[2]>=n[0]&&t[3]>=n[1]}var ZC=new ArrayBuffer(16),Cnt=new Float64Array(ZC),Pnt=new Uint32Array(ZC);var t7=sn(e_(),1);var eit=function(){function n(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],s=this.points[e+1];this.centers.push({x:(o.x+s.x)/2,y:(o.y+s.y)/2,z:(o.z+s.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,p=this.points[e+1].y-(this.centers[e].y+this.centers[e+1].y)/2,h=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+p),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e].z+h)},{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+p),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e+1].z+h)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return n.prototype.cacheSteps=function(t){var e=[],o=this.pos(0);e.push(0);for(var s=0;s<this.duration;s+=10){var l=this.pos(s),p=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));p>t&&(e.push(s),o=l)}return e},n.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))}},n.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 s=Math.floor((this.points.length-1)*o),l=(this.length-1)*o-s;return e7(l,this.points[s],this.controls[s][1],this.controls[s+1][0],this.points[s+1])},n}();function e7(n,t,e,o,s){var l=n7(n),p={x:s.x*l[0]+o.x*l[1]+e.x*l[2]+t.x*l[3],y:s.y*l[0]+o.y*l[1]+e.y*l[2]+t.y*l[3],z:s.z*l[0]+o.z*l[1]+e.z*l[2]+t.z*l[3]};return p}function n7(n){var t=n*n,e=t*n;return[e,3*t*(1-n),3*n*(1-n)*(1-n),(1-n)*(1-n)*(1-n)]}function dh(n,t){t===void 0&&(t={});var e=Number(n[0]),o=Number(n[1]),s=Number(n[2]),l=Number(n[3]);if(n.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var p=[e,o],h=[e,l],g=[s,l],m=[s,o];return Dr([[p,m,g,h,p]],t.properties,{bbox:n,id:t.id})}function r7(n){return dh(Ao(n))}var n_=r7;var x7=sn(sP(),1);var Y7=sn(lg(),1);var Z7=sn(Xd(),1);var j7=sn(e_(),1);var MP=Math.PI/180,bP=180/Math.PI,Eh=function(n,t){this.lon=n,this.lat=t,this.x=MP*n,this.y=MP*t};Eh.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)};Eh.prototype.antipode=function(){var n=-1*this.lat,t=this.lon<0?180+this.lon:(180-this.lon)*-1;return new Eh(t,n)};var AP=function(){this.coords=[],this.length=0};AP.prototype.move_to=function(n){this.length++,this.coords.push(n)};var w_=function(n){this.properties=n||{},this.geometries=[]};w_.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 n=[],t=0;t<this.geometries.length;t++)n.push(this.geometries[t].coords);return{geometry:{type:"MultiLineString",coordinates:n},type:"Feature",properties:this.properties}};w_.prototype.wkt=function(){for(var n="",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 s=this.geometries[o].coords;s.forEach(e),n+=t.substring(0,t.length-1)+")"}return n};var TP=function(n,t,e){if(!n||n.x===void 0||n.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 Eh(n.x,n.y),this.end=new Eh(t.x,t.y),this.properties=e||{};var o=this.start.x-this.end.x,s=this.start.y-this.end.y,l=Math.pow(Math.sin(s/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 "+n.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 "+n+" and "+t)};TP.prototype.interpolate=function(n){var t=Math.sin((1-n)*this.g)/Math.sin(this.g),e=Math.sin(n*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),s=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),p=bP*Math.atan2(l,Math.sqrt(Math.pow(o,2)+Math.pow(s,2))),h=bP*Math.atan2(s,o);return[h,p]};TP.prototype.Arc=function(n,t){var e=[];if(!n||n<=2)e.push([this.start.lon,this.start.lat]),e.push([this.end.lon,this.end.lat]);else for(var o=1/(n-1),s=0;s<n;++s){var l=o*s,p=this.interpolate(l);e.push(p)}for(var h=!1,g=0,m=t&&t.offset?t.offset:10,v=180-m,x=-180+m,E=360-m,M=1;M<e.length;++M){var A=e[M-1][0],I=e[M][0],S=Math.abs(I-A);S>E&&(I>v&&A<x||A>v&&I<x)?h=!0:S>g&&(g=S)}var w=[];if(h&&g<m){var R=[];w.push(R);for(var C=0;C<e.length;++C){var F=parseFloat(e[C][0]);if(C>0&&Math.abs(F-e[C-1][0])>E){var V=parseFloat(e[C-1][0]),X=parseFloat(e[C-1][1]),q=parseFloat(e[C][0]),D=parseFloat(e[C][1]);if(V>-180&&V<x&&q===180&&C+1<e.length&&e[C-1][0]>-180&&e[C-1][0]<x){R.push([-180,e[C][1]]),C++,R.push([e[C][0],e[C][1]]);continue}else if(V>v&&V<180&&q===-180&&C+1<e.length&&e[C-1][0]>v&&e[C-1][0]<180){R.push([180,e[C][1]]),C++,R.push([e[C][0],e[C][1]]);continue}if(V<x&&q>v){var xt=V;V=q,q=xt;var B=X;X=D,D=B}if(V>v&&q<x&&(q+=360),V<=180&&q>=180&&V<q){var j=(180-V)/(q-V),J=j*D+(1-j)*X;R.push([e[C-1][0]>v?180:-180,J]),R=[],R.push([e[C-1][0]>v?-180:180,J]),w.push(R)}else R=[],w.push(R);R.push([F,e[C][1]])}else R.push([e[C][0],e[C][1]])}}else{var Dt=[];w.push(Dt);for(var Q=0;Q<e.length;++Q)Dt.push([e[Q][0],e[Q][1]])}for(var At=new w_(this.properties),Mt=0;Mt<w.length;++Mt){var Lt=new AP;At.geometries.push(Lt);for(var pt=w[Mt],yt=0;yt<pt.length;++yt)Lt.move_to(pt[yt])}return At};var eY=sn(lg(),1);var tZ=sn(lg(),1);var eZ=sn(J_(),1);var iZ=sn(Xd(),1);var ln=[],cn=[],fn=[],hn=[],pn=[],dn=[],gn=[],mn=[],yn=[],vn=[],_n=[],xn=[],En=[],wn=[],Sn=[],Mn=[],bn=[],An=[],Tn=[],Cn=[],Pn=[],In=[],Rn=[],Ln=[];gn[85]=vn[85]=-1;mn[85]=_n[85]=0;yn[85]=xn[85]=1;Tn[85]=In[85]=1;Cn[85]=Rn[85]=0;Pn[85]=Ln[85]=1;ln[85]=hn[85]=0;cn[85]=pn[85]=-1;fn[85]=Sn[85]=0;Mn[85]=En[85]=0;bn[85]=wn[85]=1;dn[85]=An[85]=1;In[1]=In[169]=0;Rn[1]=Rn[169]=-1;Ln[1]=Ln[169]=0;En[1]=En[169]=-1;wn[1]=wn[169]=0;Sn[1]=Sn[169]=0;vn[4]=vn[166]=0;_n[4]=_n[166]=-1;xn[4]=xn[166]=1;Mn[4]=Mn[166]=1;bn[4]=bn[166]=0;An[4]=An[166]=0;gn[16]=gn[154]=0;mn[16]=mn[154]=1;yn[16]=yn[154]=1;hn[16]=hn[154]=1;pn[16]=pn[154]=0;dn[16]=dn[154]=1;Tn[64]=Tn[106]=0;Cn[64]=Cn[106]=1;Pn[64]=Pn[106]=0;ln[64]=ln[106]=-1;cn[64]=cn[106]=0;fn[64]=fn[106]=1;Tn[2]=Tn[168]=0;Cn[2]=Cn[168]=-1;Pn[2]=Pn[168]=1;In[2]=In[168]=0;Rn[2]=Rn[168]=-1;Ln[2]=Ln[168]=0;En[2]=En[168]=-1;wn[2]=wn[168]=0;Sn[2]=Sn[168]=0;Mn[2]=Mn[168]=-1;bn[2]=bn[168]=0;An[2]=An[168]=1;gn[8]=gn[162]=0;mn[8]=mn[162]=-1;yn[8]=yn[162]=0;vn[8]=vn[162]=0;_n[8]=_n[162]=-1;xn[8]=xn[162]=1;En[8]=En[162]=1;wn[8]=wn[162]=0;Sn[8]=Sn[162]=1;Mn[8]=Mn[162]=1;bn[8]=bn[162]=0;An[8]=An[162]=0;gn[32]=gn[138]=0;mn[32]=mn[138]=1;yn[32]=yn[138]=1;vn[32]=vn[138]=0;_n[32]=_n[138]=1;xn[32]=xn[138]=0;ln[32]=ln[138]=1;cn[32]=cn[138]=0;fn[32]=fn[138]=0;hn[32]=hn[138]=1;pn[32]=pn[138]=0;dn[32]=dn[138]=1;In[128]=In[42]=0;Rn[128]=Rn[42]=1;Ln[128]=Ln[42]=1;Tn[128]=Tn[42]=0;Cn[128]=Cn[42]=1;Pn[128]=Pn[42]=0;ln[128]=ln[42]=-1;cn[128]=cn[42]=0;fn[128]=fn[42]=1;hn[128]=hn[42]=-1;pn[128]=pn[42]=0;dn[128]=dn[42]=0;vn[5]=vn[165]=-1;_n[5]=_n[165]=0;xn[5]=xn[165]=0;In[5]=In[165]=1;Rn[5]=Rn[165]=0;Ln[5]=Ln[165]=0;Mn[20]=Mn[150]=0;bn[20]=bn[150]=1;An[20]=An[150]=1;hn[20]=hn[150]=0;pn[20]=pn[150]=-1;dn[20]=dn[150]=1;gn[80]=gn[90]=-1;mn[80]=mn[90]=0;yn[80]=yn[90]=1;Tn[80]=Tn[90]=1;Cn[80]=Cn[90]=0;Pn[80]=Pn[90]=1;En[65]=En[105]=0;wn[65]=wn[105]=1;Sn[65]=Sn[105]=0;ln[65]=ln[105]=0;cn[65]=cn[105]=-1;fn[65]=fn[105]=0;gn[160]=gn[10]=-1;mn[160]=mn[10]=0;yn[160]=yn[10]=1;vn[160]=vn[10]=-1;_n[160]=_n[10]=0;xn[160]=xn[10]=0;In[160]=In[10]=1;Rn[160]=Rn[10]=0;Ln[160]=Ln[10]=0;Tn[160]=Tn[10]=1;Cn[160]=Cn[10]=0;Pn[160]=Pn[10]=1;Mn[130]=Mn[40]=0;bn[130]=bn[40]=1;An[130]=An[40]=1;En[130]=En[40]=0;wn[130]=wn[40]=1;Sn[130]=Sn[40]=0;ln[130]=ln[40]=0;cn[130]=cn[40]=-1;fn[130]=fn[40]=0;hn[130]=hn[40]=0;pn[130]=pn[40]=-1;dn[130]=dn[40]=1;vn[37]=vn[133]=0;_n[37]=_n[133]=1;xn[37]=xn[133]=1;In[37]=In[133]=0;Rn[37]=Rn[133]=1;Ln[37]=Ln[133]=0;ln[37]=ln[133]=-1;cn[37]=cn[133]=0;fn[37]=fn[133]=0;hn[37]=hn[133]=1;pn[37]=pn[133]=0;dn[37]=dn[133]=0;Mn[148]=Mn[22]=-1;bn[148]=bn[22]=0;An[148]=An[22]=0;In[148]=In[22]=0;Rn[148]=Rn[22]=-1;Ln[148]=Ln[22]=1;Tn[148]=Tn[22]=0;Cn[148]=Cn[22]=1;Pn[148]=Pn[22]=1;hn[148]=hn[22]=-1;pn[148]=pn[22]=0;dn[148]=dn[22]=1;gn[82]=gn[88]=0;mn[82]=mn[88]=-1;yn[82]=yn[88]=1;Mn[82]=Mn[88]=1;bn[82]=bn[88]=0;An[82]=An[88]=1;En[82]=En[88]=-1;wn[82]=wn[88]=0;Sn[82]=Sn[88]=1;Tn[82]=Tn[88]=0;Cn[82]=Cn[88]=-1;Pn[82]=Pn[88]=0;gn[73]=gn[97]=0;mn[73]=mn[97]=1;yn[73]=yn[97]=0;vn[73]=vn[97]=0;_n[73]=_n[97]=-1;xn[73]=xn[97]=0;En[73]=En[97]=1;wn[73]=wn[97]=0;Sn[73]=Sn[97]=0;ln[73]=ln[97]=1;cn[73]=cn[97]=0;fn[73]=fn[97]=1;gn[145]=gn[25]=0;mn[145]=mn[25]=-1;yn[145]=yn[25]=0;En[145]=En[25]=1;wn[145]=wn[25]=0;Sn[145]=Sn[25]=1;In[145]=In[25]=0;Rn[145]=Rn[25]=1;Ln[145]=Ln[25]=1;hn[145]=hn[25]=-1;pn[145]=pn[25]=0;dn[145]=dn[25]=0;vn[70]=vn[100]=0;_n[70]=_n[100]=1;xn[70]=xn[100]=0;Mn[70]=Mn[100]=-1;bn[70]=bn[100]=0;An[70]=An[100]=1;Tn[70]=Tn[100]=0;Cn[70]=Cn[100]=-1;Pn[70]=Pn[100]=1;ln[70]=ln[100]=1;cn[70]=cn[100]=0;fn[70]=fn[100]=0;vn[101]=vn[69]=0;_n[101]=_n[69]=1;xn[101]=xn[69]=0;ln[101]=ln[69]=1;cn[101]=cn[69]=0;fn[101]=fn[69]=0;In[149]=In[21]=0;Rn[149]=Rn[21]=1;Ln[149]=Ln[21]=1;hn[149]=hn[21]=-1;pn[149]=pn[21]=0;dn[149]=dn[21]=0;Mn[86]=Mn[84]=-1;bn[86]=bn[84]=0;An[86]=An[84]=1;Tn[86]=Tn[84]=0;Cn[86]=Cn[84]=-1;Pn[86]=Pn[84]=1;gn[89]=gn[81]=0;mn[89]=mn[81]=-1;yn[89]=yn[81]=0;En[89]=En[81]=1;wn[89]=wn[81]=0;Sn[89]=Sn[81]=1;gn[96]=gn[74]=0;mn[96]=mn[74]=1;yn[96]=yn[74]=0;vn[96]=vn[74]=-1;_n[96]=_n[74]=0;xn[96]=xn[74]=1;Tn[96]=Tn[74]=1;Cn[96]=Cn[74]=0;Pn[96]=Pn[74]=0;ln[96]=ln[74]=1;cn[96]=cn[74]=0;fn[96]=fn[74]=1;gn[24]=gn[146]=0;mn[24]=mn[146]=-1;yn[24]=yn[146]=1;Mn[24]=Mn[146]=1;bn[24]=bn[146]=0;An[24]=An[146]=1;En[24]=En[146]=0;wn[24]=wn[146]=1;Sn[24]=Sn[146]=1;hn[24]=hn[146]=0;pn[24]=pn[146]=-1;dn[24]=dn[146]=0;vn[6]=vn[164]=-1;_n[6]=_n[164]=0;xn[6]=xn[164]=1;Mn[6]=Mn[164]=-1;bn[6]=bn[164]=0;An[6]=An[164]=0;In[6]=In[164]=0;Rn[6]=Rn[164]=-1;Ln[6]=Ln[164]=1;Tn[6]=Tn[164]=1;Cn[6]=Cn[164]=0;Pn[6]=Pn[164]=0;En[129]=En[41]=0;wn[129]=wn[41]=1;Sn[129]=Sn[41]=1;In[129]=In[41]=0;Rn[129]=Rn[41]=1;Ln[129]=Ln[41]=0;ln[129]=ln[41]=-1;cn[129]=cn[41]=0;fn[129]=fn[41]=0;hn[129]=hn[41]=0;pn[129]=pn[41]=-1;dn[129]=dn[41]=0;Mn[66]=Mn[104]=0;bn[66]=bn[104]=1;An[66]=An[104]=0;En[66]=En[104]=-1;wn[66]=wn[104]=0;Sn[66]=Sn[104]=1;Tn[66]=Tn[104]=0;Cn[66]=Cn[104]=-1;Pn[66]=Pn[104]=0;ln[66]=ln[104]=0;cn[66]=cn[104]=-1;fn[66]=fn[104]=1;gn[144]=gn[26]=-1;mn[144]=mn[26]=0;yn[144]=yn[26]=0;In[144]=In[26]=1;Rn[144]=Rn[26]=0;Ln[144]=Ln[26]=1;Tn[144]=Tn[26]=0;Cn[144]=Cn[26]=1;Pn[144]=Pn[26]=1;hn[144]=hn[26]=-1;pn[144]=pn[26]=0;dn[144]=dn[26]=1;vn[36]=vn[134]=0;_n[36]=_n[134]=1;xn[36]=xn[134]=1;Mn[36]=Mn[134]=0;bn[36]=bn[134]=1;An[36]=An[134]=0;ln[36]=ln[134]=0;cn[36]=cn[134]=-1;fn[36]=fn[134]=1;hn[36]=hn[134]=1;pn[36]=pn[134]=0;dn[36]=dn[134]=0;gn[9]=gn[161]=-1;mn[9]=mn[161]=0;yn[9]=yn[161]=0;vn[9]=vn[161]=0;_n[9]=_n[161]=-1;xn[9]=xn[161]=0;En[9]=En[161]=1;wn[9]=wn[161]=0;Sn[9]=Sn[161]=0;In[9]=In[161]=1;Rn[9]=Rn[161]=0;Ln[9]=Ln[161]=1;gn[136]=0;mn[136]=1;yn[136]=1;vn[136]=0;_n[136]=1;xn[136]=0;Mn[136]=-1;bn[136]=0;An[136]=1;En[136]=-1;wn[136]=0;Sn[136]=0;In[136]=0;Rn[136]=-1;Ln[136]=0;Tn[136]=0;Cn[136]=-1;Pn[136]=1;ln[136]=1;cn[136]=0;fn[136]=0;hn[136]=1;pn[136]=0;dn[136]=1;gn[34]=0;mn[34]=-1;yn[34]=0;vn[34]=0;_n[34]=-1;xn[34]=1;Mn[34]=1;bn[34]=0;An[34]=0;En[34]=1;wn[34]=0;Sn[34]=1;In[34]=0;Rn[34]=1;Ln[34]=1;Tn[34]=0;Cn[34]=1;Pn[34]=0;ln[34]=-1;cn[34]=0;fn[34]=1;hn[34]=-1;pn[34]=0;dn[34]=0;gn[35]=0;mn[35]=1;yn[35]=1;vn[35]=0;_n[35]=-1;xn[35]=1;Mn[35]=1;bn[35]=0;An[35]=0;En[35]=-1;wn[35]=0;Sn[35]=0;In[35]=0;Rn[35]=-1;Ln[35]=0;Tn[35]=0;Cn[35]=1;Pn[35]=0;ln[35]=-1;cn[35]=0;fn[35]=1;hn[35]=1;pn[35]=0;dn[35]=1;gn[153]=0;mn[153]=1;yn[153]=1;En[153]=-1;wn[153]=0;Sn[153]=0;In[153]=0;Rn[153]=-1;Ln[153]=0;hn[153]=1;pn[153]=0;dn[153]=1;vn[102]=0;_n[102]=-1;xn[102]=1;Mn[102]=1;bn[102]=0;An[102]=0;Tn[102]=0;Cn[102]=1;Pn[102]=0;ln[102]=-1;cn[102]=0;fn[102]=1;gn[155]=0;mn[155]=-1;yn[155]=0;En[155]=1;wn[155]=0;Sn[155]=1;In[155]=0;Rn[155]=1;Ln[155]=1;hn[155]=-1;pn[155]=0;dn[155]=0;vn[103]=0;_n[103]=1;xn[103]=0;Mn[103]=-1;bn[103]=0;An[103]=1;Tn[103]=0;Cn[103]=-1;Pn[103]=1;ln[103]=1;cn[103]=0;fn[103]=0;gn[152]=0;mn[152]=1;yn[152]=1;Mn[152]=-1;bn[152]=0;An[152]=1;En[152]=-1;wn[152]=0;Sn[152]=0;In[152]=0;Rn[152]=-1;Ln[152]=0;Tn[152]=0;Cn[152]=-1;Pn[152]=1;hn[152]=1;pn[152]=0;dn[152]=1;gn[156]=0;mn[156]=-1;yn[156]=1;Mn[156]=1;bn[156]=0;An[156]=1;En[156]=-1;wn[156]=0;Sn[156]=0;In[156]=0;Rn[156]=-1;Ln[156]=0;Tn[156]=0;Cn[156]=1;Pn[156]=1;hn[156]=-1;pn[156]=0;dn[156]=1;gn[137]=0;mn[137]=1;yn[137]=1;vn[137]=0;_n[137]=1;xn[137]=0;En[137]=-1;wn[137]=0;Sn[137]=0;In[137]=0;Rn[137]=-1;Ln[137]=0;ln[137]=1;cn[137]=0;fn[137]=0;hn[137]=1;pn[137]=0;dn[137]=1;gn[139]=0;mn[139]=1;yn[139]=1;vn[139]=0;_n[139]=-1;xn[139]=0;En[139]=1;wn[139]=0;Sn[139]=0;In[139]=0;Rn[139]=1;Ln[139]=0;ln[139]=-1;cn[139]=0;fn[139]=0;hn[139]=1;pn[139]=0;dn[139]=1;gn[98]=0;mn[98]=-1;yn[98]=0;vn[98]=0;_n[98]=-1;xn[98]=1;Mn[98]=1;bn[98]=0;An[98]=0;En[98]=1;wn[98]=0;Sn[98]=1;Tn[98]=0;Cn[98]=1;Pn[98]=0;ln[98]=-1;cn[98]=0;fn[98]=1;gn[99]=0;mn[99]=1;yn[99]=0;vn[99]=0;_n[99]=-1;xn[99]=1;Mn[99]=1;bn[99]=0;An[99]=0;En[99]=-1;wn[99]=0;Sn[99]=1;Tn[99]=0;Cn[99]=-1;Pn[99]=0;ln[99]=1;cn[99]=0;fn[99]=1;vn[38]=0;_n[38]=-1;xn[38]=1;Mn[38]=1;bn[38]=0;An[38]=0;In[38]=0;Rn[38]=1;Ln[38]=1;Tn[38]=0;Cn[38]=1;Pn[38]=0;ln[38]=-1;cn[38]=0;fn[38]=1;hn[38]=-1;pn[38]=0;dn[38]=0;vn[39]=0;_n[39]=1;xn[39]=1;Mn[39]=-1;bn[39]=0;An[39]=0;In[39]=0;Rn[39]=-1;Ln[39]=1;Tn[39]=0;Cn[39]=1;Pn[39]=0;ln[39]=-1;cn[39]=0;fn[39]=1;hn[39]=1;pn[39]=0;dn[39]=0;var K_=function(n){return[[n.bottomleft,0],[0,0],[0,n.leftbottom]]},j_=function(n){return[[1,n.rightbottom],[1,0],[n.bottomright,0]]},Q_=function(n){return[[n.topright,1],[1,1],[1,n.righttop]]},t1=function(n){return[[0,n.lefttop],[0,1],[n.topleft,1]]},e1=function(n){return[[n.bottomright,0],[n.bottomleft,0],[0,n.leftbottom],[0,n.lefttop]]},n1=function(n){return[[n.bottomright,0],[n.bottomleft,0],[1,n.righttop],[1,n.rightbottom]]},r1=function(n){return[[1,n.righttop],[1,n.rightbottom],[n.topleft,1],[n.topright,1]]},i1=function(n){return[[0,n.leftbottom],[0,n.lefttop],[n.topleft,1],[n.topright,1]]},oZ=function(n){return[[0,0],[0,n.leftbottom],[1,n.rightbottom],[1,0]]},sZ=function(n){return[[1,0],[n.bottomright,0],[n.topright,1],[1,1]]},aZ=function(n){return[[1,1],[1,n.righttop],[0,n.lefttop],[0,1]]},uZ=function(n){return[[n.bottomleft,0],[0,0],[0,1],[n.topleft,1]]},lZ=function(n){return[[1,n.righttop],[1,n.rightbottom],[0,n.leftbottom],[0,n.lefttop]]},cZ=function(n){return[[n.topleft,1],[n.topright,1],[n.bottomright,0],[n.bottomleft,0]]},fZ=function(){return[[0,0],[0,1],[1,1],[1,0]]},hZ=function(n){return[[1,n.rightbottom],[1,0],[0,0],[0,1],[n.topleft,1]]},pZ=function(n){return[[n.topright,1],[1,1],[1,0],[0,0],[0,n.leftbottom]]},dZ=function(n){return[[1,0],[n.bottomright,0],[0,n.lefttop],[0,1],[1,1]]},gZ=function(n){return[[1,1],[1,n.righttop],[n.bottomleft,0],[0,0],[0,1]]},mZ=function(n){return[[1,n.righttop],[1,n.rightbottom],[0,n.lefttop],[0,1],[n.topleft,1]]},yZ=function(n){return[[1,1],[1,n.righttop],[n.bottomright,0],[n.bottomleft,0],[n.topright,1]]},vZ=function(n){return[[1,n.rightbottom],[1,0],[n.bottomright,0],[0,n.leftbottom],[0,n.lefttop]]},_Z=function(n){return[[n.topright,1],[n.bottomleft,0],[0,0],[0,n.leftbottom],[n.topleft,1]]},xZ=function(n){return[[n.bottomright,0],[n.bottomleft,0],[0,n.lefttop],[0,1],[n.topleft,1]]},EZ=function(n){return[[1,1],[1,n.righttop],[0,n.leftbottom],[0,n.lefttop],[n.topright,1]]},wZ=function(n){return[[1,n.rightbottom],[1,0],[n.bottomright,0],[n.topleft,1],[n.topright,1]]},SZ=function(n){return[[1,n.righttop],[1,n.rightbottom],[n.bottomleft,0],[0,0],[0,n.leftbottom]]},MZ=function(n){return[[1,n.rightbottom],[1,0],[0,0],[0,n.leftbottom],[n.topleft,1],[n.topright,1]]},bZ=function(n){return[[1,1],[1,0],[n.bottomright,0],[0,n.leftbottom],[0,n.lefttop],[n.topright,1]]},AZ=function(n){return[[1,1],[1,n.righttop],[n.bottomright,0],[n.bottomleft,0],[0,n.lefttop],[0,1]]},TZ=function(n){return[[1,n.righttop],[1,n.rightbottom],[n.bottomleft,0],[0,0],[0,1],[n.topleft,1]]},CZ=function(n){return[[1,1],[1,n.righttop],[n.bottomleft,0],[0,0],[0,n.leftbottom],[n.topright,1]]},PZ=function(n){return[[1,n.rightbottom],[1,0],[n.bottomright,0],[0,n.lefttop],[0,1],[n.topleft,1]]},IZ=function(n){return[[1,n.righttop],[1,n.rightbottom],[n.bottomright,0],[n.bottomleft,0],[0,n.leftbottom],[0,n.lefttop],[n.topleft,1],[n.topright,1]]},RZ=function(n){return[[1,1],[1,n.righttop],[n.bottomleft,0],[0,0],[0,n.leftbottom],[n.topright,1]]},LZ=function(n){return[[1,n.rightbottom],[1,0],[n.bottomright,0],[0,n.lefttop],[0,1],[n.topleft,1]]},NZ=function(n){return[[1,1],[1,n.righttop],[n.bottomright,0],[n.bottomleft,0],[0,n.leftbottom],[0,n.lefttop],[n.topright,1]]},OZ=function(n){return[[1,n.righttop],[1,n.rightbottom],[n.bottomleft,0],[0,0],[0,n.leftbottom],[n.topleft,1],[n.topright,1]]},DZ=function(n){return[[1,n.righttop],[1,n.rightbottom],[n.bottomright,0],[n.bottomleft,0],[0,n.lefttop],[0,1],[n.topleft,1]]},FZ=function(n){return[[1,n.rightbottom],[1,0],[n.bottomright,0],[0,n.leftbottom],[0,n.lefttop],[n.topleft,1],[n.topright,1]]},Bn=[],zn=[],Gn=[],kn=[],qn=[],Hn=[],Vn=[],Wn=[];kn[1]=qn[1]=18;kn[169]=qn[169]=18;Gn[4]=zn[4]=12;Gn[166]=zn[166]=12;Bn[16]=Wn[16]=4;Bn[154]=Wn[154]=4;Hn[64]=Vn[64]=22;Hn[106]=Vn[106]=22;Gn[2]=Hn[2]=17;kn[2]=qn[2]=18;Gn[168]=Hn[168]=17;kn[168]=qn[168]=18;Bn[8]=kn[8]=9;zn[8]=Gn[8]=12;Bn[162]=kn[162]=9;zn[162]=Gn[162]=12;Bn[32]=Wn[32]=4;zn[32]=Vn[32]=1;Bn[138]=Wn[138]=4;zn[138]=Vn[138]=1;qn[128]=Wn[128]=21;Hn[128]=Vn[128]=22;qn[42]=Wn[42]=21;Hn[42]=Vn[42]=22;zn[5]=qn[5]=14;zn[165]=qn[165]=14;Gn[20]=Wn[20]=6;Gn[150]=Wn[150]=6;Bn[80]=Hn[80]=11;Bn[90]=Hn[90]=11;kn[65]=Vn[65]=3;kn[105]=Vn[105]=3;Bn[160]=Hn[160]=11;zn[160]=qn[160]=14;Bn[10]=Hn[10]=11;zn[10]=qn[10]=14;Gn[130]=Wn[130]=6;kn[130]=Vn[130]=3;Gn[40]=Wn[40]=6;kn[40]=Vn[40]=3;zn[101]=Vn[101]=1;zn[69]=Vn[69]=1;qn[149]=Wn[149]=21;qn[21]=Wn[21]=21;Gn[86]=Hn[86]=17;Gn[84]=Hn[84]=17;Bn[89]=kn[89]=9;Bn[81]=kn[81]=9;Bn[96]=Vn[96]=0;zn[96]=Hn[96]=15;Bn[74]=Vn[74]=0;zn[74]=Hn[74]=15;Bn[24]=Gn[24]=8;kn[24]=Wn[24]=7;Bn[146]=Gn[146]=8;kn[146]=Wn[146]=7;zn[6]=Hn[6]=15;Gn[6]=qn[6]=16;zn[164]=Hn[164]=15;Gn[164]=qn[164]=16;kn[129]=Wn[129]=7;qn[129]=Vn[129]=20;kn[41]=Wn[41]=7;qn[41]=Vn[41]=20;Gn[66]=Vn[66]=2;kn[66]=Hn[66]=19;Gn[104]=Vn[104]=2;kn[104]=Hn[104]=19;Bn[144]=qn[144]=10;Hn[144]=Wn[144]=23;Bn[26]=qn[26]=10;Hn[26]=Wn[26]=23;zn[36]=Wn[36]=5;Gn[36]=Vn[36]=2;zn[134]=Wn[134]=5;Gn[134]=Vn[134]=2;Bn[9]=qn[9]=10;zn[9]=kn[9]=13;Bn[161]=qn[161]=10;zn[161]=kn[161]=13;zn[37]=Wn[37]=5;qn[37]=Vn[37]=20;zn[133]=Wn[133]=5;qn[133]=Vn[133]=20;Gn[148]=qn[148]=16;Hn[148]=Wn[148]=23;Gn[22]=qn[22]=16;Hn[22]=Wn[22]=23;Bn[82]=Gn[82]=8;kn[82]=Hn[82]=19;Bn[88]=Gn[88]=8;kn[88]=Hn[88]=19;Bn[73]=Vn[73]=0;zn[73]=kn[73]=13;Bn[97]=Vn[97]=0;zn[97]=kn[97]=13;Bn[145]=kn[145]=9;qn[145]=Wn[145]=21;Bn[25]=kn[25]=9;qn[25]=Wn[25]=21;zn[70]=Vn[70]=1;Gn[70]=Hn[70]=17;zn[100]=Vn[100]=1;Gn[100]=Hn[100]=17;Bn[34]=kn[34]=9;zn[34]=Gn[34]=12;qn[34]=Wn[34]=21;Hn[34]=Vn[34]=22;Bn[136]=Wn[136]=4;zn[136]=Vn[136]=1;Gn[136]=Hn[136]=17;kn[136]=qn[136]=18;Bn[35]=Wn[35]=4;zn[35]=Gn[35]=12;kn[35]=qn[35]=18;Hn[35]=Vn[35]=22;Bn[153]=Wn[153]=4;kn[153]=qn[153]=18;zn[102]=Gn[102]=12;Hn[102]=Vn[102]=22;Bn[155]=kn[155]=9;qn[155]=Wn[155]=23;zn[103]=Vn[103]=1;Gn[103]=Hn[103]=17;Bn[152]=Wn[152]=4;Gn[152]=Hn[152]=17;kn[152]=qn[152]=18;Bn[156]=Gn[156]=8;kn[156]=qn[156]=18;Hn[156]=Wn[156]=23;Bn[137]=Wn[137]=4;zn[137]=Vn[137]=1;kn[137]=qn[137]=18;Bn[139]=Wn[139]=4;zn[139]=kn[139]=13;qn[139]=Vn[139]=20;Bn[98]=kn[98]=9;zn[98]=Gn[98]=12;Hn[98]=Vn[98]=22;Bn[99]=Vn[99]=0;zn[99]=Gn[99]=12;kn[99]=Hn[99]=19;zn[38]=Gn[38]=12;qn[38]=Wn[38]=21;Hn[38]=Vn[38]=22;zn[39]=Wn[39]=5;Gn[39]=qn[39]=16;Hn[39]=Vn[39]=22;var re=[];re[1]=re[169]=K_;re[4]=re[166]=j_;re[16]=re[154]=Q_;re[64]=re[106]=t1;re[168]=re[2]=e1;re[162]=re[8]=n1;re[138]=re[32]=r1;re[42]=re[128]=i1;re[5]=re[165]=oZ;re[20]=re[150]=sZ;re[80]=re[90]=aZ;re[65]=re[105]=uZ;re[160]=re[10]=lZ;re[130]=re[40]=cZ;re[85]=fZ;re[101]=re[69]=hZ;re[149]=re[21]=pZ;re[86]=re[84]=dZ;re[89]=re[81]=gZ;re[96]=re[74]=mZ;re[24]=re[146]=yZ;re[6]=re[164]=vZ;re[129]=re[41]=_Z;re[66]=re[104]=xZ;re[144]=re[26]=EZ;re[36]=re[134]=wZ;re[9]=re[161]=SZ;re[37]=re[133]=MZ;re[148]=re[22]=bZ;re[82]=re[88]=AZ;re[73]=re[97]=TZ;re[145]=re[25]=CZ;re[70]=re[100]=PZ;re[34]=function(n){return[i1(n),n1(n)]};re[35]=IZ;re[136]=function(n){return[r1(n),e1(n)]};re[153]=function(n){return[Q_(n),K_(n)]};re[102]=function(n){return[j_(n),t1(n)]};re[155]=RZ;re[103]=LZ;re[152]=function(n){return[Q_(n),e1(n)]};re[156]=NZ;re[137]=function(n){return[r1(n),K_(n)]};re[139]=OZ;re[98]=function(n){return[n1(n),t1(n)]};re[99]=DZ;re[38]=function(n){return[j_(n),i1(n)]};re[39]=FZ;function BZ(n){return(n>0)-(n<0)||+n}function ff(n,t,e){var o=t[0]-n[0],s=t[1]-n[1],l=e[0]-t[0],p=e[1]-t[1];return BZ(o*p-l*s)}function dL(n,t){var e=n.geometry.coordinates[0].map(function(p){return p[0]}),o=n.geometry.coordinates[0].map(function(p){return p[1]}),s=t.geometry.coordinates[0].map(function(p){return p[0]}),l=t.geometry.coordinates[0].map(function(p){return p[1]});return Math.max.apply(null,e)===Math.max.apply(null,s)&&Math.max.apply(null,o)===Math.max.apply(null,l)&&Math.min.apply(null,e)===Math.min.apply(null,s)&&Math.min.apply(null,o)===Math.min.apply(null,l)}function o1(n,t){return t.geometry.coordinates[0].every(function(e){return ki(Pr(e),n)})}function gL(n,t){return n[0]===t[0]&&n[1]===t[1]}var zZ=function(){function n(t){this.id=n.buildId(t),this.coordinates=t,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}return n.buildId=function(t){return t.join(",")},n.prototype.removeInnerEdge=function(t){this.innerEdges=this.innerEdges.filter(function(e){return e.from.id!==t.from.id})},n.prototype.removeOuterEdge=function(t){this.outerEdges=this.outerEdges.filter(function(e){return e.to.id!==t.to.id})},n.prototype.addOuterEdge=function(t){this.outerEdges.push(t),this.outerEdgesSorted=!1},n.prototype.sortOuterEdges=function(){var t=this;this.outerEdgesSorted||(this.outerEdges.sort(function(e,o){var s=e.to,l=o.to;if(s.coordinates[0]-t.coordinates[0]>=0&&l.coordinates[0]-t.coordinates[0]<0)return 1;if(s.coordinates[0]-t.coordinates[0]<0&&l.coordinates[0]-t.coordinates[0]>=0)return-1;if(s.coordinates[0]-t.coordinates[0]===0&&l.coordinates[0]-t.coordinates[0]===0)return s.coordinates[1]-t.coordinates[1]>=0||l.coordinates[1]-t.coordinates[1]>=0?s.coordinates[1]-l.coordinates[1]:l.coordinates[1]-s.coordinates[1];var p=ff(t.coordinates,s.coordinates,l.coordinates);if(p<0)return 1;if(p>0)return-1;var h=Math.pow(s.coordinates[0]-t.coordinates[0],2)+Math.pow(s.coordinates[1]-t.coordinates[1],2),g=Math.pow(l.coordinates[0]-t.coordinates[0],2)+Math.pow(l.coordinates[1]-t.coordinates[1],2);return h-g}),this.outerEdgesSorted=!0)},n.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges},n.prototype.getOuterEdge=function(t){return this.sortOuterEdges(),this.outerEdges[t]},n.prototype.addInnerEdge=function(t){this.innerEdges.push(t)},n}(),s1=zZ;var GZ=function(){function n(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 n.prototype.getSymetric=function(){return this.symetric||(this.symetric=new n(this.to,this.from),this.symetric.symetric=this),this.symetric},n.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)},n.prototype.isEqual=function(t){return this.from.id===t.from.id&&this.to.id===t.to.id},n.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }"},n.prototype.toLineString=function(){return Gi([this.from.coordinates,this.to.coordinates])},n.prototype.compareTo=function(t){return ff(t.from.coordinates,t.to.coordinates,this.to.coordinates)},n}(),mL=GZ;var kZ=function(){function n(){this.edges=[],this.polygon=void 0,this.envelope=void 0}return n.prototype.push=function(t){this.edges.push(t),this.polygon=this.envelope=void 0},n.prototype.get=function(t){return this.edges[t]},Object.defineProperty(n.prototype,"length",{get:function(){return this.edges.length},enumerable:!0,configurable:!0}),n.prototype.forEach=function(t){this.edges.forEach(t)},n.prototype.map=function(t){return this.edges.map(t)},n.prototype.some=function(t){return this.edges.some(t)},n.prototype.isValid=function(){return!0},n.prototype.isHole=function(){var t=this,e=this.edges.reduce(function(p,h,g){return h.from.coordinates[1]>t.edges[p].from.coordinates[1]&&(p=g),p},0),o=(e===0?this.length:e)-1,s=(e+1)%this.length,l=ff(this.edges[o].from.coordinates,this.edges[e].from.coordinates,this.edges[s].from.coordinates);return l===0?this.edges[o].from.coordinates[0]>this.edges[s].from.coordinates[0]:l>0},n.prototype.toMultiPoint=function(){return Uv(this.edges.map(function(t){return t.from.coordinates}))},n.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=Dr([t])},n.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=n_(this.toPolygon())},n.findEdgeRingContaining=function(t,e){var o=t.getEnvelope(),s,l;return e.forEach(function(p){var h=p.getEnvelope();if(l&&(s=l.getEnvelope()),!dL(h,o)&&o1(h,o)){for(var g=t.map(function(A){return A.from.coordinates}),m=void 0,v=function(A){p.some(function(I){return gL(A,I.from.coordinates)})||(m=A)},x=0,E=g;x<E.length;x++){var M=E[x];v(M)}m&&p.inside(Pr(m))&&(!l||o1(s,h))&&(l=p)}}),l},n.prototype.inside=function(t){return ki(t,this.toPolygon())},n}(),a1=kZ;function qZ(n){if(!n)throw new Error("No geojson passed");if(n.type!=="FeatureCollection"&&n.type!=="GeometryCollection"&&n.type!=="MultiLineString"&&n.type!=="LineString"&&n.type!=="Feature")throw new Error("Invalid input type '"+n.type+"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")}var lct=function(){function n(){this.edges=[],this.nodes={}}return n.fromGeoJson=function(t){qZ(t);var e=new n;return ys(t,function(o){zv(o,"LineString","Graph::fromGeoJson"),TC(o,function(s,l){if(s){var p=e.getNode(s),h=e.getNode(l);e.addEdge(p,h)}return l})}),e},n.prototype.getNode=function(t){var e=s1.buildId(t),o=this.nodes[e];return o||(o=this.nodes[e]=new s1(t)),o},n.prototype.addEdge=function(t,e){var o=new mL(t,e),s=o.getSymetric();this.edges.push(o),this.edges.push(s)},n.prototype.deleteDangles=function(){var t=this;Object.keys(this.nodes).map(function(e){return t.nodes[e]}).forEach(function(e){return t._removeIfDangle(e)})},n.prototype._removeIfDangle=function(t){var e=this;if(t.innerEdges.length<=1){var o=t.getOuterEdges().map(function(s){return s.to});this.removeNode(t),o.forEach(function(s){return e._removeIfDangle(s)})}},n.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))})},n.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,s){t.getOuterEdge((s===0?t.getOuterEdges().length:s)-1).symetric.next=o})},n.prototype._computeNextCCWEdges=function(t,e){for(var o=t.getOuterEdges(),s,l,p=o.length-1;p>=0;--p){var h=o[p],g=h.symetric,m=void 0,v=void 0;h.label===e&&(m=h),g.label===e&&(v=g),!(!m||!v)&&(v&&(l=v),m&&(l&&(l.next=m,l=void 0),s||(s=m)))}l&&(l.next=s)},n.prototype._findLabeledEdgeRings=function(){var t=[],e=0;return this.edges.forEach(function(o){if(!(o.label>=0)){t.push(o);var s=o;do s.label=e,s=s.next;while(!o.isEqual(s));e++}}),t},n.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(s){t._computeNextCCWEdges(s,o.label)})});var e=[];return this.edges.forEach(function(o){o.ring||e.push(t._findEdgeRing(o))}),e},n.prototype._findIntersectionNodes=function(t){var e=[],o=t,s=function(){var l=0;o.from.getOuterEdges().forEach(function(p){p.label===t.label&&++l}),l>1&&e.push(o.from),o=o.next};do s();while(!t.isEqual(o));return e},n.prototype._findEdgeRing=function(t){var e=t,o=new a1;do o.push(e),e.ring=o,e=e.next;while(!t.isEqual(e));return o},n.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]},n.prototype.removeEdge=function(t){this.edges=this.edges.filter(function(e){return!e.isEqual(t)}),t.deleteEdge()},n}();var XZ=sn(u1(),1);var YZ=sn(u1(),1);var ZZ=sn(bL(),1);var nJ=sn(DL(),1);function UL(n){for(var t=n,e=[];t.parent;)e.unshift(t),t=t.parent;return e}function iJ(){return new BL(function(n){return n.f})}var h1={search:function(n,t,e,o){n.cleanDirty(),o=o||{};var s=o.heuristic||h1.heuristics.manhattan,l=o.closest||!1,p=iJ(),h=t;for(t.h=s(t,e),p.push(t);p.size()>0;){var g=p.pop();if(g===e)return UL(g);g.closed=!0;for(var m=n.neighbors(g),v=0,x=m.length;v<x;++v){var E=m[v];if(!(E.closed||E.isWall())){var M=g.g+E.getCost(g),A=E.visited;(!A||M<E.g)&&(E.visited=!0,E.parent=g,E.h=E.h||s(E,e),E.g=M,E.f=E.g+E.h,n.markDirty(E),l&&(E.h<h.h||E.h===h.h&&E.g<h.g)&&(h=E),A?p.rescoreElement(E):p.push(E))}}}return l?UL(h):[]},heuristics:{manhattan:function(n,t){var e=Math.abs(t.x-n.x),o=Math.abs(t.y-n.y);return e+o},diagonal:function(n,t){var e=1,o=Math.sqrt(2),s=Math.abs(t.x-n.x),l=Math.abs(t.y-n.y);return e*(s+l)+(o-2*e)*Math.min(s,l)}},cleanNode:function(n){n.f=0,n.g=0,n.h=0,n.visited=!1,n.closed=!1,n.parent=null}};function Ih(n,t){t=t||{},this.nodes=[],this.diagonal=!!t.diagonal,this.grid=[];for(var e=0;e<n.length;e++){this.grid[e]=[];for(var o=0,s=n[e];o<s.length;o++){var l=new Fg(e,o,s[o]);this.grid[e][o]=l,this.nodes.push(l)}}this.init()}Ih.prototype.init=function(){this.dirtyNodes=[];for(var n=0;n<this.nodes.length;n++)h1.cleanNode(this.nodes[n])};Ih.prototype.cleanDirty=function(){for(var n=0;n<this.dirtyNodes.length;n++)h1.cleanNode(this.dirtyNodes[n]);this.dirtyNodes=[]};Ih.prototype.markDirty=function(n){this.dirtyNodes.push(n)};Ih.prototype.neighbors=function(n){var t=[],e=n.x,o=n.y,s=this.grid;return s[e-1]&&s[e-1][o]&&t.push(s[e-1][o]),s[e+1]&&s[e+1][o]&&t.push(s[e+1][o]),s[e]&&s[e][o-1]&&t.push(s[e][o-1]),s[e]&&s[e][o+1]&&t.push(s[e][o+1]),this.diagonal&&(s[e-1]&&s[e-1][o-1]&&t.push(s[e-1][o-1]),s[e+1]&&s[e+1][o-1]&&t.push(s[e+1][o-1]),s[e-1]&&s[e-1][o+1]&&t.push(s[e-1][o+1]),s[e+1]&&s[e+1][o+1]&&t.push(s[e+1][o+1])),t};Ih.prototype.toString=function(){for(var n=[],t=this.grid,e,o,s,l,p=0,h=t.length;p<h;p++){for(e=[],o=t[p],s=0,l=o.length;s<l;s++)e.push(o[s].weight);n.push(e.join(" "))}return n.join(\`
27665
27665
  \`)};function Fg(n,t,e){this.x=n,this.y=t,this.weight=e}Fg.prototype.toString=function(){return"["+this.x+" "+this.y+"]"};Fg.prototype.getCost=function(n){return n&&n.x!==this.x&&n.y!==this.y?this.weight*1.41421:this.weight};Fg.prototype.isWall=function(){return this.weight===0};function BL(n){this.content=[],this.scoreFunction=n}BL.prototype={push:function(n){this.content.push(n),this.sinkDown(this.content.length-1)},pop:function(){var n=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),n},remove:function(n){var t=this.content.indexOf(n),e=this.content.pop();t!==this.content.length-1&&(this.content[t]=e,this.scoreFunction(e)<this.scoreFunction(n)?this.sinkDown(t):this.bubbleUp(t))},size:function(){return this.content.length},rescoreElement:function(n){this.sinkDown(this.content.indexOf(n))},sinkDown:function(n){for(var t=this.content[n];n>0;){var e=(n+1>>1)-1,o=this.content[e];if(this.scoreFunction(t)<this.scoreFunction(o))this.content[e]=t,this.content[n]=o,n=e;else break}},bubbleUp:function(n){for(var t=this.content.length,e=this.content[n],o=this.scoreFunction(e);;){var s=n+1<<1,l=s-1,p=null,h;if(l<t){var g=this.content[l];h=this.scoreFunction(g),h<o&&(p=l)}if(s<t){var m=this.content[s],v=this.scoreFunction(m);v<(p===null?o:h)&&(p=s)}if(p!==null)this.content[n]=this.content[p],this.content[p]=e,n=p;else break}}};function p1(){this._=null}function pf(n){n.U=n.C=n.L=n.R=n.P=n.N=null}p1.prototype={constructor:p1,insert:function(n,t){var e,o,s;if(n){if(t.P=n,t.N=n.N,n.N&&(n.N.P=t),n.N=t,n.R){for(n=n.R;n.L;)n=n.L;n.L=t}else n.R=t;e=n}else this._?(n=zL(this._),t.P=null,t.N=n,n.P=n.L=t,e=n):(t.P=t.N=null,this._=t,e=null);for(t.L=t.R=null,t.U=e,t.C=!0,n=t;e&&e.C;)o=e.U,e===o.L?(s=o.R,s&&s.C?(e.C=s.C=!1,o.C=!0,n=o):(n===e.R&&(Rh(this,e),n=e,e=n.U),e.C=!1,o.C=!0,Lh(this,o))):(s=o.L,s&&s.C?(e.C=s.C=!1,o.C=!0,n=o):(n===e.L&&(Lh(this,e),n=e,e=n.U),e.C=!1,o.C=!0,Rh(this,o))),e=n.U;this._.C=!1},remove:function(n){n.N&&(n.N.P=n.P),n.P&&(n.P.N=n.N),n.N=n.P=null;var t=n.U,e,o=n.L,s=n.R,l,p;if(o?s?l=zL(s):l=o:l=s,t?t.L===n?t.L=l:t.R=l:this._=l,o&&s?(p=l.C,l.C=n.C,l.L=o,o.U=l,l!==s?(t=l.U,l.U=n.U,n=l.R,t.L=n,l.R=s,s.U=l):(l.U=t,t=l,n=l.R)):(p=n.C,n=l),n&&(n.U=t),!p){if(n&&n.C){n.C=!1;return}do{if(n===this._)break;if(n===t.L){if(e=t.R,e.C&&(e.C=!1,t.C=!0,Rh(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,Lh(this,e),e=t.R),e.C=t.C,t.C=e.R.C=!1,Rh(this,t),n=this._;break}}else if(e=t.L,e.C&&(e.C=!1,t.C=!0,Lh(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,Rh(this,e),e=t.L),e.C=t.C,t.C=e.L.C=!1,Lh(this,t),n=this._;break}e.C=!0,n=t,t=t.U}while(!n.C);n&&(n.C=!1)}}};function Rh(n,t){var e=t,o=t.R,s=e.U;s?s.L===e?s.L=o:s.R=o:n._=o,o.U=s,e.U=o,e.R=o.L,e.R&&(e.R.U=e),o.L=e}function Lh(n,t){var e=t,o=t.L,s=e.U;s?s.L===e?s.L=o:s.R=o:n._=o,o.U=s,e.U=o,e.L=o.R,e.L&&(e.L.U=e),o.R=e}function zL(n){for(;n.L;)n=n.L;return n}var d1=p1;function df(n,t,e,o){var s=[null,null],l=Hi.push(s)-1;return s.left=n,s.right=t,e&&Nh(s,n,t,e),o&&Nh(s,t,n,o),To[n.index].halfedges.push(l),To[t.index].halfedges.push(l),s}function gf(n,t,e){var o=[t,e];return o.left=n,o}function Nh(n,t,e,o){!n[0]&&!n[1]?(n[0]=o,n.left=t,n.right=e):n.left===e?n[1]=o:n[0]=o}function oJ(n,t,e,o,s){var l=n[0],p=n[1],h=l[0],g=l[1],m=p[0],v=p[1],x=0,E=1,M=m-h,A=v-g,I;if(I=t-h,!(!M&&I>0)){if(I/=M,M<0){if(I<x)return;I<E&&(E=I)}else if(M>0){if(I>E)return;I>x&&(x=I)}if(I=o-h,!(!M&&I<0)){if(I/=M,M<0){if(I>E)return;I>x&&(x=I)}else if(M>0){if(I<x)return;I<E&&(E=I)}if(I=e-g,!(!A&&I>0)){if(I/=A,A<0){if(I<x)return;I<E&&(E=I)}else if(A>0){if(I>E)return;I>x&&(x=I)}if(I=s-g,!(!A&&I<0)){if(I/=A,A<0){if(I>E)return;I>x&&(x=I)}else if(A>0){if(I<x)return;I<E&&(E=I)}return!(x>0)&&!(E<1)||(x>0&&(n[0]=[h+x*M,g+x*A]),E<1&&(n[1]=[h+E*M,g+E*A])),!0}}}}}function sJ(n,t,e,o,s){var l=n[1];if(l)return!0;var p=n[0],h=n.left,g=n.right,m=h[0],v=h[1],x=g[0],E=g[1],M=(m+x)/2,A=(v+E)/2,I,S;if(E===v){if(M<t||M>=o)return;if(m>x){if(!p)p=[M,e];else if(p[1]>=s)return;l=[M,s]}else{if(!p)p=[M,s];else if(p[1]<e)return;l=[M,e]}}else if(I=(m-x)/(E-v),S=A-I*M,I<-1||I>1)if(m>x){if(!p)p=[(e-S)/I,e];else if(p[1]>=s)return;l=[(s-S)/I,s]}else{if(!p)p=[(s-S)/I,s];else if(p[1]<e)return;l=[(e-S)/I,e]}else if(v<E){if(!p)p=[t,I*t+S];else if(p[0]>=o)return;l=[o,I*o+S]}else{if(!p)p=[o,I*o+S];else if(p[0]<t)return;l=[t,I*t+S]}return n[0]=p,n[1]=l,!0}function GL(n,t,e,o){for(var s=Hi.length,l;s--;)(!sJ(l=Hi[s],n,t,e,o)||!oJ(l,n,t,e,o)||!(Math.abs(l[0][0]-l[1][0])>Er||Math.abs(l[0][1]-l[1][1])>Er))&&delete Hi[s]}function kL(n){return To[n.index]={site:n,halfedges:[]}}function aJ(n,t){var e=n.site,o=t.left,s=t.right;return e===s&&(s=o,o=e),s?Math.atan2(s[1]-o[1],s[0]-o[0]):(e===o?(o=t[1],s=t[0]):(o=t[0],s=t[1]),Math.atan2(o[0]-s[0],s[1]-o[1]))}function g1(n,t){return t[+(t.left!==n.site)]}function uJ(n,t){return t[+(t.left===n.site)]}function qL(){for(var n=0,t=To.length,e,o,s,l;n<t;++n)if((e=To[n])&&(l=(o=e.halfedges).length)){var p=new Array(l),h=new Array(l);for(s=0;s<l;++s)p[s]=s,h[s]=aJ(e,Hi[o[s]]);for(p.sort(function(g,m){return h[m]-h[g]}),s=0;s<l;++s)h[s]=o[p[s]];for(s=0;s<l;++s)o[s]=h[s]}}function HL(n,t,e,o){var s=To.length,l,p,h,g,m,v,x,E,M,A,I,S,w=!0;for(l=0;l<s;++l)if(p=To[l]){for(h=p.site,m=p.halfedges,g=m.length;g--;)Hi[m[g]]||m.splice(g,1);for(g=0,v=m.length;g<v;)A=uJ(p,Hi[m[g]]),I=A[0],S=A[1],x=g1(p,Hi[m[++g%v]]),E=x[0],M=x[1],(Math.abs(I-E)>Er||Math.abs(S-M)>Er)&&(m.splice(g,0,Hi.push(gf(h,A,Math.abs(I-n)<Er&&o-S>Er?[n,Math.abs(E-n)<Er?M:o]:Math.abs(S-o)<Er&&e-I>Er?[Math.abs(M-o)<Er?E:e,o]:Math.abs(I-e)<Er&&S-t>Er?[e,Math.abs(E-e)<Er?M:t]:Math.abs(S-t)<Er&&I-n>Er?[Math.abs(M-t)<Er?E:n,t]:null))-1),++v);v&&(w=!1)}if(w){var R,C,F,V=1/0;for(l=0,w=null;l<s;++l)(p=To[l])&&(h=p.site,R=h[0]-n,C=h[1]-t,F=R*R+C*C,F<V&&(V=F,w=p));if(w){var X=[n,t],q=[n,o],D=[e,o],xt=[e,t];w.halfedges.push(Hi.push(gf(h=w.site,X,q))-1,Hi.push(gf(h,q,D))-1,Hi.push(gf(h,D,xt))-1,Hi.push(gf(h,xt,X))-1)}}for(l=0;l<s;++l)(p=To[l])&&(p.halfedges.length||delete To[l])}var VL=[],Ug;function lJ(){pf(this),this.x=this.y=this.arc=this.site=this.cy=null}function Wl(n){var t=n.P,e=n.N;if(!(!t||!e)){var o=t.site,s=n.site,l=e.site;if(o!==l){var p=s[0],h=s[1],g=o[0]-p,m=o[1]-h,v=l[0]-p,x=l[1]-h,E=2*(g*x-m*v);if(!(E>=-WL)){var M=g*g+m*m,A=v*v+x*x,I=(x*M-m*A)/E,S=(g*A-v*M)/E,w=VL.pop()||new lJ;w.arc=n,w.site=s,w.x=I+p,w.y=(w.cy=S+h)+Math.sqrt(I*I+S*S),n.circle=w;for(var R=null,C=mf._;C;)if(w.y<C.y||w.y===C.y&&w.x<=C.x)if(C.L)C=C.L;else{R=C.P;break}else if(C.R)C=C.R;else{R=C;break}mf.insert(R,w),R||(Ug=w)}}}}function Xl(n){var t=n.circle;t&&(t.P||(Ug=t.N),mf.remove(t),VL.push(t),pf(t),n.circle=null)}var YL=[];function cJ(){pf(this),this.edge=this.site=this.circle=null}function XL(n){var t=YL.pop()||new cJ;return t.site=n,t}function m1(n){Xl(n),Yl.remove(n),YL.push(n),pf(n)}function $L(n){var t=n.circle,e=t.x,o=t.cy,s=[e,o],l=n.P,p=n.N,h=[n];m1(n);for(var g=l;g.circle&&Math.abs(e-g.circle.x)<Er&&Math.abs(o-g.circle.cy)<Er;)l=g.P,h.unshift(g),m1(g),g=l;h.unshift(g),Xl(g);for(var m=p;m.circle&&Math.abs(e-m.circle.x)<Er&&Math.abs(o-m.circle.cy)<Er;)p=m.N,h.push(m),m1(m),m=p;h.push(m),Xl(m);var v=h.length,x;for(x=1;x<v;++x)m=h[x],g=h[x-1],Nh(m.edge,g.site,m.site,s);g=h[0],m=h[v-1],m.edge=df(g.site,m.site,null,s),Wl(g),Wl(m)}function ZL(n){for(var t=n[0],e=n[1],o,s,l,p,h=Yl._;h;)if(l=JL(h,e)-t,l>Er)h=h.L;else if(p=t-fJ(h,e),p>Er){if(!h.R){o=h;break}h=h.R}else{l>-Er?(o=h.P,s=h):p>-Er?(o=h,s=h.N):o=s=h;break}kL(n);var g=XL(n);if(Yl.insert(o,g),!(!o&&!s)){if(o===s){Xl(o),s=XL(o.site),Yl.insert(g,s),g.edge=s.edge=df(o.site,g.site),Wl(o),Wl(s);return}if(!s){g.edge=df(o.site,g.site);return}Xl(o),Xl(s);var m=o.site,v=m[0],x=m[1],E=n[0]-v,M=n[1]-x,A=s.site,I=A[0]-v,S=A[1]-x,w=2*(E*S-M*I),R=E*E+M*M,C=I*I+S*S,F=[(S*R-M*C)/w+v,(E*C-I*R)/w+x];Nh(s.edge,m,A,F),g.edge=df(m,n,null,F),s.edge=df(n,A,null,F),Wl(o),Wl(s)}}function JL(n,t){var e=n.site,o=e[0],s=e[1],l=s-t;if(!l)return o;var p=n.P;if(!p)return-1/0;e=p.site;var h=e[0],g=e[1],m=g-t;if(!m)return h;var v=h-o,x=1/l-1/m,E=v/m;return x?(-E+Math.sqrt(E*E-2*x*(v*v/(-2*m)-g+m/2+s-l/2)))/x+o:(o+h)/2}function fJ(n,t){var e=n.N;if(e)return JL(e,t);var o=n.site;return o[1]===t?o[0]:1/0}var Er=1e-6,WL=1e-12,Yl,To,mf,Hi;function hJ(n,t,e){return(n[0]-e[0])*(t[1]-n[1])-(n[0]-t[0])*(e[1]-n[1])}function pJ(n,t){return t[1]-n[1]||t[0]-n[0]}function Bg(n,t){var e=n.sort(pJ).pop(),o,s,l;for(Hi=[],To=new Array(n.length),Yl=new d1,mf=new d1;;)if(l=Ug,e&&(!l||e[1]<l.y||e[1]===l.y&&e[0]<l.x))(e[0]!==o||e[1]!==s)&&(ZL(e),o=e[0],s=e[1]),e=n.pop();else if(l)$L(l.arc);else break;if(qL(),t){var p=+t[0][0],h=+t[0][1],g=+t[1][0],m=+t[1][1];GL(p,h,g,m),HL(p,h,g,m)}this.edges=Hi,this.cells=To,Yl=mf=Hi=To=null}Bg.prototype={constructor:Bg,polygons:function(){var n=this.edges;return this.cells.map(function(t){var e=t.halfedges.map(function(o){return g1(t,n[o])});return e.data=t.site.data,e})},triangles:function(){var n=[],t=this.edges;return this.cells.forEach(function(e,o){if(h=(l=e.halfedges).length)for(var s=e.site,l,p=-1,h,g,m=t[l[h-1]],v=m.left===s?m.right:m.left;++p<h;)g=v,m=t[l[p]],v=m.left===s?m.right:m.left,g&&v&&o<g.index&&o<v.index&&hJ(s,g,v)<0&&n.push([s.data,g.data,v.data])}),n},links:function(){return this.edges.filter(function(n){return n.right}).map(function(n){return{source:n.left.data,target:n.right.data}})},find:function(n,t,e){for(var o=this,s,l=o._found||0,p=o.cells.length,h;!(h=o.cells[l]);)if(++l>=p)return null;var g=n-h.site[0],m=t-h.site[1],v=g*g+m*m;do h=o.cells[s=l],l=null,h.halfedges.forEach(function(x){var E=o.edges[x],M=E.left;if(!((M===h.site||!M)&&!(M=E.right))){var A=n-M[0],I=t-M[1],S=A*A+I*I;S<v&&(v=S,l=M.index)}});while(l!==null);return o._found=s,e==null||v<=e*e?h.site:null}};var EJ=sn(yf(),1);var R1=sn(tN(),1);function Zo(){return new kg}function kg(){this.reset()}kg.prototype={constructor:kg,reset:function(){this.s=this.t=0},add:function(n){eN(Gg,n,this.t),eN(this,Gg.s,this.s),this.s?this.t+=Gg.t:this.s=Gg.t},valueOf:function(){return this.s}};var Gg=new kg;function eN(n,t,e){var o=n.s=t+e,s=o-t,l=o-s;n.t=t-l+(e-s)}var er=1e-6;var gr=Math.PI,Mi=gr/2,qg=gr/4,Da=gr*2,$l=180/gr,Jo=gr/180,Zr=Math.abs,aa=Math.atan,Ko=Math.atan2,Xn=Math.cos;var Hg=Math.exp;var Oh=Math.log;var an=Math.sin;var no=Math.sqrt,Dh=Math.tan;function _1(n){return n>1?0:n<-1?gr:Math.acos(n)}function Co(n){return n>1?Mi:n<-1?-Mi:Math.asin(n)}function ua(){}var wJ=Zo(),rpt=Zo();function Zl(n){var t=n[0],e=n[1],o=Xn(e);return[o*Xn(t),o*an(t),an(e)]}function Fh(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Uh(n){var t=no(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}var ppt=Zo();function rN(n,t){return[n>gr?n-Da:n<-gr?n+Da:n,t]}rN.invert=rN;function x1(){var n=[],t;return{point:function(e,o){t.push([e,o])},lineStart:function(){n.push(t=[])},lineEnd:ua,rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function E1(n,t){return Zr(n[0]-t[0])<er&&Zr(n[1]-t[1])<er}function Vg(n,t,e,o){this.x=n,this.z=t,this.o=e,this.e=o,this.v=!1,this.n=this.p=null}function w1(n,t,e,o,s){var l=[],p=[],h,g;if(n.forEach(function(A){if(!((I=A.length-1)<=0)){var I,S=A[0],w=A[I],R;if(E1(S,w)){for(s.lineStart(),h=0;h<I;++h)s.point((S=A[h])[0],S[1]);s.lineEnd();return}l.push(R=new Vg(S,A,null,!0)),p.push(R.o=new Vg(S,null,R,!1)),l.push(R=new Vg(w,A,null,!1)),p.push(R.o=new Vg(w,null,R,!0))}}),!!l.length){for(p.sort(t),iN(l),iN(p),h=0,g=p.length;h<g;++h)p[h].e=e=!e;for(var m=l[0],v,x;;){for(var E=m,M=!0;E.v;)if((E=E.n)===m)return;v=E.z,s.lineStart();do{if(E.v=E.o.v=!0,E.e){if(M)for(h=0,g=v.length;h<g;++h)s.point((x=v[h])[0],x[1]);else o(E.x,E.n.x,1,s);E=E.n}else{if(M)for(v=E.p.z,h=v.length-1;h>=0;--h)s.point((x=v[h])[0],x[1]);else o(E.x,E.p.x,-1,s);E=E.p}E=E.o,v=E.z,M=!M}while(!E.v);s.lineEnd()}}}function iN(n){if(t=n.length){for(var t,e=0,o=n[0],s;++e<t;)o.n=s=n[e],s.p=o,o=s;o.n=s=n[0],s.p=o}}function sl(n,t){return n<t?-1:n>t?1:n>=t?0:NaN}function S1(n){return n.length===1&&(n=bJ(n)),{left:function(t,e,o,s){for(o==null&&(o=0),s==null&&(s=t.length);o<s;){var l=o+s>>>1;n(t[l],e)<0?o=l+1:s=l}return o},right:function(t,e,o,s){for(o==null&&(o=0),s==null&&(s=t.length);o<s;){var l=o+s>>>1;n(t[l],e)>0?s=l:o=l+1}return o}}}function bJ(n){return function(t,e){return sl(n(t),e)}}var oN=S1(sl),AJ=oN.right,TJ=oN.left;var sN=Array.prototype,PJ=sN.slice,IJ=sN.map;var odt=Math.sqrt(50),sdt=Math.sqrt(10),adt=Math.sqrt(2);function Xg(n){for(var t=n.length,e,o=-1,s=0,l,p;++o<t;)s+=n[o].length;for(l=new Array(s);--t>=0;)for(p=n[t],e=p.length;--e>=0;)l[--s]=p[e];return l}var BJ=1e9,Vgt=-BJ;var M1=Zo();function b1(n,t){var e=t[0],o=t[1],s=[an(e),-Xn(e),0],l=0,p=0;M1.reset();for(var h=0,g=n.length;h<g;++h)if(v=(m=n[h]).length)for(var m,v,x=m[v-1],E=x[0],M=x[1]/2+qg,A=an(M),I=Xn(M),S=0;S<v;++S,E=R,A=F,I=V,x=w){var w=m[S],R=w[0],C=w[1]/2+qg,F=an(C),V=Xn(C),X=R-E,q=X>=0?1:-1,D=q*X,xt=D>gr,B=A*F;if(M1.add(Ko(B*q*an(D),I*V+B*Xn(D))),l+=xt?X+q*Da:X,xt^E>=e^R>=e){var j=Fh(Zl(x),Zl(w));Uh(j);var J=Fh(s,j);Uh(J);var Dt=(xt^X>=0?-1:1)*Co(J[2]);(o>Dt||o===Dt&&(j[0]||j[1]))&&(p+=xt^X>=0?1:-1)}}return(l<-er||l<er&&M1<-er)^p&1}var tmt=Zo();var _mt=Zo(),xmt=Zo();var kJ=1/0;var Smt=-kJ;function A1(n){this._context=n}A1.prototype={_radius:4.5,pointRadius:function(n){return this._radius=n,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(n,t){switch(this._point){case 0:{this._context.moveTo(n,t),this._point=1;break}case 1:{this._context.lineTo(n,t);break}default:{this._context.moveTo(n+this._radius,t),this._context.arc(n,t,this._radius,0,Da);break}}},result:ua};var Nmt=Zo();function T1(){this._string=[]}T1.prototype={_radius:4.5,_circle:lN(4.5),pointRadius:function(n){return(n=+n)!==this._radius&&(this._radius=n,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(n,t){switch(this._point){case 0:{this._string.push("M",n,",",t),this._point=1;break}case 1:{this._string.push("L",n,",",t);break}default:{this._circle==null&&(this._circle=lN(this._radius)),this._string.push("M",n,",",t,this._circle);break}}},result:function(){if(this._string.length){var n=this._string.join("");return this._string=[],n}else return null}};function lN(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function C1(n,t,e,o){return function(s,l){var p=t(l),h=s.invert(o[0],o[1]),g=x1(),m=t(g),v=!1,x,E,M,A={point:I,lineStart:w,lineEnd:R,polygonStart:function(){A.point=C,A.lineStart=F,A.lineEnd=V,E=[],x=[]},polygonEnd:function(){A.point=I,A.lineStart=w,A.lineEnd=R,E=Xg(E);var X=b1(x,h);E.length?(v||(l.polygonStart(),v=!0),w1(E,VJ,X,e,l)):X&&(v||(l.polygonStart(),v=!0),l.lineStart(),e(null,null,1,l),l.lineEnd()),v&&(l.polygonEnd(),v=!1),E=x=null},sphere:function(){l.polygonStart(),l.lineStart(),e(null,null,1,l),l.lineEnd(),l.polygonEnd()}};function I(X,q){var D=s(X,q);n(X=D[0],q=D[1])&&l.point(X,q)}function S(X,q){var D=s(X,q);p.point(D[0],D[1])}function w(){A.point=S,p.lineStart()}function R(){A.point=I,p.lineEnd()}function C(X,q){M.push([X,q]);var D=s(X,q);m.point(D[0],D[1])}function F(){m.lineStart(),M=[]}function V(){C(M[0][0],M[0][1]),m.lineEnd();var X=m.clean(),q=g.result(),D,xt=q.length,B,j,J;if(M.pop(),x.push(M),M=null,!!xt){if(X&1){if(j=q[0],(B=j.length-1)>0){for(v||(l.polygonStart(),v=!0),l.lineStart(),D=0;D<B;++D)l.point((J=j[D])[0],J[1]);l.lineEnd()}return}xt>1&&X&2&&q.push(q.pop().concat(q.shift())),E.push(q.filter(HJ))}}return A}}function HJ(n){return n.length>1}function VJ(n,t){return((n=n.x)[0]<0?n[1]-Mi-er:Mi-n[1])-((t=t.x)[0]<0?t[1]-Mi-er:Mi-t[1])}var WJ=C1(function(){return!0},XJ,$J,[-gr,-Mi]);function XJ(n){var t=NaN,e=NaN,o=NaN,s;return{lineStart:function(){n.lineStart(),s=1},point:function(l,p){var h=l>0?gr:-gr,g=Zr(l-t);Zr(g-gr)<er?(n.point(t,e=(e+p)/2>0?Mi:-Mi),n.point(o,e),n.lineEnd(),n.lineStart(),n.point(h,e),n.point(l,e),s=0):o!==h&&g>=gr&&(Zr(t-o)<er&&(t-=o*er),Zr(l-h)<er&&(l-=h*er),e=YJ(t,e,l,p),n.point(o,e),n.lineEnd(),n.lineStart(),n.point(h,e),s=0),n.point(t=l,e=p),o=h},lineEnd:function(){n.lineEnd(),t=e=NaN},clean:function(){return 2-s}}}function YJ(n,t,e,o){var s,l,p=an(n-e);return Zr(p)>er?aa((an(t)*(l=Xn(o))*an(e)-an(o)*(s=Xn(t))*an(n))/(s*l*p)):(t+o)/2}function $J(n,t,e,o){var s;if(n==null)s=e*Mi,o.point(-gr,s),o.point(0,s),o.point(gr,s),o.point(gr,0),o.point(gr,-s),o.point(0,-s),o.point(-gr,-s),o.point(-gr,0),o.point(-gr,s);else if(Zr(n[0]-t[0])>er){var l=n[0]<t[0]?gr:-gr;s=e*l/2,o.point(-l,s),o.point(0,s),o.point(l,s)}else o.point(t[0],t[1])}function Yg(n){return function(t){var e=new P1;for(var o in n)e[o]=n[o];return e.stream=t,e}}function P1(){}P1.prototype={constructor:P1,point:function(n,t){this.stream.point(n,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 x0t=Xn(30*Jo);var O0t=Yg({point:function(n,t){this.stream.point(n*Jo,t*Jo)}});function $g(n){return function(t,e){var o=Xn(t),s=Xn(e),l=n(o*s);return[l*s*an(t),l*an(e)]}}function Fa(n){return function(t,e){var o=no(t*t+e*e),s=n(o),l=an(s),p=Xn(s);return[Ko(t*l,o*p),Co(o&&e*l/o)]}}var mN=$g(function(n){return no(2/(1+n))});mN.invert=Fa(function(n){return 2*Co(n/2)});var yN=$g(function(n){return(n=_1(n))&&n/an(n)});yN.invert=Fa(function(n){return n});function I1(n,t){return[n,Oh(Dh((Mi+t)/2))]}I1.invert=function(n,t){return[n,2*aa(Hg(t))-Mi]};function Zg(n,t){return[n,t]}Zg.invert=Zg;function vN(n,t){var e=Xn(t),o=Xn(n)*e;return[e*an(n)/o,an(t)/o]}vN.invert=Fa(aa);function _N(n,t){var e=t*t,o=e*e;return[n*(.8707-.131979*e+o*(-.013791+o*(.003971*e-.001529*o))),t*(1.007226+e*(.015085+o*(-.044475+.028874*e-.005916*o)))]}_N.invert=function(n,t){var e=t,o=25,s;do{var l=e*e,p=l*l;e-=s=(e*(1.007226+l*(.015085+p*(-.044475+.028874*l-.005916*p)))-t)/(1.007226+l*(.015085*3+p*(-.044475*7+.028874*9*l-.005916*11*p)))}while(Zr(s)>er&&--o>0);return[n/(.8707+(l=e*e)*(-.131979+l*(-.013791+l*l*l*(.003971-.001529*l)))),e]};function xN(n,t){return[Xn(t)*an(n),an(t)]}xN.invert=Fa(Co);function EN(n,t){var e=Xn(t),o=1+Xn(n)*e;return[e*an(n)/o,an(t)/o]}EN.invert=Fa(function(n){return 2*aa(n)});function wN(n,t){return[Oh(Dh((Mi+t)/2)),-n]}wN.invert=function(n,t){return[-t,2*aa(Hg(n))-Mi]};var tK=sn(yf(),1);var eK=sn(yf(),1);var rK=sn(yf(),1);var iK=sn(yf(),1);function _f(n,t){return Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2)}function MN(n){let t=0;for(let e=0;e<n.length-1;e++)t+=_f(n[e],n[e+1]);return t}var jo=sn(bN(),1);var Nn="___",Jg=class{isFacilityByType(t){return["facility","escalator","straightLadder","staircase","ramp","connectionPoint"].includes(t)}initFacilities(t){this.facilities=t.map(e=>{let o=[];try{o=JSON.parse(e.entry_end_floor)}catch(l){o=[]}let s=[];try{s=JSON.parse(e.entry_start_floor)}catch(l){s=[]}return Lu({},e,{entry_start_floor:s,entry_end_floor:o})})}getParkingSpaceInfo(t,e){let o=""+t+Nn+e;var s;return(s=this.parkingMap.get(o))!=null?s:null}getNodeInfo(t,e){let o=""+t+Nn+e,s=this.nodeMap.get(o);if(!(s!=null&&s.length))return null;let l=this.pointMap.get(s[0]);return l!=null?l:null}initRoute(t,e){this.clear(),this.roadInfo=t,this.initFacilities(e);let o=new Date,s=o.getHours()*60+o.getMinutes();t.length&&(t.forEach(l=>{let p=(l.points||[]).filter(h=>!(0,jo.isNil)(h.passWeight)&&h.passWeight!==1&&!(0,jo.isNil)(h.coverageArea)&&h.coverageArea!==0);(l.points||[]).filter(h=>h.openStatus!==!1).filter(h=>{if(!h.startTime||!h.endTime)return!0;let[g,m]=h.startTime.split(":").map(A=>+A),[v,x]=h.endTime.split(":").map(A=>+A),E=g*60+m,M=v*60+x;return s>=E&&s<=M}).forEach(h=>{h.floor=l.floor;let g=""+l.floor+Nn+h.id,m=""+l.floor+Nn+h.nodeId,v=this.nodeMap.get(m)||[];if(v.push(""+l.floor+Nn+(h.relatedId||h.id)),this.nodeMap.set(""+l.floor+Nn+h.nodeId,v),this.pointMap.set(g,h),this.isFacilityByType(h.type)){let x=this.facilities.find(E=>E.id===+h.targetId);if(x){switch(x.entry_infra_type){case"straightLadder":if(x.entry_end_floor.find(I=>I.floor===l.floor)&&x.entry_start_floor.find(I=>I.floor===l.floor)){let I=this.straightLadderMap.get(h.targetId)||[];I.push(Lu({},h)),this.straightLadderMap.set(h.targetId,I)}break;case"staircase":if(x.entry_end_floor.find(I=>I.floor===l.floor)&&x.entry_start_floor.find(I=>I.floor===l.floor)){let I=this.staircaseMap.get(h.targetId)||[];I.push(Lu({},h)),this.staircaseMap.set(h.targetId,I)}break;case"escalator":let M=this.escalatorMap.get(h.targetId)||[];if(x.entry_start_floor.find(I=>I.floor===l.floor)){let I=M.find(S=>{var w;return((w=S.end)==null?void 0:w.floor)!==l.floor&&!S.start});I?I.start=h:M.push({start:h})}if(x.entry_end_floor.find(I=>I.floor===l.floor)){let I=M.find(S=>{var w;return((w=S.start)==null?void 0:w.floor)!==l.floor&&!S.end});I?I.end=h:M.push({end:h})}this.escalatorMap.set(h.targetId,M);break;case"ramp":let A=this.rampMap.get(h.targetId)||[];if(x.entry_start_floor.find(I=>I.floor===l.floor)){let I=A.find(S=>{var w;return((w=S.end)==null?void 0:w.floor)!==l.floor&&!S.start});I?I.start=h:A.push({start:h})}if(x.entry_end_floor.find(I=>I.floor===l.floor)){let I=A.find(S=>{var w;return((w=S.start)==null?void 0:w.floor)!==l.floor&&!S.end});I?I.end=h:A.push({end:h})}this.rampMap.set(h.targetId,A);break;case"connectionPoint":if(x.entry_end_floor.find(I=>I.floor===l.floor)&&x.entry_start_floor.find(I=>I.floor===l.floor)){let I=this.connectionPointMap.get(h.targetId)||[];I.push(Lu({},h)),this.connectionPointMap.set(h.targetId,I)}break}let E=this.facilityMap.get(h.targetId)||[];E.push(Lu({},h)),this.facilityMap.set(h.targetId,E)}}h.type==="parkingSpace"&&h.name.split(/[,\uFF0C]/).forEach(E=>{this.parkingMap.set(""+l.floor+Nn+E,h)})}),(l.lines||[]).filter(h=>h.to!==h.from).forEach(h=>{let g=""+l.floor+Nn+h.from,m=""+l.floor+Nn+h.to,v=this.pointMap.get(g),x=this.pointMap.get(m);if(!v||!x)return;let E=v.cds,M=x.cds,A=_f(E,M);if(p.forEach(I=>{(I.id===h.from||I.id===h.to)&&(A=A/I.passWeight);let S=_f(E,I.cds)<=I.coverageArea,w=_f(M,I.cds)<=I.coverageArea;(S||w)&&(A=A/I.passWeight)}),!v.permission&&!x.permission){switch(this.addLineItem(g,m,A),this.addLineItem(m,g,A),h.direction){case"double":this.addLineItem(g,m,A,this.forwardLineMap),this.addLineItem(m,g,A,this.forwardLineMap);break;case"single":this.addLineItem(g,m,A,this.forwardLineMap);break;case"back":this.addLineItem(m,g,A,this.forwardLineMap);break}(v.type==="parkingSpace"||x.type==="parkingSpace")&&h.direction==="noDir"&&(this.addLineItem(g,m,A,this.forwardLineMap),this.addLineItem(m,g,A,this.forwardLineMap))}else v.permission&&(this.setPermissionLine(g,m,v.permission,A,""),this.setPermissionLine(m,g,v.permission,A,"")),x.permission&&x.permission!==v.permission&&(this.setPermissionLine(g,m,x.permission,A,""),this.setPermissionLine(m,g,x.permission,A,""))})}),this.addPermissionFacility(),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}getPermissionMap(t){return this["permission_"+t]||(this["permission_"+t]=new Set),this["permission_"+t]}setPermissionLine(t,e,o,s,l){this.getPermissionMap(o).add({fromKey:t,toKey:e,distance:s,type:l})}addPermissionFacility(){this.straightLadderMap.forEach((t,e)=>{if(t.length<2){this.straightLadderMap.delete(e);return}for(let o=0;o<t.length;o++){let s=""+t[o].floor+Nn+t[o].id,l=this.pointMap.get(s);if(l){for(let p=0;p<t.length;p++)if(o!==p){let h=""+t[p].floor+Nn+t[p].id,g=this.pointMap.get(h);if(!g)continue;l.permission&&this.setPermissionLine(s,h,l.permission,1,"straightLadder"),g.permission&&g.permission!==l.permission&&this.setPermissionLine(s,h,g.permission,1,"straightLadder")}}}}),this.staircaseMap.forEach((t,e)=>{if(t.length<2){this.staircaseMap.delete(e);return}for(let o=0;o<t.length;o++){let s=""+t[o].floor+Nn+t[o].id,l=this.pointMap.get(s);if(l){for(let p=0;p<t.length;p++)if(o!==p){let h=""+t[p].floor+Nn+t[p].id,g=this.pointMap.get(h);if(!g)continue;l.permission&&this.setPermissionLine(s,h,l.permission,1,"staircase"),g.permission&&g.permission!==l.permission&&this.setPermissionLine(s,h,g.permission,1,"staircase")}}}}),this.escalatorMap.forEach((t,e)=>{t.forEach(o=>{if(o.start&&o.end){let s=""+o.start.floor+Nn+o.start.id,l=""+o.end.floor+Nn+o.end.id,p=this.pointMap.get(s),h=this.pointMap.get(l);p&&h&&(p.permission&&this.setPermissionLine(s,l,p.permission,1,"escalator"),h.permission&&h.permission!==p.permission&&this.setPermissionLine(s,l,h.permission,1,"escalator"))}})}),this.rampMap.forEach((t,e)=>{t.forEach(o=>{if(o.start&&o.end){let s=""+o.start.floor+Nn+o.start.id,l=""+o.end.floor+Nn+o.end.id,p=this.pointMap.get(s),h=this.pointMap.get(l);p&&h&&(p.permission&&this.setPermissionLine(s,l,p.permission,10,"ramp"),h.permission&&h.permission!==p.permission&&this.setPermissionLine(s,l,h.permission,10,"ramp"))}})}),this.connectionPointMap.forEach((t,e)=>{if(t.length<2){this.connectionPointMap.delete(e);return}for(let o=0;o<t.length;o++){let s=""+t[o].floor+Nn+t[o].id,l=this.pointMap.get(s);if(l){for(let p=0;p<t.length;p++)if(o!==p){let h=""+t[p].floor+Nn+t[p].id,g=this.pointMap.get(h);if(!g)continue;l.permission&&this.setPermissionLine(s,h,l.permission,1,"connectionPoint"),g.permission&&g.permission!==l.permission&&this.setPermissionLine(s,h,g.permission,1,"connectionPoint")}}}})}addPermissionLineToMap(t,e,o,s){this.getPermissionMap(t).forEach(p=>{e.includes(p.type)&&(p.type===""?this.addLineItem(p.fromKey,p.toKey,p.distance,o):this.addLineItem(p.fromKey,p.toKey,s.get(p.type),o))})}addLineItem(t,e,o,s){s===void 0&&(s=this.lineMap);let l=s.get(t)||new Map;l.set(e,o),s.set(t,l)}addFacilityToLineMap(t,e,o,s){[...this.straightLadderMap,...this.staircaseMap].forEach(l=>{let[p,h]=l;if(!(h.length<2))for(let g=0;g<h.length;g++){let m=""+h[g].floor+Nn+h[g].id,v=this.pointMap.get(m);if(!(!v||v.permission)){for(let x=0;x<h.length;x++)if(g!==x){let E=""+h[x].floor+Nn+h[x].id,M=this.pointMap.get(E);if(!M||M.permission)continue;if(h[g].type==="straightLadder"){let A=e;this.addLineItem(m,E,A,s)}else{let A=o;this.addLineItem(m,E,A,s)}}}}}),this.escalatorMap.forEach((l,p)=>{l.forEach(h=>{if(h.start&&h.end){let g=""+h.start.floor+Nn+h.start.id,m=""+h.end.floor+Nn+h.end.id,v=this.pointMap.get(g),x=this.pointMap.get(m);if(v&&x&&!v.permission&&!x.permission){let E=t;this.addLineItem(g,m,E,s)}}})}),this.connectionPointMap.forEach((l,p)=>{if(!(l.length<2))for(let h=0;h<l.length;h++){let g=""+l[h].floor+Nn+l[h].id,m=this.pointMap.get(g);if(!(!m||m.permission)){for(let v=0;v<l.length;v++)if(h!==v){let x=""+l[v].floor+Nn+l[v].id,E=this.pointMap.get(x);if(!E||E.permission)continue;this.addLineItem(g,x,100,s)}}}})}initBaseRoute(){let t=new Map((0,jo.cloneDeep)([...this.lineMap]));this.addFacilityToLineMap(100,100*this.lift_priority,3e4,t),this.baseRoute=new ro.default(t)}initEscalatorRoute(){let t=new Map((0,jo.cloneDeep)([...this.lineMap])),e=1e4;this.addFacilityToLineMap(100,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new ro.default(t)}initStraightLadderRoute(){let t=new Map((0,jo.cloneDeep)([...this.lineMap])),e=1e4;this.addFacilityToLineMap(3*e,300,3e4*e,t),this.straightLadderRoute=new ro.default(t)}initForwardRoute(){this.rampMap.forEach((t,e)=>{t.forEach(o=>{if(o.start&&o.end){let s=""+o.start.floor+Nn+o.start.id,l=""+o.end.floor+Nn+o.end.id,p=this.pointMap.get(s),h=this.pointMap.get(l);p&&h&&!p.permission&&!h.permission&&this.addLineItem(s,l,10,this.forwardLineMap)}})}),this.connectionPointMap.forEach((t,e)=>{if(!(t.length<2))for(let o=0;o<t.length;o++){let s=""+t[o].floor+Nn+t[o].id,l=this.pointMap.get(s);if(!(!l||l.permission)){for(let p=0;p<t.length;p++)if(o!==p){let h=""+t[p].floor+Nn+t[p].id,g=this.pointMap.get(h);if(!g||g.permission)continue;this.addLineItem(s,h,100,this.forwardLineMap)}}}}),this.forwardRoute=new ro.default(this.forwardLineMap)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility||t.parkingSpace&&t.floor?!0:this.checkStart(t)}transformStart(t,e,o){o===void 0&&(o={});var s;if(t.nodeId){let l=this.nodeMap.get(""+t.floor+Nn+t.nodeId);if(l!=null&&l.length)return l.map(p=>{let[h,g]=p.split(Nn);return{floor:h,id:g}})}if((s=t.coord)!=null&&s.length){let l=this.roadInfo.find(m=>m.floor===t.floor);if(!l)return null;let p=l.points.filter(m=>m.isStarted),h=l.points.filter(m=>{let v=""+m.floor+Nn+m.id;if(e==="forward"){if(!this.forwardLineMap.has(v)||o.adsorptionIntersection&&p.length&&!m.isStarted)return!1}else if(!this.lineMap.has(v))return!1;return!0});if(!h.length)return null;let g=h.reduce((m,v)=>{if(v.relatedId)return m;let x=_f(t.coord,v.cds);return x<m.min&&(m.min=x,m.point=v),m},{min:1/0,point:h[0]});return[{floor:l.floor,id:g.point.id}]}return null}transformEnd(t,e){if(t.floor){if(t.parkingSpace){let s=this.parkingMap.get(""+t.floor+Nn+t.parkingSpace);if(s)return[{floor:t.floor,id:s.id}]}let o=this.transformStart(t,e);if(o)return o}if(t.facility){let s=this.facilities.filter(l=>+l.type_id==+t.facility).map(l=>l.id).map(l=>this.facilityMap.get(""+l)).flat(2);if(s!=null&&s.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,o,s,l,p){if(o===void 0&&(o=""),p===void 0&&(p={}),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let h=this.transformStart(t,o,p);if(!h)return"no-start";let g=this.transformEnd(e,o);if(!g)return"no-end";let m=[];if(Array.isArray(g))for(let E=0;E<h.length;E++){let M=h[E];for(let A=0;A<g.length;A++){let I=g[A];if(M.floor===I.floor&&M.id===I.id)return"near"}}else{m=this.facilities.filter(M=>+M.type_id==+e.facility).map(M=>M.id).map(M=>this.facilityMap.get(""+M)).flat(2).filter(M=>M).filter(M=>g.floor?M.floor===g.floor:!0);for(let M=0;M<h.length;M++){let A=h[M];for(let I=0;I<m.length;I++){let S=m[I];if(A.floor===S.floor&&A.id===S.id)return"near"}}}let v;switch(o){case"escalator":v=this.getEscalatorPath.bind(this);break;case"straightLadder":v=this.getStraightLadderPath.bind(this);break;case"forward":v=this.getForwardPath.bind(this);break;default:v=this.getBasePath.bind(this);break}let x=null;return h.forEach(E=>{if(Array.isArray(g))g.forEach(M=>{let A=v(E,M,s,l);A&&A&&(!x||A[0].consume<x[0].consume)&&(x=A)});else{if(!m.length)return null;let M=m.map(A=>v(E,{floor:A.floor,id:A.id},s,l)).filter(A=>!!A);x=M.reduce((A,I)=>{let S=I[0].consume;return S<A.distance&&(A.distance=S,A.path=I),A},{distance:1/0,path:M[0]}).path}}),x}getRoutePath(t,e,o){let s=""+t.floor+Nn+t.id,l=this.pointMap.get(s),p=""+e.floor+Nn+e.id,h=this.pointMap.get(p);if(!l||!h)return null;let g=""+l.floor+Nn+(l.relatedId||l.id),m=""+h.floor+Nn+(h.relatedId||h.id),v=o.path(g,m);if(!v)return null;let x=[],E=v.reduce((M,A,I,S)=>{if(I===0)return 0;let w=S[I-1],R=o.graph.get(w).get(A);return M+R},0);return v.map(M=>{let A=this.pointMap.get(M);if(A){var I;let{floor:S}=A,w=A.type;if(this.isFacilityByType(A.type)){let R=this.facilities.find(C=>C.id===+A.targetId);R&&(w=R.entry_infra_type)}if(((I=x[x.length-1])==null?void 0:I.floor)===S){let R=x[x.length-1];R.points.push(A.cds),R.pointInfos.push(A),R.endType=w,R.destId=A.nodeId,R.distance=MN(R.points)}else x.push({floor:S,points:[A.cds],pointInfos:[A],endType:w,destId:A.nodeId,distance:0,consume:E})}}),x}getBasePath(t,e,o){if(!o)return this.getRoutePath(t,e,this.baseRoute);let s=(0,jo.cloneDeep)(this.baseRoute.graph),l=h=>{this.addPermissionLineToMap(h,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",100],["connectionPoint",100],["straightLadder",100*this.lift_priority],["staircase",3e4]]))};Array.isArray(o)?o.forEach(h=>{l(h)}):l(o);let p=new ro.default(s);return this.getRoutePath(t,e,p)}getEscalatorPath(t,e,o){if(!o)return this.getRoutePath(t,e,this.escalatorRoute);let s=(0,jo.cloneDeep)(this.escalatorRoute.graph),l=1e4,p=g=>{this.addPermissionLineToMap(g,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",100],["connectionPoint",100],["straightLadder",this.lift_priority*l],["staircase",3e4*l]]))};Array.isArray(o)?o.forEach(g=>{p(g)}):p(o);let h=new ro.default(s);return this.getRoutePath(t,e,h)}getStraightLadderPath(t,e,o){if(!o)return this.getRoutePath(t,e,this.straightLadderRoute);let s=(0,jo.cloneDeep)(this.straightLadderRoute.graph),l=1e4,p=g=>{this.addPermissionLineToMap(g,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",3*l],["connectionPoint",100],["straightLadder",300],["staircase",3e4*l]]))};Array.isArray(o)?o.forEach(g=>{p(g)}):p(o);let h=new ro.default(s);return this.getRoutePath(t,e,h)}getForwardPath(t,e,o,s){let l=new Map,p=M=>{let A=this.forwardRoute.graph.get(g);M.forEach(I=>{let S=A.get(I);(0,jo.isNil)(S)||(l.set(I,S),A.delete(I))})},h=()=>{let M=this.forwardRoute.graph.get(g);l.forEach((A,I)=>{M.set(I,A)})},g=""+t.floor+Nn+t.id;if(!(0,jo.isNil)(s)){let M=this.forwardLineMap.get(g),A=this.pointMap.get(g);if(A&&(M!=null&&M.size)&&M.size>1){let I=new Ye(A.cds[0],A.cds[1]),S=new Map;M.forEach((R,C)=>{let F=this.pointMap.get(C);if(F){let V=new Ye(F.cds[0],F.cds[1]),q=360-(new Ye().subVectors(V,I).angle()/Math.PI*180-90+360)%360;S.set(C,q)}});let w=Array.from(S).filter(R=>{let[C,F]=R;return Math.abs(F-s)<=60}).map(R=>{let[C]=R;return C});if(w.length)w.forEach(R=>S.delete(R)),p([...S.keys()]);else{let R=Array.from(S).reduce((C,F)=>{let V=Math.abs(F[1]-s);return V<C.diff?{diff:V,key:F[0]}:C},{diff:1/0,key:""});S.delete(R.key),p([...S.keys()])}}}if(!o){let M=this.getRoutePath(t,e,this.forwardRoute);return h(),M||this.getRoutePath(t,e,this.forwardRoute)}let m=(0,jo.cloneDeep)(this.forwardRoute.graph),v=M=>{this.addPermissionLineToMap(M,["","ramp"],m,new Map([["ramp",10]]))};Array.isArray(o)?o.forEach(M=>{v(M)}):v(o);let x=new ro.default(m),E=this.getRoutePath(t,e,x);if(h(),E)return E;{let M=(0,jo.cloneDeep)(this.forwardRoute.graph);Array.isArray(o)?o.forEach(S=>{v(S)}):v(o);let A=new ro.default(M);return this.getRoutePath(t,e,A)}}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 ro.default,this.escalatorRoute=new ro.default,this.straightLadderRoute=new ro.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.facilities=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.rampMap=new Map,this.staircaseMap=new Map,this.connectionPointMap=new Map,this.parkingMap=new Map,this.lineMap=new Map,this.baseRoute=new ro.default,this.escalatorRoute=new ro.default,this.straightLadderRoute=new ro.default,this.forwardLineMap=new Map,this.forwardRoute=new ro.default}};var uwt=sn(jN(),1),lwt=sn(Yp(),1);function QN(n){return n.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function t2(n){let t={};for(let o in n)o.startsWith("on")&&(t[QN(o.slice(2))]=n[o]);let e=o=>ac(this,null,function*(){let{data:s}=o;if(t[s.type])try{let l=yield t[s.type](s.data);if(l!=null&&l.$transfer&&Array.isArray(l.$transfer)){let p=l.$transfer;delete l.$transfer,self.postMessage({type:""+s.type+"_result",key:s.key,data:l},p)}else self.postMessage({type:""+s.type+"_result",key:s.key,data:l})}catch(l){self.postMessage({type:""+s.type+"_result",key:s.key,error:l})}else self.postMessage({type:""+s.type+"_result",key:s.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}var la=new Jg,r2,QK=new Promise(n=>{r2=n});function i2(n,t,e){let{floor:o,coord:s}=n,l=null;return(t||[]).forEach(p=>{let h=la.getPath({floor:o,coord:s},{floor:p.floor,parkingSpace:p.lot_id},"forward",0,e);if(h==="near"){l={floor:p.floor,spaceNo:p.lot_id,distance:0};return}if(!h||typeof h=="string")return;let g={floor:p.floor,spaceNo:p.lot_id,distance:h[0].consume};l||(l=g),l.distance>g.distance&&(l=g)}),l}function e2(n,t,e,o,s){let l=i2({floor:n,coord:t},e[n],s);return l||tj(n,t,e,o,s)}function tj(n,t,e,o,s){let l=o.indexOf(n);l===-1&&(l=o.length);let p=1,h=null;for(;p<=o.length;){if(o.filter((m,v)=>v===l-1||v===l+1).forEach(m=>{let v=i2({floor:n,coord:t},e[m],s);h?v&&h.distance>v.distance&&(h=v):h=v}),h)return h;p++}return h}function n2(n,t,e,o,s){let l=z1(n,t,t.floor,e,s);if(l)return l;let p=z1(n,t,n.floor,e,s);return p||ej(n,t,n.floor,e,o,s)}function z1(n,t,e,o,s){let l=o[e]||[];if(!l.length)return null;let p=null;return l.forEach(h=>{let g={floor:h.floor,parkingSpace:h.lot_id},m=la.getPath(n,g,"forward",0,s);if(!m||typeof m=="string"&&m!=="near")return;let v=la.getParkingSpaceInfo(h.floor,h.lot_id);if(!v)return;let x=la.getPath({floor:h.floor,coord:v.cds},t,"",0);if(x==="near"){p={floor:h.floor,spaceNo:h.lot_id,distance:0};return}if(!x||typeof x=="string")return;let E={floor:h.floor,spaceNo:h.lot_id,distance:x[0].consume};p?p.distance>E.distance&&(p=E):p=E}),p}function ej(n,t,e,o,s,l){let p=s.indexOf(e);p===-1&&(p=s.length);let h=1,g=null;for(;h<=s.length;){if(s.filter((v,x)=>x===p-1||x===p+1).forEach(v=>{let x=z1(n,t,v,o,l);g?x&&g.distance>x.distance&&(g=x):g=x}),g)return g;h++}return g}function nj(n){if(n.coord)return{floor:n.floor,coord:n.coord};if(n.nodeId){let t=la.getNodeInfo(n.floor,n.nodeId);if(t)return{floor:t.floor,coord:t.cds}}return null}function rj(n){if(n.coord)return{floor:n.floor,coord:n.coord};if(n.nodeId){let t=la.getNodeInfo(n.floor,n.nodeId);if(t)return{floor:t.floor,coord:t.cds}}if(n.parkingSpace){let t=la.getParkingSpaceInfo(n.floor,n.parkingSpace);if(t)return{floor:t.floor,coord:t.cds}}return null}t2({onSetRoadInfo(n){let{roadData:t,facilities:e}=n;la.initRoute(t,e),r2(!0)},onRecommend(n){return ac(this,null,function*(){let{start:t,end:e,travelDirection:o,carLotStatus:s,parkingType:l}=n;yield QK;let p=s.reduce((v,x)=>(v[x.floor]?v[x.floor].push(x):v[x.floor]=[x],v),{}),h=la.roadInfo.map(v=>v.floor),g=nj(t);if(!g)return null;let m=e?rj(e):null;if(l){let v=s.filter(x=>{let E=la.getParkingSpaceInfo(x.floor,x.lot_id);return E?E.parkingType===l:!1});if(v){let x=v.reduce((E,M)=>(E[M.floor]?E[M.floor].push(M):E[M.floor]=[M],E),{});if(m){let E=n2(g,m,x,h,o);if(E)return E}else{let E=e2(g.floor,g.coord,x,h,o);if(E)return E}}}return m?n2(g,m,p,h,o):e2(g.floor,g.coord,p,h,o)})},onClear(){la.clear()}});
27666
- `],{type:"text/javascript"}),t=URL.createObjectURL(r),e=new Worker(t);return URL.revokeObjectURL(t),e}var SMt={placeId:0,catLotStatusApi:"https://vrapi.aibee.cn/parking/cat-lot-status"},nP=class{setRoadData(t,e){return fi(this.worker,"set_road_info",{roadData:t,facilities:e})}recommend(t){return Tt(this,null,function*(){let e=yield fetch(this.options.catLotStatusApi,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({place_id:+this.options.placeId})}).then(n=>n.json()).then(n=>n.data.filter(i=>i.status===0));return fi(this.worker,"recommend",te({},t,{carLotStatus:e}))})}dispose(){this.worker.terminate()}constructor(t={}){this.worker=eP(),this.options=te({},SMt,t)}};var lle=H(sf(),1),cle=H(ze(),1),hle=H(Kf(),1),fle=H(En(),1),ple=H(vR(),1),dle=H(yR(),1),gle=H(ER(),1),mle=H(bR(),1),vle=H(Xa(),1);var ile=H(sf(),1);var bMt={url:"",reconnect:!0,heartBeat:2e3,heartMsg:"PING",reconnectTime:3e3,reconnectMaxCount:1e6,noMessageTime:6e3},Eg=class extends Zi{initWebsocket(){this.ws=new WebSocket(this.options.url),this.ws.onopen=()=>{this.alive=!0,this.startHeart(),this.startOnMessageTimer(),this.stopReconnect(),this.dispatchEvent({type:"open"})},this.ws.onerror=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect(),this.registryEvent()},this.ws.onclose=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect()},this.ws.onmessage=t=>{this.startOnMessageTimer(),this.dispatchEvent({type:"message",message:t})}}startHeart(){this.stopHeart(),this.heartTimer=this.timer.setInterval(()=>{this.send(this.options.heartMsg)&&this.dispatchEvent({type:"send-heart"})},this.options.heartBeat)}stopHeart(){this.heartTimer&&(this.timer.clearInterval(this.heartTimer),this.heartTimer=null)}startReconnect(t){t===void 0&&(t=this.options.reconnectTime),this.stopReconnect(),this.options.reconnect&&(this.options.reconnectMaxCount--,this.options.reconnectMaxCount>=0&&(this.reconnectTimer=this.timer.setTimeout(()=>{this.initWebsocket()},t)))}stopReconnect(){this.reconnectTimer&&(this.timer.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}startOnMessageTimer(){this.stopOnMessageTimer(),this.noMessageTimer=this.timer.setTimeout(()=>{var t;(t=this.ws)==null||t.close(),this.dispatchEvent({type:"no-message-timeout"})},this.options.noMessageTime)}stopOnMessageTimer(){this.noMessageTimer&&(this.timer.clearTimeout(this.noMessageTimer),this.noMessageTimer=null)}send(t){var e;let n=typeof t=="string"?t:JSON.stringify(t);return this.alive&&((e=this.ws)==null?void 0:e.readyState)===1?(this.ws.send(t),this.dispatchEvent({type:"send-success",msg:n}),!0):(this.dispatchEvent({type:"send-fail",msg:n}),!1)}registryEvent(){window.addEventListener("online",this.onOnline)}unRegistryEvent(){window.removeEventListener("online",this.onOnline)}close(){var t;this.unRegistryEvent(),this.options.reconnect=!1,this.alive=!1,this.stopHeart(),this.stopReconnect(),this.stopOnMessageTimer(),(t=this.ws)==null||t.close(),this.ws=null,this.dispatchEvent({type:"close"})}dispose(){this.close(),this.timer.dispose(),super.dispose()}constructor(t){super(),this.ws=null,this.alive=!1,this.timer=new ui,this.heartTimer=null,this.reconnectTimer=null,this.noMessageTimer=null,this.onOnline=()=>{this.startReconnect()},this.options=te({},bMt,t||{}),this.options.url&&this.initWebsocket()}};var iP=H(qs(),1);var rP=r=>{let t=r.toString(2),e=""+Array(16-t.length+1).join("0")+t,n=parseInt(e.slice(0,4),2)*10,i=parseInt(e.slice(4,16),2);return[n,i]};var oP=class extends Zi{initPositionWebSocket(){let t=te({},this.options.ext_position_params,{place_id:this.options.place_id,token:this.options.access_token}),e=Object.keys(t).filter(n=>!(0,iP.isNil)(t[n])).map(n=>n+"="+t[n]).join("&");this.positionWebSocket=new Eg({url:this.options.wss_position_url+"?"+e}),this.positionWebSocket.addEventListener("message",n=>{let{message:i}=n,o=(()=>{try{return JSON.parse(i.data)}catch(L){return i.data}})();if(o.command==="POSITION_RESULT"&&o.data.success)if(["POSITION","FLOOR","PARK_POSITION"].includes(o.data.success_type)&&this.useGpsFloorTimer&&(this.positionFloor=o.data.floor,this.timer.clearTimeout(this.useGpsFloorTimer),this.useGpsFloorTimer=null),o.data.success_type==="POSITION"){let{x:L,y:tt,time:O,floor:V,ts:W}=o.data,St=this.positionFloor!==V;if(this.positionFloor=V,this.dispatchEvent({type:"ws-position",floor:V,x:L,y:tt,time:O}),console.log("positionFloor",V,St),this.options.upload_position){var a;(a=this.positionWebSocket)==null||a.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:L,y:tt,floor:V,type:"originBeacon"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:V,x:L,y:tt,time:new Date(W).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var l;if(St){var c,f,g;(g=this.pdrPosition)==null||(f=g.pdr)==null||(c=f.particleFilter)==null||c.setPosInitFlag(!1)}(l=this.pdrPosition)==null||l.setBeaconPosition({x:L,y:tt},new Date(W).getTime()-o.lag-o.duration)}else if(St){var m;if(this.resetPdr(),(m=this.carInertialPosition)==null||m.stopPositionTimer(),this.path){let j=this.path.findIndex(mt=>mt.floor===V),pt=this.path[j];if(pt){var v;this.resetPdr(),(v=this.carInertialPosition)==null||v.setBeaconPosition(pt.points[0],new Date(O).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var x;(x=this.carInertialPosition)==null||x.setBeaconPosition([L,tt],new Date(O).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var S;(S=this.carInertialPosition)==null||S.setBeaconPosition([L,tt],new Date(O).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var w;(w=this.carInertialPosition)==null||w.setBeaconPosition([L,tt],new Date(O).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="PARK_POSITION"&&o.data.success){if(this.options.type===1){let{x:L,y:tt,time:O,floor:V}=o.data,W=this.positionFloor!==V;if(this.positionFloor=o.data.floor,this.dispatchEvent({type:"ws-position",floor:V,x:L,y:tt,time:O}),!this.options.use_pdr){this.dispatchEvent({type:"position",floor:V,x:L,y:tt,time:new Date(O).getTime()});return}if(W){var E;if(this.resetPdr(),(E=this.carInertialPosition)==null||E.stopPositionTimer(),this.path){let St=this.path.findIndex(pt=>pt.floor===V),j=this.path[St];if(j){var b;this.resetPdr(),(b=this.carInertialPosition)==null||b.setPosition(j.points[0],new Date(O).getTime(),o.duration)}else{var C;(C=this.carInertialPosition)==null||C.setPosition([L,tt],new Date(O).getTime(),o.duration)}}else{var A;(A=this.carInertialPosition)==null||A.setPosition([L,tt],new Date(O).getTime(),o.duration)}}else{var P,U;if((P=this.carInertialPosition)==null||P.setPosition([L,tt],new Date(O).getTime(),o.duration),!((U=this.carInertialPosition)!=null&&U.positionTimer)){var F;(F=this.carInertialPosition)==null||F.startPositionTimer()}}if(this.options.upload_position){var D;(D=this.positionWebSocket)==null||D.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:L,y:tt,floor:V,type:"vision"}),serverData:JSON.stringify(o)})}}}else this.dispatchEvent({type:"floor",floor:o.data.floor,time:o.data.time})})}initSensorWebSocket(){let t=te({},this.options.ext_sensor_params,{token:this.options.access_token,place_id:this.options.place_id,record_sensor:1}),e=Object.keys(t).filter(n=>!(0,iP.isNil)(t[n])).map(n=>n+"="+t[n]).join("&");this.sensorWebSocket=new Eg({url:this.options.wss_sensor_url+"?"+e})}initPdr(){this.options.type===1?(this.carInertialPosition=new I_,this.carInertialPosition.addEventListener("change-pos",t=>{let{value:e}=t,{pos:n,success:i,speed:o}=e;if(i&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:n[0],y:n[1],time:Date.now(),speed:o}),this.options.upload_position)){var a;(a=this.positionWebSocket)==null||a.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:n[0],y:n[1],floor:this.positionFloor,type:"vision_pdr"})})}}),this.carInertialPosition.addEventListener("change-compass",t=>{let{value:e}=t;this.dispatchEvent({type:"compass",value:e})})):(this.pdrPosition=new C_(this.bmap,{pdr:{using_gps:this.options.use_gps},sensor:{elements:[Gr.COMPASS,Gr.ACCELERATION,Gr.DEVICE_MOTION].concat(this.options.use_gps?[Gr.GPS]:[])}}),this.requestDeviceOrientationPermission(),this.options.upload_position&&this.pdrPosition.sensor.addEventListener("sensor-data",t=>{let{data:e}=t;var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_SENSOR",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify(e)})}),this.pdrPosition.sensor.addEventListener("add-data-item",t=>{t.item.type==="compass"&&this.dispatchEvent({type:"compass",value:t.item.res})}),this.pdrPosition.addEventListener("position",t=>{let{x:e,y:n,_type:i}=t;if(console.log("_type",i,e,n,this.positionFloor,this.gpsFloor),i==="gps"&&!this.useGpsFloorTimer){let a=()=>{this.useGpsFloorTimer=this.timer.setTimeout(()=>{this.gpsFloor?this.positionFloor=this.gpsFloor:a()},5e3)};a()}if(this.positionFloor&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:e,y:n,time:Date.now()}),this.options.upload_position)){var o;(o=this.positionWebSocket)==null||o.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:e,y:n,floor:this.positionFloor,type:i})})}}))}setSensor(t){this.pdrPosition&&this.pdrPosition.setSensor(t)}requestDeviceOrientationPermission(){return Tt(this,null,function*(){if(this.pdrPosition){let t=yield this.pdrPosition.checkSensor();return t.deviceOrientation?this.pdrPosition.start():(this.dispatchEvent(te({type:"check-sensor"},t)),!t.deviceOrientation&&this.options.use_default_permission),t}else return null})}getGpsFloor(){return Tt(this,null,function*(){if(this.options.use_gps&&this.options.get_gps_floor_url){let t=yield fetch(this.options.get_gps_floor_url+"/"+this.options.place_id).then(e=>e.json());t.code===200&&(this.gpsFloor=t.data.gps_floor)}})}pausePdr(){if(this.options.type===1){var t;(t=this.carInertialPosition)==null||t.stopPositionTimer()}else{var e;(e=this.pdrPosition)==null||e.pause()}}continuePdr(){if(this.options.type===1)this.carInertialPosition&&(this.carInertialPosition.positionTimer||this.carInertialPosition.startPositionTimer());else{var t;(t=this.pdrPosition)==null||t.continue()}}setPathAngle(t){if(this.options.type===1){var e;(e=this.carInertialPosition)==null||e.setPathAngle(t)}}getForwardAngle(){if(this.options.type===1){var t,e;return(e=(t=this.carInertialPosition)==null?void 0:t.angle)!=null?e:null}else return null}resetPdr(){this.carInertialPosition&&(this.carInertialPosition.history=[],this.carInertialPosition.setPathAngle(0),this.carInertialPosition.speed=0),this.pdrPosition&&this.pdrPosition.pdr.particleFilter.setPosInitFlag(!1)}setPath(t){this.path=t}sendBeacon(t){var e;let n=[];if(yh)n=t.map(o=>{let[a,l]=rP(o.major);return[o.uuid,l,o.minor,o.rssi,o.accuracy,a]}).filter(o=>o[3]!==0).sort((o,a)=>a[3]-o[3]);else{let o=t.reduce((a,l)=>{var c,f;let[g,m]=rP(l.major),v=""+m+l.minor;return(c=a)[f=v]||(c[f]=[]),a[v].push(te({},l,{battery:g})),a},{});Object.entries(o).forEach(a=>{let[l,c]=a,{uuid:f,major:g,minor:m,accuracy:v,battery:x}=c[0];if(c.length>1){let S=c.filter(E=>E.rssi<0),w=S.reduce((E,b)=>E+b.rssi,0);n.push([f,g,m,w/S.length,v,x])}else n.push([f,g,m,c[0].rssi,v,x])})}let i={command:"POSITION",index:this.uploadIndex++,ts:Date.now(),beacons:JSON.stringify(n),ext_sensors:JSON.stringify({})};(e=this.sensorWebSocket)==null||e.send(i)}dispose(){var t,e,n,i;this.timer.dispose(),(t=this.positionWebSocket)==null||t.dispose(),this.positionWebSocket=null,(e=this.sensorWebSocket)==null||e.dispose(),this.sensorWebSocket=null,(n=this.pdrPosition)==null||n.dispose(),this.pdrPosition=null,(i=this.carInertialPosition)==null||i.dispose(),this.carInertialPosition=null,super.dispose()}constructor(t,e){super(),this.bmap=t,this.positionWebSocket=null,this.sensorWebSocket=null,this.pdrPosition=null,this.carInertialPosition=null,this.gpsFloor="",this.positionFloor="",this.useGpsFloorTimer=null,this.uploadIndex=0,this.path=null,this.timer=new ui;let n=new URLSearchParams(location.search),i=n.get("server_env")||"prod",o={test:"nav-test.aibee.cn",prod:"nav.aibee.cn"},a="wss://"+o[i]+"/aether-walker/indoor/position",l="wss://"+o[i]+"/aether-walker/indoor/sensor";this.options=te({place_id:n.get("place_id"),access_token:n.get("access_token"),env:i,wss_position_url:a,wss_sensor_url:l,get_gps_floor_url:"https://"+o[i]+"/aether-walker/indoor/conf",use_sensor:!1,type:-1,use_gps:!0,use_pdr:!0,upload_position:!0,use_default_permission:!0,ext_position_params:{},ext_sensor_params:{}},e),this.initPositionWebSocket(),this.options.use_sensor&&this.initSensorWebSocket(),this.options.use_pdr&&this.initPdr(),this.options.use_gps&&this.getGpsFloor()}};var Tle=H(ze(),1);var sP=class extends lo{showMyPosition(t,e){var n;let i=(n=this.bmap.context.currentFloor)==null?void 0:n.getGraphicPosition(t);if(i){let o=new lp(this.bmap.context,{autoUpdate:!0,appendToBody:!1});o.div.appendChild(e),o.position.copy(this.bmap.mercatorToWorld(i)),this.myPositionOverlay=o,console.log("graphicPos",i,this)}else console.warn("[showMyPosition] \u6CA1\u6709\u627E\u5230\u56FE\u5143\u6240\u5728\u7684\u4F4D\u7F6E")}hideMyPosition(){this.myPositionOverlay&&(this.myPositionOverlay.dispose(),this.myPositionOverlay=null)}dispose(){this.hideMyPosition()}constructor(...t){super(...t),this.myPositionOverlay=null}};var aP=class extends lo{highlightPoi(t,e){e===void 0&&(e={icon_size:[40,40],collision_enable:!1}),t.map(i=>this.bmap.getPoiById(i)).filter(i=>!!i).forEach(i=>{var o;(o=i.userData).restore||(o.restore={});for(let c in e)if(c in i.options){var a,l;(a=i.userData.restore)[l=c]||(a[l]=i.options[c]),i.options[c]=e[c]}})}restorePoi(t){t.map(n=>this.bmap.getPoiById(n)).filter(n=>!!n).forEach(n=>{console.log("poi.userData.restore",n.userData.restore);for(let i in n.userData.restore)i in n.options&&(n.options[i]=n.userData.restore[i]);n.userData.restore={}})}};var Lle=H(ze(),1),Nle=H(Kf(),1);var uP=class extends lo{sortByDistance(t,e,n){return Tt(this,null,function*(){n===void 0&&(n=!1);let i=[...e];if(n||e.length<20)return yield Promise.all(i.map(o=>Tt(this,null,function*(){o.distance=yield this._getDistance(t,{floor:o.floor,x:o.center_x,y:o.center_y})}))),i.sort((o,a)=>o.distance-a.distance);{let o=i.sort((l,c)=>{let f=Math.sqrt((l.center_x-t.x)**2+(l.center_y-t.y)**2)+(t.floor===l.floor?0:100),g=Math.sqrt((c.center_x-t.x)**2+(c.center_y-t.y)**2)+(t.floor===c.floor?0:100);return f-g});return[...(yield Promise.all(o.slice(0,20).map(l=>Tt(this,null,function*(){return l.distance=yield this._getDistance(t,{floor:l.floor,x:l.center_x,y:l.center_y}),l})))).sort((l,c)=>l.distance-c.distance),...o.slice(20)]}})}_getDistance(t,e){return Tt(this,null,function*(){return this.navPath.getPath({floor:t.floor,coord:[t.x,t.y]},{floor:e.floor,coord:[e.x,e.y]},"",0).then(n=>n.reduce((i,o,a)=>{if(i+=o.distance,a!==n.length-1)switch(o.endType){case"escalator":case"straightLadder":case"staircase":case"ramp":i+=100;break}return i},0)).catch(n=>n==="near"?0:1/0)})}dispose(){super.dispose(),this.needDisposeNavPath&&this.navPath.dispose()}constructor(t,e){if(super(t),this.needDisposeNavPath=!1,e)this.navPath=e;else{this.navPath=new w_;let n=new fp(t);this.needDisposeNavPath=!0,n.load(t.config.apiPath.loadPlaceInfo+"?place_id="+t.config.placeId+"&env=prod").then(i=>Tt(this,null,function*(){let[o,a]=yield Promise.all([n.getRoadNetworkData(),n.getFacilitiesData()]);this.navPath.setRoadData(o,a.infrastructures)}))}}};return q$(MMt);})();
27666
+ `],{type:"text/javascript"}),t=URL.createObjectURL(r),e=new Worker(t);return URL.revokeObjectURL(t),e}var SMt={placeId:0,catLotStatusApi:"https://vrapi.aibee.cn/parking/cat-lot-status"},nP=class{setRoadData(t,e){return fi(this.worker,"set_road_info",{roadData:t,facilities:e})}recommend(t){return Tt(this,null,function*(){let e=yield fetch(this.options.catLotStatusApi,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({place_id:+this.options.placeId})}).then(n=>n.json()).then(n=>n.data.filter(i=>i.status===0));return fi(this.worker,"recommend",te({},t,{carLotStatus:e}))})}dispose(){this.worker.terminate()}constructor(t={}){this.worker=eP(),this.options=te({},SMt,t)}};var lle=H(sf(),1),cle=H(ze(),1),hle=H(Kf(),1),fle=H(En(),1),ple=H(vR(),1),dle=H(yR(),1),gle=H(ER(),1),mle=H(bR(),1),vle=H(Xa(),1);var ile=H(sf(),1);var bMt={url:"",reconnect:!0,heartBeat:2e3,heartMsg:"PING",reconnectTime:3e3,reconnectMaxCount:1e6,noMessageTime:6e3},Eg=class extends Zi{initWebsocket(){this.ws=new WebSocket(this.options.url),this.ws.onopen=()=>{this.alive=!0,this.startHeart(),this.startOnMessageTimer(),this.stopReconnect(),this.dispatchEvent({type:"open"})},this.ws.onerror=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect(),this.registryEvent()},this.ws.onclose=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect()},this.ws.onmessage=t=>{this.startOnMessageTimer(),this.dispatchEvent({type:"message",message:t})}}startHeart(){this.stopHeart(),this.heartTimer=this.timer.setInterval(()=>{this.send(this.options.heartMsg)&&this.dispatchEvent({type:"send-heart"})},this.options.heartBeat)}stopHeart(){this.heartTimer&&(this.timer.clearInterval(this.heartTimer),this.heartTimer=null)}startReconnect(t){t===void 0&&(t=this.options.reconnectTime),this.stopReconnect(),this.options.reconnect&&(this.options.reconnectMaxCount--,this.options.reconnectMaxCount>=0&&(this.reconnectTimer=this.timer.setTimeout(()=>{this.initWebsocket()},t)))}stopReconnect(){this.reconnectTimer&&(this.timer.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}startOnMessageTimer(){this.stopOnMessageTimer(),this.noMessageTimer=this.timer.setTimeout(()=>{var t;(t=this.ws)==null||t.close(),this.dispatchEvent({type:"no-message-timeout"})},this.options.noMessageTime)}stopOnMessageTimer(){this.noMessageTimer&&(this.timer.clearTimeout(this.noMessageTimer),this.noMessageTimer=null)}send(t){var e;let n=typeof t=="string"?t:JSON.stringify(t);return this.alive&&((e=this.ws)==null?void 0:e.readyState)===1?(this.ws.send(n),this.dispatchEvent({type:"send-success",msg:n}),!0):(this.dispatchEvent({type:"send-fail",msg:n}),!1)}registryEvent(){window.addEventListener("online",this.onOnline)}unRegistryEvent(){window.removeEventListener("online",this.onOnline)}close(){var t;this.unRegistryEvent(),this.options.reconnect=!1,this.alive=!1,this.stopHeart(),this.stopReconnect(),this.stopOnMessageTimer(),(t=this.ws)==null||t.close(),this.ws=null,this.dispatchEvent({type:"close"})}dispose(){this.close(),this.timer.dispose(),super.dispose()}constructor(t){super(),this.ws=null,this.alive=!1,this.timer=new ui,this.heartTimer=null,this.reconnectTimer=null,this.noMessageTimer=null,this.onOnline=()=>{this.startReconnect()},this.options=te({},bMt,t||{}),this.options.url&&this.initWebsocket()}};var iP=H(qs(),1);var rP=r=>{let t=r.toString(2),e=""+Array(16-t.length+1).join("0")+t,n=parseInt(e.slice(0,4),2)*10,i=parseInt(e.slice(4,16),2);return[n,i]};var oP=class extends Zi{initPositionWebSocket(){let t=te({},this.options.ext_position_params,{place_id:this.options.place_id,token:this.options.access_token}),e=Object.keys(t).filter(n=>!(0,iP.isNil)(t[n])).map(n=>n+"="+t[n]).join("&");this.positionWebSocket=new Eg({url:this.options.wss_position_url+"?"+e}),this.positionWebSocket.addEventListener("message",n=>{let{message:i}=n,o=(()=>{try{return JSON.parse(i.data)}catch(L){return i.data}})();if(o.command==="POSITION_RESULT"&&o.data.success)if(["POSITION","FLOOR","PARK_POSITION"].includes(o.data.success_type)&&this.useGpsFloorTimer&&(this.positionFloor=o.data.floor,this.timer.clearTimeout(this.useGpsFloorTimer),this.useGpsFloorTimer=null),o.data.success_type==="POSITION"){let{x:L,y:tt,time:O,floor:V,ts:W}=o.data,St=this.positionFloor!==V;if(this.positionFloor=V,this.dispatchEvent({type:"ws-position",floor:V,x:L,y:tt,time:O}),console.log("positionFloor",V,St),this.options.upload_position){var a;(a=this.positionWebSocket)==null||a.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:L,y:tt,floor:V,type:"originBeacon"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:V,x:L,y:tt,time:new Date(W).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var l;if(St){var c,f,g;(g=this.pdrPosition)==null||(f=g.pdr)==null||(c=f.particleFilter)==null||c.setPosInitFlag(!1)}(l=this.pdrPosition)==null||l.setBeaconPosition({x:L,y:tt},new Date(W).getTime()-o.lag-o.duration)}else if(St){var m;if(this.resetPdr(),(m=this.carInertialPosition)==null||m.stopPositionTimer(),this.path){let j=this.path.findIndex(mt=>mt.floor===V),pt=this.path[j];if(pt){var v;this.resetPdr(),(v=this.carInertialPosition)==null||v.setBeaconPosition(pt.points[0],new Date(O).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var x;(x=this.carInertialPosition)==null||x.setBeaconPosition([L,tt],new Date(O).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var S;(S=this.carInertialPosition)==null||S.setBeaconPosition([L,tt],new Date(O).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var w;(w=this.carInertialPosition)==null||w.setBeaconPosition([L,tt],new Date(O).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="PARK_POSITION"&&o.data.success){if(this.options.type===1){let{x:L,y:tt,time:O,floor:V}=o.data,W=this.positionFloor!==V;if(this.positionFloor=o.data.floor,this.dispatchEvent({type:"ws-position",floor:V,x:L,y:tt,time:O}),!this.options.use_pdr){this.dispatchEvent({type:"position",floor:V,x:L,y:tt,time:new Date(O).getTime()});return}if(W){var E;if(this.resetPdr(),(E=this.carInertialPosition)==null||E.stopPositionTimer(),this.path){let St=this.path.findIndex(pt=>pt.floor===V),j=this.path[St];if(j){var b;this.resetPdr(),(b=this.carInertialPosition)==null||b.setPosition(j.points[0],new Date(O).getTime(),o.duration)}else{var C;(C=this.carInertialPosition)==null||C.setPosition([L,tt],new Date(O).getTime(),o.duration)}}else{var A;(A=this.carInertialPosition)==null||A.setPosition([L,tt],new Date(O).getTime(),o.duration)}}else{var P,U;if((P=this.carInertialPosition)==null||P.setPosition([L,tt],new Date(O).getTime(),o.duration),!((U=this.carInertialPosition)!=null&&U.positionTimer)){var F;(F=this.carInertialPosition)==null||F.startPositionTimer()}}if(this.options.upload_position){var D;(D=this.positionWebSocket)==null||D.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:L,y:tt,floor:V,type:"vision"}),serverData:JSON.stringify(o)})}}}else this.dispatchEvent({type:"floor",floor:o.data.floor,time:o.data.time})})}initSensorWebSocket(){let t=te({},this.options.ext_sensor_params,{token:this.options.access_token,place_id:this.options.place_id,record_sensor:1}),e=Object.keys(t).filter(n=>!(0,iP.isNil)(t[n])).map(n=>n+"="+t[n]).join("&");this.sensorWebSocket=new Eg({url:this.options.wss_sensor_url+"?"+e})}initPdr(){this.options.type===1?(this.carInertialPosition=new I_,this.carInertialPosition.addEventListener("change-pos",t=>{let{value:e}=t,{pos:n,success:i,speed:o}=e;if(i&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:n[0],y:n[1],time:Date.now(),speed:o}),this.options.upload_position)){var a;(a=this.positionWebSocket)==null||a.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:n[0],y:n[1],floor:this.positionFloor,type:"vision_pdr"})})}}),this.carInertialPosition.addEventListener("change-compass",t=>{let{value:e}=t;this.dispatchEvent({type:"compass",value:e})})):(this.pdrPosition=new C_(this.bmap,{pdr:{using_gps:this.options.use_gps},sensor:{elements:[Gr.COMPASS,Gr.ACCELERATION,Gr.DEVICE_MOTION].concat(this.options.use_gps?[Gr.GPS]:[])}}),this.requestDeviceOrientationPermission(),this.options.upload_position&&this.pdrPosition.sensor.addEventListener("sensor-data",t=>{let{data:e}=t;var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_SENSOR",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify(e)})}),this.pdrPosition.sensor.addEventListener("add-data-item",t=>{t.item.type==="compass"&&this.dispatchEvent({type:"compass",value:t.item.res})}),this.pdrPosition.addEventListener("position",t=>{let{x:e,y:n,_type:i}=t;if(console.log("_type",i,e,n,this.positionFloor,this.gpsFloor),i==="gps"&&!this.useGpsFloorTimer){let a=()=>{this.useGpsFloorTimer=this.timer.setTimeout(()=>{this.gpsFloor?this.positionFloor=this.gpsFloor:a()},5e3)};a()}if(this.positionFloor&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:e,y:n,time:Date.now()}),this.options.upload_position)){var o;(o=this.positionWebSocket)==null||o.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:e,y:n,floor:this.positionFloor,type:i})})}}))}setSensor(t){this.pdrPosition&&this.pdrPosition.setSensor(t)}requestDeviceOrientationPermission(){return Tt(this,null,function*(){if(this.pdrPosition){let t=yield this.pdrPosition.checkSensor();return t.deviceOrientation?this.pdrPosition.start():(this.dispatchEvent(te({type:"check-sensor"},t)),!t.deviceOrientation&&this.options.use_default_permission),t}else return null})}getGpsFloor(){return Tt(this,null,function*(){if(this.options.use_gps&&this.options.get_gps_floor_url){let t=yield fetch(this.options.get_gps_floor_url+"/"+this.options.place_id).then(e=>e.json());t.code===200&&(this.gpsFloor=t.data.gps_floor)}})}pausePdr(){if(this.options.type===1){var t;(t=this.carInertialPosition)==null||t.stopPositionTimer()}else{var e;(e=this.pdrPosition)==null||e.pause()}}continuePdr(){if(this.options.type===1)this.carInertialPosition&&(this.carInertialPosition.positionTimer||this.carInertialPosition.startPositionTimer());else{var t;(t=this.pdrPosition)==null||t.continue()}}setPathAngle(t){if(this.options.type===1){var e;(e=this.carInertialPosition)==null||e.setPathAngle(t)}}getForwardAngle(){if(this.options.type===1){var t,e;return(e=(t=this.carInertialPosition)==null?void 0:t.angle)!=null?e:null}else return null}resetPdr(){this.carInertialPosition&&(this.carInertialPosition.history=[],this.carInertialPosition.setPathAngle(0),this.carInertialPosition.speed=0),this.pdrPosition&&this.pdrPosition.pdr.particleFilter.setPosInitFlag(!1)}setPath(t){this.path=t}sendBeacon(t){var e;let n=[];if(yh)n=t.map(o=>{let[a,l]=rP(o.major);return[o.uuid,l,o.minor,o.rssi,o.accuracy,a]}).filter(o=>o[3]!==0).sort((o,a)=>a[3]-o[3]);else{let o=t.reduce((a,l)=>{var c,f;let[g,m]=rP(l.major),v=""+m+l.minor;return(c=a)[f=v]||(c[f]=[]),a[v].push(te({},l,{battery:g})),a},{});Object.entries(o).forEach(a=>{let[l,c]=a,{uuid:f,major:g,minor:m,accuracy:v,battery:x}=c[0];if(c.length>1){let S=c.filter(E=>E.rssi<0),w=S.reduce((E,b)=>E+b.rssi,0);n.push([f,g,m,w/S.length,v,x])}else n.push([f,g,m,c[0].rssi,v,x])})}let i={command:"POSITION",index:this.uploadIndex++,ts:Date.now(),beacons:JSON.stringify(n),ext_sensors:JSON.stringify({})};(e=this.sensorWebSocket)==null||e.send(i)}dispose(){var t,e,n,i;this.timer.dispose(),(t=this.positionWebSocket)==null||t.dispose(),this.positionWebSocket=null,(e=this.sensorWebSocket)==null||e.dispose(),this.sensorWebSocket=null,(n=this.pdrPosition)==null||n.dispose(),this.pdrPosition=null,(i=this.carInertialPosition)==null||i.dispose(),this.carInertialPosition=null,super.dispose()}constructor(t,e){super(),this.bmap=t,this.positionWebSocket=null,this.sensorWebSocket=null,this.pdrPosition=null,this.carInertialPosition=null,this.gpsFloor="",this.positionFloor="",this.useGpsFloorTimer=null,this.uploadIndex=0,this.path=null,this.timer=new ui;let n=new URLSearchParams(location.search),i=n.get("server_env")||"prod",o={test:"nav-test.aibee.cn",prod:"nav.aibee.cn"},a="wss://"+o[i]+"/aether-walker/indoor/position",l="wss://"+o[i]+"/aether-walker/indoor/sensor";this.options=te({place_id:n.get("place_id"),access_token:n.get("access_token"),env:i,wss_position_url:a,wss_sensor_url:l,get_gps_floor_url:"https://"+o[i]+"/aether-walker/indoor/conf",use_sensor:!1,type:-1,use_gps:!0,use_pdr:!0,upload_position:!0,use_default_permission:!0,ext_position_params:{},ext_sensor_params:{}},e),this.initPositionWebSocket(),this.options.use_sensor&&this.initSensorWebSocket(),this.options.use_pdr&&this.initPdr(),this.options.use_gps&&this.getGpsFloor()}};var Tle=H(ze(),1);var sP=class extends lo{showMyPosition(t,e){var n;let i=(n=this.bmap.context.currentFloor)==null?void 0:n.getGraphicPosition(t);if(i){let o=new lp(this.bmap.context,{autoUpdate:!0,appendToBody:!1});o.div.appendChild(e),o.position.copy(this.bmap.mercatorToWorld(i)),this.myPositionOverlay=o,console.log("graphicPos",i,this)}else console.warn("[showMyPosition] \u6CA1\u6709\u627E\u5230\u56FE\u5143\u6240\u5728\u7684\u4F4D\u7F6E")}hideMyPosition(){this.myPositionOverlay&&(this.myPositionOverlay.dispose(),this.myPositionOverlay=null)}dispose(){this.hideMyPosition()}constructor(...t){super(...t),this.myPositionOverlay=null}};var aP=class extends lo{highlightPoi(t,e){e===void 0&&(e={icon_size:[40,40],collision_enable:!1}),t.map(i=>this.bmap.getPoiById(i)).filter(i=>!!i).forEach(i=>{var o;(o=i.userData).restore||(o.restore={});for(let c in e)if(c in i.options){var a,l;(a=i.userData.restore)[l=c]||(a[l]=i.options[c]),i.options[c]=e[c]}})}restorePoi(t){t.map(n=>this.bmap.getPoiById(n)).filter(n=>!!n).forEach(n=>{console.log("poi.userData.restore",n.userData.restore);for(let i in n.userData.restore)i in n.options&&(n.options[i]=n.userData.restore[i]);n.userData.restore={}})}};var Lle=H(ze(),1),Nle=H(Kf(),1);var uP=class extends lo{sortByDistance(t,e,n){return Tt(this,null,function*(){n===void 0&&(n=!1);let i=[...e];if(n||e.length<20)return yield Promise.all(i.map(o=>Tt(this,null,function*(){o.distance=yield this._getDistance(t,{floor:o.floor,x:o.center_x,y:o.center_y})}))),i.sort((o,a)=>o.distance-a.distance);{let o=i.sort((l,c)=>{let f=Math.sqrt((l.center_x-t.x)**2+(l.center_y-t.y)**2)+(t.floor===l.floor?0:100),g=Math.sqrt((c.center_x-t.x)**2+(c.center_y-t.y)**2)+(t.floor===c.floor?0:100);return f-g});return[...(yield Promise.all(o.slice(0,20).map(l=>Tt(this,null,function*(){return l.distance=yield this._getDistance(t,{floor:l.floor,x:l.center_x,y:l.center_y}),l})))).sort((l,c)=>l.distance-c.distance),...o.slice(20)]}})}_getDistance(t,e){return Tt(this,null,function*(){return this.navPath.getPath({floor:t.floor,coord:[t.x,t.y]},{floor:e.floor,coord:[e.x,e.y]},"",0).then(n=>n.reduce((i,o,a)=>{if(i+=o.distance,a!==n.length-1)switch(o.endType){case"escalator":case"straightLadder":case"staircase":case"ramp":i+=100;break}return i},0)).catch(n=>n==="near"?0:1/0)})}dispose(){super.dispose(),this.needDisposeNavPath&&this.navPath.dispose()}constructor(t,e){if(super(t),this.needDisposeNavPath=!1,e)this.navPath=e;else{this.navPath=new w_;let n=new fp(t);this.needDisposeNavPath=!0,n.load(t.config.apiPath.loadPlaceInfo+"?place_id="+t.config.placeId+"&env=prod").then(i=>Tt(this,null,function*(){let[o,a]=yield Promise.all([n.getRoadNetworkData(),n.getFacilitiesData()]);this.navPath.setRoadData(o,a.infrastructures)}))}}};return q$(MMt);})();