@aibee/crc-bmap 0.0.40 → 0.0.42

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.
@@ -35,6 +35,12 @@ const bmap = new BMap(document.getElementById('app')!, {
35
35
  // bmap.getGraphicByNodeId("45f9ff75")!.options.fillColor = '#45E583';
36
36
  // bmap.getGraphicByNodeId("0b245fa9")!.options.fillColor = '#FFB166';
37
37
  // bmap.getGraphicByNodeId("9cd3408c")!.options.fillColor = '#FF4D4D';
38
+ bmap.getFloorAllGraphics().forEach(graphic => {
39
+ if (graphic.options.userData.mark) {
40
+ graphic.options.fillColor = '#F5F7F9'
41
+ graphic.options.height = 0.1
42
+ }
43
+ })
38
44
  })();
39
45
 
40
46
  const graphicId = "9338ca4b"
@@ -285,7 +291,7 @@ document.getElementById("enlargeMap")?.addEventListener('click', () => {
285
291
  })
286
292
  document.getElementById("centerView")?.addEventListener('click', () => {
287
293
  // TODO 这里应该是地面
288
- bmap.context.fitCameraToGround()
294
+ bmap.resetView()
289
295
  })
290
296
  document.getElementById("centerGraphic")?.addEventListener('click', () => {
291
297
  bmap.context.fitCameraToObject(graphic)
@@ -1,3 +1,3 @@
1
- "use strict";var lt=Object.defineProperty,ne=Object.defineProperties,oe=Object.getOwnPropertyDescriptor,re=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertyNames,kt=Object.getOwnPropertySymbols;var zt=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var C=Math.pow,yt=(r,s,t)=>s in r?lt(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t,z=(r,s)=>{for(var t in s||(s={}))zt.call(s,t)&&yt(r,t,s[t]);if(kt)for(var t of kt(s))ae.call(s,t)&&yt(r,t,s[t]);return r},xt=(r,s)=>ne(r,re(s));var ce=(r,s)=>{for(var t in s)lt(r,t,{get:s[t],enumerable:!0})},he=(r,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of se(s))!zt.call(r,i)&&i!==t&&lt(r,i,{get:()=>s[i],enumerable:!(e=oe(s,i))||e.enumerable});return r};var pe=r=>he(lt({},"__esModule",{value:!0}),r);var o=(r,s,t)=>(yt(r,typeof s!="symbol"?s+"":s,t),t);var T=(r,s,t)=>new Promise((e,i)=>{var n=p=>{try{c(t.next(p))}catch(h){i(h)}},a=p=>{try{c(t.throw(p))}catch(h){i(h)}},c=p=>p.done?e(p.value):Promise.resolve(p.value).then(n,a);c((t=t.apply(r,s)).next())});var ge={};ce(ge,{BMap:()=>Rt,BaseSvg:()=>F,Context:()=>ht,Floor:()=>ot,Graphic:()=>D,GraphicLayer:()=>et,HeatmapElement:()=>nt,HoverHelper:()=>ct,Layer:()=>$,Overlay:()=>tt,Poi:()=>j,PoiLayer:()=>it,SelectBox:()=>At,Selection:()=>at,Shadow:()=>J,SvgLine:()=>rt,SvgPolygon:()=>st,Timer:()=>A,clearCanvas:()=>Ft,clearTextTexture:()=>St,createCanvas:()=>It,createCircle:()=>U,createLine:()=>Q,createRect:()=>I,createSvg:()=>Ot,createSvgElement:()=>N,defaultConfig:()=>te,dispose:()=>O,getCenter:()=>dt,getConfig:()=>Tt,getTextureByText:()=>le,hasChinese:()=>Mt,initCamera:()=>Pt,initCanvas:()=>Bt,initControl:()=>Ct,initDirectionalLight:()=>Gt,initLight:()=>wt,initRenderer:()=>Et,initScene:()=>bt,initShape:()=>Lt,isContain:()=>Z,proxyOptions:()=>Y,setCirclePosition:()=>R,setLineStartEnd:()=>L,setRectPosition:()=>G,sleepOnePromise:()=>ut,strToNumber:()=>me,timeoutPromise:()=>q,vector3ToDevice:()=>y});module.exports=pe(ge);var ee=require("three");var A=class{constructor(){o(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(s){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),s()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(s){this.tasks.requestAnimation.delete(s),window.cancelAnimationFrame(s)}setTimeout(s,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),s()},t);return this.tasks.timeout.add(e),e}clearTimeout(s){this.tasks.timeout.delete(s),window.clearTimeout(s)}setInterval(s,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),s()},t);return this.tasks.interval.add(e),e}clearInterval(s){this.tasks.interval.delete(s),window.clearInterval(s)}dispose(){this.tasks.requestAnimation.forEach(s=>{window.cancelAnimationFrame(s)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(s=>{window.clearTimeout(s)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(s=>{window.clearInterval(s)}),this.tasks.interval.clear()}};var f=require("three"),Ht=require("three/examples/jsm/controls/MapControls");function bt(){let r=new f.Scene;return r.background=new f.Color(16777215),r}function Et(){let r=new f.WebGLRenderer({antialias:!0});return r.setClearColor(16777215),r.setPixelRatio(window.devicePixelRatio),r.shadowMap.enabled=!0,r.shadowMap.autoUpdate=!0,r.shadowMap.type=f.PCFSoftShadowMap,r}function Pt(r,s){let t=new f.OrthographicCamera(-r/2,r/2,s/2,-s/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function wt(){let r=new f.Group,s=new f.HemisphereLight(16777215,16777215,2);s.intensity=1,s.position.set(0,0,10),s.up.set(0,0,1),r.add(s);let t=new f.AmbientLight(16777215,1);return r.add(t),r}function Ct(r,s){let t=new Ht.MapControls(r,s);return t.enableDamping=!1,t.zoomSpeed=2,t}function Lt(r,s=[]){let t=new f.Shape(r.map(e=>new f.Vector2(...e)));return s.length&&s.forEach(e=>{var i=new f.Path(e.map(n=>new f.Vector2(...n)));t.holes.push(i)}),t}function Gt(r=16777215,s=1){let t=new f.DirectionalLight(r,s);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(128,128),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function O(r,s){var t;if(s&&r.children&&r.children.length&&r.children.forEach(e=>{O(e,s)}),r.isMesh){let e=r;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}r.isLight&&((t=r.dispose)==null||t.call(r))}function Mt(r){return/[\u4E00-\u9FA5]+/g.test(r)}var B=require("three");var mt=new Map;function Bt(){let r=document.createElement("canvas");r.width=1024,r.height=64;let s=r.getContext("2d",{willReadFrequently:!0});return s.font="54px sans-serif",s.textBaseline="hanging",s.lineWidth=12,s.fillStyle="rgba(0,0,0,1)",s.strokeStyle="white",{canvas:r,ctx:s}}var Dt,H;function It(){if(!Dt){let{canvas:r,ctx:s}=Bt();Dt=r,H=s}}function le(r){if(mt.has(r))return mt.get(r);It(),H.clearRect(0,0,1024,64);let s=Mt(r)?4:8;H.strokeText(r,2,s),H.fillText(r,2,s);let t=Math.ceil(H.measureText(r).width);t=t%2===0?t:t+1,t+=2;let e=H.getImageData(0,0,t,64),i=new B.DataTexture(Uint8Array.from(e.data),t,64,B.RGBAFormat);return i.flipY=!0,i.minFilter=B.LinearFilter,i.magFilter=B.LinearFilter,mt.set(r,i),i}function St(){mt.clear()}function Ft(){H=null,Dt=null}var K=require("@turf/turf");function y(r,s,t,e){let i=r.clone().project(s),n=t/2,a=e/2,c=Math.round(i.x*n+n),p=Math.round(-i.y*a+a);return{x:c,y:p}}function dt(r){let s=(0,K.featureCollection)(r.map(e=>(0,K.point)(e)));return(0,K.center)(s).geometry.coordinates}function Z(r,s,t){return r.x>=s.x&&r.x<=t.x&&r.y>=s.y&&r.y<=t.y}function Y(r,s){return new Proxy(r,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,n)=>{let a=Reflect.set(t,e,i,n);return s.dispatchEvent({type:`change-${e}`,value:i}),a}})}function q(r,s){return Promise.race([r,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),s)})])}function N(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function Ot(r,s){let t=N("svg");return t.setAttribute("width",r),t.setAttribute("height",s),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function U(r="2",s){let t=N("circle");return t.setAttribute("r",r),t.setAttribute("fill",s),t}function Q(r){let s=N("line");return s.setAttribute("stroke",r),s}function I(r,s){let t=N("rect");return t.setAttribute("stroke",r),t.setAttribute("fill",s),t}function R(r,s,t){r.setAttribute("cx",`${s}`),r.setAttribute("cy",`${t}`)}function L(r,s,t){s&&(r.setAttribute("x1",`${s.x}`),r.setAttribute("y1",`${s.y}`)),t&&(r.setAttribute("x2",`${t.x}`),r.setAttribute("y2",`${t.y}`))}function G(r,s,t,e,i){r.setAttribute("x",`${s}`),r.setAttribute("y",`${t}`),r.setAttribute("width",`${e}`),r.setAttribute("height",`${i}`)}function ut(){return Promise.resolve()}function me(r){return parseInt(r.replace("#","0x"),16)}var v=require("three"),_=require("@tweenjs/tween.js");var Nt=require("three");var x=require("three");var Vt=require("lodash"),$t=require("three/examples/jsm/lines/LineMaterial.js"),Kt=require("three/examples/jsm/lines/LineSegmentsGeometry.js"),Ut=require("three/examples/jsm/lines/LineSegments2.js");var de={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0},D=class extends x.Object3D{constructor(t,e){super();this.context=t;o(this,"geometry");o(this,"material");o(this,"mesh");o(this,"line");o(this,"options");if(this.options=Y((0,Vt.merge)({},de,e),this),this.options.geometry.type==="point"){let[i,n]=this.options.geometry.cds;return this.position.set(i,n,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.material.color=new x.Color(i)}),this.addEventListener("change-fillOpacity",({value:i})=>{this.material.opacity=i}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.line.material.color=new x.Color(i)}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.line.material.opacity=i}),this.addEventListener("change-strokeWidth",({value:i})=>{this.line.material.linewidth=i}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i})}getCenter(){if(this.options.geometry.type==="point")return this.position;let t=new x.Vector3,e=new x.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new x.Vector3(0,0,0);let t=new x.Box3,e=new x.Vector3;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height),t}init(){this.geometry=this.initGeometry(),this.material=this.initMaterial(),this.mesh=this.initMesh(),this.mesh.position.z=this.options.airHeight,this.mesh.castShadow=!0,this.add(this.mesh),this.line=this.createBorder(),this.add(this.line)}initGeometry(){let t=Lt(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new x.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){return new x.MeshStandardMaterial({color:this.options.fillColor,roughness:1,transparent:!0,opacity:this.options.fillOpacity,depthWrite:!0})}initLineMaterial(){let t=new $t.LineMaterial({color:new x.Color(this.options.strokeColor).getHex(),opacity:this.options.strokeOpacity,transparent:!0,depthWrite:!0,linewidth:this.options.strokeWidth,wireframe:!1,dashed:!1}),{clientSize:{width:e,height:i}}=this.context;return t.resolution.set(e,i),t}initMesh(){return new x.Mesh(this.geometry,this.material)}createBorder(){let t=this.initLineMaterial(),e=new x.EdgesGeometry(this.geometry),i=new Kt.LineSegmentsGeometry;i.fromEdgesGeometry(e);let n=new Ut.LineSegments2(i,t);return n.position.z=this.options.airHeight,n}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:n}=e[0];return{position:i,distance:n}}return!1}dispose(){O(this),this.clear()}};var M=require("three");var J=class extends M.Object3D{constructor(){super();o(this,"directionalLight");o(this,"plane");o(this,"basicOpacity",.39);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Gt(16777215,1);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new M.Color(t)}setPosition(t){this.position.copy(t),this.directionalLight.position.set(-t.x/2,-t.y/2,100)}initPlane(t=1e3,e=1e3){let i=new M.PlaneGeometry(t,e),n=new M.ShadowMaterial({transparent:!0,opacity:0,side:M.DoubleSide}),a=new M.Mesh(i,n);return a.receiveShadow=!0,a.position.z=-10,this.add(a),this.plane=a,a}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){O(this,!0)}};var jt=require("three"),_t=require("lodash");var V=require("three");var tt=class extends V.EventDispatcher{constructor(t){super();this.context=t;o(this,"div");o(this,"element");o(this,"position",new V.Vector3);o(this,"clientPos",{x:0,y:0});o(this,"visible",!0);o(this,"onUpdate",()=>{let t=this.getPosition(),{width:e,height:i}=this.context.clientSize,{x:n,y:a}=y(t,this.context.camera,e,i);this.clientPos.x===n&&this.clientPos.y===a||(this.clientPos={x:n,y:a},this.div.style.left=`${n}px`,this.div.style.top=`${a}px`)});this.registryEvent(),this.div=this.initDiv(),this.context.container.appendChild(this.div)}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}bindElement(t){this.element=t,this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,e="block"){t!==this.visible&&(this.div.style.display=t?e:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new V.Box3().setFromObject(this.element).getCenter(new V.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:n}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=n}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.context.container.removeChild(this.div),this.div=null}};var ue={text:"",level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0}},j=class extends jt.Object3D{constructor(t,e){var i,n,a;super();this.context=t;o(this,"textDiv");o(this,"img");o(this,"overlay");o(this,"options");o(this,"size",{width:0,height:0});o(this,"_changePosition",()=>{this.overlay.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=Y((0,_t.merge)({},ue,e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((n=e.position)==null?void 0:n.y)||0,((a=e.position)==null?void 0:a.z)||0),this.overlay=new tt(this.context),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):this.overlay.div.appendChild(this.initIcon()):(this.img&&this.overlay.div.removeChild(this.img),this.img=void 0,this.resetSize())}),this.addEventListener("change-text",({value:c})=>{this.overlay.div.removeChild(this.textDiv),this.overlay.div.appendChild(this.initText()),this.resetSize()}),this.addEventListener("change-opacity",({value:c})=>{this.overlay.setOpacity(c)}),this.addEventListener("change-icon_size",({value:c})=>{this.img&&(this.img.style.width=`${(c==null?void 0:c[0])||32}px`,this.img.style.height=`${(c==null?void 0:c[1])||32}px`,this.resetSize())})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return T(this,null,function*(){let t=this.overlay.visible;this.setVisible(!0),yield ut();let{width:e,height:i}=this.overlay.div.getBoundingClientRect();this.size={width:e,height:i},yield ut(),this._changePosition(),this.setVisible(t)})}get clientPos(){return this.overlay.clientPos}initDiv(){let t=this.overlay.div;return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.pointerEvents="none",this.overlay.setOpacity(this.options.opacity),this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.background="rgba(255, 255, 255, .7)",t.style.padding="2px",t.style.borderRadius="4px",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.text.split(`\r
2
- `).forEach(e=>{let i=document.createElement("div");i.style.whiteSpace="nowrap",i.textContent=e,t.appendChild(i)}),t}initIcon(){var e,i;let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${((e=this.options.icon_size)==null?void 0:e[0])||32}px`,t.style.height=`${((i=this.options.icon_size)==null?void 0:i[1])||32}px`,t.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){this.overlay.setVisible(t,"flex")}getBox(){let{width:t,height:e}=this.size,{x:i,y:n}=this.overlay.clientPos;return{left:i-t/2,right:i+t/2,top:this.options.icon?n-e:n-e/2,bottom:this.options.icon?n:n+e/2}}isContain(t,e){if(!this.overlay.visible)return!1;let i=this.getBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var S=require("three");var gt=require("three");var Xt=require("three");var $=class extends Xt.Object3D{constructor(t){super();this.context=t}dispose(){O(this),this.clear()}};var et=class extends ${constructor(t){super(t);o(this,"graphicMap",new Map)}getCenter(){return new gt.Box3().setFromObject(this).getCenter(new gt.Vector3)}createGraphic(t){let e=new D(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((n,a)=>{if(a instanceof D){let c=a.raycast(t);if(c){let{distance:p}=c;if(p<n.distance)return{distance:n.distance,position:n.position,graphic:a}}return n}else return n},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var Wt=require("lodash");var it=class extends ${constructor(t){super(t);o(this,"pois",[]);o(this,"debounceCollisionDetection");o(this,"timer",new A);o(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,Wt.debounce)(this.collisionDetection,10)}clear(){return super.clear(),this.pois=[],this}createPoi(t){let e=new j(this.context,t);return this.add(e),this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.remove(t),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===1){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.children.filter(n=>n instanceof j&&n.isContain(t,e))}collisionDetection(){let{clientSize:{width:t,height:e}}=this.context,i=[];this.pois.filter(a=>a.withinDisplayRange).forEach((a,c)=>{let{left:p,right:h,top:l,bottom:d}=a.getBox();if(c===0){i.push({left:p,right:h,top:l,bottom:d});return}let g=i.some(m=>h<m.right&&h>m.left||p>m.left&&p<m.right||p===m.left&&h===m.right?d<=m.bottom&&d>m.top||l>=m.top&&l<m.bottom:!1);a.setVisible(!g),i.push({left:p,right:h,top:l,bottom:d})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var P=require("three"),Zt=require("@mars3d/heatmap.js"),k=require("@turf/turf");var nt=class extends P.Object3D{constructor(t){super();this.context=t;o(this,"heatmap");o(this,"div");o(this,"plane");this.div=document.createElement("div")}clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:n,center:a}=this.getBox(t);this.heatmap=(0,Zt.create)(z({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,n)),this.initPlane(e,i),this.position.set(a[0],a[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new P.PlaneGeometry(t,e),n=new P.Texture(this.div.firstChild);n.needsUpdate=!0;let a=new P.MeshBasicMaterial({transparent:!0,side:P.DoubleSide,map:n});a.needsUpdate=!0,this.plane=new P.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new P.Matrix3().makeScale(1,-1).multiply(new P.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new P.Vector2(a.x,a.y).applyMatrix3(i);return{x:c.x,y:c.y,value:a.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,k.featureCollection)(t.data.map(h=>(0,k.point)([h.x,h.y]))),i=(0,k.bbox)(e),n=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},p=(0,k.center)(e);return{width:n,height:a,leftTop:c,center:p.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var ot=class extends S.Object3D{constructor(t){super();this.context=t;o(this,"graphicLayer");o(this,"poiLayer");o(this,"grounds",new Set);o(this,"shadow",new J);o(this,"heatmap");o(this,"groundUpper",new S.Object3D);o(this,"groundMaxHeight",0);this.graphicLayer=new et(this.context),this.poiLayer=new it(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper)}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundUpper.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight)):0}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new S.Box3().setFromObject(this.groundUpper).getCenter(new S.Vector3)}addShadow(){let t=new S.Box3().setFromObject(this.groundUpper),e=t.getCenter(new S.Vector3),i=t.getSize(new S.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i),this.add(this.shadow)}addGraphic(t){return t.airHeight=Math.max(this.groundMaxHeight,t.airHeight||0),this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new nt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new S.Box3().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}dispose(){var t;this.shadow.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.grounds.forEach(e=>e.dispose()),(t=this.heatmap)==null||t.dispose(),this.groundUpper.clear(),this.clear()}};var ft=require("three");var F=class extends ft.EventDispatcher{constructor(t){super();this.context=t;o(this,"points",[]);o(this,"svg");o(this,"enable",!0);this.svg=Ot(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:n,offsetY:a}=t,{clientWidth:c,clientHeight:p}=i.domElement,h=n/c*2-1,l=1-a/p*2;return new ft.Vector3(h,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return y(t,e,i.clientWidth,i.clientHeight)}dispose(){this.context.container.removeChild(this.svg),this.svg=null}};var rt=class extends F{constructor(t){super(t);this.context=t;o(this,"circles");o(this,"line");o(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);R(this.circles[0],t.x,t.y),L(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);R(this.circles[1],t.x,t.y),L(this.line,void 0,t)}});o(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",L(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});o(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});o(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t,a=this.circles[this.points.length];R(a,i,n),this.points.length||L(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[U(e.radius,e.fill),U(e.radius,e.fill)],this.line=Q(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:n}]=this.points;return Math.sqrt(C(i-t,2)+C(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var st=class extends F{constructor(t){super(t);o(this,"circles",[]);o(this,"lines",[]);o(this,"isClose",!1);o(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&R(this.circles[e],i.x,i.y),e!==0&&L(this.lines[e-1],void 0,i),this.lines[e]&&L(this.lines[e],i)})});o(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",L(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});o(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});o(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t;this.checkAdsorb(i,n)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:a,radius:c},line:{stroke:p}}=this.context.config.svg;if(!this.isClose){let h=U(c,a);R(h,i,n),this.addCircle(h)}if(this.lines.length&&L(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let h=Q(p);L(h,{x:i,y:n},{x:i,y:n}),this.addLine(h)}}});this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],n=+i.getAttribute("cx"),a=+i.getAttribute("cy");return Math.sqrt(C(t-n,2)+C(e-a,2))<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(n=>[n.x,n.y]),e=0,i=t.length;for(let n=0;n<i;n++){let a=(n+1)%i;e+=t[n][0]*t[a][1]-t[a][0]*t[n][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var Yt=require("three");var At=class extends F{constructor(t){super(t);this.context=t;o(this,"rect");o(this,"cornerRect",[]);o(this,"centerRect",[]);o(this,"graphic");o(this,"onUpdate",()=>{if(this.graphic){let t=new Yt.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:n}}=this.context,{min:a,max:c}=t,p=y(a,e,i,n),h=y(c,e,i,n);G(this.rect,p.x,h.y,Math.abs(h.x-p.x),Math.abs(h.y-p.y));let{x:l,y:d}=p,{x:g,y:m}=h,u=5,b=[{x:l-u,y:m-u},{x:g-u,y:m-u},{x:l-u,y:d-u},{x:g-u,y:d-u}];for(let w=0;w<b.length;w++)G(this.cornerRect[w],b[w].x,b[w].y,u*2,u*2);let E=4,X=(l+g)/2,pt=(d+m)/2,W=[{x:X-E,y:m-E},{x:l-E,y:pt-E},{x:g-E,y:pt-E},{x:X-E,y:d-E}];for(let w=0;w<W.length;w++)G(this.centerRect[w],W[w].x,W[w].y,E*2,E*2)}else{G(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)G(this.cornerRect[t],0,0,0,0),G(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=I(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=I(e.stroke,"#ffffff"),this.centerRect[i]=I(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};var qt=require("three");var vt=class extends F{constructor(t){super(t);o(this,"startPoint");o(this,"endPoint");o(this,"rect");o(this,"frustum",new qt.Frustum);o(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});o(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});o(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});o(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=z({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},n=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);G(this.rect,i.x,i.y,n,a)}else G(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=I(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),G(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:i,clientHeight:n}}}=this,a=y(this.startPoint,e,i,n),c=y(this.endPoint,e,i,n),p={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},h={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},l=this.searchMapInFrustum(p,h);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(a=>a instanceof D&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let m=t.getPosition();if(m){let u=y(m,n,a,c);return Z(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let p=t.mesh.geometry.boundingBox;if(!p)return!1;let{min:h,max:l}=p,d=y(h,n,a,c),g=y(l,n,a,c);return!(!Z(d,e,i)||!Z(g,e,i))}dispose(){this.unRegistryEvent()}};var at=class extends Nt.EventDispatcher{constructor(t){super();this.context=t;o(this,"_list",new Set);o(this,"boxSelection");o(this,"prevPanStatus");o(this,"prevRotateStatus");o(this,"downPoint",null);o(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});o(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:n,y:a}=this.downPoint;if(Math.sqrt(C(n-e,2)+C(a-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),p=new Set(c.map(l=>l.options.id));this.context.getPoisByDeviceXy(e,i).forEach(l=>{var d;if(!p.has(l.options.id)){let g=((d=this.context.currentFloor)==null?void 0:d.graphicLayer.graphicMap.get(l.options.id))||null;g&&(c.push(g),p.add(l.options.id))}}),t.ctrlKey||this._list.clear(),c.forEach(l=>this._list.add(l)),this.selectEnd(),this.downPoint=null});o(this,"onKeyDown",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)});o(this,"onKeyUp",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)});o(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new vt(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list]})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),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()}};var Qt=require("three");var ct=class extends Qt.EventDispatcher{constructor(t){super();this.context=t;o(this,"curGraphics",new Set);o(this,"timer",new A);o(this,"graphicTimerMap",new Map);o(this,"onPointerMove",({graphics:t})=>{if(!t.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:e}=this.context.config.hover;t.forEach(n=>{if(this.graphicTimerMap.get(n)||this.curGraphics.has(n))return;let a=this.timer.setTimeout(()=>{this.curGraphics.add(n),this.handleHoverGraphicsChange()},e);this.graphicTimerMap.set(n,a)}),this.graphicTimerMap.forEach((n,a)=>{t.includes(a)||(this.timer.clearTimeout(n),this.graphicTimerMap.delete(a))});let i=this.curGraphics.size;this.curGraphics.forEach(n=>{t.includes(n)||this.curGraphics.delete(n)}),i!==this.curGraphics.size&&this.handleHoverGraphicsChange()});o(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(this.curGraphics)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel)}dispose(){this.unRegistryEvent(),this.timer.dispose()}};var ht=class extends v.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;o(this,"scene",bt());o(this,"renderer",Et());o(this,"camera");o(this,"control");o(this,"lights",wt());o(this,"timer",new A);o(this,"tweenGroup",new _.Group);o(this,"currentFloor");o(this,"selection");o(this,"hoverHelper");o(this,"basicRatio");o(this,"clientSize",{width:0,height:0});o(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:n,clientHeight:a}=t;e.left=-n/2,e.right=n/2,e.top=a/2,e.bottom=-a/2,e.updateProjectionMatrix(),i.setSize(n,a),this.resizeClientSize(n,a)});o(this,"onClick",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY);e.length&&this.dispatchEvent({type:"graphic-click",graphics:e,position:i});let n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);n.length&&this.dispatchEvent({type:"poi-click",pois:n})});o(this,"onPointerover",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-over",graphics:e,pois:n,position:i})});o(this,"onPointermove",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-move",graphics:e,pois:n,position:i})});o(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});o(this,"onSelectionSelect",({graphics:t})=>{this.dispatchEvent({type:"select-graphic",graphics:t})});o(this,"onHoverChange",({graphics:t})=>{this.dispatchEvent({type:"hover",graphics:t})});this.container.style.position="relative",this.container.style.overflow="hidden",this.init(),this.selection=new at(this),this.hoverHelper=new ct(this),this.resizeClientSize(),this.registryEvent()}resizeClientSize(t,e){this.clientSize={width:t||this.container.clientWidth,height:e||this.container.clientHeight}}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=Pt(t,e),this.renderer.setSize(t,e),this.control=Ct(this.camera,this.renderer.domElement),this.control.maxPolarAngle=this.config.control.maxPolar,this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",()=>{var n;let i=this.control.getPolarAngle();(n=this.currentFloor)==null||n.setShadowOpacity(i/this.config.control.maxPolar),this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom}),this.dispatchEvent({type:"control-change"})})}getRatio(t=new v.Vector3(0,0,0),e=new v.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,a=y(t,this.camera,i,n),c=y(e,this.camera,i,n);return Math.ceil(Math.sqrt(C(c.x-a.x,2)+C(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof v.AmbientLight&&(e.color=new v.Color(t))})}switchFloor(t){this.currentFloor&&(this.scene.remove(this.currentFloor),this.currentFloor.dispose()),this.currentFloor=t,this.scene.add(t);let e=t.getCenter();e&&(this.lights.position.x=e.x,this.lights.position.y=e.y)}getGraphicsByDeviceXy(t,e){var c;let i=new v.Vector2;i.x=t/this.container.clientWidth*2-1,i.y=e/this.container.clientHeight*-2+1;let n=new v.Raycaster;return n.setFromCamera(i,this.camera),((c=this.currentFloor)==null?void 0:c.graphicLayer.getGraphicByRaycaster(n))||{graphics:[],position:null}}getPoisByDeviceXy(t,e){var n;return((n=this.currentFloor)==null?void 0:n.poiLayer.getPoiByDeviceXy(t,e))||[]}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange)}setPolarAngle(t,e=500){return q(new Promise(i=>{let n={polar:this.control.getPolarAngle()},a={polar:t},c=new _.Tween(n,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxPolarAngle=n.polar,this.control.minPolarAngle=n.polar,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}getCameraLookAt(){return new v.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){return q(new Promise(n=>{let a={zoom:this.camera.zoom,target:this.control.target.clone()},c=this.getCameraLookAt(),p=new _.Tween(a,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(a.target.clone().sub(c)),this.control.target.copy(a.target),this.camera.zoom=a.zoom,this.control.update()}).onComplete(()=>{this.tweenGroup.remove(p),this.control.enabled=!0,n(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),i+500)}fitCameraToObject(t,e=[20,20,20,20],i=500){let[n,a,c,p]=e,{clientWidth:h,clientHeight:l}=this.container,d=new v.Box3().setFromObject(t),{max:g,min:m}=d,u=y(g,this.camera,h,l),b=y(m,this.camera,h,l),X=new v.Box2().setFromPoints([new v.Vector2(u.x,u.y),new v.Vector2(b.x,b.y)]).getSize(new v.Vector2),pt=(h-a-p)/X.x,W=(l-n-c)/X.y,w=Math.min(pt,W),ie=new v.Vector3((g.x+m.x)/2,(g.y+m.y)/2,g.z);return this.setZoom(w*this.camera.zoom,ie,i)}fitCameraToGround(t=[20,20,20,20],e=500){return this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundUpper,t,e):Promise.resolve(!1)}setCameraPosition(t,e){return q(new Promise(i=>{let n=this.camera.position.clone(),a=this.getCameraLookAt(),c=new _.Tween(n,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(n),this.control.target.copy(t.clone().add(a))}).onComplete(()=>{this.tweenGroup.remove(c),this.control.update(),this.control.enabled=!0,i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}render(){this.renderer.render(this.scene,this.camera),this.dispatchEvent({type:"update"}),this.timer.requestAnimationFrame(()=>{this.render()}),this.tweenGroup.update()}dispose(){this.selection.dispose(),this.hoverHelper.dispose(),this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll(),this.unRegistryEvent(),this.container.removeChild(this.renderer.domElement),this.timer.dispose(),this.renderer.dispose(),this.lights.children.forEach(t=>t.dispose()),O(this.scene)}};var Jt=require("lodash"),te={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:.9},svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:500}};function Tt(r){return(0,Jt.merge)({},te,r)}var Rt=class extends ee.EventDispatcher{constructor(t,e={}){super();this.container=t;o(this,"config");o(this,"context");o(this,"polarKeys",[]);o(this,"azimuthalKeys",[]);o(this,"svgLine");o(this,"svgPolygon");o(this,"basicZoom",1);o(this,"prevCameraZoom",1);o(this,"floorDataMap",new Map);o(this,"buildingGroundMap",new Map);o(this,"currentBuildGround",null);o(this,"onControlChange",()=>{let{camera:{zoom:t}}=this.context;t!==this.prevCameraZoom&&(this.dispatchEvent({type:"zoom-change",basicZoom:this.basicZoom,cameraZoom:this.context.camera.zoom}),this.prevCameraZoom=t)});o(this,"onKeydown",t=>{this.polarKeys.includes(t.code)&&(this.context.control.maxPolarAngle=this.config.control.maxPolar,this.context.control.minPolarAngle=0),this.azimuthalKeys.includes(t.code)&&(this.context.control.maxAzimuthAngle=1/0,this.context.control.minAzimuthAngle=1/0)});o(this,"onKeyUp",t=>{if(this.polarKeys.includes(t.code)){let e=this.context.control.getPolarAngle();this.context.control.maxPolarAngle=e,this.context.control.minPolarAngle=e}if(this.azimuthalKeys.includes(t.code)){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e,this.context.control.minAzimuthAngle=e}});this.config=Tt(e),this.context=new ht(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(h){return T(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:p}){let{apiDomain:l,apiPath:{floorGraphic:d},apiInfo:g}=this.config,m=`${l}${d}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${a}&ts=${c}&resource_type_list=${p}`;return yield fetch(m,g).then(b=>b.json()).then(b=>b.data).then(b=>((b||[]).map(E=>E.info=JSON.parse(E.info)),b||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:n}){return`${t}-${e}-${i}-${n}`}loadBuildingGround(a){return T(this,arguments,function*({brand:t,project:e,phase:i,building:n}){let c=this.getBuildingKey({brand:t,project:e,phase:i,building:n});if(this.buildingGroundMap.get(c))return this.buildingGroundMap.get(c)||null;let{apiDomain:p,apiPath:{floorRange:h},apiInfo:l}=this.config,d=`${p}${h}?brand=${t}&project=${e}&phase=${i}&building=${n}`,g=yield fetch(d,l).then(m=>m.json()).then(m=>m.data).then(m=>{let u=(m||[])[0];return u&&(u.info=JSON.parse(u.info)),u});return this.buildingGroundMap.set(c,g),g})}getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:p}){return`${t}-${e}-${i}-${n}-${a}-${c}-${p}`}load(h){return T(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:p}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:p});if(this.floorDataMap.get(l))return;let[d,g]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:p}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(g){let m=dt(g.info.geometry.cds[0]);d.forEach(u=>{if(u.info.geometry.type==="polygon")u.info.geometry.cds.map(b=>{Array.isArray(b)&&b.forEach(E=>{E[0]-=m[0],E[1]-=m[1]})});else{let[b,E]=u.info.geometry.cds;u.info.geometry.cds=[b-m[0],E-m[1]]}u.info.transformToBuildingGround=!0})}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(l,d),d})}createFloor(t){let e=new ot(this.context);if(!t.length)return{curFloor:e,graphics:[]};let i=t.filter(h=>h.info.group==="ground");i.forEach(h=>{h.info.fillColor="#F5F7F9",h.info.fillOpacity=1,h.info.strokeOpacity=0,h.info.height=5});let n=i.map(h=>new D(this.context,h.info));e.addGrounds(n);let a=t.filter(h=>h.info.group!=="ground");a.forEach((h,l)=>{h.info.airHeight=5,h.info.height=5+l*1e-4});let c=new Map,p=a.map(h=>{let l=e.addGraphic(h.info);return l.userData.data=h,c.set(h.legacy_id,l),l});return e.addShadow(),e.userData.legacyToGraphicMap=c,{curFloor:e,graphics:p}}switchFloor(h){return T(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:p}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:p}),d=this.floorDataMap.get(l);if(this.context.control.removeEventListener("change",this.onControlChange),d){let g=this.getBuildingKey({brand:t,project:e,phase:i,building:n});this.currentBuildGround=this.buildingGroundMap.get(g)||null;let m=this.createFloor(d);m?(this.context.switchFloor(m.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,yield this.context.fitCameraToGround(void 0,0),this.basicZoom=this.context.camera.zoom,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25,this.context.control.addEventListener("change",this.onControlChange),this.onControlChange()):console.warn("[switchFloor error] ["+a+"] \u697C\u5C42\u6CA1\u6709\u6570\u636E")}else console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42")})}addHeatmap(t){var e;return(e=this.context.currentFloor)==null?void 0:e.addHeatmap(t)}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.graphicLayer.children.filter(e=>e instanceof D))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);let i=t.getCenter();return this.context.currentFloor.addPoi(xt(z({},e),{position:xt(z({},i),{z:i.z+t.options.height/2})}))}return null}removeHeatMap(){var t;(t=this.context.currentFloor)==null||t.removeHeatMap()}translateElementToCenter(t,e=500){let i=t.position.clone().setFromMatrixPosition(t.matrixWorld);return this.context.setCameraPosition(i,e)}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:n}=this.container;return y(e,this.context.camera,i,n)}changeMapType(t,e=500){return t==="2d"?this.context.setPolarAngle(0,e):this.context.setPolarAngle(.9,e)}reduceMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp)}unRegistryEvent(){window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp)}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t=.1){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e+t,this.context.control.minAzimuthAngle=e+t,this.context.control.update()}measureDistance(){return T(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new rt(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",({distance:n})=>{t(n)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new st(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",({area:n})=>{t(n)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}getGraphicByNodeId(t){var e;return((e=this.context.currentFloor)==null?void 0:e.graphicLayer.getGraphicByNodeId(t))||null}deleteGraphic(t){var e;(e=this.context.currentFloor)==null||e.graphicLayer.removeGraphic(t)}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=dt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.cds.map(n=>{Array.isArray(n)&&n.forEach(a=>{a[0]-=i[0],a[1]-=i[1]})});else{let[n,a]=t.geometry.cds;t.geometry.cds=[n-i[0],a-i[1]]}}return(e=this.context.currentFloor)==null?void 0:e.graphicLayer.createGraphic(t)}removePoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.removePoiById(t)}getPoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.getPoiById(t)}getPois(){var t;return((t=this.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]}clearPoi(){this.context.currentFloor&&(this.getPois().forEach(t=>t.dispose()),this.context.currentFloor.poiLayer.clear())}removeSelectGraphic(t){this.context.selection.remove(t)}dispose(){this.context.dispose(),St(),Ft(),this.unRegistryEvent()}};
1
+ "use strict";var lt=Object.defineProperty,re=Object.defineProperties,se=Object.getOwnPropertyDescriptor,ae=Object.getOwnPropertyDescriptors,ce=Object.getOwnPropertyNames,Rt=Object.getOwnPropertySymbols;var kt=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var C=Math.pow,yt=(r,s,t)=>s in r?lt(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t,k=(r,s)=>{for(var t in s||(s={}))kt.call(s,t)&&yt(r,t,s[t]);if(Rt)for(var t of Rt(s))he.call(s,t)&&yt(r,t,s[t]);return r},xt=(r,s)=>re(r,ae(s));var le=(r,s)=>{for(var t in s)lt(r,t,{get:s[t],enumerable:!0})},pe=(r,s,t,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of ce(s))!kt.call(r,i)&&i!==t&&lt(r,i,{get:()=>s[i],enumerable:!(e=se(s,i))||e.enumerable});return r};var me=r=>pe(lt({},"__esModule",{value:!0}),r);var o=(r,s,t)=>(yt(r,typeof s!="symbol"?s+"":s,t),t);var F=(r,s,t)=>new Promise((e,i)=>{var n=l=>{try{c(t.next(l))}catch(h){i(h)}},a=l=>{try{c(t.throw(l))}catch(h){i(h)}},c=l=>l.done?e(l.value):Promise.resolve(l.value).then(n,a);c((t=t.apply(r,s)).next())});var ve={};le(ve,{BMap:()=>Tt,BaseSvg:()=>A,Context:()=>ht,Floor:()=>ot,Graphic:()=>D,GraphicLayer:()=>et,HeatmapElement:()=>nt,HoverHelper:()=>ct,Layer:()=>$,MapTypePolar:()=>ie,Overlay:()=>tt,Poi:()=>X,PoiLayer:()=>it,SelectBox:()=>Ft,Selection:()=>at,Shadow:()=>J,SvgLine:()=>rt,SvgPolygon:()=>st,Timer:()=>O,clearCanvas:()=>At,clearTextTexture:()=>St,createCanvas:()=>It,createCircle:()=>_,createLine:()=>Q,createRect:()=>I,createSvg:()=>zt,createSvgElement:()=>N,defaultConfig:()=>te,dispose:()=>z,getCenter:()=>mt,getConfig:()=>Ot,getTextureByText:()=>de,hasChinese:()=>Mt,initCamera:()=>Pt,initCanvas:()=>Ht,initControl:()=>Ct,initDirectionalLight:()=>Gt,initLight:()=>wt,initRenderer:()=>Et,initScene:()=>bt,initShape:()=>Lt,isContain:()=>Y,proxyOptions:()=>q,setCirclePosition:()=>T,setLineStartEnd:()=>L,setRectPosition:()=>G,sleepOnePromise:()=>dt,strToNumber:()=>ue,timeoutPromise:()=>j,vector3ToDevice:()=>x});module.exports=me(ve);var ee=require("three");var O=class{constructor(){o(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(s){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),s()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(s){this.tasks.requestAnimation.delete(s),window.cancelAnimationFrame(s)}setTimeout(s,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),s()},t);return this.tasks.timeout.add(e),e}clearTimeout(s){this.tasks.timeout.delete(s),window.clearTimeout(s)}setInterval(s,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),s()},t);return this.tasks.interval.add(e),e}clearInterval(s){this.tasks.interval.delete(s),window.clearInterval(s)}dispose(){this.tasks.requestAnimation.forEach(s=>{window.cancelAnimationFrame(s)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(s=>{window.clearTimeout(s)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(s=>{window.clearInterval(s)}),this.tasks.interval.clear()}};var g=require("three"),Bt=require("three/examples/jsm/controls/MapControls");function bt(){let r=new g.Scene;return r.background=new g.Color(16777215),r}function Et(){let r=new g.WebGLRenderer({antialias:!0});return r.setClearColor(16777215),r.setPixelRatio(window.devicePixelRatio),r.shadowMap.enabled=!0,r.shadowMap.autoUpdate=!0,r.shadowMap.type=g.PCFSoftShadowMap,r}function Pt(r,s){let t=new g.OrthographicCamera(-r/2,r/2,s/2,-s/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function wt(){let r=new g.Group,s=new g.HemisphereLight(16777215,16777215,2);s.intensity=1,s.position.set(0,0,10),s.up.set(0,0,1),r.add(s);let t=new g.AmbientLight(16777215,1);return r.add(t),r}function Ct(r,s){let t=new Bt.MapControls(r,s);return t.enableDamping=!1,t.zoomSpeed=2,t}function Lt(r,s=[]){let t=new g.Shape(r.map(e=>new g.Vector2(...e)));return s.length&&s.forEach(e=>{var i=new g.Path(e.map(n=>new g.Vector2(...n)));t.holes.push(i)}),t}function Gt(r=16777215,s=1){let t=new g.DirectionalLight(r,s);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(128,128),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function z(r,s){var t;if(s&&r.children&&r.children.length&&r.children.forEach(e=>{z(e,s)}),r.isMesh){let e=r;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}r.isLight&&((t=r.dispose)==null||t.call(r))}function Mt(r){return/[\u4E00-\u9FA5]+/g.test(r)}var H=require("three");var pt=new Map;function Ht(){let r=document.createElement("canvas");r.width=1024,r.height=64;let s=r.getContext("2d",{willReadFrequently:!0});return s.font="54px sans-serif",s.textBaseline="hanging",s.lineWidth=12,s.fillStyle="rgba(0,0,0,1)",s.strokeStyle="white",{canvas:r,ctx:s}}var Dt,B;function It(){if(!Dt){let{canvas:r,ctx:s}=Ht();Dt=r,B=s}}function de(r){if(pt.has(r))return pt.get(r);It(),B.clearRect(0,0,1024,64);let s=Mt(r)?4:8;B.strokeText(r,2,s),B.fillText(r,2,s);let t=Math.ceil(B.measureText(r).width);t=t%2===0?t:t+1,t+=2;let e=B.getImageData(0,0,t,64),i=new H.DataTexture(Uint8Array.from(e.data),t,64,H.RGBAFormat);return i.flipY=!0,i.minFilter=H.LinearFilter,i.magFilter=H.LinearFilter,pt.set(r,i),i}function St(){pt.clear()}function At(){B=null,Dt=null}var K=require("@turf/turf");function x(r,s,t,e){let i=r.clone().project(s),n=t/2,a=e/2,c=Math.round(i.x*n+n),l=Math.round(-i.y*a+a);return{x:c,y:l}}function mt(r){let s=(0,K.featureCollection)(r.map(e=>(0,K.point)(e)));return(0,K.center)(s).geometry.coordinates}function Y(r,s,t){return r.x>=s.x&&r.x<=t.x&&r.y>=s.y&&r.y<=t.y}function q(r,s){return new Proxy(r,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,n)=>{let a=Reflect.set(t,e,i,n);return s.dispatchEvent({type:`change-${e}`,value:i}),a}})}function j(r,s){return Promise.race([r,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),s)})])}function N(r){return document.createElementNS("http://www.w3.org/2000/svg",r)}function zt(r,s){let t=N("svg");return t.setAttribute("width",r),t.setAttribute("height",s),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function _(r="2",s){let t=N("circle");return t.setAttribute("r",r),t.setAttribute("fill",s),t}function Q(r){let s=N("line");return s.setAttribute("stroke",r),s}function I(r,s){let t=N("rect");return t.setAttribute("stroke",r),t.setAttribute("fill",s),t}function T(r,s,t){r.setAttribute("cx",`${s}`),r.setAttribute("cy",`${t}`)}function L(r,s,t){s&&(r.setAttribute("x1",`${s.x}`),r.setAttribute("y1",`${s.y}`)),t&&(r.setAttribute("x2",`${t.x}`),r.setAttribute("y2",`${t.y}`))}function G(r,s,t,e,i){r.setAttribute("x",`${s}`),r.setAttribute("y",`${t}`),r.setAttribute("width",`${e}`),r.setAttribute("height",`${i}`)}function dt(){return Promise.resolve()}function ue(r){return parseInt(r.replace("#","0x"),16)}var v=require("three"),U=require("@tweenjs/tween.js");var Nt=require("three");var b=require("three");var Vt=require("lodash"),$t=require("three/examples/jsm/lines/LineMaterial.js"),Ut=require("three/examples/jsm/lines/LineSegmentsGeometry.js"),Kt=require("three/examples/jsm/lines/LineSegments2.js");var ge={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0},D=class extends b.Object3D{constructor(t,e){super();this.context=t;o(this,"geometry");o(this,"material");o(this,"mesh");o(this,"line");o(this,"options");if(this.options=q((0,Vt.merge)({},ge,e),this),this.options.geometry.type==="point"){let[i,n]=this.options.geometry.cds;return this.position.set(i,n,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.material.color=new b.Color(i)}),this.addEventListener("change-fillOpacity",({value:i})=>{this.material.opacity=i}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.line.material.color=new b.Color(i)}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.line.material.opacity=i}),this.addEventListener("change-strokeWidth",({value:i})=>{this.line.material.linewidth=i}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i})}getCenter(){if(this.options.geometry.type==="point")return this.position;let t=new b.Vector3,e=new b.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new b.Vector3(0,0,0);let t=new b.Box3,e=new b.Vector3;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height),t}init(){this.geometry=this.initGeometry(),this.material=this.initMaterial(),this.mesh=this.initMesh(),this.mesh.position.z=this.options.airHeight,this.mesh.castShadow=!0,this.add(this.mesh),this.line=this.createBorder(),this.add(this.line)}initGeometry(){let t=Lt(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new b.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){return new b.MeshStandardMaterial({color:this.options.fillColor,roughness:1,transparent:!0,opacity:this.options.fillOpacity,depthWrite:!0})}initLineMaterial(){let t=new $t.LineMaterial({color:new b.Color(this.options.strokeColor).getHex(),opacity:this.options.strokeOpacity,transparent:!0,depthWrite:!0,linewidth:this.options.strokeWidth,wireframe:!1,dashed:!1}),{clientSize:{width:e,height:i}}=this.context;return t.resolution.set(e,i),t}initMesh(){return new b.Mesh(this.geometry,this.material)}createBorder(){let t=this.initLineMaterial(),e=new b.EdgesGeometry(this.geometry),i=new Ut.LineSegmentsGeometry;i.fromEdgesGeometry(e);let n=new Kt.LineSegments2(i,t);return n.position.z=this.options.airHeight,n}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:n}=e[0];return{position:i,distance:n}}return!1}dispose(){z(this),this.clear()}};var M=require("three");var J=class extends M.Object3D{constructor(){super();o(this,"directionalLight");o(this,"plane");o(this,"basicOpacity",.15);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Gt(16777215,1);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new M.Color(t)}setPosition(t){this.position.copy(t),this.directionalLight.position.set(-t.x/2,-t.y/2,100)}initPlane(t=1e3,e=1e3){let i=new M.PlaneGeometry(t,e),n=new M.ShadowMaterial({transparent:!0,opacity:0,side:M.DoubleSide}),a=new M.Mesh(i,n);return a.receiveShadow=!0,a.position.z=-10,this.add(a),this.plane=a,a}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){z(this,!0)}};var jt=require("three"),_t=require("lodash");var V=require("three");var tt=class extends V.EventDispatcher{constructor(t){super();this.context=t;o(this,"div");o(this,"element");o(this,"position",new V.Vector3);o(this,"clientPos",{x:0,y:0});o(this,"visible",!0);o(this,"onUpdate",()=>{let t=this.getPosition(),{width:e,height:i}=this.context.clientSize,{x:n,y:a}=x(t,this.context.camera,e,i);this.clientPos.x===n&&this.clientPos.y===a||(this.clientPos={x:n,y:a},this.div.style.left=`${n}px`,this.div.style.top=`${a}px`)});this.registryEvent(),this.div=this.initDiv(),this.context.container.appendChild(this.div)}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}bindElement(t){this.element=t,this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,e="block"){t!==this.visible&&(this.div.style.display=t?e:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new V.Box3().setFromObject(this.element).getCenter(new V.Vector3):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:n}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=n}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.context.container.removeChild(this.div),this.div=null}};var fe={text:"",level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0}},X=class extends jt.Object3D{constructor(t,e){var i,n,a;super();this.context=t;o(this,"textDiv");o(this,"img");o(this,"overlay");o(this,"options");o(this,"size",{width:0,height:0});o(this,"_changePosition",()=>{this.overlay.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=q((0,_t.merge)({},fe,e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((n=e.position)==null?void 0:n.y)||0,((a=e.position)==null?void 0:a.z)||0),this.overlay=new tt(this.context),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):this.overlay.div.appendChild(this.initIcon()):(this.img&&this.overlay.div.removeChild(this.img),this.img=void 0,this.resetSize())}),this.addEventListener("change-text",({value:c})=>{this.overlay.div.removeChild(this.textDiv),this.overlay.div.appendChild(this.initText()),this.resetSize()}),this.addEventListener("change-opacity",({value:c})=>{this.overlay.setOpacity(c)}),this.addEventListener("change-icon_size",({value:c})=>{this.img&&(this.img.style.width=`${(c==null?void 0:c[0])||32}px`,this.img.style.height=`${(c==null?void 0:c[1])||32}px`,this.resetSize())})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return F(this,null,function*(){let t=this.overlay.visible;this.setVisible(!0),yield dt();let{width:e,height:i}=this.overlay.div.getBoundingClientRect();this.size={width:e,height:i},yield dt(),this._changePosition(),this.setVisible(t)})}get clientPos(){return this.overlay.clientPos}initDiv(){let t=this.overlay.div;return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.pointerEvents="none",this.overlay.setOpacity(this.options.opacity),this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.background="rgba(255, 255, 255, .7)",t.style.padding="2px",t.style.borderRadius="4px",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.text.split(`\r
2
+ `).forEach(e=>{let i=document.createElement("div");i.style.whiteSpace="nowrap",i.textContent=e,t.appendChild(i)}),t}initIcon(){var e,i;let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${((e=this.options.icon_size)==null?void 0:e[0])||32}px`,t.style.height=`${((i=this.options.icon_size)==null?void 0:i[1])||32}px`,t.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){this.overlay.setVisible(t,"flex")}getBox(){let{width:t,height:e}=this.size,{x:i,y:n}=this.overlay.clientPos;return{left:i-t/2,right:i+t/2,top:this.options.icon?n-e:n-e/2,bottom:this.options.icon?n:n+e/2}}isContain(t,e){if(!this.overlay.visible)return!1;let i=this.getBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var S=require("three");var ut=require("three");var Xt=require("three");var $=class extends Xt.Object3D{constructor(t){super();this.context=t}dispose(){z(this),this.clear()}};var et=class extends ${constructor(t){super(t);o(this,"graphicMap",new Map)}getCenter(){return new ut.Box3().setFromObject(this).getCenter(new ut.Vector3)}createGraphic(t){let e=new D(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((n,a)=>{if(a instanceof D){let c=a.raycast(t);if(c){let{distance:l}=c;if(l<n.distance)return{distance:n.distance,position:n.position,graphic:a}}return n}else return n},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var Wt=require("lodash");var it=class extends ${constructor(t){super(t);o(this,"pois",[]);o(this,"debounceCollisionDetection");o(this,"timer",new O);o(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=(0,Wt.debounce)(this.collisionDetection,10)}clear(){return super.clear(),this.pois=[],this}createPoi(t){let e=new X(this.context,t);return this.add(e),this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.remove(t),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===1){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.children.filter(n=>n instanceof X&&n.isContain(t,e))}collisionDetection(){let{clientSize:{width:t,height:e}}=this.context,i=[];this.pois.filter(a=>a.withinDisplayRange).forEach((a,c)=>{let{left:l,right:h,top:p,bottom:u}=a.getBox();if(c===0){i.push({left:l,right:h,top:p,bottom:u});return}let f=i.some(m=>h<m.right&&h>m.left||l>m.left&&l<m.right||l===m.left&&h===m.right?u<=m.bottom&&u>m.top||p>=m.top&&p<m.bottom:!1);a.setVisible(!f),i.push({left:l,right:h,top:p,bottom:u})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var P=require("three"),Zt=require("@mars3d/heatmap.js"),R=require("@turf/turf");var nt=class extends P.Object3D{constructor(t){super();this.context=t;o(this,"heatmap");o(this,"div");o(this,"plane");this.div=document.createElement("div")}clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:n,center:a}=this.getBox(t);this.heatmap=(0,Zt.create)(k({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,n)),this.initPlane(e,i),this.position.set(a[0],a[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new P.PlaneGeometry(t,e),n=new P.Texture(this.div.firstChild);n.needsUpdate=!0;let a=new P.MeshBasicMaterial({transparent:!0,side:P.DoubleSide,map:n});a.needsUpdate=!0,this.plane=new P.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new P.Matrix3().makeScale(1,-1).multiply(new P.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new P.Vector2(a.x,a.y).applyMatrix3(i);return{x:c.x,y:c.y,value:a.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,R.featureCollection)(t.data.map(h=>(0,R.point)([h.x,h.y]))),i=(0,R.bbox)(e),n=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},l=(0,R.center)(e);return{width:n,height:a,leftTop:c,center:l.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var ot=class extends S.Object3D{constructor(t){super();this.context=t;o(this,"graphicLayer");o(this,"poiLayer");o(this,"grounds",new Set);o(this,"shadow",new J);o(this,"heatmap");o(this,"groundUpper",new S.Object3D);o(this,"groundMaxHeight",0);this.graphicLayer=new et(this.context),this.poiLayer=new it(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper)}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.options.height+=e.options.zIndex/1e5,this.grounds.add(e),this.groundUpper.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new S.Box3().setFromObject(this.groundUpper).getCenter(new S.Vector3)}addShadow(){let t=new S.Box3().setFromObject(this.groundUpper),e=t.getCenter(new S.Vector3),i=t.getSize(new S.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i),this.add(this.shadow)}addGraphic(t){return t.height+=(t.height||0)/1e5,this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new nt(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new S.Box3().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}dispose(){var t;this.shadow.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.grounds.forEach(e=>e.dispose()),(t=this.heatmap)==null||t.dispose(),this.groundUpper.clear(),this.clear()}};var gt=require("three");var A=class extends gt.EventDispatcher{constructor(t){super();this.context=t;o(this,"points",[]);o(this,"svg");o(this,"enable",!0);this.svg=zt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:n,offsetY:a}=t,{clientWidth:c,clientHeight:l}=i.domElement,h=n/c*2-1,p=1-a/l*2;return new gt.Vector3(h,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return x(t,e,i.clientWidth,i.clientHeight)}dispose(){this.context.container.removeChild(this.svg),this.svg=null}};var rt=class extends A{constructor(t){super(t);this.context=t;o(this,"circles");o(this,"line");o(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);T(this.circles[0],t.x,t.y),L(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);T(this.circles[1],t.x,t.y),L(this.line,void 0,t)}});o(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",L(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});o(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});o(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t,a=this.circles[this.points.length];T(a,i,n),this.points.length||L(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[_(e.radius,e.fill),_(e.radius,e.fill)],this.line=Q(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:n}]=this.points;return Math.sqrt(C(i-t,2)+C(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var st=class extends A{constructor(t){super(t);o(this,"circles",[]);o(this,"lines",[]);o(this,"isClose",!1);o(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&T(this.circles[e],i.x,i.y),e!==0&&L(this.lines[e-1],void 0,i),this.lines[e]&&L(this.lines[e],i)})});o(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",L(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});o(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});o(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t;this.checkAdsorb(i,n)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:a,radius:c},line:{stroke:l}}=this.context.config.svg;if(!this.isClose){let h=_(c,a);T(h,i,n),this.addCircle(h)}if(this.lines.length&&L(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let h=Q(l);L(h,{x:i,y:n},{x:i,y:n}),this.addLine(h)}}});this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],n=+i.getAttribute("cx"),a=+i.getAttribute("cy");return Math.sqrt(C(t-n,2)+C(e-a,2))<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(n=>[n.x,n.y]),e=0,i=t.length;for(let n=0;n<i;n++){let a=(n+1)%i;e+=t[n][0]*t[a][1]-t[a][0]*t[n][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var Yt=require("three");var Ft=class extends A{constructor(t){super(t);this.context=t;o(this,"rect");o(this,"cornerRect",[]);o(this,"centerRect",[]);o(this,"graphic");o(this,"onUpdate",()=>{if(this.graphic){let t=new Yt.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:n}}=this.context,{min:a,max:c}=t,l=x(a,e,i,n),h=x(c,e,i,n);G(this.rect,l.x,h.y,Math.abs(h.x-l.x),Math.abs(h.y-l.y));let{x:p,y:u}=l,{x:f,y:m}=h,d=5,E=[{x:p-d,y:m-d},{x:f-d,y:m-d},{x:p-d,y:u-d},{x:f-d,y:u-d}];for(let w=0;w<E.length;w++)G(this.cornerRect[w],E[w].x,E[w].y,d*2,d*2);let y=4,vt=(p+f)/2,W=(u+m)/2,Z=[{x:vt-y,y:m-y},{x:p-y,y:W-y},{x:f-y,y:W-y},{x:vt-y,y:u-y}];for(let w=0;w<Z.length;w++)G(this.centerRect[w],Z[w].x,Z[w].y,y*2,y*2)}else{G(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)G(this.cornerRect[t],0,0,0,0),G(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=I(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=I(e.stroke,"#ffffff"),this.centerRect[i]=I(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};var qt=require("three");var ft=class extends A{constructor(t){super(t);o(this,"startPoint");o(this,"endPoint");o(this,"rect");o(this,"frustum",new qt.Frustum);o(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});o(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});o(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});o(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=k({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},n=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);G(this.rect,i.x,i.y,n,a)}else G(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=I(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),G(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:i,clientHeight:n}}}=this,a=x(this.startPoint,e,i,n),c=x(this.endPoint,e,i,n),l={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},h={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},p=this.searchMapInFrustum(l,h);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(a=>a instanceof D&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let m=t.getPosition();if(m){let d=x(m,n,a,c);return Y(d,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let l=t.mesh.geometry.boundingBox;if(!l)return!1;let{min:h,max:p}=l,u=x(h,n,a,c),f=x(p,n,a,c);return!(!Y(u,e,i)||!Y(f,e,i))}dispose(){this.unRegistryEvent()}};var at=class extends Nt.EventDispatcher{constructor(t){super();this.context=t;o(this,"_list",new Set);o(this,"boxSelection");o(this,"prevPanStatus");o(this,"prevRotateStatus");o(this,"downPoint",null);o(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});o(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:n,y:a}=this.downPoint;if(Math.sqrt(C(n-e,2)+C(a-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),l=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var u;if(!l.has(p.options.id)){let f=((u=this.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(p.options.id))||null;f&&(c.push(f),l.add(p.options.id))}}),t.ctrlKey||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});o(this,"onKeyDown",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)});o(this,"onKeyUp",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)});o(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new ft(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list]})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),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()}};var Qt=require("three");var ct=class extends Qt.EventDispatcher{constructor(t){super();this.context=t;o(this,"curGraphics",new Set);o(this,"timer",new O);o(this,"graphicTimerMap",new Map);o(this,"onPointerMove",({graphics:t})=>{if(!t.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:e}=this.context.config.hover;t.forEach(n=>{if(this.graphicTimerMap.get(n)||this.curGraphics.has(n))return;let a=this.timer.setTimeout(()=>{this.curGraphics.add(n),this.handleHoverGraphicsChange()},e);this.graphicTimerMap.set(n,a)}),this.graphicTimerMap.forEach((n,a)=>{t.includes(a)||(this.timer.clearTimeout(n),this.graphicTimerMap.delete(a))});let i=this.curGraphics.size;this.curGraphics.forEach(n=>{t.includes(n)||this.curGraphics.delete(n)}),i!==this.curGraphics.size&&this.handleHoverGraphicsChange()});o(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(this.curGraphics)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel)}dispose(){this.unRegistryEvent(),this.timer.dispose()}};var ht=class extends v.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;o(this,"scene",bt());o(this,"renderer",Et());o(this,"camera");o(this,"control");o(this,"lights",wt());o(this,"timer",new O);o(this,"tweenGroup",new U.Group);o(this,"currentFloor");o(this,"selection");o(this,"hoverHelper");o(this,"basicRatio");o(this,"clientSize",{width:0,height:0});o(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:n,clientHeight:a}=t;e.left=-n/2,e.right=n/2,e.top=a/2,e.bottom=-a/2,e.updateProjectionMatrix(),i.setSize(n,a),this.resizeClientSize(n,a)});o(this,"onClick",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY);e.length&&this.dispatchEvent({type:"graphic-click",graphics:e,position:i});let n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);n.length&&this.dispatchEvent({type:"poi-click",pois:n})});o(this,"onPointerover",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-over",graphics:e,pois:n,position:i})});o(this,"onPointermove",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.offsetX,t.offsetY);this.dispatchEvent({type:"pointer-move",graphics:e,pois:n,position:i})});o(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});o(this,"onSelectionSelect",({graphics:t})=>{this.dispatchEvent({type:"select-graphic",graphics:t})});o(this,"onHoverChange",({graphics:t})=>{this.dispatchEvent({type:"hover",graphics:t})});this.container.style.position="relative",this.container.style.overflow="hidden",this.init(),this.selection=new at(this),this.hoverHelper=new ct(this),this.resizeClientSize(),this.registryEvent()}resizeClientSize(t,e){this.clientSize={width:t||this.container.clientWidth,height:e||this.container.clientHeight}}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=Pt(t,e),this.renderer.setSize(t,e),this.control=Ct(this.camera,this.renderer.domElement),this.control.maxPolarAngle=this.config.control.maxPolar,this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",()=>{var n;let i=this.control.getPolarAngle();(n=this.currentFloor)==null||n.setShadowOpacity(i/this.config.control.maxPolar),this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom}),this.dispatchEvent({type:"control-change"})})}getRatio(t=new v.Vector3(0,0,0),e=new v.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,a=x(t,this.camera,i,n),c=x(e,this.camera,i,n);return Math.ceil(Math.sqrt(C(c.x-a.x,2)+C(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof v.AmbientLight&&(e.color=new v.Color(t))})}switchFloor(t){this.currentFloor&&(this.scene.remove(this.currentFloor),this.currentFloor.dispose()),this.currentFloor=t,this.scene.add(t);let e=t.getCenter();e&&(this.lights.position.x=e.x,this.lights.position.y=e.y)}getGraphicsByDeviceXy(t,e){var c;let i=new v.Vector2;i.x=t/this.container.clientWidth*2-1,i.y=e/this.container.clientHeight*-2+1;let n=new v.Raycaster;return n.setFromCamera(i,this.camera),((c=this.currentFloor)==null?void 0:c.graphicLayer.getGraphicByRaycaster(n))||{graphics:[],position:null}}getPoisByDeviceXy(t,e){var n;return((n=this.currentFloor)==null?void 0:n.poiLayer.getPoiByDeviceXy(t,e))||[]}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange)}setPolarAngle(t,e=500){return e===0?(this.control.maxPolarAngle=t,this.control.minPolarAngle=t,this.control.update(),this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,Promise.resolve()):j(new Promise(i=>{let n={polar:this.control.getPolarAngle()},a={polar:t},c=new U.Tween(n,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxPolarAngle=n.polar,this.control.minPolarAngle=n.polar,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxPolarAngle=this.config.control.maxPolar,this.control.minPolarAngle=0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}setAzimuthalAngle(t,e=500){return e===0?(this.control.maxAzimuthAngle=t,this.control.minAzimuthAngle=t,this.control.update(),this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0,Promise.resolve()):j(new Promise(i=>{let n={azimuthal:this.control.getAzimuthalAngle()},a={azimuthal:t},c=new U.Tween(n,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxAzimuthAngle=n.azimuthal,this.control.minAzimuthAngle=n.azimuthal,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.control.maxAzimuthAngle=1/0,this.control.minAzimuthAngle=1/0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}getCameraLookAt(){return new v.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){return j(new Promise(n=>{let a={zoom:this.camera.zoom,target:this.control.target.clone()},c=this.getCameraLookAt(),l=new U.Tween(a,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(a.target.clone().sub(c)),this.control.target.copy(a.target),this.camera.zoom=a.zoom,this.control.update()}).onComplete(()=>{this.tweenGroup.remove(l),this.control.enabled=!0,n(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),i+500)}fitCameraToObject(t,e=[20,20,20,20],i=500){let[n,a,c,l]=e,{clientSize:{width:h,height:p}}=this,u=this.control.getPolarAngle();this.setPolarAngle(0,0);let f=new v.Box3().setFromObject(t);this.setPolarAngle(u,0);let{max:m,min:d}=f,E=x(m,this.camera,h,p),y=x(d,this.camera,h,p),W=new v.Box2().setFromPoints([new v.Vector2(E.x,E.y),new v.Vector2(y.x,y.y)]).getSize(new v.Vector2),Z=(h-a-l)/W.x,w=(p-n-c)/W.y,ne=Math.min(Z,w),oe=new v.Vector3((m.x+d.x)/2,(m.y+d.y)/2,m.z);return this.setZoom(ne*this.camera.zoom,oe,i)}fitCameraToGround(t=[20,20,20,20],e=500){return this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundUpper,t,e):Promise.resolve(!1)}setCameraPosition(t,e){return j(new Promise(i=>{let n=this.camera.position.clone(),a=this.getCameraLookAt(),c=new U.Tween(n,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(n),this.control.target.copy(t.clone().add(a))}).onComplete(()=>{this.tweenGroup.remove(c),this.control.update(),this.control.enabled=!0,i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}render(){this.renderer.render(this.scene,this.camera),this.dispatchEvent({type:"update"}),this.timer.requestAnimationFrame(()=>{this.render()}),this.tweenGroup.update()}dispose(){this.selection.dispose(),this.hoverHelper.dispose(),this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll(),this.unRegistryEvent(),this.container.removeChild(this.renderer.domElement),this.timer.dispose(),this.renderer.dispose(),this.lights.children.forEach(t=>t.dispose()),z(this.scene)}};var Jt=require("lodash"),te={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:.9},svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:500}};function Ot(r){return(0,Jt.merge)({},te,r)}var ie=(t=>(t[t.D2=0]="D2",t[t.D3=.9]="D3",t))(ie||{}),Tt=class extends ee.EventDispatcher{constructor(t,e={}){super();this.container=t;o(this,"config");o(this,"context");o(this,"polarKeys",[]);o(this,"azimuthalKeys",[]);o(this,"svgLine");o(this,"svgPolygon");o(this,"basicZoom",1);o(this,"prevCameraZoom",1);o(this,"type","2d");o(this,"floorDataMap",new Map);o(this,"buildingGroundMap",new Map);o(this,"currentBuildGround",null);o(this,"onControlChange",()=>{let{camera:{zoom:t}}=this.context;t!==this.prevCameraZoom&&(this.dispatchEvent({type:"zoom-change",basicZoom:this.basicZoom,cameraZoom:this.context.camera.zoom}),this.prevCameraZoom=t)});o(this,"onKeydown",t=>{this.polarKeys.includes(t.code)&&(this.context.control.maxPolarAngle=this.config.control.maxPolar,this.context.control.minPolarAngle=0),this.azimuthalKeys.includes(t.code)&&(this.context.control.maxAzimuthAngle=1/0,this.context.control.minAzimuthAngle=1/0)});o(this,"onKeyUp",t=>{if(this.polarKeys.includes(t.code)){let e=this.context.control.getPolarAngle();this.context.control.maxPolarAngle=e,this.context.control.minPolarAngle=e}if(this.azimuthalKeys.includes(t.code)){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e,this.context.control.minAzimuthAngle=e}});this.config=Ot(e),this.context=new ht(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(h){return F(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:l}){let{apiDomain:p,apiPath:{floorGraphic:u},apiInfo:f}=this.config,m=`${p}${u}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${a}&ts=${c}&resource_type_list=${l}`;return yield fetch(m,f).then(E=>E.json()).then(E=>E.data).then(E=>((E||[]).map(y=>y.info=JSON.parse(y.info)),E||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:n}){return`${t}-${e}-${i}-${n}`}loadBuildingGround(a){return F(this,arguments,function*({brand:t,project:e,phase:i,building:n}){let c=this.getBuildingKey({brand:t,project:e,phase:i,building:n});if(this.buildingGroundMap.get(c))return this.buildingGroundMap.get(c)||null;let{apiDomain:l,apiPath:{floorRange:h},apiInfo:p}=this.config,u=`${l}${h}?brand=${t}&project=${e}&phase=${i}&building=${n}`,f=yield fetch(u,p).then(m=>m.json()).then(m=>m.data).then(m=>{let d=(m||[])[0];return d&&(d.info=JSON.parse(d.info)),d});return this.buildingGroundMap.set(c,f),f})}getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:l}){return`${t}-${e}-${i}-${n}-${a}-${c}-${l}`}load(h){return F(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:l}){let p=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:l});if(this.floorDataMap.get(p))return;let[u,f]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:l}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(f){let m=mt(f.info.geometry.cds[0]);u.forEach(d=>{if(d.info.geometry.type==="polygon")d.info.geometry.cds.map(E=>{Array.isArray(E)&&E.forEach(y=>{y[0]-=m[0],y[1]-=m[1]})});else{let[E,y]=d.info.geometry.cds;d.info.geometry.cds=[E-m[0],y-m[1]]}d.info.transformToBuildingGround=!0})}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(p,u),u})}createFloor(t){let e=new ot(this.context);if(!t.length)return{curFloor:e,graphics:[]};let i=t.filter(h=>h.info.group==="ground");i.forEach(h=>{h.info.fillColor="#F5F7F9",h.info.fillOpacity=1,h.info.strokeOpacity=0,h.info.height=5});let n=i.map(h=>new D(this.context,h.info));e.addGrounds(n);let a=t.filter(h=>h.info.group!=="ground");a.forEach((h,p)=>{h.info.height=5});let c=new Map,l=a.map(h=>{let p=e.addGraphic(h.info);return p.userData.data=h,c.set(h.legacy_id,p),p});return e.addShadow(),e.userData.legacyToGraphicMap=c,{curFloor:e,graphics:l}}switchFloor(h){return F(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:l}){let p=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:l}),u=this.floorDataMap.get(p);if(this.context.control.removeEventListener("change",this.onControlChange),u){let f=this.getBuildingKey({brand:t,project:e,phase:i,building:n});this.currentBuildGround=this.buildingGroundMap.get(f)||null;let m=this.createFloor(u);m?(this.context.switchFloor(m.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,yield this.context.setAzimuthalAngle(0,0),yield this.context.fitCameraToGround(void 0,0),this.basicZoom=this.context.camera.zoom,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25,this.context.control.addEventListener("change",this.onControlChange),this.onControlChange()):console.warn("[switchFloor error] ["+a+"] \u697C\u5C42\u6CA1\u6709\u6570\u636E")}else console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42")})}addHeatmap(t){var e;return(e=this.context.currentFloor)==null?void 0:e.addHeatmap(t)}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.graphicLayer.children.filter(e=>e instanceof D))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);let i=t.getCenter();return this.context.currentFloor.addPoi(xt(k({},e),{position:xt(k({},i),{z:i.z+t.options.height/2})}))}return null}removeHeatMap(){var t;(t=this.context.currentFloor)==null||t.removeHeatMap()}translateElementToCenter(t,e=500){let i=t.position.clone().setFromMatrixPosition(t.matrixWorld);return this.context.setCameraPosition(i,e)}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:n}=this.container;return x(e,this.context.camera,i,n)}changeMapType(t,e=500){return this.type=t,t==="2d"?this.context.setPolarAngle(0,e):this.context.setPolarAngle(.9,e)}resetView(t=300){return F(this,null,function*(){let e=t/3;yield this.context.setAzimuthalAngle(0,e),yield this.changeMapType(this.type,e),yield this.context.fitCameraToGround(void 0,e)})}reduceMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp)}unRegistryEvent(){window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp)}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t=.1){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e+t,this.context.control.minAzimuthAngle=e+t,this.context.control.update()}measureDistance(){return F(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new rt(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",({distance:n})=>{t(n)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new st(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",({area:n})=>{t(n)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}getGraphicByNodeId(t){var e;return((e=this.context.currentFloor)==null?void 0:e.graphicLayer.getGraphicByNodeId(t))||null}deleteGraphic(t){var e;(e=this.context.currentFloor)==null||e.graphicLayer.removeGraphic(t)}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=mt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.cds.map(n=>{Array.isArray(n)&&n.forEach(a=>{a[0]-=i[0],a[1]-=i[1]})});else{let[n,a]=t.geometry.cds;t.geometry.cds=[n-i[0],a-i[1]]}}return(e=this.context.currentFloor)==null?void 0:e.graphicLayer.createGraphic(t)}removePoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.removePoiById(t)}getPoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.getPoiById(t)}getPois(){var t;return((t=this.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]}clearPoi(){this.context.currentFloor&&(this.getPois().forEach(t=>t.dispose()),this.context.currentFloor.poiLayer.clear())}removeSelectGraphic(t){this.context.selection.remove(t)}dispose(){this.context.dispose(),St(),At(),this.unRegistryEvent()}};
3
3
  //# sourceMappingURL=bmap.cjs.min.js.map